KWin
Loading...
Searching...
No Matches
decorationoptions.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#pragma once
7
8#include <KDecoration2/Decoration>
9
10#include <QColor>
11#include <QFont>
12#include <QObject>
13#include <QPalette>
14
15namespace KWin
16{
17
18// TODO: move to deco API
20{
21public:
22 ColorSettings(const QPalette &pal);
23
24 void update(const QPalette &pal);
25
26 const QColor &titleBarColor(bool active) const
27 {
28 return active ? m_activeTitleBarColor : m_inactiveTitleBarColor;
29 }
30 const QColor &activeTitleBarColor() const
31 {
32 return m_activeTitleBarColor;
33 }
34 const QColor &inactiveTitleBarColor() const
35 {
36 return m_inactiveTitleBarColor;
37 }
38 const QColor &activeTitleBarBlendColor() const
39 {
40 return m_activeTitleBarBlendColor;
41 }
42 const QColor &inactiveTitleBarBlendColor() const
43 {
44 return m_inactiveTitleBarBlendColor;
45 }
46 const QColor &frame(bool active) const
47 {
48 return active ? m_activeFrameColor : m_inactiveFrameColor;
49 }
50 const QColor &activeFrame() const
51 {
52 return m_activeFrameColor;
53 }
54 const QColor &inactiveFrame() const
55 {
56 return m_inactiveFrameColor;
57 }
58 const QColor &font(bool active) const
59 {
60 return active ? m_activeFontColor : m_inactiveFontColor;
61 }
62 const QColor &activeFont() const
63 {
64 return m_activeFontColor;
65 }
66 const QColor &inactiveFont() const
67 {
68 return m_inactiveFontColor;
69 }
70 const QColor &activeButtonColor() const
71 {
72 return m_activeButtonColor;
73 }
74 const QColor &inactiveButtonColor() const
75 {
76 return m_inactiveButtonColor;
77 }
78 const QColor &activeHandle() const
79 {
80 return m_activeHandle;
81 }
82 const QColor &inactiveHandle() const
83 {
84 return m_inactiveHandle;
85 }
86 const QPalette &palette() const
87 {
88 return m_palette;
89 }
90
91private:
92 void init(const QPalette &pal);
93 QColor m_activeTitleBarColor;
94 QColor m_inactiveTitleBarColor;
95 QColor m_activeTitleBarBlendColor;
96 QColor m_inactiveTitleBarBlendColor;
97 QColor m_activeFrameColor;
98 QColor m_inactiveFrameColor;
99 QColor m_activeFontColor;
100 QColor m_inactiveFontColor;
101 QColor m_activeButtonColor;
102 QColor m_inactiveButtonColor;
103 QColor m_activeHandle;
104 QColor m_inactiveHandle;
105 QPalette m_palette;
106};
107
132class DecorationOptions : public QObject
133{
134 Q_OBJECT
142 Q_PROPERTY(KDecoration2::Decoration *deco READ decoration WRITE setDecoration NOTIFY decorationChanged)
146 Q_PROPERTY(QColor titleBarColor READ titleBarColor NOTIFY colorsChanged)
154 Q_PROPERTY(QColor fontColor READ fontColor NOTIFY colorsChanged)
158 Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY colorsChanged)
162 Q_PROPERTY(QColor borderColor READ borderColor NOTIFY colorsChanged)
166 Q_PROPERTY(QColor resizeHandleColor READ resizeHandleColor NOTIFY colorsChanged)
170 Q_PROPERTY(QFont titleFont READ titleFont NOTIFY fontChanged)
174 Q_PROPERTY(QList<int> titleButtonsLeft READ titleButtonsLeft NOTIFY titleButtonsChanged)
178 Q_PROPERTY(QList<int> titleButtonsRight READ titleButtonsRight NOTIFY titleButtonsChanged)
180public:
192 Q_ENUM(BorderSize)
221 Q_ENUM(DecorationButton)
222 explicit DecorationOptions(QObject *parent = nullptr);
223 ~DecorationOptions() override;
224
225 QColor titleBarColor() const;
226 QColor titleBarBlendColor() const;
227 QColor fontColor() const;
228 QColor buttonColor() const;
229 QColor borderColor() const;
230 QColor resizeHandleColor() const;
231 QFont titleFont() const;
232 QList<int> titleButtonsLeft() const;
233 QList<int> titleButtonsRight() const;
234 KDecoration2::Decoration *decoration() const;
235 void setDecoration(KDecoration2::Decoration *decoration);
236
237 int mousePressAndHoldInterval() const;
238
239Q_SIGNALS:
244
245private Q_SLOTS:
246 void slotActiveChanged();
247
248private:
249 bool m_active;
250 KDecoration2::Decoration *m_decoration;
251 ColorSettings m_colors;
252 QMetaObject::Connection m_paletteConnection;
253};
254
255class Borders : public QObject
256{
257 Q_OBJECT
258 Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged)
259 Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged)
260 Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged)
261 Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
262public:
263 Borders(QObject *parent = nullptr);
264 ~Borders() override;
265 int left() const;
266 int right() const;
267 int top() const;
268 int bottom() const;
269
270 void setLeft(int left);
271 void setRight(int right);
272 void setTop(int top);
273 void setBottom(int bottom);
274
275 operator QMargins() const;
276
277public Q_SLOTS:
281 void setAllBorders(int value);
285 void setBorders(int value);
290 void setSideBorders(int value);
294 void setTitle(int value);
295
296Q_SIGNALS:
301
302private:
303 int m_left;
304 int m_right;
305 int m_top;
306 int m_bottom;
307};
308
309#define GETTER(name) \
310 inline int Borders::name() const \
311 { \
312 return m_##name; \
313 }
314
317GETTER(top)
319
320#undef GETTER
321
322} // namespace
void setBorders(int value)
void setRight(int right)
void rightChanged()
void setBottom(int bottom)
void setLeft(int left)
void topChanged()
void leftChanged()
void setTop(int top)
void bottomChanged()
void setSideBorders(int value)
void setTitle(int value)
void setAllBorders(int value)
const QColor & activeButtonColor() const
const QPalette & palette() const
const QColor & activeTitleBarBlendColor() const
const QColor & activeFrame() const
const QColor & titleBarColor(bool active) const
const QColor & inactiveTitleBarBlendColor() const
const QColor & inactiveFrame() const
const QColor & frame(bool active) const
const QColor & inactiveTitleBarColor() const
const QColor & activeTitleBarColor() const
const QColor & inactiveHandle() const
const QColor & activeHandle() const
const QColor & activeFont() const
void update(const QPalette &pal)
const QColor & inactiveButtonColor() const
ColorSettings(const QPalette &pal)
const QColor & font(bool active) const
const QColor & inactiveFont() const
Common Window Decoration Options.
KDecoration2::Decoration * decoration() const
KDecoration2::Decoration * deco
void setDecoration(KDecoration2::Decoration *decoration)
@ BorderNone
No borders except title.
@ BorderNormal
Standard size borders, the default setting.
@ BorderNoSides
No borders on sides.
@ BorderVeryHuge
Very huge borders.
@ BorderOversized
Oversized borders.
@ BorderVeryLarge
Very large borders.
@ BorderTiny
Minimal borders.
DecorationOptions(QObject *parent=nullptr)
#define GETTER(name)
#define private