forked from openkylin/qt5-ukui-platformtheme
Task185114, add kysdk-conf2 config to replace gsettings
This commit is contained in:
parent
ddf1d6763c
commit
d1a91aeff1
|
@ -14,6 +14,7 @@ Build-Depends: dbus-x11,
|
|||
libkf5iconthemes-dev,
|
||||
libkf5wayland-dev,
|
||||
libkf5windowsystem-dev,
|
||||
libkysdk-conf2-dev,
|
||||
libkysdk-waylandhelper-dev,
|
||||
libpeony-dev,
|
||||
libqt5svg5-dev,
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
etc/kylin-config/basic/org.ukui.style.yaml
|
||||
usr/lib/*/*.so.*
|
||||
usr/share/glib-2.0/schemas/org.ukui.style.gschema.xml
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
usr/lib/*/qt5/plugins/platformthemes/*.so
|
||||
qt5-ukui-filedialog/.qm/* /usr/share/qt5-ukui-platformtheme
|
||||
qt5-ukui-platformtheme/.qm/* /usr/share/qt5-ukui-platformtheme
|
||||
usr/lib/*/qt5/plugins/platformthemes/*.so
|
||||
|
|
|
@ -27,7 +27,7 @@ DEFINES += QT_MESSAGELOGCONTEXT
|
|||
include(libqt5-ukui-style.pri)
|
||||
|
||||
CONFIG += c++11 link_pkgconfig
|
||||
PKGCONFIG += gsettings-qt
|
||||
PKGCONFIG += gsettings-qt gio-2.0 kysdk-conf2
|
||||
|
||||
DISTFILES += \
|
||||
org.ukui.style.gschema.xml
|
||||
|
@ -40,6 +40,10 @@ unix {
|
|||
gschema.files += $$PWD/settings/org.ukui.style.gschema.xml
|
||||
INSTALLS += gschema
|
||||
|
||||
kconf2.path = /etc/kylin-config/basic/
|
||||
kconf2.files += $$PWD/settings/org.ukui.style.yaml
|
||||
INSTALLS += kconf2
|
||||
|
||||
pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig
|
||||
pkgconfig.files += development-files/qt5-ukui.pc
|
||||
INSTALLS += pkgconfig
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
style:
|
||||
4.1.0.0-0k12:
|
||||
4.3.1.2:
|
||||
keys:
|
||||
blur-exception-classes:
|
||||
_type: s
|
||||
default: []
|
||||
default: '[]'
|
||||
description: 'Example: [QWidget, QWidget1, QWidget2]'
|
||||
summary: a list of QWidget based classes do not blur.
|
||||
cursor-blink:
|
||||
_type: b
|
||||
default: true
|
||||
default: 'true'
|
||||
description: Globally enable or disable blinking text cursor.
|
||||
summary: Blink text cursor.
|
||||
cursor-blink-time:
|
||||
_type: i
|
||||
default: 1200
|
||||
default: '1200'
|
||||
description: The interval of text cursor blink.
|
||||
summary: Blink text cursor interval.
|
||||
custom-highlight-color:
|
||||
_type: s
|
||||
default: #3D6BE5
|
||||
default: '#3D6BE5'
|
||||
description: Set custom highlight color for UKUI desktop environment.Now is
|
||||
to compatible with third party application
|
||||
summary: Custom highlight color
|
||||
enabled-global-blur:
|
||||
_type: b
|
||||
default: true
|
||||
default: 'true'
|
||||
description: "Globally enable or disable the window blur effects for transparent\
|
||||
\ window.\n Setting it to \"false\" will disable the effects."
|
||||
summary: Enable Window Blur Effects.
|
||||
|
@ -35,12 +35,12 @@ style:
|
|||
summary: Icon Theme for Qt Applications.
|
||||
menu-transparency:
|
||||
_type: i
|
||||
default: 72
|
||||
default: '72'
|
||||
description: The default transparency of menu.
|
||||
summary: Menu's transparency.
|
||||
peony-side-bar-transparency:
|
||||
_type: i
|
||||
default: 72
|
||||
default: '72'
|
||||
description: The default transparency of the peony side bar.
|
||||
summary: Peony::SideBar's transparency.
|
||||
style-name:
|
||||
|
@ -56,7 +56,7 @@ style:
|
|||
summary: System Font for Qt Applications.
|
||||
system-font-size:
|
||||
_type: s
|
||||
default: 11
|
||||
default: '11'
|
||||
description: System Font Size for Qt Applications. Use point size.
|
||||
summary: System Font Size for Qt Applications.
|
||||
system-palette:
|
||||
|
@ -66,19 +66,19 @@ style:
|
|||
summary: System Palette
|
||||
theme-color:
|
||||
_type: s
|
||||
default: #3790FA
|
||||
default: '#3790FA'
|
||||
description: "Set theme color for UKUI desktop environment.include default,daybreakBlue,jamPurple,magenta,sunRed,sunsetOrange,dustGold,polarGreen,\n\
|
||||
\ and using rgba for example \"(125,125,125) or #3790FA"
|
||||
summary: theme color
|
||||
use-custom-highlight-color:
|
||||
_type: b
|
||||
default: false
|
||||
default: 'false'
|
||||
description: Globally enable or disable custom highlight color.Now is to compatible
|
||||
with third party application
|
||||
summary: Use custom highlight color.
|
||||
use-system-palette:
|
||||
_type: b
|
||||
default: false
|
||||
default: 'false'
|
||||
description: Globally enable or disable system palette provided by ukui platform.
|
||||
summary: Use system palette.
|
||||
widget-theme-name:
|
||||
|
@ -88,7 +88,7 @@ style:
|
|||
summary: Current widget theme name
|
||||
window-radius:
|
||||
_type: i
|
||||
default: 12
|
||||
default: '12'
|
||||
description: Set the rounded corner size of the window
|
||||
range: 0,12
|
||||
summary: Window Radius
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
HEADERS += $$PWD/libqt5-ukui-style_global.h \
|
||||
$$PWD/ukui-style-conf-settings.h \
|
||||
$$PWD/ukui-style-settings.h \
|
||||
$$PWD/black-list.h \
|
||||
$$PWD/application-style-settings.h
|
||||
|
||||
SOURCES += $$PWD/ukui-style-settings.cpp \
|
||||
$$PWD/application-style-settings.cpp
|
||||
$$PWD/application-style-settings.cpp \
|
||||
$$PWD/ukui-style-conf-settings.cpp
|
||||
|
||||
INCLUDEPATH += $$PWD/..
|
||||
INCLUDEPATH += $$PWD
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* Qt5-UKUI's Library
|
||||
*
|
||||
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: xibowen <xibowen@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ukui-style-conf-settings.h"
|
||||
#include "libkysettings.h"
|
||||
#include <glib.h>
|
||||
#include <QDebug>
|
||||
|
||||
//char to QString
|
||||
QString qtify_name(const char *name)
|
||||
{
|
||||
bool next_cap = false;
|
||||
QString result;
|
||||
|
||||
while (*name) {
|
||||
if (*name == '-') {
|
||||
next_cap = true;
|
||||
} else if (next_cap) {
|
||||
result.append(QChar(*name).toUpper().toLatin1());
|
||||
next_cap = false;
|
||||
} else {
|
||||
result.append(*name);
|
||||
}
|
||||
|
||||
name++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//QString to char
|
||||
char * unqtify_name(const QString &name)
|
||||
{
|
||||
const char *p;
|
||||
QByteArray bytes;
|
||||
GString *str;
|
||||
|
||||
bytes = name.toUtf8();
|
||||
str = g_string_new (NULL);
|
||||
|
||||
for (p = bytes.constData(); *p; p++) {
|
||||
const QChar c(*p);
|
||||
if (c.isUpper()) {
|
||||
g_string_append_c (str, '-');
|
||||
g_string_append_c (str, c.toLower().toLatin1());
|
||||
}
|
||||
else {
|
||||
g_string_append_c (str, *p);
|
||||
}
|
||||
}
|
||||
|
||||
return g_string_free(str, FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void settingChanged(KSettings *ukuistyle_settings, const char *key, void *user_data)
|
||||
{
|
||||
ukuiStyleConfSettings *self = (ukuiStyleConfSettings *)user_data;
|
||||
|
||||
QMetaObject::invokeMethod(self, "changed", Qt::QueuedConnection, Q_ARG(QString, qtify_name(key)));
|
||||
}
|
||||
|
||||
ukuiStyleConfSettings::ukuiStyleConfSettings(const QByteArray &schema_id)
|
||||
{
|
||||
if (!ukuistyle_settings)
|
||||
ukuistyle_settings = kdk_conf2_new(schema_id, NULL);
|
||||
|
||||
signal_handler_id = kdk_conf2_connect_signal(ukuistyle_settings, "changed",
|
||||
(KCallBack)settingChanged, this);
|
||||
}
|
||||
|
||||
ukuiStyleConfSettings::~ukuiStyleConfSettings()
|
||||
{
|
||||
if (ukuistyle_settings) {
|
||||
kdk_conf2_ksettings_destroy(ukuistyle_settings);
|
||||
ukuistyle_settings = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ukuiStyleConfSettings::types_to_qvariant(const char *key,const char* value) const
|
||||
{
|
||||
char *type = kdk_conf2_get_type(this->ukuistyle_settings, key);
|
||||
switch (*type) {
|
||||
case VARIANT_CLASS_BOOLEAN:
|
||||
return QVariant(value);
|
||||
|
||||
case VARIANT_CLASS_BYTE:
|
||||
return QVariant(QString(value));
|
||||
|
||||
case VARIANT_CLASS_INT16:
|
||||
return QVariant(QString(value).toShort());
|
||||
|
||||
case VARIANT_CLASS_UINT16:
|
||||
return QVariant(QString(value).toUShort());
|
||||
|
||||
case VARIANT_CLASS_INT32:
|
||||
return QVariant(QString(value).toInt());
|
||||
|
||||
case VARIANT_CLASS_UINT32:
|
||||
return QVariant(QString(value).toUInt());
|
||||
|
||||
case VARIANT_CLASS_INT64:
|
||||
return QVariant(QString(value).toLongLong());
|
||||
|
||||
case VARIANT_CLASS_UINT64:
|
||||
return QVariant(QString(value).toULongLong());
|
||||
|
||||
case VARIANT_CLASS_DOUBLE:
|
||||
return QVariant(QString(value).toDouble());
|
||||
|
||||
case VARIANT_CLASS_STRING:
|
||||
return QVariant(QString(value));
|
||||
|
||||
case VARIANT_CLASS_ARRAY:
|
||||
// if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY)) {
|
||||
// GVariantIter iter;
|
||||
// QStringList list;
|
||||
// const gchar *str;
|
||||
|
||||
// g_variant_iter_init (&iter, value);
|
||||
// while (g_variant_iter_next (&iter, "&s", &str))
|
||||
// list.append (str);
|
||||
|
||||
// return QVariant(list);
|
||||
// } else if (g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) {
|
||||
// return QVariant(QByteArray(g_variant_get_bytestring(value)));
|
||||
// } else if (g_variant_is_of_type(value, G_VARIANT_TYPE("a{ss}"))) {
|
||||
// GVariantIter iter;
|
||||
// QMap<QString, QVariant> map;
|
||||
// const gchar *key;
|
||||
// const gchar *val;
|
||||
|
||||
// g_variant_iter_init (&iter, value);
|
||||
// while (g_variant_iter_next (&iter, "{&s&s}", &key, &val))
|
||||
// map.insert(key, QVariant(val));
|
||||
|
||||
// return map;
|
||||
// }
|
||||
|
||||
// fall through
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ukuiStyleConfSettings::get(const QString &key) const
|
||||
{
|
||||
char *ckey = unqtify_name(key);
|
||||
char *value = kdk_conf2_get_value(ukuistyle_settings, ckey);
|
||||
|
||||
QVariant qvalue = types_to_qvariant(ckey, value);
|
||||
|
||||
g_free(value);
|
||||
g_free(ckey);
|
||||
return qvalue;
|
||||
}
|
||||
|
||||
void ukuiStyleConfSettings::set(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (!this->trySet(key, value))
|
||||
qWarning("unable to set key '%s' to value '%s'", key.toUtf8().constData(), value.toString().toUtf8().constData());
|
||||
}
|
||||
|
||||
bool ukuiStyleConfSettings::trySet(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (!ukuistyle_settings)
|
||||
return false;
|
||||
|
||||
char *ckey = unqtify_name(key);
|
||||
char *cvalue = unqtify_name(value.value<QString>());
|
||||
bool success = false;
|
||||
|
||||
success = kdk_conf2_set_value(ukuistyle_settings, ckey, cvalue);
|
||||
g_free(ckey);
|
||||
g_free(cvalue);
|
||||
return success;
|
||||
}
|
||||
|
||||
QStringList ukuiStyleConfSettings::keys() const
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
char **keys = kdk_conf2_list_keys(ukuistyle_settings);
|
||||
for (int i = 0; keys[i]; i++)
|
||||
list.append(qtify_name(keys[i]));
|
||||
|
||||
g_strfreev(keys);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void ukuiStyleConfSettings::reset(const QString &qkey)
|
||||
{
|
||||
if (!ukuistyle_settings)
|
||||
return;
|
||||
|
||||
char *key = unqtify_name(qkey);
|
||||
kdk_conf2_reset(ukuistyle_settings, key);
|
||||
g_free(key);
|
||||
}
|
||||
|
||||
bool ukuiStyleConfSettings::isSettingsAvailable(const QString &schema_id)
|
||||
{
|
||||
char *schema = unqtify_name(schema_id);
|
||||
bool result = false;
|
||||
if (kdk_conf2_new(schema, NULL)) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
g_free(schema);
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Qt5-UKUI's Library
|
||||
*
|
||||
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: xibowen <xibowen@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UKUISTYLECONFSETTINGS_H
|
||||
#define UKUISTYLECONFSETTINGS_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
typedef struct _KSettings KSettings;
|
||||
|
||||
class ukuiStyleConfSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum VariantClass {
|
||||
VARIANT_CLASS_BOOLEAN = 'b',
|
||||
VARIANT_CLASS_BYTE = 'y',
|
||||
VARIANT_CLASS_INT16 = 'n',
|
||||
VARIANT_CLASS_UINT16 = 'q',
|
||||
VARIANT_CLASS_INT32 = 'i',
|
||||
VARIANT_CLASS_UINT32 = 'u',
|
||||
VARIANT_CLASS_INT64 = 'x',
|
||||
VARIANT_CLASS_UINT64 = 't',
|
||||
VARIANT_CLASS_HANDLE = 'h',
|
||||
VARIANT_CLASS_DOUBLE = 'd',
|
||||
VARIANT_CLASS_STRING = 's',
|
||||
VARIANT_CLASS_OBJECT_PATH = 'o',
|
||||
VARIANT_CLASS_SIGNATURE = 'g',
|
||||
VARIANT_CLASS_VARIANT = 'v',
|
||||
VARIANT_CLASS_MAYBE = 'm',
|
||||
VARIANT_CLASS_ARRAY = 'a',
|
||||
VARIANT_CLASS_TUPLE = '(',
|
||||
VARIANT_CLASS_DICT_ENTRY = '{'
|
||||
};
|
||||
|
||||
|
||||
ukuiStyleConfSettings(const QByteArray &schema_id);
|
||||
|
||||
~ukuiStyleConfSettings();
|
||||
|
||||
QVariant types_to_qvariant(const char *key, const char *value) const;
|
||||
|
||||
static ukuiStyleConfSettings *globalInstance();
|
||||
|
||||
QVariant get(const QString &key) const;
|
||||
|
||||
void set(const QString &key, const QVariant &value);
|
||||
|
||||
bool trySet(const QString &key, const QVariant &value);
|
||||
|
||||
QStringList keys() const;
|
||||
|
||||
void reset(const QString &key);
|
||||
|
||||
static bool isSettingsAvailable(const QString &schema_id);
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed(const QString &key);
|
||||
|
||||
private:
|
||||
KSettings *ukuistyle_settings = NULL;
|
||||
long signal_handler_id;
|
||||
};
|
||||
|
||||
#endif // UKUISTYLECONFSETTINGS_H
|
|
@ -26,6 +26,9 @@
|
|||
#include "libqt5-ukui-style_global.h"
|
||||
#include <QGSettings>
|
||||
|
||||
//Fix me:after so
|
||||
//#include "ukui-style-conf-settings.h"
|
||||
|
||||
/*!
|
||||
* \brief The UKUIStyleSettings class
|
||||
* \details
|
||||
|
|
|
@ -15,7 +15,7 @@ TARGET = qt5-ukui-filedialog
|
|||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
CONFIG += c++11 link_pkgconfig lrelease
|
||||
PKGCONFIG += gsettings-qt peony kysdk-waylandhelper
|
||||
PKGCONFIG += gsettings-qt peony kysdk-waylandhelper kysdk-conf2
|
||||
LIBS += -lX11
|
||||
|
||||
include(../libqt5-ukui-style/libqt5-ukui-style.pri)
|
||||
|
|
|
@ -15,7 +15,7 @@ TARGET = qt5-ukui-platformtheme
|
|||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
CONFIG += c++11 link_pkgconfig lrelease
|
||||
PKGCONFIG += gsettings-qt Qt5XdgIconLoader kysdk-waylandhelper fontconfig freetype2 gio-2.0
|
||||
PKGCONFIG += gsettings-qt Qt5XdgIconLoader kysdk-waylandhelper fontconfig freetype2 gio-2.0 kysdk-conf2
|
||||
LIBS += -lX11 -lfontconfig -lfreetype
|
||||
|
||||
include(../libqt5-ukui-style/libqt5-ukui-style.pri)
|
||||
|
|
|
@ -23,7 +23,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG += gsettings-qt
|
||||
PKGCONFIG += gsettings-qt gio-2.0 kysdk-conf2
|
||||
|
||||
include(../../libqt5-ukui-style/libqt5-ukui-style.pri)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ QT += widgets widgets-private KWindowSystem gui gui-private x11extras dbus
|
|||
TARGET = qt5-style-ukui
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG += gsettings-qt
|
||||
PKGCONFIG += gsettings-qt gio-2.0 kysdk-conf2
|
||||
LIBS += -lxcb
|
||||
|
||||
include(../libqt5-ukui-style/libqt5-ukui-style.pri)
|
||||
|
|
Loading…
Reference in New Issue