Theme: Add system effects option

pull/26/head
reionwong 4 years ago
parent 23ca4cffa8
commit c99fbca89b

@ -25,6 +25,9 @@
#include <QDBusServiceWatcher> #include <QDBusServiceWatcher>
#include <QDBusPendingCall> #include <QDBusPendingCall>
#include <QStandardPaths>
#include <QDebug>
Appearance::Appearance(QObject *parent) Appearance::Appearance(QObject *parent)
: QObject(parent) : QObject(parent)
, m_interface("org.cutefish.Settings", , m_interface("org.cutefish.Settings",
@ -32,16 +35,22 @@ Appearance::Appearance(QObject *parent)
"org.cutefish.Theme", "org.cutefish.Theme",
QDBusConnection::sessionBus()) QDBusConnection::sessionBus())
, m_dockSettings(new QSettings(QSettings::UserScope, "cutefishos", "dock")) , m_dockSettings(new QSettings(QSettings::UserScope, "cutefishos", "dock"))
, m_kwinSettings(new QSettings(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/kwinrc",
QSettings::IniFormat))
, m_dockConfigWacher(new QFileSystemWatcher(this)) , m_dockConfigWacher(new QFileSystemWatcher(this))
, m_dockIconSize(0) , m_dockIconSize(0)
, m_dockDirection(0) , m_dockDirection(0)
, m_dockVisibility(0) , m_dockVisibility(0)
, m_fontPointSize(11) , m_fontPointSize(11)
, m_systemEffects(false)
{ {
m_kwinSettings->beginGroup("Compositing");
m_dockIconSize = m_dockSettings->value("IconSize").toInt(); m_dockIconSize = m_dockSettings->value("IconSize").toInt();
m_dockDirection = m_dockSettings->value("Direction").toInt(); m_dockDirection = m_dockSettings->value("Direction").toInt();
m_dockVisibility = m_dockSettings->value("Visibility").toInt(); m_dockVisibility = m_dockSettings->value("Visibility").toInt();
m_dockRoundedWindow = m_dockSettings->value("RoundedWindow").toBool(); m_dockRoundedWindow = m_dockSettings->value("RoundedWindow").toBool();
m_systemEffects = !m_kwinSettings->value("OpenGLIsUnsafe", false).toBool();
m_dockConfigWacher->addPath(m_dockSettings->fileName()); m_dockConfigWacher->addPath(m_dockSettings->fileName());
connect(m_dockConfigWacher, &QFileSystemWatcher::fileChanged, this, [=] { connect(m_dockConfigWacher, &QFileSystemWatcher::fileChanged, this, [=] {
@ -209,3 +218,19 @@ void Appearance::setDevicePixelRatio(double value)
iface.call("setDevicePixelRatio", value); iface.call("setDevicePixelRatio", value);
} }
} }
bool Appearance::systemEffects() const
{
return m_systemEffects;
}
void Appearance::setSystemEffects(bool systemEffects)
{
if (m_systemEffects != systemEffects) {
m_systemEffects = systemEffects;
m_kwinSettings->setValue("OpenGLIsUnsafe", !systemEffects);
m_kwinSettings->sync();
QDBusInterface("org.kde.KWin", "/KWin").call("reconfigure");
emit systemEffectsChanged();
}
}

@ -35,6 +35,7 @@ class Appearance : public QObject
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper WRITE setDimsWallpaper NOTIFY dimsWallpaperChanged) Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper WRITE setDimsWallpaper NOTIFY dimsWallpaperChanged)
Q_PROPERTY(double devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged) Q_PROPERTY(double devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
Q_PROPERTY(bool dockRoundedWindow READ dockRoundedWindow WRITE setDockRoundedWindow NOTIFY dockRoundedWindowChanged) Q_PROPERTY(bool dockRoundedWindow READ dockRoundedWindow WRITE setDockRoundedWindow NOTIFY dockRoundedWindowChanged)
Q_PROPERTY(bool systemEffects READ systemEffects WRITE setSystemEffects NOTIFY systemEffectsChanged)
public: public:
explicit Appearance(QObject *parent = nullptr); explicit Appearance(QObject *parent = nullptr);
@ -67,6 +68,9 @@ public:
double devicePixelRatio() const; double devicePixelRatio() const;
Q_INVOKABLE void setDevicePixelRatio(double value); Q_INVOKABLE void setDevicePixelRatio(double value);
bool systemEffects() const;
void setSystemEffects(bool systemEffects);
signals: signals:
void dockIconSizeChanged(); void dockIconSizeChanged();
void dockDirectionChanged(); void dockDirectionChanged();
@ -75,10 +79,12 @@ signals:
void dimsWallpaperChanged(); void dimsWallpaperChanged();
void devicePixelRatioChanged(); void devicePixelRatioChanged();
void dockRoundedWindowChanged(); void dockRoundedWindowChanged();
void systemEffectsChanged();
private: private:
QDBusInterface m_interface; QDBusInterface m_interface;
QSettings *m_dockSettings; QSettings *m_dockSettings;
QSettings *m_kwinSettings;
QFileSystemWatcher *m_dockConfigWacher; QFileSystemWatcher *m_dockConfigWacher;
bool m_dockRoundedWindow; bool m_dockRoundedWindow;
@ -86,6 +92,8 @@ private:
int m_dockDirection; int m_dockDirection;
int m_dockVisibility; int m_dockVisibility;
int m_fontPointSize; int m_fontPointSize;
bool m_systemEffects;
}; };
#endif // APPEARANCE_H #endif // APPEARANCE_H

@ -26,7 +26,7 @@
#include <unicode/unistr.h> #include <unicode/unistr.h>
static const QStringList supportList = {"en_US", "en_GB", "de_DE", "cs_CZ", "es_ES", static const QStringList supportList = {"en_US", "en_GB", "de_DE", "cs_CZ", "es_ES",
"es_MX", "fa_IR", "fi_FI", "fr_FR", "es_MX", "ar_AA", "bg_BG", "fa_IR", "fi_FI", "fr_FR",
"uk_UA", "uz_UZ", "hu_HU", "hi_IN", "id_ID" "uk_UA", "uz_UZ", "hu_HU", "hi_IN", "id_ID"
"it_IT", "ja_JP", "nb_NO", "ne_NP", "pl_PL", "it_IT", "ja_JP", "nb_NO", "ne_NP", "pl_PL",
"pt_BR", "pt_PT", "ru_RU", "sv_SE", "so", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "so",

@ -91,6 +91,25 @@ ItemPage {
rightPadding: 0 rightPadding: 0
} }
} }
RowLayout {
Label {
text: qsTr("System effects")
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
}
Item {
Layout.fillWidth: true
}
Switch {
checked: appearance.systemEffects
Layout.fillHeight: true
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
onCheckedChanged: appearance.systemEffects = checked
rightPadding: 0
}
}
} }
RoundedItem { RoundedItem {

@ -137,7 +137,12 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../src/qml/Appearance/Main.qml" line="98"/> <location filename="../src/qml/Appearance/Main.qml" line="97"/>
<source>System effects</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/qml/Appearance/Main.qml" line="117"/>
<source>Accent color</source> <source>Accent color</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

@ -137,7 +137,12 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/qml/Appearance/Main.qml" line="98"/> <location filename="../src/qml/Appearance/Main.qml" line="97"/>
<source>System effects</source>
<translation></translation>
</message>
<message>
<location filename="../src/qml/Appearance/Main.qml" line="117"/>
<source>Accent color</source> <source>Accent color</source>
<translation></translation> <translation></translation>
</message> </message>

Loading…
Cancel
Save