14#include <QStandardPaths>
17#include <KConfigGroup>
19Q_LOGGING_CATEGORY(AURORAE,
"aurorae", QtWarningMsg)
35 QHash<AuroraeButtonType, QString>
pathes;
44 : activeCompositing(true)
57 QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
60 file += QLatin1String(
"z");
61 path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
63 if (!path.isEmpty()) {
85 return !d->themeName.isNull();
90 KConfig conf(QStringLiteral(
"auroraerc"));
91 KConfig config(QLatin1String(
"aurorae/themes/") + name + QLatin1Char(
'/') + name + QLatin1String(
"rc"),
92 KConfig::FullConfig, QStandardPaths::GenericDataLocation);
93 KConfigGroup themeGroup(&conf, name);
100 QString file(QLatin1String(
"aurorae/themes/") + d->themeName + QLatin1String(
"/decoration.svg"));
101 QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
102 if (path.isEmpty()) {
103 file += QLatin1String(
"z");
104 path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);
106 if (path.isEmpty()) {
107 qCDebug(AURORAE) <<
"Could not find decoration svg: aborting";
108 d->themeName.clear();
111 d->decorationPath = path;
124 d->themeConfig.load(config);
130 return d->pathes.contains(button);
137 return QLatin1String(
"minimize");
139 return QLatin1String(
"maximize");
141 return QLatin1String(
"restore");
143 return QLatin1String(
"close");
145 return QLatin1String(
"alldesktops");
147 return QLatin1String(
"keepabove");
149 return QLatin1String(
"keepbelow");
151 return QLatin1String(
"shade");
153 return QLatin1String(
"help");
155 return QLatin1String(
"menu");
157 return QLatin1String(
"appmenu");
159 return QLatin1String(
"");
168void AuroraeTheme::borders(
int &left,
int &top,
int &right,
int &bottom,
bool maximized)
const
170 const qreal
titleHeight = std::max((qreal)d->themeConfig.titleHeight(),
171 d->themeConfig.buttonHeight() *
buttonSizeFactor() + d->themeConfig.buttonMarginTop());
173 const qreal title =
titleHeight + d->themeConfig.titleEdgeTopMaximized() + d->themeConfig.titleEdgeBottomMaximized();
176 left = right = bottom = 0;
180 left = right = top = 0;
184 top = right = bottom = 0;
188 left = top = bottom = 0;
192 left = right = bottom = top = 0;
198 switch (d->borderSize) {
199 case KDecoration2::BorderSize::NoSides:
200 case KDecoration2::BorderSize::Tiny:
204 case KDecoration2::BorderSize::Normal:
208 case KDecoration2::BorderSize::Large:
212 case KDecoration2::BorderSize::VeryLarge:
216 case KDecoration2::BorderSize::Huge:
220 case KDecoration2::BorderSize::VeryHuge:
224 case KDecoration2::BorderSize::Oversized:
233 left = std::clamp(d->themeConfig.borderLeft(), minMargin, maxMargin);
234 right = std::clamp(d->themeConfig.borderRight(), minMargin, maxMargin);
235 bottom = std::clamp(d->themeConfig.borderBottom(), minMargin, maxMargin);
237 if (d->borderSize == KDecoration2::BorderSize::None) {
241 }
else if (d->borderSize == KDecoration2::BorderSize::NoSides) {
246 const qreal title =
titleHeight + d->themeConfig.titleEdgeTop() + d->themeConfig.titleEdgeBottom();
261 left = right = bottom = top = 0;
269 int left, top, right, bottom;
270 left = top = right = bottom = 0;
271 borders(left, top, right, bottom,
false);
277 int left, top, right, bottom;
278 left = top = right = bottom = 0;
279 borders(left, top, right, bottom,
false);
285 int left, top, right, bottom;
286 left = top = right = bottom = 0;
287 borders(left, top, right, bottom,
false);
293 int left, top, right, bottom;
294 left = top = right = bottom = 0;
295 borders(left, top, right, bottom,
false);
301 int left, top, right, bottom;
302 left = top = right = bottom = 0;
303 borders(left, top, right, bottom,
true);
309 int left, top, right, bottom;
310 left = top = right = bottom = 0;
311 borders(left, top, right, bottom,
true);
317 int left, top, right, bottom;
318 left = top = right = bottom = 0;
319 borders(left, top, right, bottom,
true);
325 int left, top, right, bottom;
326 left = top = right = bottom = 0;
327 borders(left, top, right, bottom,
true);
331void AuroraeTheme::padding(
int &left,
int &top,
int &right,
int &bottom)
const
333 left = d->themeConfig.paddingLeft();
334 top = d->themeConfig.paddingTop();
335 right = d->themeConfig.paddingRight();
336 bottom = d->themeConfig.paddingBottom();
339#define THEME_CONFIG(prototype) \
340 int AuroraeTheme::prototype() const \
342 return d->themeConfig.prototype(); \
377#define THEME_CONFIG_TYPE(rettype, prototype) \
378 rettype AuroraeTheme::prototype() const \
380 return d->themeConfig.prototype(); \
388#undef THEME_CONFIG_TYPE
392 return d->decorationPath;
395#define BUTTON_PATH(prototype, buttonType) \
396 QString AuroraeTheme::prototype() const \
398 if (hasButton(buttonType)) { \
399 return d->pathes[buttonType]; \
420 left = d->themeConfig.titleEdgeLeftMaximized();
421 top = d->themeConfig.titleEdgeTopMaximized();
422 right = d->themeConfig.titleEdgeRightMaximized();
423 bottom = d->themeConfig.titleEdgeBottomMaximized();
425 left = d->themeConfig.titleEdgeLeft();
426 top = d->themeConfig.titleEdgeTop();
427 right = d->themeConfig.titleEdgeRight();
428 bottom = d->themeConfig.titleEdgeBottom();
434 return d->activeCompositing;
439 d->activeCompositing = active;
444 if (d->borderSize == size) {
447 d->borderSize = size;
453 if (d->buttonSize == size) {
456 d->buttonSize = size;
462 d->dragMimeType = mime;
467 return d->dragMimeType;
472 switch (d->buttonSize) {
473 case KDecoration2::BorderSize::Tiny:
475 case KDecoration2::BorderSize::Large:
477 case KDecoration2::BorderSize::VeryLarge:
479 case KDecoration2::BorderSize::Huge:
481 case KDecoration2::BorderSize::VeryHuge:
483 case KDecoration2::BorderSize::Oversized:
485 case KDecoration2::BorderSize::Normal:
498#include "moc_auroraetheme.cpp"
#define THEME_CONFIG(prototype)
#define BUTTON_PATH(prototype, buttonType)
#define THEME_CONFIG_TYPE(rettype, prototype)
const QString & tabDragMimeType() const
static QLatin1String mapButtonToName(AuroraeButtonType type)
int rightBorderMaximized() const
bool hasButton(AuroraeButtonType button) const
int bottomBorderMaximized() const
bool isCompositingActive() const
void titleEdges(int &left, int &top, int &right, int &bottom, bool maximized) const
void setCompositingActive(bool active)
void setButtonSize(KDecoration2::BorderSize size)
void setTabDragMimeType(const QString &mime)
void borderSizesChanged()
void buttonSizesChanged()
int leftBorderMaximized() const
void loadTheme(const QString &name, const KConfig &config)
void setBorderSize(KDecoration2::BorderSize size)
AuroraeTheme(QObject *parent=nullptr)
int topBorderMaximized() const
DecorationPosition decorationPosition() const
KDecoration2::BorderSize borderSize
KDecoration2::BorderSize buttonSize
Aurorae::ThemeConfig themeConfig
QHash< AuroraeButtonType, QString > pathes
void initButtonFrame(AuroraeButtonType type)