From a0a6446bf536473c3ee4b19c7654eb6fdcfcce22 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 1 Nov 2022 07:15:39 +0100 Subject: [PATCH] Run clang-format --- src/common/gnomesettings.cpp | 22 ++++----- src/common/gnomesettings.h | 1 + src/common/gsettingshintprovider.cpp | 9 ++-- src/common/gsettingshintprovider.h | 1 - src/common/hintprovider.cpp | 5 ++- src/common/hintprovider.h | 49 ++++++++++++++++----- src/common/portalhintprovider.cpp | 25 ++++++----- src/common/portalhintprovider.h | 3 -- src/common/utils.cpp | 5 ++- src/common/utils.h | 9 ++-- src/decoration/qgnomeplatformdecoration.cpp | 14 +++--- src/theme/qxdgdesktopportalfiledialog.cpp | 2 +- 12 files changed, 87 insertions(+), 58 deletions(-) diff --git a/src/common/gnomesettings.cpp b/src/common/gnomesettings.cpp index d10e252..4491a80 100644 --- a/src/common/gnomesettings.cpp +++ b/src/common/gnomesettings.cpp @@ -18,8 +18,8 @@ */ #include "gnomesettings.h" -#include "hintprovider.h" #include "gsettingshintprovider.h" +#include "hintprovider.h" #include "portalhintprovider.h" #if QT_VERSION >= 0x060000 @@ -41,8 +41,8 @@ #include #include #include -#include #include +#include #include #include @@ -103,7 +103,7 @@ GnomeSettings::GnomeSettings(QObject *parent) watcher->setConnection(QDBusConnection::sessionBus()); watcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange); watcher->addWatchedService(QString::fromLatin1("org.freedesktop.portal.Desktop")); - connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, [=] (const QString &service, const QString &oldOwner, const QString &newOwner) { + connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, [=](const QString &service, const QString &oldOwner, const QString &newOwner) { Q_UNUSED(service) if (newOwner.isEmpty()) { @@ -219,9 +219,7 @@ bool GnomeSettings::useGtkThemeDarkVariant() const return m_hintProvider->appearance() == PreferDark; } - return theme.toLower().contains("-dark") || - theme.toLower().endsWith("inverse") || - m_hintProvider->appearance() == PreferDark; + return theme.toLower().contains("-dark") || theme.toLower().endsWith("inverse") || m_hintProvider->appearance() == PreferDark; } bool GnomeSettings::useGtkThemeHighContrastVariant() const @@ -259,8 +257,8 @@ GnomeSettings::TitlebarButtonsPlacement GnomeSettings::titlebarButtonPlacement() void GnomeSettings::loadPalette() { if (useGtkThemeHighContrastVariant()) { - m_palette = new QPalette( - Adwaita::Colors::palette(useGtkThemeDarkVariant() ? Adwaita::ColorVariant::AdwaitaHighcontrastInverse : Adwaita::ColorVariant::AdwaitaHighcontrast)); + m_palette = new QPalette(Adwaita::Colors::palette(useGtkThemeDarkVariant() ? Adwaita::ColorVariant::AdwaitaHighcontrastInverse + : Adwaita::ColorVariant::AdwaitaHighcontrast)); } else { m_palette = new QPalette(Adwaita::Colors::palette(useGtkThemeDarkVariant() ? Adwaita::ColorVariant::AdwaitaDark : Adwaita::ColorVariant::Adwaita)); } @@ -367,7 +365,10 @@ QStringList GnomeSettings::styleNames() const // 2) Use GTK theme if (!gtkTheme.isEmpty()) { - const QStringList adwaitaStyles = { QStringLiteral("adwaita"), QStringLiteral("adwaita-dark"), QStringLiteral("highcontrast"), QStringLiteral("highcontrastinverse") }; + const QStringList adwaitaStyles = {QStringLiteral("adwaita"), + QStringLiteral("adwaita-dark"), + QStringLiteral("highcontrast"), + QStringLiteral("highcontrastinverse")}; if (adwaitaStyles.contains(gtkTheme.toLower())) { QString theme = gtkTheme; @@ -405,8 +406,7 @@ QStringList GnomeSettings::styleNames() const } // 5) Use other styles - styleNames << QStringLiteral("fusion") - << QStringLiteral("windows"); + styleNames << QStringLiteral("fusion") << QStringLiteral("windows"); return styleNames; } diff --git a/src/common/gnomesettings.h b/src/common/gnomesettings.h index e252605..91179cf 100644 --- a/src/common/gnomesettings.h +++ b/src/common/gnomesettings.h @@ -73,6 +73,7 @@ private Q_SLOTS: void onThemeChanged(); void onHintProviderChanged(); + private: void configureKvantum(const QString &theme) const; void initializeHintProvider() const; diff --git a/src/common/gsettingshintprovider.cpp b/src/common/gsettingshintprovider.cpp index 24632f4..9b80a16 100644 --- a/src/common/gsettingshintprovider.cpp +++ b/src/common/gsettingshintprovider.cpp @@ -96,7 +96,6 @@ GSettingsHintProvider::~GSettingsHintProvider() g_object_unref(m_settings); } - void GSettingsHintProvider::gsettingPropertyChanged(GSettings *settings, gchar *key, GSettingsHintProvider *hintProvider) { Q_UNUSED(settings) @@ -114,13 +113,13 @@ void GSettingsHintProvider::gsettingPropertyChanged(GSettings *settings, gchar * } else if (changedProperty == QStringLiteral("cursor-blink-time")) { hintProvider->loadCursorBlinkTime(); Q_EMIT hintProvider->cursorBlinkTimeChanged(); - } else if (changedProperty == QStringLiteral("font-name") || - changedProperty == QStringLiteral("monospace-font-name") || - changedProperty == QStringLiteral("titlebar-font")) { + } else if (changedProperty == QStringLiteral("font-name") || changedProperty == QStringLiteral("monospace-font-name") + || changedProperty == QStringLiteral("titlebar-font")) { hintProvider->loadFonts(); Q_EMIT hintProvider->fontChanged(); } else if (changedProperty == QStringLiteral("cursor-size")) { - hintProvider->loadCursorSize();; + hintProvider->loadCursorSize(); + ; Q_EMIT hintProvider->fontChanged(); } else if (changedProperty == QStringLiteral("cursor-theme")) { hintProvider->loadCursorTheme(); diff --git a/src/common/gsettingshintprovider.h b/src/common/gsettingshintprovider.h index 34cbc90..bbf02b7 100644 --- a/src/common/gsettingshintprovider.h +++ b/src/common/gsettingshintprovider.h @@ -63,4 +63,3 @@ class GSettingsHintProvider : public HintProvider }; #endif // GSETTINGS_HINT_PROVIDER_H - diff --git a/src/common/hintprovider.cpp b/src/common/hintprovider.cpp index 6a8d12b..07503e7 100644 --- a/src/common/hintprovider.cpp +++ b/src/common/hintprovider.cpp @@ -28,7 +28,7 @@ Q_LOGGING_CATEGORY(QGnomePlatformHintProvider, "qt.qpa.qgnomeplatform.hintprovider") -HintProvider::HintProvider(QObject* parent) +HintProvider::HintProvider(QObject *parent) : QObject(parent) { // Generic hints shared with all providers @@ -39,7 +39,8 @@ HintProvider::HintProvider(QObject* parent) m_hints[QPlatformTheme::PasswordMaskCharacter] = QVariant(QChar(0x2022)); } -HintProvider::~HintProvider() { +HintProvider::~HintProvider() +{ qDeleteAll(m_fonts); } diff --git a/src/common/hintprovider.h b/src/common/hintprovider.h index d07e456..9f9f65a 100644 --- a/src/common/hintprovider.h +++ b/src/common/hintprovider.h @@ -22,8 +22,8 @@ #include "gnomesettings.h" -#include #include +#include #include #include @@ -38,25 +38,52 @@ class HintProvider : public QObject explicit HintProvider(QObject *parent = nullptr); virtual ~HintProvider(); - inline QHash hints() const { return m_hints; } - inline QHash fonts() const { return m_fonts; } + inline QHash hints() const + { + return m_hints; + } + inline QHash fonts() const + { + return m_fonts; + } // Theme - inline QString gtkTheme() const { return m_gtkTheme; } - inline GnomeSettings::Appearance appearance() const { return m_appearance; } + inline QString gtkTheme() const + { + return m_gtkTheme; + } + inline GnomeSettings::Appearance appearance() const + { + return m_appearance; + } // Whether we can assume e.g. Adwaita-dark should be used when Appearance == PreferDark // even though the theme is set to Adwaita // Used only when color-scheme from org.freedesktop.Appearance interface is implemented // in the xdg-desktop-portal backend - inline bool canRelyOnAppearance() const { return m_canRelyOnAppearance; } + inline bool canRelyOnAppearance() const + { + return m_canRelyOnAppearance; + } // Cursor - inline int cursorSize() const { return m_cursorSize; } - inline QString cursorTheme() const { return m_cursorTheme; } + inline int cursorSize() const + { + return m_cursorSize; + } + inline QString cursorTheme() const + { + return m_cursorTheme; + } // Window decorations - inline GnomeSettings::TitlebarButtons titlebarButtons() const { return m_titlebarButtons; } - inline GnomeSettings::TitlebarButtonsPlacement titlebarButtonPlacement() const { return m_titlebarButtonPlacement; } + inline GnomeSettings::TitlebarButtons titlebarButtons() const + { + return m_titlebarButtons; + } + inline GnomeSettings::TitlebarButtonsPlacement titlebarButtonPlacement() const + { + return m_titlebarButtonPlacement; + } Q_SIGNALS: void cursorBlinkTimeChanged(); @@ -95,5 +122,3 @@ class HintProvider : public QObject }; #endif // GNOME_SETTINGS_P_H - - diff --git a/src/common/portalhintprovider.cpp b/src/common/portalhintprovider.cpp index 8b4d988..0cc92d4 100644 --- a/src/common/portalhintprovider.cpp +++ b/src/common/portalhintprovider.cpp @@ -20,7 +20,6 @@ #include "portalhintprovider.h" // QtDBus -#include #include #include #include @@ -30,11 +29,11 @@ #include #include #include +#include Q_LOGGING_CATEGORY(QGnomePlatformPortalHintProvider, "qt.qpa.qgnomeplatform.portalhintprovider") -const QDBusArgument -&operator>>(const QDBusArgument &argument, QMap &map) +const QDBusArgument &operator>>(const QDBusArgument &argument, QMap &map) { argument.beginMap(); map.clear(); @@ -59,7 +58,9 @@ PortalHintProvider::PortalHintProvider(QObject *parent, bool asynchronous) QStringLiteral("/org/freedesktop/portal/desktop"), QStringLiteral("org.freedesktop.portal.Settings"), QStringLiteral("ReadAll")); - message << QStringList{{QStringLiteral("org.gnome.desktop.interface")}, {QStringLiteral("org.gnome.desktop.wm.preferences")}, {QStringLiteral("org.freedesktop.appearance")}}; + message << QStringList{{QStringLiteral("org.gnome.desktop.interface")}, + {QStringLiteral("org.gnome.desktop.wm.preferences")}, + {QStringLiteral("org.freedesktop.appearance")}}; qCDebug(QGnomePlatformPortalHintProvider) << "Reading settings from xdg-desktop-portal"; if (asynchronous) { @@ -123,13 +124,12 @@ void PortalHintProvider::settingChanged(const QString &group, const QString &key } else if (key == QStringLiteral("cursor-blink-time")) { loadCursorBlinkTime(); Q_EMIT cursorBlinkTimeChanged(); - } else if (key == QStringLiteral("font-name") || - key == QStringLiteral("monospace-font-name") || - key == QStringLiteral("titlebar-font")) { + } else if (key == QStringLiteral("font-name") || key == QStringLiteral("monospace-font-name") || key == QStringLiteral("titlebar-font")) { loadFonts(); Q_EMIT fontChanged(); } else if (key == QStringLiteral("cursor-size")) { - loadCursorSize();; + loadCursorSize(); + ; Q_EMIT fontChanged(); } else if (key == QStringLiteral("cursor-theme")) { loadCursorTheme(); @@ -167,8 +167,10 @@ void PortalHintProvider::loadIconTheme() void PortalHintProvider::loadFonts() { const QString fontName = m_portalSettings.value(QStringLiteral("org.gnome.desktop.interface")).value(QStringLiteral("font-name")).toString(); - const QString monospaceFontName = m_portalSettings.value(QStringLiteral("org.gnome.desktop.interface")).value(QStringLiteral("monospace-font-name")).toString(); - const QString titlebarFontName = m_portalSettings.value(QStringLiteral("org.gnome.desktop.wm.preferences")).value(QStringLiteral("titlebar-font")).toString(); + const QString monospaceFontName = + m_portalSettings.value(QStringLiteral("org.gnome.desktop.interface")).value(QStringLiteral("monospace-font-name")).toString(); + const QString titlebarFontName = + m_portalSettings.value(QStringLiteral("org.gnome.desktop.wm.preferences")).value(QStringLiteral("titlebar-font")).toString(); setFonts(fontName, monospaceFontName, titlebarFontName); } @@ -181,7 +183,8 @@ void PortalHintProvider::loadTitlebar() void PortalHintProvider::loadTheme() { const QString theme = m_portalSettings.value(QStringLiteral("org.gnome.desktop.interface")).value(QStringLiteral("gtk-theme")).toString(); - const GnomeSettings::Appearance appearance = static_cast(m_portalSettings.value(QStringLiteral("org.freedesktop.appearance")).value(QStringLiteral("color-scheme")).toUInt()); + const GnomeSettings::Appearance appearance = static_cast( + m_portalSettings.value(QStringLiteral("org.freedesktop.appearance")).value(QStringLiteral("color-scheme")).toUInt()); setTheme(theme, appearance); } diff --git a/src/common/portalhintprovider.h b/src/common/portalhintprovider.h index d05af52..9ec5823 100644 --- a/src/common/portalhintprovider.h +++ b/src/common/portalhintprovider.h @@ -53,9 +53,6 @@ private Q_SLOTS: void loadStaticHints(); QMap m_portalSettings; - }; #endif // PORTAL_HINT_PROVIDER_H - - diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 9f5327f..3acd9d3 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -23,10 +23,11 @@ #include -namespace Utils { +namespace Utils +{ // FIXME: duplicate -QFont* qt_fontFromString(const QString &name) +QFont *qt_fontFromString(const QString &name) { QFont *font = new QFont(QLatin1String("Sans"), 10); diff --git a/src/common/utils.h b/src/common/utils.h index 6345ac1..de884c8 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -25,10 +25,11 @@ class QFont; class QString; -namespace Utils { - QFont* qt_fontFromString(const QString &name); - GnomeSettings::TitlebarButtons titlebarButtonsFromString(const QString &layout); - GnomeSettings::TitlebarButtonsPlacement titlebarButtonPlacementFromString(const QString &layout); +namespace Utils +{ +QFont *qt_fontFromString(const QString &name); +GnomeSettings::TitlebarButtons titlebarButtonsFromString(const QString &layout); +GnomeSettings::TitlebarButtonsPlacement titlebarButtonPlacementFromString(const QString &layout); } #endif // UTILS_H diff --git a/src/decoration/qgnomeplatformdecoration.cpp b/src/decoration/qgnomeplatformdecoration.cpp index 5fbb95d..1673dd9 100644 --- a/src/decoration/qgnomeplatformdecoration.cpp +++ b/src/decoration/qgnomeplatformdecoration.cpp @@ -78,11 +78,11 @@ QGnomePlatformDecoration::QGnomePlatformDecoration() option.setWrapMode(QTextOption::NoWrap); m_windowTitle.setTextOption(option); - connect(&GnomeSettings::getInstance(), &GnomeSettings::themeChanged, this, [this] () { + connect(&GnomeSettings::getInstance(), &GnomeSettings::themeChanged, this, [this]() { loadConfiguration(); forceRepaint(); }); - connect(&GnomeSettings::getInstance(), &GnomeSettings::titlebarChanged, this, [this] () { + connect(&GnomeSettings::getInstance(), &GnomeSettings::titlebarChanged, this, [this]() { loadConfiguration(); forceRepaint(); }); @@ -125,8 +125,8 @@ QRectF QGnomePlatformDecoration::minimizeButtonRect() const const bool maximizeEnabled = GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton); if (GnomeSettings::getInstance().titlebarButtonPlacement() == GnomeSettings::getInstance().RightPlacement) { - return QRectF(windowContentGeometry().width() - BUTTON_WIDTH * (maximizeEnabled ? 3 : 2) - (BUTTON_SPACING * (maximizeEnabled ? 2 : 1)) - - BUTTON_MARGINS - margins().right(), + return QRectF(windowContentGeometry().width() - BUTTON_WIDTH * (maximizeEnabled ? 3 : 2) - (BUTTON_SPACING * (maximizeEnabled ? 2 : 1)) - BUTTON_MARGINS + - margins().right(), (margins().top() - BUTTON_WIDTH + margins().bottom()) / 2, BUTTON_WIDTH, BUTTON_WIDTH); @@ -526,9 +526,11 @@ bool QGnomePlatformDecoration::handleTouch(QWaylandInputDevice *inputDevice, if (handled) { if (closeButtonRect().contains(local)) { QWindowSystemInterface::handleCloseEvent(window()); - } else if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton) && maximizeButtonRect().contains(local)) { + } else if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton) + && maximizeButtonRect().contains(local)) { window()->setWindowStates(window()->windowStates() ^ Qt::WindowMaximized); - } else if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MinimizeButton) && minimizeButtonRect().contains(local)) { + } else if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MinimizeButton) + && minimizeButtonRect().contains(local)) { window()->setWindowState(Qt::WindowMinimized); } else if (local.y() <= margins().top()) { waylandWindow()->shellSurface()->move(inputDevice); diff --git a/src/theme/qxdgdesktopportalfiledialog.cpp b/src/theme/qxdgdesktopportalfiledialog.cpp index 4892d59..52fe6a9 100644 --- a/src/theme/qxdgdesktopportalfiledialog.cpp +++ b/src/theme/qxdgdesktopportalfiledialog.cpp @@ -28,9 +28,9 @@ #include #include -#include #include #include +#include #include #include #include