Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinoptions/mouse.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "mouse.h" | 20 | #include "mouse.h" | ||
21 | 21 | | |||
22 | #include <QLabel> | | |||
23 | #include <KComboBox> | | |||
24 | | ||||
25 | #include <QLayout> | | |||
26 | #include <QSizePolicy> | | |||
27 | #include <QBitmap> | | |||
28 | | ||||
29 | #include <QGroupBox> | | |||
30 | #include <QPixmap> | | |||
31 | #include <QVBoxLayout> | | |||
32 | #include <QHBoxLayout> | | |||
33 | #include <QFormLayout> | | |||
34 | | ||||
35 | #include <QDebug> | 22 | #include <QDebug> | ||
36 | #include <kcolorscheme.h> | | |||
37 | #include <kseparator.h> | | |||
38 | #include <QtDBus> | 23 | #include <QtDBus> | ||
39 | 24 | | |||
40 | #include <cstdlib> | 25 | #include <cstdlib> | ||
41 | 26 | | |||
42 | #include "kwinoptions_settings.h" | 27 | #include "kwinoptions_settings.h" | ||
43 | 28 | | |||
44 | | ||||
45 | namespace | | |||
46 | { | | |||
47 | | ||||
48 | QPixmap maxButtonPixmaps[3]; | | |||
49 | | ||||
50 | void createMaxButtonPixmaps() | | |||
51 | { | | |||
52 | char const *maxButtonXpms[][3 + 13] = { | | |||
53 | { | | |||
54 | nullptr, nullptr, nullptr, | | |||
55 | "...............", | | |||
56 | ".......#.......", | | |||
57 | "......###......", | | |||
58 | ".....#####.....", | | |||
59 | "..#....#....#..", | | |||
60 | ".##....#....##.", | | |||
61 | "###############", | | |||
62 | ".##....#....##.", | | |||
63 | "..#....#....#..", | | |||
64 | ".....#####.....", | | |||
65 | "......###......", | | |||
66 | ".......#.......", | | |||
67 | "..............." | | |||
68 | }, | | |||
69 | { | | |||
70 | nullptr, nullptr, nullptr, | | |||
71 | "...............", | | |||
72 | ".......#.......", | | |||
73 | "......###......", | | |||
74 | ".....#####.....", | | |||
75 | ".......#.......", | | |||
76 | ".......#.......", | | |||
77 | ".......#.......", | | |||
78 | ".......#.......", | | |||
79 | ".......#.......", | | |||
80 | ".....#####.....", | | |||
81 | "......###......", | | |||
82 | ".......#.......", | | |||
83 | "..............." | | |||
84 | }, | | |||
85 | { | | |||
86 | nullptr, nullptr, nullptr, | | |||
87 | "...............", | | |||
88 | "...............", | | |||
89 | "...............", | | |||
90 | "...............", | | |||
91 | "..#.........#..", | | |||
92 | ".##.........##.", | | |||
93 | "###############", | | |||
94 | ".##.........##.", | | |||
95 | "..#.........#..", | | |||
96 | "...............", | | |||
97 | "...............", | | |||
98 | "...............", | | |||
99 | "..............." | | |||
100 | }, | | |||
101 | }; | | |||
102 | | ||||
103 | QByteArray baseColor(". c " + KColorScheme(QPalette::Active, KColorScheme::View).background().color().name().toLatin1()); | | |||
104 | QByteArray textColor("# c " + KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name().toLatin1()); | | |||
105 | for (int t = 0; t < 3; ++t) { | | |||
106 | maxButtonXpms[t][0] = "15 13 2 1"; | | |||
107 | maxButtonXpms[t][1] = baseColor.constData(); | | |||
108 | maxButtonXpms[t][2] = textColor.constData(); | | |||
109 | maxButtonPixmaps[t] = QPixmap(maxButtonXpms[t]); | | |||
110 | maxButtonPixmaps[t].setMask(maxButtonPixmaps[t].createHeuristicMask()); | | |||
111 | } | | |||
112 | } | | |||
113 | | ||||
114 | } // namespace | | |||
115 | | ||||
116 | KWinMouseConfigForm::KWinMouseConfigForm(QWidget *parent) | 29 | KWinMouseConfigForm::KWinMouseConfigForm(QWidget *parent) | ||
117 | : QWidget(parent) | 30 | : QWidget(parent) | ||
118 | { | 31 | { | ||
119 | setupUi(parent); | 32 | setupUi(parent); | ||
120 | } | 33 | } | ||
121 | 34 | | |||
122 | KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent) | 35 | KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent) | ||
123 | : QWidget(parent) | 36 | : QWidget(parent) | ||
124 | { | 37 | { | ||
125 | setupUi(parent); | 38 | setupUi(parent); | ||
126 | } | 39 | } | ||
127 | 40 | | |||
128 | void KTitleBarActionsConfig::paletteChanged() | | |||
129 | { | | |||
130 | createMaxButtonPixmaps(); | | |||
131 | for (int i=0; i<3; ++i) { | | |||
132 | m_ui->kcfg_MaximizeButtonLeftClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | | |||
133 | m_ui->kcfg_MaximizeButtonMiddleClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | | |||
134 | m_ui->kcfg_MaximizeButtonRightClickCommand->setItemIcon(i, maxButtonPixmaps[i]); | | |||
135 | } | | |||
136 | | ||||
137 | } | | |||
138 | | ||||
139 | KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) | 41 | KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) | ||
140 | : KCModule(parent), standAlone(_standAlone) | 42 | : KCModule(parent), standAlone(_standAlone) | ||
141 | , m_ui(new KWinMouseConfigForm(this)) | 43 | , m_ui(new KWinMouseConfigForm(this)) | ||
142 | , m_settings(settings) | 44 | , m_settings(settings) | ||
143 | { | 45 | { | ||
144 | addConfig(m_settings, this); | 46 | addConfig(m_settings, this); | ||
145 | | ||||
146 | // create the items for the maximize button actions | | |||
147 | createMaxButtonPixmaps(); | | |||
148 | for (int i=0; i<3; ++i) { | | |||
149 | m_ui->kcfg_MaximizeButtonLeftClickCommand->addItem(maxButtonPixmaps[i], QString()); | | |||
150 | m_ui->kcfg_MaximizeButtonMiddleClickCommand->addItem(maxButtonPixmaps[i], QString()); | | |||
151 | m_ui->kcfg_MaximizeButtonRightClickCommand->addItem(maxButtonPixmaps[i], QString()); | | |||
152 | } | | |||
153 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonLeftClickCommand); | | |||
154 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonMiddleClickCommand); | | |||
155 | createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonRightClickCommand); | | |||
156 | | ||||
157 | load(); | 47 | load(); | ||
158 | } | 48 | } | ||
159 | 49 | | |||
160 | void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo) | | |||
161 | { | | |||
162 | combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole); | | |||
163 | combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole); | | |||
164 | combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole); | | |||
165 | } | | |||
166 | | ||||
167 | void KTitleBarActionsConfig::showEvent(QShowEvent *ev) | 50 | void KTitleBarActionsConfig::showEvent(QShowEvent *ev) | ||
168 | { | 51 | { | ||
169 | if (!standAlone) { | 52 | if (!standAlone) { | ||
170 | // Workaround KCModule::showEvent() calling load(), see bug 163817 | 53 | // Workaround KCModule::showEvent() calling load(), see bug 163817 | ||
171 | QWidget::showEvent(ev); | 54 | QWidget::showEvent(ev); | ||
172 | return; | 55 | return; | ||
173 | } | 56 | } | ||
174 | KCModule::showEvent(ev); | 57 | KCModule::showEvent(ev); | ||
175 | } | 58 | } | ||
176 | 59 | | |||
177 | void KTitleBarActionsConfig::changeEvent(QEvent *ev) | 60 | void KTitleBarActionsConfig::changeEvent(QEvent *ev) | ||
178 | { | 61 | { | ||
179 | if (ev->type() == QEvent::PaletteChange) { | | |||
180 | paletteChanged(); | | |||
181 | } | | |||
182 | ev->accept(); | 62 | ev->accept(); | ||
183 | } | 63 | } | ||
184 | 64 | | |||
185 | void KTitleBarActionsConfig::save() | 65 | void KTitleBarActionsConfig::save() | ||
186 | { | 66 | { | ||
187 | KCModule::save(); | 67 | KCModule::save(); | ||
188 | 68 | | |||
189 | if (standAlone) { | 69 | if (standAlone) { | ||
Show All 36 Lines |