25 #include "fontcolour.moc"
28 #include <kfontchooser.h>
29 #include <kfontdialog.h>
30 #include <kcolordialog.h>
34 #include <QPushButton>
36 #include <QVBoxLayout>
37 #include <QHBoxLayout>
41 const QStringList &fontList,
const QString& frameLabel,
bool fg,
bool defaultFont,
int visibleListSize)
46 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
47 topLayout->setMargin(0);
48 topLayout->setSpacing(KDialog::spacingHint());
50 if (!frameLabel.isNull())
53 topLayout->addWidget(page);
54 topLayout =
new QVBoxLayout(page);
55 topLayout->setMargin(KDialog::marginHint());
56 topLayout->setSpacing(KDialog::spacingHint());
58 QHBoxLayout* hlayout =
new QHBoxLayout();
59 hlayout->setMargin(0);
60 topLayout->addLayout(hlayout);
61 QVBoxLayout* colourLayout =
new QVBoxLayout();
62 colourLayout->setMargin(0);
63 hlayout->addLayout(colourLayout);
68 box->setSpacing(KDialog::spacingHint()/2);
69 colourLayout->addWidget(box);
71 QLabel* label =
new QLabel(i18nc(
"@label:listbox",
"Foreground color:"), box);
72 box->setStretchFactor(
new QWidget(box), 0);
74 connect(mFgColourButton, SIGNAL(changed(QColor)), SLOT(setSampleColour()));
75 label->setBuddy(mFgColourButton);
76 box->setWhatsThis(i18nc(
"@info:whatsthis",
"Select the alarm message foreground color"));
81 box->setSpacing(KDialog::spacingHint()/2);
82 colourLayout->addWidget(box);
84 QLabel* label =
new QLabel(i18nc(
"@label:listbox",
"Background color:"), box);
85 box->setStretchFactor(
new QWidget(box), 0);
87 connect(mBgColourButton, SIGNAL(changed(QColor)), SLOT(setSampleColour()));
88 label->setBuddy(mBgColourButton);
89 box->setWhatsThis(i18nc(
"@info:whatsthis",
"Select the alarm message background color"));
90 hlayout->addStretch();
94 QHBoxLayout* layout =
new QHBoxLayout();
96 topLayout->addLayout(layout);
97 mDefaultFont =
new CheckBox(i18nc(
"@option:check",
"Use default font"), page);
98 mDefaultFont->setMinimumSize(mDefaultFont->sizeHint());
99 connect(mDefaultFont, SIGNAL(toggled(
bool)), SLOT(slotDefaultFontToggled(
bool)));
100 mDefaultFont->setWhatsThis(i18nc(
"@info:whatsthis",
"Check to use the default font current at the time the alarm is displayed."));
101 layout->addWidget(mDefaultFont);
102 layout->addWidget(
new QWidget(page));
107 mFontChooser =
new KFontChooser(page, KFontChooser::DisplayFrame, fontList, visibleListSize);
108 mFontChooser->installEventFilter(
this);
110 for (
int i = 0, end = kids.count(); i < end; ++i)
111 kids[i]->installEventFilter(
this);
112 topLayout->addWidget(mFontChooser);
114 slotDefaultFontToggled(
false);
120 mDefaultFont->setChecked(
true);
126 mDefaultFont->setChecked(
false);
127 mFontChooser->setFont(font, onlyFixed);
132 return mDefaultFont ? mDefaultFont->isChecked() :
false;
137 return (mDefaultFont && mDefaultFont->isChecked()) ? QFont() : mFontChooser->font();
142 mBgColourButton->setColor(colour);
143 mFontChooser->setBackgroundColor(colour);
146 void FontColourChooser::setSampleColour()
148 QColor bg = mBgColourButton->color();
149 mFontChooser->setBackgroundColor(bg);
151 mFontChooser->setColor(fg);
156 return mBgColourButton->color();
162 return mFgColourButton->color();
165 QColor bg = mBgColourButton->color();
166 QPalette pal(bg, bg);
167 return pal.color(QPalette::Active, QPalette::Text);
173 return mFontChooser->sampleText();
178 mFontChooser->setSampleText(text);
185 mFgColourButton->setColor(colour);
186 mFontChooser->setColor(colour);
208 case QEvent::MouseMove:
209 case QEvent::MouseButtonPress:
210 case QEvent::MouseButtonRelease:
211 case QEvent::MouseButtonDblClick:
212 case QEvent::KeyPress:
213 case QEvent::KeyRelease:
222 void FontColourChooser::slotDefaultFontToggled(
bool on)
224 mFontChooser->setEnabled(!on);
virtual void setReadOnly(bool readOnly)
virtual bool eventFilter(QObject *, QEvent *)
virtual QByteArray text(quint32 serialNumber) const =0
the KAlarm application object
void setFgColour(const QColor &)
void setFont(const QFont &, bool onlyFixed=false)
void setSampleText(const QString &text)
void setBgColour(const QColor &)
FontColourChooser(QWidget *parent=0, const QStringList &fontList=QStringList(), const QString &frameLabel=i18n("Requested font"), bool fg=true, bool defaultFont=false, int visibleListSize=8)
QString sampleText() const