#include <qobjectlist.h>
#include <qcolordialog.h>
#include <qwidgetstack.h>
+#include <qpushbutton.h>
+#include <qfontdialog.h>
#include "QtxIntSpinBox.h"
#include "QtxDblSpinBox.h"
case Space:
item = new Spacer( resourceEdit(), this, this );
break;
+ case Font:
+ item = new FontItem( title, resourceEdit(), this, this );
+ break;
}
return item;
{
myColor->setPaletteBackgroundColor( getColor() );
}
+
+
+/*
+ Class: QtxListResourceEdit::FontItem
+ Descr: GUI implementation of resources font item.
+*/
+QtxListResourceEdit::FontItem::FontItem( const QString& title, QtxResourceEdit* edit, Item* pItem, QWidget* parent )
+: PrefItem( Font, edit, pItem, parent )
+{
+ new QLabel( title, this );
+ myFontPrs = new QLabel( "", this );
+ QPushButton* selFont = new QPushButton( "..", this );
+ connect( selFont, SIGNAL( clicked() ), this, SLOT( onSelectFont() ) );
+}
+
+QtxListResourceEdit::FontItem::~FontItem()
+{
+}
+
+void QtxListResourceEdit::FontItem::store()
+{
+ Item::setFont( myFont );
+}
+
+void QtxListResourceEdit::FontItem::retrieve()
+{
+ myFont = getFont();
+ buildFontPrs();
+}
+
+void QtxListResourceEdit::FontItem::buildFontPrs()
+{
+ QStringList fval;
+ fval.append( myFont.family() );
+ if( myFont.bold() )
+ fval.append( "Bold" );
+ if( myFont.italic() )
+ fval.append( "Italic" );
+ fval.append( QString( "%1" ).arg( myFont.pointSize() ) );
+
+ myFontPrs->setText( fval.join( ", " ) );
+}
+
+void QtxListResourceEdit::FontItem::onSelectFont()
+{
+ bool ok;
+ QFont newFont = QFontDialog::getFont( &ok, myFont, this );
+ if( ok )
+ {
+ myFont = newFont;
+ buildFontPrs();
+ }
+}
class DoubleEditItem;
class IntegerSpinItem;
class IntegerEditItem;
+ class FontItem;
- enum { Space, Bool, Color, String, Selector, DblSpin, IntSpin, Double, Integer };
+ enum { Space, Bool, Color, String, Selector, DblSpin, IntSpin, Double, Integer, Font, User };
public:
QtxListResourceEdit( QtxResourceMgr*, QWidget* = 0 );
QWidget* myColor;
};
+/*
+ Class: QtxListResourceEdit::FontItem
+ Descr: GUI implementation of resources font item.
+*/
+
+class QtxListResourceEdit::FontItem : public PrefItem
+{
+ Q_OBJECT
+
+public:
+ FontItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
+ virtual ~FontItem();
+
+ virtual void store();
+ virtual void retrieve();
+
+protected slots:
+ void onSelectFont();
+
+protected:
+ void buildFontPrs();
+
+private:
+ QFont myFont;
+ QLabel* myFontPrs;
+};
+
#endif