diff --git a/dbus/org.deepin.dde.Appearance1.xml b/dbus/org.deepin.dde.Appearance1.xml index d70aff5..b652657 100644 --- a/dbus/org.deepin.dde.Appearance1.xml +++ b/dbus/org.deepin.dde.Appearance1.xml @@ -86,6 +86,7 @@ + diff --git a/misc/dconfig/org.deepin.dde.appearance.json b/misc/dconfig/org.deepin.dde.appearance.json index b612e6e..a66e9ff 100644 --- a/misc/dconfig/org.deepin.dde.appearance.json +++ b/misc/dconfig/org.deepin.dde.appearance.json @@ -161,6 +161,26 @@ "description": "Save all the wallpaper URL information.", "permissions": "readwrite", "visibility": "private" + }, + "Dtk_Size_Mode": { + "value": 0, + "serial": 0, + "flags": [], + "name": "Dtk_Size_Mode", + "name[zh_CN]": "紧凑模式", + "description": "Compact Mode.", + "permissions": "readwrite", + "visibility": "private" + }, + "Compact_Font_Size": { + "value": 9.0, + "serial": 0, + "flags": [], + "name": "Compact_Font_Size", + "name[zh_CN]": "紧凑模式下,字体大小", + "description": "Compact font size.", + "permissions": "readwrite", + "visibility": "private" } } } diff --git a/src/service/dbus/appearance1.cpp b/src/service/dbus/appearance1.cpp index b35396f..533e833 100644 --- a/src/service/dbus/appearance1.cpp +++ b/src/service/dbus/appearance1.cpp @@ -121,12 +121,23 @@ int Appearance1::windowRadius() const return appearance1Thread->windowRadius(); } +int Appearance1::dtkSizeMode() const +{ + return appearance1Thread->dtkSizeMode(); +} + void Appearance1::setWindowRadius(int value) { // message.setDelayedReply(true); QMetaObject::invokeMethod(appearance1Thread.get(), "setWindowRadius", Qt::QueuedConnection, Q_ARG(int, value)); } +void Appearance1::setDTKSizeMode(int value) +{ + // message.setDelayedReply(true); + QMetaObject::invokeMethod(appearance1Thread.get(), "setDTKSizeMode", Qt::QueuedConnection, Q_ARG(int, value)); +} + void Appearance1::Delete(const QString &ty, const QString &name) { auto message = this->message(); diff --git a/src/service/dbus/appearance1.h b/src/service/dbus/appearance1.h index 16e3b20..d62e8de 100644 --- a/src/service/dbus/appearance1.h +++ b/src/service/dbus/appearance1.h @@ -65,6 +65,10 @@ class Appearance1 : public QObject, protected QDBusContext int windowRadius() const; void setWindowRadius(int value); + Q_PROPERTY(int DTKSizeMode READ dtkSizeMode WRITE setDTKSizeMode) + int dtkSizeMode() const; + void setDTKSizeMode(int value); + public Q_SLOTS: // METHODS void Delete(const QString &ty, const QString &name); QString GetCurrentWorkspaceBackground(); diff --git a/src/service/dbus/appearance1thread.cpp b/src/service/dbus/appearance1thread.cpp index 7001bf8..baa977d 100644 --- a/src/service/dbus/appearance1thread.cpp +++ b/src/service/dbus/appearance1thread.cpp @@ -28,7 +28,9 @@ Appearance1Thread::Appearance1Thread() property->cursorTheme.init(settingDconfig.value(GSKEYCURSORTHEME).toString()); property->standardFont.init(settingDconfig.value(GSKEYFONTSTANDARD).toString()); property->monospaceFont.init(settingDconfig.value(GSKEYFONTMONOSPACE).toString()); - property->fontSize.init(settingDconfig.value(GSKEYFONTSIZE).toDouble()); + property->dtkSizeMode.init(settingDconfig.value(DDTKSIZEMODE).toInt()); + // dtkSizeMode必须先于fontSize初始化,紧凑模式下,使用Compact_Font_Size配置 + property->fontSize.init(settingDconfig.value(property->dtkSizeMode == 1 ? DCOMPACTFONTSIZE : GSKEYFONTSIZE).toDouble()); property->opacity.init(settingDconfig.value(GSKEYOPACITY).toDouble()); property->wallpaperSlideShow.init(settingDconfig.value(GSKEYWALLPAPERSLIDESHOW).toString()); property->wallpaperURls.init(settingDconfig.value(GSKEYWALLPAPERURIS).toString()); @@ -139,6 +141,17 @@ QString Appearance1Thread::wallpaperURls() const return property->wallpaperURls; } +int Appearance1Thread::dtkSizeMode() const +{ + return property->dtkSizeMode; +} + +void Appearance1Thread::setDTKSizeMode(int value) +{ + QMutexLocker locker(&mutex); + appearanceManager->doSetDTKSizeMode(value); +} + int Appearance1Thread::windowRadius() const { return property->windowRadius; @@ -210,7 +223,7 @@ void Appearance1Thread::Reset(const QDBusMessage &message) { Q_UNUSED(message); QMutexLocker locker(&mutex); - QStringList keys{GSKEYGLOBALTHEME, GSKEYGTKTHEME, GSKEYICONTHEM, GSKEYCURSORTHEME, GSKEYFONTSIZE}; + QStringList keys{GSKEYGLOBALTHEME, GSKEYGTKTHEME, GSKEYICONTHEM, GSKEYCURSORTHEME, GSKEYFONTSIZE, DDTKSIZEMODE, DCOMPACTFONTSIZE}; appearanceManager->doResetSettingBykeys(keys); diff --git a/src/service/dbus/appearance1thread.h b/src/service/dbus/appearance1thread.h index 389c793..af77854 100644 --- a/src/service/dbus/appearance1thread.h +++ b/src/service/dbus/appearance1thread.h @@ -60,6 +60,9 @@ class Appearance1Thread : public QObject Q_PROPERTY(int WindowRadius READ windowRadius WRITE setWindowRadius) int windowRadius() const; + Q_PROPERTY(int DTKSizeMode READ dtkSizeMode WRITE setDTKSizeMode) + int dtkSizeMode() const; + public Q_SLOTS: // PROPERTIES void setFontSize(double value); @@ -67,6 +70,7 @@ public Q_SLOTS: void setQtActiveColor(const QString &value); void setWallpaperSlideShow(const QString &value); void setWindowRadius(int value); + void setDTKSizeMode(int value); // METHODS void Delete(const QString &ty, const QString &name, const QDBusMessage &message); QString GetCurrentWorkspaceBackground(const QDBusMessage &message); diff --git a/src/service/dbus/appearancedbusproxy.cpp b/src/service/dbus/appearancedbusproxy.cpp index 76f57e9..8bac325 100644 --- a/src/service/dbus/appearancedbusproxy.cpp +++ b/src/service/dbus/appearancedbusproxy.cpp @@ -106,6 +106,10 @@ void AppearanceDBusProxy::SetString(const QString &prop, const QString &v) { m_xSettingsInterface->asyncCall(QStringLiteral("SetString"), prop, v); } +void AppearanceDBusProxy::SetInteger(const QString &prop, const int &v) +{ + m_xSettingsInterface->asyncCall(QStringLiteral("SetInteger"), prop, v); +} double AppearanceDBusProxy::GetScaleFactor() { return QDBusPendingReply(m_xSettingsInterface->asyncCall(QStringLiteral("GetScaleFactor"))); diff --git a/src/service/dbus/appearancedbusproxy.h b/src/service/dbus/appearancedbusproxy.h index 09d2691..c2f59d7 100644 --- a/src/service/dbus/appearancedbusproxy.h +++ b/src/service/dbus/appearancedbusproxy.h @@ -61,6 +61,7 @@ public Q_SLOTS: // xSettingsInterface public Q_SLOTS: void SetString(const QString &prop, const QString &v); + void SetInteger(const QString &prop, const int &v); double GetScaleFactor(); void SetScaleFactor(double scale); ScaleFactors GetScreenScaleFactors(); diff --git a/src/service/dbus/appearanceproperty.cpp b/src/service/dbus/appearanceproperty.cpp index 2c3574a..a19f0b9 100644 --- a/src/service/dbus/appearanceproperty.cpp +++ b/src/service/dbus/appearanceproperty.cpp @@ -37,6 +37,7 @@ AppearanceProperty::AppearanceProperty() , wallpaperSlideShow("WallpaperSlideShow") , wallpaperURls("WallpaperURls") , windowRadius("WindowRadius") + , dtkSizeMode("DTKSizeMode") { fontSize.init(0.0); opacity.init(0.0); diff --git a/src/service/dbus/appearanceproperty.h b/src/service/dbus/appearanceproperty.h index 2c148e0..e506d0b 100644 --- a/src/service/dbus/appearanceproperty.h +++ b/src/service/dbus/appearanceproperty.h @@ -65,6 +65,7 @@ class AppearanceProperty DBusProperty wallpaperSlideShow; DBusProperty wallpaperURls; DBusProperty windowRadius; + DBusProperty dtkSizeMode; }; #endif // APPEARANCEPROPERTY_H diff --git a/src/service/impl/appearancemanager.cpp b/src/service/impl/appearancemanager.cpp index fb5d3da..c0be7e1 100644 --- a/src/service/impl/appearancemanager.cpp +++ b/src/service/impl/appearancemanager.cpp @@ -117,6 +117,7 @@ bool AppearanceManager::init() connect(m_dbusProxy.get(), &AppearanceDBusProxy::TimeUpdate, this, &AppearanceManager::handleTimeUpdate); connect(m_dbusProxy.get(), &AppearanceDBusProxy::HandleForSleep, this, &AppearanceManager::handlePrepareForSleep); + initDtkSizeMode(); initGlobalTheme(); QVector> iconList = m_subthemes->listIconThemes(); @@ -353,6 +354,10 @@ void AppearanceManager::handleSettingDConfigChange(QString key) bSuccess = doSetMonospaceFont(value); } else if (key == GSKEYFONTSIZE) { type = TYPEFONTSIZE; + // 如果是紧凑模式,使用compact-font-size + if (m_property->dtkSizeMode == 1) { + break; + } double size = m_settingDconfig.value(key).toDouble(); if (size == m_property->fontSize) { break; @@ -389,6 +394,25 @@ void AppearanceManager::handleSettingDConfigChange(QString key) break; } utils::writeWallpaperConfig(wallpaper); + } else if (key == DDTKSIZEMODE) { + type = TYPEDTKSIZEMODE; + bool ok = false; + int mode = m_settingDconfig.value(key).toInt(&ok); + if (ok) { + doSetDTKSizeMode(mode); + double size = m_settingDconfig.value(mode == 1 ? DCOMPACTFONTSIZE : GSKEYFONTSIZE).toDouble(&ok); + if (ok) { + bSuccess = doSetFonts(size); + } + } + } else if (key == DCOMPACTFONTSIZE) { + type = TYPECOMPACTFONTSIZE; + bool ok = false; + double size = m_settingDconfig.value(key).toDouble(&ok); + if (ok && m_property->dtkSizeMode == 1) { + bSuccess = doSetFonts(size); + value = QString::number(size); + } } else { return; } @@ -490,7 +514,7 @@ void AppearanceManager::setFontSize(double value) } if (m_settingDconfig.isValid() && !qFuzzyCompare(value, m_property->fontSize)) { - m_settingDconfig.setValue(GSKEYFONTSIZE, value); + m_settingDconfig.setValue(m_property->dtkSizeMode == 1 ? DCOMPACTFONTSIZE : GSKEYFONTSIZE, value); m_property->fontSize = value; updateCustomTheme(TYPEFONTSIZE, QString::number(value)); } @@ -554,6 +578,14 @@ void AppearanceManager::setMonospaceFont(QString value) } } +void AppearanceManager::setDTKSizeMode(int value) +{ + if (value != m_property->dtkSizeMode && m_settingDconfig.isValid()) { + m_settingDconfig.setValue(DDTKSIZEMODE, value); + m_property->dtkSizeMode = value; + } +} + void AppearanceManager::setWindowRadius(int value) { if (value != m_property->windowRadius && m_xSetting) { @@ -1514,7 +1546,15 @@ void AppearanceManager::doSetByType(const QString &type, const QString &value) } else if (type == TYPEWALLPAPER) { doSetCurrentWorkspaceBackground(value); updateValut = true; + } else if (type == TYPEDTKSIZEMODE) { + bool ok = false; + int mode = value.toInt(&ok); + if (ok) { + QString fontSizeKey = GSKEYFONTSIZE; + doSetDTKSizeMode(mode); + } } + if (updateValut) { updateCustomTheme(type, value); } @@ -1734,6 +1774,10 @@ QString AppearanceManager::getWallpaperUri(const QString &index, const QString & return wallpaper; } +void AppearanceManager::initDtkSizeMode(){ + m_dbusProxy->SetInteger("DTK/SizeMode",m_property->dtkSizeMode); +} + void AppearanceManager::initGlobalTheme() { QVector> globalList = m_subthemes->listGlobalThemes(); @@ -1827,6 +1871,13 @@ QString AppearanceManager::doGetWorkspaceBackgroundForMonitor(const int &index, return getWallpaperUri(QString::number(index), strMonitorName); } +void AppearanceManager::doSetDTKSizeMode(int value) { + if (value != m_property->dtkSizeMode) { + setDTKSizeMode(value); + m_dbusProxy->SetInteger("DTK/SizeMode",value); + } +} + void AppearanceManager::autoChangeBg(QString monitorSpace, QDateTime date) { qDebug() << "autoChangeBg: " << monitorSpace << ", " << date; diff --git a/src/service/impl/appearancemanager.h b/src/service/impl/appearancemanager.h index f683d73..e609ac2 100644 --- a/src/service/impl/appearancemanager.h +++ b/src/service/impl/appearancemanager.h @@ -64,6 +64,7 @@ class AppearanceManager : public QObject void setQtActiveColor(const QString &value); bool setWallpaperSlideShow(const QString &value); bool setWallpaperURls(const QString &value); + void setDTKSizeMode(int value); bool doSetFonts(double size); bool doUpdateFonts(double size); bool doSetGlobalTheme(QString value); @@ -75,6 +76,7 @@ class AppearanceManager : public QObject bool doSetBackground(QString value); bool doSetGreeterBackground(QString value); QString doGetWallpaperSlideShow(QString monitorName); + void doSetDTKSizeMode(int value); double getScaleFactor(); ScaleFactors getScreenScaleFactors(); bool setScaleFactor(double scale); @@ -108,6 +110,7 @@ class AppearanceManager : public QObject inline QString getWallpaperSlideShow() {return m_property->wallpaperSlideShow; } inline QString getWallpaperURls() {return m_property->wallpaperURls;} inline int getWindowRadius() {return m_property->windowRadius; } + inline int getDTKSizeMode() {return m_property->dtkSizeMode; } inline QString getGreetBg() {return m_greeterBg; } inline QMap& getMonitor() {return m_monitorMap; } @@ -139,6 +142,7 @@ public Q_SLOTS: void initUserObj(); void initCurrentBgs(); void initWallpaperSlideshow(); + void initDtkSizeMode(); void iso6709Parsing(QString city, QString coordinates); void doUpdateWallpaperURIs(); void setPropertyWallpaperURIs(QMap monitorWallpaperUris); diff --git a/src/service/modules/common/commondefine.h b/src/service/modules/common/commondefine.h index 44b1725..4e00e45 100644 --- a/src/service/modules/common/commondefine.h +++ b/src/service/modules/common/commondefine.h @@ -37,6 +37,8 @@ const QString APPEARANCE_INTERFACE = "org.deepin.dde.Appearance1"; #define GSKEYDTKWINDOWRADIUS "dtkWindowRadius" #define GSKEYFONTNAME "gtkFontName" #define DCKEYALLWALLPAPER "All_Wallpaper_Uris" +#define DDTKSIZEMODE "Dtk_Size_Mode" +#define DCOMPACTFONTSIZE "Compact_Font_Size" #define GTK2CONFDELIM "=" #define GTK3GROUPSETTINGS "Settings" @@ -84,6 +86,8 @@ const QString APPEARANCE_INTERFACE = "org.deepin.dde.Appearance1"; #define TYPWINDOWRADIUS "windowradius" #define TYPEWALLPAPERSLIDESHOW "wallpaperflideshow" #define TYPEALLWALLPAPER "allwallpaperuris" +#define TYPEDTKSIZEMODE "dtksizemode" +#define TYPECOMPACTFONTSIZE "compactfontsize" #define MIMETYPEGLOBAL "application/x-global-theme" #define MIMETYPEGTK "application/x-gtk-theme" #define MIMETYPEICON "application/x-icon-theme"