OSDN Git Service

Rename boardmanager.cpp and boardmanager.h
[kita/kita.git] / src / prefs / faceprefpage.cpp
1 /***************************************************************************
2 *   Copyright (C) 2003 by Hideki Ikemoto                                  *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
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 ***************************************************************************/
10
11 #include "faceprefpage.h"
12
13 #include <kfontdialog.h>
14
15 #include "libkita/colorconfig.h"
16 #include "libkita/globalconfig.h"
17 #include "libkita/kita_misc.h"
18
19 using namespace Kita;
20
21 FacePrefPage::FacePrefPage(QWidget* parent) : AbstractPrefPage(parent)
22 {
23     setupUi(this);
24     load();
25     // font
26     connect(listFontButton, SIGNAL(clicked()), SLOT(slotFontButtonClicked()));
27
28     connect(threadFontButton, SIGNAL(clicked()),
29              SLOT(slotThreadFontButtonClicked()));
30
31     connect(popupFontButton, SIGNAL(clicked()),
32              SLOT(slotPopupFontButtonClicked()));
33
34     // color
35     connect(threadColorButton, SIGNAL(changed(const QColor&)),
36             SIGNAL(changed()));
37     connect(threadBackgroundColorButton, SIGNAL(changed(const QColor&)),
38             SIGNAL(changed()));
39     connect(popupColorButton, SIGNAL(changed(const QColor&)),
40             SIGNAL(changed()));
41     connect(popupBackgroundColorButton, SIGNAL(changed(const QColor&)),
42             SIGNAL(changed()));
43 }
44
45 void FacePrefPage::apply()
46 {
47     // font
48     QFont font = listFontButton->font();
49     GlobalConfig::setFont(font);
50     emit fontChanged(font);
51
52     QFont threadFont = threadFontButton->font();
53     GlobalConfig::setThreadFont(threadFont);
54
55     QFont popupFont = popupFontButton->font();
56     GlobalConfig::setPopupFont(popupFont);
57
58     // color
59     ColorConfig::setThread(threadColorButton->color());
60     ColorConfig::setThreadBackground(threadBackgroundColorButton->color());
61     ColorConfig::setPopup(popupColorButton->color());
62     ColorConfig::setPopupBackground(popupBackgroundColorButton->color());
63 }
64
65 void FacePrefPage::load()
66 {
67     // font
68     QFont font = GlobalConfig::font();
69     listFontButton->setText(fontToString(font));
70     listFontButton->setFont(font);
71
72     QFont threadFont = GlobalConfig::threadFont();
73     threadFontButton->setText(fontToString(threadFont));
74     threadFontButton->setFont(threadFont);
75
76     QFont popupFont = GlobalConfig::popupFont();
77     popupFontButton->setText(fontToString(popupFont));
78     popupFontButton->setFont(popupFont);
79
80     // color
81     threadColorButton->setColor(ColorConfig::thread());
82     threadBackgroundColorButton->setColor(ColorConfig::threadBackground());
83     popupColorButton->setColor(ColorConfig::popup());
84     popupBackgroundColorButton->setColor(ColorConfig::popupBackground());
85
86 }
87
88 void FacePrefPage::reset()
89 {
90     ColorConfig::self()->useDefaults(true);
91     GlobalConfig::self()->useDefaults(true);
92     load();
93     GlobalConfig::self()->useDefaults(false);
94     ColorConfig::self()->useDefaults(false);
95 }
96
97 void FacePrefPage::slotThreadFontButtonClicked()
98 {
99     QFont threadFont = threadFontButton->font();
100
101     if (KFontDialog::getFont(threadFont, false, this) == QDialog::Accepted) {
102         threadFontButton->setText(fontToString(threadFont));
103         threadFontButton->setFont(threadFont);
104         emit changed();
105     }
106 }
107
108 void FacePrefPage::slotFontButtonClicked()
109 {
110     QFont font = listFontButton->font();
111
112     if (KFontDialog::getFont(font, false, this) == QDialog::Accepted) {
113         listFontButton->setText(fontToString(font));
114         listFontButton->setFont(font);
115         emit changed();
116     }
117 }
118
119 void FacePrefPage::slotPopupFontButtonClicked()
120 {
121     QFont font = popupFontButton->font();
122
123     if (KFontDialog::getFont(font, false, this) == QDialog::Accepted) {
124         popupFontButton->setText(fontToString(font));
125         popupFontButton->setFont(font);
126         emit changed();
127     }
128 }