diff --git a/src/plugins/decorations/material/materialdecoration.cpp b/src/plugins/decorations/material/materialdecoration.cpp index a81e83e..682a84f 100644 --- a/src/plugins/decorations/material/materialdecoration.cpp +++ b/src/plugins/decorations/material/materialdecoration.cpp @@ -105,7 +105,9 @@ QMargins QWaylandMaterialDecoration::margins(MarginsType marginsType) const // Title bar is 32dp plus borders if (window() && window()->type() == Qt::Popup) return QMargins(0, 0, 0, 0); - if (window() && ((window()->windowStates() & Qt::WindowMaximized) || (window()->windowStates() & Qt::WindowFullScreen))) + if (window() + && ((window()->windowStates() & Qt::WindowMaximized) + || (window()->windowStates() & Qt::WindowFullScreen))) return QMargins(0, TITLE_BAR_HEIGHT, 0, 0); return QMargins(WINDOW_BORDER, TITLE_BAR_HEIGHT, WINDOW_BORDER, WINDOW_BORDER); } @@ -145,15 +147,18 @@ void QWaylandMaterialDecoration::paint(QPaintDevice *device) int radius = window()->windowStates() & Qt::WindowMaximized ? 0 : dp(3); QPainterPath roundedRect; roundedRect.addRoundedRect(margins().left(), margins().top() - TITLE_BAR_HEIGHT, - frameGeometry.width() - margins().left() - margins().right(), TITLE_BAR_HEIGHT + radius * 2, - radius, radius); + frameGeometry.width() - margins().left() - margins().right(), + TITLE_BAR_HEIGHT + radius * 2, radius, radius); p.fillPath(roundedRect.simplified(), m_backgroundColor); // Borders (transparent so the border is not noticeable) QPainterPath borderPath; - borderPath.addRect(0, margins().top(), margins().left(), frameGeometry.height() - margins().top()); - borderPath.addRect(0, frameGeometry.height() - margins().bottom(), frameGeometry.width(), margins().bottom()); - borderPath.addRect(frameGeometry.width() - margins().right(), margins().top(), margins().right(), frameGeometry.height() - margins().bottom()); + borderPath.addRect(0, margins().top(), margins().left(), + frameGeometry.height() - margins().top()); + borderPath.addRect(0, frameGeometry.height() - margins().bottom(), frameGeometry.width(), + margins().bottom()); + borderPath.addRect(frameGeometry.width() - margins().right(), margins().top(), + margins().right(), frameGeometry.height() - margins().bottom()); p.fillPath(borderPath, Qt::transparent); // Window title @@ -195,7 +200,8 @@ void QWaylandMaterialDecoration::paint(QPaintDevice *device) rect = closeButtonRect(); qreal crossSize = rect.height() / 2.3; QPointF crossCenter(rect.center()); - QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize); + QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, + crossSize, crossSize); pen.setWidth(2); p.setPen(pen); p.drawLine(crossRect.topLeft(), crossRect.bottomRight()); @@ -229,7 +235,8 @@ void QWaylandMaterialDecoration::paint(QPaintDevice *device) lines.append(QLineF(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2)); lines.append(QLineF(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2)); lines.append(QLineF(rect.bottomLeft(), rect.bottomRight())); - lines.append(QLineF(rect.left() + 2, rect.top() + 2, rect.right() - 2, rect.top() + 2)); + lines.append( + QLineF(rect.left() + 2, rect.top() + 2, rect.right() - 2, rect.top() + 2)); p.drawLines(lines); } p.restore(); @@ -277,8 +284,9 @@ bool QWaylandMaterialDecoration::handleMouse(QWaylandInputDevice *inputDevice, c QWindowSystemInterface::handleCloseEvent(window()); } else if (isMaximizeable() && maximizeButtonRect().contains(local)) { if (clickButton(b, Maximize)) - window()->setWindowState(window()->windowStates() & Qt::WindowMaximized ? Qt::WindowNoState - : Qt::WindowMaximized); + window()->setWindowState(window()->windowStates() & Qt::WindowMaximized + ? Qt::WindowNoState + : Qt::WindowMaximized); } else if (minimizeButtonRect().contains(local)) { if (clickButton(b, Minimize)) window()->setWindowState(Qt::WindowMinimized); @@ -300,7 +308,9 @@ bool QWaylandMaterialDecoration::handleMouse(QWaylandInputDevice *inputDevice, c return true; } -bool QWaylandMaterialDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) +bool QWaylandMaterialDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, + const QPointF &global, QEventPoint::State state, + Qt::KeyboardModifiers mods) { Q_UNUSED(inputDevice); Q_UNUSED(global); @@ -311,8 +321,9 @@ bool QWaylandMaterialDecoration::handleTouch(QWaylandInputDevice *inputDevice, c if (closeButtonRect().contains(local)) QWindowSystemInterface::handleCloseEvent(window()); else if (isMaximizeable() && maximizeButtonRect().contains(local)) - window()->setWindowState(window()->windowStates() & Qt::WindowMaximized ? Qt::WindowNoState - : Qt::WindowMaximized); + window()->setWindowState(window()->windowStates() & Qt::WindowMaximized + ? Qt::WindowNoState + : Qt::WindowMaximized); else if (minimizeButtonRect().contains(local)) window()->setWindowState(Qt::WindowMinimized); else if (local.y() <= margins().top()) @@ -430,18 +441,16 @@ int QWaylandMaterialDecoration::dp(int dp) const bool QWaylandMaterialDecoration::isMinimizeable() const { - return window()->flags() & Qt::WindowMinimizeButtonHint || - window()->isTopLevel(); + return window()->flags() & Qt::WindowMinimizeButtonHint || window()->isTopLevel(); } bool QWaylandMaterialDecoration::isMaximizeable() const { - return window()->flags() & Qt::WindowMaximizeButtonHint || ( - (window()->maximumSize().width() > window()->minimumSize().width()) && - (window()->maximumSize().height() > window()->minimumSize().height()) - ); + return window()->flags() & Qt::WindowMaximizeButtonHint + || ((window()->maximumSize().width() > window()->minimumSize().width()) + && (window()->maximumSize().height() > window()->minimumSize().height())); } -} +} // namespace QtWaylandClient QT_END_NAMESPACE diff --git a/src/plugins/decorations/material/materialdecoration.h b/src/plugins/decorations/material/materialdecoration.h index f9821e8..9349a4f 100644 --- a/src/plugins/decorations/material/materialdecoration.h +++ b/src/plugins/decorations/material/materialdecoration.h @@ -20,11 +20,9 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient -{ +namespace QtWaylandClient { -enum Button -{ +enum Button { None, Close, Maximize, @@ -34,7 +32,8 @@ enum Button class Q_WAYLANDCLIENT_EXPORT QWaylandMaterialDecoration : public QWaylandAbstractDecoration { Q_OBJECT - Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY + backgroundColorChanged) Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged) Q_PROPERTY(QColor iconColor READ iconColor WRITE setIconColor NOTIFY iconColorChanged) public: @@ -90,4 +89,4 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandMaterialDecoration : public QWaylandAbstrac QColor m_textColor; QStaticText m_windowTitle; }; -} +} // namespace QtWaylandClient diff --git a/src/plugins/platformtheme/hintssettings.cpp b/src/plugins/platformtheme/hintssettings.cpp index db5dadc..53c51f1 100644 --- a/src/plugins/platformtheme/hintssettings.cpp +++ b/src/plugins/platformtheme/hintssettings.cpp @@ -78,14 +78,12 @@ HintsSettings::HintsSettings(QObject *parent) // Change only the few hints involved, for some of these settings // we need to take actions to refresh applications - connect(m_settings, &QtGSettings::QGSettings::settingChanged, this, - [this](const QString &key) { + connect(m_settings, &QtGSettings::QGSettings::settingChanged, this, [this](const QString &key) { if (key == QStringLiteral("cursorBlinkTime")) qtSettingsChanged(); else if (key == QStringLiteral("toolButtonStyle")) toolButtonStyleChanged(); - else if (key == QStringLiteral("iconTheme") || - key == QStringLiteral("toolbarIconsSize")) + else if (key == QStringLiteral("iconTheme") || key == QStringLiteral("toolbarIconsSize")) iconChanged(); else if (key == QStringLiteral("widgetsStyle")) styleChanged(); @@ -139,24 +137,19 @@ void HintsSettings::collectHints() m_hints.insert(QPlatformTheme::UseFullScreenForPopupMenu, true); // TODO: Use the Mac keyboard scheme only if an Apple keyboard is detected // int(MacKeyboardScheme); - m_hints.insert(QPlatformTheme::KeyboardScheme, - int(QPlatformTheme::GnomeKeyboardScheme)); - m_hints.insert(QPlatformTheme::UiEffects, - QPlatformTheme::AnimateMenuUiEffect | - QPlatformTheme::FadeMenuUiEffect | - QPlatformTheme::AnimateComboUiEffect | - QPlatformTheme::AnimateTooltipUiEffect | - QPlatformTheme::FadeTooltipUiEffect | - QPlatformTheme::AnimateToolBoxUiEffect); + m_hints.insert(QPlatformTheme::KeyboardScheme, int(QPlatformTheme::GnomeKeyboardScheme)); + m_hints.insert( + QPlatformTheme::UiEffects, + QPlatformTheme::AnimateMenuUiEffect | QPlatformTheme::FadeMenuUiEffect + | QPlatformTheme::AnimateComboUiEffect | QPlatformTheme::AnimateTooltipUiEffect + | QPlatformTheme::FadeTooltipUiEffect | QPlatformTheme::AnimateToolBoxUiEffect); m_hints.insert(QPlatformTheme::SpellCheckUnderlineStyle, int(QTextCharFormat::SpellCheckUnderline)); m_hints.insert(QPlatformTheme::TabFocusBehavior, int(Qt::TabFocusAllControls)); m_hints.insert(QPlatformTheme::MouseCursorTheme, m_settings->value("cursorTheme"_L1)); m_hints.insert(QPlatformTheme::MouseCursorSize, m_settings->value("cursorSize"_L1)); QList pixmapSizes; - pixmapSizes - << 512 << 256 << 128 << 96 << 64 << 48 - << 32 << 24 << 22 << 16; + pixmapSizes << 512 << 256 << 128 << 96 << 64 << 48 << 32 << 24 << 22 << 16; m_hints.insert(QPlatformTheme::IconPixmapSizes, QVariant::fromValue(pixmapSizes)); } @@ -164,8 +157,9 @@ void HintsSettings::refreshPalette() { // Locate color scheme QString scheme = m_settings->value(QStringLiteral("colorScheme")).toString(); - QString schemeFileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("color-schemes/%1.colors").arg(scheme)); + QString schemeFileName = + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("color-schemes/%1.colors").arg(scheme)); // Palette QPalette systemPalette = QPalette(); @@ -189,25 +183,29 @@ void HintsSettings::refreshFonts() if (QFont *systemFont = readFont(fontFamily, fontSize)) m_resources.fonts[QPlatformTheme::SystemFont] = systemFont; else - m_resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); + m_resources.fonts[QPlatformTheme::SystemFont] = + new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); // Monospace font if (QFont *monospaceFont = readFont(monospaceFontFamily, monospaceFontSize)) m_resources.fonts[QPlatformTheme::FixedFont] = monospaceFont; else - m_resources.fonts[QPlatformTheme::FixedFont] = new QFont(QLatin1String(defaultMonospaceFontName), defaultMonospaceFontSize); + m_resources.fonts[QPlatformTheme::FixedFont] = + new QFont(QLatin1String(defaultMonospaceFontName), defaultMonospaceFontSize); // Small font if (QFont *smallFont = readFont(smallFontFamily, smallFontSize)) m_resources.fonts[QPlatformTheme::SmallFont] = smallFont; else - m_resources.fonts[QPlatformTheme::SmallFont] = new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); + m_resources.fonts[QPlatformTheme::SmallFont] = + new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); // Mini font if (QFont *miniFont = readFont(miniFontFamily, miniFontSize)) m_resources.fonts[QPlatformTheme::MiniFont] = miniFont; else - m_resources.fonts[QPlatformTheme::MiniFont] = new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); + m_resources.fonts[QPlatformTheme::MiniFont] = + new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); // Other fonts QList fonts; @@ -217,7 +215,8 @@ void HintsSettings::refreshFonts() if (QFont *systemFont = readFont(fontFamily, fontSize)) m_resources.fonts[font] = systemFont; else - m_resources.fonts[font] = new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); + m_resources.fonts[font] = + new QFont(QLatin1String(defaultSystemFontName), defaultSystemFontSize); m_resources.fonts[font]->setBold(true); } } diff --git a/src/plugins/platformtheme/hintssettings.h b/src/plugins/platformtheme/hintssettings.h index 85c4555..4e23028 100644 --- a/src/plugins/platformtheme/hintssettings.h +++ b/src/plugins/platformtheme/hintssettings.h @@ -20,17 +20,20 @@ class HintsSettings : public QObject explicit HintsSettings(QObject *parent = nullptr); ~HintsSettings(); - inline QVariant themeHint(QPlatformTheme::ThemeHint hint) const { + inline QVariant themeHint(QPlatformTheme::ThemeHint hint) const + { if (m_hints.contains(hint)) return m_hints[hint]; return QVariant(); } - inline QPalette *palette(QPlatformTheme::Palette type) const { + inline QPalette *palette(QPlatformTheme::Palette type) const + { return m_resources.palettes[type]; } - inline QFont *font(QPlatformTheme::Font type) const { + inline QFont *font(QPlatformTheme::Font type) const + { return m_resources.fonts[type]; } diff --git a/src/plugins/platformtheme/main.cpp b/src/plugins/platformtheme/main.cpp index cd78409..7d88fc1 100644 --- a/src/plugins/platformtheme/main.cpp +++ b/src/plugins/platformtheme/main.cpp @@ -9,7 +9,8 @@ class LiriThemePlugin : public QPlatformThemePlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "liritheme.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE + "liritheme.json") public: explicit LiriThemePlugin(QObject *parent = 0); diff --git a/src/plugins/platformtheme/resourcehelper.cpp b/src/plugins/platformtheme/resourcehelper.cpp index c00d53b..c6be399 100644 --- a/src/plugins/platformtheme/resourcehelper.cpp +++ b/src/plugins/platformtheme/resourcehelper.cpp @@ -38,7 +38,8 @@ void ResourceHelper::readPalette(const QString &fileName, QPalette *pal) { QSettings colorScheme(fileName, QSettings::IniFormat); - if (!readColor(pal, QPalette::Button, colorScheme.value(QStringLiteral("Colors:Button/BackgroundNormal")))) { + if (!readColor(pal, QPalette::Button, + colorScheme.value(QStringLiteral("Colors:Button/BackgroundNormal")))) { // kcolorscheme.cpp: SetDefaultColors const QColor defaultWindowBackground(214, 210, 208); const QColor defaultButtonBackground(223, 220, 217); @@ -46,18 +47,29 @@ void ResourceHelper::readPalette(const QString &fileName, QPalette *pal) return; } - readColor(pal, QPalette::Window, colorScheme.value(QStringLiteral("Colors:Window/BackgroundNormal"))); - readColor(pal, QPalette::Text, colorScheme.value(QStringLiteral("Colors:View/ForegroundNormal"))); - readColor(pal, QPalette::WindowText, colorScheme.value(QStringLiteral("Colors:Window/ForegroundNormal"))); - readColor(pal, QPalette::Base, colorScheme.value(QStringLiteral("Colors:View/BackgroundNormal"))); - readColor(pal, QPalette::Highlight, colorScheme.value(QStringLiteral("Colors:Selection/BackgroundNormal"))); - readColor(pal, QPalette::HighlightedText, colorScheme.value(QStringLiteral("Colors:Selection/ForegroundNormal"))); - readColor(pal, QPalette::AlternateBase, colorScheme.value(QStringLiteral("Colors:View/BackgroundAlternate"))); - readColor(pal, QPalette::ButtonText, colorScheme.value(QStringLiteral("Colors:Button/ForegroundNormal"))); + readColor(pal, QPalette::Window, + colorScheme.value(QStringLiteral("Colors:Window/BackgroundNormal"))); + readColor(pal, QPalette::Text, + colorScheme.value(QStringLiteral("Colors:View/ForegroundNormal"))); + readColor(pal, QPalette::WindowText, + colorScheme.value(QStringLiteral("Colors:Window/ForegroundNormal"))); + readColor(pal, QPalette::Base, + colorScheme.value(QStringLiteral("Colors:View/BackgroundNormal"))); + readColor(pal, QPalette::Highlight, + colorScheme.value(QStringLiteral("Colors:Selection/BackgroundNormal"))); + readColor(pal, QPalette::HighlightedText, + colorScheme.value(QStringLiteral("Colors:Selection/ForegroundNormal"))); + readColor(pal, QPalette::AlternateBase, + colorScheme.value(QStringLiteral("Colors:View/BackgroundAlternate"))); + readColor(pal, QPalette::ButtonText, + colorScheme.value(QStringLiteral("Colors:Button/ForegroundNormal"))); readColor(pal, QPalette::Link, colorScheme.value(QStringLiteral("Colors:View/ForegroundLink"))); - readColor(pal, QPalette::LinkVisited, colorScheme.value(QStringLiteral("Colors:View/ForegroundVisited"))); - readColor(pal, QPalette::ToolTipBase, colorScheme.value(QStringLiteral("Colors:Tooltip/BackgroundNormal"))); - readColor(pal, QPalette::ToolTipText, colorScheme.value(QStringLiteral("Colors:Tooltip/ForegroundNormal"))); + readColor(pal, QPalette::LinkVisited, + colorScheme.value(QStringLiteral("Colors:View/ForegroundVisited"))); + readColor(pal, QPalette::ToolTipBase, + colorScheme.value(QStringLiteral("Colors:Tooltip/BackgroundNormal"))); + readColor(pal, QPalette::ToolTipText, + colorScheme.value(QStringLiteral("Colors:Tooltip/ForegroundNormal"))); // Set all color roles to "normal" colors, but calculate disabled colors const QColor button = pal->color(QPalette::Button); diff --git a/src/plugins/platformtheme/resourcehelper.h b/src/plugins/platformtheme/resourcehelper.h index f09534f..9486396 100644 --- a/src/plugins/platformtheme/resourcehelper.h +++ b/src/plugins/platformtheme/resourcehelper.h @@ -12,7 +12,10 @@ class ResourceHelper { public: explicit ResourceHelper(); - ~ResourceHelper() { clear(); } + ~ResourceHelper() + { + clear(); + } void clear();