Remove label from FontSelector
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 4 Aug 2009 07:42:46 +0000 (09:42 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Aug 2009 18:25:59 +0000 (20:25 +0200)
Earlier the FontSelector had its own label, which in retrospect was a stupid idea.
Much better to just consider the demo widget and choose button parts of the FontSelector
widget and have settingspages supply their own description label - or checkbox.

This makes it much easier to have a font disableable, without introducing the need for
multi-property autowidgets.

src/uisupport/fontselector.cpp
src/uisupport/fontselector.h

index 8a53551..457c1d9 100644 (file)
 #include "fontselector.h"
 
 FontSelector::FontSelector(QWidget *parent) : QWidget(parent) {
-  init();
-}
-
-FontSelector::FontSelector(const QString &label, QWidget *parent) : QWidget(parent) {
-  init(label);
-}
-
-void FontSelector::init(const QString &label) {
   QHBoxLayout *layout = new QHBoxLayout(this);
   QPushButton *chooseButton = new QPushButton(tr("Choose..."), this);
   connect(chooseButton, SIGNAL(clicked()), SLOT(chooseFont()));
 
-  layout->addWidget(_label = new QLabel(label));
   layout->addWidget(_demo = new QLabel("Font"));
   layout->addWidget(chooseButton);
   layout->setContentsMargins(0, 0, 0, 0);
@@ -50,10 +41,6 @@ void FontSelector::init(const QString &label) {
   _font = font();
 }
 
-void FontSelector::setText(const QString &label) {
-  _label->setText(label);
-}
-
 void FontSelector::setSelectedFont(const QFont &font) {
   _font = font;
   _demo->setText(QString("%1 %2pt").arg(font.family()).arg(font.pointSize()));
index 60d2777..378bf29 100644 (file)
 class FontSelector : public QWidget {
   Q_OBJECT
   Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
-  Q_PROPERTY(QString text READ text WRITE setText)
 
 public:
   FontSelector(QWidget *parent = 0);
-  FontSelector(const QString &label, QWidget *parent = 0);
 
   inline const QFont &selectedFont() const { return _font; }
-  inline QString text() const { return _label->text(); }
 
 public slots:
-  void setText(const QString &label);
   void setSelectedFont(const QFont &font);
 
 signals:
@@ -51,9 +47,7 @@ protected slots:
 
 private:
   QFont _font;
-  QLabel *_demo, *_label;
-
-  void init(const QString &label = "Font");
+  QLabel *_demo;
 };
 
 #endif // FONTSELECTOR_H_