libkysdk-applications/0011-update-changelog.patch
2024-04-24 10:25:27 +08:00

8319 lines
272 KiB
Diff
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From: wangzhenyu <wangzhenyu@kylinos.cn>
Date: Tue, 14 Mar 2023 17:16:25 +0800
Subject: update changelog
---
development-files/kysdk-notification.pc | 5 +
kysdk-application.pro | 3 +-
kysdk-notification/kysdk-notification.pro | 30 +
kysdk-notification/src/knotifier.cpp | 172 +++++
kysdk-notification/src/knotifier.h | 98 +++
kysdk-notification/testNotifier/main.cpp | 11 +
kysdk-notification/testNotifier/testNotifier.pro | 31 +
kysdk-notification/testNotifier/widget.cpp | 70 ++
kysdk-notification/testNotifier/widget.h | 21 +
kysdk-qtwidgets/kysdk-qtwidgets.pro | 25 +-
kysdk-qtwidgets/src/kbackgroundgroup.cpp | 440 +++++++++++
kysdk-qtwidgets/src/kbackgroundgroup.h | 115 +++
kysdk-qtwidgets/src/kballontip.cpp | 8 +-
kysdk-qtwidgets/src/kborderbutton.cpp | 14 +-
kysdk-qtwidgets/src/kborderlessbutton.cpp | 1 +
kysdk-qtwidgets/src/kbreadcrumb.cpp | 4 +
kysdk-qtwidgets/src/kbubblewidget.cpp | 2 +-
kysdk-qtwidgets/src/kbuttonbox.cpp | 279 +++++++
kysdk-qtwidgets/src/kbuttonbox.h | 144 ++++
kysdk-qtwidgets/src/kcolorbutton.cpp | 198 +++++
kysdk-qtwidgets/src/kcolorbutton.h | 71 ++
kysdk-qtwidgets/src/kcolorcombobox.cpp | 300 ++++++++
kysdk-qtwidgets/src/kcolorcombobox.h | 91 +++
kysdk-qtwidgets/src/kdialog.cpp | 3 +-
kysdk-qtwidgets/src/kiconbar.cpp | 21 +-
kysdk-qtwidgets/src/kinputdialog.cpp | 131 +---
kysdk-qtwidgets/src/klineframe.cpp | 137 ++++
kysdk-qtwidgets/src/klineframe.h | 34 +
kysdk-qtwidgets/src/klistviewdelegate.cpp | 1 -
kysdk-qtwidgets/src/kmenubutton.cpp | 2 +-
kysdk-qtwidgets/src/kmessagebox.cpp | 802 +++++++++++++++++++++
kysdk-qtwidgets/src/kmessagebox.h | 276 +++++++
kysdk-qtwidgets/src/knavigationbar.cpp | 20 +-
kysdk-qtwidgets/src/kpasswordedit.cpp | 91 +--
kysdk-qtwidgets/src/kpasswordedit.h | 6 +
kysdk-qtwidgets/src/kpressbutton.cpp | 3 +
kysdk-qtwidgets/src/kprogressbar.cpp | 14 +
kysdk-qtwidgets/src/kprogressbar.h | 6 +
kysdk-qtwidgets/src/kpushbutton.cpp | 9 +-
kysdk-qtwidgets/src/ksearchlineedit.cpp | 17 +-
kysdk-qtwidgets/src/kslider.cpp | 35 +-
kysdk-qtwidgets/src/kslider.h | 2 +-
kysdk-qtwidgets/src/ktabbar.cpp | 30 +-
kysdk-qtwidgets/src/ktabbar.h | 2 +-
kysdk-qtwidgets/src/ktag.cpp | 2 +-
kysdk-qtwidgets/src/ktoolbutton.cpp | 3 +-
kysdk-qtwidgets/src/kwidget.cpp | 197 +++--
kysdk-qtwidgets/src/kwindowbuttonbar.cpp | 17 +-
kysdk-qtwidgets/src/kwindowbuttonbar.h | 11 +
kysdk-qtwidgets/src/parmscontroller.cpp | 12 +-
kysdk-qtwidgets/test/test.pro | 9 +-
kysdk-qtwidgets/test/testDialog/main.cpp | 10 +-
kysdk-qtwidgets/test/testDialog/testDialog.pro | 2 +-
kysdk-qtwidgets/test/testKBubbleWidget/main.cpp | 11 +
.../test/testKBubbleWidget/testKBubbleWidget.pro | 31 +
kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp | 65 ++
kysdk-qtwidgets/test/testKBubbleWidget/widget.h | 14 +
kysdk-qtwidgets/test/testKButtonBox/main.cpp | 11 +
.../test/testKButtonBox/testKButtonBox.pro | 31 +
kysdk-qtwidgets/test/testKButtonBox/widget.cpp | 87 +++
kysdk-qtwidgets/test/testKButtonBox/widget.h | 14 +
kysdk-qtwidgets/test/testKMessageBox/main.cpp | 29 +
.../test/testKMessageBox/testKMessageBox.pro | 31 +
kysdk-qtwidgets/test/testKMessageBox/widget.cpp | 53 ++
kysdk-qtwidgets/test/testKMessageBox/widget.h | 14 +
kysdk-qtwidgets/test/testKPushButton/main.cpp | 19 +
.../test/testKPushButton/testKPushButton.pro | 2 +-
.../test/testKTranslucentFloor/main.cpp | 19 +
.../testKTranslucentFloor.pro | 2 +-
kysdk-qtwidgets/test/testListView/main.cpp | 19 +
kysdk-qtwidgets/test/testListView/testListView.pro | 2 +-
kysdk-qtwidgets/test/testListWidget/main.cpp | 19 +
.../test/testListWidget/testListWidget.pro | 2 +-
kysdk-qtwidgets/test/testProgressCircle/main.cpp | 19 +
.../test/testProgressCircle/testProgressCircle.pro | 2 +-
kysdk-qtwidgets/test/testPushbutton/main.cpp | 19 +
.../test/testPushbutton/testPushbutton.pro | 2 +-
kysdk-qtwidgets/test/testSwitchButton/main.cpp | 19 +
.../test/testSwitchButton/testSwitchButton.pro | 2 +-
kysdk-qtwidgets/test/testTag/main.cpp | 19 +
kysdk-qtwidgets/test/testTag/testTag.pro | 2 +-
kysdk-qtwidgets/test/testTranslucent/main.cpp | 15 +
.../test/testTranslucent/testTranslucent.pro | 30 +
kysdk-qtwidgets/test/testTranslucent/widget.cpp | 117 +++
kysdk-qtwidgets/test/testTranslucent/widget.h | 17 +
kysdk-qtwidgets/test/testWidget/main.cpp | 9 +
kysdk-qtwidgets/test/testWidget/testWidget.pro | 2 +-
kysdk-qtwidgets/test/testbadge/main.cpp | 20 +-
kysdk-qtwidgets/test/testbadge/testbadge.pro | 2 +-
kysdk-qtwidgets/test/testballontip/main.cpp | 20 +-
.../test/testballontip/testballontip.pro | 2 +-
kysdk-qtwidgets/test/testbreadcrumb/main.cpp | 20 +-
.../test/testbreadcrumb/testbreadcrumb.pro | 2 +-
kysdk-qtwidgets/test/testcolorbutton/main.cpp | 11 +
.../test/testcolorbutton/testcolorbutton.pro | 31 +
kysdk-qtwidgets/test/testcolorbutton/widget.cpp | 106 +++
kysdk-qtwidgets/test/testcolorbutton/widget.h | 14 +
kysdk-qtwidgets/test/testinputdialog/main.cpp | 9 +
.../test/testinputdialog/testinputdialog.pro | 2 +-
kysdk-qtwidgets/test/testkbackground/main.cpp | 11 +
.../test/testkbackground/testkbackground.pro | 31 +
kysdk-qtwidgets/test/testkbackground/widget.cpp | 172 +++++
kysdk-qtwidgets/test/testkbackground/widget.h | 16 +
kysdk-qtwidgets/test/testkcolorcombobox/main.cpp | 11 +
.../test/testkcolorcombobox/testkcolorcombobox.pro | 31 +
kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp | 57 ++
kysdk-qtwidgets/test/testkcolorcombobox/widget.h | 14 +
kysdk-qtwidgets/test/testkpressbutton/main.cpp | 19 +
.../test/testkpressbutton/testkpressbutton.pro | 2 +-
kysdk-qtwidgets/test/testnavigationbar/main.cpp | 19 +
.../test/testnavigationbar/testnavigationbar.pro | 2 +-
kysdk-qtwidgets/test/testpasswordedit/main.cpp | 19 +
.../test/testpasswordedit/testpasswordedit.pro | 2 +-
kysdk-qtwidgets/test/testprogressbar/main.cpp | 17 +
.../test/testprogressbar/testprogressbar.pro | 2 +-
kysdk-qtwidgets/test/testprogressdialog/main.cpp | 19 +
.../test/testprogressdialog/testprogressdialog.pro | 2 +-
kysdk-qtwidgets/test/testsearchlinedit/main.cpp | 9 +
.../test/testsearchlinedit/testsearchlinedit.pro | 2 +-
kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp | 9 +
.../testsecuritylevelbar/testsecuritylevelbar.pro | 2 +-
kysdk-qtwidgets/test/testslider/main.cpp | 19 +
kysdk-qtwidgets/test/testslider/testslider.pro | 2 +-
kysdk-qtwidgets/test/testtabbar/main.cpp | 19 +
kysdk-qtwidgets/test/testtabbar/testtabbar.pro | 2 +-
kysdk-qtwidgets/test/testtoolbutton/main.cpp | 19 +
.../test/testtoolbutton/testtoolbutton.pro | 2 +-
kysdk-qtwidgets/translations/gui_bo_CN.qm | Bin 3135 -> 3129 bytes
kysdk-qtwidgets/translations/gui_bo_CN.ts | 54 +-
kysdk-qtwidgets/translations/gui_zh_CN.qm | Bin 2131 -> 2133 bytes
kysdk-qtwidgets/translations/gui_zh_CN.ts | 54 +-
.../ukuistylehelper/ukui-decoration-manager.cpp | 4 +-
.../src/ukuistylehelper/ukuistylehelper.cpp | 2 +-
kysdk-widgetutils/kysdk-widgetutils.pro | 5 +-
kysdk-widgetutils/src/kwidgetutils.cpp | 47 ++
kysdk-widgetutils/src/kwidgetutils.h | 11 +
.../test/testWidgetutils/testWidgetutils.pro | 7 +-
137 files changed, 5375 insertions(+), 366 deletions(-)
create mode 100644 development-files/kysdk-notification.pc
create mode 100644 kysdk-notification/kysdk-notification.pro
create mode 100644 kysdk-notification/src/knotifier.cpp
create mode 100644 kysdk-notification/src/knotifier.h
create mode 100644 kysdk-notification/testNotifier/main.cpp
create mode 100644 kysdk-notification/testNotifier/testNotifier.pro
create mode 100644 kysdk-notification/testNotifier/widget.cpp
create mode 100644 kysdk-notification/testNotifier/widget.h
create mode 100644 kysdk-qtwidgets/src/kbackgroundgroup.cpp
create mode 100644 kysdk-qtwidgets/src/kbackgroundgroup.h
create mode 100644 kysdk-qtwidgets/src/kbuttonbox.cpp
create mode 100644 kysdk-qtwidgets/src/kbuttonbox.h
create mode 100644 kysdk-qtwidgets/src/kcolorbutton.cpp
create mode 100644 kysdk-qtwidgets/src/kcolorbutton.h
create mode 100644 kysdk-qtwidgets/src/kcolorcombobox.cpp
create mode 100644 kysdk-qtwidgets/src/kcolorcombobox.h
create mode 100644 kysdk-qtwidgets/src/klineframe.cpp
create mode 100644 kysdk-qtwidgets/src/klineframe.h
create mode 100644 kysdk-qtwidgets/src/kmessagebox.cpp
create mode 100644 kysdk-qtwidgets/src/kmessagebox.h
create mode 100644 kysdk-qtwidgets/test/testKBubbleWidget/main.cpp
create mode 100644 kysdk-qtwidgets/test/testKBubbleWidget/testKBubbleWidget.pro
create mode 100644 kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testKBubbleWidget/widget.h
create mode 100644 kysdk-qtwidgets/test/testKButtonBox/main.cpp
create mode 100644 kysdk-qtwidgets/test/testKButtonBox/testKButtonBox.pro
create mode 100644 kysdk-qtwidgets/test/testKButtonBox/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testKButtonBox/widget.h
create mode 100644 kysdk-qtwidgets/test/testKMessageBox/main.cpp
create mode 100644 kysdk-qtwidgets/test/testKMessageBox/testKMessageBox.pro
create mode 100644 kysdk-qtwidgets/test/testKMessageBox/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testKMessageBox/widget.h
create mode 100644 kysdk-qtwidgets/test/testTranslucent/main.cpp
create mode 100644 kysdk-qtwidgets/test/testTranslucent/testTranslucent.pro
create mode 100644 kysdk-qtwidgets/test/testTranslucent/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testTranslucent/widget.h
create mode 100644 kysdk-qtwidgets/test/testcolorbutton/main.cpp
create mode 100644 kysdk-qtwidgets/test/testcolorbutton/testcolorbutton.pro
create mode 100644 kysdk-qtwidgets/test/testcolorbutton/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testcolorbutton/widget.h
create mode 100644 kysdk-qtwidgets/test/testkbackground/main.cpp
create mode 100644 kysdk-qtwidgets/test/testkbackground/testkbackground.pro
create mode 100644 kysdk-qtwidgets/test/testkbackground/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testkbackground/widget.h
create mode 100644 kysdk-qtwidgets/test/testkcolorcombobox/main.cpp
create mode 100644 kysdk-qtwidgets/test/testkcolorcombobox/testkcolorcombobox.pro
create mode 100644 kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp
create mode 100644 kysdk-qtwidgets/test/testkcolorcombobox/widget.h
diff --git a/development-files/kysdk-notification.pc b/development-files/kysdk-notification.pc
new file mode 100644
index 0000000..6933b54
--- /dev/null
+++ b/development-files/kysdk-notification.pc
@@ -0,0 +1,5 @@
+Name: libkysdk-notification
+Description: kysdk notification development library
+Version: 1.2.0
+Libs: -L/usr/lib/kysdk/applications/ -lkysdk-notification -Wl,-rpath=/usr/lib/kysdk/applications/
+Cflags: -I/usr/include/kysdk/applications/
\ No newline at end of file
diff --git a/kysdk-application.pro b/kysdk-application.pro
index 90eb59d..ef56bfc 100644
--- a/kysdk-application.pro
+++ b/kysdk-application.pro
@@ -8,7 +8,8 @@ SUBDIRS = \
kysdk-qtwidgets \
kysdk-kabase/kabase/ \
kysdk-alm \
- kysdk-ukenv
+ kysdk-ukenv \
+ kysdk-notification
pc.files = development-files/*.pc
pc.path = /usr/share/pkgconfig
diff --git a/kysdk-notification/kysdk-notification.pro b/kysdk-notification/kysdk-notification.pro
new file mode 100644
index 0000000..13fc769
--- /dev/null
+++ b/kysdk-notification/kysdk-notification.pro
@@ -0,0 +1,30 @@
+QT += widgets gui dbus
+
+TEMPLATE = lib
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ src/knotifier.cpp
+
+HEADERS += \
+ src/knotifier.h
+
+# Default rules for deployment.
+unix {
+ headers.files = $${HEADERS}
+ headers.path = /usr/include/kysdk/applications/
+ target.path = /usr/lib/kysdk/applications/
+}
+!isEmpty(target.path): INSTALLS += target headers
diff --git a/kysdk-notification/src/knotifier.cpp b/kysdk-notification/src/knotifier.cpp
new file mode 100644
index 0000000..667d324
--- /dev/null
+++ b/kysdk-notification/src/knotifier.cpp
@@ -0,0 +1,172 @@
+#include "knotifier.h"
+#include <QStringList>
+#include <QDBusConnection>
+#include <QDBusMessage>
+#include <QList>
+#include <QVariant>
+#include <QDebug>
+
+namespace kdk {
+
+#define SERVICE "org.freedesktop.Notifications"
+#define PATH "/org/freedesktop/Notifications"
+#define INTERFACE "org.freedesktop.Notifications"
+
+#define NOTIFY "Notify"
+#define CLOSE "CloseNotification"
+
+
+static QList<QVariant> dbusCall(QString serviceName, QString objectPath, QString interfaceName,
+ QString methodName, QList<QVariant> args = QList<QVariant>())
+{
+ QList<QVariant> ret;
+ ret.clear();
+
+ if (serviceName.isEmpty() || objectPath.isEmpty() || interfaceName.isEmpty() || methodName.isEmpty()) {
+ qDebug() << "knotifier : args error!";
+ return ret;
+ }
+
+ QDBusMessage message = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, methodName);
+ if (!args.isEmpty()) {
+ message.setArguments(args);
+ }
+
+ QDBusMessage reply = QDBusConnection::sessionBus().call(message);
+ if (reply.type() == QDBusMessage::ReplyMessage) {
+ ret = reply.arguments();
+ return ret;
+ } else {
+ qDebug() << "knotifier : dbus call method fail " << reply.errorMessage();
+ }
+
+ return ret;
+}
+
+class KNotifierPrivate: public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KNotifier)
+
+public:
+ KNotifierPrivate(KNotifier *parent = nullptr);
+
+public:
+ KNotifier *q_ptr;
+ uint m_replaceId;
+ uint m_id;
+ int m_showTime;
+ QString m_bodyText;
+ QString m_summary;
+ QString m_iconName;
+ QString m_appName;
+ QStringList m_actionList;
+
+};
+
+KNotifier::KNotifier(QObject *parent) :
+ QObject(parent),
+ d_ptr(new KNotifierPrivate(this))
+{
+ Q_D(KNotifier);
+}
+
+KNotifier::~KNotifier()
+{
+
+}
+
+void KNotifier::setDefaultAction(const QString &appName)
+{
+ Q_D(KNotifier);
+ d->m_actionList.insert(0,appName);
+ d->m_actionList.insert(1,"default");
+}
+
+uint KNotifier::notify()
+{
+ Q_D(KNotifier);
+
+ QMap<QString, QVariant> hints;
+ QList<QVariant> args;
+ args << d->m_appName
+ << d->m_replaceId
+ << d->m_iconName
+ << d->m_summary
+ << d->m_bodyText
+ << d->m_actionList
+ << hints
+ << d->m_showTime;
+ QList<QVariant> list = dbusCall(SERVICE,PATH,INTERFACE,NOTIFY,args);
+ d->m_id = list.at(0).toUInt();
+ return d->m_id;
+}
+
+void KNotifier::addAction(const QString &appName, const QString &text)
+{
+ Q_D(KNotifier);
+
+ d->m_actionList.append(appName);
+ d->m_actionList.append(text);
+}
+
+void KNotifier::setShowTime(int milliseconds)
+{
+ Q_D(KNotifier);
+
+ d->m_showTime = milliseconds;
+}
+
+void KNotifier::setAppName(const QString &appName)
+{
+ Q_D(KNotifier);
+
+ d->m_appName = appName;
+}
+
+void KNotifier::setBodyText(const QString &bodyText)
+{
+ Q_D(KNotifier);
+
+ d->m_bodyText = bodyText;
+}
+
+void KNotifier::setSummary(const QString &summary)
+{
+ Q_D(KNotifier);
+
+ d->m_summary = summary;
+}
+
+void KNotifier::setAppIcon(const QString &iconName)
+{
+ Q_D(KNotifier);
+
+ d->m_iconName = iconName;
+}
+
+void KNotifier::setReplaceId(const uint id)
+{
+ Q_D(KNotifier);
+ d->m_replaceId = id;
+}
+
+void KNotifier::closeNotification(uint id)
+{
+
+ QList<QVariant> args;
+ args << id;
+ dbusCall(SERVICE,PATH,INTERFACE,CLOSE,args);
+}
+
+KNotifierPrivate::KNotifierPrivate(KNotifier *parent)
+ :q_ptr(parent),
+ m_replaceId(0),
+ m_showTime(KNotifier::Default)
+{
+ setParent(parent);
+}
+
+}
+#include "knotifier.moc"
+#include "moc_knotifier.cpp"
diff --git a/kysdk-notification/src/knotifier.h b/kysdk-notification/src/knotifier.h
new file mode 100644
index 0000000..8333b72
--- /dev/null
+++ b/kysdk-notification/src/knotifier.h
@@ -0,0 +1,98 @@
+#ifndef NOTIFIER_H
+#define NOTIFIER_H
+
+#include <QObject>
+
+namespace kdk {
+
+class KNotifierPrivate;
+
+/**
+ * @brief 消息通知类调用notify()发消息后会在屏幕右上角以弹窗形式展示消息内容和支持的操作
+ * 支持设置应用名称应用图标消息标题消息主体内容显示时长添加action等
+ */
+
+class KNotifier : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ enum ShowTime
+ {
+ Default = -1, //系统默认显示消息时长
+ AllTheTime = 0 //消息常驻
+ };
+ explicit KNotifier(QObject *parent = nullptr);
+ ~KNotifier();
+
+ /**
+ * @brief 发送消息通知请求
+ * @return 返回消息通知id
+ */
+ uint notify();
+
+ /**
+ * @brief 设置默认跳转应用,点击消息弹窗时进行跳转
+ * @param 应用名称
+ */
+ void setDefaultAction(const QString& appName);
+
+ /**
+ * @brief 在消息弹窗中添加跳转按钮,最多可以添加三个
+ * @param 按钮显示文本
+ * @param 跳转应用名称
+ */
+ void addAction(const QString& appName, const QString& text);
+
+ /**
+ * @brief 设置消息弹窗的显示时长Default为系统默认时长AllTheTime为常驻消息
+ * @param 毫秒数
+ */
+ void setShowTime(int milliseconds);
+
+ /**
+ * @brief 设置消息弹窗应用名称
+ * @param 应用名称
+ */
+ void setAppName(const QString& appName);
+
+ /**
+ * @brief 设置消息弹窗主内容
+ * @param 主内容
+ */
+ void setBodyText(const QString& bodyText);
+
+ /**
+ * @brief 设置消息弹窗标题
+ * @param 标题
+ */
+ void setSummary(const QString& summary);
+
+ /**
+ * @brief 设置消息弹窗应用图标,仅支持系统图标
+ * @param 图标名称
+ */
+ void setAppIcon(const QString& iconName);
+
+ /**
+ * @brief 设置替换消息弹窗的id替换通知即更新通知内容在通知还未消失时更新通知弹窗的主题、正文、跳转动作和按钮。
+ * @param id
+ */
+ void setReplaceId(const uint id);
+
+ /**
+ * @brief 主动关闭消息弹窗
+ * @param id
+ */
+ static void closeNotification(uint id);
+
+private:
+ Q_DECLARE_PRIVATE(KNotifier)
+ KNotifierPrivate* const d_ptr;
+
+};
+
+}
+
+#endif // NOTIFIER_H
diff --git a/kysdk-notification/testNotifier/main.cpp b/kysdk-notification/testNotifier/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-notification/testNotifier/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-notification/testNotifier/testNotifier.pro b/kysdk-notification/testNotifier/testNotifier.pro
new file mode 100644
index 0000000..5b8d7b0
--- /dev/null
+++ b/kysdk-notification/testNotifier/testNotifier.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-notification
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-notification/testNotifier/widget.cpp b/kysdk-notification/testNotifier/widget.cpp
new file mode 100644
index 0000000..2752656
--- /dev/null
+++ b/kysdk-notification/testNotifier/widget.cpp
@@ -0,0 +1,70 @@
+#include "widget.h"
+#include <QHBoxLayout>
+
+#include <QDebug>
+
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QHBoxLayout *hLayout = new QHBoxLayout(this);
+
+ QPushButton *btn1 = new QPushButton("常规通知",this);
+ QPushButton *btn2 = new QPushButton("通知内容替换",this);
+ QPushButton *btn3 = new QPushButton("常驻通知",this);
+ QPushButton *btn4 = new QPushButton("关闭通知",this);
+
+ hLayout->addWidget(btn1);
+ hLayout->addWidget(btn2);
+ hLayout->addWidget(btn3);
+ hLayout->addWidget(btn4);
+
+ connect(btn1,&QPushButton::clicked,this,[=](){
+ KNotifier notifier;
+ notifier.setAppName("ukui-control-center");
+ notifier.setAppIcon("ukui-control-center");
+ notifier.setBodyText("bodyText");
+ notifier.setSummary("summary");
+ notifier.setDefaultAction("ukui-control-center");
+ notifier.addAction("kylin-music","music");
+ m_id = notifier.notify();
+ qDebug() << "notifacation id:"<<m_id;
+ });
+
+ connect(btn2,&QPushButton::clicked,this,[=](){
+ KNotifier notifier;
+ notifier.setAppName("ukui-control-center");
+ notifier.setAppIcon("ukui-control-center");
+ notifier.setBodyText("replaced bodyText");
+ notifier.setSummary("summary");
+
+ notifier.addAction("kylin-music","music");
+ notifier.setDefaultAction("ukui-control-center");
+ notifier.setReplaceId(1);
+ m_id = notifier.notify();
+ qDebug() << "notifacation id:"<<m_id;
+ });
+
+ connect(btn3,&QPushButton::clicked,this,[=](){
+ KNotifier notifier;
+ notifier.setAppName("ukui-control-center");
+ notifier.setAppIcon("ukui-control-center");
+ notifier.setBodyText("bodyText");
+ notifier.setSummary("summary");
+ notifier.setDefaultAction("ukui-control-center");
+ notifier.addAction("kylin-music","music");
+ notifier.setShowTime(KNotifier::AllTheTime);
+ m_id = notifier.notify();
+ qDebug() << "notifacation id:"<<m_id;
+ });
+
+
+ connect(btn4,&QPushButton::clicked,this,[=](){
+ KNotifier::closeNotification(m_id);
+ });
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-notification/testNotifier/widget.h b/kysdk-notification/testNotifier/widget.h
new file mode 100644
index 0000000..18eba8f
--- /dev/null
+++ b/kysdk-notification/testNotifier/widget.h
@@ -0,0 +1,21 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <knotifier.h>
+
+using namespace kdk;
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+
+private:
+ int m_id;
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/kysdk-qtwidgets.pro b/kysdk-qtwidgets/kysdk-qtwidgets.pro
index 7989998..658b4c7 100644
--- a/kysdk-qtwidgets/kysdk-qtwidgets.pro
+++ b/kysdk-qtwidgets/kysdk-qtwidgets.pro
@@ -1,4 +1,4 @@
-QT += widgets core sql x11extras KWindowSystem dbus
+QT += widgets core sql x11extras KWindowSystem dbus widgets-private
TEMPLATE = lib
DEFINES += GUI_LIBRARY
@@ -30,11 +30,10 @@ LIBS += -L../kysdk-waylandhelper -lkysdk-waylandhelper -Wl,-rpath=/usr/lib/kysdk
TRANSLATIONS += ./translations/gui_zh_CN.ts \
./translations/gui_bo_CN.ts
-SUBDIRS += build
-
SOURCES += \
- src/parmscontroller.cpp \
+ src/parmscontroller.cpp\
src/kbreadcrumb.cpp \
+ src/kcolorcombobox.cpp \
src/kpasswordedit.cpp \
src/kpixmapcontainer.cpp \
src/kprogressbar.cpp \
@@ -71,12 +70,17 @@ SOURCES += \
src/kpressbutton.cpp\
src/kpushbutton.cpp\
src/ktranslucentfloor.cpp\
- src/kbubblewidget.cpp
-
+ src/kbubblewidget.cpp\
+ src/kbuttonbox.cpp\
+ src/kbackgroundgroup.cpp\
+ src/klineframe.cpp\
+ src/kcolorbutton.cpp\
+ src/kmessagebox.cpp
HEADERS += \
- src/parmscontroller.h \
+ src/parmscontroller.h\
src/kbreadcrumb.h \
+ src/kcolorcombobox.h \
src/kpasswordedit.h \
src/kpixmapcontainer.h \
src/kprogressbar.h \
@@ -114,7 +118,12 @@ HEADERS += \
src/kpressbutton.h\
src/kpushbutton.h\
src/ktranslucentfloor.h\
- src/kbubblewidget.h
+ src/kbubblewidget.h\
+ src/kbuttonbox.h\
+ src/kbackgroundgroup.h\
+ src/klineframe.h\
+ src/kcolorbutton.h\
+ src/kmessagebox.h
diff --git a/kysdk-qtwidgets/src/kbackgroundgroup.cpp b/kysdk-qtwidgets/src/kbackgroundgroup.cpp
new file mode 100644
index 0000000..5ad48e6
--- /dev/null
+++ b/kysdk-qtwidgets/src/kbackgroundgroup.cpp
@@ -0,0 +1,440 @@
+#include "kbackgroundgroup.h"
+#include "themeController.h"
+#include <QVBoxLayout>
+#include "klineframe.h"
+#include <QPainter>
+#include <QPainterPath>
+#include <QEvent>
+
+namespace kdk {
+
+class KBackgroundGroupPrivate : public QObject ,public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KBackgroundGroup)
+public:
+ enum WidgetPosition
+ {
+ Beginning,
+ Middle,
+ End
+ };
+ KBackgroundGroupPrivate(KBackgroundGroup* parent);
+ void updateLayout();
+private:
+ KBackgroundGroup* q_ptr;
+ QVBoxLayout* m_pmainWidgetLayout;
+ QList<QWidget*> m_pwidgetList;
+ QList<QWidget*> m_pwidgetStateList;
+ QPalette::ColorRole m_brushColorRole;
+ QColor m_backgroundColor;
+ WidgetPosition m_widgetPosition;
+ QRect m_rect;
+ int m_rectLocal;
+ int m_radius;
+};
+
+KBackgroundGroup::KBackgroundGroup(QWidget *parent)
+ :QFrame(parent)
+ ,d_ptr(new KBackgroundGroupPrivate(this))
+{
+ setFrameShape(QFrame::Box);
+ setFrameShadow(QFrame::Plain);
+ setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
+}
+
+void KBackgroundGroup::addWidget(QWidget *widget)
+{
+ Q_D(KBackgroundGroup);
+ if(widget->maximumHeight() != widget->minimumHeight())
+ widget->setFixedHeight(60);
+ if(!d->m_pwidgetList.contains(widget))
+ d->m_pwidgetList.append(widget);
+ else
+ return;
+ d->updateLayout();
+}
+
+void KBackgroundGroup::addWidgetList(QList<QWidget *> list)
+{
+ Q_D(KBackgroundGroup);
+ for (int i = 0; i < list.count();i++)
+ {
+ auto widget = list.at(i);
+ if(widget->maximumHeight() != widget->minimumHeight())
+ widget->setFixedHeight(60);
+ if(!d->m_pwidgetList.contains(list.at(i)))
+ d->m_pwidgetList.append(list.at(i));
+ else
+ continue ;
+ }
+ d->updateLayout();
+}
+
+void KBackgroundGroup::removeWidgetAt(int i)
+{
+ Q_D(KBackgroundGroup);
+ if(d->m_pwidgetList.contains(d->m_pwidgetList.at(i)))
+ d->m_pwidgetList.removeAt(i);
+ else
+ return;
+ d->updateLayout();
+}
+
+void KBackgroundGroup::removeWidget(QWidget *widget)
+{
+ Q_D(KBackgroundGroup);
+ if(d->m_pwidgetList.contains(widget))
+ d->m_pwidgetList.removeOne(widget);
+ else
+ return ;
+ d->updateLayout();
+}
+
+void KBackgroundGroup::removeWidgetList(QList<QWidget *> list)
+{
+ Q_D(KBackgroundGroup);
+ for (int i = 0; i < list.count();i++)
+ {
+ if(d->m_pwidgetList.contains(list.at(i)))
+ d->m_pwidgetList.removeOne(list.at(i));
+ else
+ continue ;
+ }
+ d->updateLayout();
+}
+
+void KBackgroundGroup::insertWidgetAt(int index, QWidget *widget)
+{
+ Q_D(KBackgroundGroup);
+ if(widget->maximumHeight() != widget->minimumHeight())
+ widget->setFixedHeight(60);
+ if(!d->m_pwidgetList.contains(widget))
+ d->m_pwidgetList.insert(index,widget);
+ else
+ return ;
+ d->updateLayout();
+}
+
+void KBackgroundGroup::insertWidgetList(int index, QList<QWidget *> list)
+{
+ Q_D(KBackgroundGroup);
+ for (int i = 0; i < list.count();i++)
+ {
+ auto widget = list.at(i);
+ if(widget->maximumHeight() != widget->minimumHeight())
+ widget->setFixedHeight(60);
+ if(!d->m_pwidgetList.contains(list.at(i)))
+ d->m_pwidgetList.insert(index++,list.at(i));
+ else
+ continue ;
+ }
+ d->updateLayout();
+}
+
+void KBackgroundGroup::setBorderRadius(int radius)
+{
+ Q_D(KBackgroundGroup);
+ d->m_radius = radius;
+}
+
+int KBackgroundGroup::borderRadius()
+{
+ Q_D(KBackgroundGroup);
+ return d->m_radius;
+}
+
+void KBackgroundGroup::setBackgroundRole(QPalette::ColorRole role)
+{
+ Q_D(KBackgroundGroup);
+ d->m_brushColorRole = role;
+}
+
+QPalette::ColorRole KBackgroundGroup::backgroundRole() const
+{
+ Q_D(const KBackgroundGroup);
+ return d->m_brushColorRole ;
+}
+
+void KBackgroundGroup::setStateEnable(QWidget *widget, bool flag)
+{
+ Q_D(KBackgroundGroup);
+ if(!d->m_pwidgetStateList.contains(widget) && flag)
+ {
+ d->m_pwidgetStateList.append(widget);
+ widget->installEventFilter(this);
+ widget->setAttribute(Qt::WA_TranslucentBackground);
+ }
+}
+
+QList<QWidget *> KBackgroundGroup::widgetList()
+{
+ Q_D(KBackgroundGroup);
+ return d->m_pwidgetList;
+}
+
+void KBackgroundGroup::paintEvent(QPaintEvent *event)
+{
+ Q_D(KBackgroundGroup);
+ //绘制backgroundgroup
+ QRect rect =this->rect();
+
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::transparent);
+ painter.setBrush(palette().color(d->m_brushColorRole));
+
+ QPainterPath path;
+ path.moveTo(rect.topLeft() + QPointF(d->m_radius , 0));
+ path.quadTo(rect.topLeft() , rect.topLeft() + QPointF(0,d->m_radius));
+ path.lineTo(rect.bottomLeft() - QPointF(0, d->m_radius));
+ path.quadTo(rect.bottomLeft() , rect.bottomLeft() + QPointF(d->m_radius,0));
+ path.lineTo(rect.bottomRight() - QPointF(d->m_radius,0));
+ path.quadTo(rect.bottomRight() , rect.bottomRight() - QPointF(0,d->m_radius));
+ path.lineTo(rect.topRight() + QPointF(0,d->m_radius));
+ path.quadTo(rect.topRight() , rect.topRight() - QPointF(d->m_radius,0));
+ path.lineTo(rect.topLeft() + QPointF(d->m_radius , 0));
+ painter.drawPath(path);
+
+ //三态事件响应颜色
+ painter.save();
+ painter.setBrush(d->m_backgroundColor);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::transparent);
+
+ //确定三态区域
+ int index,offset=0;
+ for(index =0;index<d->m_pwidgetList.count()-1;index++)
+ {
+ auto widget = d->m_pwidgetList.at(index);
+ if( widget == d->m_pwidgetStateList.at(d->m_rectLocal))
+ break;
+ else
+ offset = offset + d->m_pwidgetList.at(index)->height();
+ }
+
+ d->m_rect = d->m_rect.translated(0,offset+index);
+ d->m_rect = d->m_rect.adjusted(0,0,2,2);
+
+ //三态区域颜色调整
+ QPainterPath path1;
+ if(d->m_pwidgetList.count() == 1 && d->m_pwidgetStateList.count() == 1)
+ {
+ painter.drawRoundedRect(d->m_rect,d->m_radius,d->m_radius);
+ }
+ else if(d->m_pwidgetList.count() > 1)
+ {
+ switch (d->m_widgetPosition)
+ {
+ case KBackgroundGroupPrivate::Beginning:
+ path1.moveTo(d->m_rect.topLeft() + QPointF(0,d->m_radius));
+ path1.lineTo(d->m_rect.bottomLeft());
+ path1.lineTo(d->m_rect.bottomRight());
+ path1.lineTo(d->m_rect.topRight() + QPointF(0,d->m_radius));
+ path1.quadTo(d->m_rect.topRight() , d->m_rect.topRight() - QPointF(d->m_radius,0));
+ path1.lineTo(d->m_rect.topLeft() + QPointF(d->m_radius,0));
+ path1.quadTo(d->m_rect.topLeft() , d->m_rect.topLeft() + QPointF(0,d->m_radius));
+ painter.drawPath(path1);
+ break;
+ case KBackgroundGroupPrivate::Middle:
+ painter.drawRoundedRect(d->m_rect,0,0);
+ break;
+ case KBackgroundGroupPrivate::End:
+ path1.moveTo(d->m_rect.topLeft());
+ path1.lineTo(d->m_rect.bottomLeft() - QPointF(0,d->m_radius));
+ path1.quadTo(d->m_rect.bottomLeft() , d->m_rect.bottomLeft() + QPointF(d->m_radius,0));
+ path1.lineTo(d->m_rect.bottomRight() - QPointF(d->m_radius,0));
+ path1.quadTo(d->m_rect.bottomRight() , d->m_rect.bottomRight() - QPointF(0,d->m_radius));
+ path1.lineTo(d->m_rect.topRight());
+ path1.lineTo(d->m_rect.topLeft());
+ painter.drawPath(path1);
+ break;
+ default:
+ break;
+ }
+ }
+ painter.restore();
+}
+
+bool KBackgroundGroup::eventFilter(QObject *watched, QEvent *event)
+{
+ Q_D(KBackgroundGroup);
+ auto widget = static_cast<QWidget*>(watched);
+
+ if(d->m_pwidgetStateList.contains(widget))
+ {
+ //事件过滤器判断事件设置颜色
+ QColor color;
+ switch (event->type())
+ {
+ case QEvent::HoverEnter:
+ d->m_rect = widget->rect();
+ //设置三态区域背景色
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ color = palette().button().color();//QColor("#E6E6E6");
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::black,0.05);
+ }
+ else
+ {
+ color =palette().base().color();// QColor("#373737");
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::white,0.2);
+ }
+ //获取三态区域位置
+ if(d->m_pwidgetList.at(0) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::Beginning;
+ else if(d->m_pwidgetList.at(d->m_pwidgetList.count()-1) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::End;
+ else
+ d->m_widgetPosition = KBackgroundGroupPrivate::Middle;
+ d->m_rectLocal =d->m_pwidgetStateList.indexOf(widget);
+ update();
+ break;
+ case QEvent::Enter:
+ d->m_rect = widget->rect();
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ color = palette().button().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::black,0.05);
+ }
+ else
+ {
+ color = palette().base().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::white,0.2);
+ }
+ if(d->m_pwidgetList.at(0) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::Beginning;
+ else if(d->m_pwidgetList.at(d->m_pwidgetList.count()-1) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::End;
+ else
+ d->m_widgetPosition = KBackgroundGroupPrivate::Middle;
+ d->m_rectLocal =d->m_pwidgetStateList.indexOf(widget);
+ update();
+ break;
+ case QEvent::MouseButtonPress:
+ d->m_rect = widget->rect();
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ color = palette().button().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::black,0.2);
+ }
+ else
+ {
+ color = palette().base().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::white,0.05);
+ }
+ if(d->m_pwidgetList.at(0) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::Beginning;
+ else if(d->m_pwidgetList.at(d->m_pwidgetList.count()-1) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::End;
+ else
+ d->m_widgetPosition = KBackgroundGroupPrivate::Middle;
+ d->m_rectLocal =d->m_pwidgetStateList.indexOf(widget);
+ update();
+ break;
+ case QEvent::MouseButtonRelease:
+ {
+ d->m_rect = widget->rect();
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ color = palette().button().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::black,0.05);
+ }
+ else
+ {
+ color = palette().base().color();
+ d->m_backgroundColor = ThemeController::mixColor(color,Qt::white,0.2);
+ }
+ if(d->m_pwidgetList.at(0) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::Beginning;
+ else if(d->m_pwidgetList.at(d->m_pwidgetList.count()-1) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::End;
+ else
+ d->m_widgetPosition = KBackgroundGroupPrivate::Middle;
+ Q_EMIT clicked(widget);
+ d->m_rectLocal =d->m_pwidgetStateList.indexOf(widget);
+ update();
+ break;
+ }
+ case QEvent::Leave:
+ d->m_rect = widget->rect();
+ d->m_backgroundColor = palette().color(QPalette::Base);
+ if(d->m_pwidgetList.at(0) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::Beginning;
+ else if(d->m_pwidgetList.at(d->m_pwidgetList.count()-1) == widget)
+ d->m_widgetPosition = KBackgroundGroupPrivate::End;
+ else
+ d->m_widgetPosition = KBackgroundGroupPrivate::Middle;
+ d->m_rectLocal =d->m_pwidgetStateList.indexOf(widget);
+ update();
+ break;
+ default:
+ break;
+ }
+ }
+ return QObject::eventFilter(watched,event);
+}
+
+KBackgroundGroupPrivate::KBackgroundGroupPrivate(KBackgroundGroup *parent)
+ :q_ptr(parent)
+ ,m_widgetPosition(KBackgroundGroupPrivate::Beginning),m_rectLocal(0)
+ ,m_radius(12),m_backgroundColor(parent->palette().color(QPalette::Base))
+ ,m_brushColorRole(QPalette::Base)
+{
+ Q_Q(KBackgroundGroup);
+ m_pmainWidgetLayout = new QVBoxLayout(q);
+ m_pmainWidgetLayout->setContentsMargins(0,0,0,0);
+ m_pmainWidgetLayout->setSpacing(0);
+ m_pmainWidgetLayout->setMargin(0);
+
+// q->setFocus(Qt::MouseFocusReason);
+ connect(m_gsetting,&QGSettings::changed,this,[=](){
+ initThemeStyle();
+ });
+}
+
+void KBackgroundGroupPrivate::updateLayout()
+{
+ Q_Q(KBackgroundGroup);
+ //清空
+ QLayoutItem *child;
+ while ((child = m_pmainWidgetLayout->takeAt(0)) != 0)
+ {
+ //删除Stretch(弹簧)等布局
+ if (child->spacerItem())
+ {
+ m_pmainWidgetLayout->removeItem(child);
+ continue;
+ }
+ //删除布局
+ m_pmainWidgetLayout->removeWidget(child->widget());
+ child->widget()->setParent(nullptr);
+ delete child;
+ child =nullptr;
+ }
+
+ //添加布局
+ if(m_pwidgetList.count() < 1)
+ return;
+ else if(m_pwidgetList.count() == 1)
+ {
+ m_pmainWidgetLayout->addWidget(m_pwidgetList.at(0));
+ }
+ else
+ {
+ for (int i = 0; i < m_pwidgetList.count(); ++i)
+ {
+ m_pmainWidgetLayout->addWidget(m_pwidgetList.at(i));
+ if(i != m_pwidgetList.count()-1)
+ {
+ KHLineFrame* frame = new KHLineFrame();
+ m_pmainWidgetLayout->addWidget(frame);
+ }
+ }
+ }
+}
+
+}
+
+#include "kbackgroundgroup.moc"
+#include "moc_kbackgroundgroup.cpp"
diff --git a/kysdk-qtwidgets/src/kbackgroundgroup.h b/kysdk-qtwidgets/src/kbackgroundgroup.h
new file mode 100644
index 0000000..f061078
--- /dev/null
+++ b/kysdk-qtwidgets/src/kbackgroundgroup.h
@@ -0,0 +1,115 @@
+#ifndef KBACKGROUNDGROUP_H
+#define KBACKGROUNDGROUP_H
+
+#include "gui_g.h"
+#include <QFrame>
+#include <QWidget>
+namespace kdk {
+
+class KBackgroundGroupPrivate;
+
+class GUI_EXPORT KBackgroundGroup : public QFrame
+{
+ Q_OBJECT
+
+public:
+ KBackgroundGroup(QWidget* parent = nullptr);
+
+ /**
+ * @brief 添加一个widget控件
+ * @param widget
+ */
+ void addWidget(QWidget* widget);
+
+ /**
+ * @brief 添加一个widget list
+ * @param list
+ */
+ void addWidgetList(QList<QWidget*> list);
+
+ /**
+ * @brief 删除一个制定index的widget
+ * @param i
+ */
+ void removeWidgetAt(int i);
+
+ /**
+ * @brief 删除一个widget
+ * @param widget
+ */
+ void removeWidget(QWidget* widget);
+
+ /**
+ * @brief 删除一个widget list
+ * @param list
+ */
+ void removeWidgetList(QList<QWidget*> list);
+
+ /**
+ * @brief 指定位置插入一个widget
+ * @param index
+ * @param widget
+ */
+ void insertWidgetAt(int index, QWidget *widget);
+
+ /**
+ * @brief 指定位置插入一个widget list
+ * @param index
+ * @param list
+ */
+ void insertWidgetList(int index, QList<QWidget*> list);
+
+ /**
+ * @brief 设置KBackgroundGroup的圆角
+ * @param radius
+ */
+ void setBorderRadius(int radius);
+
+ /**
+ * @brief 返回KBackgroundGroup的圆角
+ * @return
+ */
+ int borderRadius();
+
+ /**
+ * @brief 设置背景颜色
+ * @param role
+ */
+ void setBackgroundRole(QPalette::ColorRole role);
+
+ /**
+ * @brief 返回背景颜色
+ * @return
+ */
+ QPalette::ColorRole backgroundRole() const;
+
+ /**
+ * @brief 设置窗体是否可以相应三态
+ * @param flag
+ * @param widget
+ */
+ void setStateEnable(QWidget* widget,bool flag);
+
+ /**
+ * @brief 返回widget列表
+ * @return
+ */
+ QList<QWidget *> widgetList();
+
+Q_SIGNALS:
+ /**
+ * @brief 点击会发出信号
+ */
+ void clicked(QWidget*);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+ bool eventFilter(QObject *watched, QEvent *event);
+
+private:
+ Q_DECLARE_PRIVATE(KBackgroundGroup)
+ KBackgroundGroupPrivate* const d_ptr;
+};
+
+}
+#endif // KBACKGROUNDGROUP_H
diff --git a/kysdk-qtwidgets/src/kballontip.cpp b/kysdk-qtwidgets/src/kballontip.cpp
index 784929d..499e39d 100644
--- a/kysdk-qtwidgets/src/kballontip.cpp
+++ b/kysdk-qtwidgets/src/kballontip.cpp
@@ -45,9 +45,10 @@ KBallonTip::KBallonTip(QWidget *parent)
d_ptr(new KBallonTipPrivate(this))
{
Q_D(KBallonTip);
+ setWindowFlag(Qt::ToolTip);
d->m_pVLayout = new QVBoxLayout(this);
d->m_pLayout = new QHBoxLayout(this);
- d->m_pLayout->setSpacing(13);
+ d->m_pLayout->setSpacing(12);
this->setContentsMargins(24,18,24,18);
d->m_pContentLabel = new QLabel(this);
d->m_pContentLabel->setWordWrap(true);
@@ -75,7 +76,7 @@ KBallonTip::KBallonTip(QWidget *parent)
d->m_pVLayout->addLayout(d->m_pLayout);
d->m_pVLayout->addStretch();
d->adjustStyle();
- d->m_pVLayout->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize);
+ d->m_pVLayout->setSizeConstraint(QLayout::SizeConstraint::SetMinimumSize);
if(ThemeController::systemFontSize() > 11)
vLayout->setContentsMargins(0,(ThemeController::systemFontSize()-11),0,0);
else
@@ -205,7 +206,8 @@ void KBallonTipPrivate::adjustStyle()
m_pIconLabel->hide();
break;
case TipType::Normal:
- m_icon = QIcon::fromTheme("ukui-dialog-success");
+// m_icon = QIcon::fromTheme("ukui-dialog-success");
+ m_icon = QIcon::fromTheme("ukui-dialog-success", QIcon::fromTheme("emblem-default"));
m_pIconLabel->show();
break;
case TipType::Info:;
diff --git a/kysdk-qtwidgets/src/kborderbutton.cpp b/kysdk-qtwidgets/src/kborderbutton.cpp
index 42fd3a2..1598833 100644
--- a/kysdk-qtwidgets/src/kborderbutton.cpp
+++ b/kysdk-qtwidgets/src/kborderbutton.cpp
@@ -38,6 +38,12 @@ KBorderButton::~KBorderButton()
{
}
+QSize KBorderButton::sizeHint() const
+{
+ auto size = QPushButton::sizeHint();
+ size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
+ return size;
+}
bool KBorderButton::eventFilter(QObject *watched, QEvent *event)
{
Q_D(KBorderButton);
@@ -89,6 +95,7 @@ void KBorderButton::paintEvent(QPaintEvent *event)
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
QPen pen;
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
@@ -150,13 +157,6 @@ void KBorderButton::paintEvent(QPaintEvent *event)
p.drawText(ir,tf,option.text);
}
-QSize KBorderButton::sizeHint() const
-{
- auto size = QPushButton::sizeHint();
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
- return size;
-}
-
KBorderButton::KBorderButton(const QString &text, QWidget *parent ):KBorderButton(parent)
{
setText(text);
diff --git a/kysdk-qtwidgets/src/kborderlessbutton.cpp b/kysdk-qtwidgets/src/kborderlessbutton.cpp
index d7c7c3f..81cb28d 100644
--- a/kysdk-qtwidgets/src/kborderlessbutton.cpp
+++ b/kysdk-qtwidgets/src/kborderlessbutton.cpp
@@ -138,6 +138,7 @@ void KBorderlessButton::paintEvent(QPaintEvent *event)
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
QPen pen;
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
diff --git a/kysdk-qtwidgets/src/kbreadcrumb.cpp b/kysdk-qtwidgets/src/kbreadcrumb.cpp
index 322a59a..8a3760a 100644
--- a/kysdk-qtwidgets/src/kbreadcrumb.cpp
+++ b/kysdk-qtwidgets/src/kbreadcrumb.cpp
@@ -92,6 +92,10 @@ void KBreadCrumb::paintEvent(QPaintEvent *event)
focusColor = "#262626";
}
QPainter p(this);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.setRenderHint(QPainter::HighQualityAntialiasing);
+ p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
for(int i = 0 ; i < count(); i++)
{
QRect rc = tabRect(i);
diff --git a/kysdk-qtwidgets/src/kbubblewidget.cpp b/kysdk-qtwidgets/src/kbubblewidget.cpp
index 85ac6d7..5ddaced 100644
--- a/kysdk-qtwidgets/src/kbubblewidget.cpp
+++ b/kysdk-qtwidgets/src/kbubblewidget.cpp
@@ -3,8 +3,8 @@
#include <QPainter>
#include <QRegion>
#include <KWindowEffects>
-#include <QPainterPath>
#include "themeController.h"
+#include <QPainterPath>
namespace kdk {
diff --git a/kysdk-qtwidgets/src/kbuttonbox.cpp b/kysdk-qtwidgets/src/kbuttonbox.cpp
new file mode 100644
index 0000000..b92ae85
--- /dev/null
+++ b/kysdk-qtwidgets/src/kbuttonbox.cpp
@@ -0,0 +1,279 @@
+#include "kbuttonbox.h"
+#include <QButtonGroup>
+#include <QBoxLayout>
+#include <QPainter>
+#include <QStyleOptionButton>
+#include <QColor>
+#include <QStylePainter>
+#include "themeController.h"
+
+namespace kdk {
+class KButtonBoxPrivate : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KButtonBox)
+public:
+ KButtonBoxPrivate(KButtonBox* parent);
+ void updateBorderRadius();
+ void updateButtonList();
+private:
+ KButtonBox *q_ptr;
+ QButtonGroup *m_buttonGroup;
+ QBoxLayout *m_layout;
+ int m_radius;
+ bool m_isCheckable;
+ QList<KPushButton *> m_buttonList;
+};
+
+KButtonBoxPrivate::KButtonBoxPrivate(KButtonBox *parent)
+ :q_ptr(parent)
+{
+ Q_Q(KButtonBox);
+ m_buttonGroup = new QButtonGroup(q);
+ q->connect(m_buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), q, SIGNAL(buttonClicked(QAbstractButton*)));
+ q->connect(m_buttonGroup, SIGNAL(buttonPressed(QAbstractButton*)), q, SIGNAL(buttonPressed(QAbstractButton*)));
+ q->connect(m_buttonGroup, SIGNAL(buttonReleased(QAbstractButton*)), q, SIGNAL(buttonReleased(QAbstractButton*)));
+ q->connect(m_buttonGroup, SIGNAL(buttonToggled(QAbstractButton*, bool)), q, SIGNAL(buttonToggled(QAbstractButton*, bool)));
+
+ m_layout = new QHBoxLayout(q);
+ m_layout->setSizeConstraint(QLayout::SetFixedSize);
+ m_layout->setMargin(0);
+ m_layout->setSpacing(0);
+ m_radius = 6;
+ m_isCheckable = false;
+}
+
+void KButtonBoxPrivate::updateBorderRadius()
+{
+ Q_Q(KButtonBox);
+ QList<KPushButton *> buttonList = q->buttonList();
+ switch (q->orientation()) {
+ case Qt::Horizontal: {
+ for(int i = 0 ; i < buttonList.count(); i++)
+ {
+ KPushButton *button = buttonList.at(i);
+ if(i == 0){
+ Q_ASSERT(button);
+ button->setBorderRadius(m_radius,m_radius,0,0);
+ }
+ else if(i == buttonList.count()-1){
+ Q_ASSERT(button);
+ button->setBorderRadius(0,0,m_radius,m_radius);
+ }
+ else {
+ Q_ASSERT(button);
+ button->setBorderRadius(0);
+ }
+ }
+ break;
+ }
+ case Qt::Vertical: {
+ for(int i = 0 ; i < buttonList.count(); i++)
+ {
+ KPushButton *button = buttonList.at(i);
+ if(i == 0){
+ Q_ASSERT(button);
+ button->setBorderRadius(0,m_radius,m_radius,0);
+ }
+ else if(i == buttonList.count()-1){
+ Q_ASSERT(button);
+ button->setBorderRadius(m_radius,0,0,m_radius);
+ }
+ else {
+ Q_ASSERT(button);
+ button->setBorderRadius(0);
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ q->update();
+}
+
+void KButtonBoxPrivate::updateButtonList()
+{
+ Q_Q(KButtonBox);
+
+ for (QAbstractButton *button : m_buttonGroup->buttons()) {
+ m_buttonGroup->removeButton(button);
+ m_layout->removeWidget(button);
+ }
+ for (int i = 0; i < m_buttonList.count(); ++i) {
+ KPushButton *button = m_buttonList.at(i);
+ button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ m_layout->insertWidget(i,button);
+ m_buttonGroup->addButton(button,i);
+ button->setCheckable(m_isCheckable);
+ }
+ updateBorderRadius();
+}
+
+KButtonBox::KButtonBox(QWidget *parent)
+ :QWidget(parent)
+ ,d_ptr(new KButtonBoxPrivate(this))
+{
+ Q_D(KButtonBox);
+}
+
+KButtonBox::~KButtonBox()
+{
+
+}
+
+Qt::Orientation KButtonBox::orientation()
+{
+ Q_D(KButtonBox);
+ QBoxLayout::Direction layoutDirection = d->m_layout->direction();
+ if(layoutDirection == QBoxLayout::LeftToRight || layoutDirection == QBoxLayout::RightToLeft)
+ {
+ return Qt::Horizontal;
+ }
+ return Qt::Vertical;
+}
+
+void KButtonBox::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(KButtonBox);
+ if(orientation == Qt::Vertical)
+ {
+ d->m_layout->setDirection(QBoxLayout::TopToBottom);
+ d->updateBorderRadius();
+ return;
+ }
+ d->m_layout->setDirection(QBoxLayout::LeftToRight);
+ d->updateBorderRadius();
+}
+
+void KButtonBox::addButton(KPushButton *button ,int i)
+{
+ Q_D(KButtonBox);
+ if(i < -1)
+ return;
+
+ if(i == -1 || i >= d->m_buttonList.count()){
+ d->m_buttonList.append(button);
+ }
+ else{
+ d->m_buttonList.insert(i,button);
+ }
+
+ button->show();
+
+ setButtonList(d->m_buttonList);
+}
+
+void KButtonBox::removeButton(KPushButton *button)
+{
+ Q_D(KButtonBox);
+ if(d->m_buttonList.contains(button)){
+ d->m_buttonList.removeAll(button);
+ button->hide();
+ }
+ setButtonList(d->m_buttonList);
+}
+
+void KButtonBox::removeButton(int i)
+{
+ Q_D(KButtonBox);
+ if(i < 0 || i >= d->m_buttonList.count())
+ return;
+ auto button = d->m_buttonList.at(i);
+ if(button)
+ button->hide();
+ d->m_buttonList.removeAt(i);
+ setButtonList(d->m_buttonList);
+}
+
+void KButtonBox::setButtonList(const QList<KPushButton *> &list)
+{
+ Q_D(KButtonBox);
+ d->m_buttonList = list;
+ d->updateButtonList();
+}
+
+QList<KPushButton *> KButtonBox::buttonList()
+{
+ Q_D(KButtonBox);
+ return d->m_buttonList;
+}
+
+void KButtonBox::setBorderRadius(int radius)
+{
+ Q_D(KButtonBox);
+ d->m_radius = radius;
+ update();
+}
+
+int KButtonBox::borderRadius()
+{
+ Q_D(KButtonBox);
+ return d->m_radius;
+}
+
+void KButtonBox::setId(KPushButton *button, int id)
+{
+ Q_D(KButtonBox);
+ d->m_buttonGroup->setId(button,id);
+}
+
+int KButtonBox::id(KPushButton *button)
+{
+ Q_D(KButtonBox);
+ return d->m_buttonGroup->id(button);
+}
+
+KPushButton *KButtonBox::checkedButton()
+{
+ Q_D(KButtonBox);
+ KPushButton * button = dynamic_cast<KPushButton*>(d->m_buttonGroup->checkedButton());
+ return button;
+}
+
+KPushButton *KButtonBox::button(int id)
+{
+ Q_D(KButtonBox);
+ KPushButton * button = dynamic_cast<KPushButton*>(d->m_buttonGroup->button(id));
+ return button;
+}
+
+int KButtonBox::checkedId()
+{
+ Q_D(KButtonBox);
+ return d->m_buttonGroup->checkedId();
+}
+
+void KButtonBox::setExclusive(bool exclusive)
+{
+ Q_D(KButtonBox);
+ d->m_buttonGroup->setExclusive(exclusive);
+}
+
+bool KButtonBox::exclusive()
+{
+ Q_D(KButtonBox);
+ return d->m_buttonGroup->exclusive();
+}
+
+void KButtonBox::setCheckable(bool flag)
+{
+ Q_D(KButtonBox);
+ d->m_isCheckable = flag;
+ QList<KPushButton *> list = buttonList();
+ for (int i = 0; i < list.count(); ++i) {
+ KPushButton *button = list.at(i);
+ button->setCheckable(d->m_isCheckable);
+ }
+ update();
+}
+
+bool KButtonBox::isCheckable()
+{
+ Q_D(KButtonBox);
+ return d->m_isCheckable;
+}
+
+}
+#include "kbuttonbox.moc"
+#include "moc_kbuttonbox.cpp"
diff --git a/kysdk-qtwidgets/src/kbuttonbox.h b/kysdk-qtwidgets/src/kbuttonbox.h
new file mode 100644
index 0000000..424ed45
--- /dev/null
+++ b/kysdk-qtwidgets/src/kbuttonbox.h
@@ -0,0 +1,144 @@
+#ifndef KBUTTONBOX_H
+#define KBUTTONBOX_H
+
+#include "gui_g.h"
+#include "kpushbutton.h"
+#include <QWidget>
+#include <QAbstractButton>
+
+
+namespace kdk {
+
+class KButtonBoxPrivate;
+
+class GUI_EXPORT KButtonBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit KButtonBox(QWidget *parent = nullptr);
+ ~KButtonBox();
+
+ /**
+ * @brief 获取KButtonBox的布局类型
+ * @return
+ */
+ Qt::Orientation orientation();
+
+ /**
+ * @brief 设置KButtonBox的布局类型,包括水平类型和垂直类型
+ * @param orientation
+ */
+ void setOrientation(Qt::Orientation orientation);
+
+ /**
+ * @brief 添加按钮
+ * @param button
+ */
+ void addButton(KPushButton *button,int i = -1);
+
+ /**
+ * @brief 删除按钮
+ * @param button
+ */
+ void removeButton(KPushButton *button);
+
+ /**
+ * @brief 按id删除指定按钮
+ * @param i
+ */
+ void removeButton(int i);
+
+ /**
+ * @brief 以列表形式向KButtonBox中添加按钮
+ * @param list
+ * @param checkable
+ */
+ void setButtonList(const QList<KPushButton*> &list);
+
+ /**
+ * @brief 获取KButtonBox中的按钮列表
+ * @return
+ */
+ QList<KPushButton *> buttonList();
+
+ /**
+ * @brief 设置KButtonBox首尾部分按钮的圆角
+ * @param radius
+ */
+ void setBorderRadius(int radius);
+
+ /**
+ * @brief 获取KButtonBox首尾部分按钮的圆角
+ * @return
+ */
+ int borderRadius();
+
+ /**
+ * @brief 设置按钮id
+ * @param button
+ * @param id
+ */
+ void setId(KPushButton *button, int id);
+
+ /**
+ * @brief 获取按钮id
+ * @param button
+ * @return
+ */
+ int id(KPushButton *button);
+
+ /**
+ * @brief 返回已选中的按钮
+ * @return
+ */
+ KPushButton * checkedButton();
+
+ /**
+ * @brief 通过按钮id获取按钮
+ * @param id
+ * @return
+ */
+ KPushButton *button(int id);
+
+ /**
+ * @brief 返回已选中按钮的id
+ * @return
+ */
+ int checkedId();
+
+ /**
+ * @brief 设置KButtonBox按钮间是否互斥
+ */
+ void setExclusive(bool);
+
+ /**
+ * @brief 返回KButtonBox按钮间是否互斥
+ * @return
+ */
+ bool exclusive();
+
+ /**
+ * @brief 设置KButtonBox中的按钮是否可选中
+ */
+ void setCheckable(bool flag);
+
+ /**
+ * @brief 返回KButtonBox中的按钮是否可选中
+ * @return
+ */
+ bool isCheckable();
+
+Q_SIGNALS:
+ void buttonClicked(QAbstractButton *);
+ void buttonPressed(QAbstractButton *);
+ void buttonReleased(QAbstractButton *);
+ void buttonToggled(QAbstractButton *, bool);
+
+private:
+ Q_DECLARE_PRIVATE(KButtonBox)
+ KButtonBoxPrivate* const d_ptr;
+};
+
+}
+#endif // KBUTTONBOX_H
diff --git a/kysdk-qtwidgets/src/kcolorbutton.cpp b/kysdk-qtwidgets/src/kcolorbutton.cpp
new file mode 100644
index 0000000..f407b98
--- /dev/null
+++ b/kysdk-qtwidgets/src/kcolorbutton.cpp
@@ -0,0 +1,198 @@
+#include "kcolorbutton.h"
+#include <QPainter>
+#include <QStyleOptionButton>
+#include "themeController.h"
+#include <QDebug>
+
+namespace kdk {
+
+static const int circleButtonSize = 20;
+static const int normalButtonSize = 24;
+
+class KColorButtonPrivate : public QObject,public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KColorButton)
+public:
+ KColorButtonPrivate(KColorButton* parent);
+
+protected:
+ void changeTheme();
+
+private:
+ KColorButton* const q_ptr;
+ bool m_backgroundFlag;
+ QColor m_backgroundColor;
+ int m_radius;
+ KColorButton::ButtonType m_buttonType;
+};
+
+KColorButton::KColorButton(QWidget *parent)
+ :QPushButton(parent)
+ ,d_ptr(new KColorButtonPrivate(this))
+{
+ Q_D(KColorButton);
+ setCheckable(true);
+}
+
+void KColorButton::setBackgroundColor(QColor color)
+{
+ Q_D(KColorButton);
+ d->m_backgroundFlag = true;
+ d->m_backgroundColor = color;
+ update();
+}
+
+QColor KColorButton::backgroundColor()
+{
+ Q_D(KColorButton);
+ return d->m_backgroundColor;
+}
+
+void KColorButton::setBorderRadius(int radious)
+{
+ Q_D(KColorButton);
+ d->m_radius = radious;
+}
+
+void KColorButton::setButtonType(KColorButton::ButtonType type)
+{
+ Q_D(KColorButton);
+ d->m_buttonType = type;
+}
+
+void KColorButton::paintEvent(QPaintEvent *)
+{
+ Q_D(KColorButton);
+ QStyleOptionButton option;
+ initStyleOption(&option);
+
+ QRect rect = option.rect;
+
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setRenderHint(QPainter::HighQualityAntialiasing);
+ painter.setRenderHint(QPainter::SmoothPixmapTransform);
+ painter.setPen(Qt::NoPen);
+
+ if(!option.state.testFlag(QStyle::State_Enabled))
+ {
+ painter.save();
+ painter.setBrush(option.palette.color(QPalette::Disabled,QPalette::ButtonText));
+ painter.drawRoundedRect(rect,d->m_radius,d->m_radius);
+ painter.restore();
+ }
+ else if(d->m_buttonType == RoundedRect)
+ {
+ painter.save();
+ if(d->m_backgroundFlag)
+ {
+ painter.setBrush(d->m_backgroundColor);
+ }
+ else
+ {
+ painter.setBrush(palette().highlight().color());
+ }
+ if(isChecked() || option.state.testFlag(QStyle::State_MouseOver))
+ {
+ painter.save();
+ painter.setBrush(Qt::white);
+ painter.drawRoundedRect(rect,d->m_radius,d->m_radius);//绘制边框
+ rect = rect.adjusted(2,2,-2,-2);
+ painter.restore();
+
+ painter.drawRoundedRect(rect,d->m_radius/2,d->m_radius/2);
+ }
+ else
+ painter.drawRoundedRect(rect,d->m_radius,d->m_radius);
+ painter.restore();
+ }
+ else if(d->m_buttonType == Circle)
+ {
+ painter.save();
+ QRect rect = option.rect.adjusted(1,1,0,0);
+ if(d->m_backgroundFlag)
+ {
+ painter.setBrush(d->m_backgroundColor);
+ }
+ else
+ {
+ painter.setBrush(palette().highlight().color());
+ }
+
+ painter.drawEllipse(rect);
+
+ QRect rect1 = rect.adjusted(rect.width()/4,rect.height()/4,-rect.width()/4,-rect.height()/4);
+ if(option.state.testFlag(QStyle::State_MouseOver) || isChecked())
+ {
+ painter.save();
+ painter.setBrush(Qt::white);
+ painter.drawEllipse(rect1);
+ painter.restore();
+ }
+ painter.restore();
+ }
+ else
+ {
+ painter.save();
+ if(d->m_backgroundFlag)
+ {
+ painter.setBrush(d->m_backgroundColor);
+ }
+ else
+ {
+ painter.setBrush(palette().highlight().color());
+ }
+ if(isChecked())
+ {
+ QPointF points[3] = {
+ QPointF(rect.x() + rect.width() * 2 / 11, rect.y() + rect.height() * 6 / 11),
+ QPointF(rect.x() + rect.width() * 5 / 11, rect.y() + rect.height() * 8 / 11),
+ QPointF(rect.x() + rect.width() * 9 / 11, rect.y() + rect.height() * 4 / 11),
+ };
+ painter.drawRoundedRect(rect,d->m_radius,d->m_radius);
+ painter.setPen(QPen(Qt::white,2));
+ painter.drawPolyline(points, 3);
+ }
+ else
+ {
+ painter.drawRoundedRect(rect,d->m_radius,d->m_radius);
+ }
+ painter.restore();
+ }
+}
+
+QSize KColorButton::sizeHint() const
+{
+ Q_D(const KColorButton);
+ if(d->m_buttonType == Circle)
+ return QSize(circleButtonSize,circleButtonSize);
+ else
+ return QSize(normalButtonSize,normalButtonSize);
+}
+
+KColorButtonPrivate::KColorButtonPrivate(KColorButton *parent)
+ :q_ptr(parent)
+{
+ Q_Q(KColorButton);
+ m_backgroundFlag = false;
+ m_radius =6;
+ m_buttonType = KColorButton::RoundedRect;
+ m_backgroundColor = q->palette().highlight().color();
+ connect(m_gsetting,&QGSettings::changed,this,[=](){
+ changeTheme();
+ q->update();
+ });
+}
+
+void KColorButtonPrivate::changeTheme()
+{
+ Q_Q(KColorButton);
+ initThemeStyle();
+}
+
+
+}
+
+#include "kcolorbutton.moc"
+#include "moc_kcolorbutton.cpp"
diff --git a/kysdk-qtwidgets/src/kcolorbutton.h b/kysdk-qtwidgets/src/kcolorbutton.h
new file mode 100644
index 0000000..58d381c
--- /dev/null
+++ b/kysdk-qtwidgets/src/kcolorbutton.h
@@ -0,0 +1,71 @@
+#ifndef KCOLORBUTTON_H
+#define KCOLORBUTTON_H
+
+#include <QPushButton>
+#include "gui_g.h"
+
+namespace kdk {
+
+class KColorButtonPrivate;
+
+class GUI_EXPORT KColorButton :public QPushButton
+{
+ Q_OBJECT
+public:
+
+ enum ButtonType{
+ Circle,
+ RoundedRect,
+ CheckedRect
+ };
+
+ KColorButton(QWidget* parent = nullptr);
+
+ /**
+ * @brief 设置colorButton背景色
+ * @param color
+ */
+ void setBackgroundColor(QColor color);
+
+ /**
+ * @brief 返回colorButton背景色
+ * @return
+ */
+ QColor backgroundColor();
+
+ /**
+ * @brief 设置圆角(仅NormalType类型生效)
+ * @param radious
+ */
+ void setBorderRadius(int radious);
+
+ /**
+ * @brief 返回圆角
+ * @return
+ */
+ int borderRadius();
+
+ /**
+ * @brief 设置colorButton类型
+ * @param type
+ */
+ void setButtonType(KColorButton::ButtonType type);
+
+ /**
+ * @brief 返回colorButton类型
+ * @return
+ */
+ KColorButton::ButtonType buttonType();
+
+protected:
+ void paintEvent(QPaintEvent *) override;
+ QSize sizeHint() const override;
+
+private:
+ Q_DECLARE_PRIVATE(KColorButton)
+ KColorButtonPrivate* const d_ptr;
+};
+
+}
+
+#endif // KCOLORBUTTON_H
diff --git a/kysdk-qtwidgets/src/kcolorcombobox.cpp b/kysdk-qtwidgets/src/kcolorcombobox.cpp
new file mode 100644
index 0000000..eeef9c9
--- /dev/null
+++ b/kysdk-qtwidgets/src/kcolorcombobox.cpp
@@ -0,0 +1,300 @@
+#include "kcolorcombobox.h"
+#include "themeController.h"
+#include <qstylepainter.h>
+#include <QStyledItemDelegate>
+#include <QVariant>
+#include <QAbstractItemView>
+#include <QCompleter>
+#include <QListView>
+#include <QProxyStyle>
+#include <QDebug>
+#include <QResizeEvent>
+
+namespace kdk {
+
+const static int defaultBorderRadius = 4;
+const static QSize defaultPopupItemSize(20,20);
+static QSize g_size;
+
+class KComboStyle:public QProxyStyle
+{
+public:
+ KComboStyle(){}
+ ~KComboStyle(){}
+
+QSize sizeFromContents(QStyle::ContentsType type,
+ const QStyleOption *option,
+ const QSize &contentsSize,
+ const QWidget *widget = nullptr) const override;
+
+};
+
+class KColorComboBoxDelegate:public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ enum ItemRoles {
+ ColorRole = Qt::UserRole + 1
+ };
+
+ KColorComboBoxDelegate(QObject *parent = nullptr,KColorComboBox* combo = nullptr);
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+
+private:
+ KColorComboBox* m_combo;
+};
+
+class KColorComboBoxPrivate:public QObject,public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KColorComboBox)
+
+public:
+ KColorComboBoxPrivate(KColorComboBox*parent);
+ void updateList();
+
+public Q_SLOTS:
+ void slotActivated(int);
+ void slotHighlighted(int);
+ void slotCurrentIndexChanged(int);
+
+private:
+ KColorComboBox* q_ptr;
+ KColorComboBox::ComboType m_comboType;
+ QList<QColor> m_colorList;
+ int m_borderRadius;
+ QColor m_currentColor;
+ QSize m_popupItemSize;
+};
+
+KColorComboBox::KColorComboBox(QWidget *parent)
+ : QComboBox(parent),
+ d_ptr(new KColorComboBoxPrivate(this))
+{
+ Q_D(KColorComboBox);
+ setItemDelegate(new KColorComboBoxDelegate(this,this));
+ KComboStyle*style = new KComboStyle();
+ setStyle(style);
+ view()->setFixedWidth(d->m_popupItemSize.width());
+ connect(this, SIGNAL(activated(int)), d, SLOT(slotActivated(int)));
+ connect(this, SIGNAL(highlighted(int)),d, SLOT(slotHighlighted(int)));
+ connect(this, SIGNAL(currentIndexChanged(int)),d, SLOT(slotCurrentIndexChanged(int)));
+}
+
+void KColorComboBox::setColorList(const QList<QColor> &list)
+{
+ Q_D(KColorComboBox);
+ d->m_colorList = list;
+ d->updateList();
+}
+
+QList<QColor> KColorComboBox::colorList()
+{
+ Q_D(KColorComboBox);
+ return d->m_colorList;
+}
+
+void KColorComboBox::addColor(const QColor &color)
+{
+ Q_D(KColorComboBox);
+ d->m_colorList.append(color);
+ addItem(QString());
+ setItemData(d->m_colorList.count()-1 , d->m_colorList.back(), KColorComboBoxDelegate::ColorRole);
+ update();
+}
+
+void KColorComboBox::setComboType(const KColorComboBox::ComboType &type)
+{
+ Q_D(KColorComboBox);
+ d->m_comboType = type;
+ update();
+}
+
+KColorComboBox::ComboType KColorComboBox::comboType()
+{
+ Q_D(KColorComboBox);
+ return d->m_comboType;
+}
+
+void KColorComboBox::setPopupItemSize(const QSize &size)
+{
+ Q_D(KColorComboBox);
+
+ //d->m_popupItemSize = size;
+ d->m_popupItemSize = size.expandedTo(this->size());
+ g_size = d->m_popupItemSize;
+ view()->setFixedWidth(d->m_popupItemSize.width());
+ update();
+}
+
+QSize KColorComboBox::popupItemSzie()
+{
+ Q_D(KColorComboBox);
+ return d->m_popupItemSize;
+}
+
+void KColorComboBox::paintEvent(QPaintEvent *event)
+{
+ Q_UNUSED(event)
+ Q_D(KColorComboBox);
+ QStylePainter painter(this);
+ painter.setPen(Qt::NoPen);
+
+ QStyleOptionComboBox opt;
+ initStyleOption(&opt);
+
+ QRect frame = this->rect();
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::transparent);
+ if(d->m_currentColor.isValid())
+ painter.setBrush(d->m_currentColor);
+ if(d->m_comboType == KColorComboBox::Circle)
+ {
+ painter.drawEllipse(frame.adjusted(1, 1, -1, -1));
+ }
+ else
+ {
+ painter.drawRoundedRect(frame.adjusted(1, 1, -1, -1), d->m_borderRadius, d->m_borderRadius);
+ }
+}
+
+void KColorComboBox::resizeEvent(QResizeEvent *event)
+{
+ setPopupItemSize(event->size());
+ QComboBox::resizeEvent(event);
+}
+
+KColorComboBoxPrivate::KColorComboBoxPrivate(KColorComboBox *parent)
+ :q_ptr(parent),
+ m_comboType(KColorComboBox::Circle),
+ m_borderRadius(defaultBorderRadius),
+ m_popupItemSize(defaultPopupItemSize)
+{
+ setParent(parent);
+}
+
+void KColorComboBoxPrivate::updateList()
+{
+ Q_Q(KColorComboBox);
+ while (q->count()) {
+ q->removeItem(0);
+ }
+ for (int i = 0 ; i < m_colorList.count(); ++i) {
+ q->addItem(QString());
+ q->setItemData(i , m_colorList[i], KColorComboBoxDelegate::ColorRole);
+ }
+ q->update();
+}
+
+void KColorComboBoxPrivate::slotActivated(int index)
+{
+ Q_Q(KColorComboBox);
+
+ m_currentColor = m_colorList[index];
+ q->update();
+ Q_EMIT q->activated(m_currentColor);
+}
+
+void KColorComboBoxPrivate::slotHighlighted(int index)
+{
+ Q_Q(KColorComboBox);
+
+ auto color = m_colorList[index];
+ q->update();
+ Q_EMIT q->highlighted(color);
+}
+
+void KColorComboBoxPrivate::slotCurrentIndexChanged(int index)
+{
+ Q_Q(KColorComboBox);
+
+ m_currentColor = m_colorList[index];
+ q->update();
+ Q_EMIT q->currentColorChanged(m_currentColor);
+}
+
+KColorComboBoxDelegate::KColorComboBoxDelegate(QObject *parent,KColorComboBox*combo)
+ :QStyledItemDelegate(parent),
+ m_combo(combo)
+{
+}
+
+void KColorComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ auto variant = index.data(ItemRoles::ColorRole);
+ auto color = variant.value<QColor>();
+ auto paintRect = option.rect.adjusted(5,5,-5,-5);
+
+ switch (m_combo->comboType()) {
+ case KColorComboBox::Circle:
+ {
+ if(color.isValid())
+ {
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(color);
+ painter->drawEllipse(paintRect);
+ painter->restore();
+ }
+ if(option.state & (QStyle::State_MouseOver | QStyle::State_Selected))
+ {
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(Qt::white);
+ QRect subRect(paintRect.top(),paintRect.left(),paintRect.width()/2,paintRect.height()/2);
+ subRect.moveCenter(paintRect.center());
+ painter->drawEllipse(subRect);
+ painter->restore();
+ }
+ break;
+ }
+ case KColorComboBox::RoundedRect:
+ {
+ if(color.isValid())
+ {
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+ if(option.state & (QStyle::State_MouseOver | QStyle::State_Selected))
+ {
+ QPen pen;
+ pen.setWidth(2);
+ pen.setBrush(Qt::white);
+ painter->setPen(pen);
+ }
+ else
+ {
+ painter->setPen(Qt::NoPen);
+ }
+ painter->setBrush(color);
+ painter->drawRoundedRect(paintRect,defaultBorderRadius,defaultBorderRadius);
+ painter->restore();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+QSize KColorComboBoxDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ return m_combo->popupItemSzie();
+}
+
+QSize KComboStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
+{
+ if(type == QStyle::CT_ComboBox)
+ return g_size;
+
+ return QProxyStyle::sizeFromContents(type,option,contentsSize,widget);
+}
+
+}
+#include "kcolorcombobox.moc"
+#include "moc_kcolorcombobox.cpp"
diff --git a/kysdk-qtwidgets/src/kcolorcombobox.h b/kysdk-qtwidgets/src/kcolorcombobox.h
new file mode 100644
index 0000000..49995c6
--- /dev/null
+++ b/kysdk-qtwidgets/src/kcolorcombobox.h
@@ -0,0 +1,91 @@
+#ifndef KCOLORCOMBOBOX_H
+#define KCOLORCOMBOBOX_H
+
+#include <QComboBox>
+#include <QList>
+#include <QColor>
+#include "gui_g.h"
+
+namespace kdk {
+
+class KColorComboBoxPrivate;
+
+/**
+ * @brief 颜色选择框
+ */
+class GUI_EXPORT KColorComboBox : public QComboBox
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * @brief 指定显示样式,圆形或者圆角矩形
+ */
+ enum ComboType
+ {
+ Circle,
+ RoundedRect
+ };
+
+ explicit KColorComboBox(QWidget *parent = nullptr);
+
+ /**
+ * @brief 以列表形式添加颜色选项
+ * @param list
+ */
+ void setColorList(const QList<QColor>& list);
+
+ /**
+ * @brief 获取颜色列表
+ * @return
+ */
+ QList<QColor> colorList();
+
+ /**
+ * @brief 添加颜色选项
+ * @param color
+ */
+ void addColor(const QColor& color);
+
+ /**
+ * @brief 设置显示样式
+ * @param type
+ */
+ void setComboType(const ComboType& type);
+
+ /**
+ * @brief 获取显示样式
+ * @return
+ */
+ ComboType comboType();
+
+ /**
+ * @brief 设置item尺寸
+ * @param size
+ */
+ void setPopupItemSize(const QSize&size);
+
+ /**
+ * @brief 返回item尺寸
+ * @return
+ */
+ QSize popupItemSzie();
+
+
+Q_SIGNALS:
+
+ void activated(const QColor& color);
+ void currentColorChanged(const QColor& color);
+ void highlighted(const QColor& color);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ Q_DECLARE_PRIVATE(KColorComboBox)
+ KColorComboBoxPrivate*const d_ptr;
+};
+}
+#endif // KCOLORCOMBOBOX_H
diff --git a/kysdk-qtwidgets/src/kdialog.cpp b/kysdk-qtwidgets/src/kdialog.cpp
index 7a2d25c..0b2a4fe 100644
--- a/kysdk-qtwidgets/src/kdialog.cpp
+++ b/kysdk-qtwidgets/src/kdialog.cpp
@@ -2,9 +2,9 @@
#include <QBoxLayout>
#include <QApplication>
#include "xatom-helper.h"
-#include "ukuistylehelper/ukui-decoration-manager.h"
#include "parmscontroller.h"
+#include "ukuistylehelper/ukui-decoration-manager.h"
namespace kdk
{
class KDialogPrivate:public QObject
@@ -101,6 +101,7 @@ void KDialog::setWindowTitle(const QString &title)
{
Q_D(KDialog);
d->m_pIconBar->setWidgetName(title);
+ QDialog::setWindowTitle(title);
}
QPushButton *KDialog::maximumButton()
diff --git a/kysdk-qtwidgets/src/kiconbar.cpp b/kysdk-qtwidgets/src/kiconbar.cpp
index cb937a7..2e9af67 100644
--- a/kysdk-qtwidgets/src/kiconbar.cpp
+++ b/kysdk-qtwidgets/src/kiconbar.cpp
@@ -39,7 +39,9 @@ KIconBar::KIconBar(QWidget*parent)
setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight));
connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){
setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight));
- d->m_pIconLabel->setPixmap(QIcon::fromTheme(d->m_IconName).pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize))));
+ d->m_pIconLabel->setPixmap(QIcon::fromTheme(d->m_IconName).pixmap(
+ QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),
+ Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize))));
updateGeometry();
});
}
@@ -75,7 +77,7 @@ void KIconBar::setIcon(const QIcon &icon)
if(!d->m_pIconLabel)
return;
- d->m_pIconLabel->setPixmap(icon.pixmap(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize)));
+ d->m_pIconLabel->setPixmap(icon.pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize))));
d->m_IconName = icon.name();
setWindowIcon(icon.pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize))));
}
@@ -92,6 +94,12 @@ void KIconBar::setWidgetName(const QString &widgetName)
d->elideWidgetName();
}
+QSize KIconBar::sizeHint() const
+{
+ auto size = QFrame::sizeHint();
+ size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
+ return size;
+}
QLabel *KIconBar::nameLabel()
{
Q_D(KIconBar);
@@ -118,13 +126,6 @@ void KIconBar::resizeEvent(QResizeEvent *event)
d->elideWidgetName();
}
-QSize KIconBar::sizeHint() const
-{
- auto size =QFrame::sizeHint();
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
- return size;
-}
-
KIconBarPrivate::KIconBarPrivate(KIconBar *parent)
:q_ptr(parent)
{
@@ -132,6 +133,8 @@ KIconBarPrivate::KIconBarPrivate(KIconBar *parent)
setParent(parent);
m_pMainLayout = new QHBoxLayout(q);
m_pIconLabel = new QLabel(q);
+ m_pIconLabel->setScaledContents(true);
+ m_pIconLabel->setFixedSize(24,24);
m_pNameLabel = new QLabel(q);
m_pMainLayout->addSpacing(8);
diff --git a/kysdk-qtwidgets/src/kinputdialog.cpp b/kysdk-qtwidgets/src/kinputdialog.cpp
index 2a728f7..be1fd8c 100644
--- a/kysdk-qtwidgets/src/kinputdialog.cpp
+++ b/kysdk-qtwidgets/src/kinputdialog.cpp
@@ -15,7 +15,6 @@
#include "qvalidator.h"
#include "qevent.h"
#include "kinputdialog.h"
-#include "parmscontroller.h"
namespace kdk
{
@@ -130,19 +129,6 @@ private:
}
};
-class KInputDialogListView : public QListView
-{
-public:
- KInputDialogListView(QWidget *parent = nullptr) : QListView(parent) {}
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
- {
- if (query == Qt::ImEnabled)
- return false;
- return QListView::inputMethodQuery(query);
- }
-};
-
-
class KInputDialogLineEdit :public QLineEdit
{
public:
@@ -152,13 +138,16 @@ protected:
};
-class KInputDialogButton : public QPushButton
+class KInputDialogListView : public QListView
{
public:
- KInputDialogButton(QWidget *parent = nullptr) : QPushButton(parent){}
- KInputDialogButton(const QString &text, QWidget *parent = nullptr):QPushButton(text,parent){}
-protected:
- QSize sizeHint() const;
+ KInputDialogListView(QWidget *parent = nullptr) : QListView(parent) {}
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
+ {
+ if (query == Qt::ImEnabled)
+ return false;
+ return QListView::inputMethodQuery(query);
+ }
};
class KInputDialogPrivate : public QObject
@@ -188,17 +177,16 @@ public:
void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex);
mutable QLabel *label;
- mutable KInputDialogButton *okButton;
- mutable KInputDialogButton *cancelButton;
+ mutable QPushButton *okButton;
+ mutable QPushButton *cancelButton;
mutable KInputDialogLineEdit *lineEdit;
mutable QPlainTextEdit *plainTextEdit;
- mutable KInputDialogSpinBox *intSpinBox;
+ mutable QSpinBox *intSpinBox;
mutable QDoubleSpinBox *doubleSpinBox;
mutable QComboBox *comboBox;
mutable KInputDialogListView *listView;
mutable QWidget *inputWidget;
mutable QVBoxLayout *mainLayout;
- mutable QHBoxLayout *hLayout;
KInputDialog::InputDialogOptions opts;
QString textValue;
QPointer<QObject> receiverToDisconnectOnClose;
@@ -210,67 +198,19 @@ private:
KInputDialogPrivate::KInputDialogPrivate(KInputDialog*parent)
: q_ptr(parent),label(nullptr), okButton(nullptr),cancelButton(nullptr), lineEdit(nullptr), plainTextEdit(nullptr), intSpinBox(nullptr), doubleSpinBox(nullptr),
- comboBox(nullptr), listView(nullptr), inputWidget(nullptr), mainLayout(nullptr),hLayout(nullptr)
+ comboBox(nullptr), listView(nullptr), inputWidget(nullptr), mainLayout(nullptr)
{
Q_Q(KInputDialog);
+ q->setMinimumHeight(198);
+ q->setMinimumWidth(336);
connect(q->m_gsetting,&QGSettings::changed,q,&KInputDialog::changeTheme);
- connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){
-
- ensureLayout();
- q->updateGeometry();
- });
}
void KInputDialogPrivate::ensureLayout()
{
Q_Q(KInputDialog);
-
- if(hLayout)
- {
- QLayoutItem *child;
- while((child = hLayout->takeAt(0))!= 0)
- {
- if(child->spacerItem())
- {
- hLayout->removeItem(child);
- continue;
- }
- hLayout->removeWidget(child->widget());
- }
- hLayout->setContentsMargins(0,0,0,0);
- hLayout->setSpacing(0);
- hLayout->addStretch();
- hLayout->addWidget(cancelButton);
- hLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Button_Spacing));
- hLayout->addWidget(okButton);
- }
if (mainLayout)
- {
- QLayoutItem *child;
- while((child = mainLayout->takeAt(0))!= 0)
- {
- if(child->spacerItem())
- {
- mainLayout->removeItem(child);
- continue;
- }
- mainLayout->removeWidget(child->widget());
- }
-
- mainLayout->setSpacing(0);
- mainLayout->setContentsMargins(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Right_Spacing)
- ,0
- ,Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Right_Spacing)
- ,Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Bottom_Spacing));
- mainLayout->addStretch();
- mainLayout->addWidget(label);
- mainLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Label_Spacing));
- mainLayout->addWidget(inputWidget);
- mainLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Widget_Spacing));
- mainLayout->addLayout(hLayout);
return;
- }
-
if (!inputWidget) {
ensureLineEdit();
inputWidget = lineEdit;
@@ -285,29 +225,28 @@ void KInputDialogPrivate::ensureLayout()
#endif
label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
label->setWordWrap(true);
- hLayout = new QHBoxLayout();
- okButton = new KInputDialogButton(tr("ok"),q);
- cancelButton = new KInputDialogButton(tr("cancel"),q);
+ QHBoxLayout *hLayout = new QHBoxLayout();
+ okButton = new QPushButton(tr("ok"),q);
+ okButton->setFixedSize(96,36);
+ cancelButton = new QPushButton(tr("cancel"),q);
+ cancelButton->setFixedSize(96,36);
hLayout->setContentsMargins(0,0,0,0);
hLayout->setSpacing(0);
hLayout->addStretch();
hLayout->addWidget(cancelButton);
- hLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Button_Spacing));
+ hLayout->addSpacing(10);
hLayout->addWidget(okButton);
QObject::connect(okButton, SIGNAL(clicked(bool)), q, SLOT(accept()));
QObject::connect(cancelButton, SIGNAL(clicked(bool)), q, SLOT(reject()));
mainLayout = new QVBoxLayout();
mainLayout->setSpacing(0);
- mainLayout->setContentsMargins(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Right_Spacing)
- ,0
- ,Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Right_Spacing)
- ,Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Bottom_Spacing));
- mainLayout->addStretch();
+ mainLayout->setContentsMargins(24,0,24,24);
mainLayout->addWidget(label);
- mainLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Label_Spacing));
+ mainLayout->addSpacing(8);
mainLayout->addWidget(inputWidget);
- mainLayout->addSpacing(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Widget_Spacing));
+ mainLayout->addSpacing(32);
+ //mainLayout->addStretch();
mainLayout->addLayout(hLayout);
q->mainWidget()->setLayout(mainLayout);
q->changeTheme();
@@ -321,6 +260,7 @@ void KInputDialogPrivate::ensureLineEdit()
Q_Q(KInputDialog);
if (!lineEdit) {
lineEdit = new KInputDialogLineEdit(q);
+ lineEdit->setFixedHeight(36);
lineEdit->hide();
QObject::connect(lineEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_textChanged(QString)));
@@ -940,8 +880,7 @@ QSize KInputDialog::sizeHint() const
{
Q_D(const KInputDialog);
d->ensureLayout();
- QSize size(Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Width),Parmscontroller::parm(Parmscontroller::Parm::PM_InputDialog_Height));
- return size;
+ return QDialog::sizeHint();
}
void KInputDialog::setVisible(bool visible)
@@ -1134,27 +1073,19 @@ double KInputDialog::doubleStep() const
return 1.0;
}
-QSize KInputDialogLineEdit::sizeHint() const
+QSize KInputDialogSpinBox::sizeHint() const
{
QSize size;
size.setWidth(288);
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
+ size.setHeight(36);
return size;
}
-QSize KInputDialogButton::sizeHint() const
-{
- QSize size;
- size.setWidth(96);
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
- return size;
-}
-
-QSize KInputDialogSpinBox::sizeHint() const
+QSize KInputDialogLineEdit::sizeHint() const
{
QSize size;
size.setWidth(288);
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
+ size.setHeight(36);
return size;
}
@@ -1162,7 +1093,7 @@ QSize KInputDialogDoubleSpinBox::sizeHint() const
{
QSize size;
size.setWidth(288);
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
+ size.setHeight(36);
return size;
}
diff --git a/kysdk-qtwidgets/src/klineframe.cpp b/kysdk-qtwidgets/src/klineframe.cpp
new file mode 100644
index 0000000..58eb7dc
--- /dev/null
+++ b/kysdk-qtwidgets/src/klineframe.cpp
@@ -0,0 +1,137 @@
+#include "klineframe.h"
+#include "themeController.h"
+#include <QApplication>
+#include <QDebug>
+
+namespace kdk {
+class KHLineFramePrivate:public QObject,public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KHLineFrame)
+
+public:
+ KHLineFramePrivate(KHLineFrame* parent);
+
+ void changeTheme();
+private:
+ KHLineFrame* q_ptr;
+};
+
+class KVLineFramePrivate:public QObject,public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KVLineFrame)
+
+public:
+ KVLineFramePrivate(KVLineFrame* parent);
+
+ void changeTheme();
+private:
+ KVLineFrame* q_ptr;
+};
+
+KHLineFrame::KHLineFrame(QWidget *parent)
+ :QFrame(parent)
+ ,d_ptr(new KHLineFramePrivate(this))
+{
+ setContentsMargins(0,10,0,10);
+ this->setFrameShape(QFrame::Shape::HLine);
+ setLineWidth(1);
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.2);
+ palette.setColor(QPalette::Window,color);
+ setPalette(palette);
+ setFixedHeight(1);
+}
+
+KHLineFrame::~KHLineFrame()
+{
+
+}
+
+KHLineFramePrivate::KHLineFramePrivate(KHLineFrame *parent)
+ :q_ptr(parent)
+{
+ Q_Q(KHLineFrame);
+ connect(m_gsetting,&QGSettings::changed,this,[=](){
+ changeTheme();
+ });
+}
+
+void KHLineFramePrivate::changeTheme()
+{
+ Q_Q(KHLineFrame);
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.2);
+ palette.setColor(QPalette::Window,color);
+ q->setPalette(palette);
+ }
+ else
+ {
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.3);
+ palette.setColor(QPalette::Window,color);
+ q->setPalette(palette);
+ }
+}
+
+KVLineFrame::KVLineFrame(QWidget *parent)
+ :QFrame(parent)
+ ,d_ptr(new KVLineFramePrivate(this))
+{
+ setContentsMargins(10,0,10,0);
+ setLineWidth(1);
+ this->setFrameShape(QFrame::Shape::VLine);
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.2);
+ palette.setColor(QPalette::Window,color);
+ setPalette(palette);
+ setFixedWidth(1);
+}
+
+KVLineFrame::~KVLineFrame()
+{
+
+}
+
+KVLineFramePrivate::KVLineFramePrivate(KVLineFrame *parent)
+ :q_ptr(parent)
+{
+ Q_Q(KVLineFrame);
+ connect(m_gsetting,&QGSettings::changed,this,[=](){
+ changeTheme();
+ });
+}
+
+void KVLineFramePrivate::changeTheme()
+{
+ Q_Q(KVLineFrame);
+ if(ThemeController::themeMode() == LightTheme)
+ {
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.2);
+ palette.setColor(QPalette::Window,color);
+ q->setPalette(palette);
+ }
+ else
+ {
+ QPalette palette =qApp->palette();
+ QColor color(ThemeController::mixColor(Qt::gray,Qt::white,0.1));
+ color.setAlphaF(0.3);
+ palette.setColor(QPalette::Window,color);
+ q->setPalette(palette);
+ }
+}
+
+}
+
+
+#include "klineframe.moc"
+#include "moc_klineframe.cpp"
diff --git a/kysdk-qtwidgets/src/klineframe.h b/kysdk-qtwidgets/src/klineframe.h
new file mode 100644
index 0000000..9851e81
--- /dev/null
+++ b/kysdk-qtwidgets/src/klineframe.h
@@ -0,0 +1,34 @@
+#ifndef KLINEFRAME_H
+#define KLINEFRAME_H
+
+#include <QFrame>
+#include "gui_g.h"
+namespace kdk {
+
+class KHLineFramePrivate;
+class KVLineFramePrivate;
+
+class GUI_EXPORT KHLineFrame : public QFrame
+{
+ Q_OBJECT
+public:
+ KHLineFrame(QWidget* parent = nullptr);
+ ~KHLineFrame();
+private:
+ Q_DECLARE_PRIVATE(KHLineFrame)
+ KHLineFramePrivate* const d_ptr;
+};
+
+class GUI_EXPORT KVLineFrame : public QFrame
+{
+ Q_OBJECT
+public:
+ KVLineFrame(QWidget* parent = nullptr);
+ ~KVLineFrame();
+private:
+ Q_DECLARE_PRIVATE(KVLineFrame)
+ KVLineFramePrivate* const d_ptr;
+};
+
+}
+#endif // KLINEFRAME_H
diff --git a/kysdk-qtwidgets/src/klistviewdelegate.cpp b/kysdk-qtwidgets/src/klistviewdelegate.cpp
index ea46632..222262a 100644
--- a/kysdk-qtwidgets/src/klistviewdelegate.cpp
+++ b/kysdk-qtwidgets/src/klistviewdelegate.cpp
@@ -1,7 +1,6 @@
#include "klistviewdelegate.h"
#include <QString>
#include <QPainter>
-#include <QPainterPath>
#include <QFont>
#include <QApplication>
#include <QFontMetrics>
diff --git a/kysdk-qtwidgets/src/kmenubutton.cpp b/kysdk-qtwidgets/src/kmenubutton.cpp
index 4a0536a..209f70c 100644
--- a/kysdk-qtwidgets/src/kmenubutton.cpp
+++ b/kysdk-qtwidgets/src/kmenubutton.cpp
@@ -37,7 +37,7 @@ KMenuButton::KMenuButton(QWidget *parent)
//setArrowType(Qt::NoArrow);
d->m_pMenu =new QMenu(this);
setMenu(d->m_pMenu);
- setToolTip(tr("more"));
+ setToolTip(tr("option"));
d->m_pSettingAction = new QAction(tr("Setting"),d->m_pMenu);
d->m_pThemeAction = new QAction(tr("Theme"),d->m_pMenu);
d->m_pAssistAction = new QAction(tr("Assist"),d->m_pMenu);
diff --git a/kysdk-qtwidgets/src/kmessagebox.cpp b/kysdk-qtwidgets/src/kmessagebox.cpp
new file mode 100644
index 0000000..d429fe6
--- /dev/null
+++ b/kysdk-qtwidgets/src/kmessagebox.cpp
@@ -0,0 +1,802 @@
+#include "kmessagebox.h"
+
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <qpa/qplatformdialoghelper.h>
+#include <QTextDocument>
+#include <QStyle>
+#include <QMessageBox>
+#include <QApplication>
+#include <QStyleOption>
+#include <QPainter>
+#include <private/qdesktopwidget_p.h>
+#include "private/qapplication_p.h"
+#include "private/qlabel_p.h"
+#include <private/qdialog_p.h>
+#include <QScreen>
+#include <QVBoxLayout>
+#include <QCheckBox>
+#include "themeController.h"
+
+namespace kdk {
+
+enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
+ Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
+ NewButtonMask = 0xFFFFFC00 };
+
+class KMessageBoxPrivate: public QObject, public QDialogPrivate, public ThemeController
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(KMessageBox)
+
+public:
+ KMessageBoxPrivate(KMessageBox*parent);
+
+ void init(const QString &title = QString(), const QString &text = QString());
+ static QPixmap standardIcon(KMessageBox::Icon icon, KMessageBox *mb);
+ void setupLayout();
+ void updateSize();
+ void setClickedButton(QAbstractButton *button);
+ int execReturnCode(QAbstractButton *button);
+ int dialogCodeForButton(QAbstractButton *button) const;
+ void addOldButtons(int button0, int button1, int button2);
+ QAbstractButton *findButton(int button0, int button1, int button2, int flags);
+
+public Q_SLOTS:
+ void _q_buttonClicked(QAbstractButton *);
+ void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
+
+protected:
+ void changeTheme();
+
+private:
+ KMessageBox *q_ptr;
+ QLabel *iconLabel;
+ QLabel *label;
+ QLabel *informativeLabel;
+ QDialogButtonBox *buttonBox;
+ QList<QAbstractButton *> customButtonList;
+ QSharedPointer<QMessageDialogOptions> options;
+ KMessageBox::Icon icon;
+ QAbstractButton *clickedButton;
+ QCheckBox *checkbox;
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+ QByteArray signalToDisconnectOnClose;
+ QPushButton *defaultButton;
+ bool autoAddOkButton;
+ bool compatMode;
+ QString m_iconName;
+
+ void initHelper(QPlatformDialogHelper *) override;
+ void helperPrepareShow(QPlatformDialogHelper *) override;
+ void helperDone(KDialog::DialogCode, QPlatformDialogHelper *) override;
+};
+
+KMessageBox::KMessageBox(QWidget *parent)
+ : KDialog(parent),
+ d_ptr(new KMessageBoxPrivate(this))
+{
+ Q_D(KMessageBox);
+ d->init();
+ d->changeTheme();
+ connect(d->m_gsetting,&QGSettings::changed,this,[=](){d->changeTheme();});
+}
+
+KMessageBox::~KMessageBox()
+{
+}
+
+void KMessageBox::setCustomIcon(const QIcon &icon)
+{
+ Q_D(KMessageBox);
+ d->m_iconName = icon.name();
+ this->setIconPixmap(icon.pixmap(24,24));
+}
+
+void KMessageBox::addButton(QAbstractButton *button, ButtonRole role)
+{
+ Q_D(KMessageBox);
+ if (!button)
+ return;
+ removeButton(button);
+ d->options->addButton(button->text(), static_cast<QPlatformDialogHelper::ButtonRole>(role),
+ button);
+ d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
+ d->customButtonList.append(button);
+ d->autoAddOkButton = false;
+}
+
+QPushButton *KMessageBox::addButton(const QString &text, ButtonRole role)
+{
+ Q_D(KMessageBox);
+ QPushButton *pushButton = new QPushButton(text);
+ addButton(pushButton, role);
+ return pushButton;
+}
+
+QPushButton *KMessageBox::addButton(StandardButton button)
+{
+ Q_D(KMessageBox);
+ QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button);
+ if (pushButton)
+ d->autoAddOkButton = false;
+ return pushButton;
+}
+
+void KMessageBox::removeButton(QAbstractButton *button)
+{
+ Q_D(KMessageBox);
+ d->customButtonList.removeAll(button);
+ if (d->defaultButton == button)
+ d->defaultButton = 0;
+ d->buttonBox->removeButton(button);
+}
+
+QAbstractButton *KMessageBox::button(KMessageBox::StandardButton which) const
+{
+ Q_D(const KMessageBox);
+ return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
+}
+
+QList<QAbstractButton *> KMessageBox::buttons() const
+{
+ Q_D(const KMessageBox);
+ return d->buttonBox->buttons();
+}
+
+KMessageBox::ButtonRole KMessageBox::buttonRole(QAbstractButton *button) const
+{
+ Q_D(const KMessageBox);
+ return KMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
+}
+
+QCheckBox *KMessageBox::checkBox() const
+{
+ Q_D(const KMessageBox);
+ return d->checkbox;
+}
+
+void KMessageBox::setCheckBox(QCheckBox *cb)
+{
+ Q_D(KMessageBox);
+
+ if (cb == d->checkbox)
+ return;
+
+ if (d->checkbox) {
+ d->checkbox->hide();
+ layout()->removeWidget(d->checkbox);
+ if (d->checkbox->parentWidget() == this) {
+ d->checkbox->setParent(0);
+ d->checkbox->deleteLater();
+ }
+ }
+ d->checkbox = cb;
+ if (d->checkbox) {
+ QSizePolicy sp = d->checkbox->sizePolicy();
+ sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
+ d->checkbox->setSizePolicy(sp);
+ }
+ d->setupLayout();
+}
+
+QString KMessageBox::text() const
+{
+ Q_D(const KMessageBox);
+ return d->label->text();
+}
+
+void KMessageBox::setText(const QString &text)
+{
+ Q_D(KMessageBox);
+ d->label->setText(text);
+ d->label->setWordWrap(d->label->textFormat() == Qt::RichText
+ || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));
+ d->updateSize();
+}
+
+QString KMessageBox::informativeText() const
+{
+ Q_D(const KMessageBox);
+ return d->informativeLabel ? d->informativeLabel->text() : QString();
+}
+
+void KMessageBox::setInformativeText(const QString &text)
+{
+ Q_D(KMessageBox);
+ if (text.isEmpty()) {
+ if (d->informativeLabel) {
+ d->informativeLabel->hide();
+ d->informativeLabel->deleteLater();
+ }
+ d->informativeLabel = 0;
+ } else {
+ if (!d->informativeLabel) {
+ QLabel *label = new QLabel;
+ label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));
+ label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ label->setOpenExternalLinks(true);
+ label->setWordWrap(true);
+ d->informativeLabel = label;
+ }
+ d->informativeLabel->setText(text);
+ }
+ d->setupLayout();
+}
+
+KMessageBox::Icon KMessageBox::icon() const
+{
+ Q_D(const KMessageBox);
+ return d->icon;
+}
+
+void KMessageBox::setIcon(Icon icon)
+{
+ Q_D(KMessageBox);
+ setIconPixmap(KMessageBoxPrivate::standardIcon((KMessageBox::Icon)icon,this));
+ d->icon = icon;
+}
+
+QPixmap KMessageBox::iconPixmap() const
+{
+ Q_D(const KMessageBox);
+ if (d->iconLabel && d->iconLabel->pixmap())
+ return *d->iconLabel->pixmap();
+ return QPixmap();
+}
+
+void KMessageBox::setIconPixmap(const QPixmap &pixmap)
+{
+ Q_D(KMessageBox);
+ d->iconLabel->setPixmap(pixmap);
+ d->icon = NoIcon;
+ d->setupLayout();
+}
+
+KMessageBox::StandardButtons KMessageBox::standardButtons() const
+{
+ Q_D(const KMessageBox);
+ return KMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
+}
+
+void KMessageBox::setStandardButtons(KMessageBox::StandardButtons buttons)
+{
+ Q_D(KMessageBox);
+ d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
+
+ QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
+ if (!buttonList.contains(d->defaultButton))
+ d->defaultButton = 0;
+ d->autoAddOkButton = false;
+}
+
+KMessageBox::StandardButton KMessageBox::standardButton(QAbstractButton *button) const
+{
+ Q_D(const KMessageBox);
+ return (KMessageBox::StandardButton)d->buttonBox->standardButton(button);
+}
+
+QPushButton *KMessageBox::defaultButton() const
+{
+ Q_D(const KMessageBox);
+ return d->defaultButton;
+}
+
+void KMessageBox::setDefaultButton(QPushButton *button)
+{
+ Q_D(KMessageBox);
+ if (!d->buttonBox->buttons().contains(button))
+ return;
+ d->defaultButton = button;
+ button->setDefault(true);
+ button->setFocus();
+}
+
+void KMessageBox::setDefaultButton(KMessageBox::StandardButton button)
+{
+ Q_D(KMessageBox);
+ setDefaultButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
+}
+
+QAbstractButton *KMessageBox::clickedButton() const
+{
+ Q_D(const KMessageBox);
+ return d->clickedButton;
+}
+
+QPixmap KMessageBox::standardIcon(KMessageBox::Icon icon)
+{
+ return KMessageBoxPrivate::standardIcon(icon, 0);
+}
+
+KMessageBox::StandardButton KMessageBox::information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, KMessageBox::StandardButton defaultButton)
+{
+ KMessageBox msgBox(parent);
+ msgBox.setIcon(KMessageBox::Icon::Information);
+ msgBox.setWindowTitle(title);
+ msgBox.setText(text);
+ msgBox.setStandardButtons(buttons);
+ msgBox.setDefaultButton(defaultButton);
+ msgBox.setParent(parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ if (msgBox.exec() == -1)
+ return KMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+KMessageBox::StandardButton KMessageBox::question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, KMessageBox::StandardButton defaultButton)
+{
+ KMessageBox msgBox(parent);
+ msgBox.setIcon(KMessageBox::Icon::Question);
+ msgBox.setWindowTitle(title);
+ msgBox.setText(text);
+ msgBox.setStandardButtons(buttons);
+ msgBox.setDefaultButton(defaultButton);
+ msgBox.setParent(parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ if (msgBox.exec() == -1)
+ return KMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+KMessageBox::StandardButton KMessageBox::warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, KMessageBox::StandardButton defaultButton)
+{
+ KMessageBox msgBox(parent);
+ msgBox.setIcon(KMessageBox::Icon::Warning);
+ msgBox.setWindowTitle(title);
+ msgBox.setText(text);
+ msgBox.setStandardButtons(buttons);
+ msgBox.setDefaultButton(defaultButton);
+ msgBox.setParent(parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ if (msgBox.exec() == -1)
+ return KMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+KMessageBox::StandardButton KMessageBox::critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, KMessageBox::StandardButton defaultButton)
+{
+ KMessageBox msgBox(parent);
+ msgBox.setIcon(KMessageBox::Icon::Critical);
+ msgBox.setWindowTitle(title);
+ msgBox.setText(text);
+ msgBox.setStandardButtons(buttons);
+ msgBox.setDefaultButton(defaultButton);
+ msgBox.setParent(parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ if (msgBox.exec() == -1)
+ return KMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+KMessageBox::StandardButton KMessageBox::success(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, KMessageBox::StandardButton defaultButton)
+{
+ KMessageBox msgBox(parent);
+ msgBox.setCustomIcon(QIcon::fromTheme("ukui-dialog-success"));
+ msgBox.setWindowTitle(title);
+ msgBox.setText(text);
+ msgBox.setStandardButtons(buttons);
+ msgBox.setDefaultButton(defaultButton);
+ msgBox.setParent(parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ if (msgBox.exec() == -1)
+ return KMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+bool KMessageBox::event(QEvent *e)
+{
+ Q_D(KMessageBox);
+ bool result =KDialog::event(e);
+ switch (e->type()) {
+ case QEvent::LayoutRequest:
+ d->updateSize();
+ break;
+ case QEvent::FontChange:
+ d->updateSize();
+ break;
+ default:
+ break;
+ }
+ return result;
+}
+
+KMessageBoxPrivate::KMessageBoxPrivate(KMessageBox *parent):q_ptr(parent), options(QMessageDialogOptions::create()), informativeLabel(0),
+ checkbox(0), compatMode(false), clickedButton(0), defaultButton(0)
+
+{
+ Q_Q(KMessageBox);
+}
+
+void KMessageBoxPrivate::init(const QString &title, const QString &text)
+{
+ Q_Q(KMessageBox);
+
+ label = new QLabel;
+ label->setObjectName(QLatin1String("qt_kmsgbox_label"));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
+ label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+ label->setOpenExternalLinks(true);
+ iconLabel = new QLabel(q);
+ iconLabel->setObjectName(QLatin1String("qt_kmsgbox_icon_label"));
+ iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ buttonBox = new QDialogButtonBox;
+ buttonBox->setObjectName(QLatin1String("qt_kmsgbox_buttonbox"));
+ buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q));
+ QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
+ this, SLOT(_q_buttonClicked(QAbstractButton*)));
+ setupLayout();
+ if (!title.isEmpty() || !text.isEmpty()) {
+ q->setWindowTitle(title);
+ q->setText(text);
+ }
+ q->setModal(true);
+ icon = KMessageBox::NoIcon;
+}
+
+QPixmap KMessageBoxPrivate::standardIcon(KMessageBox::Icon icon, KMessageBox *mb)
+{
+ QStyle *style = mb ? mb->style() : QApplication::style();
+ int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, mb);
+ QIcon tmpIcon;
+ switch (icon) {
+ case KMessageBox::Information:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, mb);
+ break;
+ case KMessageBox::Warning:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb);
+ break;
+ case KMessageBox::Critical:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb);
+ break;
+ case KMessageBox::Question:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb);
+ default:
+ break;
+ }
+ if (!tmpIcon.isNull()) {
+ QWindow *window = nullptr;
+ if (mb) {
+ window = mb->windowHandle();
+ if (!window) {
+ if (const QWidget *nativeParent = mb->nativeParentWidget())
+ window = nativeParent->windowHandle();
+ }
+ }
+ return tmpIcon.pixmap(window, QSize(iconSize, iconSize));
+ }
+
+ return QPixmap();
+}
+
+void KMessageBoxPrivate::setupLayout()
+{
+ Q_Q(KMessageBox);
+ if(q->mainWidget()->layout())
+ delete q->mainWidget()->layout();
+
+ QGridLayout *grid = new QGridLayout;
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
+ buttonLayout->setContentsMargins(0,0,0,0);
+ grid->setHorizontalSpacing(8);
+ if(informativeLabel)
+ grid->setVerticalSpacing(8);
+ else
+ grid->setVerticalSpacing(0);
+ grid->setContentsMargins(0,0,0,0);
+
+ bool hasIcon = iconLabel->pixmap() && !iconLabel->pixmap()->isNull();
+ if (hasIcon)
+ grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
+ iconLabel->setVisible(hasIcon);
+ grid->addWidget(label, 0, hasIcon ? 2 : 1, 1, 1);
+
+ if (informativeLabel) {
+ grid->addWidget(informativeLabel, 1, hasIcon ? 2 : 1, 1, 1);
+ }
+ grid->setSizeConstraint(QLayout::SetNoConstraint);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins(24,0,24,24);
+
+ buttonLayout->setSizeConstraint(QLayout::SetNoConstraint);
+ if(checkbox)
+ buttonLayout->addWidget(checkbox, 0, Qt::AlignLeft | Qt::AlignVCenter);
+ buttonLayout->addWidget(buttonBox,0, Qt::AlignRight | Qt::AlignVCenter);
+
+ layout->setSpacing(0);
+ layout->addLayout(grid);
+ layout->addSpacing(32);
+ layout->addLayout(buttonLayout);
+
+ q->mainWidget()->setLayout(layout);
+ updateSize();
+}
+
+void KMessageBoxPrivate::updateSize()
+{
+ Q_Q(KMessageBox);
+
+ if(!q->isVisible())
+ return;
+
+ while (buttonBox->layout()->count() < buttonBox->buttons().count() + 1) {
+ QEvent event(QEvent::StyleChange);
+ QGuiApplication::sendEvent(buttonBox, &event);
+ }
+
+ QSize minSize(424, 156);
+ QSize size;
+ QSize screenSize = QGuiApplication::screenAt(QCursor::pos())->availableGeometry().size();
+ QSize maxSize(screenSize.width() * 0.8, screenSize.height() * 0.8);
+
+ label->setWordWrap(false);
+ if (informativeLabel) {
+ informativeLabel->setWordWrap(false);
+ }
+
+ q->mainWidget()->layout()->activate();
+
+ if (q->sizeHint().width() > qMax(buttonBox->sizeHint().width() + 24 + 24, 452)) {
+ label->setWordWrap(true);
+ if (informativeLabel) {
+ informativeLabel->setWordWrap(true);
+ }
+ }
+
+ q->mainWidget()->layout()->activate();
+
+ q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ size.setWidth(qMax(qMin(maxSize.width(), q->sizeHint().width()), minSize.width()));
+ size.setHeight(qMax(qMin(maxSize.height(), q->layout()->hasHeightForWidth() ? q->layout()->totalHeightForWidth(size.width())
+ : q->layout()->totalMinimumSize().height()), minSize.height()));
+
+ q->setFixedSize(size);
+
+ QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
+
+}
+
+void KMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
+{
+ Q_Q(KMessageBox);
+ setClickedButton(button);
+
+ if (receiverToDisconnectOnClose) {
+ QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose,
+ memberToDisconnectOnClose);
+ receiverToDisconnectOnClose = nullptr;
+ }
+ signalToDisconnectOnClose.clear();
+ memberToDisconnectOnClose.clear();
+
+}
+
+void KMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
+{
+ Q_Q(KMessageBox);
+ if (button > QPlatformDialogHelper::LastButton) {
+ clickedButton = static_cast<QAbstractButton *>(options->customButton(button)->button);
+ Q_ASSERT(clickedButton);
+ clickedButton->click();
+ q->done(role);
+ } else {
+ q->done(button);
+ }
+}
+
+static int oldButton(int button)
+{
+ switch (button & KMessageBox::ButtonMask) {
+ case KMessageBox::Ok:
+ return Old_Ok;
+ case KMessageBox::Cancel:
+ return Old_Cancel;
+ case KMessageBox::Yes:
+ return Old_Yes;
+ case KMessageBox::No:
+ return Old_No;
+ case KMessageBox::Abort:
+ return Old_Abort;
+ case KMessageBox::Retry:
+ return Old_Retry;
+ case KMessageBox::Ignore:
+ return Old_Ignore;
+ case KMessageBox::YesToAll:
+ return Old_YesAll;
+ case KMessageBox::NoToAll:
+ return Old_NoAll;
+ default:
+ return 0;
+ }
+}
+
+void KMessageBoxPrivate::setClickedButton(QAbstractButton *button)
+{
+ Q_Q(KMessageBox);
+
+ clickedButton = button;
+ emit q->buttonClicked(clickedButton);
+
+ int resultCode = execReturnCode(button);
+ q->hide();
+ q->close();
+ int dialogCode = dialogCodeForButton(button);
+ if (dialogCode == QDialog::Accepted)
+ emit q->accepted();
+ else if (dialogCode == QDialog::Rejected)
+ emit q->rejected();
+ emit q->finished(resultCode);
+}
+
+int KMessageBoxPrivate::execReturnCode(QAbstractButton *button)
+{
+ int ret = buttonBox->standardButton(button);
+ if (ret == KMessageBox::NoButton) {
+ ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1
+ } else if (compatMode) {
+ ret = oldButton(ret);
+ }
+ return ret;
+}
+
+int KMessageBoxPrivate::dialogCodeForButton(QAbstractButton *button) const
+{
+ Q_Q(const KMessageBox);
+
+ switch (q->buttonRole(button)) {
+ case KMessageBox::AcceptRole:
+ case KMessageBox::YesRole:
+ return KDialog::Accepted;
+ case KMessageBox::RejectRole:
+ case KMessageBox::NoRole:
+ return KDialog::Rejected;
+ default:
+ return -1;
+ }
+}
+
+static KMessageBox::StandardButton newButton(int button)
+{
+ // this is needed for source compatibility with Qt 4.0 and 4.1
+ if (button == KMessageBox::NoButton || (button & NewButtonMask))
+ return KMessageBox::StandardButton(button & KMessageBox::ButtonMask);
+
+#if QT_VERSION < 0x050000
+ // this is needed for binary compatibility with Qt 4.0 and 4.1
+ switch (button & Old_ButtonMask) {
+ case Old_Ok:
+ return KMessageBox::Ok;
+ case Old_Cancel:
+ return KMessageBox::Cancel;
+ case Old_Yes:
+ return KMessageBox::Yes;
+ case Old_No:
+ return KMessageBox::No;
+ case Old_Abort:
+ return KMessageBox::Abort;
+ case Old_Retry:
+ return KMessageBox::Retry;
+ case Old_Ignore:
+ return KMessageBox::Ignore;
+ case Old_YesAll:
+ return KMessageBox::YesToAll;
+ case Old_NoAll:
+ return KMessageBox::NoToAll;
+ default:
+ return KMessageBox::NoButton;
+ }
+#else
+ return KMessageBox::NoButton;
+#endif
+}
+
+static bool detectedCompat(int button0, int button1, int button2)
+{
+ if (button0 != 0 && !(button0 & NewButtonMask))
+ return true;
+ if (button1 != 0 && !(button1 & NewButtonMask))
+ return true;
+ if (button2 != 0 && !(button2 & NewButtonMask))
+ return true;
+ return false;
+}
+
+void KMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
+{
+ Q_Q(KMessageBox);
+ q->addButton(newButton(button0));
+ q->addButton(newButton(button1));
+ q->addButton(newButton(button2));
+ q->setDefaultButton(
+ static_cast<QPushButton *>(findButton(button0, button1, button2, KMessageBox::Default)));
+ compatMode = detectedCompat(button0, button1, button2);
+}
+
+QAbstractButton *KMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
+{
+ Q_Q(KMessageBox);
+ int button = 0;
+
+ if (button0 & flags) {
+ button = button0;
+ } else if (button1 & flags) {
+ button = button1;
+ } else if (button2 & flags) {
+ button = button2;
+ }
+ return q->button(newButton(button));
+}
+
+void KMessageBoxPrivate::changeTheme()
+{
+ Q_Q(KMessageBox);
+ q->setIconPixmap(QIcon::fromTheme(m_iconName).pixmap(24,24));
+}
+
+void KMessageBoxPrivate::initHelper(QPlatformDialogHelper *h)
+{
+ Q_Q(KMessageBox);
+ QObject::connect(static_cast<QPlatformMessageDialogHelper *>(h), SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)),
+ this, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));
+ static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options);
+}
+
+static QMessageDialogOptions::Icon helperIcon(KMessageBox::Icon i)
+{
+ switch (i) {
+ case KMessageBox::NoIcon:
+ return QMessageDialogOptions::NoIcon;
+ case KMessageBox::Information:
+ return QMessageDialogOptions::Information;
+ case KMessageBox::Warning:
+ return QMessageDialogOptions::Warning;
+ case KMessageBox::Critical:
+ return QMessageDialogOptions::Critical;
+ case KMessageBox::Question:
+ return QMessageDialogOptions::Question;
+ }
+ return QMessageDialogOptions::NoIcon;
+}
+
+static QPlatformDialogHelper::StandardButtons helperStandardButtons(KMessageBox * q)
+{
+ QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));
+ return buttons;
+}
+
+void KMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *)
+{
+ Q_Q(KMessageBox);
+ options->setWindowTitle(q->windowTitle());
+ options->setText(q->text());
+ options->setInformativeText(q->informativeText());
+ options->setIcon(helperIcon(q->icon()));
+ options->setStandardButtons(helperStandardButtons(q));
+}
+
+void KMessageBoxPrivate::helperDone(KDialog::DialogCode code, QPlatformDialogHelper *)
+{
+ Q_Q(KMessageBox);
+ QAbstractButton *button = q->button(KMessageBox::StandardButton(code));
+ if (button)
+ clickedButton = button;
+}
+
+}
+
+#include "moc_kmessagebox.cpp"
+#include "kmessagebox.moc"
diff --git a/kysdk-qtwidgets/src/kmessagebox.h b/kysdk-qtwidgets/src/kmessagebox.h
new file mode 100644
index 0000000..abc90dd
--- /dev/null
+++ b/kysdk-qtwidgets/src/kmessagebox.h
@@ -0,0 +1,276 @@
+#ifndef KMESSAGEBOX_H
+#define KMESSAGEBOX_H
+
+#include <QDialog>
+#include <QAbstractButton>
+#include "gui_g.h"
+#include "kdialog.h"
+#include <QCheckBox>
+
+namespace kdk {
+
+class KMessageBoxPrivate;
+
+class GUI_EXPORT KMessageBox : public KDialog
+{
+ Q_OBJECT
+public:
+ enum Icon {
+ // keep this in sync with QMessageDialogOptions::Icon
+ NoIcon = 0,
+ Information = 1,
+ Warning = 2,
+ Critical = 3,
+ Question = 4,
+ };
+ Q_ENUM(Icon)
+
+ enum ButtonRole {
+ InvalidRole = -1,
+ AcceptRole,
+ RejectRole,
+ DestructiveRole,
+ ActionRole,
+ HelpRole,
+ YesRole,
+ NoRole,
+ ResetRole,
+ ApplyRole,
+ NRoles
+ };
+
+ enum StandardButton {
+ // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
+ NoButton = 0x00000000,
+ Ok = 0x00000400,
+ Save = 0x00000800,
+ SaveAll = 0x00001000,
+ Open = 0x00002000,
+ Yes = 0x00004000,
+ YesToAll = 0x00008000,
+ No = 0x00010000,
+ NoToAll = 0x00020000,
+ Abort = 0x00040000,
+ Retry = 0x00080000,
+ Ignore = 0x00100000,
+ Close = 0x00200000,
+ Cancel = 0x00400000,
+ Discard = 0x00800000,
+ Help = 0x01000000,
+ Apply = 0x02000000,
+ Reset = 0x04000000,
+ RestoreDefaults = 0x08000000,
+
+ FirstButton = Ok, // internal
+ LastButton = RestoreDefaults, // internal
+
+ YesAll = YesToAll, // obsolete
+ NoAll = NoToAll, // obsolete
+
+ Default = 0x00000100, // obsolete
+ Escape = 0x00000200, // obsolete
+ FlagMask = 0x00000300, // obsolete
+ ButtonMask = ~FlagMask // obsolete
+ };
+ typedef StandardButton Button;
+
+ Q_DECLARE_FLAGS(StandardButtons, StandardButton)
+ Q_FLAG(StandardButtons)
+
+ KMessageBox(QWidget *parent = nullptr);
+ ~KMessageBox();
+
+ /**
+ * @brief 自定义KMessageBox的提示图标
+ * @param icon
+ */
+ void setCustomIcon(const QIcon&icon);
+
+ /**
+ * @brief 添加一个自定义按钮
+ * @param button
+ * @param role
+ */
+ void addButton(QAbstractButton *button, ButtonRole role);
+
+ /**
+ * @brief 添加设置好文本的按钮
+ * @param text
+ * @param role
+ * @return
+ */
+ QPushButton* addButton(const QString &text, ButtonRole role);
+
+ /**
+ * @brief 添加一个标准按钮并且返回这个按钮
+ * @param button
+ * @return
+ */
+ QPushButton* addButton(StandardButton button);
+
+ /**
+ * @brief 移除一个按钮
+ * @param button
+ */
+ void removeButton(QAbstractButton *button);
+
+ /**
+ * @brief 返回与标准按钮对应的指针如果此消息框中不存在标准按钮则返回0。
+ * @param which
+ * @return
+ */
+ QAbstractButton* button (StandardButton which) const;
+
+ /**
+ * @brief 返回已添加到消息框中的所有按钮的列表
+ * @return
+ */
+ QList<QAbstractButton*> buttons() const;
+
+ /**
+ * @brief 返回指定按钮的按钮角色如果按钮为0或尚未添加到消息框中此函数将返回InvalidRole
+ * @param button
+ * @return
+ */
+ KMessageBox::ButtonRole buttonRole(QAbstractButton *button) const;
+
+ /**
+ * @brief 返回KMessageBox中显示的复选框
+ * @return
+ */
+ QCheckBox* checkBox() const;
+
+ /**
+ * @brief 设置KMessageBox显示的复选框未设置则为0
+ * @param cb
+ */
+ void setCheckBox(QCheckBox *cb);
+
+ /**
+ * @brief 获取KMessageBox的文本
+ * @return
+ */
+ QString text() const;
+
+ /**
+ * @brief 设置KMessageBox的文本
+ * @param text
+ */
+ void setText (const QString& text);
+
+ /**
+ * @brief 获取KMessageBox信息性文本的描述
+ * @return
+ */
+ QString informativeText() const;
+
+ /**
+ * @brief 设置KMessageBox信息性文本的描述
+ * @param text
+ */
+ void setInformativeText(const QString &text);
+
+ /**
+ * @brief 获取KMessageBox的图标
+ * @return
+ */
+ Icon icon() const;
+
+ /**
+ * @brief 设置KMessageBox的图标
+ * @param icon
+ */
+ void setIcon(Icon icon);
+
+ /**
+ * @brief 返回当前KMessageBox的icon
+ * @return
+ */
+ QPixmap iconPixmap() const;
+
+ /**
+ * @brief 设置当前KMessageBox的icon
+ * @param pixmap
+ */
+ void setIconPixmap(const QPixmap &pixmap);
+
+ /**
+ * @brief KMessageBox中标准按钮的集合
+ * @return
+ */
+ KMessageBox::StandardButtons standardButtons() const;
+
+ /**
+ * @brief 设置多个标准按钮
+ * @param buttons
+ */
+ void setStandardButtons(KMessageBox::StandardButtons buttons);
+
+ /**
+ * @brief 返回与给定按钮对应的标准按钮枚举值如果给定按钮不是标准按钮则返回NoButton
+ * @param button
+ * @return
+ */
+ KMessageBox::StandardButton standardButton(QAbstractButton *button) const;
+
+ /**
+ * @brief 返回KMessageBox的默认按钮
+ * @return
+ */
+ QPushButton* defaultButton() const;
+
+ /**
+ * @brief 设置KMessageBox的默认按钮
+ * @param button
+ */
+ void setDefaultButton(QPushButton *button);
+
+ /**
+ * @brief 设置KMessageBox的默认按钮
+ * @param button
+ */
+ void setDefaultButton(KMessageBox::StandardButton button);
+
+ /**
+ * @brief 返回被点击的按钮
+ * @return
+ */
+ QAbstractButton* clickedButton() const;
+
+ /**
+ * @brief 返回用于标准图标的pixmap。
+ * @param icon
+ * @return
+ */
+ static QPixmap standardIcon(Icon icon);
+
+ static StandardButton information(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton question(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = StandardButtons(Yes | No),
+ StandardButton defaultButton = NoButton);
+ static StandardButton warning(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton critical(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton success(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+
+
+Q_SIGNALS:
+ void buttonClicked(QAbstractButton *button);
+
+protected:
+ bool event(QEvent *e) override;
+
+private:
+ Q_DECLARE_PRIVATE(KMessageBox)
+ KMessageBoxPrivate* const d_ptr;
+};
+
+}
+#endif // KMESSAGEBOX_H
diff --git a/kysdk-qtwidgets/src/knavigationbar.cpp b/kysdk-qtwidgets/src/knavigationbar.cpp
index cc9b2b2..f3763a3 100644
--- a/kysdk-qtwidgets/src/knavigationbar.cpp
+++ b/kysdk-qtwidgets/src/knavigationbar.cpp
@@ -93,6 +93,13 @@ KNavigationBar::KNavigationBar(QWidget* parent)
d->changeTheme();
connect(d->m_pDelegate->m_gsetting,&QGSettings::changed,this,[=](){d->changeTheme();});
//this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){
+// if(Parmscontroller::isTabletMode()) //解决导航栏滑动条切换主题为白条
+// d->m_pView->setStyleSheet("QListView item {height : 48}");
+// else
+// d->m_pView->setStyleSheet("QListView item {height : 36}");
+ updateGeometry();
+ });
}
void KNavigationBar::addItem(QStandardItem *item)
@@ -172,9 +179,11 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
QLinearGradient m_linearGradient;
QRectF rect;
rect.setX(option.rect.x());
- rect.setY(option.rect.y());
+ rect.setY(option.rect.y()+1);
rect.setWidth(option.rect.width());
- rect.setHeight(option.rect.height() - Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatInterval));
+// rect.setHeight(option.rect.height()-2);
+ rect.setHeight(option.rect.height()-Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatInterval));
+
//QPainterPath画圆角矩形
const qreal radius = 6; //圆角半径6px
QPainterPath path;
@@ -190,6 +199,9 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
int flag = index.model()->data(index,Qt::UserRole).toInt();
painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::HighQualityAntialiasing);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
QColor color;
m_linearGradient = QLinearGradient(rect.width()/2,rect.y(),rect.width()/2,rect.height()+rect.y());
if(!(option.state & QStyle::State_Enabled))
@@ -268,6 +280,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
QRect iconRect=QRect(rect.x()+16,rect.y()+(rect.height()-16)/2,16,16); //图片大小16*16 左边距16
auto *model =dynamic_cast<QStandardItemModel*>(const_cast<QAbstractItemModel*>(index.model()));
auto icon = model->item(index.row())->icon();
+
if(ThemeController::themeMode() == DarkTheme)
icon = ThemeController::drawSymbolicColoredPixmap(icon.pixmap(16,16));
if((m_listView->currentIndex() == index)|| (option.state & QStyle::State_Selected))
@@ -366,10 +379,9 @@ QSize Delegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &
size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatHeight)+12);
break;
default:
- size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatHeight) + Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatInterval));
+ size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatHeight)+Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBatInterval));
break;
}
-// size.setWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_NavigationBarWidth));
size.setWidth(option.rect.width());
return size;
}
diff --git a/kysdk-qtwidgets/src/kpasswordedit.cpp b/kysdk-qtwidgets/src/kpasswordedit.cpp
index 2dee21b..2c7cc4f 100644
--- a/kysdk-qtwidgets/src/kpasswordedit.cpp
+++ b/kysdk-qtwidgets/src/kpasswordedit.cpp
@@ -38,8 +38,8 @@ private:
QTimer *m_pTimer;
bool m_isLoading;
bool m_hasFocus;
+ bool m_useCustomPalette;
int m_flashState;
- QPalette m_palette;
};
KPasswordEdit::KPasswordEdit(QWidget*parent)
@@ -76,9 +76,9 @@ KPasswordEdit::KPasswordEdit(QWidget*parent)
});
connect(d->m_gsetting,&QGSettings::changed,d,&KPasswordEditPrivate::changeTheme);
connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){
- updateGeometry();
+ updateGeometry();
});
- d->changeTheme();
+ d->repaintIcon();
installEventFilter(this);
setContextMenuPolicy(Qt::NoContextMenu);
setFocusPolicy(Qt::ClickFocus);
@@ -90,29 +90,29 @@ void KPasswordEdit::setState(LoginState state)
Q_D(KPasswordEdit);
d->m_state = state;
-
+ auto palette = this->palette();
switch (d->m_state)
{
case Ordinary:
if(ThemeController::widgetTheme() == FashionTheme)
- d->m_palette.setBrush(QPalette::Highlight,QColor("#3769DD"));
+ palette.setBrush(QPalette::Highlight,QColor("#3769DD"));
else
- d->m_palette.setBrush(QPalette::Highlight,QGuiApplication::palette().color(QPalette::Highlight));
- setPalette(d->m_palette);
+ palette.setBrush(QPalette::Highlight,QGuiApplication::palette().color(QPalette::Highlight));
+ setPalette(palette);
break;
case LoginSuccess:
if(ThemeController::widgetTheme() == FashionTheme)
- d->m_palette.setBrush(QPalette::Highlight,QColor("#3ECF20"));
+ palette.setBrush(QPalette::Highlight,QColor("#3ECF20"));
else
- d->m_palette.setBrush(QPalette::Highlight,QColor(15,206,117));
- setPalette(d->m_palette);
+ palette.setBrush(QPalette::Highlight,QColor(15,206,117));
+ setPalette(palette);
break;
case LoginFailed:
if(ThemeController::widgetTheme() == FashionTheme)
- d->m_palette.setBrush(QPalette::Highlight,QColor("#D2293F"));
+ palette.setBrush(QPalette::Highlight,QColor("#D2293F"));
else
- d->m_palette.setBrush(QPalette::Highlight,QColor(243,34,45));
- setPalette(d->m_palette);
+ palette.setBrush(QPalette::Highlight,QColor(243,34,45));
+ setPalette(palette);
break;
default:
break;
@@ -215,6 +215,12 @@ void KPasswordEdit::setEchoMode(QLineEdit::EchoMode mode)
d->repaintIcon();
}
+void KPasswordEdit::setUseCustomPalette(bool flag)
+{
+ Q_D(KPasswordEdit);
+ d->m_useCustomPalette =flag;
+}
+
void KPasswordEdit::resizeEvent(QResizeEvent *event)
{
Q_D(KPasswordEdit);
@@ -260,10 +266,9 @@ QSize KPasswordEdit::sizeHint() const
}
KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent)
- :q_ptr(parent)
+ :q_ptr(parent),m_useCustomPalette(false)
{
Q_Q(KPasswordEdit);
- m_palette = q->palette();
m_flashState = 0;
m_state = Ordinary;
m_hasFocus = q->hasFocus();
@@ -282,6 +287,8 @@ KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent)
btnPalette.setBrush(QPalette::Disabled, QPalette::Highlight, Qt::transparent);
m_pEchoModeBtn = new KToolButton(q);
+ m_pEchoModeBtn->setAutoFillBackground(true);
+ m_pEchoModeBtn->setPalette(btnPalette);
m_pEchoModeBtn->setType(KToolButtonType::Background);
m_pEchoModeBtn->setIconSize(QSize(16,16));
m_pEchoModeBtn->setFixedSize(QSize(16,16));
@@ -289,6 +296,8 @@ KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent)
m_pEchoModeBtn->setCursor(Qt::ArrowCursor);
m_pEchoModeBtn->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic"));
m_pLoadingBtn = new KToolButton(q);
+ m_pLoadingBtn->setAutoFillBackground(true);
+ m_pLoadingBtn->setPalette(btnPalette);
m_pLoadingBtn->setType(KToolButtonType::Background);
m_pLoadingBtn->setIconSize(QSize(16,16));
m_pLoadingBtn->setFixedSize(QSize(16,16));
@@ -297,6 +306,8 @@ KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent)
m_pLoadingBtn->setIcon(QIcon::fromTheme("ukui-loading-0"));
m_pLoadingBtn->hide();
m_pClearBtn = new KToolButton(q);
+ m_pClearBtn->setAutoFillBackground(true);
+ m_pClearBtn->setPalette(btnPalette);
m_pClearBtn->setType(KToolButtonType::Background);
m_pClearBtn->setIconSize(QSize(16,16));
m_pClearBtn->setFixedSize(QSize(16,16));
@@ -313,14 +324,6 @@ KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent)
m_pWidgetLayout->addWidget(m_pEchoModeBtn);
m_pWidgetLayout->addSpacing(5);
m_pWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
-
-
- m_pEchoModeBtn->setAutoFillBackground(true);
- m_pLoadingBtn->setAutoFillBackground(true);
- m_pClearBtn->setAutoFillBackground(true);
- m_pEchoModeBtn->setPalette(btnPalette);
- m_pLoadingBtn->setPalette(btnPalette);
- m_pClearBtn->setPalette(btnPalette);
setParent(parent);
}
@@ -375,39 +378,41 @@ void KPasswordEditPrivate::changeTheme()
{
Q_Q(KPasswordEdit);
initThemeStyle();
+ if(m_useCustomPalette)
+ return;
repaintIcon();
+ QPalette palette = q->palette();
if(q->hasFocus())
{
- QPalette p = q->palette();
- QColor color = p.color(QPalette::Base);
- m_palette.setBrush(QPalette::Button,color);
+ QColor color = q->palette().color(QPalette::Base);
+ palette.setBrush(QPalette::Button,color);
if(ThemeController::themeMode() == LightTheme)
- m_palette.setBrush(QPalette::Text, QColor(38,38,38));
+ palette.setBrush(QPalette::Text, QColor(38,38,38));
else
- m_palette.setBrush(QPalette::Active, QPalette::Text, QColor(255,255,255));
- q->setPalette(m_palette);
+ palette.setBrush(QPalette::Active, QPalette::Text, QColor(255,255,255));
+ q->setPalette(palette);
}
else
{
if(ThemeController::themeMode() == LightTheme)
{
- m_palette.setBrush(QPalette::Active, QPalette::Button, QColor(230,230,230));
- m_palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(230,230,230));
- m_palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(233,233,233));
- m_palette.setBrush(QPalette::Active, QPalette::Text, QColor(140,140,140));
- m_palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(140,140,140));
- m_palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(179,179,179));
- q->setPalette(m_palette);
+ palette.setBrush(QPalette::Active, QPalette::Button, QColor(230,230,230));
+ palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(230,230,230));
+ palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(233,233,233));
+ palette.setBrush(QPalette::Active, QPalette::Text, QColor(140,140,140));
+ palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(140,140,140));
+ palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(179,179,179));
+ q->setPalette(palette);
}
else
{
- m_palette.setBrush(QPalette::Active, QPalette::Button, QColor(55,55,59));
- m_palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(55,55,59));
- m_palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(46,46,48));
- m_palette.setBrush(QPalette::Active, QPalette::Text, QColor(115,115,115));
- m_palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(115,115,115));
- m_palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(71,71,74));
- q->setPalette(m_palette);
+ palette.setBrush(QPalette::Active, QPalette::Button, QColor(55,55,59));
+ palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(55,55,59));
+ palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(46,46,48));
+ palette.setBrush(QPalette::Active, QPalette::Text, QColor(115,115,115));
+ palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(115,115,115));
+ palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(71,71,74));
+ q->setPalette(palette);
}
}
}
diff --git a/kysdk-qtwidgets/src/kpasswordedit.h b/kysdk-qtwidgets/src/kpasswordedit.h
index 98979c3..a12461e 100644
--- a/kysdk-qtwidgets/src/kpasswordedit.h
+++ b/kysdk-qtwidgets/src/kpasswordedit.h
@@ -115,6 +115,12 @@ public:
*/
void setEchoMode(EchoMode mode);
+ /**
+ * @brief 设置是否走默认palette
+ * @param flag
+ */
+ void setUseCustomPalette(bool flag);
+
protected:
void resizeEvent(QResizeEvent*event);
diff --git a/kysdk-qtwidgets/src/kpressbutton.cpp b/kysdk-qtwidgets/src/kpressbutton.cpp
index 34dc6a1..a1dcb71 100755
--- a/kysdk-qtwidgets/src/kpressbutton.cpp
+++ b/kysdk-qtwidgets/src/kpressbutton.cpp
@@ -157,6 +157,9 @@ void KPressButton::paintEvent(QPaintEvent *event)
initStyleOption(&opt);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
+ p.setRenderHint(QPainter::HighQualityAntialiasing);
+ p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
if(d->m_pTranslucent)
{
diff --git a/kysdk-qtwidgets/src/kprogressbar.cpp b/kysdk-qtwidgets/src/kprogressbar.cpp
index 1686e64..1cb3eee 100644
--- a/kysdk-qtwidgets/src/kprogressbar.cpp
+++ b/kysdk-qtwidgets/src/kprogressbar.cpp
@@ -32,6 +32,7 @@ private:
QRect m_textRect;
QRect m_contentRect;
QRect m_rect;
+ int m_bodyWidth;
};
KProgressBar::KProgressBar(QWidget *parent)
@@ -299,12 +300,21 @@ void KProgressBar::setOrientation(Qt::Orientation orientation)
QProgressBar::setOrientation(orientation);
}
+void KProgressBar::setBodyWidth(int width)
+{
+ Q_D(KProgressBar);
+ d->m_bodyWidth = width;
+ update();
+}
+
+
KProgressBarPrivate::KProgressBarPrivate(KProgressBar *parent)
:q_ptr(parent)
{
m_contentMargin = 2;
m_state = NormalProgress;
setParent(parent);
+ m_bodyWidth = 0;
}
void KProgressBarPrivate::calculateTextRect()
@@ -342,6 +352,8 @@ void KProgressBarPrivate::calculateRect() //背景矩形
m_rect = q->rect();
if(q->orientation() == Qt::Horizontal)
{
+ if(m_bodyWidth != 0)
+ m_rect.setHeight(m_bodyWidth);
if(!q->isTextVisible())
return;
else
@@ -357,6 +369,8 @@ void KProgressBarPrivate::calculateRect() //背景矩形
}
else
{
+ if(m_bodyWidth != 0)
+ m_rect.setWidth(m_bodyWidth);
if(!q->isTextVisible())
return;
else
diff --git a/kysdk-qtwidgets/src/kprogressbar.h b/kysdk-qtwidgets/src/kprogressbar.h
index e7196c1..1a841aa 100644
--- a/kysdk-qtwidgets/src/kprogressbar.h
+++ b/kysdk-qtwidgets/src/kprogressbar.h
@@ -55,6 +55,12 @@ public:
*/
void setOrientation(Qt::Orientation);
+ /**
+ * @brief 设置进度条宽度
+ * @param width
+ */
+ void setBodyWidth(int width);
+
protected:
void paintEvent(QPaintEvent *event) override;
QSize sizeHint() const;
diff --git a/kysdk-qtwidgets/src/kpushbutton.cpp b/kysdk-qtwidgets/src/kpushbutton.cpp
index 959c62a..52d514c 100644
--- a/kysdk-qtwidgets/src/kpushbutton.cpp
+++ b/kysdk-qtwidgets/src/kpushbutton.cpp
@@ -63,6 +63,7 @@ KPushButton::~KPushButton()
void KPushButton::setBorderRadius(int radius)
{
Q_D(KPushButton);
+ d->m_hasOneParam = true;
d->m_radius = radius;
update();
}
@@ -284,12 +285,14 @@ void KPushButton::paintEvent(QPaintEvent *event)
backgroundColor = highlight;
}
- /*绘制背景色和rect*/
- p.save();
- p.setBrush(backgroundColor);
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
+
+ /*绘制背景色和rect*/
+ p.save();
+ p.setBrush(backgroundColor);
p.setPen(Qt::NoPen);
switch(d->m_buttonType)
diff --git a/kysdk-qtwidgets/src/ksearchlineedit.cpp b/kysdk-qtwidgets/src/ksearchlineedit.cpp
index 45390b4..a8d4e41 100644
--- a/kysdk-qtwidgets/src/ksearchlineedit.cpp
+++ b/kysdk-qtwidgets/src/ksearchlineedit.cpp
@@ -20,8 +20,8 @@
#include <QStyle>
#include <QProxyStyle>
#include <QPainterPath>
-#include "parmscontroller.h"
#include "kshadowhelper.h"
+#include "parmscontroller.h"
namespace kdk
{
@@ -52,7 +52,6 @@ protected:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
-
static const int iconMargin = 6;
static const int buttonMargin = 6;
static const int icontextSpacing = 5;
@@ -274,7 +273,7 @@ bool KSearchLineEdit::eventFilter(QObject *watched, QEvent *event)
}
else if(event->type() == QEvent::HoverEnter)
{
- if(width()-icontextSpacing-d->m_pIconLabel->width() < fm.width(d->m_placeHolderText))
+ if(width()-icontextSpacing-d->m_pIconLabel->width()<fm.width(d->m_placeHolderText))
{
if(d->m_hasFocus)
setToolTip(d->m_placeHolderText);
@@ -440,6 +439,7 @@ void KSearchLineEditPrivate::changeTheme()
m_pCompleter->popup()->setPalette(palette);
m_pCompleter->popup()->setBackgroundRole(QPalette::Base);
m_pCompleter->popup()->setAutoFillBackground(true);
+
}
else
{
@@ -450,6 +450,9 @@ void KSearchLineEditPrivate::changeTheme()
m_pCompleter->popup()->setPalette(palette);
m_pCompleter->popup()->setBackgroundRole(QPalette::Base);
m_pCompleter->popup()->setAutoFillBackground(true);
+
+ QPalette pal=qApp->palette();
+ m_pTextLabel->setPalette(pal);
}
}
@@ -461,7 +464,6 @@ void KSearchLineEditPrivate::init()
m_pIconLabel = new QLabel;
m_pIconLabel->setScaledContents(true);
QPixmap pixmap = QIcon::fromTheme("search-symbolic").pixmap(QSize(16,16));
-
m_pIconLabel->setPixmap(pixmap);
m_pIconLabel->setFixedSize(QSize(16,16));
m_pWidget =new QWidget(q);
@@ -482,7 +484,6 @@ void KSearchLineEditPrivate::init()
q->setTextMargins(iconMargin + m_pIconLabel->width(),0,0,0);
}
-
ListViewDelegate::ListViewDelegate(QObject *parent):QStyledItemDelegate(parent)
{
@@ -584,9 +585,6 @@ QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMode
return size;
}
-#include "ksearchlineedit.moc"
-#include "moc_ksearchlineedit.cpp"
-
void MyStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
@@ -628,4 +626,7 @@ QRect MyStyle::subElementRect(QStyle::SubElement element, const QStyleOption *op
}
}
+
}
+#include "ksearchlineedit.moc"
+#include "moc_ksearchlineedit.cpp"
diff --git a/kysdk-qtwidgets/src/kslider.cpp b/kysdk-qtwidgets/src/kslider.cpp
index 8a5efbf..cd9c8bb 100644
--- a/kysdk-qtwidgets/src/kslider.cpp
+++ b/kysdk-qtwidgets/src/kslider.cpp
@@ -16,11 +16,10 @@ using namespace kdk;
namespace kdk {
static const int node_radius = 5;
-static const int handle_radius = 8;
+static const int handle_radius = 10;
static const int spaceing = handle_radius+2;
static const int line_width = 4;
static const int line_border_radius = 2;
-static int select_node_radius;
class KSliderPrivate :public QObject,public ThemeController
{
@@ -57,6 +56,7 @@ private:
QString m_pToolTipText;
QLinearGradient m_linearGradient;
bool m_isTranslucent;
+ int m_handleRadius;
};
@@ -67,8 +67,14 @@ KSliderPrivate::KSliderPrivate(KSlider *parent)
m_isHovered(false),
m_valuePosition(0),
m_currentpos(QPoint(0,0)),
- m_nodeVisible(true)
+ m_nodeVisible(true),
+ m_handleRadius(0)
{
+ Q_Q(KSlider);
+ QStyleOptionSlider sliderOption;
+ //获取滑动块大小
+ QRect handle = q->style()->proxy()->subControlRect(QStyle::CC_Slider, &sliderOption, QStyle::SC_SliderHandle, q);
+ m_handleRadius =handle.width()/2;
}
KSliderPrivate::~KSliderPrivate()
@@ -117,7 +123,6 @@ void KSliderPrivate::drawSlider(QPainter*painter)
//获取滑动块大小
// QRect handle = q->style()->proxy()->subControlRect(QStyle::CC_Slider, &sliderOption, QStyle::SC_SliderHandle, q);
int handle_radius = Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)/2;
-
QPoint point;
if(q->orientation() == Qt::Horizontal)
{
@@ -347,15 +352,16 @@ void KSliderPrivate::updateColor()
{
QColor whiteColor("#FFFFFF");
QColor darkColor("#000000");
+ m_coverColor = highlightColor.darker(120);
if(m_isPressed)
{
- m_coverColor = highlightColor.darker(120).darker(120);
+// m_coverColor = highlightColor.darker(120).darker(120); //取消lineRect三态
m_startColor = highlightColor.darker(120);
return;
}
else if(m_isHovered)
{
- m_coverColor = highlightColor.darker(120);
+// m_coverColor = highlightColor.darker(120);//取消lineRect三态
if(ThemeController::widgetTheme() == FashionTheme)
{
m_startColor = ThemeController::mixColor(highlightColor,whiteColor,0.2);
@@ -370,22 +376,23 @@ void KSliderPrivate::updateColor()
}
else
{
- m_coverColor = highlightColor.darker(120);
+// m_coverColor = highlightColor.darker(120);//取消lineRect三态
m_startColor = highlightColor;
}
}
else
{
QColor whiteColor("#FFFFFF");
+ m_coverColor = highlightColor.lighter(120);
if(m_isPressed)
{
- m_coverColor = highlightColor.lighter(120).lighter(120);
+// m_coverColor = highlightColor.lighter(120).lighter(120);//取消lineRect三态
m_startColor = highlightColor.lighter(120);
return;
}
else if(m_isHovered)
{
- m_coverColor = highlightColor.lighter(120);
+// m_coverColor = highlightColor.lighter(120);//取消lineRect三态
if(ThemeController::widgetTheme() == FashionTheme)
{
m_startColor = ThemeController::mixColor(highlightColor,whiteColor,0.2);
@@ -400,7 +407,7 @@ void KSliderPrivate::updateColor()
}
else
{
- m_coverColor = highlightColor.lighter(120);
+// m_coverColor = highlightColor.lighter(120);//取消lineRect三态
m_startColor = highlightColor;
}
}
@@ -427,7 +434,7 @@ QRect KSliderPrivate::baseLineRect()
}
else
{
- rect.setBottom(q->height() - spaceing -select_node_radius);
+ rect.setBottom(q->height() - spaceing -m_handleRadius);
rect.setTop(spaceing);
rect.setLeft(q->width()/2 - line_width/2);
rect.setRight(q->width()/2 + line_width/2);
@@ -448,7 +455,7 @@ QRect KSliderPrivate::coverLineRect()
}
else
{
- rect.setBottom(q->height() - spaceing -select_node_radius);
+ rect.setBottom(q->height() - spaceing -m_handleRadius);
rect.setTop(m_valuePosition);
rect.setLeft(q->width()/2 - line_width/2);
rect.setRight(q->width()/2 + line_width/2);
@@ -459,7 +466,6 @@ QRect KSliderPrivate::coverLineRect()
KSlider::KSlider(QWidget *parent)
:KSlider(Qt::Horizontal,parent)
{
-
}
KSlider::KSlider(Qt::Orientation orientation, QWidget *parent)
@@ -473,6 +479,7 @@ KSlider::KSlider(Qt::Orientation orientation, QWidget *parent)
update();
});
installEventFilter(this);
+ setFocusPolicy(Qt::ClickFocus);
}
void KSlider::setTickInterval(int interval)
@@ -580,7 +587,6 @@ void KSlider::paintEvent(QPaintEvent *event)
d->locateNode();
d->updateValuePosition();
QPainter p(this);
-
d->drawBasePath(&p);
if(d->m_sliderType != SingleSelectSlider)
d->drawCoverLine(&p);
@@ -680,6 +686,7 @@ QSize KSlider::sizeHint() const
size.setWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius));
return size;
}
+
}
//#include "kslider.moc"
#include "moc_kslider.cpp"
diff --git a/kysdk-qtwidgets/src/kslider.h b/kysdk-qtwidgets/src/kslider.h
index d0c62c2..b310465 100644
--- a/kysdk-qtwidgets/src/kslider.h
+++ b/kysdk-qtwidgets/src/kslider.h
@@ -106,7 +106,7 @@ protected:
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
- QSize sizeHint() const override;
+ QSize sizeHint() const override;
private:
KSliderPrivate *const d_ptr;
diff --git a/kysdk-qtwidgets/src/ktabbar.cpp b/kysdk-qtwidgets/src/ktabbar.cpp
index 2a4aa8b..837810e 100644
--- a/kysdk-qtwidgets/src/ktabbar.cpp
+++ b/kysdk-qtwidgets/src/ktabbar.cpp
@@ -2,7 +2,6 @@
#include "themeController.h"
#include <QStyleOptionTab>
#include <QPainter>
-#include <QPainterPath>
#include <QStylePainter>
#include <QPainterPath>
#include <QFontMetrics>
@@ -10,6 +9,7 @@
#include <QEvent>
#include <QApplication>
#include "parmscontroller.h"
+
namespace kdk
{
class KTabBarPrivate:public QObject,public ThemeController
@@ -43,10 +43,11 @@ KTabBar::KTabBar(KTabBarStyle barStyle,QWidget* parent):
d->m_kTabBarStyle = barStyle;
d->m_useCustomColor = false;
+ //this->setObjectName("KTabbar");
d->changeTheme();
connect(d->m_gsetting,&QGSettings::changed, d,&KTabBarPrivate::changeTheme);
connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](bool flag){
- updateGeometry();
+ updateGeometry();
});
}
@@ -96,7 +97,6 @@ QSize KTabBar::sizeHint() const
{
auto size = QTabBar::sizeHint();
size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_TabBarHeight));
-// qDebug()<<"size hint:"<<size;
return size;
}
@@ -122,6 +122,10 @@ void KTabBar::paintEvent(QPaintEvent *event)
{
Q_D(KTabBar);
QPainter p(this);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.setRenderHint(QPainter::HighQualityAntialiasing);
+ p.setRenderHint(QPainter::TextAntialiasing);
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
QColor fontColor;
QColor mix;
@@ -130,6 +134,8 @@ void KTabBar::paintEvent(QPaintEvent *event)
{
QStyleOptionTab option;
initStyleOption(&option, i);
+ QRect rect = option.rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin);
+ rect.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight));
switch (d->m_kTabBarStyle)
{
case SegmentDark:
@@ -146,20 +152,16 @@ void KTabBar::paintEvent(QPaintEvent *event)
{
bkgrdColor = ThemeController::mixColor(bkgrdColor,mix,0.05);
}
- QRect rect = option.rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin);
-
if(option.position == QStyleOptionTab::Middle)
{
p.save();
p.setBrush(bkgrdColor);
p.setPen(Qt::NoPen);
- p.setRenderHint(QPainter::Antialiasing);
//利用quadto绘制圆角矩形会出现一个像素的偏差修正一下QRect底部高度
p.drawRect(rect.adjusted(0,0,0,-1));
p.restore();
p.setBrush(Qt::NoBrush);
p.setPen(fontColor);
- p.setRenderHint(QPainter::Antialiasing);
QPoint point;
uint tf = Qt::AlignVCenter;
if (!option.icon.isNull()) {
@@ -223,7 +225,6 @@ void KTabBar::paintEvent(QPaintEvent *event)
p.save();
p.setBrush(bkgrdColor);
p.setPen(Qt::NoPen);
- p.setRenderHint(QPainter::Antialiasing);
QPainterPath path;
auto tempRect = rect.adjusted(0,0,1,0);
path.moveTo(tempRect.topLeft() + QPointF(0, d->m_borderRadius));
@@ -237,7 +238,6 @@ void KTabBar::paintEvent(QPaintEvent *event)
p.restore();
p.setBrush(Qt::NoBrush);
p.setPen(fontColor);
- p.setRenderHint(QPainter::Antialiasing);
QPoint point;
uint tf = Qt::AlignVCenter;
if (!option.icon.isNull()) {
@@ -292,7 +292,6 @@ void KTabBar::paintEvent(QPaintEvent *event)
p.save();
p.setBrush(bkgrdColor);
p.setPen(Qt::NoPen);
- p.setRenderHint(QPainter::Antialiasing);
QPainterPath path;
path.moveTo(rect.topLeft());
path.lineTo(rect.bottomLeft());
@@ -305,7 +304,6 @@ void KTabBar::paintEvent(QPaintEvent *event)
p.restore();
p.setBrush(Qt::NoBrush);
p.setPen(fontColor);
- p.setRenderHint(QPainter::Antialiasing);
QPoint point;
uint tf = Qt::AlignVCenter;
if (!option.icon.isNull()) {
@@ -384,14 +382,12 @@ void KTabBar::paintEvent(QPaintEvent *event)
p.save();
p.setBrush(bkgrdColor);
p.setPen(Qt::NoPen);
- p.setRenderHint(QPainter::Antialiasing);
- p.drawRoundedRect(option.rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin),
+ p.drawRoundedRect(/*option.rect.adjusted*/rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin),
d->m_borderRadius,d->m_borderRadius);
p.restore();
p.setBrush(Qt::NoBrush);
p.setPen(fontColor);
- p.setRenderHint(QPainter::Antialiasing);
- QRect rect = option.rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin);
+ /*QRect*/ rect = /*option.*/rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin);
QPoint point;
uint tf = Qt::AlignVCenter;
if (!option.icon.isNull()) {
@@ -470,14 +466,12 @@ void KTabBar::paintEvent(QPaintEvent *event)
pen.setColor(bkgrdColor);
pen.setWidth(2);
p.setPen(pen);
- p.setRenderHint(QPainter::Antialiasing);
- QRect rect = option.rect.adjusted(d->m_horizontalMargin,0,0,-5);
+ /*QRect*/ rect = /*option.*/rect.adjusted(d->m_horizontalMargin,0,0,-5);
p.drawLine(rect.bottomLeft(),rect.bottomRight());
p.restore();
p.setBrush(Qt::NoBrush);
p.setPen(fontColor);
- p.setRenderHint(QPainter::Antialiasing);
QPoint point;
uint tf = Qt::AlignVCenter;
if (!option.icon.isNull()) {
diff --git a/kysdk-qtwidgets/src/ktabbar.h b/kysdk-qtwidgets/src/ktabbar.h
index 7f7d71f..6eb4f01 100644
--- a/kysdk-qtwidgets/src/ktabbar.h
+++ b/kysdk-qtwidgets/src/ktabbar.h
@@ -68,7 +68,7 @@ public:
protected:
QSize sizeHint() const;
QSize minimumTabSizeHint(int index) const;
- QSize tabSizeHint(int index) const;
+ QSize tabSizeHint(int index) const;
void paintEvent(QPaintEvent *event);
private:
diff --git a/kysdk-qtwidgets/src/ktag.cpp b/kysdk-qtwidgets/src/ktag.cpp
index 1a7efd5..a659c0a 100644
--- a/kysdk-qtwidgets/src/ktag.cpp
+++ b/kysdk-qtwidgets/src/ktag.cpp
@@ -36,7 +36,7 @@ KTag::KTag(QWidget *parent)
setClosable(false);
d->changeTheme();
connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](bool flag){
- updateGeometry();
+ updateGeometry();
});
}
diff --git a/kysdk-qtwidgets/src/ktoolbutton.cpp b/kysdk-qtwidgets/src/ktoolbutton.cpp
index 8f1cf46..0e99df7 100644
--- a/kysdk-qtwidgets/src/ktoolbutton.cpp
+++ b/kysdk-qtwidgets/src/ktoolbutton.cpp
@@ -202,7 +202,8 @@ bool KToolButton::eventFilter(QObject *watched, QEvent *event)
QSize KToolButton::sizeHint() const
{
Q_D(const KToolButton);
- QSize size(Parmscontroller::parm(Parmscontroller::Parm::PM_ToolButtonHeight),Parmscontroller::parm(Parmscontroller::Parm::PM_ToolButtonHeight));
+ QSize size(Parmscontroller::parm(Parmscontroller::Parm::PM_ToolButtonHeight),
+ Parmscontroller::parm(Parmscontroller::Parm::PM_ToolButtonHeight));
if(d->m_hasArrow)
size.setWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_ToolButtonHeight)+24);
return size;
diff --git a/kysdk-qtwidgets/src/kwidget.cpp b/kysdk-qtwidgets/src/kwidget.cpp
index 57d8161..0e084da 100644
--- a/kysdk-qtwidgets/src/kwidget.cpp
+++ b/kysdk-qtwidgets/src/kwidget.cpp
@@ -6,7 +6,10 @@
#include <QPainter>
#include <QApplication>
#include "parmscontroller.h"
+
+#include <QGuiApplication>
#include "ukuistylehelper/ukui-decoration-manager.h"
+
namespace kdk
{
class KWidgetPrivate:public QObject
@@ -32,6 +35,8 @@ private:
LayoutType m_layoutType;
void adjustBackground();
+ void adjustFlagsTitleStatus(Qt::WindowFlags type);
+ void adjustFlagTitleStatus(Qt::WindowFlags type);
};
KWidget::KWidget(QWidget *parent)
@@ -93,19 +98,19 @@ KWidget::KWidget(QWidget *parent)
d->m_pIconBar->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width));
if(Parmscontroller::isTabletMode())
{
- d->m_pWindowButtonBar->maximumButton()->hide();
+ if(d->m_pWindowButtonBar->followMode())
+ d->m_pWindowButtonBar->maximumButton()->hide();
}
else
{
- d->m_pWindowButtonBar->maximumButton()->show();
+ if(d->m_pWindowButtonBar->followMode())
+ d->m_pWindowButtonBar->maximumButton()->show();
}
updateGeometry();
});
-
changeTheme();
connect(m_gsetting,&QGSettings::changed,this,[=](){changeTheme();});
-
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("xcb"),Qt::CaseInsensitive))
{
@@ -115,6 +120,7 @@ KWidget::KWidget(QWidget *parent)
hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
}
+
installEventFilter(this);
resize(800,600);
}
@@ -144,6 +150,7 @@ void KWidget::setWidgetName(const QString &widgetName)
{
Q_D(KWidget);
d->m_pIconBar->setWidgetName(widgetName);
+ QWidget::setWindowTitle(widgetName);
}
QWidget *KWidget::sideBar()
@@ -179,8 +186,9 @@ void KWidget::setLayoutType(LayoutType type)
void KWidget::setWindowFlags(Qt::WindowFlags type)
{
+ Q_D(KWidget);
QWidget::setWindowFlags(type);
-
+ d->adjustFlagsTitleStatus(type);
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("xcb"),Qt::CaseInsensitive))
{
@@ -195,8 +203,9 @@ void KWidget::setWindowFlags(Qt::WindowFlags type)
void KWidget::setWindowFlag(Qt::WindowType flag, bool on)
{
+ Q_D(KWidget);
QWidget::setWindowFlag(flag,on);
-
+ d->adjustFlagTitleStatus(flag);
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("xcb"),Qt::CaseInsensitive))
{
@@ -226,7 +235,6 @@ bool KWidget::eventFilter(QObject *target, QEvent *event)
UKUIDecorationManager::getInstance()->removeHeaderBar(this->windowHandle());
}
}
-
return QWidget::eventFilter(target, event);
}
@@ -242,46 +250,6 @@ void KWidget::changeTheme()
Q_D(KWidget);
initThemeStyle();
d->adjustBackground();
- auto baseColor = this->palette().brush(QPalette::Base).color();
- auto sideColor = this->palette().brush(QPalette::Window).color();
- sideColor.setAlphaF(d->tranSparency);
- QPalette basePalette = this->palette();
- basePalette.setColor(QPalette::Window,baseColor);
- d->m_pWindowButtonBar->setAutoFillBackground(true);
- d->m_pWindowButtonBar->setPalette(basePalette);
- d->m_pBaseWidget->setAutoFillBackground(true);
- d->m_pBaseWidget->setPalette(basePalette);
-
- QPalette sidePalette = this->palette();
- switch (d->m_layoutType)
- {
- case VerticalType:
- sidePalette.setColor(QPalette::Window,sideColor);
- d->m_pIconBar->setAutoFillBackground(true);
- d->m_pIconBar->setPalette(basePalette);
- d->m_pSideWidget->hide();
- break;
- case HorizontalType:
- sidePalette.setColor(QPalette::Window,sideColor);
- d->m_pSideWidget->setAutoFillBackground(true);
- d->m_pSideWidget->setPalette(sidePalette);
- d->m_pIconBar->setAutoFillBackground(true);
- d->m_pIconBar->setPalette(sidePalette);
- d->m_pIconBar->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width));
- d->m_pSideWidget->show();
- break;
- case MixedType:
- sidePalette.setColor(QPalette::Window,sideColor);
- d->m_pSideWidget->setAutoFillBackground(true);
- d->m_pSideWidget->setPalette(sidePalette);
- d->m_pSideWidget->show();
- d->m_pIconBar->setAutoFillBackground(true);
- d->m_pIconBar->setPalette(basePalette);
- break;
- default:
- break;
- }
-
}
KWidgetPrivate::KWidgetPrivate(KWidget *parent)
@@ -361,6 +329,141 @@ void KWidgetPrivate::adjustBackground()
break;
}
}
+
+void KWidgetPrivate::adjustFlagsTitleStatus(Qt::WindowFlags type)
+{
+ Q_Q(KWidget);
+ m_pWindowButtonBar->menuButton()->hide();
+ switch (type)
+ {
+ case Qt::Drawer:
+ m_pWindowButtonBar->minimumButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Tool:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::ToolTip:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::SplashScreen:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Dialog:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Sheet:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Popup:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Desktop:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+// m_pWindowButtonBar->menuButton()->hide();
+ q->deleteLater();
+ break;
+ case Qt::ForeignWindow:
+// m_pWindowButtonBar->menuButton()->hide();
+// break;
+ case Qt::CoverWindow:
+// m_pWindowButtonBar->menuButton()->hide();
+// break;
+ case Qt::Window:
+// m_pWindowButtonBar->menuButton()->hide();
+// break;
+ case Qt::Widget:
+// m_pWindowButtonBar->menuButton()->hide();
+// break;
+ case Qt::SubWindow:
+// m_pWindowButtonBar->menuButton()->hide();
+ break;
+ default:
+ break;
+ }
+}
+
+void KWidgetPrivate::adjustFlagTitleStatus(Qt::WindowFlags type)
+{
+ Q_Q(KWidget);
+ switch (type)
+ {
+ case Qt::Drawer:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Tool:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::ToolTip:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::SplashScreen:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Dialog:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Sheet:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Popup:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Desktop:
+ m_pWindowButtonBar->minimumButton()->hide();
+ m_pWindowButtonBar->maximumButton()->hide();
+ m_pWindowButtonBar->closeButton()->hide();
+ m_pWindowButtonBar->menuButton()->hide();
+ q->deleteLater();
+ break;
+ case Qt::ForeignWindow:
+ q->setWindowFlags(Qt::WindowMinMaxButtonsHint); //为窗口添加最大化和最小化按钮
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::CoverWindow:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Window:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::Widget:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ case Qt::SubWindow:
+ m_pWindowButtonBar->menuButton()->hide();
+ break;
+ default:
+ break;
+ }
+}
}
#include "kwidget.moc"
diff --git a/kysdk-qtwidgets/src/kwindowbuttonbar.cpp b/kysdk-qtwidgets/src/kwindowbuttonbar.cpp
index 9e465f7..7a81ef9 100644
--- a/kysdk-qtwidgets/src/kwindowbuttonbar.cpp
+++ b/kysdk-qtwidgets/src/kwindowbuttonbar.cpp
@@ -28,6 +28,7 @@ private:
MaximumButtonState m_maximumButtonState;
QWidget*m_pParentWidget;
QColor m_pixColor;
+ bool m_followMode;
};
KWindowButtonBar::KWindowButtonBar(QWidget *parent)
@@ -92,6 +93,18 @@ void KWindowButtonBar::setMaximumButtonState(MaximumButtonState state)
d->changeTheme();
}
+void KWindowButtonBar::setFollowMode(bool flag)
+{
+ Q_D(KWindowButtonBar);
+ d->m_followMode=flag;
+}
+
+bool KWindowButtonBar::followMode()
+{
+ Q_D(KWindowButtonBar);
+ return d->m_followMode;
+}
+
void KWindowButtonBar::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_D(KWindowButtonBar);
@@ -163,7 +176,7 @@ QSize KWindowButtonBar::sizeHint() const
}
KWindowButtonBarPrivate::KWindowButtonBarPrivate(KWindowButtonBar *parent)
- :q_ptr(parent)
+ :q_ptr(parent),m_followMode(true)
{
Q_Q(KWindowButtonBar);
QHBoxLayout *hLayout = new QHBoxLayout();
@@ -179,11 +192,9 @@ KWindowButtonBarPrivate::KWindowButtonBarPrivate(KWindowButtonBar *parent)
m_pMinimumBtn->setToolTip(tr("minimize"));
m_pMinimumBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize));
-
m_pmaximumBtn = new QPushButton(q);
m_pmaximumBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize));
-
m_pCloseBtn = new QPushButton(q);
m_pCloseBtn->setObjectName("CloseButton");
m_pCloseBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize));
diff --git a/kysdk-qtwidgets/src/kwindowbuttonbar.h b/kysdk-qtwidgets/src/kwindowbuttonbar.h
index dde21cb..e54826b 100644
--- a/kysdk-qtwidgets/src/kwindowbuttonbar.h
+++ b/kysdk-qtwidgets/src/kwindowbuttonbar.h
@@ -69,6 +69,17 @@ public:
*/
void setMaximumButtonState(MaximumButtonState state);
+ /**
+ * @brief 设置是否遵循模式 since 1.2.0.4-table4
+ * @param flag
+ */
+ void setFollowMode(bool flag);
+
+ /**
+ * @brief 返回是否遵循模式 since 1.2.0.4-table4
+ * @return
+ */
+ bool followMode();
Q_SIGNALS:
diff --git a/kysdk-qtwidgets/src/parmscontroller.cpp b/kysdk-qtwidgets/src/parmscontroller.cpp
index 2e0969d..775deca 100644
--- a/kysdk-qtwidgets/src/parmscontroller.cpp
+++ b/kysdk-qtwidgets/src/parmscontroller.cpp
@@ -12,6 +12,7 @@ namespace kdk
static Parmscontroller *g_parmscontroller;
static QDBusInterface *g_statusManagerDBus;
+static bool g_isTablet;
const static QString DBUS_STATUS_MANAGER = "com.kylin.statusmanager.interface";
const static int TABLET_CONTROL_HEIGHT = 48;
@@ -70,8 +71,13 @@ Parmscontroller::Parmscontroller(QObject *parent) : QObject(parent)
if (g_statusManagerDBus->isValid()) {
//平板模式切换
connect(g_statusManagerDBus, SIGNAL(mode_change_signal(bool)), this, SIGNAL(modeChanged(bool)));
+ connect(this,&Parmscontroller::modeChanged,this,[=](bool flag)
+ {
+ g_isTablet = flag;
+ });
}
}
+ g_isTablet = isTabletMode();
}
Parmscontroller::~Parmscontroller()
@@ -82,7 +88,7 @@ Parmscontroller::~Parmscontroller()
bool Parmscontroller::isTabletMode()
{
- if (g_statusManagerDBus)
+ if (g_statusManagerDBus && g_statusManagerDBus->isValid())
{
QDBusReply<bool> message = g_statusManagerDBus->call("get_current_tabletmode");
if (message.isValid())
@@ -96,7 +102,7 @@ bool Parmscontroller::isTabletMode()
int Parmscontroller::parm(Parmscontroller::Parm p)
{
- if(Parmscontroller::isTabletMode())
+ if(g_isTablet)
{
switch (p) {
case PM_TabBarHeight:
@@ -129,7 +135,7 @@ int Parmscontroller::parm(Parmscontroller::Parm p)
case PM_InputDialog_Height:
return TABLET_INPUTDIALOG_HEIGHT;
case PM_InputDialog_Width:
- return TABLET_INPUTDIALOG_WIDTH;
+ return TABLET_INPUTDIALOG_WIDTH;
case PM_InputDialog_Label_Spacing:
return TABLET_INPUTDIALOG_LABEL_SPACING;
case PM_InputDialog_Widget_Spacing:
diff --git a/kysdk-qtwidgets/test/test.pro b/kysdk-qtwidgets/test/test.pro
index 57e43a9..ae9d015 100644
--- a/kysdk-qtwidgets/test/test.pro
+++ b/kysdk-qtwidgets/test/test.pro
@@ -20,11 +20,16 @@ SUBDIRS += \
testtabbar \
testTag \
testtoolbutton \
- testWidget \
+ testWidget \
testListWidget \
testListView \
testkpressbutton\
testKPushButton\
testKTranslucentFloor\
testTranslucent\
- testKBubbleWidget
+ testKBubbleWidget\
+ testkcolorcombobox\
+ testKButtonBox\
+ testkbackground\
+ testcolorbutton\
+ testKMessageBox
diff --git a/kysdk-qtwidgets/test/testDialog/main.cpp b/kysdk-qtwidgets/test/testDialog/main.cpp
index 77af6b9..136b8eb 100644
--- a/kysdk-qtwidgets/test/testDialog/main.cpp
+++ b/kysdk-qtwidgets/test/testDialog/main.cpp
@@ -2,10 +2,11 @@
#include <QApplication>
#include <QTranslator>
-#include <QApplication>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
QTranslator trans;
QString locale = QLocale::system().name();
@@ -16,6 +17,13 @@ int main(int argc, char *argv[])
a.installTranslator(&trans);
}
}
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testDialog/testDialog.pro b/kysdk-qtwidgets/test/testDialog/testDialog.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testDialog/testDialog.pro
+++ b/kysdk-qtwidgets/test/testDialog/testDialog.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testKBubbleWidget/main.cpp b/kysdk-qtwidgets/test/testKBubbleWidget/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKBubbleWidget/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testKBubbleWidget/testKBubbleWidget.pro b/kysdk-qtwidgets/test/testKBubbleWidget/testKBubbleWidget.pro
new file mode 100644
index 0000000..d37043d
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKBubbleWidget/testKBubbleWidget.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp b/kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp
new file mode 100644
index 0000000..836a575
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp
@@ -0,0 +1,65 @@
+#include "widget.h"
+#include <QApplication>
+#include <QLayout>
+#include <QFrame>
+#include <QGraphicsDropShadowEffect>
+#include "kbubblewidget.h"
+#include "kwidget.h"
+#include <QHBoxLayout>
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QPushButton* btn1 = new QPushButton(this);
+ btn1->setText("常规");
+
+ QPushButton* btn2 = new QPushButton(this);
+ btn2->setText("毛玻璃");
+
+ btn2->move(100,0);
+
+ KBubbleWidget* w =new KBubbleWidget();
+ w->setTailPosition(TailDirection::TopDirection);
+ w->setTailSize(QSize(16,8));
+ w->setBorderRadius(12);
+ w->setOpacity(0.4);
+ w->setEnableBlur(false);
+ w->setFixedSize(320,320);
+ QHBoxLayout* layout = new QHBoxLayout(w);
+ QPushButton* button = new QPushButton(w);
+ button->setText("关闭");
+ layout->addWidget(button);
+ connect(button,&QPushButton::clicked,this,[=](){
+ w->hide();
+ });
+
+ KBubbleWidget* w2 =new KBubbleWidget();
+ w2->setTailPosition(TailDirection::TopDirection);
+ w2->setTailSize(QSize(16,8));
+ w2->setBorderRadius(12);
+ w2->setOpacity(0.4);
+ w2->setEnableBlur(true);
+ w2->setFixedSize(320,320);
+ QPushButton* button2 = new QPushButton(w2);
+ button2->setText("关闭");
+ QHBoxLayout* layout2 = new QHBoxLayout(w2);
+ layout2->addWidget(button2);
+
+ connect(button2,&QPushButton::clicked,this,[=](){
+ w2->hide();
+ });
+
+ connect(btn1,&QPushButton::clicked,this,[=](){
+ w->show();
+ });
+ connect(btn2,&QPushButton::clicked,this,[=](){
+ w2->show();
+ });
+
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testKBubbleWidget/widget.h b/kysdk-qtwidgets/test/testKBubbleWidget/widget.h
new file mode 100644
index 0000000..47b6270
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKBubbleWidget/widget.h
@@ -0,0 +1,14 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testKButtonBox/main.cpp b/kysdk-qtwidgets/test/testKButtonBox/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKButtonBox/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testKButtonBox/testKButtonBox.pro b/kysdk-qtwidgets/test/testKButtonBox/testKButtonBox.pro
new file mode 100644
index 0000000..cdead9a
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKButtonBox/testKButtonBox.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testKButtonBox/widget.cpp b/kysdk-qtwidgets/test/testKButtonBox/widget.cpp
new file mode 100644
index 0000000..ee247ee
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKButtonBox/widget.cpp
@@ -0,0 +1,87 @@
+#include "widget.h"
+#include "kbuttonbox.h"
+#include <QList>
+#include "kpushbutton.h"
+#include <QDebug>
+#include <QBoxLayout>
+#include <QPushButton>
+#include <QComboBox>
+
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ QHBoxLayout *layout1 = new QHBoxLayout;
+ KButtonBox *box1 = new KButtonBox(this);
+ KPushButton *btn1 = new KPushButton;
+ btn1->setIcon(QIcon::fromTheme("list-add-symbolic"));
+ btn1->setFixedSize(48,48);
+ btn1->setIconSize(QSize(32,32));
+ KPushButton *btn2 = new KPushButton;
+ btn2->setIcon(QIcon::fromTheme("list-remove-symbolic"));
+ btn2->setFixedSize(48,48);
+ btn2->setIconSize(QSize(32,32));
+ box1->addButton(btn1);
+ box1->addButton(btn2);
+
+ KButtonBox *box2 = new KButtonBox(this);
+ KPushButton *btn3 = new KPushButton;
+ btn3->setIcon(QIcon::fromTheme("list-add-symbolic"));
+ btn3->setFixedSize(48,48);
+ btn3->setIconSize(QSize(32,32));
+ KPushButton *btn4 = new KPushButton;
+ btn4->setIcon(QIcon::fromTheme("list-remove-symbolic"));
+ btn4->setFixedSize(48,48);
+ btn4->setIconSize(QSize(32,32));
+ btn4->setEnabled(false);
+ box2->addButton(btn3);
+ box2->addButton(btn4);
+
+ QHBoxLayout *layout2 = new QHBoxLayout;
+ KButtonBox *box3 = new KButtonBox(this);
+ KPushButton *btn5 = new KPushButton(this);
+ btn5->setIcon(QIcon::fromTheme("system-computer-symbolic"));
+ KPushButton *btn6 = new KPushButton(this);
+ btn6->setIcon(QIcon::fromTheme("format-text-italic-symbolic"));
+ KPushButton *btn7 = new KPushButton(this);
+ btn7->setIcon(QIcon::fromTheme("format-text-underline-symbolic"));
+ KPushButton *btn8 = new KPushButton(this);
+ btn8->setIcon(QIcon::fromTheme("format-text-strikethrough-symbolic"));
+ QList<KPushButton *> list;
+ list.insert(0,btn5);
+ list.insert(1,btn6);
+ list.insert(2,btn7);
+ list.insert(3,btn8);
+
+ box3->setButtonList(list);
+ box3->setCheckable(true);
+ box3->setExclusive(false);
+
+ KPushButton *btn = new KPushButton;
+ btn->setText("New Button");
+
+ connect(box1,&KButtonBox::buttonClicked,this,[=](QAbstractButton *button){
+ if(btn1 == button)
+ box3->addButton(btn);
+ if(btn2 == button)
+ box3->removeButton(btn);
+ });
+
+ layout1->addWidget(box1);
+ layout1->addWidget(box2);
+ layout2->addWidget(box3);
+ layout->addLayout(layout1);
+ layout->addLayout(layout2);
+ this->setLayout(layout);
+ this->setFixedSize(500,400);
+
+
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testKButtonBox/widget.h b/kysdk-qtwidgets/test/testKButtonBox/widget.h
new file mode 100644
index 0000000..47b6270
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKButtonBox/widget.h
@@ -0,0 +1,14 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testKMessageBox/main.cpp b/kysdk-qtwidgets/test/testKMessageBox/main.cpp
new file mode 100644
index 0000000..5ef19b2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKMessageBox/main.cpp
@@ -0,0 +1,29 @@
+#include "widget.h"
+#include "kwidgetutils.h"
+#include <QApplication>
+#include <QTranslator>
+
+int main(int argc, char *argv[])
+{
+ kdk::KWidgetUtils::highDpiScaling();
+ QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testKMessageBox/testKMessageBox.pro b/kysdk-qtwidgets/test/testKMessageBox/testKMessageBox.pro
new file mode 100644
index 0000000..0bc0fdc
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKMessageBox/testKMessageBox.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-widgetutils kysdk-qtwidgets
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testKMessageBox/widget.cpp b/kysdk-qtwidgets/test/testKMessageBox/widget.cpp
new file mode 100644
index 0000000..a489a29
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKMessageBox/widget.cpp
@@ -0,0 +1,53 @@
+#include "widget.h"
+#include <QPushButton>
+#include <QVBoxLayout>
+#include "kmessagebox.h"
+
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout;
+
+ QPushButton *btn_1 = new QPushButton(this);
+ btn_1->setText("TestDemoOne");
+ QObject::connect(btn_1,&QPushButton::clicked,this,[=](){
+ KMessageBox w;
+ w.setCustomIcon(QIcon::fromTheme("dialog-error"));
+ w.setText("打印测试失败,建议修改驱动后重试");
+
+ QPushButton *btn1 = new QPushButton("修改驱动");
+ QPushButton *btn2 = new QPushButton("取消");
+ w.addButton(btn1,KMessageBox::YesRole);
+ w.addButton(btn2,KMessageBox::NoRole);
+
+ w.exec();
+ });
+
+ QPushButton *btn_2 = new QPushButton(this);
+ btn_2->setText("TestDemoTwo");
+ QObject::connect(btn_2,&QPushButton::clicked,this,[=](){
+ KMessageBox w;
+ w.setCustomIcon(QIcon::fromTheme("ukui-dialog-success"));
+ w.setText("添加成功,是否打印测试页?");
+
+ QPushButton *btn1 = new QPushButton("打印测试页");
+ QPushButton *btn2 = new QPushButton("查看设备");
+ w.addButton(btn1,KMessageBox::YesRole);
+ w.addButton(btn2,KMessageBox::NoRole);
+
+ w.exec();
+ });
+
+ layout->addWidget(btn_1);
+ layout->addWidget(btn_2);
+
+ this->setLayout(layout);
+ this->setFixedSize(300,200);
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testKMessageBox/widget.h b/kysdk-qtwidgets/test/testKMessageBox/widget.h
new file mode 100644
index 0000000..47b6270
--- /dev/null
+++ b/kysdk-qtwidgets/test/testKMessageBox/widget.h
@@ -0,0 +1,14 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testKPushButton/main.cpp b/kysdk-qtwidgets/test/testKPushButton/main.cpp
index 4bf59fb..6bc2dbc 100644
--- a/kysdk-qtwidgets/test/testKPushButton/main.cpp
+++ b/kysdk-qtwidgets/test/testKPushButton/main.cpp
@@ -3,10 +3,29 @@
#include <QApplication>
#include <kwindoweffects.h>
#include <QRegion>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.setAttribute(Qt::WA_TranslucentBackground,true);
KWindowEffects::enableBlurBehind(w.winId(),true);
diff --git a/kysdk-qtwidgets/test/testKPushButton/testKPushButton.pro b/kysdk-qtwidgets/test/testKPushButton/testKPushButton.pro
index ce010e9..b6c23a6 100644
--- a/kysdk-qtwidgets/test/testKPushButton/testKPushButton.pro
+++ b/kysdk-qtwidgets/test/testKPushButton/testKPushButton.pro
@@ -11,7 +11,7 @@ CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# You can also make your code fail to compile if it uses deprecated APIs.
diff --git a/kysdk-qtwidgets/test/testKTranslucentFloor/main.cpp b/kysdk-qtwidgets/test/testKTranslucentFloor/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testKTranslucentFloor/main.cpp
+++ b/kysdk-qtwidgets/test/testKTranslucentFloor/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testKTranslucentFloor/testKTranslucentFloor.pro b/kysdk-qtwidgets/test/testKTranslucentFloor/testKTranslucentFloor.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testKTranslucentFloor/testKTranslucentFloor.pro
+++ b/kysdk-qtwidgets/test/testKTranslucentFloor/testKTranslucentFloor.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testListView/main.cpp b/kysdk-qtwidgets/test/testListView/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testListView/main.cpp
+++ b/kysdk-qtwidgets/test/testListView/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testListView/testListView.pro b/kysdk-qtwidgets/test/testListView/testListView.pro
index a93f398..6c73866 100644
--- a/kysdk-qtwidgets/test/testListView/testListView.pro
+++ b/kysdk-qtwidgets/test/testListView/testListView.pro
@@ -4,7 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testListWidget/main.cpp b/kysdk-qtwidgets/test/testListWidget/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testListWidget/main.cpp
+++ b/kysdk-qtwidgets/test/testListWidget/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testListWidget/testListWidget.pro b/kysdk-qtwidgets/test/testListWidget/testListWidget.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testListWidget/testListWidget.pro
+++ b/kysdk-qtwidgets/test/testListWidget/testListWidget.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testProgressCircle/main.cpp b/kysdk-qtwidgets/test/testProgressCircle/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testProgressCircle/main.cpp
+++ b/kysdk-qtwidgets/test/testProgressCircle/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testProgressCircle/testProgressCircle.pro b/kysdk-qtwidgets/test/testProgressCircle/testProgressCircle.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testProgressCircle/testProgressCircle.pro
+++ b/kysdk-qtwidgets/test/testProgressCircle/testProgressCircle.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testPushbutton/main.cpp b/kysdk-qtwidgets/test/testPushbutton/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testPushbutton/main.cpp
+++ b/kysdk-qtwidgets/test/testPushbutton/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testPushbutton/testPushbutton.pro b/kysdk-qtwidgets/test/testPushbutton/testPushbutton.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testPushbutton/testPushbutton.pro
+++ b/kysdk-qtwidgets/test/testPushbutton/testPushbutton.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testSwitchButton/main.cpp b/kysdk-qtwidgets/test/testSwitchButton/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testSwitchButton/main.cpp
+++ b/kysdk-qtwidgets/test/testSwitchButton/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testSwitchButton/testSwitchButton.pro b/kysdk-qtwidgets/test/testSwitchButton/testSwitchButton.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testSwitchButton/testSwitchButton.pro
+++ b/kysdk-qtwidgets/test/testSwitchButton/testSwitchButton.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testTag/main.cpp b/kysdk-qtwidgets/test/testTag/main.cpp
index 91d8b13..0682a8b 100644
--- a/kysdk-qtwidgets/test/testTag/main.cpp
+++ b/kysdk-qtwidgets/test/testTag/main.cpp
@@ -1,9 +1,28 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testTag/testTag.pro b/kysdk-qtwidgets/test/testTag/testTag.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testTag/testTag.pro
+++ b/kysdk-qtwidgets/test/testTag/testTag.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testTranslucent/main.cpp b/kysdk-qtwidgets/test/testTranslucent/main.cpp
new file mode 100644
index 0000000..d684805
--- /dev/null
+++ b/kysdk-qtwidgets/test/testTranslucent/main.cpp
@@ -0,0 +1,15 @@
+#include "widget.h"
+
+#include <QApplication>
+#include <KWindowEffects>
+//#include <kwidgetutils.h>
+
+int main(int argc, char *argv[])
+{
+// kdk::KWidgetUtils::highDpiScaling();
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ KWindowEffects::enableBlurBehind(w.winId(),true);
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testTranslucent/testTranslucent.pro b/kysdk-qtwidgets/test/testTranslucent/testTranslucent.pro
new file mode 100644
index 0000000..1131058
--- /dev/null
+++ b/kysdk-qtwidgets/test/testTranslucent/testTranslucent.pro
@@ -0,0 +1,30 @@
+QT += core gui KWindowSystem
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11 link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testTranslucent/widget.cpp b/kysdk-qtwidgets/test/testTranslucent/widget.cpp
new file mode 100644
index 0000000..4c4dbeb
--- /dev/null
+++ b/kysdk-qtwidgets/test/testTranslucent/widget.cpp
@@ -0,0 +1,117 @@
+#include "widget.h"
+#include "kslider.h"
+#include "kswitchbutton.h"
+#include <kwindoweffects.h>
+#include <QPalette>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <QLineEdit>
+#include <QLabel>
+#include <QEvent>
+#include "ksearchlineedit.h"
+#include "kpressbutton.h"
+#include "kpushbutton.h"
+
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ setAttribute(Qt::WA_TranslucentBackground);
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this);
+ QWidget *mainWidget = new QWidget(this);
+ mainWidget->setFocusPolicy(Qt::FocusPolicy::ClickFocus);
+ mainWidget->installEventFilter(this);
+ QLabel* label1 = new QLabel("KSlider",this);
+ label1->move(50,100);
+ KSlider* slider = new KSlider(mainWidget);
+ slider->setToolTip("this is a tool tip");
+ slider->setRange(0,100);
+ //测试接口
+ slider->setTranslucent(true);
+ slider->setTickInterval(20);
+ slider->setFixedWidth(300);
+ slider->move(200,100);
+
+ QLabel* label2 = new QLabel("KSwitchButton",this);
+ label2->setFixedWidth(150);
+ label2->move(50,200);
+ KSwitchButton* switchbutton = new KSwitchButton(mainWidget);
+ //测试接口
+ switchbutton->setTranslucent(true);
+ switchbutton->move(200,200);
+
+ QLabel* label3 = new QLabel("KSearchLineEdit",this);
+ label3->move(50,300);
+ KSearchLineEdit* lineEdit = new KSearchLineEdit(mainWidget);
+ lineEdit->move(200,300);
+ //测试接口
+ lineEdit->setTranslucent(true);
+
+ QLabel* label4 = new QLabel("KPressButton",this);
+ label4->move(50,400);
+ KPressButton* pressBtn1 = new KPressButton(this);
+ pressBtn1->setButtonType(KPressButton::CircleType);
+ pressBtn1->setFixedSize(40,40);
+ pressBtn1->setIcon(QIcon::fromTheme("ukui-alarm-symbolic"));
+ //测试接口
+ pressBtn1->setTranslucent(true);
+ pressBtn1->move(200,400);
+
+ KPressButton* pressBtn2 = new KPressButton(this);
+ pressBtn2->setFixedSize(40,40);
+ pressBtn2->setIcon(QIcon::fromTheme("ukui-alarm-symbolic"));
+ //测试接口
+ pressBtn2->setTranslucent(true);
+ pressBtn2->move(250,400);
+
+ QLabel* label5 = new QLabel("KPushButton",this);
+ label5->move(50,500);
+
+
+ KPushButton* pushbtn1 = new KPushButton(this);
+ pushbtn1->setButtonType(KPushButton::CircleType);
+ pushbtn1->setFixedSize(40,40);
+ pushbtn1->setIcon(QIcon::fromTheme("ukui-alarm-symbolic"));
+ pushbtn1->setTranslucent(true);
+ pushbtn1->move(200,500);
+
+ KPushButton* pushbtn2 = new KPushButton(this);
+ pushbtn2->setFixedSize(40,40);
+ pushbtn2->setIcon(QIcon::fromTheme("ukui-alarm-symbolic"));
+ pushbtn2->setIconColor(QColor(255,0,0));
+ //测试接口
+ pushbtn2->setTranslucent(true);
+ pushbtn2->move(250,500);
+
+
+ mainLayout->addWidget(mainWidget);
+ mainLayout->setMargin(0);
+ setFixedSize(800,600);
+}
+
+Widget::~Widget()
+{
+}
+
+bool Widget::eventFilter(QObject *watched, QEvent *event)
+{
+ if(event->type() == QEvent::Paint)
+ {
+ auto widget = qobject_cast<QWidget*>(watched);
+ if(widget)
+ {
+ widget->setAutoFillBackground(true);
+
+ QPalette palette = this->palette();
+ auto color = this->palette().color(QPalette::Window);
+ color.setAlphaF(0.39);
+ palette.setColor(QPalette::Window,color);
+ widget->setPalette(palette);
+ widget->setBackgroundRole(QPalette::Window);
+ }
+ }
+ return QObject::eventFilter(watched,event);
+}
+
diff --git a/kysdk-qtwidgets/test/testTranslucent/widget.h b/kysdk-qtwidgets/test/testTranslucent/widget.h
new file mode 100644
index 0000000..0729603
--- /dev/null
+++ b/kysdk-qtwidgets/test/testTranslucent/widget.h
@@ -0,0 +1,17 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+
+protected:
+ bool eventFilter(QObject *watched, QEvent *event);
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testWidget/main.cpp b/kysdk-qtwidgets/test/testWidget/main.cpp
index acd64e0..8e5b1a1 100644
--- a/kysdk-qtwidgets/test/testWidget/main.cpp
+++ b/kysdk-qtwidgets/test/testWidget/main.cpp
@@ -6,10 +6,12 @@
#include "kwidget.h"
#include "kprogressdialog.h"
#include "kdialog.h"
+#include "kwidgetutils.h"
using namespace kdk;
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
QTranslator trans;
QString locale = QLocale::system().name();
@@ -20,6 +22,13 @@ int main(int argc, char *argv[])
a.installTranslator(&trans);
}
}
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
TestWidget widget;
widget.setWidgetName("TestWidget");
widget.setIcon("kylin-music");
diff --git a/kysdk-qtwidgets/test/testWidget/testWidget.pro b/kysdk-qtwidgets/test/testWidget/testWidget.pro
index 7170f21..f474949 100644
--- a/kysdk-qtwidgets/test/testWidget/testWidget.pro
+++ b/kysdk-qtwidgets/test/testWidget/testWidget.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testbadge/main.cpp b/kysdk-qtwidgets/test/testbadge/main.cpp
index b0a4ec2..5ef19b2 100644
--- a/kysdk-qtwidgets/test/testbadge/main.cpp
+++ b/kysdk-qtwidgets/test/testbadge/main.cpp
@@ -1,10 +1,28 @@
#include "widget.h"
-
+#include "kwidgetutils.h"
#include <QApplication>
+#include <QTranslator>
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testbadge/testbadge.pro b/kysdk-qtwidgets/test/testbadge/testbadge.pro
index 9559e38..2313afe 100644
--- a/kysdk-qtwidgets/test/testbadge/testbadge.pro
+++ b/kysdk-qtwidgets/test/testbadge/testbadge.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
diff --git a/kysdk-qtwidgets/test/testballontip/main.cpp b/kysdk-qtwidgets/test/testballontip/main.cpp
index b0a4ec2..5ef19b2 100644
--- a/kysdk-qtwidgets/test/testballontip/main.cpp
+++ b/kysdk-qtwidgets/test/testballontip/main.cpp
@@ -1,10 +1,28 @@
#include "widget.h"
-
+#include "kwidgetutils.h"
#include <QApplication>
+#include <QTranslator>
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testballontip/testballontip.pro b/kysdk-qtwidgets/test/testballontip/testballontip.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testballontip/testballontip.pro
+++ b/kysdk-qtwidgets/test/testballontip/testballontip.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testbreadcrumb/main.cpp b/kysdk-qtwidgets/test/testbreadcrumb/main.cpp
index b0a4ec2..5ef19b2 100644
--- a/kysdk-qtwidgets/test/testbreadcrumb/main.cpp
+++ b/kysdk-qtwidgets/test/testbreadcrumb/main.cpp
@@ -1,10 +1,28 @@
#include "widget.h"
-
+#include "kwidgetutils.h"
#include <QApplication>
+#include <QTranslator>
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testbreadcrumb/testbreadcrumb.pro b/kysdk-qtwidgets/test/testbreadcrumb/testbreadcrumb.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testbreadcrumb/testbreadcrumb.pro
+++ b/kysdk-qtwidgets/test/testbreadcrumb/testbreadcrumb.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testcolorbutton/main.cpp b/kysdk-qtwidgets/test/testcolorbutton/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testcolorbutton/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testcolorbutton/testcolorbutton.pro b/kysdk-qtwidgets/test/testcolorbutton/testcolorbutton.pro
new file mode 100644
index 0000000..cdead9a
--- /dev/null
+++ b/kysdk-qtwidgets/test/testcolorbutton/testcolorbutton.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testcolorbutton/widget.cpp b/kysdk-qtwidgets/test/testcolorbutton/widget.cpp
new file mode 100644
index 0000000..3782d0a
--- /dev/null
+++ b/kysdk-qtwidgets/test/testcolorbutton/widget.cpp
@@ -0,0 +1,106 @@
+#include "widget.h"
+#include "kcolorbutton.h"
+#include <QHBoxLayout>
+#include <QDebug>
+#include <QButtonGroup>
+
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout* vlayout = new QVBoxLayout(this);
+
+ QHBoxLayout* hlayout = new QHBoxLayout();
+ QHBoxLayout* hlayout1 = new QHBoxLayout();
+
+ KColorButton* btn1 = new KColorButton();
+ KColorButton* btn2 = new KColorButton();
+ btn2->setBackgroundColor(Qt::cyan);
+ KColorButton* btn3 = new KColorButton();
+ btn3->setBackgroundColor(Qt::darkYellow);
+ KColorButton* btn4 = new KColorButton();
+ btn4->setBackgroundColor(Qt::red);
+ KColorButton* btn5 = new KColorButton();
+ btn5->setBackgroundColor(Qt::gray);
+ btn5->setButtonType(KColorButton::CheckedRect);
+ KColorButton* btn6 = new KColorButton();
+ btn6->setBackgroundColor(Qt::green);
+ btn6->setButtonType(KColorButton::CheckedRect);
+ KColorButton* btn7 = new KColorButton();
+ btn7->setBackgroundColor(Qt::darkCyan);
+ btn7->setButtonType(KColorButton::CheckedRect);
+ KColorButton* btn8 = new KColorButton();
+ btn8->setBackgroundColor(Qt::darkRed);
+ btn8->setButtonType(KColorButton::CheckedRect);
+
+ QButtonGroup* group = new QButtonGroup(this);
+ group->addButton(btn1);
+ group->addButton(btn2);
+ group->addButton(btn3);
+ group->addButton(btn4);
+ group->addButton(btn5);
+ group->addButton(btn6);
+ group->addButton(btn7);
+ group->addButton(btn8);
+ group->setExclusive(false); //方形按钮是否可以多选 false为可以多选
+
+ //方形第一行
+ hlayout->addStretch();
+ hlayout->setSpacing(10);
+ hlayout->addWidget(btn1);
+ hlayout->addWidget(btn2);
+ hlayout->addWidget(btn3);
+ hlayout->addWidget(btn4);
+ hlayout->addStretch();
+
+ //方形第二行
+ hlayout1->addStretch();
+ hlayout1->setSpacing(10);
+ hlayout1->addWidget(btn5);
+ hlayout1->addWidget(btn6);
+ hlayout1->addWidget(btn7);
+ hlayout1->addWidget(btn8);
+ hlayout1->addStretch();
+
+ //圆形
+ KColorButton* btn9 = new KColorButton();
+ btn9->setBackgroundColor(Qt::gray);
+ btn9->setButtonType(KColorButton::Circle);
+ KColorButton* btn10 = new KColorButton();
+ btn10->setBackgroundColor(Qt::green);
+ btn10->setButtonType(KColorButton::Circle);
+ KColorButton* btn11 = new KColorButton();
+ btn11->setBackgroundColor(Qt::darkCyan);
+ btn11->setButtonType(KColorButton::Circle);
+ KColorButton* btn12 = new KColorButton();
+ btn12->setBackgroundColor(Qt::darkRed);
+ btn12->setButtonType(KColorButton::Circle);
+
+ QButtonGroup* group1 = new QButtonGroup(this);
+ group1->addButton(btn9);
+ group1->addButton(btn10);
+ group1->addButton(btn11);
+ group1->addButton(btn12);
+ group1->setExclusive(false); //圆形形按钮是否可以多选 false为可以多选
+
+ QHBoxLayout* hlayout2 = new QHBoxLayout();
+ hlayout2->addStretch();
+ hlayout2->addWidget(btn9);
+ hlayout2->addWidget(btn10);
+ hlayout2->addWidget(btn11);
+ hlayout2->addWidget(btn12);
+ hlayout2->addStretch();
+
+ vlayout->addLayout(hlayout);
+ vlayout->addLayout(hlayout1);
+ vlayout->addLayout(hlayout2);
+// vlayout->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize);
+ this->setFixedSize(300,240);
+
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testcolorbutton/widget.h b/kysdk-qtwidgets/test/testcolorbutton/widget.h
new file mode 100644
index 0000000..167311d
--- /dev/null
+++ b/kysdk-qtwidgets/test/testcolorbutton/widget.h
@@ -0,0 +1,14 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+#include "kwidget.h"
+#include <QWidget>
+using namespace kdk;
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testinputdialog/main.cpp b/kysdk-qtwidgets/test/testinputdialog/main.cpp
index 57c360b..41d0d86 100644
--- a/kysdk-qtwidgets/test/testinputdialog/main.cpp
+++ b/kysdk-qtwidgets/test/testinputdialog/main.cpp
@@ -2,9 +2,11 @@
#include <QApplication>
#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
Widget w;
QTranslator trans;
@@ -16,6 +18,13 @@ int main(int argc, char *argv[])
a.installTranslator(&trans);
}
}
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
w.show();
return a.exec();
}
diff --git a/kysdk-qtwidgets/test/testinputdialog/testinputdialog.pro b/kysdk-qtwidgets/test/testinputdialog/testinputdialog.pro
index 41a4d79..4222e17 100644
--- a/kysdk-qtwidgets/test/testinputdialog/testinputdialog.pro
+++ b/kysdk-qtwidgets/test/testinputdialog/testinputdialog.pro
@@ -3,7 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testkbackground/main.cpp b/kysdk-qtwidgets/test/testkbackground/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkbackground/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testkbackground/testkbackground.pro b/kysdk-qtwidgets/test/testkbackground/testkbackground.pro
new file mode 100644
index 0000000..d37043d
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkbackground/testkbackground.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testkbackground/widget.cpp b/kysdk-qtwidgets/test/testkbackground/widget.cpp
new file mode 100644
index 0000000..56d67e6
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkbackground/widget.cpp
@@ -0,0 +1,172 @@
+#include "widget.h"
+#include <QHBoxLayout>
+#include "kbackgroundgroup.h"
+#include <QFrame>
+#include "klineframe.h"
+#include "kpushbutton.h"
+#include <QCheckBox>
+#include <QLineEdit>
+#include "kswitchbutton.h"
+#include "kborderlessbutton.h"
+#include "ktoolbutton.h"
+#include <QLabel>
+
+using namespace kdk;
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout* vmainLayout=new QVBoxLayout(this);
+
+ QLabel *networkLabel = new QLabel();
+ networkLabel->setText("有线网络");
+ networkLabel->setContentsMargins(20,0,0,0);
+
+ QWidget *widget1 = new QWidget();
+
+ QLabel* widget1Label = new QLabel();
+ widget1Label->setText("开启");
+
+ KSwitchButton *widget1Switch = new KSwitchButton();
+
+ QHBoxLayout* widget1Layout = new QHBoxLayout(widget1);
+ widget1Layout->setContentsMargins(16,0,16,0);
+ widget1Layout->addWidget(widget1Label);
+ widget1Layout->addStretch();
+ widget1Layout->addWidget(widget1Switch);
+
+ KBackgroundGroup *back = new KBackgroundGroup();
+ back->addWidget(widget1);
+
+ QWidget *widget2 = new QWidget();
+// widget2->setFixedHeight(100);
+
+ QLabel *widget2label = new QLabel();
+ widget2label->setText("网卡wwwwwww");
+
+ KBorderlessButton *less = new KBorderlessButton();
+ less->setIcon(QIcon::fromTheme("system-computer-symbolic"));
+ less->setAttribute(Qt::WA_TranslucentBackground);
+
+ KSwitchButton *widget2Switch = new KSwitchButton();
+ widget2Switch->setAttribute(Qt::WA_TranslucentBackground);
+
+ QHBoxLayout *widget2Layout = new QHBoxLayout(widget2);
+ widget2Layout->setContentsMargins(16,0,16,0);
+ widget2Layout->addWidget(widget2label);
+ widget2Layout->addStretch();
+ widget2Layout->addWidget(less);
+ widget2Layout->addWidget(widget2Switch);
+
+ QWidget *widget3 = new QWidget();
+// QPushButton *widget3 = new QPushButton();
+ widget3->setProperty("isWindowButton",0x01);
+
+ QLabel *widget3Label1 = new QLabel();
+ widget3Label1->setPixmap(QIcon::fromTheme("system-computer-symbolic").pixmap(16,16));
+ QLabel *widget3Label2 = new QLabel();
+ widget3Label2->setText("网络名称");
+
+ QLabel *widget3Label3 = new QLabel();
+ widget3Label3->setText("连接");
+
+ KBorderlessButton *widget3btn = new KBorderlessButton(this);
+ widget3btn->setIcon(QIcon::fromTheme("stock-people-symbolic"));
+ widget3btn->setAttribute(Qt::WA_TranslucentBackground);
+
+ QHBoxLayout *widget3Layout= new QHBoxLayout(widget3);
+ widget3Layout->setContentsMargins(16,0,16,0);
+ widget3Layout->addWidget(widget3Label1);
+ widget3Layout->addWidget(widget3Label2);
+ widget3Layout->addStretch();
+ widget3Layout->addWidget(widget3Label3);
+ widget3Layout->addWidget(widget3btn);
+
+ QWidget *widget4=new QWidget();
+
+ QLabel *widget4Label1 = new QLabel();
+ widget4Label1->setText("点击添加");
+
+ QLabel *widget4Label2 = new QLabel();
+ widget4Label2->setPixmap(QIcon::fromTheme("system-computer-symbolic").pixmap(16,16));
+
+ QHBoxLayout *widget4Layout = new QHBoxLayout(widget4);
+ widget4Layout->addStretch();
+ widget4Layout->addWidget(widget4Label2);
+ widget4Layout->addWidget(widget4Label1);
+ widget4Layout->addStretch();
+
+ QList<QWidget*> list;
+ list.append(widget2);
+ list.append(widget3);
+ list.append(widget4);
+
+ KBackgroundGroup *back1 = new KBackgroundGroup();
+ back1->addWidgetList(list);
+ back1->setStateEnable(widget3,true);
+ back1->setStateEnable(widget4,true);
+
+
+ QWidget *widget5 = new QWidget();
+ widget5->hide();
+
+ QWidget *widget6 =new QWidget();
+ widget6->setWindowIcon(QIcon::fromTheme("kylin-music"));
+ widget6->hide();
+
+ connect(widget1Switch,&KSwitchButton::clicked,this,[=](){
+ if(back1->isVisible())
+ back1->hide();
+ else
+ back1->show();
+ });
+
+ //插入删除
+ connect(widget2Switch,&KSwitchButton::clicked,this,[=](){
+ if(back1->widgetList().contains(widget3))
+ back1->removeWidget(widget3);
+ else
+ back1->insertWidgetAt(back1->widgetList().count()-1,widget3);
+ back1->setStateEnable(widget3,true);
+ });
+
+ connect(less,&KBorderlessButton::clicked,this,[=](){
+ if(back1->widgetList().contains(widget3))
+ back1->removeWidget(widget3);
+ else
+ back1->insertWidgetAt(back1->widgetList().count()-1,widget3);
+ back1->setStateEnable(widget3,true);
+ });
+
+ connect(back1,&KBackgroundGroup::clicked,this,[=](QWidget* widget){
+ if(widget == widget3 )
+ {
+ if(widget3Label3->isVisible())
+ widget3Label3->hide();
+ else
+ widget3Label3->show();
+ }
+ if(widget == widget4 )
+ {
+ if(widget6->isVisible())
+ widget6->hide();
+ else
+ widget6->show();
+ }
+ });
+
+ connect(widget3btn,&KBorderlessButton::clicked,this,[=](){
+ if(widget5->isVisible())
+ widget5->hide();
+ else
+ widget5->show();
+ });
+ vmainLayout->addWidget(networkLabel);
+ vmainLayout->addWidget(back);
+ vmainLayout->addWidget(back1);
+ vmainLayout->addStretch();
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testkbackground/widget.h b/kysdk-qtwidgets/test/testkbackground/widget.h
new file mode 100644
index 0000000..60542d7
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkbackground/widget.h
@@ -0,0 +1,16 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+#include "kwidget.h"
+using namespace kdk;
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testkcolorcombobox/main.cpp b/kysdk-qtwidgets/test/testkcolorcombobox/main.cpp
new file mode 100644
index 0000000..b0a4ec2
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkcolorcombobox/main.cpp
@@ -0,0 +1,11 @@
+#include "widget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/kysdk-qtwidgets/test/testkcolorcombobox/testkcolorcombobox.pro b/kysdk-qtwidgets/test/testkcolorcombobox/testkcolorcombobox.pro
new file mode 100644
index 0000000..969b81d
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkcolorcombobox/testkcolorcombobox.pro
@@ -0,0 +1,31 @@
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+CONFIG += link_pkgconfig
+PKGCONFIG += kysdk-qtwidgets
+
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+ main.cpp \
+ widget.cpp
+
+HEADERS += \
+ widget.h
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp b/kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp
new file mode 100644
index 0000000..e3359fa
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp
@@ -0,0 +1,57 @@
+#include "widget.h"
+#include <QHBoxLayout>
+#include <QColor>
+#include <QList>
+#include "kcolorcombobox.h"
+#include <QDebug>
+using namespace kdk;
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ QHBoxLayout *hLayout = new QHBoxLayout(this);
+ KColorComboBox *comboBoxCircle = new KColorComboBox(this);
+ comboBoxCircle->setComboType(KColorComboBox::Circle);
+ connect(comboBoxCircle,&KColorComboBox::currentColorChanged,this,[=](){
+ qDebug()<<"currentColorChanged";
+ });
+ connect(comboBoxCircle,&KColorComboBox::activated,this,[=](){
+ qDebug()<<"activatedChanged";
+ });
+ connect(comboBoxCircle,&KColorComboBox::highlighted,this,[=](){
+ qDebug()<<"highlightChanged";
+ });
+ hLayout->addWidget(comboBoxCircle);
+ comboBoxCircle->setFixedSize(36,36);
+ KColorComboBox *comboBoxRect = new KColorComboBox(this);
+ connect(comboBoxRect,&KColorComboBox::currentColorChanged,this,[=](){
+ qDebug()<<"currentColorChanged";
+ });
+ connect(comboBoxRect,&KColorComboBox::activated,this,[=](){
+ qDebug()<<"activatedChanged";
+ });
+ connect(comboBoxRect,&KColorComboBox::highlighted,this,[=](){
+ qDebug()<<"highlightChanged";
+ });
+ comboBoxRect->setComboType(KColorComboBox::RoundedRect);
+ hLayout->addWidget(comboBoxRect);
+ comboBoxRect->setFixedSize(36,36);
+
+// 1.列表插入
+ QList <QColor> list;
+ list.append(QColor(255,0,0));
+ list.append(QColor(0,255,0));
+ list.append(QColor(255,255,0));
+ comboBoxCircle->setColorList(list);
+// 2.逐个插入
+ comboBoxRect->addColor(QColor(255,0,0));
+ comboBoxRect->addColor(QColor(0,255,0));
+ comboBoxRect->addColor(QColor(255,255,0));
+ setGeometry(400,400,400,400);
+ comboBoxCircle->setCurrentIndex(1);
+}
+
+Widget::~Widget()
+{
+}
+
diff --git a/kysdk-qtwidgets/test/testkcolorcombobox/widget.h b/kysdk-qtwidgets/test/testkcolorcombobox/widget.h
new file mode 100644
index 0000000..47b6270
--- /dev/null
+++ b/kysdk-qtwidgets/test/testkcolorcombobox/widget.h
@@ -0,0 +1,14 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = nullptr);
+ ~Widget();
+};
+#endif // WIDGET_H
diff --git a/kysdk-qtwidgets/test/testkpressbutton/main.cpp b/kysdk-qtwidgets/test/testkpressbutton/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testkpressbutton/main.cpp
+++ b/kysdk-qtwidgets/test/testkpressbutton/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testkpressbutton/testkpressbutton.pro b/kysdk-qtwidgets/test/testkpressbutton/testkpressbutton.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testkpressbutton/testkpressbutton.pro
+++ b/kysdk-qtwidgets/test/testkpressbutton/testkpressbutton.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testnavigationbar/main.cpp b/kysdk-qtwidgets/test/testnavigationbar/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testnavigationbar/main.cpp
+++ b/kysdk-qtwidgets/test/testnavigationbar/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testnavigationbar/testnavigationbar.pro b/kysdk-qtwidgets/test/testnavigationbar/testnavigationbar.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testnavigationbar/testnavigationbar.pro
+++ b/kysdk-qtwidgets/test/testnavigationbar/testnavigationbar.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/test/testpasswordedit/main.cpp b/kysdk-qtwidgets/test/testpasswordedit/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testpasswordedit/main.cpp
+++ b/kysdk-qtwidgets/test/testpasswordedit/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testpasswordedit/testpasswordedit.pro b/kysdk-qtwidgets/test/testpasswordedit/testpasswordedit.pro
index a93f398..6c73866 100644
--- a/kysdk-qtwidgets/test/testpasswordedit/testpasswordedit.pro
+++ b/kysdk-qtwidgets/test/testpasswordedit/testpasswordedit.pro
@@ -4,7 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testprogressbar/main.cpp b/kysdk-qtwidgets/test/testprogressbar/main.cpp
index b0a4ec2..e20d7f9 100644
--- a/kysdk-qtwidgets/test/testprogressbar/main.cpp
+++ b/kysdk-qtwidgets/test/testprogressbar/main.cpp
@@ -1,10 +1,27 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testprogressbar/testprogressbar.pro b/kysdk-qtwidgets/test/testprogressbar/testprogressbar.pro
index f68ecbb..bbd3ac9 100644
--- a/kysdk-qtwidgets/test/testprogressbar/testprogressbar.pro
+++ b/kysdk-qtwidgets/test/testprogressbar/testprogressbar.pro
@@ -3,7 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testprogressdialog/main.cpp b/kysdk-qtwidgets/test/testprogressdialog/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testprogressdialog/main.cpp
+++ b/kysdk-qtwidgets/test/testprogressdialog/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testprogressdialog/testprogressdialog.pro b/kysdk-qtwidgets/test/testprogressdialog/testprogressdialog.pro
index 41a4d79..4222e17 100644
--- a/kysdk-qtwidgets/test/testprogressdialog/testprogressdialog.pro
+++ b/kysdk-qtwidgets/test/testprogressdialog/testprogressdialog.pro
@@ -3,7 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testsearchlinedit/main.cpp b/kysdk-qtwidgets/test/testsearchlinedit/main.cpp
index 1af2e22..136b8eb 100644
--- a/kysdk-qtwidgets/test/testsearchlinedit/main.cpp
+++ b/kysdk-qtwidgets/test/testsearchlinedit/main.cpp
@@ -2,9 +2,11 @@
#include <QApplication>
#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
QTranslator trans;
QString locale = QLocale::system().name();
@@ -15,6 +17,13 @@ int main(int argc, char *argv[])
a.installTranslator(&trans);
}
}
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testsearchlinedit/testsearchlinedit.pro b/kysdk-qtwidgets/test/testsearchlinedit/testsearchlinedit.pro
index 843c8ef..2c035b6 100644
--- a/kysdk-qtwidgets/test/testsearchlinedit/testsearchlinedit.pro
+++ b/kysdk-qtwidgets/test/testsearchlinedit/testsearchlinedit.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
diff --git a/kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp b/kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp
index 1af2e22..136b8eb 100644
--- a/kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp
+++ b/kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp
@@ -2,9 +2,11 @@
#include <QApplication>
#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
QTranslator trans;
QString locale = QLocale::system().name();
@@ -15,6 +17,13 @@ int main(int argc, char *argv[])
a.installTranslator(&trans);
}
}
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testsecuritylevelbar/testsecuritylevelbar.pro b/kysdk-qtwidgets/test/testsecuritylevelbar/testsecuritylevelbar.pro
index 41a4d79..4222e17 100644
--- a/kysdk-qtwidgets/test/testsecuritylevelbar/testsecuritylevelbar.pro
+++ b/kysdk-qtwidgets/test/testsecuritylevelbar/testsecuritylevelbar.pro
@@ -3,7 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testslider/main.cpp b/kysdk-qtwidgets/test/testslider/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testslider/main.cpp
+++ b/kysdk-qtwidgets/test/testslider/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testslider/testslider.pro b/kysdk-qtwidgets/test/testslider/testslider.pro
index 41a4d79..4222e17 100644
--- a/kysdk-qtwidgets/test/testslider/testslider.pro
+++ b/kysdk-qtwidgets/test/testslider/testslider.pro
@@ -3,7 +3,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
CONFIG += c++11
diff --git a/kysdk-qtwidgets/test/testtabbar/main.cpp b/kysdk-qtwidgets/test/testtabbar/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testtabbar/main.cpp
+++ b/kysdk-qtwidgets/test/testtabbar/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testtabbar/testtabbar.pro b/kysdk-qtwidgets/test/testtabbar/testtabbar.pro
index 9559e38..2313afe 100644
--- a/kysdk-qtwidgets/test/testtabbar/testtabbar.pro
+++ b/kysdk-qtwidgets/test/testtabbar/testtabbar.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
diff --git a/kysdk-qtwidgets/test/testtoolbutton/main.cpp b/kysdk-qtwidgets/test/testtoolbutton/main.cpp
index b0a4ec2..136b8eb 100644
--- a/kysdk-qtwidgets/test/testtoolbutton/main.cpp
+++ b/kysdk-qtwidgets/test/testtoolbutton/main.cpp
@@ -1,10 +1,29 @@
#include "widget.h"
#include <QApplication>
+#include <QTranslator>
+#include "kwidgetutils.h"
int main(int argc, char *argv[])
{
+ kdk::KWidgetUtils::highDpiScaling();
QApplication a(argc, argv);
+ QTranslator trans;
+ QString locale = QLocale::system().name();
+ if(locale == "zh_CN")
+ {
+ if(trans.load(":/translations/gui_zh_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
+ if(locale == "bo_CN")
+ {
+ if(trans.load(":/translations/gui_bo_CN.qm"))
+ {
+ a.installTranslator(&trans);
+ }
+ }
Widget w;
w.show();
return a.exec();
diff --git a/kysdk-qtwidgets/test/testtoolbutton/testtoolbutton.pro b/kysdk-qtwidgets/test/testtoolbutton/testtoolbutton.pro
index d37043d..b7027d7 100644
--- a/kysdk-qtwidgets/test/testtoolbutton/testtoolbutton.pro
+++ b/kysdk-qtwidgets/test/testtoolbutton/testtoolbutton.pro
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += link_pkgconfig
-PKGCONFIG += kysdk-qtwidgets
+PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-qtwidgets/translations/gui_bo_CN.qm b/kysdk-qtwidgets/translations/gui_bo_CN.qm
index 5961308..d870988 100644
--- a/kysdk-qtwidgets/translations/gui_bo_CN.qm
+++ b/kysdk-qtwidgets/translations/gui_bo_CN.qm
@@ -1,8 +1,7 @@
-<<3C>d<18><EFBFBD>!<1C>`<60><><EFBFBD>B[Sg.Sg<07><02><><01><04><><03><04><>I<04><><06><05><04>F<><05>G<><47>gPHE
-tR<><52><04>Z<>|<08>Z<>5wj6<6A> <09>lyzKt):t):
-<04><><EFBFBD><03>;<3B><>h<05><><EFBFBD>C<06>I<EFBFBD><02><06>I<EFBFBD><05><07><><EFBFBD><06>ʶ<>
-<2D><08>H5
- <09><02>E ˰
-2<><32>a
-2<><32> r <0C><><EFBFBD>X<>4<00>i %<00>A<0F>zQ bD Br X cB c f<0F><0F>B b<0F>f Izb f<0F><0F>|Q B| brX BD aD f<0F><0F>rB f<0F><0F>|b V<0F>f XzQ 
.No mail applicaiton accessible in your system.kdk::KAboutDialog,0
-BfD V`r Bfc Vf<0F><0F>Bf
0 Privacy statementkdk::KAboutDialog8^Vf ^t QD b<0F><0F>V f<0F><0F>|b Z|Bf T Service & Support: kdk::KAboutDialogPf<0F><0F>B b<0F>f Izb f<0F><0F>|Q V<0F> brX A U<0F>z Xr PtV 
Unable to open mail applicationkdk::KAboutDialogDA<0F>|Q @<0F>rf B<0F>Df @ SD `GtB BSD b|Bf
Enter a value:kdk::KInputDialog XzQ Tb V_| QB|f
cancelkdk::KInputDialogPrivate"QD|f ft Af czS T
okkdk::KInputDialogPrivateQz`r f<0F>|b
Aboutkdk::KMenuButton$b|Bf bX V<0F>zQ QB|f
Assistkdk::KMenuButton,X cB Br b<0F>zf ft `V<0F>D VAutokdk::KMenuButtonZ|f B^r _V T
Darkkdk::KMenuButtonXQ|B f<0F>tB T|
Lightkdk::KMenuButton$U<0F>rb `PzS V<0F> QB|f
Quitkdk::KMenuButton.V@|Q f<0F><0F>rB VEf V<0F> QB|f
Settingkdk::KMenuButtonU<0F>r Ztc
Themekdk::KMenuButtonQz Vf @<0F>D XD morekdk::KMenuButton XzQ Tb V_| QB|f
cancelkdk::KProgressDialog `Z|c ^rV V<0F>zQ T
Searchkdk::KSearchLineEditPrivate `Z|c ^rV V<0F>zQ T
searchkdk::KSearchLineEditPrivateXP|S T|
Highkdk::KSecurityLevelBar QX` V
Lowkdk::KSecurityLevelBar&@<0F>tD B|`r BtD @<0F>tD Mediumkdk::KSecurityLevelBar QX` V
Lowkdk::KSecurityLevelBarPrivate.`BS BYD czS T`r XrD `Qr deb name:kdk::KUninstallDialogTb B^r
 deb version:kdk::KUninstallDialog2`U<0F>c Xb UV czS V<0F>zQ QB|f
 uninstallkdk::KUninstallDialog.`BS BYD czS T`r XrD `Qr deb name:kdk::KUninstallDialogPrivateTb B^r
 deb version:kdk::KUninstallDialogPrivatef<0F>| b<0F><0F>B T
closekdk::KWindowButtonBarPrivate2Fzf Fz V VEf ft `B<0F>tb Vb maximizekdk::KWindowButtonBarPrivateFzf FtD V arS
minimizekdk::KWindowButtonBarPrivate$f<0F>b Bf| V<0F>zQ QB|f
restorekdk::KWindowButtonBarPrivate
\ No newline at end of file
+<<3C>d<18><EFBFBD>!<1C>`<60><><EFBFBD>B[Sg(Sg<07><02><><01><04><><03><04><>I<04><><06><05><04>G<><47>gPHE
+nR<><52><04>Z<>|<08>Z<>5wj6<6A> <09>lyzKt):<07>t): <04><><EFBFBD><03>;<3B><>b<05><><EFBFBD>=<06>I<EFBFBD><02><06>I<EFBFBD><05>g<>^<05><07><><EFBFBD><06>ʶ<>
+<2B><08>H5
+ <09><02>E ˰
+2<><32>[
+2<><32> l <0C><><EFBFBD>X<>4<00>i <00>A<0F>zQ bD Br X cB c f<0F><0F>B b<0F>f Izb f<0F><0F>|Q B| brX BD aD f<0F><0F>rB f<0F><0F>|b V<0F>f XzQ 
.No mail applicaiton accessible in your system.kdk::KAboutDialog,0
+BfD V`r Bfc Vf<0F><0F>Bf
0 Privacy statementkdk::KAboutDialog8^Vf ^t QD b<0F><0F>V f<0F><0F>|b Z|Bf T Service & Support: kdk::KAboutDialogPf<0F><0F>B b<0F>f Izb f<0F><0F>|Q V<0F> brX A U<0F>z Xr PtV 
Unable to open mail applicationkdk::KAboutDialogDA<0F>|Q @<0F>rf B<0F>Df @ SD `GtB BSD b|Bf
Enter a value:kdk::KInputDialog XzQ Tb V_| QB|f
cancelkdk::KInputDialogPrivate"QD|f ft Af czS T
okkdk::KInputDialogPrivateQz`r f<0F>|b
Aboutkdk::KMenuButton$b|Bf bX V<0F>zQ QB|f
Assistkdk::KMenuButton,X cB Br b<0F>zf ft `V<0F>D VAutokdk::KMenuButtonZ|f B^r _V T
Darkkdk::KMenuButtonXQ|B f<0F>tB T|
Lightkdk::KMenuButton$U<0F>rb `PzS V<0F> QB|f
Quitkdk::KMenuButton.V@|Q f<0F><0F>rB VEf V<0F> QB|f
Settingkdk::KMenuButtonU<0F>r Ztc
Themekdk::KMenuButton`QzXf ZS optionkdk::KMenuButton XzQ Tb V_| QB|f
cancelkdk::KProgressDialog `Z|c ^rV V<0F>zQ T
Searchkdk::KSearchLineEditPrivate `Z|c ^rV V<0F>zQ T
searchkdk::KSearchLineEditPrivateXP|S T|
Highkdk::KSecurityLevelBar QX` V
Lowkdk::KSecurityLevelBar&@<0F>tD B|`r BtD @<0F>tD Mediumkdk::KSecurityLevelBar QX` V
Lowkdk::KSecurityLevelBarPrivate.`BS BYD czS T`r XrD `Qr deb name:kdk::KUninstallDialogTb B^r
 deb version:kdk::KUninstallDialog2`U<0F>c Xb UV czS V<0F>zQ QB|f
 uninstallkdk::KUninstallDialog.`BS BYD czS T`r XrD `Qr deb name:kdk::KUninstallDialogPrivateTb B^r
 deb version:kdk::KUninstallDialogPrivatef<0F>| b<0F><0F>B T
closekdk::KWindowButtonBarPrivate2Fzf Fz V VEf ft `B<0F>tb Vb maximizekdk::KWindowButtonBarPrivateFzf FtD V arS
minimizekdk::KWindowButtonBarPrivate$f<0F>b Bf| V<0F>zQ QB|f
restorekdk::KWindowButtonBarPrivate
\ No newline at end of file
diff --git a/kysdk-qtwidgets/translations/gui_bo_CN.ts b/kysdk-qtwidgets/translations/gui_bo_CN.ts
index 7fab129..e898d38 100644
--- a/kysdk-qtwidgets/translations/gui_bo_CN.ts
+++ b/kysdk-qtwidgets/translations/gui_bo_CN.ts
@@ -4,24 +4,24 @@
<context>
<name>kdk::KAboutDialog</name>
<message>
- <location filename="../src/kaboutdialog.cpp" line="90"/>
+ <location filename="../src/kaboutdialog.cpp" line="97"/>
<source>No mail applicaiton accessible in your system.</source>
<translation>ཁྱེད་རང་གི་མ་ལག་ལ་སྦྲག་རྫས་ཉེར་སྤྱོད་གོ་རིམ་གང་ཡང་སྒྲིག་སྦྱོར་བྱས་མེད་།</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="91"/>
+ <location filename="../src/kaboutdialog.cpp" line="98"/>
<source>Unable to open mail application</source>
<translation>སྦྲག་རྫས་ཉེར་སྤྱོད་བྱ་རིམ་ཁ་ཕྱེ་མི་ཐུབ་།</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="209"/>
- <location filename="../src/kaboutdialog.cpp" line="223"/>
+ <location filename="../src/kaboutdialog.cpp" line="230"/>
+ <location filename="../src/kaboutdialog.cpp" line="244"/>
<source>Service &amp; Support: </source>
<translation>ཞབས་ཞུ་དང་རྒྱབ་སྐྱོར་ཚོགས་པ་</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="215"/>
- <location filename="../src/kaboutdialog.cpp" line="229"/>
+ <location filename="../src/kaboutdialog.cpp" line="236"/>
+ <location filename="../src/kaboutdialog.cpp" line="250"/>
<source>Privacy statement</source>
<translation>《གསང་བའི་གསལ་བསྒྲགས། 》</translation>
</message>
@@ -29,7 +29,7 @@
<context>
<name>kdk::KInputDialog</name>
<message>
- <location filename="../src/kinputdialog.cpp" line="205"/>
+ <location filename="../src/kinputdialog.cpp" line="220"/>
<source>Enter a value:</source>
<translation>ཁྱོད་ཀྱིས་གྲངས་ཀ་ནང་འཇུག་གནང་རོགས།</translation>
</message>
@@ -37,12 +37,12 @@
<context>
<name>kdk::KInputDialogPrivate</name>
<message>
- <location filename="../src/kinputdialog.cpp" line="214"/>
+ <location filename="../src/kinputdialog.cpp" line="229"/>
<source>ok</source>
<translation>དངོས་སུ་ཁས་ལེན་པ།</translation>
</message>
<message>
- <location filename="../src/kinputdialog.cpp" line="216"/>
+ <location filename="../src/kinputdialog.cpp" line="231"/>
<source>cancel</source>
<translation>མེད་པར་བཟོ་དགོས།</translation>
</message>
@@ -50,47 +50,51 @@
<context>
<name>kdk::KMenuButton</name>
<message>
- <location filename="../src/kmenubutton.cpp" line="39"/>
<source>more</source>
- <translation>དེ་བས་ཀྱང་མང་</translation>
+ <translation type="vanished">དེ་བས་ཀྱང་མང་</translation>
</message>
<message>
<location filename="../src/kmenubutton.cpp" line="40"/>
+ <source>option</source>
+ <translation>འདེམས་ཚན་</translation>
+ </message>
+ <message>
+ <location filename="../src/kmenubutton.cpp" line="41"/>
<source>Setting</source>
<translation>བཀོད་སྒྲིག་བཅས་བྱ་དགོས།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="41"/>
+ <location filename="../src/kmenubutton.cpp" line="42"/>
<source>Theme</source>
<translation>ཕྱི་ཚུལ།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="42"/>
+ <location filename="../src/kmenubutton.cpp" line="43"/>
<source>Assist</source>
<translation>རོགས་རམ་བྱེད་དགོས།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="43"/>
+ <location filename="../src/kmenubutton.cpp" line="44"/>
<source>About</source>
<translation>དེའི་སྐོར།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="44"/>
+ <location filename="../src/kmenubutton.cpp" line="45"/>
<source>Quit</source>
<translation>ཕྱིར་འཐེན་བྱ་དགོས།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="51"/>
+ <location filename="../src/kmenubutton.cpp" line="52"/>
<source>Auto</source>
<translation>མ་ལག་གི་རྗེས་སུ་འབྲང་བ</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="53"/>
+ <location filename="../src/kmenubutton.cpp" line="54"/>
<source>Light</source>
<translation>མདོག་སྨུག་པོ།</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="55"/>
+ <location filename="../src/kmenubutton.cpp" line="56"/>
<source>Dark</source>
<translation>ཚོས་གཞི་ཟབ་པ།</translation>
</message>
@@ -98,7 +102,7 @@
<context>
<name>kdk::KProgressDialog</name>
<message>
- <location filename="../src/kprogressdialog.cpp" line="47"/>
+ <location filename="../src/kprogressdialog.cpp" line="48"/>
<source>cancel</source>
<translation>མེད་པར་བཟོ་དགོས།</translation>
</message>
@@ -106,12 +110,12 @@
<context>
<name>kdk::KSearchLineEditPrivate</name>
<message>
- <location filename="../src/ksearchlineedit.cpp" line="350"/>
+ <location filename="../src/ksearchlineedit.cpp" line="362"/>
<source>search</source>
<translation>འཚོལ་ཞིབ་བྱེད་པ།</translation>
</message>
<message>
- <location filename="../src/ksearchlineedit.cpp" line="441"/>
+ <location filename="../src/ksearchlineedit.cpp" line="463"/>
<source>Search</source>
<translation>འཚོལ་ཞིབ་བྱེད་པ།</translation>
</message>
@@ -177,22 +181,22 @@
<context>
<name>kdk::KWindowButtonBarPrivate</name>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="162"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="192"/>
<source>minimize</source>
<translation>ཆེས་ཆུང་བ་ཡིན།</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="218"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="246"/>
<source>maximize</source>
<translation>ཆེས་ཆེ་བ་བཅས་སུ་འགྱུར་བར་</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="223"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="251"/>
<source>restore</source>
<translation>སླར་གསོ་བྱེད་དགོས།</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="173"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="201"/>
<source>close</source>
<translation>སྒོ་རྒྱག་པ།</translation>
</message>
diff --git a/kysdk-qtwidgets/translations/gui_zh_CN.qm b/kysdk-qtwidgets/translations/gui_zh_CN.qm
index e33838e..df95b6e 100644
--- a/kysdk-qtwidgets/translations/gui_zh_CN.qm
+++ b/kysdk-qtwidgets/translations/gui_zh_CN.qm
@@ -1,4 +1,4 @@
-<<3C>d<18><EFBFBD>!<1C>`<60><><EFBFBD>B[<01>SgxSg<04><02><><00><04><>\<04><><02><04><>G<05><02>F<>sG<><47><01>PHE<06>R<><52><02>Z<>|<05>Z<>5Ej6<6A>ElyzUt):t):<05><04><><EFBFBD>-;<3B><><04><05><><EFBFBD><03><06>I<EFBFBD><01><06>I<EFBFBD><03><07><><EFBFBD>
ʶ<><06><08>H5 <09><02><00> ˰
-2<><32>K
-2<><32> <0C><><EFBFBD>X<>4ri9`<60>v<EFBFBD>|<7C>~<7E>g*[<5B><><EFBFBD>N<EFBFBD>OUu5[P<><50>N<EFBFBD>^<5E>u(.No mail applicaiton accessible in your system.kdk::KAboutDialog 0
-<2D><>y<EFBFBD>X<EFBFBD>f0 Privacy statementkdk::KAboutDialogg
R<EFBFBD>Ne/cV<><56><1F>Service & Support: kdk::KAboutDialoge<>l<EFBFBD>bS_<00><>N<EFBFBD>[<5B>b7z<37>Unable to open mail applicationkdk::KAboutDialog <0C><><EFBFBD><EFBFBD>QeepP<<3C>Enter a value:kdk::KInputDialogS<>m<EFBFBD>cancelkdk::KInputDialogPrivatexn<78><6E>okkdk::KInputDialogPrivateQsN<73>Aboutkdk::KMenuButton^.R<>Assistkdk::KMenuButton<08>ߖ<EFBFBD>|<7C>~<7E>Autokdk::KMenuButtonm<><6D>rDarkkdk::KMenuButtonmE<6D>rLightkdk::KMenuButton<04>Q<>Quitkdk::KMenuButton<04><>nSettingkdk::KMenuButtonY<16><>Themekdk::KMenuButtonf<>Ymorekdk::KMenuButtonS<>m<EFBFBD>cancelkdk::KProgressDialogd}"Searchkdk::KSearchLineEditPrivated}"searchkdk::KSearchLineEditPrivate<02><>Highkdk::KSecurityLevelBarONLowkdk::KSecurityLevelBarN-Mediumkdk::KSecurityLevelBarONLowkdk::KSecurityLevelBarPrivateST
<EFBFBD> deb name:kdk::KUninstallDialogrHg,<2C> deb version:kdk::KUninstallDialogz<>SsSx<53>} uninstallkdk::KUninstallDialogST
<EFBFBD> deb name:kdk::KUninstallDialogPrivaterHg,<2C> deb version:kdk::KUninstallDialogPrivateQs<51><73>closekdk::KWindowButtonBarPrivategY'Smaximizekdk::KWindowButtonBarPrivateg\Sminimizekdk::KWindowButtonBarPrivate<04><>S<EFBFBD>restorekdk::KWindowButtonBarPrivate
\ No newline at end of file
+<<3C>d<18><EFBFBD>!<1C>`<60><><EFBFBD>B[<01>SgzSg<04><02><><00><04><>\<04><><02><04><>I<05><02>G<><47><01>PHE<06>R<><52><02>Z<>|<05>Z<>5Ej6<6A>GlyzUt):t):<05><04><><EFBFBD>-;<3B><><04><05><><EFBFBD><03><06>I<EFBFBD><01><06>I<EFBFBD><03>g<>^s<07><><EFBFBD>ʶ<><06><08>H5<06> <09><02><00> ˰
+2<><32>M
+2<><32> <0C><><EFBFBD>X<>4ri;`<60>v<EFBFBD>|<7C>~<7E>g*[<5B><><EFBFBD>N<EFBFBD>OUu5[P<><50>N<EFBFBD>^<5E>u(.No mail applicaiton accessible in your system.kdk::KAboutDialog 0
+<2B><>y<EFBFBD>X<EFBFBD>f0 Privacy statementkdk::KAboutDialogg
R<EFBFBD>Ne/cV<><56><1F>Service & Support: kdk::KAboutDialoge<>l<EFBFBD>bS_<00><>N<EFBFBD>[<5B>b7z<37>Unable to open mail applicationkdk::KAboutDialog <0C><><EFBFBD><EFBFBD>QeepP<<3C>Enter a value:kdk::KInputDialogS<>m<EFBFBD>cancelkdk::KInputDialogPrivatexn<78><6E>okkdk::KInputDialogPrivateQsN<73>Aboutkdk::KMenuButton^.R<>Assistkdk::KMenuButton<08>ߖ<EFBFBD>|<7C>~<7E>Autokdk::KMenuButtonm<><6D>rDarkkdk::KMenuButtonmE<6D>rLightkdk::KMenuButton<04>Q<>Quitkdk::KMenuButton<04><>nSettingkdk::KMenuButtonY<16><>Themekdk::KMenuButton<04> <09>yoptionkdk::KMenuButtonS<>m<EFBFBD>cancelkdk::KProgressDialogd}"Searchkdk::KSearchLineEditPrivated}"searchkdk::KSearchLineEditPrivate<02><>Highkdk::KSecurityLevelBarONLowkdk::KSecurityLevelBarN-Mediumkdk::KSecurityLevelBarONLowkdk::KSecurityLevelBarPrivateST
<EFBFBD> deb name:kdk::KUninstallDialogrHg,<2C> deb version:kdk::KUninstallDialogz<>SsSx<53>} uninstallkdk::KUninstallDialogST
<EFBFBD> deb name:kdk::KUninstallDialogPrivaterHg,<2C> deb version:kdk::KUninstallDialogPrivateQs<51><73>closekdk::KWindowButtonBarPrivategY'Smaximizekdk::KWindowButtonBarPrivateg\Sminimizekdk::KWindowButtonBarPrivate<04><>S<EFBFBD>restorekdk::KWindowButtonBarPrivate
\ No newline at end of file
diff --git a/kysdk-qtwidgets/translations/gui_zh_CN.ts b/kysdk-qtwidgets/translations/gui_zh_CN.ts
index bdb451c..5bfe4b5 100644
--- a/kysdk-qtwidgets/translations/gui_zh_CN.ts
+++ b/kysdk-qtwidgets/translations/gui_zh_CN.ts
@@ -32,25 +32,25 @@
<context>
<name>kdk::KAboutDialog</name>
<message>
- <location filename="../src/kaboutdialog.cpp" line="90"/>
+ <location filename="../src/kaboutdialog.cpp" line="97"/>
<source>No mail applicaiton accessible in your system.</source>
<translation>您的系统未安装任何电子邮件应用</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="91"/>
+ <location filename="../src/kaboutdialog.cpp" line="98"/>
<source>Unable to open mail application</source>
<translation>无法打开邮件客户端</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="209"/>
- <location filename="../src/kaboutdialog.cpp" line="223"/>
+ <location filename="../src/kaboutdialog.cpp" line="230"/>
+ <location filename="../src/kaboutdialog.cpp" line="244"/>
<source>Service &amp; Support: </source>
<translatorcomment>服务与支持团队:</translatorcomment>
<translation>服务与支持团队:</translation>
</message>
<message>
- <location filename="../src/kaboutdialog.cpp" line="215"/>
- <location filename="../src/kaboutdialog.cpp" line="229"/>
+ <location filename="../src/kaboutdialog.cpp" line="236"/>
+ <location filename="../src/kaboutdialog.cpp" line="250"/>
<source>Privacy statement</source>
<translation>《隐私声明》</translation>
</message>
@@ -58,7 +58,7 @@
<context>
<name>kdk::KInputDialog</name>
<message>
- <location filename="../src/kinputdialog.cpp" line="205"/>
+ <location filename="../src/kinputdialog.cpp" line="220"/>
<source>Enter a value:</source>
<translation>请输入数值:</translation>
</message>
@@ -66,12 +66,12 @@
<context>
<name>kdk::KInputDialogPrivate</name>
<message>
- <location filename="../src/kinputdialog.cpp" line="214"/>
+ <location filename="../src/kinputdialog.cpp" line="229"/>
<source>ok</source>
<translation>确认</translation>
</message>
<message>
- <location filename="../src/kinputdialog.cpp" line="216"/>
+ <location filename="../src/kinputdialog.cpp" line="231"/>
<source>cancel</source>
<translation>取消</translation>
</message>
@@ -79,48 +79,52 @@
<context>
<name>kdk::KMenuButton</name>
<message>
- <location filename="../src/kmenubutton.cpp" line="39"/>
<source>more</source>
- <translation>更多</translation>
+ <translation type="vanished">更多</translation>
</message>
<message>
<location filename="../src/kmenubutton.cpp" line="40"/>
+ <source>option</source>
+ <translation>选项</translation>
+ </message>
+ <message>
+ <location filename="../src/kmenubutton.cpp" line="41"/>
<source>Setting</source>
<translatorcomment>设置</translatorcomment>
<translation>设置</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="41"/>
+ <location filename="../src/kmenubutton.cpp" line="42"/>
<source>Theme</source>
<translation>外观</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="42"/>
+ <location filename="../src/kmenubutton.cpp" line="43"/>
<source>Assist</source>
<translation>帮助</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="43"/>
+ <location filename="../src/kmenubutton.cpp" line="44"/>
<source>About</source>
<translation>关于</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="44"/>
+ <location filename="../src/kmenubutton.cpp" line="45"/>
<source>Quit</source>
<translation>退出</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="51"/>
+ <location filename="../src/kmenubutton.cpp" line="52"/>
<source>Auto</source>
<translation>跟随系统</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="53"/>
+ <location filename="../src/kmenubutton.cpp" line="54"/>
<source>Light</source>
<translation>浅色</translation>
</message>
<message>
- <location filename="../src/kmenubutton.cpp" line="55"/>
+ <location filename="../src/kmenubutton.cpp" line="56"/>
<source>Dark</source>
<translation>深色</translation>
</message>
@@ -128,7 +132,7 @@
<context>
<name>kdk::KProgressDialog</name>
<message>
- <location filename="../src/kprogressdialog.cpp" line="47"/>
+ <location filename="../src/kprogressdialog.cpp" line="48"/>
<source>cancel</source>
<translation>取消</translation>
</message>
@@ -153,12 +157,12 @@
<context>
<name>kdk::KSearchLineEditPrivate</name>
<message>
- <location filename="../src/ksearchlineedit.cpp" line="350"/>
+ <location filename="../src/ksearchlineedit.cpp" line="362"/>
<source>search</source>
<translation>搜索</translation>
</message>
<message>
- <location filename="../src/ksearchlineedit.cpp" line="441"/>
+ <location filename="../src/ksearchlineedit.cpp" line="463"/>
<source>Search</source>
<translation>搜索</translation>
</message>
@@ -256,22 +260,22 @@
<context>
<name>kdk::KWindowButtonBarPrivate</name>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="162"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="192"/>
<source>minimize</source>
<translation>最小化</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="218"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="246"/>
<source>maximize</source>
<translation>最大化</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="223"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="251"/>
<source>restore</source>
<translation>还原</translation>
</message>
<message>
- <location filename="../src/kwindowbuttonbar.cpp" line="173"/>
+ <location filename="../src/kwindowbuttonbar.cpp" line="201"/>
<source>close</source>
<translation>关闭</translation>
</message>
diff --git a/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp b/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp
index f5ef2b5..38b8769 100644
--- a/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp
+++ b/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp
@@ -64,8 +64,8 @@ bool UKUIDecorationManager::removeHeaderBar(QWindow *windowHandle)
auto nativeInterface = qApp->platformNativeInterface();
if(!windowHandle)
- return false;
-
+ return false;
+
wl_surface *surface = reinterpret_cast<wl_surface *>(nativeInterface->nativeResourceForWindow(QByteArrayLiteral("surface"), windowHandle));
if (!surface)
return false;
diff --git a/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp b/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp
index 9cd055b..89f3f3e 100644
--- a/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp
+++ b/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp
@@ -4,8 +4,8 @@
#include "xatom-helper.h"
#include <QWidget>
#include <QGuiApplication>
-#include <QDebug>
#include <QEvent>
+
namespace kdk {
static UkuiStyleHelper *global_instance = nullptr;
diff --git a/kysdk-widgetutils/kysdk-widgetutils.pro b/kysdk-widgetutils/kysdk-widgetutils.pro
index 7aaad6c..52cbd2d 100644
--- a/kysdk-widgetutils/kysdk-widgetutils.pro
+++ b/kysdk-widgetutils/kysdk-widgetutils.pro
@@ -1,9 +1,10 @@
-QT += widgets gui
+QT += widgets gui dbus
TEMPLATE = lib
DEFINES += KYSDKWIDGETUTILS_LIBRARY
-CONFIG += c++11
+CONFIG += c++11 link_pkgconfig
+PKGCONFIG += gsettings-qt
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
diff --git a/kysdk-widgetutils/src/kwidgetutils.cpp b/kysdk-widgetutils/src/kwidgetutils.cpp
index 9f6cce8..4343a4b 100644
--- a/kysdk-widgetutils/src/kwidgetutils.cpp
+++ b/kysdk-widgetutils/src/kwidgetutils.cpp
@@ -2,7 +2,14 @@
#include <QApplication>
#include <QGuiApplication>
#include <QDebug>
+#include <QtDBus/QtDBus>
+#include <QGSettings/QGSettings>
+#include <QByteArray>
+#include <QVariant>
+#define KWIN_SERVICE "org.ukui.KWin"
+#define KWIN_PATH "/Compositor"
+#define KWIN_INTERFACE "org.ukui.kwin.Compositing"
using namespace kdk;
KWidgetUtils::KWidgetUtils()
@@ -22,3 +29,43 @@ void KWidgetUtils::highDpiScaling()
qDebug()<<"setHighDpiScaleFactorRoundingPolicy success";
#endif
}
+
+bool KWidgetUtils::checkCompositorRunning()
+{
+ QDBusInterface dbus_iface (KWIN_SERVICE, KWIN_PATH, KWIN_INTERFACE, QDBusConnection::sessionBus());
+ QVariant reply = dbus_iface.property ("active");
+ bool isfoundCompositingManger = false;
+ if (reply.toBool()) {
+ isfoundCompositingManger = true;
+ }
+
+ if(!isfoundCompositingManger)
+ {
+ if(QGSettings::isSchemaInstalled("org.gnome.metacity"))
+ {
+ QProcess process;
+ process.start("sh -c \"ps -e |grep metacity\"");
+ if(process.waitForStarted(100)&&process.waitForFinished(100) && process.readAllStandardOutput().contains("metacity"))
+ {
+ QGSettings metacityGSettings("org.gnome.metacity", "/org/gnome/metacity/");
+ isfoundCompositingManger = metacityGSettings.get("compositing-manager").toBool();
+ }
+ }
+ }
+
+ if(!isfoundCompositingManger)
+ {
+ if(QGSettings::isSchemaInstalled("org.mate.Marco.general"))
+ {
+ QProcess process;
+ process.start("sh -c \"ps -e |grep marco\"");
+ if(process.waitForStarted(100)&&process.waitForFinished(100) && process.readAllStandardOutput().contains("marco"))
+ {
+ QGSettings marcoGSettings("org.mate.Marco.general", "/org/mate/marco/general/");
+ isfoundCompositingManger = marcoGSettings.get("compositing-manager").toBool();
+ }
+ }
+ }
+
+ return isfoundCompositingManger;
+}
diff --git a/kysdk-widgetutils/src/kwidgetutils.h b/kysdk-widgetutils/src/kwidgetutils.h
index c3bdf43..646e282 100644
--- a/kysdk-widgetutils/src/kwidgetutils.h
+++ b/kysdk-widgetutils/src/kwidgetutils.h
@@ -15,6 +15,17 @@ public:
* QApplication a(argc, argv);
*/
static void highDpiScaling();
+
+
+ /**
+ * @brief 判断合成器是否开启
+ *
+ * @param 无
+ *
+ * @retval true 开启
+ * @retval false 没开启
+ */
+ static bool checkCompositorRunning(void);
};
}
diff --git a/kysdk-widgetutils/test/testWidgetutils/testWidgetutils.pro b/kysdk-widgetutils/test/testWidgetutils/testWidgetutils.pro
index d6f84e6..e574409 100644
--- a/kysdk-widgetutils/test/testWidgetutils/testWidgetutils.pro
+++ b/kysdk-widgetutils/test/testWidgetutils/testWidgetutils.pro
@@ -1,10 +1,13 @@
-QT += core gui
+QT += core gui widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 link_pkgconfig
-PKGCONFIG += kysdk-widgetutils
+PKGCONFIG += kysdk-widgetutils gsettings-qt
+
+CONFIG += c++11 link_pkgconfig
+PKGCONFIG += gsettings-qt
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the