Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
grulja authored and urFate committed Nov 1, 2022
1 parent 4093f1a commit a0a6446
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 58 deletions.
22 changes: 11 additions & 11 deletions src/common/gnomesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

#include "gnomesettings.h"
#include "hintprovider.h"
#include "gsettingshintprovider.h"
#include "hintprovider.h"
#include "portalhintprovider.h"

#if QT_VERSION >= 0x060000
Expand All @@ -41,8 +41,8 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QDBusReply>
#include <QDBusServiceWatcher>

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -405,8 +406,7 @@ QStringList GnomeSettings::styleNames() const
}

// 5) Use other styles
styleNames << QStringLiteral("fusion")
<< QStringLiteral("windows");
styleNames << QStringLiteral("fusion") << QStringLiteral("windows");

return styleNames;
}
Expand Down
1 change: 1 addition & 0 deletions src/common/gnomesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private Q_SLOTS:
void onThemeChanged();

void onHintProviderChanged();

private:
void configureKvantum(const QString &theme) const;
void initializeHintProvider() const;
Expand Down
9 changes: 4 additions & 5 deletions src/common/gsettingshintprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ GSettingsHintProvider::~GSettingsHintProvider()
g_object_unref(m_settings);
}


void GSettingsHintProvider::gsettingPropertyChanged(GSettings *settings, gchar *key, GSettingsHintProvider *hintProvider)
{
Q_UNUSED(settings)
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/common/gsettingshintprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ class GSettingsHintProvider : public HintProvider
};

#endif // GSETTINGS_HINT_PROVIDER_H

5 changes: 3 additions & 2 deletions src/common/hintprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,7 +39,8 @@ HintProvider::HintProvider(QObject* parent)
m_hints[QPlatformTheme::PasswordMaskCharacter] = QVariant(QChar(0x2022));
}

HintProvider::~HintProvider() {
HintProvider::~HintProvider()
{
qDeleteAll(m_fonts);
}

Expand Down
49 changes: 37 additions & 12 deletions src/common/hintprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include "gnomesettings.h"

#include <QObject>
#include <QHash>
#include <QObject>
#include <QVariant>

#include <qpa/qplatformtheme.h>
Expand All @@ -38,25 +38,52 @@ class HintProvider : public QObject
explicit HintProvider(QObject *parent = nullptr);
virtual ~HintProvider();

inline QHash<QPlatformTheme::ThemeHint, QVariant> hints() const { return m_hints; }
inline QHash<QPlatformTheme::Font, QFont *> fonts() const { return m_fonts; }
inline QHash<QPlatformTheme::ThemeHint, QVariant> hints() const
{
return m_hints;
}
inline QHash<QPlatformTheme::Font, QFont *> 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();
Expand Down Expand Up @@ -95,5 +122,3 @@ class HintProvider : public QObject
};

#endif // GNOME_SETTINGS_P_H


25 changes: 14 additions & 11 deletions src/common/portalhintprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "portalhintprovider.h"

// QtDBus
#include <QtDBus/QtDBus>
#include <QDBusArgument>
#include <QDBusConnection>
#include <QDBusMessage>
Expand All @@ -30,11 +29,11 @@
#include <QDBusVariant>
#include <QLoggingCategory>
#include <QVariant>
#include <QtDBus/QtDBus>

Q_LOGGING_CATEGORY(QGnomePlatformPortalHintProvider, "qt.qpa.qgnomeplatform.portalhintprovider")

const QDBusArgument
&operator>>(const QDBusArgument &argument, QMap<QString, QVariantMap> &map)
const QDBusArgument &operator>>(const QDBusArgument &argument, QMap<QString, QVariantMap> &map)
{
argument.beginMap();
map.clear();
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand All @@ -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<GnomeSettings::Appearance>(m_portalSettings.value(QStringLiteral("org.freedesktop.appearance")).value(QStringLiteral("color-scheme")).toUInt());
const GnomeSettings::Appearance appearance = static_cast<GnomeSettings::Appearance>(
m_portalSettings.value(QStringLiteral("org.freedesktop.appearance")).value(QStringLiteral("color-scheme")).toUInt());
setTheme(theme, appearance);
}

Expand Down
3 changes: 0 additions & 3 deletions src/common/portalhintprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ private Q_SLOTS:
void loadStaticHints();

QMap<QString, QVariantMap> m_portalSettings;

};

#endif // PORTAL_HINT_PROVIDER_H


5 changes: 3 additions & 2 deletions src/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

#include <pango/pango.h>

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);

Expand Down
9 changes: 5 additions & 4 deletions src/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions src/decoration/qgnomeplatformdecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/theme/qxdgdesktopportalfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <QDBusPendingReply>
#include <QtDBus/QtDBus>

#include <QGuiApplication>
#include <QFile>
#include <QFileInfo>
#include <QGuiApplication>
#include <QMetaType>
#include <QMimeDatabase>
#include <QMimeType>
Expand Down

0 comments on commit a0a6446

Please sign in to comment.