1 /***************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto *
3 * ikemo@users.sourceforge.jp *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 #include "faceprefpage.h"
13 #include <kfontdialog.h>
15 #include "libkita/colorconfig.h"
16 #include "libkita/globalconfig.h"
17 #include "libkita/kita_misc.h"
21 FacePrefPage::FacePrefPage(QWidget* parent) : AbstractPrefPage(parent)
26 connect(listFontButton, SIGNAL(clicked()), SLOT(slotFontButtonClicked()));
28 connect(threadFontButton, SIGNAL(clicked()),
29 SLOT(slotThreadFontButtonClicked()));
31 connect(popupFontButton, SIGNAL(clicked()),
32 SLOT(slotPopupFontButtonClicked()));
35 connect(threadColorButton, SIGNAL(changed(const QColor&)),
37 connect(threadBackgroundColorButton, SIGNAL(changed(const QColor&)),
39 connect(popupColorButton, SIGNAL(changed(const QColor&)),
41 connect(popupBackgroundColorButton, SIGNAL(changed(const QColor&)),
45 void FacePrefPage::apply()
48 QFont font = listFontButton->font();
49 GlobalConfig::setFont(font);
50 emit fontChanged(font);
52 QFont threadFont = threadFontButton->font();
53 GlobalConfig::setThreadFont(threadFont);
55 QFont popupFont = popupFontButton->font();
56 GlobalConfig::setPopupFont(popupFont);
59 ColorConfig::setThread(threadColorButton->color());
60 ColorConfig::setThreadBackground(threadBackgroundColorButton->color());
61 ColorConfig::setPopup(popupColorButton->color());
62 ColorConfig::setPopupBackground(popupBackgroundColorButton->color());
65 void FacePrefPage::load()
68 QFont font = GlobalConfig::font();
69 listFontButton->setText(fontToString(font));
70 listFontButton->setFont(font);
72 QFont threadFont = GlobalConfig::threadFont();
73 threadFontButton->setText(fontToString(threadFont));
74 threadFontButton->setFont(threadFont);
76 QFont popupFont = GlobalConfig::popupFont();
77 popupFontButton->setText(fontToString(popupFont));
78 popupFontButton->setFont(popupFont);
81 threadColorButton->setColor(ColorConfig::thread());
82 threadBackgroundColorButton->setColor(ColorConfig::threadBackground());
83 popupColorButton->setColor(ColorConfig::popup());
84 popupBackgroundColorButton->setColor(ColorConfig::popupBackground());
88 void FacePrefPage::reset()
90 ColorConfig::self()->useDefaults(true);
91 GlobalConfig::self()->useDefaults(true);
93 GlobalConfig::self()->useDefaults(false);
94 ColorConfig::self()->useDefaults(false);
97 void FacePrefPage::slotThreadFontButtonClicked()
99 QFont threadFont = threadFontButton->font();
101 if (KFontDialog::getFont(threadFont, false, this) == QDialog::Accepted) {
102 threadFontButton->setText(fontToString(threadFont));
103 threadFontButton->setFont(threadFont);
108 void FacePrefPage::slotFontButtonClicked()
110 QFont font = listFontButton->font();
112 if (KFontDialog::getFont(font, false, this) == QDialog::Accepted) {
113 listFontButton->setText(fontToString(font));
114 listFontButton->setFont(font);
119 void FacePrefPage::slotPopupFontButtonClicked()
121 QFont font = popupFontButton->font();
123 if (KFontDialog::getFont(font, false, this) == QDialog::Accepted) {
124 popupFontButton->setText(fontToString(font));
125 popupFontButton->setFont(font);