23 #include <tqcheckbox.h>
25 #include <tqwhatsthis.h>
27 #include <tdelocale.h>
30 #include "fontcolour.h"
31 #include "preferences.h"
32 #include "pushbutton.h"
33 #include "fontcolourbutton.moc"
41 FontColourButton::FontColourButton(TQWidget* parent,
const char* name)
42 : TQFrame(parent, name),
45 setFrameStyle(NoFrame);
46 TQHBoxLayout* layout =
new TQHBoxLayout(
this, 0, KDialog::spacingHint());
48 mButton =
new PushButton(i18n(
"Font && Co&lor..."),
this);
49 mButton->setFixedSize(mButton->sizeHint());
50 connect(mButton, TQ_SIGNAL(clicked()), TQ_SLOT(slotButtonPressed()));
51 TQWhatsThis::add(mButton,
52 i18n(
"Choose the font, and foreground and background color, for the alarm message."));
53 layout->addWidget(mButton);
56 mSample =
new TQLineEdit(
this);
57 mSample->setMinimumHeight(TQMAX(mSample->fontMetrics().lineSpacing(), mButton->height()*3/2));
58 mSample->setSizePolicy(TQSizePolicy::Ignored, TQSizePolicy::MinimumExpanding);
59 mSample->setText(i18n(
"The Quick Brown Fox Jumps Over The Lazy Dog"));
60 mSample->setCursorPosition(0);
61 mSample->setAlignment(TQt::AlignCenter);
62 TQWhatsThis::add(mSample,
63 i18n(
"This sample text illustrates the current font and color settings. "
64 "You may edit it to test special characters."));
65 layout->addWidget(mSample);
68 void FontColourButton::setDefaultFont()
71 mSample->setFont(Preferences::messageFont());
74 void FontColourButton::setFont(
const TQFont& font)
78 mSample->setFont(mFont);
81 void FontColourButton::setBgColour(
const TQColor& colour)
84 mSample->setPaletteBackgroundColor(mBgColour);
87 void FontColourButton::setFgColour(
const TQColor& colour)
90 mSample->setPaletteForegroundColor(mFgColour);
97 void FontColourButton::slotButtonPressed()
99 FontColourDlg dlg(mBgColour, mFgColour, mFont, mDefaultFont,
100 i18n(
"Choose Alarm Font & Color"),
this,
"fontColourDlg");
101 dlg.setReadOnly(mReadOnly);
102 if (dlg.exec() == TQDialog::Accepted)
104 mDefaultFont = dlg.defaultFont();
106 mSample->setFont(mFont);
107 mBgColour = dlg.bgColour();
108 mSample->setPaletteBackgroundColor(mBgColour);
109 mFgColour = dlg.fgColour();
110 mSample->setPaletteForegroundColor(mFgColour);
121 FontColourDlg::FontColourDlg(
const TQColor& bgColour,
const TQColor& fgColour,
const TQFont& font,
122 bool defaultFont,
const TQString& caption, TQWidget* parent,
const char* name)
123 : KDialogBase(parent, name, true, caption, Ok|Cancel, Ok, false),
126 TQWidget* page =
new TQWidget(
this);
128 TQVBoxLayout* layout =
new TQVBoxLayout(page, 0, spacingHint());
129 mChooser =
new FontColourChooser(page, 0,
false, TQStringList(), TQString(),
false,
true,
true);
130 mChooser->setBgColour(bgColour);
131 mChooser->setFgColour(fgColour);
133 mChooser->setDefaultFont();
135 mChooser->setFont(font);
136 layout->addWidget(mChooser);
137 layout->addSpacing(KDialog::spacingHint());
143 void FontColourDlg::slotOk()
150 mDefaultFont = mChooser->defaultFont();
151 mFont = mChooser->font();
152 mBgColour = mChooser->bgColour();
153 mFgColour = mChooser->fgColour();
157 void FontColourDlg::setReadOnly(
bool ro)
160 mChooser->setReadOnly(mReadOnly);