return value( currentSection(), name, val );
}
+bool QtxResourceMgr::value( const QString& name, QFont& val ) const
+{
+ return value( currentSection(), name, val );
+}
+
bool QtxResourceMgr::value( const QString& name, QString& val, const bool subst ) const
{
return value( currentSection(), name, val, subst );
return res;
}
+bool QtxResourceMgr::value( const QString& sect, const QString& name, QFont& fVal ) const
+{
+ QString val = stringValue( sect, name, "" ).stripWhiteSpace();
+ QStringList font_values = QStringList::split( val, "," );
+ if( font_values.count()<2 || font_values.count()>4 )
+ return false;
+
+ QString family = font_values[0];
+ bool isBold = false, isItalic = false, isOk = false;
+ int pSize = -1;
+ for( int i=1, n=font_values.count(); i<n; i++ )
+ {
+ if( !isBold && font_values[i].lower()=="bold" )
+ isBold = true;
+ else if( !isItalic && font_values[i].lower()=="italic" )
+ isItalic = true;
+ else if( pSize<0 )
+ {
+ pSize = font_values[i].toInt( &isOk );
+ if( !isOk )
+ pSize = -1;
+ }
+ }
+
+ if( pSize>0 && !family.isEmpty() )
+ {
+ fVal = QFont( family, pSize );
+ fVal.setBold( isBold );
+ fVal.setItalic( isItalic );
+ return true;
+ }
+ else
+ return false;
+}
+
bool QtxResourceMgr::value( const QString& sect, const QString& name, QString& val, const bool subst ) const
{
initialize();
return booleanValue( currentSection(), name, def );
}
+QFont QtxResourceMgr::fontValue( const QString& name, const QFont& def ) const
+{
+ return fontValue( currentSection(), name, def );
+}
+
QColor QtxResourceMgr::colorValue( const QString& name, const QColor& def ) const
{
return colorValue( currentSection(), name, def );
return val;
}
+QFont QtxResourceMgr::fontValue( const QString& sect, const QString& name, const QFont& def ) const
+{
+ QFont font;
+ if( !value( sect, name, font ) )
+ font = def;
+ return font;
+}
+
QColor QtxResourceMgr::colorValue( const QString& sect, const QString& name, const QColor& def ) const
{
QColor val;
setValue( currentSection(), name, val );
}
+void QtxResourceMgr::setValue( const QString& name, const QFont& val )
+{
+ setValue( currentSection(), name, val );
+}
+
void QtxResourceMgr::setValue( const QString& name, const QString& val )
{
setValue( currentSection(), name, val );
setValue( sect, name, QString( "%1, %2, %3").arg( val.red() ).arg( val.green() ).arg( val.blue() ) );
}
+void QtxResourceMgr::setValue( const QString& sect, const QString& name, const QFont& f )
+{
+ QStringList val;
+ val.append( f.family() );
+ if( f.bold() )
+ val.append( "Bold" );
+ if( f.italic() )
+ val.append( "Italic" );
+ val.append( QString( "%1" ).arg( f.pointSize() ) );
+
+ setValue( sect, name, val.join( "," ) );
+}
+
void QtxResourceMgr::setValue( const QString& sect, const QString& name, const QString& val )
{
initialize();
#include <qmap.h>
#include <qcolor.h>
+#include <qfont.h>
#include <qpixmap.h>
#include <qstringlist.h>
#include <qtranslator.h>
bool value( const QString&, double& ) const;
bool value( const QString&, bool& ) const;
bool value( const QString&, QColor& ) const;
+ bool value( const QString&, QFont& ) const;
bool value( const QString&, QString&, const bool = true ) const;
bool value( const QString&, const QString&, int& ) const;
bool value( const QString&, const QString&, double& ) const;
bool value( const QString&, const QString&, bool& ) const;
bool value( const QString&, const QString&, QColor& ) const;
+ bool value( const QString&, const QString&, QFont& ) const;
bool value( const QString&, const QString&, QString&, const bool = true ) const;
int integerValue( const QString&, const int = 0 ) const;
- double doubleValue( const QString&, const double = 0 ) const;
+ double doubleValue ( const QString&, const double = 0 ) const;
bool booleanValue( const QString&, const bool = false ) const;
- QColor colorValue( const QString&, const QColor& = QColor() ) const;
- QString stringValue( const QString&, const char* = 0 ) const;
+ QColor colorValue ( const QString&, const QColor& = QColor() ) const;
+ QFont fontValue ( const QString&, const QFont& = QFont() ) const;
+ QString stringValue ( const QString&, const char* = 0 ) const;
int integerValue( const QString&, const QString&, const int = 0 ) const;
- double doubleValue( const QString&, const QString&, const double = 0 ) const;
+ double doubleValue ( const QString&, const QString&, const double = 0 ) const;
bool booleanValue( const QString&, const QString&, const bool = false ) const;
- QColor colorValue( const QString&, const QString&, const QColor& = QColor() ) const;
- QString stringValue( const QString&, const QString&, const char* = 0 ) const;
+ QColor colorValue ( const QString&, const QString&, const QColor& = QColor() ) const;
+ QFont fontValue ( const QString&, const QString&, const QFont& = QFont() ) const;
+ QString stringValue ( const QString&, const QString&, const char* = 0 ) const;
bool hasSection( const QString& ) const;
bool hasValue( const QString& ) const;
void setValue( const QString&, const double );
void setValue( const QString&, const bool );
void setValue( const QString&, const QColor& );
+ void setValue( const QString&, const QFont& );
void setValue( const QString&, const QString& );
void setValue( const QString&, const QString&, const int );
void setValue( const QString&, const QString&, const double );
void setValue( const QString&, const QString&, const bool );
void setValue( const QString&, const QString&, const QColor& );
+ void setValue( const QString&, const QString&, const QFont& );
void setValue( const QString&, const QString&, const QString& );
void remove( const QString& );