Skip to content
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

feat: add interface for scrollbar policy #131

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbus/org.deepin.dde.Appearance1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<property access='read' type='s' name='StandardFont' />
<property access='readwrite' type='s' name='WallpaperSlideShow' />
<property access='readwrite' type='i' name='DTKSizeMode' />
<property access='readwrite' type='i' name='QtScrollBarPolicy' />
<property access='read' type='s' name='WallpaperURls' />

<signal name='Changed'>
Expand Down
10 changes: 10 additions & 0 deletions misc/dconfig/org.deepin.dde.appearance.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@
"description": "Compact font size.",
"permissions": "readwrite",
"visibility": "private"
},
"Qt_Scrollbar_Policy": {
"value": 0,
"serial": 0,
"flags": [],
"name": "Qt_Scrollbar_Policy",
"name[zh_CN]": "滚动条显示策略",
"description": "Scroll bar display strategy.",
"permissions": "readwrite",
"visibility": "private"
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/service/dbus/appearance1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ int Appearance1::dtkSizeMode() const
return appearance1Thread->dtkSizeMode();
}

int Appearance1::qtScrollBarPolicy() const
{
return appearance1Thread->qtScrollBarPolicy();
}

void Appearance1::setQtScrollBarPolicy(int value)
{
QMetaObject::invokeMethod(appearance1Thread.get(), "setQtScrollBarPolicy", Qt::QueuedConnection, Q_ARG(int, value));
}

void Appearance1::setWindowRadius(int value)
{
// message.setDelayedReply(true);
Expand Down
4 changes: 4 additions & 0 deletions src/service/dbus/appearance1.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class Appearance1 : public QObject, protected QDBusContext
int dtkSizeMode() const;
void setDTKSizeMode(int value);

Q_PROPERTY(int QtScrollBarPolicy READ qtScrollBarPolicy WRITE setQtScrollBarPolicy)
int qtScrollBarPolicy() const;
void setQtScrollBarPolicy(int value);

public Q_SLOTS: // METHODS
void Delete(const QString &ty, const QString &name);
QString GetCurrentWorkspaceBackground();
Expand Down
12 changes: 12 additions & 0 deletions src/service/dbus/appearance1thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Appearance1Thread::Appearance1Thread()
property->dtkSizeMode.init(settingDconfig.value(DDTKSIZEMODE).toInt());
// dtkSizeMode必须先于fontSize初始化,紧凑模式下,使用Compact_Font_Size配置
property->fontSize.init(settingDconfig.value(property->dtkSizeMode == 1 ? DCOMPACTFONTSIZE : GSKEYFONTSIZE).toDouble());
property->qtScrollBarPolicy.init(settingDconfig.value(DQTSCROLLBARPOLICY).toInt());
property->opacity.init(settingDconfig.value(GSKEYOPACITY).toDouble());
property->wallpaperSlideShow.init(settingDconfig.value(GSKEYWALLPAPERSLIDESHOW).toString());
property->wallpaperURls.init(settingDconfig.value(GSKEYWALLPAPERURIS).toString());
Expand Down Expand Up @@ -152,6 +153,17 @@ void Appearance1Thread::setDTKSizeMode(int value)
appearanceManager->doSetDTKSizeMode(value);
}

int Appearance1Thread::qtScrollBarPolicy() const
{
return property->qtScrollBarPolicy;
}

void Appearance1Thread::setQtScrollBarPolicy(int value)
{
QMutexLocker locker(&mutex);
appearanceManager->doSetQtScrollBarPolicy(value);
}

