FontColourChooser::FontColourChooser(QWidget *parent, const char *name, bool onlyFixed, const QStringList &fontList, const QString &frameLabel, bool editColours, bool fg, bool defaultFont, int visibleListSize) : QWidget(parent, name), mFgColourButton(0), mRemoveColourButton(0), mColourList(Preferences::messageColours()), mReadOnly(false) { QVBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint()); QWidget *page = this; if(!frameLabel.isNull()) { page = new QGroupBox(frameLabel, this); topLayout->addWidget(page); topLayout = new QVBoxLayout(page, KDialog::marginHint(), KDialog::spacingHint()); topLayout->addSpacing(fontMetrics().height() - KDialog::marginHint() + KDialog::spacingHint()); } QHBoxLayout *hlayout = new QHBoxLayout(topLayout); QVBoxLayout *colourLayout = new QVBoxLayout(hlayout); if(fg) { QHBox *box = new QHBox(page); // to group widgets for QWhatsThis text box->setSpacing(KDialog::spacingHint() / 2); colourLayout->addWidget(box); QLabel *label = new QLabel(i18n("&Foreground color:"), box); box->setStretchFactor(new QWidget(box), 0); mFgColourButton = new ColourCombo(box); connect(mFgColourButton, SIGNAL(activated(const QString &)), SLOT(setSampleColour())); label->setBuddy(mFgColourButton); QWhatsThis::add(box, i18n("Select the alarm message foreground color")); } QHBox *box = new QHBox(page); // to group widgets for QWhatsThis text box->setSpacing(KDialog::spacingHint() / 2); colourLayout->addWidget(box); QLabel *label = new QLabel(i18n("&Background color:"), box); box->setStretchFactor(new QWidget(box), 0); mBgColourButton = new ColourCombo(box); connect(mBgColourButton, SIGNAL(activated(const QString &)), SLOT(setSampleColour())); label->setBuddy(mBgColourButton); QWhatsThis::add(box, i18n("Select the alarm message background color")); hlayout->addStretch(); if(editColours) { QHBoxLayout *layout = new QHBoxLayout(topLayout); QPushButton *button = new QPushButton(i18n("Add Co&lor..."), page); button->setFixedSize(button->sizeHint()); connect(button, SIGNAL(clicked()), SLOT(slotAddColour())); QWhatsThis::add(button, i18n("Choose a new color to add to the color selection list.")); layout->addWidget(button); mRemoveColourButton = new QPushButton(i18n("&Remove Color"), page); mRemoveColourButton->setFixedSize(mRemoveColourButton->sizeHint()); connect(mRemoveColourButton, SIGNAL(clicked()), SLOT(slotRemoveColour())); QWhatsThis::add(mRemoveColourButton, i18n("Remove the color currently shown in the background color chooser, from the color selection list.")); layout->addWidget(mRemoveColourButton); } if(defaultFont) { QHBoxLayout *layout = new QHBoxLayout(topLayout); mDefaultFont = new CheckBox(i18n("Use &default font"), page); mDefaultFont->setMinimumSize(mDefaultFont->sizeHint()); connect(mDefaultFont, SIGNAL(toggled(bool)), SLOT(slotDefaultFontToggled(bool))); QWhatsThis::add(mDefaultFont, i18n("Check to use the default font current at the time the alarm is displayed.")); layout->addWidget(mDefaultFont); layout->addWidget(new QWidget(page)); // left adjust the widget } else mDefaultFont = 0; mFontChooser = new KFontChooser(page, name, onlyFixed, fontList, false, visibleListSize); mFontChooser->installEventFilter(this); // for read-only mode const QObjectList *kids = mFontChooser->queryList(); for(QObjectList::ConstIterator it = kids->constBegin(); it != kids->constEnd(); ++it) (*it)->installEventFilter(this); topLayout->addWidget(mFontChooser); slotDefaultFontToggled(false); }
FontColourChooser::FontColourChooser(QWidget *parent, const QStringList &fontList, const QString& frameLabel, bool fg, bool defaultFont, int visibleListSize) : QWidget(parent), mFgColourButton(0), mReadOnly(false) { QVBoxLayout* topLayout = new QVBoxLayout(this); topLayout->setMargin(0); topLayout->setSpacing(KDialog::spacingHint()); QWidget* page = this; if (!frameLabel.isNull()) { page = new QGroupBox(frameLabel, this); topLayout->addWidget(page); topLayout = new QVBoxLayout(page); topLayout->setMargin(KDialog::marginHint()); topLayout->setSpacing(KDialog::spacingHint()); } QHBoxLayout* hlayout = new QHBoxLayout(); hlayout->setMargin(0); topLayout->addLayout(hlayout); QVBoxLayout* colourLayout = new QVBoxLayout(); colourLayout->setMargin(0); hlayout->addLayout(colourLayout); if (fg) { KHBox* box = new KHBox(page); // to group widgets for QWhatsThis text box->setMargin(0); box->setSpacing(KDialog::spacingHint()/2); colourLayout->addWidget(box); QLabel* label = new QLabel(i18nc("@label:listbox", "Foreground color:"), box); box->setStretchFactor(new QWidget(box), 0); mFgColourButton = new ColourButton(box); connect(mFgColourButton, SIGNAL(changed(const QColor&)), SLOT(setSampleColour())); label->setBuddy(mFgColourButton); box->setWhatsThis(i18nc("@info:whatsthis", "Select the alarm message foreground color")); } KHBox* box = new KHBox(page); // to group widgets for QWhatsThis text box->setMargin(0); box->setSpacing(KDialog::spacingHint()/2); colourLayout->addWidget(box); QLabel* label = new QLabel(i18nc("@label:listbox", "Background color:"), box); box->setStretchFactor(new QWidget(box), 0); mBgColourButton = new ColourButton(box); connect(mBgColourButton, SIGNAL(changed(const QColor&)), SLOT(setSampleColour())); label->setBuddy(mBgColourButton); box->setWhatsThis(i18nc("@info:whatsthis", "Select the alarm message background color")); hlayout->addStretch(); if (defaultFont) { QHBoxLayout* layout = new QHBoxLayout(); layout->setMargin(0); topLayout->addLayout(layout); mDefaultFont = new CheckBox(i18nc("@option:check", "Use default font"), page); mDefaultFont->setMinimumSize(mDefaultFont->sizeHint()); connect(mDefaultFont, SIGNAL(toggled(bool)), SLOT(slotDefaultFontToggled(bool))); mDefaultFont->setWhatsThis(i18nc("@info:whatsthis", "Check to use the default font current at the time the alarm is displayed.")); layout->addWidget(mDefaultFont); layout->addWidget(new QWidget(page)); // left adjust the widget } else mDefaultFont = 0; mFontChooser = new KFontChooser(page, KFontChooser::DisplayFrame, fontList, visibleListSize); mFontChooser->installEventFilter(this); // for read-only mode QList<QWidget*> kids = mFontChooser->findChildren<QWidget*>(); for (int i = 0, end = kids.count(); i < end; ++i) kids[i]->installEventFilter(this); topLayout->addWidget(mFontChooser); slotDefaultFontToggled(false); }