-
Notifications
You must be signed in to change notification settings - Fork 32
feat: sync Xresouces and xsettings scale with treeland scale changes #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright (C) 2025 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #include "abstractsettings.h" | ||
|
|
||
| AbstractSettings::AbstractSettings(xcb_connection_t *connection, QObject *parent) | ||
| : QObject(parent) | ||
| , m_connection(connection) | ||
| { | ||
| } | ||
|
|
||
| AbstractSettings::~AbstractSettings() | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (C) 2025 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <xcb/xcb.h> | ||
|
|
||
| #include <QObject> | ||
| #include <QVariant> | ||
|
|
||
| class AbstractSettings : public QObject | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| explicit AbstractSettings(xcb_connection_t *connection, QObject *parent = nullptr); | ||
| ~AbstractSettings() override; | ||
|
|
||
| virtual bool initialized() const = 0; | ||
| virtual bool isEmpty() const = 0; | ||
|
|
||
| virtual bool contains(const QByteArray &property) const = 0; | ||
| virtual QVariant getPropertyValue(const QByteArray &property) const = 0; | ||
| virtual void setPropertyValue(const QByteArray &property, const QVariant &value) = 0; | ||
| virtual QByteArrayList propertyList() const = 0; | ||
| virtual void apply() = 0; | ||
|
|
||
| Q_SIGNALS: | ||
| void propertyChanged(const QByteArray &property, const QVariant &value); | ||
| void propertyAdded(const QByteArray &property, const QVariant &value); | ||
| void propertyRemoved(const QByteArray &property, const QVariant &value); | ||
|
|
||
| protected: | ||
| xcb_connection_t *m_connection = nullptr; | ||
| xcb_atom_t m_atom = XCB_ATOM_NONE; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // Copyright (C) 2025 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #include "settingmanager.h" | ||
| #include "common/treelandlogging.h" | ||
|
|
||
| const static qreal BASE_DPI = 96; | ||
| const static qreal XSETTINGS_BASE_DPI_FIXED = BASE_DPI * 1024; | ||
|
|
||
| SettingManager::SettingManager(xcb_connection_t *connection, QObject *parent) | ||
| : QObject(parent) | ||
| , m_resource(new XResource(connection, this)) | ||
| , m_settings(new XSettings(connection, this)) | ||
| { | ||
| } | ||
|
|
||
| SettingManager::~SettingManager() | ||
| { | ||
| } | ||
|
|
||
| void SettingManager::setGTKTheme(const QString &themeName) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Gtk_ThemeName), themeName); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gtk_ThemeName), themeName); | ||
| } | ||
|
|
||
| QString SettingManager::GTKTheme() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Gtk_ThemeName)).toString(); | ||
| } | ||
|
|
||
| void SettingManager::setFont(const QString &name) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Gtk_FontName), name); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gtk_FontName), name); | ||
| } | ||
|
|
||
| QString SettingManager::font() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Gtk_FontName)).toString(); | ||
| } | ||
|
|
||
| void SettingManager::setIconTheme(const QString &theme) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Gtk_IconThemeName), theme); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gtk_IconThemeName), theme); | ||
| } | ||
|
|
||
| QString SettingManager::iconTheme() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Gtk_IconThemeName)).toString(); | ||
| } | ||
|
|
||
| void SettingManager::setSoundTheme(const QString &theme) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Net_SoundThemeName), theme); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Net_SoundThemeName), theme); | ||
| } | ||
|
|
||
| QString SettingManager::soundTheme() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Net_SoundThemeName)).toString(); | ||
| } | ||
|
|
||
| void SettingManager::setCursorTheme(const QString &theme) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Gtk_CursorThemeName), theme); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gtk_CursorThemeName), theme); | ||
| } | ||
|
|
||
| QString SettingManager::cursorTheme() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Gtk_CursorThemeName)).toString(); | ||
| } | ||
|
|
||
| void SettingManager::setCursorSize(qreal value) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Xcursor_Size), value); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Xcursor_Size), value); | ||
| } | ||
|
|
||
| qreal SettingManager::cursorSize() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Xcursor_Size)).toReal(); | ||
| } | ||
|
|
||
| void SettingManager::setDoubleClickInterval(int interval) | ||
| { | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Net_DoubleClickTime), interval); | ||
| } | ||
|
|
||
| void SettingManager::setGlobalScale(qreal scale) | ||
| { | ||
| m_resource->setPropertyValue(XResource::toByteArray(XResource::Xft_DPI), scale * BASE_DPI); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gdk_WindowScalingFactor), qFloor(scale)); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Gdk_UnscaledDPI), scale * XSETTINGS_BASE_DPI_FIXED); | ||
| m_settings->setPropertyValue(XSettings::toByteArray(XSettings::Xft_DPI), scale * XSETTINGS_BASE_DPI_FIXED); | ||
| } | ||
|
|
||
| qreal SettingManager::globalScale() const | ||
| { | ||
| return m_settings->getPropertyValue(XSettings::toByteArray(XSettings::Gdk_UnscaledDPI)).toReal() / XSETTINGS_BASE_DPI_FIXED; | ||
| } | ||
|
|
||
| void SettingManager::apply() | ||
| { | ||
| m_resource->apply(); | ||
| m_settings->apply(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (C) 2025 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "xresource.h" | ||
| #include "xsettings.h" | ||
|
|
||
| #include <QObject> | ||
|
|
||
| class SettingManager : public QObject | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| explicit SettingManager(xcb_connection_t *connection, QObject *parent = nullptr); | ||
| ~SettingManager() override; | ||
|
|
||
| void setGTKTheme(const QString &themeName); | ||
| QString GTKTheme() const; | ||
|
|
||
| void setFont(const QString &name); | ||
| QString font() const; | ||
|
|
||
| void setIconTheme(const QString &theme); | ||
| QString iconTheme() const; | ||
|
|
||
| void setSoundTheme(const QString &theme); | ||
| QString soundTheme() const; | ||
|
|
||
| void setCursorTheme(const QString &theme); | ||
| QString cursorTheme() const; | ||
|
|
||
| void setCursorSize(qreal value); | ||
| qreal cursorSize() const; | ||
|
|
||
| void setDoubleClickInterval(int interval); | ||
|
|
||
| void setGlobalScale(qreal scale); | ||
| qreal globalScale() const; | ||
|
|
||
| void apply(); | ||
|
|
||
| private: | ||
| XResource *m_resource = nullptr; | ||
| XSettings *m_settings = nullptr; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.