int Appearance1Thread::windowRadius() const
{
return property->windowRadius;
Expand Down
4 changes: 4 additions & 0 deletions src/service/dbus/appearance1thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class Appearance1Thread : public QObject
Q_PROPERTY(int DTKSizeMode READ dtkSizeMode WRITE setDTKSizeMode)
int dtkSizeMode() const;

Q_PROPERTY(int qtScrollBarPolicy READ qtScrollBarPolicy WRITE setQtScrollBarPolicy)
int qtScrollBarPolicy() const;

public Q_SLOTS:
// PROPERTIES
void setFontSize(double value);
Expand All @@ -71,6 +74,7 @@ public Q_SLOTS:
void setWallpaperSlideShow(const QString &value);
void setWindowRadius(int value);
void setDTKSizeMode(int value);
void setQtScrollBarPolicy(int value);
// METHODS
void Delete(const QString &ty, const QString &name, const QDBusMessage &message);
QString GetCurrentWorkspaceBackground(const QDBusMessage &message);
Expand Down
2 changes: 1 addition & 1 deletion src/service/dbus/appearancedbusproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AppearanceDBusProxy : public QObject
{
Q_OBJECT
public:
explicit AppearanceDBusProxy(QObject *parent = nullptr);
void setUserInterface(const QString &userPath);
explicit AppearanceDBusProxy(QObject *parent = nullptr);
// Notifications
public Q_SLOTS:
void Notify(const QString &in0, const QString &in2, const QString &summary, const QString &body, const QStringList &options, const QVariantMap &optionMap, int expireTimeout);
Expand Down
1 change: 1 addition & 0 deletions src/service/dbus/appearanceproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ AppearanceProperty::AppearanceProperty()
, wallpaperURls("WallpaperURls")
, windowRadius("WindowRadius")
, dtkSizeMode("DTKSizeMode")
, qtScrollBarPolicy("QtScrollBarPolicy")
{
fontSize.init(0.0);
opacity.init(0.0);
Expand Down
1 change: 1 addition & 0 deletions src/service/dbus/appearanceproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class AppearanceProperty
DBusProperty<QString> wallpaperURls;
DBusProperty<int> windowRadius;
DBusProperty<int> dtkSizeMode;
DBusProperty<int> qtScrollBarPolicy;
};

#endif // APPEARANCEPROPERTY_H
33 changes: 32 additions & 1 deletion src/service/impl/appearancemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,16 @@ void AppearanceManager::handleSettingDConfigChange(QString key)
bSuccess = doSetFonts(size);
value = QString::number(size);
}
} else {
} else if (key == DQTSCROLLBARPOLICY) {
type = TYPEQTSCROLLBARPOLICY;
bool ok = false;
int policy = m_settingDconfig.value(key).toInt(&ok);
if (ok) {
setQtScrollBarPolicy(policy);
value = QString::number(policy);
}
}
else {
return;
}
} while (false);
Expand Down Expand Up @@ -586,6 +595,14 @@ void AppearanceManager::setDTKSizeMode(int value)
}
}

void AppearanceManager::setQtScrollBarPolicy(int value)
{
if (value != m_property->qtScrollBarPolicy && m_settingDconfig.isValid()) {
m_settingDconfig.setValue(DQTSCROLLBARPOLICY, value);
m_property->qtScrollBarPolicy = value;
}
}

void AppearanceManager::setWindowRadius(int value)
{
if (value != m_property->windowRadius && m_xSetting) {
Expand Down Expand Up @@ -1553,6 +1570,12 @@ void AppearanceManager::doSetByType(const QString &type, const QString &value)
QString fontSizeKey = GSKEYFONTSIZE;
doSetDTKSizeMode(mode);
}
} else if (type == TYPEQTSCROLLBARPOLICY) {
bool ok = false;
int policy = value.toInt(&ok);
if (ok) {
doSetQtScrollBarPolicy(policy);
}
}

if (updateValut) {
Expand Down Expand Up @@ -1878,6 +1901,14 @@ void AppearanceManager::doSetDTKSizeMode(int value) {
}
}

void AppearanceManager::doSetQtScrollBarPolicy(int value)
{
if (value != m_property->qtScrollBarPolicy) {
setQtScrollBarPolicy(value);
m_dbusProxy->SetInteger("Qt/ScrollBarPolicy",value);
}
}

void AppearanceManager::autoChangeBg(QString monitorSpace, QDateTime date)
{
qDebug() << "autoChangeBg: " << monitorSpace << ", " << date;
Expand Down
2 changes: 2 additions & 0 deletions src/service/impl/appearancemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AppearanceManager : public QObject
bool setWallpaperSlideShow(const QString &value);
bool setWallpaperURls(const QString &value);
void setDTKSizeMode(int value);
void setQtScrollBarPolicy(int value);
bool doSetFonts(double size);
bool doUpdateFonts(double size);
bool doSetGlobalTheme(QString value);
Expand All @@ -77,6 +78,7 @@ class AppearanceManager : public QObject
bool doSetGreeterBackground(QString value);
QString doGetWallpaperSlideShow(QString monitorName);
void doSetDTKSizeMode(int value);
void doSetQtScrollBarPolicy(int value);
double getScaleFactor();
ScaleFactors getScreenScaleFactors();
bool setScaleFactor(double scale);
Expand Down
2 changes: 2 additions & 0 deletions src/service/modules/common/commondefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const QString APPEARANCE_INTERFACE = "org.deepin.dde.Appearance1";
#define DCKEYALLWALLPAPER "All_Wallpaper_Uris"
#define DDTKSIZEMODE "Dtk_Size_Mode"
#define DCOMPACTFONTSIZE "Compact_Font_Size"
#define DQTSCROLLBARPOLICY "Qt_Scrollbar_Policy"

#define GTK2CONFDELIM "="
#define GTK3GROUPSETTINGS "Settings"
Expand Down Expand Up @@ -88,6 +89,7 @@ const QString APPEARANCE_INTERFACE = "org.deepin.dde.Appearance1";
#define TYPEALLWALLPAPER "allwallpaperuris"
#define TYPEDTKSIZEMODE "dtksizemode"
#define TYPECOMPACTFONTSIZE "compactfontsize"
#define TYPEQTSCROLLBARPOLICY "qtscrollbarpolicy"
#define MIMETYPEGLOBAL "application/x-global-theme"
#define MIMETYPEGTK "application/x-gtk-theme"
#define MIMETYPEICON "application/x-icon-theme"
Expand Down
Loading