libkysdk-applications-2.2.1.1/0000775000175000017500000000000014474244170015126 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/0000775000175000017500000000000014474244170017401 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/kysdk-ukenv.pro0000664000175000017500000000076114474244170022402 0ustar adminadminQT += core dbus TARGET = kysdk-ukenv TEMPLATE = lib CONFIG += c++11 console link_pkgconfig PKGCONFIG += gsettings-qt HEADERS += src/usermanual.h \ src/currency.h \ src/gsettingmonitor.h SOURCES += src/usermanual.cpp \ src/currency.cpp \ src/gsettingmonitor.cpp # Default rules for deployment. headers.files = $${HEADERS} headers.path = /usr/include/kysdk/applications/ target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu INSTALLS += target headers libkysdk-applications-2.2.1.1/kysdk-ukenv/src/0000775000175000017500000000000014474244170020170 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/src/usermanual.cpp0000664000175000017500000000364514474244170023060 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include #include #include #include "usermanual.h" namespace kdk { namespace { constexpr char dbusObjectPath[] = "/"; constexpr char dbusInterfaceName[] = "com.guide.hotel"; constexpr char dbusCallUserManualMethod[] = "showGuide"; } // namespace UserManual::UserManual() = default; UserManual::~UserManual() = default; bool UserManual::callUserManual(QString appName) { if (appName.isEmpty()) { return false; } const QString dbusServiceName = QString("com.kylinUserGuide.hotel") + QString("_") + QString::number(getuid()); QDBusMessage message = QDBusMessage::createMethodCall(dbusServiceName, dbusObjectPath, dbusInterfaceName, dbusCallUserManualMethod); QList args; args << appName; message.setArguments(args); QDBusMessage ret = QDBusConnection::sessionBus().call(message); if (ret.type() == QDBusMessage::InvalidMessage || ret.type() == QDBusMessage::ErrorMessage) { qCritical() << "kdk : user manual d-bus call fail!"; return false; } return true; } } // namespace kdk libkysdk-applications-2.2.1.1/kysdk-ukenv/src/currency.h0000664000175000017500000000352314474244170022176 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #ifndef KYSDK_UKENV_CURRENCY_H_ #define KYSDK_UKENV_CURRENCY_H_ #include namespace kdk { enum AppName { KylinIpmsg = 0, /* 传书 */ KylinFontViewer, /* 字体管理器 */ KylinCalculator, /* 麒麟计算器 */ KylinGpuController, /* 显卡控制器 */ KylinMusic, /* 音乐 */ KylinWeather, /* 天气 */ KylinPhotoViewer, /* 看图 */ KylinServiceSupport, /* 服务与支持 */ KylinPrinter, /* 麒麟打印 */ KylinCalendar, /* 日历 */ KylinRecorder, /* 录音 */ KylinCamera, /* 摄像头 */ KylinNotebook, /* 便签 */ KylinOsManager, /* 麒麟管家 */ KylinNetworkCheck, /* 网络检测工具 */ KylinGallery, /* 相册 */ KylinScanner, /* 扫描 */ KylinMobileAssistant, /* 多端协同 */ KylinTest /* 测试预留 */ }; class Currency { public: Currency(); ~Currency(); static QString getAppName(AppName appName); }; } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-ukenv/src/currency.cpp0000664000175000017500000000465214474244170022535 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include "currency.h" namespace kdk { Currency::Currency() = default; Currency::~Currency() = default; QString Currency::getAppName(AppName appName) { switch (appName) { case AppName::KylinCalculator: return QString("kylin-calaulator"); case AppName::KylinCalendar: return QString("kylin-calendar"); case AppName::KylinCamera: return QString("kylin-camera"); case AppName::KylinFontViewer: return QString("kylin-font-viewer"); case AppName::KylinGpuController: return QString("kylin-gpu-controller"); case AppName::KylinIpmsg: return QString("kylin-ipmsg"); case AppName::KylinMusic: return QString("kylin-music"); case AppName::KylinPhotoViewer: return QString("kylin-photo-viewer"); case AppName::KylinPrinter: return QString("kylin-printer"); case AppName::KylinRecorder: return QString("kylin-recorder"); case AppName::KylinServiceSupport: return QString("kylin-service-support"); case AppName::KylinWeather: return QString("kylin-weather"); case AppName::KylinNotebook: return QString("kylin-notebook"); case AppName::KylinOsManager: return QString("kylin-os-manager"); case AppName::KylinNetworkCheck: return QString("kylin-network-check-tools"); case AppName::KylinGallery: return QString("kylin-gallery"); case AppName::KylinScanner: return QString("kylin-scanner"); case AppName::KylinMobileAssistant: return QString("kylin-mobile-assistant"); default: return QString(""); } /* 不应该被执行 */ return ""; } } libkysdk-applications-2.2.1.1/kysdk-ukenv/src/usermanual.h0000664000175000017500000000225214474244170022516 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #ifndef KYSDK_UKENV_USERMANUAL_H_ #define KYSDK_UKENV_USERMANUAL_H_ #include namespace kdk { class UserManual { public: UserManual(); ~UserManual(); /** * @brief 调用用户手册 * * @param appName 应用名 * * @retval true 成功 * @retval false 失败 */ bool callUserManual(QString appName); }; } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-ukenv/src/gsettingmonitor.cpp0000664000175000017500000001130314474244170024126 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include #include "gsettingmonitor.h" namespace kdk { namespace { constexpr char themeSchemasId[] = "org.ukui.style"; constexpr char controlCenterPersonaliseSchemasId[] = "org.ukui.control-center.personalise"; constexpr char systemFontSizeKey[] = "systemFontSize"; constexpr char systemTransparencyKey[] = "transparency"; constexpr char systemThemeKey[] = "styleName"; constexpr char themeFlag[] = "__themeFlag"; constexpr char controlCenterPersonaliseFlag[] = "__controlCenterPersonaliseFlag"; QHash g_gsettings; } // namespace GsettingMonitor GsettingMonitor::m_gsettingMonitor; GsettingMonitor::GsettingMonitor() { if (!GsettingMonitor::registerGsetting(themeFlag, themeSchemasId)) { qCritical() << "kdk : register org.ukui.style gsetting fail!"; } if (!GsettingMonitor::registerGsetting(controlCenterPersonaliseFlag, controlCenterPersonaliseSchemasId)) { qCritical() << "kdk : register org.ukui.control-center.personalise gsetting fail!"; } conn(); } GsettingMonitor::~GsettingMonitor() { for (QHash::iterator it = g_gsettings.begin(); it != g_gsettings.end(); it++) { QGSettings *s = it.value(); if (s != nullptr) { delete s; s = nullptr; } } g_gsettings.clear(); } GsettingMonitor *GsettingMonitor::getInstance(void) { return &m_gsettingMonitor; } bool GsettingMonitor::registerGsetting(QString flag, QByteArray schemasId) { QGSettings *s = nullptr; if (g_gsettings.contains(flag)) { qCritical() << "kdk : gsettings flag repeat!"; return false; } if (QGSettings::isSchemaInstalled(schemasId)) { s = new QGSettings(schemasId); } else { qCritical() << "kdk : gsettings schemasId not fount!"; return false; } g_gsettings.insert(flag, s); return true; } QVariant GsettingMonitor::getSystemFontSize(void) { QGSettings *s = nullptr; if (g_gsettings.contains(themeFlag)) { s = g_gsettings.value(themeFlag); } if (s != nullptr && s->keys().contains(systemFontSizeKey)) { return s->get(systemFontSizeKey); } return QVariant(); } QVariant GsettingMonitor::getSystemTransparency(void) { QGSettings *s = nullptr; if (g_gsettings.contains(controlCenterPersonaliseFlag)) { s = g_gsettings.value(controlCenterPersonaliseFlag); } if (s != nullptr && s->keys().contains(systemTransparencyKey)) { return s->get(systemTransparencyKey); } return QVariant(); } QVariant GsettingMonitor::getSystemTheme(void) { QGSettings *s = nullptr; if (g_gsettings.contains(themeFlag)) { s = g_gsettings.value(themeFlag); } if (s != nullptr && s->keys().contains(systemThemeKey)) { return s->get(systemThemeKey); } return QVariant(); } void GsettingMonitor::conn(void) { QGSettings *theme = nullptr; QGSettings *control = nullptr; if (g_gsettings.contains(themeFlag)) { theme = g_gsettings.value(themeFlag); } if (g_gsettings.contains(controlCenterPersonaliseFlag)) { control = g_gsettings.value(controlCenterPersonaliseFlag); } if (theme != nullptr) { QObject::connect(theme, &QGSettings::changed, this, &GsettingMonitor::themeChange); } if (control != nullptr) { QObject::connect(control, &QGSettings::changed, this, &GsettingMonitor::controlCenterPersonaliseChange); } return; } void GsettingMonitor::themeChange(QString key) { if (key == QString(systemThemeKey)) { Q_EMIT systemThemeChange(); } else if (key == QString(systemFontSizeKey)) { Q_EMIT systemFontSizeChange(); } return; } void GsettingMonitor::controlCenterPersonaliseChange(QString key) { if (key == QString(systemTransparencyKey)) { Q_EMIT systemTransparencyChange(); } return; } } // namespace kdk libkysdk-applications-2.2.1.1/kysdk-ukenv/src/gsettingmonitor.h0000664000175000017500000000416214474244170023600 0ustar adminadmin/* * libkysdk-ukenv's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #ifndef KYSDK_UKENV_GSETTINGMONITOR_H_ #define KYSDK_UKENV_GSETTINGMONITOR_H_ #include #include #include #include namespace kdk { class GsettingMonitor : public QObject { Q_OBJECT public: ~GsettingMonitor(); /** * @brief 获取单例指针 * * @param 无 * * @return 获取到的单例指针 */ static GsettingMonitor *getInstance(void); /** * @brief 获取系统字号 * * @param 无 * * @return 获取到的系统字号 */ static QVariant getSystemFontSize(void); /** * @brief 获取系统透明度 * * @param 无 * * @return 获取到的系统透明度 */ static QVariant getSystemTransparency(void); /** * @brief 获取系统主题 * * @param 无 * * @return 获取到的系统主题 */ static QVariant getSystemTheme(void); Q_SIGNALS: void systemFontSizeChange(); void systemTransparencyChange(); void systemThemeChange(); private Q_SLOTS: void themeChange(QString key); void controlCenterPersonaliseChange(QString key); private: GsettingMonitor(); void conn(void); static bool registerGsetting(QString flag, QByteArray schemasId); static GsettingMonitor m_gsettingMonitor; }; } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-ukenv/test/0000775000175000017500000000000014474244076020365 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/0000775000175000017500000000000014474244170023434 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/testusermanual.pro0000664000175000017500000000020414474244076027233 0ustar adminadminQT += widgets TARGET = testusermanual TEMPLATE = app CONFIG += c++11 link_pkgconfig PKGCONFIG += kysdk-ukenv SOURCES += main.cpplibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/main.cpp0000664000175000017500000000215414474244170025066 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include "usermanual.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); /* 调用用户手册 */ kdk::UserManual userManual; if (!userManual.callUserManual("messages")) { qCritical() << "call user manual fail!"; return -1; } return app.exec(); } libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/0000775000175000017500000000000014474244170023112 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/main.cpp0000664000175000017500000000175714474244170024554 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include "currency.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); qDebug() << kdk::Currency::getAppName(kdk::AppName::KylinIpmsg); app.exec(); } libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/testcurrency.pro0000664000175000017500000000020614474244076026371 0ustar adminadminQT += core TARGET = testcurrency TEMPLATE = app CONFIG += c++11 console link_pkgconfig PKGCONFIG += kysdk-ukenv SOURCES += main.cpplibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/0000775000175000017500000000000014474244170024514 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/testgsettingmonitor.pro0000664000175000017500000000023214474244076031374 0ustar adminadminQT += core TARGET = testgsettingmonitor TEMPLATE = app CONFIG += c++11 console link_pkgconfig PKGCONFIG += gsettings-qt kysdk-ukenv SOURCES += main.cpplibkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/main.cpp0000664000175000017500000000346714474244170026156 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include #include "gsettingmonitor.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); qDebug() << "系统字号 : " << kdk::GsettingMonitor::getSystemFontSize(); qDebug() << "系统透明度 : " << kdk::GsettingMonitor::getSystemTransparency(); qDebug() << "系统主题" << kdk::GsettingMonitor::getSystemTheme(); QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemFontSizeChange, [=]() { qDebug() << "系统字号改变 : " << kdk::GsettingMonitor::getSystemFontSize(); }); QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemThemeChange, [=]() { qDebug() << "系统主题改变 : " << kdk::GsettingMonitor::getSystemTheme(); }); QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemTransparencyChange, [=]() { qDebug() << "系统透明度改变 : " << kdk::GsettingMonitor::getSystemTransparency(); }); return app.exec(); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/0000775000175000017500000000000014474244170021110 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/readme.md0000664000175000017500000000000014474244076022662 0ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/kysdk-waylandhelper.pro0000664000175000017500000000570414474244170025622 0ustar adminadminQT += KWaylandClient KWaylandServer gui widgets x11extras KWindowSystem KIconThemes TEMPLATE = lib DEFINES += KYSDKWAYLANDHELPER_LIBRARY CONFIG += c++11 link_pkgconfig PKGCONFIG += wayland-client x11 # 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/ukuistylehelper/ukui-decoration-core.c \ src/ukuistylehelper/ukui-decoration-manager.cpp \ src/ukuistylehelper/ukuistylehelper.cpp \ src/ukuistylehelper/xatom-helper.cpp \ src/waylandhelper.cpp \ src/windowmanager/abstractinterface.cpp \ src/windowmanager/waylandinterface.cpp \ src/windowmanager/wmregister.cpp \ src/windowmanager/xcbinterface.cpp \ src/windowmanager/windowmanager.cpp HEADERS += \ src/ukuistylehelper/ukui-decoration-client.h \ src/ukuistylehelper/ukui-decoration-manager.h \ src/ukuistylehelper/ukuistylehelper.h \ src/ukuistylehelper/xatom-helper.h \ src/waylandhelper.h \ src/windowmanager/abstractinterface.h \ src/windowmanager/waylandinterface.h \ src/windowmanager/windowinfo.h \ src/windowmanager/wmregister.h \ src/windowmanager/xcbinterface.h \ src/windowmanager/windowmanager.h \ src/kysdk-waylandhelper_global.h #kysdk-waylandhelper/src/*.h usr/include/kysdk/applications/ #kysdk-waylandhelper/src/ukuistylehelper/*.h usr/include/kysdk/applications/ukuistylehelper/ #kysdk-waylandhelper/src/windowmanager/*.h usr/include/kysdk/applications/windowmanager/ # Default rules for deployment. headers.files = src/kysdk-waylandhelper_global.h \ src/waylandhelper.h headers.path = /usr/include/kysdk/applications/ wm_headers.files = src/windowmanager/abstractinterface.h \ src/windowmanager/waylandinterface.h \ src/windowmanager/windowinfo.h \ src/windowmanager/wmregister.h \ src/windowmanager/xcbinterface.h \ src/windowmanager/windowmanager.h wm_headers.path = /usr/include/kysdk/applications/windowmanager/ sty_headers.files = src/ukuistylehelper/ukui-decoration-client.h \ src/ukuistylehelper/ukui-decoration-manager.h \ src/ukuistylehelper/ukuistylehelper.h \ src/ukuistylehelper/xatom-helper.h sty_headers.path = /usr/include/kysdk/applications/ukuistylehelper/ target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu INSTALLS += target headers wm_headers sty_headers libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/0000775000175000017500000000000014474244170021677 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/0000775000175000017500000000000014474244170024541 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowmanager.cpp0000664000175000017500000001421714474244170030114 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "windowmanager.h" #include #include #include using namespace kdk; static WindowManager* g_windowmanger = nullptr; static WmRegister* m_wm =nullptr; kdk::WindowManager::WindowManager(QObject *parent) :QObject(parent) { m_wm = new WmRegister(this); connect(m_wm->winInterface(),&AbstractInterface::windowAdded,this,&WindowManager::windowAdded); connect(m_wm->winInterface(),&AbstractInterface::windowRemoved,this,&WindowManager::windowRemoved); connect(m_wm->winInterface(),&AbstractInterface::activeWindowChanged,this,&WindowManager::activeWindowChanged); connect(m_wm->winInterface(),&AbstractInterface::windowChanged,this,&WindowManager::windowChanged); connect(m_wm->winInterface(),&AbstractInterface::currentDesktopChanged,this,&WindowManager::currentDesktopChanged); connect(m_wm->winInterface(),&AbstractInterface::isShowingDesktopChanged,this,&WindowManager::isShowingDesktopChanged); } WindowId WindowManager::currentActiveWindow() { self(); if(!m_wm) return QVariant(); return m_wm->winInterface()->activeWindow(); } void WindowManager::keepWindowAbove(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->requestToggleKeepAbove(windowId); } QString WindowManager::getWindowTitle(const WindowId &windowId) { self(); if(!m_wm) return QString(); return m_wm->winInterface()->titleFor(windowId); } QIcon WindowManager::getWindowIcon(const WindowId &windowId) { self(); if(!m_wm) return QIcon(); return m_wm->winInterface()->iconFor(windowId); } QString WindowManager::getWindowGroup(const WindowId &windowId) { if(!m_wm) return QString(); self(); return m_wm->winInterface()->windowGroupFor(windowId); } void WindowManager::closeWindow(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->requestClose(windowId); } void WindowManager::activateWindow(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->requestActivate(windowId); } void WindowManager::maximizeWindow(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->requestToggleMaximized(windowId); } void WindowManager::minimizeWindow(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->requestToggleMinimized(windowId); } quint32 WindowManager::getPid(const WindowId &windowId) { self(); quint32 pid = 0; if(!m_wm) return pid; pid = m_wm->winInterface()->pid(windowId); return pid; } WindowManager *WindowManager::self() { if(g_windowmanger) return g_windowmanger; g_windowmanger = new WindowManager(); return g_windowmanger; } WindowInfo WindowManager::getwindowInfo(const WindowId &windowId) { self(); if(!m_wm) return WindowInfo(); return m_wm->winInterface()->requestInfo(windowId); } void WindowManager::showDesktop() { self(); if(!m_wm) return; m_wm->winInterface()->showCurrentDesktop(); } void WindowManager::hideDesktop() { self(); if(!m_wm) return; m_wm->winInterface()->hideCurrentDesktop(); } QString WindowManager::currentDesktop() { self(); if(!m_wm) return 0; return m_wm->winInterface()->currentDesktop(); } QList WindowManager::windows() { self(); if(!m_wm) return QList(); return m_wm->winInterface()->windows(); } NET::WindowType WindowManager::getWindowType(const WindowId &windowId) { self(); if(!m_wm) return NET::WindowType::Unknown; return m_wm->winInterface()->windowType(windowId); } void WindowManager::setGeometry(QWindow *window, const QRect &rect) { self(); if(!m_wm) return; m_wm->winInterface()->setGeometry(window,rect); } void WindowManager::setSkipTaskBar(QWindow *window, bool skip) { self(); if(!m_wm) return; m_wm->winInterface()->setSkipTaskBar(window,skip); } void WindowManager::setSkipSwitcher(QWindow *window, bool skip) { self(); if(!m_wm) return; m_wm->winInterface()->setSkipSwitcher(window,skip); } bool WindowManager::skipTaskBar(const WindowId &windowId) { self(); if(!m_wm) return false; return m_wm->winInterface()->skipTaskBar(windowId); } bool WindowManager::skipSwitcher(const WindowId &windowId) { self(); if(!m_wm) return false; return m_wm->winInterface()->skipSwitcher(windowId); } bool WindowManager::isShowingDesktop() { self(); if(!m_wm) return false; return m_wm->winInterface()->isShowingDesktop(); } void WindowManager::setOnAllDesktops(const WindowId &windowId) { self(); if(!m_wm) return; m_wm->winInterface()->setOnAllDesktops(windowId); } bool WindowManager::isOnAllDesktops(const WindowId &windowId) { kdk::WindowInfo windowInfo = WindowManager::getwindowInfo(windowId); return windowInfo.isOnAllDesktops(); } bool WindowManager::isOnCurrentDesktop(const WindowId &windowId) { kdk::WindowInfo windowinfo = WindowManager::getwindowInfo(windowId); return windowinfo.isOnDesktop(currentDesktop()); } bool WindowManager::isOnDesktop(const WindowId &windowId, int desktop) { kdk::WindowInfo windowinfo = WindowManager::getwindowInfo(windowId); return windowinfo.isOnDesktop(QString::number(desktop)); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/wmregister.h0000664000175000017500000000227514474244170027110 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WMREGISTER_H #define WMREGISTER_H #include #include "../kysdk-waylandhelper_global.h" #include "abstractinterface.h" namespace kdk { class KYSDKWAYLANDHELPER_EXPORT WmRegister:public QObject { public: WmRegister(QObject*parent = nullptr); ~WmRegister(); AbstractInterface* winInterface(); private: AbstractInterface *m_winInterface{nullptr}; }; } #endif // WMREGISTER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/abstractinterface.h0000664000175000017500000000602714474244170030403 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef ABSTRACTINTERFACE_H #define ABSTRACTINTERFACE_H #include #include #include #include "windowinfo.h" #include "netwm.h" namespace kdk { using WindowId = QVariant; class KWindows; class AbstractInterface:public QObject { Q_OBJECT public: AbstractInterface(QObject* parent=nullptr); virtual ~AbstractInterface(); virtual WindowInfo requestInfo(WindowId wid) = 0; virtual void requestActivate(WindowId wid) = 0; virtual void requestClose(WindowId wid) = 0; virtual void requestToggleKeepAbove(WindowId wid) = 0; virtual void requestToggleMinimized(WindowId wid) = 0; virtual void requestToggleMaximized(WindowId wid) = 0; virtual WindowId activeWindow() = 0; virtual QIcon iconFor(WindowId wid) = 0; virtual QString titleFor(WindowId wid) = 0; virtual QString windowGroupFor(WindowId wid) = 0; virtual bool windowCanBeDragged(WindowId wid) = 0; virtual bool windowCanBeMaximized(WindowId wid) = 0; virtual void showCurrentDesktop() = 0; virtual void hideCurrentDesktop() = 0; virtual quint32 pid(WindowId wid) = 0; virtual void setGeometry(QWindow *window, const QRect &rect) = 0; virtual NET::WindowType windowType(WindowId wid) = 0; virtual void setSkipTaskBar(QWindow* window,bool skip) = 0; virtual void setSkipSwitcher(QWindow* window,bool skip) = 0; virtual bool skipTaskBar(const WindowId &wid) = 0; virtual bool skipSwitcher(const WindowId &wid) = 0; virtual bool isShowingDesktop() = 0; virtual void setOnAllDesktops(const WindowId &wid) = 0; bool inCurrentDesktopActivity(const WindowInfo &winfo) ; bool isPlasmaDesktop(const QRect &wGeometry); QString currentDesktop() ; QString currentActivity() ; void setPlasmaDesktop(WindowId wid); bool isValidFor(const WindowId &wid) ; QList windows(); Q_SIGNALS: void activeWindowChanged(WindowId wid); void windowChanged(WindowId winfo); void windowAdded(WindowId wid); void windowRemoved(WindowId wid); void currentDesktopChanged(); void isShowingDesktopChanged(); public: QMap m_windows; QString m_currentDesktop; QString m_currentActivity; }; } #endif // ABSTRACTINTERFACE_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/abstractinterface.cpp0000664000175000017500000000433114474244170030732 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "abstractinterface.h" #include #include #include using namespace kdk; AbstractInterface::AbstractInterface(QObject *parent) :QObject(parent) { } AbstractInterface::~AbstractInterface() { } bool AbstractInterface::inCurrentDesktopActivity(const WindowInfo &winfo) { if(winfo.isValid() && winfo.isOnDesktop(currentDesktop())) return (winfo.isValid() && winfo.isOnDesktop(currentDesktop()) /*&& winfo.isOnActivity(currentActivity())*/); } bool AbstractInterface::isPlasmaDesktop(const QRect &wGeometry) { if (wGeometry.isEmpty()) { return false; } for (const auto scr : qGuiApp->screens()) { if (wGeometry == scr->geometry()) { return true; } } return false; } QString AbstractInterface::currentDesktop() { return m_currentDesktop; } QString AbstractInterface::currentActivity() { return m_currentActivity; } void AbstractInterface::setPlasmaDesktop(WindowId wid) { if (!m_windows.contains(wid)) { return; } if (!m_windows[wid].isPlasmaDesktop()) { m_windows[wid].setIsPlasmaDesktop(true); //updateAllHints(); } } bool AbstractInterface::isValidFor(const WindowId &wid) { if (!m_windows.contains(wid)) { return false; } return m_windows[wid].isValid() && !m_windows[wid].isPlasmaDesktop(); } QList AbstractInterface::windows() { return m_windows.keys(); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowmanager.h0000664000175000017500000001311014474244170027550 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WINDOWMANAGER_H #define WINDOWMANAGER_H #include #include #include #include "windowinfo.h" #include "wmregister.h" namespace kdk { using WindowId = QVariant; class WindowManager : public QObject { Q_OBJECT public: /** * @brief self * @return */ static WindowManager* self(); /** * @brief 获取窗口信息 * @param windowId * @return */ static WindowInfo getwindowInfo(const WindowId& windowId); /** * @brief 获取当前活动窗口 * @return */ static WindowId currentActiveWindow(); /** * @brief 置顶窗口 * @param windowId */ static void keepWindowAbove(const WindowId& windowId); /** * @brief 获取窗口标题 * @param windowId * @return */ static QString getWindowTitle(const WindowId& windowId); /** * @brief 获取窗口图标 * @param windowId * @return */ static QIcon getWindowIcon(const WindowId& windowId); /** * @brief 获取窗口所在组的组名 * @param windowId * @return */ static QString getWindowGroup(const WindowId& windowId); /** * @brief 关闭窗口 * @param windowId */ static void closeWindow(const WindowId& windowId); /** * @brief 激活窗口 * @param windowId */ static void activateWindow(const WindowId& windowId); /** * @brief 最大化窗口 * @param windowId */ static void maximizeWindow(const WindowId& windowId); /** * @brief 最小化窗口 * @param windowId */ static void minimizeWindow(const WindowId& windowId); /** * @brief 获取窗口进程pid * @return */ static quint32 getPid(const WindowId& windowId); /** * @brief 显示当前桌面 */ static void showDesktop(); /** * @brief 取消显示当前桌面 */ static void hideDesktop(); /** * @brief 获取当前桌面的名称 * @return */ static QString currentDesktop(); /** * @brief 获取当前窗口列表 * @return */ static QList windows(); /** * @brief 获取窗口类型,仅适用于X环境下,wayland下统一返回normal * @param windowId * @return */ static NET::WindowType getWindowType(const WindowId& windowId); /** * @brief 设置窗口位置 * @param window * @param rect */ static void setGeometry(QWindow *window,const QRect &rect); /** * @brief 设置是否跳过任务栏,since 2.0 * @param window * @param skip */ static void setSkipTaskBar(QWindow *window,bool skip); /** * @brief 设置是否跳过窗口选择,,since 2.0 * @param window * @param skip */ static void setSkipSwitcher(QWindow *window,bool skip); /** * @brief 判断窗体是否跳过任务栏,since 2.0 * @param windowId * @return */ static bool skipTaskBar(const WindowId& windowId); /** * @brief 判断窗体是否跳过窗口选择,since 2.0 * @param windowId * @return */ static bool skipSwitcher(const WindowId& windowId); /** * @brief 判断桌面是否处于显示状态,,since 2.0 * @return */ static bool isShowingDesktop(); /** * @brief 设置窗口在所有桌面中显示,since 2.0 * @param wid */ static void setOnAllDesktops(const WindowId &windowId); /** * @brief 判断窗口在所有桌面中显示,since 2.0 * @param windowId * @return */ static bool isOnAllDesktops(const WindowId &windowId); /** * @brief 判断窗口是否在当前桌面 * @param 窗口id * @return */ static bool isOnCurrentDesktop(const WindowId& id); /** * @brief 判断窗口是否在指定桌面 * @param 窗口id * @param 桌面id * @return */ static bool isOnDesktop(const WindowId &id, int desktop); Q_SIGNALS: /** * @brief 窗口添加信号 * @param windowId */ void windowAdded(const WindowId& windowId); /** * @brief 窗口删除信号 * @param windowId */ void windowRemoved(const WindowId& windowId); /** * @brief 活动窗口改变信号 * @param wid */ void activeWindowChanged(const WindowId& wid); /** * @brief 窗口改变信号 * @param wid */ void windowChanged(const WindowId& wid); /** * @brief 当前桌面改变信号 * @param wid */ void currentDesktopChanged(); /** * @brief 桌面显示状态变化信号 */ void isShowingDesktopChanged(); private: WindowManager(QObject *parent = nullptr); }; } #endif // WINDOWMANAGER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/netwm.h0000664000175000017500000015260314474244170026053 0ustar adminadmin/* Copyright (c) 2000 Troll Tech AS Copyright (c) 2003 Lubos Lunak Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef netwm_h #define netwm_h #include #include #include #if KWINDOWSYSTEM_HAVE_X11 #include #include #include "netwm_def.h" #define KDE_ALL_ACTIVITIES_UUID "00000000-0000-0000-0000-000000000000" // forward declaration struct NETRootInfoPrivate; struct NETWinInfoPrivate; template class NETRArray; /** Common API for root window properties/protocols. The NETRootInfo class provides a common API for clients and window managers to set/read/change properties on the root window as defined by the NET Window Manager Specification.. @author Bradley T. Hughes @see NET @see NETWinInfo **/ class KWINDOWSYSTEM_EXPORT NETRootInfo : public NET { public: /** Indexes for the properties array. **/ // update also NETRootInfoPrivate::properties[] size when extending this enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS, PROPERTIES_SIZE }; /** Window Managers should use this constructor to create a NETRootInfo object, which will be used to set/update information stored on the rootWindow. The application role is automatically set to WindowManager when using this constructor. @param connection XCB connection @param supportWindow The Window id of the supportWindow. The supportWindow must be created by the window manager as a child of the rootWindow. The supportWindow must not be destroyed until the Window Manager exits. @param wmName A string which should be the window manager's name (ie. "KWin" or "Blackbox"). @param properties The properties the window manager supports @param windowTypes The window types the window manager supports @param states The states the window manager supports @param properties2 The properties2 the window manager supports @param actions The actions the window manager supports @param screen For Window Managers that support multiple screen (ie. "multiheaded") displays, the screen number may be explicitly defined. If this argument is omitted, the default screen will be used. @param doActivate true to activate the window **/ NETRootInfo(xcb_connection_t *connection, xcb_window_t supportWindow, const char *wmName, NET::Properties properties, NET::WindowTypes windowTypes, NET::States states, NET::Properties2 properties2, NET::Actions actions, int screen = -1, bool doActivate = true); /** Clients should use this constructor to create a NETRootInfo object, which will be used to query information set on the root window. The application role is automatically set to Client when using this constructor. @param connection XCB connection @param properties The properties the client is interested in. @param properties2 The properties2 the client is interested in. @param properties_size The number of elements in the properties array. @param screen For Clients that support multiple screen (ie. "multiheaded") displays, the screen number may be explicitly defined. If this argument is omitted, the default screen will be used. @param doActivate true to call activate() to do an initial data read/update of the query information. **/ NETRootInfo(xcb_connection_t *connection, NET::Properties properties, NET::Properties2 properties2 = NET::Properties2(), int screen = -1, bool doActivate = true); /** Creates a shared copy of the specified NETRootInfo object. @param rootinfo the NETRootInfo object to copy **/ NETRootInfo(const NETRootInfo &rootinfo); /** Destroys the NETRootInfo object. **/ virtual ~NETRootInfo(); /** Returns the xcb connection used. @return the XCB connection **/ xcb_connection_t *xcbConnection() const; /** Returns the Window id of the rootWindow. @return the id of the root window **/ xcb_window_t rootWindow() const; /** Returns the Window id of the supportWindow. @return the id of the support window **/ xcb_window_t supportWindow() const; /** Returns the name of the Window Manager. @return the name of the window manager **/ const char *wmName() const; /** Sets the given property if on is true, and clears the property otherwise. In WindowManager mode this function updates _NET_SUPPORTED. In Client mode this function does nothing. @since 4.4 **/ void setSupported(NET::Property property, bool on = true); /** @overload @since 4.4 **/ void setSupported(NET::Property2 property, bool on = true); /** @overload @since 4.4 **/ void setSupported(NET::WindowTypeMask property, bool on = true); /** @overload @since 4.4 **/ void setSupported(NET::State property, bool on = true); /** @overload @since 4.4 **/ void setSupported(NET::Action property, bool on = true); /** Returns true if the given property is supported by the window manager. Note that for Client mode, NET::Supported needs to be passed in the properties argument for this to work. **/ bool isSupported(NET::Property property) const; /** @overload **/ bool isSupported(NET::Property2 property) const; /** @overload **/ bool isSupported(NET::WindowTypeMask type) const; /** @overload **/ bool isSupported(NET::State state) const; /** @overload **/ bool isSupported(NET::Action action) const; /** In the Window Manager mode, this is equivalent to the properties argument passed to the constructor. In the Client mode, if NET::Supported was passed in the properties argument, the returned value are all properties supported by the Window Manager. Other supported protocols and properties are returned by the specific methods. @see supportedProperties2() @see supportedStates() @see supportedWindowTypes() @see supportedActions() **/ NET::Properties supportedProperties() const; /** * In the Window Manager mode, this is equivalent to the properties2 * argument passed to the constructor. In the Client mode, if * NET::Supported was passed in the properties argument, the returned * value are all properties2 supported by the Window Manager. Other supported * protocols and properties are returned by the specific methods. * @see supportedProperties() * @see supportedStates() * @see supportedWindowTypes() * @see supportedActions() * @since 5.0 **/ NET::Properties2 supportedProperties2() const; /** * In the Window Manager mode, this is equivalent to the states * argument passed to the constructor. In the Client mode, if * NET::Supported was passed in the properties argument, the returned * value are all states supported by the Window Manager. Other supported * protocols and properties are returned by the specific methods. * @see supportedProperties() @see supportedProperties2() * @see supportedWindowTypes() * @see supportedActions() * @since 5.0 **/ NET::States supportedStates() const; /** * In the Window Manager mode, this is equivalent to the windowTypes * argument passed to the constructor. In the Client mode, if * NET::Supported was passed in the properties argument, the returned * value are all window types supported by the Window Manager. Other supported * protocols and properties are returned by the specific methods. * @see supportedProperties() @see supportedProperties2() * @see supportedStates() * @see supportedActions() * @since 5.0 **/ NET::WindowTypes supportedWindowTypes() const; /** * In the Window Manager mode, this is equivalent to the actions * argument passed to the constructor. In the Client mode, if * NET::Supported was passed in the properties argument, the returned * value are all actions supported by the Window Manager. Other supported * protocols and properties are returned by the specific methods. * @see supportedProperties() @see supportedProperties2() * @see supportedStates() * @see supportedWindowTypes() * @since 5.0 **/ NET::Actions supportedActions() const; /** * @returns the properties argument passed to the constructor. * @see passedProperties2() * @see passedStates() * @see passedWindowTypes() * @see passedActions() **/ NET::Properties passedProperties() const; /** * @returns the properties2 argument passed to the constructor. * @see passedProperties() * @see passedStates() * @see passedWindowTypes() * @see passedActions() * @since 5.0 **/ NET::Properties2 passedProperties2() const; /** * @returns the states argument passed to the constructor. * @see passedProperties() * @see passedProperties2() * @see passedWindowTypes() * @see passedActions() * @since 5.0 **/ NET::States passedStates() const; /** * @returns the windowTypes argument passed to the constructor. * @see passedProperties() * @see passedProperties2() * @see passedStates() * @see passedActions() * @since 5.0 **/ NET::WindowTypes passedWindowTypes() const; /** * @returns the actions argument passed to the constructor. * @see passedProperties() * @see passedProperties2() * @see passedStates() * @see passedWindowTypes() * @since 5.0 **/ NET::Actions passedActions() const; /** Returns an array of Window id's, which contain all managed windows. @return the array of Window id's @see clientListCount() **/ const xcb_window_t *clientList() const; /** Returns the number of managed windows in clientList array. @return the number of managed windows in the clientList array @see clientList() **/ int clientListCount() const; /** Returns an array of Window id's, which contain all managed windows in stacking order. @return the array of Window id's in stacking order @see clientListStackingCount() **/ const xcb_window_t *clientListStacking() const; /** Returns the number of managed windows in the clientListStacking array. @return the number of Window id's in the client list @see clientListStacking() **/ int clientListStackingCount() const; /** Returns the desktop geometry size. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. You should use calls for virtual desktops, viewport is mapped to them if needed. @return the size of the desktop **/ NETSize desktopGeometry() const; /** Returns the viewport of the specified desktop. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. You should use calls for virtual desktops, viewport is mapped to them if needed. @param desktop the number of the desktop @return the position of the desktop's viewport **/ NETPoint desktopViewport(int desktop) const; /** Returns the workArea for the specified desktop. @param desktop the number of the desktop @return the size of the work area **/ NETRect workArea(int desktop) const; /** Returns the name for the specified desktop. @param desktop the number of the desktop @return the name of the desktop **/ const char *desktopName(int desktop) const; /** Returns an array of Window id's, which contain the virtual root windows. @return the array of Window id's @see virtualRootsCount() **/ const xcb_window_t *virtualRoots() const; /** Returns the number of window in the virtualRoots array. @return the number of Window id's in the virtual root array @see virtualRoots() **/ int virtualRootsCount() const; /** Returns the desktop layout orientation. **/ NET::Orientation desktopLayoutOrientation() const; /** Returns the desktop layout number of columns and rows. Note that either may be 0 (see _NET_DESKTOP_LAYOUT). **/ QSize desktopLayoutColumnsRows() const; /** Returns the desktop layout starting corner. **/ NET::DesktopLayoutCorner desktopLayoutCorner() const; /** Returns the number of desktops. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. They are however mapped to virtual desktops if needed. @param ignore_viewport if false, viewport is mapped to virtual desktops @return the number of desktops **/ int numberOfDesktops(bool ignore_viewport = false) const; /** Returns the current desktop. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. They are however mapped to virtual desktops if needed. @param ignore_viewport if false, viewport is mapped to virtual desktops @return the number of the current desktop **/ int currentDesktop(bool ignore_viewport = false) const; /** Returns the active (focused) window. @return the id of the active window **/ xcb_window_t activeWindow() const; /** Window Managers must call this after creating the NETRootInfo object, and before using any other method in the class. This method sets initial data on the root window and does other post-construction duties. Clients must also call this after creating the object to do an initial data read/update. **/ void activate(); /** Sets the list of managed windows on the Root/Desktop window. @param windows The array of Window id's @param count The number of windows in the array **/ void setClientList(const xcb_window_t *windows, unsigned int count); /** Sets the list of managed windows in stacking order on the Root/Desktop window. @param windows The array of Window id's @param count The number of windows in the array. **/ void setClientListStacking(const xcb_window_t *windows, unsigned int count); /** Sets the current desktop to the specified desktop. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. It is however mapped to virtual desktops if needed. @param desktop the number of the desktop @param ignore_viewport if false, viewport is mapped to virtual desktops **/ void setCurrentDesktop(int desktop, bool ignore_viewport = false); /** Sets the desktop geometry to the specified geometry. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. You should use calls for virtual desktops, viewport is mapped to them if needed. @param geometry the new size of the desktop **/ void setDesktopGeometry(const NETSize &geometry); /** Sets the viewport for the current desktop to the specified point. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. You should use calls for virtual desktops, viewport is mapped to them if needed. @param desktop the number of the desktop @param viewport the new position of the desktop's viewport **/ void setDesktopViewport(int desktop, const NETPoint &viewport); /** Sets the number of desktops to the specified number. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. Viewport is mapped to virtual desktops if needed, but not for this call. @param numberOfDesktops the number of desktops **/ void setNumberOfDesktops(int numberOfDesktops); /** Sets the name of the specified desktop. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. Viewport is mapped to virtual desktops if needed, but not for this call. @param desktop the number of the desktop @param desktopName the new name of the desktop **/ void setDesktopName(int desktop, const char *desktopName); /** Requests that the specified window becomes the active (focused) one. @param window the id of the new active window @param src whether the request comes from normal application or from a pager or similar tool @param timestamp X server timestamp of the user action that caused the request @param active_window active window of the requesting application, if any **/ void setActiveWindow(xcb_window_t window, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window); /** Sets the active (focused) window the specified window. This should be used only in the window manager mode. @param window the if of the new active window **/ void setActiveWindow(xcb_window_t window); /** Sets the workarea for the specified desktop @param desktop the number of the desktop @param workArea the new work area of the desktop **/ void setWorkArea(int desktop, const NETRect &workArea); /** Sets the list of virtual root windows on the root window. @param windows The array of Window id's @param count The number of windows in the array. **/ void setVirtualRoots(const xcb_window_t *windows, unsigned int count); /** Sets the desktop layout. This is set by the pager. When setting, the pager must own the _NET_DESKTOP_LAYOUT_Sn manager selection. See _NET_DESKTOP_LAYOUT for details. **/ void setDesktopLayout(NET::Orientation orientation, int columns, int rows, NET::DesktopLayoutCorner corner); /** * Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown). */ void setShowingDesktop(bool showing); /** * Returns the status of _NET_SHOWING_DESKTOP. */ bool showingDesktop() const; /** Assignment operator. Ensures that the shared data reference counts are correct. **/ const NETRootInfo &operator=(const NETRootInfo &rootinfo); /** Clients (such as pagers/taskbars) that wish to close a window should call this function. This will send a request to the Window Manager, which usually can usually decide how to react to such requests. @param window the id of the window to close **/ void closeWindowRequest(xcb_window_t window); /** Clients (such as pagers/taskbars) that wish to start a WMMoveResize (where the window manager controls the resize/movement, i.e. _NET_WM_MOVERESIZE) should call this function. This will send a request to the Window Manager. @param window The client window that would be resized/moved. @param x_root X position of the cursor relative to the root window. @param y_root Y position of the cursor relative to the root window. @param direction One of NET::Direction (see base class documentation for a description of the different directions). **/ void moveResizeRequest(xcb_window_t window, int x_root, int y_root, Direction direction); /** Clients (such as pagers/taskbars) that wish to move/resize a window using WM2MoveResizeWindow (_NET_MOVERESIZE_WINDOW) should call this function. This will send a request to the Window Manager. See _NET_MOVERESIZE_WINDOW description for details. @param window The client window that would be resized/moved. @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description) @param x Requested X position for the window @param y Requested Y position for the window @param width Requested width for the window @param height Requested height for the window **/ void moveResizeWindowRequest(xcb_window_t window, int flags, int x, int y, int width, int height); /** Sends the _NET_RESTACK_WINDOW request. **/ void restackRequest(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp); /** Sends a ping with the given timestamp to the window, using the _NET_WM_PING protocol. */ void sendPing(xcb_window_t window, xcb_timestamp_t timestamp); #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) /** This function takes the passed XEvent and returns an OR'ed list of NETRootInfo properties that have changed in the properties argument. The new information will be read immediately by the class. The elements of the properties argument are as they would be passed to the constructor, if the array is not large enough, changed properties that don't fit in it won't be listed there (they'll be updated in the class though). @param event the event @param properties properties that changed @param properties_size size of the passed properties array @deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*) **/ KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETRootInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)") void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size); #endif /** * This function takes the passed xcb_generic_event_t and returns the updated properties in the passed in arguments. * * The new information will be read immediately by the class. It is possible to pass in a * null pointer in the arguments. In that case the passed in argument will obviously not * be updated, but the class will process the information nevertheless. * * @param event the event * @param properties The NET::Properties that changed * @param properties2 The NET::Properties2 that changed * @since 5.0 **/ void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr); /** This function takes the passed XEvent and returns an OR'ed list of NETRootInfo properties that have changed. The new information will be read immediately by the class. This overloaded version returns only a single mask, and therefore cannot check state of all properties like the other variant. @param event the event @return the properties **/ NET::Properties event(xcb_generic_event_t *event); protected: /** A Client should subclass NETRootInfo and reimplement this function when it wants to know when a window has been added. @param window the id of the window to add **/ virtual void addClient(xcb_window_t window) { Q_UNUSED(window); } /** A Client should subclass NETRootInfo and reimplement this function when it wants to know when a window has been removed. @param window the id of the window to remove **/ virtual void removeClient(xcb_window_t window) { Q_UNUSED(window); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to change the number of desktops. @param numberOfDesktops the new number of desktops **/ virtual void changeNumberOfDesktops(int numberOfDesktops) { Q_UNUSED(numberOfDesktops); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to change the specified desktop geometry. @param desktop the number of the desktop @param geom the new size **/ virtual void changeDesktopGeometry(int desktop, const NETSize &geom) { Q_UNUSED(desktop); Q_UNUSED(geom); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to change the specified desktop viewport. @param desktop the number of the desktop @param viewport the new position of the viewport **/ virtual void changeDesktopViewport(int desktop, const NETPoint &viewport) { Q_UNUSED(desktop); Q_UNUSED(viewport); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to change the current desktop. @param desktop the number of the desktop **/ virtual void changeCurrentDesktop(int desktop) { Q_UNUSED(desktop); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to close a window. @param window the id of the window to close **/ virtual void closeWindow(xcb_window_t window) { Q_UNUSED(window); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to start a move/resize. @param window The window that wants to move/resize @param x_root X position of the cursor relative to the root window. @param y_root Y position of the cursor relative to the root window. @param direction One of NET::Direction (see base class documentation for a description of the different directions). **/ virtual void moveResize(xcb_window_t window, int x_root, int y_root, unsigned long direction) { Q_UNUSED(window); Q_UNUSED(x_root); Q_UNUSED(y_root); Q_UNUSED(direction); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to receive replies to the _NET_WM_PING protocol. @param window the window from which the reply came @param timestamp timestamp of the ping */ virtual void gotPing(xcb_window_t window, xcb_timestamp_t timestamp) { Q_UNUSED(window); Q_UNUSED(timestamp); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to change the active (focused) window. @param window the id of the window to activate @param src the source from which the request came @param timestamp the timestamp of the user action causing this request @param active_window active window of the requesting application, if any **/ virtual void changeActiveWindow(xcb_window_t window, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window) { Q_UNUSED(window); Q_UNUSED(src); Q_UNUSED(timestamp); Q_UNUSED(active_window); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a pager made a request to move/resize a window. See _NET_MOVERESIZE_WINDOW for details. @param window the id of the window to more/resize @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description) @param x Requested X position for the window @param y Requested Y position for the window @param width Requested width for the window @param height Requested height for the window **/ virtual void moveResizeWindow(xcb_window_t window, int flags, int x, int y, int width, int height) { Q_UNUSED(window); Q_UNUSED(flags); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(width); Q_UNUSED(height); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a Client made a request to restack a window. See _NET_RESTACK_WINDOW for details. @param window the id of the window to restack @param source the source of the request @param above other window in the restack request @param detail restack detail @param timestamp the timestamp of the request **/ virtual void restackWindow(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp) { Q_UNUSED(window); Q_UNUSED(source); Q_UNUSED(above); Q_UNUSED(detail); Q_UNUSED(timestamp); } /** A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when a pager made a request to change showing the desktop. See _NET_SHOWING_DESKTOP for details. @param showing whether to activate the showing desktop mode **/ virtual void changeShowingDesktop(bool showing) { Q_UNUSED(showing); } private: void update(NET::Properties properties, NET::Properties2 properties2); void setSupported(); void setDefaultProperties(); void updateSupportedProperties(xcb_atom_t atom); protected: /** Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. Unused in this class. */ virtual void virtual_hook(int id, void *data); private: NETRootInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared) }; /** Common API for application window properties/protocols. The NETWinInfo class provides a common API for clients and window managers to set/read/change properties on an application window as defined by the NET Window Manager Specification. @author Bradley T. Hughes @see NET @see NETRootInfo @see http://www.freedesktop.org/standards/wm-spec/ **/ class KWINDOWSYSTEM_EXPORT NETWinInfo : public NET { public: /** Indexes for the properties array. **/ // update also NETWinInfoPrivate::properties[] size when extending this enum { PROTOCOLS, PROTOCOLS2, PROPERTIES_SIZE }; /** Create a NETWinInfo object, which will be used to set/read/change information stored on an application window. @param connection XCB connection @param window The Window id of the application window. @param rootWindow The Window id of the root window. @param properties The NET::Properties flags @param properties2 The NET::Properties2 flags @param role Select the application role. If this argument is omitted, the role will default to Client. **/ NETWinInfo(xcb_connection_t *connection, xcb_window_t window, xcb_window_t rootWindow, NET::Properties properties, NET::Properties2 properties2, Role role = Client); #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) /** This constructor differs from the above one only in the way it accepts the list of properties the client is interested in. @deprecated since 5.0 use above ctor **/ KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo(xcb_connection_t *, xcb_window_t, xcb_window_t, NET::Properties, NET::Properties2, Role") NETWinInfo(xcb_connection_t *connection, xcb_window_t window, xcb_window_t rootWindow, NET::Properties properties, Role role = Client); #endif /** Creates a shared copy of the specified NETWinInfo object. @param wininfo the NETWinInfo to copy **/ NETWinInfo(const NETWinInfo &wininfo); /** Destroys the NETWinInfo object. **/ virtual ~NETWinInfo(); /** Assignment operator. Ensures that the shared data reference counts are correct. **/ const NETWinInfo &operator=(const NETWinInfo &wintinfo); /** Returns the xcb connection used. @return the XCB connection **/ xcb_connection_t *xcbConnection() const; /** Returns true if the window has any window type set, even if the type itself is not known to this implementation. Presence of a window type as specified by the NETWM spec is considered as the window supporting this specification. @return true if the window has support for the NETWM spec **/ bool hasNETSupport() const; /** @returns the properties argument passed to the constructor. @see passedProperties2() **/ NET::Properties passedProperties() const; /** * @returns the properties2 argument passed to the constructor. * @see passedProperties() * @since 5.0 **/ NET::Properties2 passedProperties2() const; /** Returns the icon geometry. @return the geometry of the icon **/ NETRect iconGeometry() const; /** Returns the state of the window (see the NET base class documentation for a description of the various states). @return the state of the window **/ NET::States state() const; /** Returns the extended (partial) strut specified by this client. See _NET_WM_STRUT_PARTIAL in the spec. **/ NETExtendedStrut extendedStrut() const; // Still used internally, e.g. by KWindowSystem::strutChanged() logic /** @deprecated use strutPartial() Returns the strut specified by this client. @return the strut of the window **/ NETStrut strut() const; /** Returns the window type for this client (see the NET base class documentation for a description of the various window types). Since clients may specify several windows types for a window in order to support backwards compatibility and extensions not available in the NETWM spec, you should specify all window types you application supports (see the NET::WindowTypeMask mask values for various window types). This method will return the first window type that is listed in the supported types, or NET::Unknown if none of the window types is supported. @return the type of the window **/ WindowType windowType(WindowTypes supported_types) const; /** This function returns false if the window has not window type specified at all. Used by KWindowInfo::windowType() to return either NET::Normal or NET::Dialog as appropriate as a fallback. **/ bool hasWindowType() const; /** Returns the name of the window in UTF-8 format. @return the name of the window **/ const char *name() const; /** Returns the visible name as set by the window manager in UTF-8 format. @return the visible name of the window **/ const char *visibleName() const; /** Returns the iconic name of the window in UTF-8 format. Note that this has nothing to do with icons, but it's for "iconic" representations of the window (taskbars etc.), that should be shown when the window is in iconic state. See description of _NET_WM_ICON_NAME for details. @return the iconic name **/ const char *iconName() const; /** Returns the visible iconic name as set by the window manager in UTF-8 format. Note that this has nothing to do with icons, but it's for "iconic" representations of the window (taskbars etc.), that should be shown when the window is in iconic state. See description of _NET_WM_VISIBLE_ICON_NAME for details. @return the visible iconic name **/ const char *visibleIconName() const; /** Returns the desktop where the window is residing. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. It is however mapped to virtual desktops if needed. @param ignore_viewport if false, viewport is mapped to virtual desktops @return the number of the window's desktop @see OnAllDesktops() **/ int desktop(bool ignore_viewport = false) const; /** Returns the process id for the client window. @return the process id of the window **/ int pid() const; /** Returns whether or not this client handles icons. @return true if this client handles icons, false otherwise **/ bool handledIcons() const; /** Returns the mapping state for the window (see the NET base class documentation for a description of mapping state). @return the mapping state **/ MappingState mappingState() const; /** Set icons for the application window. If replace is True, then the specified icon is defined to be the only icon. If replace is False, then the specified icon is added to a list of icons. @param icon the new icon @param replace true to replace, false to append to the list of icons **/ void setIcon(NETIcon icon, bool replace = true); /** Set the icon geometry for the application window. @param geometry the new icon geometry **/ void setIconGeometry(NETRect geometry); /** Set the extended (partial) strut for the application window. @param extended_strut the new strut **/ void setExtendedStrut(const NETExtendedStrut &extended_strut); // Still used internally, e.g. by KWindowSystem::strutChanged() logic /** @deprecated use setExtendedStrut() Set the strut for the application window. @param strut the new strut **/ void setStrut(NETStrut strut); /** Set the state for the application window (see the NET base class documentation for a description of window state). @param state the name state @param mask the mask for the state **/ void setState(NET::States state, NET::States mask); /** Sets the window type for this client (see the NET base class documentation for a description of the various window types). @param type the window type **/ void setWindowType(WindowType type); /** Sets the name for the application window. @param name the new name of the window **/ void setName(const char *name); /** For Window Managers only: set the visible name ( i.e. xterm, xterm <2>, xterm <3>, ... ) @param visibleName the new visible name **/ void setVisibleName(const char *visibleName); /** Sets the iconic name for the application window. @param name the new iconic name **/ void setIconName(const char *name); /** For Window Managers only: set the visible iconic name ( i.e. xterm, xterm <2>, xterm <3>, ... ) @param name the new visible iconic name **/ void setVisibleIconName(const char *name); /** Set which window the desktop is (should be) on. NOTE: KDE uses virtual desktops and does not directly support viewport in any way. It is however mapped to virtual desktops if needed. @param desktop the number of the new desktop @param ignore_viewport if false, viewport is mapped to virtual desktops @see OnAllDesktops() **/ void setDesktop(int desktop, bool ignore_viewport = false); /** Set the application window's process id. @param pid the window's process id **/ void setPid(int pid); /** Set whether this application window handles icons. @param handled true if the window handles icons, false otherwise **/ void setHandledIcons(bool handled); /** Set the frame decoration strut, i.e. the width of the decoration borders. @param strut the new strut **/ void setFrameExtents(NETStrut strut); /** Returns the frame decoration strut, i.e. the width of the decoration borders. @since 4.3 **/ NETStrut frameExtents() const; /** Sets the window frame overlap strut, i.e. how far the window frame extends behind the client area on each side. Set the strut values to -1 if you want the window frame to cover the whole client area. The default values are 0. @since 4.4 **/ void setFrameOverlap(NETStrut strut); /** Returns the frame overlap strut, i.e. how far the window frame extends behind the client area on each side. @since 4.4 **/ NETStrut frameOverlap() const; /** Sets the extents of the drop-shadow drawn by the client. @since 5.65 **/ void setGtkFrameExtents(NETStrut strut); /** Returns the extents of the drop-shadow drawn by a GTK client. @since 5.65 **/ NETStrut gtkFrameExtents() const; /** Returns an icon. If width and height are passed, the icon returned will be the closest it can find (the next biggest). If width and height are omitted, then the largest icon in the list is returned. @param width the preferred width for the icon, -1 to ignore @param height the preferred height for the icon, -1 to ignore @return the icon **/ NETIcon icon(int width = -1, int height = -1) const; /** Returns a list of provided icon sizes. Each size is pair width,height, terminated with pair 0,0. @since 4.3 **/ const int *iconSizes() const; /** * Sets user timestamp @p time on the window (property _NET_WM_USER_TIME). * The timestamp is expressed as XServer time. If a window * is shown with user timestamp older than the time of the last * user action, it won't be activated after being shown, with the special * value 0 meaning not to activate the window after being shown. */ void setUserTime(xcb_timestamp_t time); /** * Returns the time of last user action on the window, or -1 if not set. */ xcb_timestamp_t userTime() const; /** * Sets the startup notification id @p id on the window. */ void setStartupId(const char *startup_id); /** * Returns the startup notification id of the window. */ const char *startupId() const; /** * Sets opacity (0 = transparent, 0xffffffff = opaque ) on the window. */ void setOpacity(unsigned long opacity); /** * Returns the opacity of the window. */ unsigned long opacity() const; /** * Sets actions that the window manager allows for the window. */ void setAllowedActions(NET::Actions actions); /** * Returns actions that the window manager allows for the window. */ NET::Actions allowedActions() const; /** * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow * for this window. */ xcb_window_t transientFor() const; /** * Returns the leader window for the group the window is in, if any. */ xcb_window_t groupLeader() const; /** * Returns whether the UrgencyHint is set in the WM_HINTS.flags. * See ICCCM 4.1.2.4. * * @since 5.3 **/ bool urgency() const; /** * Returns whether the Input flag is set in WM_HINTS. * See ICCCM 4.1.2.4 and 4.1.7. * * The default value is @c true in case the Client is mapped without a WM_HINTS property. * * @since 5.3 **/ bool input() const; /** * Returns the initial mapping state as set in WM_HINTS. * See ICCCM 4.1.2.4 and 4.1.4. * * The default value if @c Withdrawn in case the Client is mapped without * a WM_HINTS property or without the initial state hint set. * * @since 5.5 **/ MappingState initialMappingState() const; /** * Returns the icon pixmap as set in WM_HINTS. * See ICCCM 4.1.2.4. * * The default value is @c XCB_PIXMAP_NONE. * * Using the ICCCM variant for the icon is deprecated and only * offers a limited functionality compared to {@link icon}. * Only use this variant as a fallback. * * @see icccmIconPixmapMask * @see icon * @since 5.7 **/ xcb_pixmap_t icccmIconPixmap() const; /** * Returns the mask for the icon pixmap as set in WM_HINTS. * See ICCCM 4.1.2.4. * * The default value is @c XCB_PIXMAP_NONE. * * @see icccmIconPixmap * @since 5.7 **/ xcb_pixmap_t icccmIconPixmapMask() const; /** * Returns the class component of the window class for the window * (i.e. WM_CLASS property). */ const char *windowClassClass() const; /** * Returns the name component of the window class for the window * (i.e. WM_CLASS property). */ const char *windowClassName() const; /** * Returns the window role for the window (i.e. WM_WINDOW_ROLE property). */ const char *windowRole() const; /** * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property). */ const char *clientMachine() const; /** * returns a comma-separated list of the activities the window is associated with. * FIXME this might be better as a NETRArray ? * @since 4.6 */ const char *activities() const; /** * Sets the comma-separated list of activities the window is associated with. * @since 5.1 */ void setActivities(const char *activities); /** * Sets whether the client wishes to block compositing (for better performance) * @since 4.7 */ void setBlockingCompositing(bool active); /** * Returns whether the client wishes to block compositing (for better performance) * @since 4.7 */ bool isBlockingCompositing() const; /** Places the window frame geometry in frame, and the application window geometry in window. Both geometries are relative to the root window. @param frame the geometry for the frame @param window the geometry for the window **/ void kdeGeometry(NETRect &frame, NETRect &window); /** Sets the desired multiple-monitor topology (4 monitor indices indicating the top, bottom, left, and right edges of the window) when the fullscreen state is enabled. The indices are from the set returned by the Xinerama extension. See _NET_WM_FULLSCREEN_MONITORS for details. @param topology A struct that models the desired monitor topology, namely: top is the monitor whose top edge defines the top edge of the fullscreen window, bottom is the monitor whose bottom edge defines the bottom edge of the fullscreen window, left is the monitor whose left edge defines the left edge of the fullscreen window, and right is the monitor whose right edge defines the right edge of the fullscreen window. **/ void setFullscreenMonitors(NETFullscreenMonitors topology); /** Returns the desired fullscreen monitor topology for this client, should it be in fullscreen state. See _NET_WM_FULLSCREEN_MONITORS in the spec. **/ NETFullscreenMonitors fullscreenMonitors() const; #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) /** This function takes the passed XEvent and returns an OR'ed list of NETWinInfo properties that have changed in the properties argument. The new information will be read immediately by the class. The elements of the properties argument are as they would be passed to the constructor, if the array is not large enough, changed properties that don't fit in it won't be listed there (they'll be updated in the class though). @param event the event @param properties properties that changed @param properties_size size of the passed properties array @deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*) **/ KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)") void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size); #endif /** * This function takes the passed in xcb_generic_event_t and returns the updated properties * in the passed in arguments. * * The new information will be read immediately by the class. It is possible to pass in a * null pointer in the arguments. In that case the passed in * argument will obviously not be updated, but the class will process the information * nevertheless. * * @param event the event * @param properties The NET::Properties that changed * @param properties2 The NET::Properties2 that changed * @since 5.0 **/ void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr); /** This function takes the pass XEvent and returns an OR'ed list of NETWinInfo properties that have changed. The new information will be read immediately by the class. This overloaded version returns only a single mask, and therefore cannot check state of all properties like the other variant. @param event the event @return the properties **/ NET::Properties event(xcb_generic_event_t *event); /** * @returns The window manager protocols this Client supports. * @since 5.3 **/ NET::Protocols protocols() const; /** * @returns @c true if the Client supports the @p protocol. * @param protocol The window manager protocol to test for * @since 5.3 **/ bool supportsProtocol(NET::Protocol protocol) const; /** * @returns The opaque region as specified by the Client. * @since 5.7 **/ std::vector opaqueRegion() const; /** * Sets the @p name as the desktop file name. * * This is either the base name without full path and without file extension of the * desktop file for the window's application (e.g. "org.kde.foo"). * * If the application's desktop file name is not at a standard location it should be * the full path to the desktop file name (e.g. "/opt/kde/share/org.kde.foo.desktop"). * * If the window does not know the desktop file name, it should not set the name at all. * * @since 5.28 **/ void setDesktopFileName(const char *name); /** * @returns The desktop file name of the window's application if present. * @since 5.28 * @see setDesktopFileName **/ const char *desktopFileName() const; /** Sentinel value to indicate that the client wishes to be visible on all desktops. @return the value to be on all desktops **/ static const int OnAllDesktops; protected: /** A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when a Client made a request to change desktops (ie. move to another desktop). @param desktop the number of the desktop **/ virtual void changeDesktop(int desktop) { Q_UNUSED(desktop); } /** A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when a Client made a request to change state (ie. to Shade / Unshade). @param state the new state @param mask the mask for the state **/ virtual void changeState(NET::States state, NET::States mask) { Q_UNUSED(state); Q_UNUSED(mask); } /** A Window Manager should subclass NETWinInfo2 and reimplement this function when it wants to know when a Client made a request to change the fullscreen monitor topology for its fullscreen state. @param topology A structure (top, bottom, left, right) representing the fullscreen monitor topology. **/ virtual void changeFullscreenMonitors(NETFullscreenMonitors topology) { Q_UNUSED(topology); } private: void update(NET::Properties dirtyProperties, NET::Properties2 dirtyProperties2 = NET::Properties2()); void updateWMState(); void setIconInternal(NETRArray &icons, int &icon_count, xcb_atom_t property, NETIcon icon, bool replace); NETIcon iconInternal(NETRArray &icons, int icon_count, int width, int height) const; protected: /** Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. Unused in this class. */ virtual void virtual_hook(int id, void *data); private: NETWinInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared) }; //#define KWIN_FOCUS #endif #endif // netwm_h libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/xcbinterface.h0000664000175000017500000000467014474244170027356 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef XCBINTERFACE_H #define XCBINTERFACE_H #include "abstractinterface.h" #include #include using namespace kdk; class Q_DECL_HIDDEN XcbInterface:public AbstractInterface { public: XcbInterface(QObject* parent=nullptr); ~XcbInterface(); WindowInfo requestInfo(WindowId wid) override; void requestActivate(WindowId wid) override; void requestClose(WindowId wid) ; void requestToggleKeepAbove(WindowId wid) override; void requestToggleMinimized(WindowId wid) override; void requestToggleMaximized(WindowId wid) override; QIcon iconFor(WindowId wid) override; QString titleFor(WindowId wid) override; QString windowGroupFor(WindowId wid) override; void showCurrentDesktop() override; void hideCurrentDesktop() override; quint32 pid(WindowId wid) override; WindowId activeWindow() override; bool windowCanBeDragged(WindowId wid) override; bool windowCanBeMaximized(WindowId wid) override; void setGeometry(QWindow *window, const QRect &rect) override; void setSkipTaskBar(QWindow* window,bool skip) override; void setSkipSwitcher(QWindow* window,bool skip) override; bool skipTaskBar(const WindowId &wid) override; bool skipSwitcher(const WindowId &wid) override; bool isShowingDesktop(); void setOnAllDesktops(const WindowId &wid); NET::WindowType windowType(WindowId wid) override; private: bool isValidWindow(WindowId wid) ; bool isValidWindow(const KWindowInfo &winfo) ; void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2); private: WindowId m_desktopId{-1}; }; #endif // XCBINTERFACE_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/waylandinterface.h0000664000175000017500000000712714474244170030241 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WAYLANDINTERFACE_H #define WAYLANDINTERFACE_H #include "abstractinterface.h" #include #include #include #include #include #include #include using namespace kdk; using namespace KWayland::Client; class Q_DECL_HIDDEN WaylandInterface:public AbstractInterface { public: WaylandInterface(QObject* parent=nullptr); ~WaylandInterface(); WindowInfo requestInfo(WindowId wid) override; void requestActivate(WindowId wid) override; void requestClose(WindowId wid) override; void requestToggleKeepAbove(WindowId wid) override; void requestToggleMinimized(WindowId wid) override; void requestToggleMaximized(WindowId wid) override; QIcon iconFor(WindowId wid) override; QString titleFor(WindowId wid) override; QString windowGroupFor(WindowId wid) override; quint32 pid(WindowId wid) override; void showCurrentDesktop() override; void hideCurrentDesktop() override; bool windowCanBeDragged(WindowId wid) override; bool windowCanBeMaximized(WindowId wid) override; WindowId activeWindow() override; void setGeometry(QWindow *window, const QRect &rect) override; void setSkipTaskBar(QWindow* window,bool skip) override; void setSkipSwitcher(QWindow* window,bool skip) override; bool skipTaskBar(const WindowId &wid) override; bool skipSwitcher(const WindowId &wid) override; bool isShowingDesktop(); void setOnAllDesktops(const WindowId &wid); NET::WindowType windowType(WindowId wid) override; protected: bool eventFilter(QObject *obj, QEvent *ev) override; private slots: void updateWindow(); void windowUnmapped(); private: PlasmaWindow *windowFor(WindowId wid) ; bool isValidWindow(const KWayland::Client::PlasmaWindow *w) ; bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) ; bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) ; void windowCreatedProxy(KWayland::Client::PlasmaWindow *w); void trackWindow(KWayland::Client::PlasmaWindow *w); void untrackWindow(KWayland::Client::PlasmaWindow *w); void setCurrentDesktop(QString desktop); void addDesktop(const QString &id, quint32 position); private: ConnectionThread *m_connection=nullptr; PlasmaShell *m_plasmaShell = nullptr; Shell *m_shell = nullptr; PlasmaWindowManagement *m_windowManager = nullptr; PlasmaWindow *m_appWindow = nullptr; PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr}; QStringList m_desktops; QMapm_surfaces; QMapm_plasmaShellSurfaces; }; #endif // WAYLANDINTERFACE_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/waylandinterface.cpp0000664000175000017500000004511714474244170030575 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "waylandinterface.h" #include #include #include #include #include #include WaylandInterface::WaylandInterface(QObject *parent) :AbstractInterface(parent) { m_connection = KWayland::Client::ConnectionThread::fromApplication(qApp); auto registry = new Registry(this); registry->create(m_connection->display()); connect(registry, &KWayland::Client::Registry::plasmaShellAnnounced, this, [=](){ const auto interface = registry->interface(KWayland::Client::Registry::Interface::PlasmaShell); if (interface.name != 0) { m_plasmaShell = registry->createPlasmaShell(interface.name, interface.version, this); } }); connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [=](){ const auto interface = registry->interface(Registry::Interface::PlasmaWindowManagement); if (interface.name != 0) { m_windowManager = registry->createPlasmaWindowManagement(interface.name, interface.version, this); } if(m_windowManager) { connect(m_windowManager, &PlasmaWindowManagement::showingDesktopChanged,this,&AbstractInterface::isShowingDesktopChanged); connect(m_windowManager, &PlasmaWindowManagement::windowCreated, this, &WaylandInterface::windowCreatedProxy); connect(m_windowManager, &PlasmaWindowManagement::activeWindowChanged, this, [&]() noexcept { auto w = m_windowManager->activeWindow(); if(w) { emit activeWindowChanged(w ? w->internalId() : 0); } }, Qt::QueuedConnection); connect(m_windowManager, &PlasmaWindowManagement::windowCreated,this, [this](PlasmaWindow *window) { if (!m_windows.contains(window->internalId())) { m_windows.insert(window->internalId(), this->requestInfo(window->internalId())); } emit windowAdded(window->internalId()); }); } }); connect(registry, &KWayland::Client::Registry::plasmaVirtualDesktopManagementAnnounced, [this, registry] (quint32 name, quint32 version) { m_virtualDesktopManagement = registry->createPlasmaVirtualDesktopManagement(name, version, this); if(m_virtualDesktopManagement) { connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopCreated, this, [this](const QString &id, quint32 position) { addDesktop(id, position); }); connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopRemoved, this, [this](const QString &id) { m_desktops.removeAll(id); if (m_currentDesktop == id) { setCurrentDesktop(QString()); } }); } }); connect(registry, &KWayland::Client::Registry::shellAnnounced, this, [=](){ const auto interface = registry->interface(KWayland::Client::Registry::Interface::Shell); if (interface.name != 0) { m_shell = registry->createShell(interface.name, interface.version, this); } }); registry->setup(); m_connection->roundtrip(); } WaylandInterface::~WaylandInterface() { } WindowInfo WaylandInterface::requestInfo(WindowId wid) { WindowInfo windowInfo; auto w = windowFor(wid); if (w) { if (isPlasmaDesktop(w)) { windowInfo.setIsValid(true); windowInfo.setIsPlasmaDesktop(true); windowInfo.setWid(wid); //! Window Abilities windowInfo.setIsClosable(false); windowInfo.setIsFullScreenable(false); windowInfo.setIsGroupable(false); windowInfo.setIsMaximizable(false); windowInfo.setIsMinimizable(false); windowInfo.setIsMovable(false); windowInfo.setIsResizable(false); windowInfo.setIsShadeable(false); windowInfo.setIsVirtualDesktopsChangeable(false); //! Window Abilities } else if (isValidWindow(w)) { windowInfo.setIsValid(true); windowInfo.setWid(wid); windowInfo.setIsActive(w->isActive()); windowInfo.setIsMinimized(w->isMinimized()); windowInfo.setIsMaxVert(w->isMaximized()); windowInfo.setIsMaxHoriz(w->isMaximized()); windowInfo.setIsFullscreen(w->isFullscreen()); windowInfo.setIsShaded(w->isShaded()); windowInfo.setIsOnAllDesktops(w->isOnAllDesktops()); windowInfo.setIsOnAllActivities(true); windowInfo.setHasSkipTaskbar(w->skipTaskbar()); windowInfo.setHasSkipSwitcher(w->skipSwitcher()); windowInfo.setIsKeepAbove(w->isKeepAbove()); //! Window Abilities windowInfo.setIsClosable(w->isCloseable()); windowInfo.setIsFullScreenable(w->isFullscreenable()); windowInfo.setIsMaximizable(w->isMaximizeable()); windowInfo.setIsMinimizable(w->isMinimizeable()); windowInfo.setIsMovable(w->isMovable()); windowInfo.setIsResizable(w->isResizable()); windowInfo.setIsShadeable(w->isShadeable()); windowInfo.setIsVirtualDesktopsChangeable(w->isVirtualDesktopChangeable()); //! Window Abilities windowInfo.setDesktops(w->plasmaVirtualDesktops()); } } else { windowInfo.setIsValid(false); } return windowInfo; } void WaylandInterface::requestActivate(WindowId wid) { auto w = windowFor(wid); if (w) { w->requestActivate(); m_connection->roundtrip(); emit windowChanged(w->internalId()); } } void WaylandInterface::requestClose(WindowId wid) { auto w = windowFor(wid); if (w) { w->requestClose(); m_connection->roundtrip(); } } void WaylandInterface::requestToggleKeepAbove(WindowId wid) { auto w = windowFor(wid); if (w) { w->requestToggleKeepAbove(); m_connection->roundtrip(); emit windowChanged(w->internalId()); } } void WaylandInterface::requestToggleMinimized(WindowId wid) { auto w = windowFor(wid); if (w) { w->requestToggleMinimized(); m_connection->roundtrip(); } } void WaylandInterface::requestToggleMaximized(WindowId wid) { auto w = windowFor(wid); if (w) { w->requestToggleMaximized(); m_connection->roundtrip(); } } QIcon WaylandInterface::iconFor(WindowId wid) { auto window = windowFor(wid); if (window) { return window->icon(); } return QIcon(); } QString WaylandInterface::titleFor(WindowId wid) { auto window = windowFor(wid); if (window) { return window->title(); } return QString(); } QString WaylandInterface::windowGroupFor(WindowId wid) { auto window = windowFor(wid); if (window) { m_connection->roundtrip(); return window->appId(); } else return QString(); } quint32 WaylandInterface::pid(WindowId wid) { quint32 pid = 0; auto window = windowFor(wid); if (window) { m_connection->roundtrip(); return window->pid(); } else return pid; } void WaylandInterface::showCurrentDesktop() { if(m_windowManager) { m_windowManager->showDesktop(); m_connection->roundtrip(); } } void WaylandInterface::hideCurrentDesktop() { if(m_windowManager) { m_windowManager->hideDesktop(); m_connection->roundtrip(); } } bool WaylandInterface::windowCanBeDragged(WindowId wid) { auto w = windowFor(wid); if (w && isValidWindow(w)) { WindowInfo winfo = requestInfo(wid); return (winfo.isValid() && w->isMovable() && !winfo.isMinimized() && inCurrentDesktopActivity(winfo) && !winfo.isPlasmaDesktop()); } return false; } bool WaylandInterface::windowCanBeMaximized(WindowId wid) { auto w = windowFor(wid); if (w && isValidWindow(w)) { WindowInfo winfo = requestInfo(wid); return (winfo.isValid() && w->isMaximizeable() && !winfo.isMinimized() && inCurrentDesktopActivity(winfo) && !winfo.isPlasmaDesktop()); } return false; } WindowId WaylandInterface::activeWindow() { if (!m_windowManager) { return 0; } m_connection->roundtrip(); auto wid = m_windowManager->activeWindow(); return wid ? QVariant(wid->internalId()) : 0; } void WaylandInterface::setGeometry(QWindow *window, const QRect &rect) { if(!window) return; if (!m_plasmaShell) return; auto surface = KWayland::Client::Surface::fromWindow(window); if (!surface) return; if(!m_surfaces.contains(window)) { m_surfaces.insert(window,surface); } auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window); if (!plasmaShellSurface) return; if(!m_plasmaShellSurfaces.contains(window)) { m_plasmaShellSurfaces.insert(window,plasmaShellSurface); } plasmaShellSurface->setPosition(rect.topLeft()); window->resize(rect.size()); window->installEventFilter(this); } void WaylandInterface::setSkipTaskBar(QWindow *window, bool skip) { if(!window) return; if (!m_plasmaShell) return; auto surface = KWayland::Client::Surface::fromWindow(window); if (!surface) return; if(!m_surfaces.contains(window)) m_surfaces.insert(window,surface); auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window); if (!plasmaShellSurface) return; if(!m_plasmaShellSurfaces.contains(window)) m_plasmaShellSurfaces.insert(window,plasmaShellSurface); plasmaShellSurface->setSkipTaskbar(skip); window->installEventFilter(this); } void WaylandInterface::setSkipSwitcher(QWindow *window, bool skip) { if(!window) return; if (!m_plasmaShell) return; auto surface = KWayland::Client::Surface::fromWindow(window); if (!surface) return; if(!m_surfaces.contains(window)) m_surfaces.insert(window,surface); auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window); if (!plasmaShellSurface) return; if(!m_plasmaShellSurfaces.contains(window)) m_plasmaShellSurfaces.insert(window,plasmaShellSurface); plasmaShellSurface->setSkipSwitcher(skip); window->installEventFilter(this); } bool WaylandInterface::skipTaskBar(const WindowId &wid) { auto window = windowFor(wid); return window ? window->skipTaskbar() : false; } bool WaylandInterface::skipSwitcher(const WindowId &wid) { auto window = windowFor(wid); return window ? window->skipSwitcher() : false; } bool WaylandInterface::isShowingDesktop() { bool flag = false; if(m_windowManager) { flag = m_windowManager->isShowingDesktop(); m_connection->roundtrip(); } return flag; } void WaylandInterface::setOnAllDesktops(const WindowId &wid) { auto w = windowFor(wid); if (w && isValidWindow(w) && m_desktops.count() > 1) { if (w->isOnAllDesktops()) { w->requestEnterVirtualDesktop(m_currentDesktop); } else { const QStringList &now = w->plasmaVirtualDesktops(); foreach (const QString &desktop, now) { w->requestLeaveVirtualDesktop(desktop); } } } } NET::WindowType WaylandInterface::windowType(WindowId wid) { return NET::WindowType::Normal; } bool WaylandInterface::eventFilter(QObject *obj, QEvent *ev) { auto window = qobject_cast(obj); if(window && ev->type() == QEvent::Hide) { if(m_plasmaShellSurfaces.contains(window)) { auto plasmaShellSurface = m_plasmaShellSurfaces.value(window); if(plasmaShellSurface) { plasmaShellSurface->release(); plasmaShellSurface->destroy(); } m_plasmaShellSurfaces.remove(window); } if(m_surfaces.contains(window)) { auto surface = m_surfaces.value(window); if(surface) { surface->release(); surface->destroy(); } m_surfaces.remove(window); } } return QObject::eventFilter(obj,ev); } void WaylandInterface::updateWindow() { PlasmaWindow* w = qobject_cast(QObject::sender()); if(w && !isPlasmaPanel(w)) { m_connection->roundtrip(); emit windowChanged(w->internalId()); } } void WaylandInterface::windowUnmapped() { PlasmaWindow *pW = qobject_cast(QObject::sender()); if (pW) { untrackWindow(pW); if (!m_windows.contains(pW->internalId())) { m_windows.remove(pW->internalId()); } emit windowRemoved(pW->internalId()); } } PlasmaWindow *WaylandInterface::windowFor(WindowId wid) { auto it = std::find_if(m_windowManager->windows().constBegin(), m_windowManager->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept { return w->isValid() && w->internalId() == wid; }); if (it == m_windowManager->windows().constEnd()) { return nullptr; } return *it; } bool WaylandInterface::isValidWindow(const PlasmaWindow *w) { return w->isValid(); } bool WaylandInterface::isPlasmaDesktop(const PlasmaWindow *w) { if (!w || (w->appId() != QLatin1String("org.kde.plasmashell"))) { return false; } return AbstractInterface::isPlasmaDesktop(w->geometry()); } bool WaylandInterface::isPlasmaPanel(const PlasmaWindow *w) { if(w && w->appId() == QLatin1String("ukui-panel")) return true; else return false; } void WaylandInterface::windowCreatedProxy(PlasmaWindow *w) { if (!isValidWindow(w)) { return; } if ((w->appId() == QLatin1String("org.kde.plasmashell")) && isPlasmaPanel(w)) { //registerPlasmaPanel(w->internalId()); } else { trackWindow(w); } } void WaylandInterface::trackWindow(PlasmaWindow *w) { if (!w) { return; } //监控activeChanged会导致最小化状态获取不准确的问题 //connect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::iconChanged, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow); connect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped); } void WaylandInterface::untrackWindow(PlasmaWindow *w) { if (!w) { return; } disconnect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow); disconnect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped); } void WaylandInterface::setCurrentDesktop(QString desktop) { if (m_currentDesktop == desktop) { return; } m_currentDesktop = desktop; emit currentDesktopChanged(); } void WaylandInterface::addDesktop(const QString &id, quint32 position) { if (m_desktops.contains(id)) { return; } m_desktops.append(id); const KWayland::Client::PlasmaVirtualDesktop *desktop = m_virtualDesktopManagement->getVirtualDesktop(id); QObject::connect(desktop, &KWayland::Client::PlasmaVirtualDesktop::activated, this, [desktop, this]() { setCurrentDesktop(desktop->id()); } ); if (desktop->isActive()) { setCurrentDesktop(id); } } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/xcbinterface.cpp0000664000175000017500000003325214474244170027707 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "xcbinterface.h" #include #include #include #include #include #include #include #include #include "kwindowinfo.h" #include XcbInterface::XcbInterface(QObject *parent) :AbstractInterface(parent) { m_currentDesktop = QString::number(KWindowSystem::self()->currentDesktop()); connect(KWindowSystem::self(),&KWindowSystem::showingDesktopChanged,this,&AbstractInterface::isShowingDesktopChanged); connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &AbstractInterface::activeWindowChanged); connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, [=](WindowId wid){ if (!m_windows.contains(wid)) { m_windows.insert(wid, this->requestInfo(wid)); } emit windowAdded(wid);}); connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, this, [=](WindowId wid){ m_windows.remove(wid); emit windowRemoved(wid); }); connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [&](int desktop) { m_currentDesktop = QString::number(desktop); emit currentDesktopChanged(); }); connect(KWindowSystem::self() , static_cast (&KWindowSystem::windowChanged) , this, &XcbInterface::windowChangedProxy); for(auto wid : KWindowSystem::self()->windows()) { emit windowAdded(wid); windowChangedProxy(wid,0,0); } } XcbInterface::~XcbInterface() { } WindowInfo XcbInterface::requestInfo(WindowId wid) { const KWindowInfo winfo{wid.value(), NET::WMFrameExtents | NET::WMWindowType | NET::WMGeometry | NET::WMDesktop | NET::WMState | NET::WMName | NET::WMVisibleName, NET::WM2WindowClass | NET::WM2Activities | NET::WM2AllowedActions | NET::WM2TransientFor}; bool isDesktop{false}; if (winfo.windowClassName() == "plasmashell" && isPlasmaDesktop(winfo.geometry())) { isDesktop = true; this->setPlasmaDesktop(wid); } WindowInfo windowInfo; if (!winfo.valid()) { windowInfo.setIsValid(false); } else if (isValidWindow(winfo) && !isDesktop) { windowInfo.setIsValid(true); windowInfo.setWid(wid); windowInfo.setIsPlasmaDesktop(false); //windowInfo.setParentId(winfo.transientFor()); windowInfo.setIsActive(KWindowSystem::activeWindow() == wid.value()); windowInfo.setIsMinimized(winfo.hasState(NET::Hidden)); windowInfo.setIsMaxVert(winfo.hasState(NET::MaxVert)); windowInfo.setIsMaxHoriz(winfo.hasState(NET::MaxHoriz)); windowInfo.setIsFullscreen(winfo.hasState(NET::FullScreen)); windowInfo.setIsShaded(winfo.hasState(NET::Shaded)); windowInfo.setIsOnAllDesktops(winfo.onAllDesktops()); windowInfo.setIsOnAllActivities(winfo.activities().empty()); //windowInfo.setGeometry(winfo.frameGeometry()); windowInfo.setIsKeepAbove(winfo.hasState(NET::KeepAbove)); windowInfo.setHasSkipTaskbar(winfo.hasState(NET::SkipTaskbar)); //! Window Abilities windowInfo.setIsClosable(winfo.actionSupported(NET::ActionClose)); windowInfo.setIsFullScreenable(winfo.actionSupported(NET::ActionFullScreen)); windowInfo.setIsMaximizable(winfo.actionSupported(NET::ActionMax)); windowInfo.setIsMinimizable(winfo.actionSupported(NET::ActionMinimize)); windowInfo.setIsMovable(winfo.actionSupported(NET::ActionMove)); windowInfo.setIsResizable(winfo.actionSupported(NET::ActionResize)); windowInfo.setIsShadeable(winfo.actionSupported(NET::ActionShade)); windowInfo.setIsVirtualDesktopsChangeable(winfo.actionSupported(NET::ActionChangeDesktop)); //! Window Abilities //windowInfo.setDisplay(winfo.visibleName()); windowInfo.setDesktops({QString::number(winfo.desktop())}); //windowInfo.setActivities(winfo.activities()); } else if (m_desktopId == wid) { windowInfo.setIsValid(true); windowInfo.setIsPlasmaDesktop(true); windowInfo.setWid(wid); //windowInfo.setParentId(0); windowInfo.setHasSkipTaskbar(true); //! Window Abilities windowInfo.setIsClosable(false); windowInfo.setIsFullScreenable(false); windowInfo.setIsGroupable(false); windowInfo.setIsMaximizable(false); windowInfo.setIsMinimizable(false); windowInfo.setIsMovable(false); windowInfo.setIsResizable(false); windowInfo.setIsShadeable(false); windowInfo.setIsVirtualDesktopsChangeable(false); //! Window Abilities } return windowInfo; } void XcbInterface::requestActivate(WindowId wid) { KWindowSystem::activateWindow(wid.toInt()); } void XcbInterface::requestClose(WindowId wid) { WindowInfo wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } NETRootInfo ri(QX11Info::connection(), NET::CloseWindow); ri.closeWindowRequest(wInfo.wid().toUInt()); } void XcbInterface::requestToggleKeepAbove(WindowId wid) { WindowInfo wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } NETWinInfo ni(QX11Info::connection(), wid.toUInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2()); if (wInfo.isKeepAbove()) { ni.setState(NET::States(), NET::StaysOnTop); } else { ni.setState(NET::StaysOnTop, NET::StaysOnTop); } } void XcbInterface::requestToggleMinimized(WindowId wid) { WindowInfo wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop() || !inCurrentDesktopActivity(wInfo)) { return; } if (wInfo.isMinimized()) { bool onCurrent = wInfo.isOnDesktop(m_currentDesktop); KWindowSystem::unminimizeWindow(wid.toUInt()); if (onCurrent) { KWindowSystem::forceActiveWindow(wid.toUInt()); } } else { KWindowSystem::minimizeWindow(wid.toUInt()); } } void XcbInterface::requestToggleMaximized(WindowId wid) { WindowInfo wInfo = requestInfo(wid); if (!windowCanBeMaximized(wid) || !inCurrentDesktopActivity(wInfo)) { return; } bool restore = wInfo.isMaxHoriz() && wInfo.isMaxVert(); if (wInfo.isMinimized()) { KWindowSystem::unminimizeWindow(wid.toUInt()); } NETWinInfo ni(QX11Info::connection(), wid.toInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2()); if (restore) { ni.setState(NET::States(), NET::Max); } else { ni.setState(NET::Max, NET::Max); } } QIcon XcbInterface::iconFor(WindowId wid) { QIcon icon; icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmall, KIconLoader::SizeSmall, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeMedium, KIconLoader::SizeMedium, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeLarge, KIconLoader::SizeLarge, false)); return icon; } QString XcbInterface::titleFor(WindowId wid) { const KWindowInfo winfo{wid.value(), NET::WMName}; if(winfo.valid()) return winfo.name(); else return QString(); } QString XcbInterface::windowGroupFor(WindowId wid) { KWindowInfo winfo(wid.toULongLong(), NET::WMName, NET::WM2WindowClass); if(winfo.valid()) return winfo.windowClassClass(); else return QString(); } void XcbInterface::showCurrentDesktop() { KWindowSystem::setShowingDesktop(true); } void XcbInterface::hideCurrentDesktop() { KWindowSystem::setShowingDesktop(false); } quint32 XcbInterface::pid(WindowId wid) { quint64 pid = 0; const KWindowInfo winfo{wid.value(), NET::WMName}; if(!winfo.valid()) return pid; else { pid = winfo.pid(); } return pid; } WindowId XcbInterface::activeWindow() { WId wid = KWindowSystem::self()->activeWindow(); return QVariant::fromValue(wid); } bool XcbInterface::windowCanBeDragged(WindowId wid) { WindowInfo winfo = requestInfo(wid); return (winfo.isValid() && !winfo.isMinimized() && winfo.isMovable() && inCurrentDesktopActivity(winfo) && !winfo.isPlasmaDesktop()); } bool XcbInterface::windowCanBeMaximized(WindowId wid) { WindowInfo winfo = requestInfo(wid); return (winfo.isValid() && !winfo.isMinimized() && winfo.isMaximizable() && inCurrentDesktopActivity(winfo) && !winfo.isPlasmaDesktop()); } void XcbInterface::setGeometry(QWindow *window, const QRect &rect) { if(window) window->setGeometry(rect); } void XcbInterface::setSkipTaskBar(QWindow *window, bool skip) { if(skip) KWindowSystem::setState(window->winId(),NET::SkipTaskbar); else KWindowSystem::clearState(window->winId(),NET::SkipTaskbar); } void XcbInterface::setSkipSwitcher(QWindow *window, bool skip) { if(skip) KWindowSystem::setState(window->winId(),NET::SkipSwitcher); else KWindowSystem::clearState(window->winId(),NET::SkipSwitcher); } bool XcbInterface::skipTaskBar(const WindowId &wid) { const KWindowInfo winfo(wid.value(), NET::WMState); return winfo.valid() ? winfo.hasState(NET::SkipTaskbar) : false; } bool XcbInterface::skipSwitcher(const WindowId &wid) { const KWindowInfo winfo(wid.value(), NET::WMState); return winfo.valid() ? winfo.hasState(NET::SkipSwitcher) : false; } bool XcbInterface::isShowingDesktop() { return KWindowSystem::showingDesktop(); } void XcbInterface::setOnAllDesktops(const WindowId &wid) { WindowInfo wInfo = requestInfo(wid); if (!wInfo.isValid()) { return; } if (KWindowSystem::numberOfDesktops() <= 1) { return; } if (wInfo.isOnAllDesktops()) { KWindowSystem::setOnDesktop(wid.toUInt(), KWindowSystem::currentDesktop()); KWindowSystem::forceActiveWindow(wid.toUInt()); } else { KWindowSystem::setOnAllDesktops(wid.toUInt(), true); } } NET::WindowType XcbInterface::windowType(WindowId wid) { KWindowInfo info(wid.value(),NET::WMWindowType|NET::WMState,NET::WM2TransientFor); return info.windowType(NET::AllTypesMask); } bool XcbInterface::isValidWindow(WindowId wid) { if (this->isValidFor(wid)) { return true; } const KWindowInfo winfo{wid.value(), NET::WMWindowType | NET::WMState}; return isValidWindow(winfo); } bool XcbInterface::isValidWindow(const KWindowInfo &winfo) { if (this->isValidFor(winfo.win())) { return true; } //! ignored windows from tracking // if (m_ignoredWindows.contains(winfo.win())) { // return false; // } if (m_desktopId == winfo.win()) { return false; } bool hasSkipTaskbar = winfo.hasState(NET::SkipTaskbar); bool hasSkipPager = winfo.hasState(NET::SkipPager); bool isSkipped = hasSkipTaskbar && hasSkipPager; return !isSkipped; } void XcbInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2) { // const KWindowInfo info(wid, NET::WMGeometry, NET::WM2WindowClass); // const auto winClass = info.windowClassName(); // //! ignored windows do not trackd // if (m_ignoredWindows.contains(wid)) { // return; // } // if (winClass == "plasmashell") { // //! update desktop id // if (isPlasmaDesktop(info.geometry())) { // m_desktopId = wid; // windowsTracker()->setPlasmaDesktop(wid); // considerWindowChanged(wid); // return; // } else if (isPlasmaPanel(info.geometry())) { // registerPlasmaPanel(wid); // return; // } // } //! accept only NET::Properties events, //! ignore when the user presses a key, or a window is sending X events etc. //! without needing to (e.g. Firefox, https://bugzilla.mozilla.org/show_bug.cgi?id=1389953) //! NET::WM2UserTime, NET::WM2IconPixmap etc.... if (prop1 == 0 && !(prop2 & (NET::WM2Activities | NET::WM2TransientFor))) { return; } //! accept only the following NET:Properties changed signals //! NET::WMState, NET::WMGeometry, NET::ActiveWindow if ( !(prop1 & NET::WMState) && !(prop1 & NET::WMGeometry) && !(prop1 & NET::ActiveWindow) && !(prop1 & NET::WMDesktop) && !(prop1 & (NET::WMName | NET::WMVisibleName) && !(prop2 & NET::WM2TransientFor) && !(prop2 & NET::WM2Activities)) ) { return; } if (!isValidWindow(wid)) { return; } emit windowChanged(wid); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/wmregister.cpp0000664000175000017500000000277014474244170027443 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "wmregister.h" #include #include #include #include #include "../waylandhelper.h" #include "waylandinterface.h" #include "xcbinterface.h" using namespace kdk; using namespace KWayland::Client; kdk::WmRegister::WmRegister(QObject *parent) :QObject(parent) { QString platform = QGuiApplication::platformName(); if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) m_winInterface = new WaylandInterface(this); else m_winInterface = new XcbInterface(this); } WmRegister::~WmRegister() { } AbstractInterface *WmRegister::winInterface() { return m_winInterface; } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowinfo.h0000664000175000017500000002464214474244170027105 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WINDOWINFO_H #define WINDOWINFO_H #include #include #include namespace kdk { class WindowInfo { using WindowId = QVariant; public: WindowInfo(): m_handle(nullptr) , m_isValid(false) , m_isActive(false) , m_isMinimized(false) , m_isMaxVert(false) , m_isMaxHoriz(false) , m_isFullscreen(false) , m_isShaded(false) , m_isPlasmaDesktop(false) , m_isKeepAbove(false) , m_hasSkipTaskbar(false) , m_hasSkipSwitcher(false) , m_isOnAllDesktops(false) , m_isOnAllActivities(false) , m_isClosable(false) , m_isFullScreenable(false) , m_isGroupable(false) , m_isMaximizable(false) , m_isMinimizable(false) , m_isMovable(false) , m_isResizable(false) , m_isShadeable(false) , m_isVirtualDesktopsChangeable(false){} inline bool isPlasmaDesktop() const; inline void setIsPlasmaDesktop(bool isPlasmaDesktop); inline bool isValid() const; inline void setIsValid(bool isValid); inline bool isActive() const noexcept; inline void setIsActive(bool isActive) noexcept; inline bool isMaxVert() const; inline void setIsMaxVert(bool isMaxVert); inline bool isMaxHoriz() const; inline void setIsMaxHoriz(bool isMaxHoriz); inline WindowId wid() const; inline void setWid(const WindowId &wid); inline bool isKeepAbove() const; inline void setIsKeepAbove(bool isKeepAbove); inline bool isMinimized() const; inline void setIsMinimized(bool isMinimized); inline bool isMaximized() const; inline bool isFullscreen() const noexcept; inline void setIsFullscreen(bool isFullscreen) noexcept; inline bool isShaded() const noexcept; inline void setIsShaded(bool isShaded) noexcept; inline bool hasSkipTaskbar() const noexcept; inline void setHasSkipTaskbar(bool skipTaskbar) noexcept; inline bool hasSkipSwitcher() const noexcept; inline void setHasSkipSwitcher(bool skipSwitcher) noexcept; inline bool isOnAllDesktops() const noexcept; inline void setIsOnAllDesktops(bool alldesktops) noexcept; inline bool isOnAllActivities() const noexcept; inline void setIsOnAllActivities(bool allactivities) noexcept; //ability inline bool isCloseable() const noexcept; inline void setIsClosable(bool closable) noexcept; inline bool isFullScreenable() const noexcept; inline void setIsFullScreenable(bool fullscreenable) noexcept; inline bool isGroupable() const noexcept; inline void setIsGroupable(bool groupable) noexcept; inline bool isMaximizable() const; inline void setIsMaximizable(bool maximizable); inline bool isMinimizable() const; inline void setIsMinimizable(bool minimizable); inline bool isMovable() const noexcept; inline void setIsMovable(bool movable) noexcept; inline bool isResizable() const noexcept; inline void setIsResizable(bool resizable) noexcept; inline bool isShadeable() const noexcept; inline void setIsShadeable(bool shadeble) noexcept; inline bool isVirtualDesktopsChangeable() const noexcept; inline void setIsVirtualDesktopsChangeable(bool virtualdesktopchangeable) noexcept; // //ability // inline bool isMainWindow() const noexcept; // inline bool isChildWindow() const noexcept; // inline QRect geometry() const noexcept; // inline void setGeometry(const QRect &geometry) noexcept; // inline QString appName() const noexcept; // inline void setAppName(const QString &appName) noexcept; // inline QString display() const noexcept; // inline void setDisplay(const QString &display) noexcept; inline QIcon icon() const noexcept; inline void setIcon(const QIcon &icon) noexcept; // inline WindowId wid() const noexcept; // inline void setWid(const WindowId &wid) noexcept; // inline WindowId parentId() const noexcept; // inline void setParentId(const WindowId &parentId) noexcept; inline QStringList desktops() const noexcept; inline void setDesktops(const QStringList &desktops) noexcept; // inline QStringList activities() const noexcept; // inline void setActivities(const QStringList &activities) noexcept; inline bool isOnDesktop(const QString &desktop) const noexcept; // inline bool isOnActivity(const QString &activity) const noexcept; private: void* m_handle; bool m_isWayland; WindowId m_wid{0}; WindowId m_parentId{0}; QRect m_geometry; bool m_isValid : 1; bool m_isActive : 1; bool m_isMinimized : 1; bool m_isMaxVert : 1; bool m_isMaxHoriz : 1; bool m_isFullscreen : 1; bool m_isShaded : 1; bool m_isPlasmaDesktop : 1; bool m_isKeepAbove: 1; bool m_hasSkipTaskbar: 1; bool m_isOnAllDesktops: 1; bool m_isOnAllActivities: 1; bool m_hasSkipSwitcher: 1; //!BEGIN: Window Abilities bool m_isClosable : 1; bool m_isFullScreenable : 1; bool m_isGroupable : 1; bool m_isMaximizable : 1; bool m_isMinimizable : 1; bool m_isMovable : 1; bool m_isResizable : 1; bool m_isShadeable : 1; bool m_isVirtualDesktopsChangeable : 1; QString m_appName; QString m_display; QIcon m_icon; QStringList m_desktops; QStringList m_activities; }; bool WindowInfo::isPlasmaDesktop() const { return m_isPlasmaDesktop; } void WindowInfo::setIsPlasmaDesktop(bool isPlasmaDesktop) { m_isPlasmaDesktop = isPlasmaDesktop; } bool WindowInfo::isValid() const { return m_isValid; } void WindowInfo::setIsValid(bool isValid) { m_isValid = isValid; } bool WindowInfo::isActive() const noexcept { return m_isActive; } void WindowInfo::setIsActive(bool isActive) noexcept { m_isActive = isActive; } bool WindowInfo::isMaxVert() const { return m_isMaxVert; } void WindowInfo::setIsMaxVert(bool isMaxVert) { m_isMaxVert = isMaxVert; } bool WindowInfo::isMaxHoriz() const { return m_isMaxHoriz; } void WindowInfo::setIsMaxHoriz(bool isMaxHoriz) { m_isMaxHoriz = isMaxHoriz; } WindowInfo::WindowId WindowInfo::wid() const { return m_wid; } void WindowInfo::setWid(const WindowId &wid) { m_wid = wid; } bool WindowInfo::isKeepAbove() const { return m_isKeepAbove; } void WindowInfo::setIsKeepAbove(bool isKeepAbove) { m_isKeepAbove = isKeepAbove; } bool WindowInfo::isMinimized() const { return m_isMinimized; } void WindowInfo::setIsMinimized(bool isMinimized) { m_isMinimized = isMinimized; } bool WindowInfo::isMaximized() const { return m_isMaxVert && m_isMaxHoriz; } bool WindowInfo::isFullscreen() const noexcept { return m_isFullscreen; } void WindowInfo::setIsFullscreen(bool isFullscreen) noexcept { m_isFullscreen = isFullscreen; } bool WindowInfo::isShaded() const noexcept { return m_isShaded; } void WindowInfo::setIsShaded(bool isShaded) noexcept { m_isShaded = isShaded; } bool WindowInfo::hasSkipTaskbar() const noexcept { return m_hasSkipTaskbar; } void WindowInfo::setHasSkipTaskbar(bool skipTaskbar) noexcept { m_hasSkipTaskbar = skipTaskbar; } inline bool WindowInfo::hasSkipSwitcher() const noexcept { return m_hasSkipSwitcher; } inline void WindowInfo::setHasSkipSwitcher(bool skipSwitcher) noexcept { m_hasSkipSwitcher = skipSwitcher; } bool WindowInfo::isOnAllDesktops() const noexcept { return m_isOnAllDesktops; } void WindowInfo::setIsOnAllDesktops(bool alldesktops) noexcept { m_isOnAllDesktops = alldesktops; } bool WindowInfo::isOnAllActivities() const noexcept { return m_isOnAllActivities; } void WindowInfo::setIsOnAllActivities(bool allactivities) noexcept { m_isOnAllActivities = allactivities; } bool WindowInfo::isCloseable() const noexcept { return m_isClosable; } void WindowInfo::setIsClosable(bool closable) noexcept { m_isClosable = closable; } bool WindowInfo::isFullScreenable() const noexcept { return m_isFullScreenable; } void WindowInfo::setIsFullScreenable(bool fullscreenable) noexcept { m_isFullScreenable = fullscreenable; } bool WindowInfo::isGroupable() const noexcept { return m_isGroupable; } void WindowInfo::setIsGroupable(bool groupable) noexcept { m_isGroupable = groupable; } bool WindowInfo::isMaximizable() const { return m_isMaximizable; } void WindowInfo::setIsMaximizable(bool maximizable) { m_isMaximizable = maximizable; } bool WindowInfo::isMinimizable() const { return m_isMinimizable; } void WindowInfo::setIsMinimizable(bool minimizable) { m_isMinimizable = minimizable; } bool WindowInfo::isOnDesktop(const QString &desktop) const noexcept { return m_isOnAllDesktops || m_desktops.contains(desktop); } bool WindowInfo::isMovable() const noexcept { return m_isMovable; } void WindowInfo::setIsMovable(bool movable) noexcept { m_isMovable = movable; } bool WindowInfo::isResizable() const noexcept { return m_isResizable; } void WindowInfo::setIsResizable(bool resizable) noexcept { m_isResizable = resizable; } bool WindowInfo::isShadeable() const noexcept { return m_isShadeable; } void WindowInfo::setIsShadeable(bool shadeble) noexcept { m_isShadeable = shadeble; } bool WindowInfo::isVirtualDesktopsChangeable() const noexcept { return m_isVirtualDesktopsChangeable; } void WindowInfo::setIsVirtualDesktopsChangeable(bool virtualdesktopchangeable) noexcept { m_isVirtualDesktopsChangeable = virtualdesktopchangeable; } QIcon WindowInfo::icon() const noexcept { return m_icon; } void WindowInfo::setIcon(const QIcon &icon) noexcept { m_icon = icon; } QStringList WindowInfo::desktops() const noexcept { return m_desktops; } void WindowInfo::setDesktops(const QStringList &desktops) noexcept { m_desktops = desktops; } } #endif // WINDOWINFO_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/waylandhelper.h0000664000175000017500000000224614474244170024713 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WAYLANDHELPER_H #define WAYLANDHELPER_H #include "kysdk-waylandhelper_global.h" #include namespace kdk { class KYSDKWAYLANDHELPER_EXPORT WaylandHelper:public QObject { public: static bool isWaylandServer(); static bool isWaylandClient(); static WaylandHelper *self(); private: WaylandHelper(QObject* parent=nullptr); }; } #endif // WAYLANDHELPER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/waylandhelper.cpp0000664000175000017500000000310414474244170025240 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "waylandhelper.h" #include #include using namespace kdk; static const char* server_flag = "XDG_SESSION_TYPE"; static const char* client_flag = "QT_QPA_PLATFORM"; static WaylandHelper* g_instance = nullptr; bool WaylandHelper::isWaylandServer() { if (qgetenv(server_flag) == QString("wayland")) { return true; } else { return false; } } bool WaylandHelper::isWaylandClient() { if (qgetenv(client_flag) == QString("wayland")) { return true; } else { return false; } } WaylandHelper *WaylandHelper::self() { if (!g_instance) g_instance = new WaylandHelper(); return g_instance; } WaylandHelper::WaylandHelper(QObject *parent) :QObject(parent) { } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/0000775000175000017500000000000014474244170025135 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/xatom-helper.cpp0000664000175000017500000001377414474244076030267 0ustar adminadmin/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "xatom-helper.h" #include #include #include #include #include static XAtomHelper *global_instance = nullptr; XAtomHelper *XAtomHelper::getInstance() { if (!global_instance) global_instance = new XAtomHelper; return global_instance; } bool XAtomHelper::isFrameLessWindow(int winId) { auto hints = getInstance()->getWindowMotifHint(winId); if (hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) { return true; } return false; } bool XAtomHelper::isWindowDecorateBorderOnly(int winId) { return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId)); } bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint) { bool isDeco = false; if (hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) { if (hint.decorations == MWM_DECOR_BORDER) isDeco = true; } return isDeco; } bool XAtomHelper::isUKUICsdSupported() { // fixme: return false; } bool XAtomHelper::isUKUIDecorationWindow(int winId) { if (m_ukuiDecorationAtion == None) return false; Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; bool isUKUIDecoration = false; XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, 0, LONG_MAX, false, m_ukuiDecorationAtion, &type, &format, &nitems, &bytes_after, &data); if (type == m_ukuiDecorationAtion) { if (nitems == 1) { isUKUIDecoration = data[0]; } } return isUKUIDecoration; } UnityCorners XAtomHelper::getWindowBorderRadius(int winId) { UnityCorners corners; Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; if (m_unityBorderRadiusAtom != None) { XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, 0, LONG_MAX, false, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &data); if (type == XA_CARDINAL) { if (nitems == 4) { corners.topLeft = static_cast(data[0]); corners.topRight = static_cast(data[1*sizeof (ulong)]); corners.bottomLeft = static_cast(data[2*sizeof (ulong)]); corners.bottomRight = static_cast(data[3*sizeof (ulong)]); } XFree(data); } } return corners; } void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight}; XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight}; XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set) { if (m_ukuiDecorationAtion == None) return; XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1); } void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints) { if (m_unityBorderRadiusAtom == None) return; XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof (MotifWmHints)/ sizeof (ulong)); } MotifWmHints XAtomHelper::getWindowMotifHint(int winId) { MotifWmHints hints; if (m_unityBorderRadiusAtom == None) return hints; uchar *data; Atom type; int format; ulong nitems; ulong bytes_after; XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom, 0, sizeof (MotifWmHints)/sizeof (long), false, AnyPropertyType, &type, &format, &nitems, &bytes_after, &data); if (type == None) { return hints; } else { hints = *(MotifWmHints *)data; XFree(data); } return hints; } XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent) { if (!QX11Info::isPlatformX11()) return; m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true); m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false); m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false); } Atom XAtomHelper::registerUKUICsdNetWmSupportAtom() { // fixme: return None; } void XAtomHelper::unregisterUKUICsdNetWmSupportAtom() { // fixme: } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/xatom-helper.h0000664000175000017500000000625314474244076027726 0ustar adminadmin/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef XATOMHELPER_H #define XATOMHELPER_H #include struct UnityCorners { ulong topLeft = 0; ulong topRight = 0; ulong bottomLeft = 0; ulong bottomRight = 0; }; typedef struct { ulong flags = 0; ulong functions = 0; ulong decorations = 0; long input_mode = 0; ulong status = 0; } MotifWmHints, MwmHints; #define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_INPUT_MODE (1L << 2) #define MWM_HINTS_STATUS (1L << 3) #define MWM_FUNC_ALL (1L << 0) #define MWM_FUNC_RESIZE (1L << 1) #define MWM_FUNC_MOVE (1L << 2) #define MWM_FUNC_MINIMIZE (1L << 3) #define MWM_FUNC_MAXIMIZE (1L << 4) #define MWM_FUNC_CLOSE (1L << 5) #define MWM_DECOR_ALL (1L << 0) #define MWM_DECOR_BORDER (1L << 1) #define MWM_DECOR_RESIZEH (1L << 2) #define MWM_DECOR_TITLE (1L << 3) #define MWM_DECOR_MENU (1L << 4) #define MWM_DECOR_MINIMIZE (1L << 5) #define MWM_DECOR_MAXIMIZE (1L << 6) #define MWM_INPUT_MODELESS 0 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 #define MWM_INPUT_SYSTEM_MODAL 2 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL #define MWM_TEAROFF_WINDOW (1L<<0) namespace UKUI { class Decoration; } class XAtomHelper : public QObject { friend class UKUI::Decoration; Q_OBJECT public: static XAtomHelper *getInstance(); static bool isFrameLessWindow(int winId); bool isWindowDecorateBorderOnly(int winId); bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint); bool isUKUICsdSupported(); bool isUKUIDecorationWindow(int winId); UnityCorners getWindowBorderRadius(int winId); void setWindowBorderRadius(int winId, const UnityCorners &data); void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight); void setUKUIDecoraiontHint(int winId, bool set = true); void setWindowMotifHint(int winId, const MotifWmHints &hints); MotifWmHints getWindowMotifHint(int winId); private: explicit XAtomHelper(QObject *parent = nullptr); unsigned long registerUKUICsdNetWmSupportAtom(); void unregisterUKUICsdNetWmSupportAtom(); unsigned long m_motifWMHintsAtom = 0l; unsigned long m_unityBorderRadiusAtom = 0l; unsigned long m_ukuiDecorationAtion = 0l; }; #endif // XATOMHELPER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-core.c0000664000175000017500000000334514474244170031336 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ /* Generated by wayland-scanner 1.18.0 */ #include #include #include "wayland-util.h" #ifndef __has_attribute # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) #define WL_PRIVATE __attribute__ ((visibility("hidden"))) #else #define WL_PRIVATE #endif extern const struct wl_interface wl_surface_interface; static const struct wl_interface *custom_types[] = { &wl_surface_interface, &wl_surface_interface, NULL, &wl_surface_interface, NULL, NULL, NULL, NULL, }; static const struct wl_message ukui_decoration_requests[] = { { "move_surface", "o", custom_types + 0 }, { "set_ukui_decoration_mode", "ou", custom_types + 1 }, { "set_unity_border_radius", "ouuuu", custom_types + 3 }, }; WL_PRIVATE const struct wl_interface ukui_decoration_interface = { "ukui_decoration", 1, 3, ukui_decoration_requests, 0, NULL, }; libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp0000664000175000017500000000764614474244170032370 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ukui-decoration-manager.h" #include "ukui-decoration-client.h" #include #include #include static UKUIDecorationManager *global_instance = nullptr; static wl_display *display = nullptr; static ukui_decoration *ukui_decoration_manager = nullptr; static void handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { if (strcmp(interface, ukui_decoration_interface.name) == 0) { ukui_decoration_manager = (ukui_decoration *) wl_registry_bind(registry, name, &ukui_decoration_interface, version); } } static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) { // Who cares } static const struct wl_registry_listener registry_listener = { .global = handle_global, .global_remove = handle_global_remove, }; UKUIDecorationManager *UKUIDecorationManager::getInstance() { if (!global_instance) global_instance = new UKUIDecorationManager; return global_instance; } bool UKUIDecorationManager::supportUKUIDecoration() { return ukui_decoration_manager; } bool UKUIDecorationManager::moveWindow(QWindow *windowHandle) { if (!supportUKUIDecoration()) return false; auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle); if (!kde_surface) return false; wl_surface *surface = *kde_surface; if (!surface) return false; ukui_decoration_move_surface(ukui_decoration_manager, surface); wl_surface_commit(surface); wl_display_roundtrip(display); return true; } bool UKUIDecorationManager::removeHeaderBar(QWindow *windowHandle) { if (!supportUKUIDecoration()) return false; auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle); if (!kde_surface) return false; wl_surface *surface = *kde_surface; if (!surface) return false; ukui_decoration_set_ukui_decoration_mode(ukui_decoration_manager, surface, 1); wl_surface_commit(surface); wl_display_roundtrip(display); return true; } bool UKUIDecorationManager::setCornerRadius(QWindow *windowHandle, int topleft, int topright, int bottomleft, int bottomright) { if (!supportUKUIDecoration()) return false; auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle); if (!kde_surface) return false; wl_surface *surface = *kde_surface; if (!surface) return false; ukui_decoration_set_unity_border_radius(ukui_decoration_manager, surface, topleft, topright, bottomleft, bottomright); wl_surface_commit(surface); wl_display_roundtrip(display); return true; } UKUIDecorationManager::UKUIDecorationManager() { auto connectionThread = KWayland::Client::ConnectionThread::fromApplication(qApp); display = connectionThread->display(); struct wl_registry *registry = wl_display_get_registry(display); // get ukui_decoration_manager wl_registry_add_listener(registry, ®istry_listener, nullptr); wl_display_roundtrip(display); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.h0000664000175000017500000000241114474244170032016 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef UKUIDECORATIONMANAGER_H #define UKUIDECORATIONMANAGER_H #include class UKUIDecorationManager { public: static UKUIDecorationManager *getInstance(); bool supportUKUIDecoration(); bool moveWindow(QWindow *windowHandle); bool removeHeaderBar(QWindow *windowHandle); bool setCornerRadius(QWindow *windowHandle, int topleft, int topright, int bottomleft, int bottomright); private: UKUIDecorationManager(); }; #endif // UKUIDECORATIONMANAGER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.h0000664000175000017500000000234014474244170030543 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef UKUISTYLEHELPER_H #define UKUISTYLEHELPER_H #include namespace kdk { class UkuiStyleHelper:public QObject { public: static UkuiStyleHelper *self(); /** * @brief 移除窗管标题栏 * @param widget */ void removeHeader(QWidget* widget); protected: bool eventFilter(QObject *obj, QEvent *ev) override; private: UkuiStyleHelper(); QWidget* m_widget; }; } #endif // UKUISTYLEHELPER_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp0000664000175000017500000000424414474244170031103 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ukuistylehelper.h" #include "../waylandhelper.h" #include "ukui-decoration-manager.h" #include "xatom-helper.h" #include #include namespace kdk { static UkuiStyleHelper *global_instance = nullptr; UkuiStyleHelper *UkuiStyleHelper::self() { if(global_instance) return global_instance; else { global_instance = new UkuiStyleHelper(); return global_instance; } } void UkuiStyleHelper::removeHeader(QWidget* widget) { if(!widget) return; QString platform = QGuiApplication::platformName(); if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { m_widget = widget; m_widget->installEventFilter(this); } else { MotifWmHints hints1; hints1.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; hints1.functions = MWM_FUNC_ALL; hints1.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(widget->winId(), hints1); } } bool UkuiStyleHelper::eventFilter(QObject *obj, QEvent *ev) { if(obj == m_widget && (ev->type() == QEvent::PlatformSurface || ev->type() == QEvent::Show || ev->type() == QEvent::Paint)) { UKUIDecorationManager::getInstance()->removeHeaderBar(m_widget->windowHandle()); } return QObject::eventFilter(obj,ev); } UkuiStyleHelper::UkuiStyleHelper() { } } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-client.h0000664000175000017500000001006614474244170031667 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ /* Generated by wayland-scanner 1.18.0 */ #ifndef CUSTOM_CLIENT_PROTOCOL_H #define CUSTOM_CLIENT_PROTOCOL_H #include #include #include "wayland-client.h" #ifdef __cplusplus extern "C" { #endif struct ukui_decoration; struct wl_surface; /** * @page page_iface_ukui_decoration ukui_decoration * @section page_iface_ukui_decoration_desc Description * * This example shows how to add extra functionality to Wayland * through an extension. This is the global object of the extension. * @section page_iface_ukui_decoration_api API * See @ref iface_ukui_decoration. */ /** * @defgroup iface_ukui_decoration The ukui_decoration interface * * This example shows how to add extra functionality to Wayland * through an extension. This is the global object of the extension. */ extern const struct wl_interface ukui_decoration_interface; #define UKUI_DECORATION_MOVE_SURFACE 0 #define UKUI_DECORATION_SET_UKUI_DECORATION_MODE 1 #define UKUI_DECORATION_SET_UNITY_BORDER_RADIUS 2 /** * @ingroup iface_ukui_decoration */ #define UKUI_DECORATION_MOVE_SURFACE_SINCE_VERSION 1 /** * @ingroup iface_ukui_decoration */ #define UKUI_DECORATION_SET_UKUI_DECORATION_MODE_SINCE_VERSION 1 /** * @ingroup iface_ukui_decoration */ #define UKUI_DECORATION_SET_UNITY_BORDER_RADIUS_SINCE_VERSION 1 /** @ingroup iface_ukui_decoration */ static inline void ukui_decoration_set_user_data(struct ukui_decoration *ukui_decoration, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) ukui_decoration, user_data); } /** @ingroup iface_ukui_decoration */ static inline void * ukui_decoration_get_user_data(struct ukui_decoration *ukui_decoration) { return wl_proxy_get_user_data((struct wl_proxy *) ukui_decoration); } static inline uint32_t ukui_decoration_get_version(struct ukui_decoration *ukui_decoration) { return wl_proxy_get_version((struct wl_proxy *) ukui_decoration); } /** @ingroup iface_ukui_decoration */ static inline void ukui_decoration_destroy(struct ukui_decoration *ukui_decoration) { wl_proxy_destroy((struct wl_proxy *) ukui_decoration); } /** * @ingroup iface_ukui_decoration * * Inform the compositor that the client has a new surface that is * covered by the extension. */ static inline void ukui_decoration_move_surface(struct ukui_decoration *ukui_decoration, struct wl_surface *surface) { wl_proxy_marshal((struct wl_proxy *) ukui_decoration, UKUI_DECORATION_MOVE_SURFACE, surface); } /** * @ingroup iface_ukui_decoration * * The compositor should perform a move animation on the surface. */ static inline void ukui_decoration_set_ukui_decoration_mode(struct ukui_decoration *ukui_decoration, struct wl_surface *surface, uint32_t mode) { wl_proxy_marshal((struct wl_proxy *) ukui_decoration, UKUI_DECORATION_SET_UKUI_DECORATION_MODE, surface, mode); } /** * @ingroup iface_ukui_decoration * * The compositor should perform a move animation on the surface. */ static inline void ukui_decoration_set_unity_border_radius(struct ukui_decoration *ukui_decoration, struct wl_surface *surface, uint32_t topleft, uint32_t topright, uint32_t bottomleft, uint32_t bottomright) { wl_proxy_marshal((struct wl_proxy *) ukui_decoration, UKUI_DECORATION_SET_UNITY_BORDER_RADIUS, surface, topleft, topright, bottomleft, bottomright); } #ifdef __cplusplus } #endif #endif libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/kysdk-waylandhelper_global.h0000664000175000017500000000211114474244170027345 0ustar adminadmin/* * libkysdk-waylandhelper's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KYSDKWAYLANDHELPER_GLOBAL_H #define KYSDKWAYLANDHELPER_GLOBAL_H #include #if defined(KYSDKWAYLANDHELPER_LIBRARY) # define KYSDKWAYLANDHELPER_EXPORT Q_DECL_EXPORT #else # define KYSDKWAYLANDHELPER_EXPORT Q_DECL_IMPORT #endif #endif // KYSDKWAYLANDHELPER_GLOBAL_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/0000775000175000017500000000000014474244076022074 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/0000775000175000017500000000000014474244170025531 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/0000775000175000017500000000000014474244170031173 5ustar adminadmin././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.cpplibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.cp0000664000175000017500000001432714474244170033011 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent), m_subWidget1(nullptr), m_subWidget2(nullptr) { m_manager = new kdk::WindowManager(); m_timer = new QTimer(this); m_timer->setInterval(2000); initUI(); initConnection(); } Widget::~Widget() { } void Widget::initUI() { QVBoxLayout* mainLayout = new QVBoxLayout(this); QHBoxLayout* hLayout1 = new QHBoxLayout(); m_btnMinimize = new QPushButton("minimize",this); m_btnMaximum = new QPushButton("maximum",this); m_btnActivate = new QPushButton("activate",this); m_btnStayOnTop = new QPushButton("stayOnTop",this); m_btnClose = new QPushButton("close",this); m_btnShowDesktop = new QPushButton("shwDsktp",this); m_shwWindowTitle = new QPushButton("shwTitle",this); m_shwWindowIcon = new QPushButton("shwIcon",this); hLayout1->addWidget(m_btnMinimize); hLayout1->addWidget(m_btnMaximum); hLayout1->addWidget(m_btnActivate); hLayout1->addWidget(m_btnStayOnTop); hLayout1->addWidget(m_btnClose); hLayout1->addWidget(m_btnShowDesktop); hLayout1->addWidget(m_shwWindowTitle); hLayout1->addWidget(m_shwWindowIcon); QHBoxLayout* hLayout2 = new QHBoxLayout(); m_shwWdg1btn1 = new QPushButton("showWg1",this); m_shwWdg1btn2 = new QPushButton("showWg2",this); hLayout2->addWidget(m_shwWdg1btn1); hLayout2->addWidget(m_shwWdg1btn2); QHBoxLayout* hLayout3 = new QHBoxLayout(); m_btnChangeIcon = new QPushButton("changeIcon",this); m_btnChangeTitle = new QPushButton("changeTitle",this); hLayout3->addWidget(m_btnChangeIcon); hLayout3->addWidget(m_btnChangeTitle); mainLayout->addLayout(hLayout1); mainLayout->addLayout(hLayout2); mainLayout->addLayout(hLayout3); this->setWindowIcon(QIcon::fromTheme("kylin-music")); } void Widget::initConnection() { connect(m_manager,&WindowManager::activeWindowChanged,this,[=](const WindowId&wid){ qDebug()<<"activeWindowChanged:"<currentActiveWindow(); }); connect(m_manager,&WindowManager::windowAdded,this,[=](const WindowId& windowId){ m_lastestWindowId = windowId; qDebug()<<"windowAdded:"<minimizeWindow(m_subWidget1->winId()); } }); connect(m_btnMaximum,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { m_manager->maximizeWindow(m_subWidget1->winId()); } }); connect(m_btnActivate,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { m_manager->activateWindow(m_subWidget1->winId()); } }); connect(m_btnStayOnTop,&QPushButton::clicked,this,[=](){ if(!m_subWidget1) { m_subWidget1 = new QWidget(); m_subWidget1->setWindowTitle("widget1"); } m_manager->keepWindowAbove(m_subWidget1->winId()); }); connect(m_btnClose,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { m_manager->closeWindow(m_subWidget1->winId()); } }); connect(m_btnShowDesktop,&QPushButton::clicked,this,[=](){ m_manager->showDesktop(); m_timer->start(); connect(m_timer,&QTimer::timeout,this,[=](){ m_manager->hideDesktop(); }); }); connect(m_shwWdg1btn1,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { m_subWidget1->show(); } else { m_subWidget1 = new QWidget(); m_subWidget1->setWindowTitle("widget1"); m_subWidget1->show(); } }); connect(m_shwWdg1btn2,&QPushButton::clicked,this,[=](){ if(m_subWidget2) { m_subWidget2->show(); } else { m_subWidget2 = new QWidget(); m_subWidget2->setWindowTitle("widget2"); m_subWidget2->show(); } }); connect(m_btnChangeTitle,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { if(m_subWidget1->windowTitle()!= QString("originTitle")) m_subWidget1->setWindowTitle("originTitle"); else m_subWidget1->setWindowTitle("changedTitle"); } }); connect(m_btnChangeIcon,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { if(!m_subWidget1->windowIcon().name().contains("kylin-music")) m_subWidget1->setWindowIcon(QIcon::fromTheme("kylin-music")); else m_subWidget1->setWindowIcon(QIcon::fromTheme("kylin-network")); } }); connect(m_shwWindowTitle,&QPushButton::clicked,this,[=](){ if(m_subWidget1) qDebug() << m_manager->getWindowTitle(m_subWidget1->winId()); }); connect(m_shwWindowIcon,&QPushButton::clicked,this,[=](){ if(m_subWidget1) { WindowId nb = m_manager->currentActiveWindow(); qDebug() << m_manager->getWindowIcon(nb); } }); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.h0000664000175000017500000000316314474244170032632 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include #include #include "windowmanager/windowmanager.h" using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); void initUI(); void initConnection(); private: QWidget* m_subWidget1; QWidget* m_subWidget2; QPushButton* m_btnMinimize; QPushButton* m_btnMaximum; QPushButton* m_btnActivate; QPushButton* m_btnStayOnTop; QPushButton* m_btnClose; QPushButton* m_btnShowDesktop; QPushButton* m_btnChangeIcon; QPushButton* m_btnChangeTitle; QPushButton* m_shwWdg1btn1; QPushButton* m_shwWdg1btn2; QPushButton* m_shwWindowTitle; QPushButton* m_shwWindowIcon; kdk::WindowManager *m_manager; QTimer* m_timer; WindowId m_lastestWindowId; }; #endif // WIDGET_H ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.2fbbdfelibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.0000664000175000017500000005317414474244076032767 0ustar adminadmin EnvironmentId {2fbbdfe0-46ea-4bec-b909-73a0b852001a} ProjectExplorer.Project.ActiveTarget 0 ProjectExplorer.Project.EditorSettings true false true Cpp CppGlobal QmlJS QmlJSGlobal 2 UTF-8 false 4 false 80 true true 1 true false 0 true true 0 8 true 1 true true true false ProjectExplorer.Project.PluginSettings ProjectExplorer.Project.Target.0 桌面 桌面 {d0fe3a0f-07ac-433e-b833-ff24c72691fa} 0 0 0 /home/sunzhen/kysdk-waylandhelper/build true QtProjectManager.QMakeBuildStep true false false false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 /home/sunzhen/kysdk-waylandhelper/test/build-testWindowManager-unknown-Release true QtProjectManager.QMakeBuildStep false false false true true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Release Qt4ProjectManager.Qt4BuildConfiguration 0 /home/sunzhen/kysdk-waylandhelper/test/build-testWindowManager-unknown-Profile true QtProjectManager.QMakeBuildStep true false true true true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Profile Qt4ProjectManager.Qt4BuildConfiguration 0 3 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 ProjectExplorer.DefaultDeployConfiguration 1 dwarf cpu-cycles 250 -e cpu-cycles --call-graph dwarf,4096 -F 250 -F true 4096 false false 1000 true false false false false true 0.01 10 true kcachegrind 1 25 1 true false true valgrind 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 Qt4ProjectManager.Qt4RunConfiguration:/home/sunzhen/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro /home/sunzhen/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro false false true true false false true /home/sunzhen/kysdk-waylandhelper/build 1 ProjectExplorer.Project.TargetCount 1 ProjectExplorer.Project.Updater.FileVersion 22 Version 22 libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/widget.cpp0000664000175000017500000003641714474244170027533 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include #include #include #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent), m_subWidget(nullptr) { m_timer = new QTimer(this); m_timer->setInterval(2000); connect(WindowManager::self(),&WindowManager::windowAdded,this,[=](const WindowId& windowId){ /*注意: * 最新创建的窗体被设置为操作窗体,此demo中每个按钮对应一个接口函数调用,所有接口函数操作的窗口都是该最新创建的窗体 */ m_lastestWindowId = windowId; qDebug()<<"窗口添加:"<setText("注意:最新创建的窗体被设置为操作窗体,此demo中每个按钮对应一个接口函数调用,所有接口函数操作的窗口都是该最新创建的窗体"); m_btnMinimize = new QPushButton("最小化窗口",this); m_btnMaximum = new QPushButton("最大化窗口",this); m_btnActivate = new QPushButton("激活窗口",this); m_btnStayOnTop = new QPushButton("置顶窗口",this); m_btnClose = new QPushButton("关闭窗口",this); m_btnShowDesktop = new QPushButton("显示桌面",this); m_shwWindowTitle = new QPushButton("获取窗口标题",this); m_shwWindowIcon = new QPushButton("获取窗口图标",this); m_btnShowGroup = new QPushButton("获取窗口所属组",this); m_btnprintList = new QPushButton("获取窗口列表",this); m_btnSetGeometry = new QPushButton("设置窗口大小",this); hLayout1->addWidget(m_btnMinimize); hLayout1->addWidget(m_btnMaximum); hLayout1->addWidget(m_btnActivate); hLayout1->addWidget(m_btnStayOnTop); hLayout1->addWidget(m_btnClose); QLabel *label = new QLabel(this); label->setText("依次输入起点x,起点y,宽度w,高度h"); m_posX = new QSpinBox(this); m_posY = new QSpinBox(this); m_width = new QSpinBox(this); m_height = new QSpinBox(this); m_posX->setRange(0,2000); m_posY->setRange(0,2000); m_width->setRange(1,2000); m_height->setRange(1,2000); m_posX->setValue(0); m_posY->setValue(0); m_width->setValue(800); m_height->setValue(600); QHBoxLayout *hLayout5 = new QHBoxLayout; hLayout5->addWidget(m_posX); hLayout5->addWidget(m_posY); hLayout5->addWidget(m_width); hLayout5->addWidget(m_height); QHBoxLayout* hLayout2 = new QHBoxLayout(); m_shwWdgbtn = new QPushButton("打开测试窗口",this); hLayout2->addWidget(m_shwWdgbtn); hLayout2->addWidget(m_btnSetGeometry); hLayout2->addWidget(new QLabel("设置窗口类型",this)); m_setTypeBox = new QComboBox(this); QStringList l; l<<"Widget"<<"Window"<<"Dialog"<<"Sheet"<<"Drawer"<<"Popup"<<"Tool"<<"ToolTip"<< "SplashScreen"<<"Desktop"<<"SubWindow"<<"ForeignWindow"<<"CoverWindow"; m_setTypeBox->addItems(l); hLayout2->addWidget(m_setTypeBox); QHBoxLayout* hLayout4 = new QHBoxLayout(); hLayout4->addWidget(m_btnShowDesktop); hLayout4->addWidget(m_shwWindowTitle); hLayout4->addWidget(m_shwWindowIcon); hLayout4->addWidget(m_btnShowGroup); hLayout4->addWidget(m_btnprintList); QHBoxLayout* hLayout3 = new QHBoxLayout(); m_btnChangeIcon = new QPushButton("更改图标",this); m_btnChangeTitle = new QPushButton("更改标题",this); m_btnGetType = new QPushButton("获取窗口类型",this); hLayout3->addWidget(m_btnChangeIcon); hLayout3->addWidget(m_btnChangeTitle); hLayout3->addWidget(m_btnGetType); QGroupBox *box2 = new QGroupBox("2.0需求接口",this); QHBoxLayout *hLayout6 = new QHBoxLayout(); m_skipTaskbarBtn = new QPushButton("跳过任务栏",this); m_skipSwitcherBtn = new QPushButton("跳过窗口选择器",this); hLayout6->addWidget(m_skipTaskbarBtn); hLayout6->addWidget(m_skipSwitcherBtn); QHBoxLayout *hLayout7 = new QHBoxLayout(); m_showOnAllDesktop = new QPushButton("在所有桌面中显示",this); m_isDesktopShowing = new QPushButton("获取桌面是否处于显示状态",this); hLayout7->addWidget(m_showOnAllDesktop); hLayout7->addWidget(m_isDesktopShowing); QVBoxLayout* vlayout = new QVBoxLayout(); vlayout->addLayout(hLayout6); vlayout->addLayout(hLayout7); box2->setLayout(vlayout); QGroupBox *box3 = new QGroupBox("2.1需求接口",this); QVBoxLayout *vLayout = new QVBoxLayout(); QHBoxLayout *hLayout8 = new QHBoxLayout(); m_isOnCurrentDesktop = new QPushButton("被测窗体是否在当前桌面",this); hLayout8->addStretch(); hLayout8->addWidget(m_isOnCurrentDesktop); vLayout->addLayout(hLayout8); box3->setLayout(vLayout); mainLayout->addWidget(m_label); mainLayout->addLayout(hLayout1); mainLayout->addWidget(label); mainLayout->addLayout(hLayout5); mainLayout->addLayout(hLayout2); mainLayout->addLayout(hLayout3); mainLayout->addLayout(hLayout4); mainLayout->addWidget(box2); mainLayout->addWidget(box3); m_subWidget = new QWidget(); m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-music")); m_subWidget->setWindowTitle("widget"); } void Widget::initConnection() { connect(m_setTypeBox,static_cast(&QComboBox::currentIndexChanged),this,[=](int index) { switch (index) { case 0: m_subWidget->setWindowFlags(Qt::Widget); break; case 1: m_subWidget->setWindowFlags(Qt::Window); break; case 2: m_subWidget->setWindowFlags(Qt::Dialog); break; case 3: m_subWidget->setWindowFlags(Qt::Sheet); break; case 4: m_subWidget->setWindowFlags(Qt::Drawer); break; case 5: m_subWidget->setWindowFlags(Qt::Popup); break; case 6: m_subWidget->setWindowFlags(Qt::Tool); break; case 7: m_subWidget->setWindowFlags(Qt::ToolTip); break; case 8: m_subWidget->setWindowFlags(Qt::SplashScreen); break; case 9: m_subWidget->setWindowFlags(Qt::Desktop); break; case 10: m_subWidget->setWindowFlags(Qt::SubWindow); break; case 11: m_subWidget->setWindowFlags(Qt::ForeignWindow); break; case 12: m_subWidget->setWindowFlags(Qt::CoverWindow); break; default: break; } }); connect(WindowManager::self(),&WindowManager::activeWindowChanged,this,[=](const WindowId&wid){ qDebug()<<"活动窗口改变:"<start(); connect(m_timer,&QTimer::timeout,this,[=](){ WindowManager::hideDesktop(); }); }); connect(m_btnShowGroup,&QPushButton::clicked,this,[=](){ qDebug()<<"窗口所属组:"<show(); }); connect(m_btnChangeTitle,&QPushButton::clicked,this,[=](){ if(m_subWidget) { if(m_subWidget->windowTitle()!= QString("originTitle")) m_subWidget->setWindowTitle("originTitle"); else m_subWidget->setWindowTitle("changedTitle"); } }); connect(m_btnChangeIcon,&QPushButton::clicked,this,[=](){ if(m_subWidget) { if(!m_subWidget->windowIcon().name().contains("kylin-music")) m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-music")); else m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-network")); } }); connect(m_shwWindowTitle,&QPushButton::clicked,this,[=](){ if(m_subWidget) qDebug() << "窗口标题为:"<< WindowManager::getWindowTitle(m_lastestWindowId); }); connect(m_shwWindowIcon,&QPushButton::clicked,this,[=](){ if(m_subWidget) { qDebug() <<"窗口图标为:"< lists = WindowManager::windows(); qDebug()<<"打印窗口列表:"; for(auto id : lists) { qDebug()<show(); QRect rect(m_posX->value(),m_posY->value(),m_width->value(),m_height->value()); WindowManager::setGeometry(m_subWidget->windowHandle(),rect); }); connect(m_btnGetType,&QPushButton::clicked,this,[=](){ /* *Unknown = -1, *Normal = 0 *Desktop = 1, *Dock = 2, *Toolbar = 3, *Menu = 4, *Dialog = 5, *Override = 6, // NON STANDARD *TopMenu = 7, // NON STANDARD *Utility = 8, *Splash = 9, *DropdownMenu = 10, *PopupMenu = 11, *Tooltip = 12, *Notification = 13, *ComboBox = 14, *DNDIcon = 15, *OnScreenDisplay = 16, *CriticalNotification = 17 */ switch (WindowManager::getWindowType(m_subWidget->winId())) { case NET::WindowType::Unknown: qDebug()<<"Unknown"; break; case NET::WindowType::Normal: qDebug()<<"normal"; break; case NET::WindowType::Desktop: qDebug()<<"Desktop"; break; case NET::WindowType::Dock: qDebug()<<"Dock"; break; case NET::WindowType::Toolbar: qDebug()<<"Toolbar"; break; case NET::WindowType::Menu: qDebug()<<"Menu"; break; case NET::WindowType::Dialog: qDebug()<<"Dialog"; break; case NET::WindowType::Override: qDebug()<<"Override"; break; case NET::WindowType::TopMenu: qDebug()<<"TopMenu"; break; case NET::WindowType::Splash: qDebug()<<"Splash"; break; case NET::WindowType::Utility: qDebug()<<"Utility"; break; case NET::WindowType::DropdownMenu: qDebug()<<"DropdownMenu"; break; case NET::WindowType::PopupMenu: qDebug()<<"PopupMenu"; break; case NET::WindowType::Tooltip: qDebug()<<"Tooltip"; break; case NET::WindowType::Notification: qDebug()<<"Notification"; break; case NET::WindowType::ComboBox: qDebug()<<"ComboBox"; break; case NET::WindowType::DNDIcon: qDebug()<<"DNDIcon"; break; case NET::WindowType::OnScreenDisplay: qDebug()<<"OnScreenDisplay"; break; case NET::WindowType::CriticalNotification: qDebug()<<"CriticalNotification"; break; default: qDebug()<winId()); break; } ; }); connect(m_skipTaskbarBtn,&QPushButton::clicked,this,[=](){; WindowManager::setSkipTaskBar(this->windowHandle(),true); QTimer::singleShot(1000,this,[=](){ qDebug()<<"跳过任务栏:"<windowHandle(),true); QTimer::singleShot(1000,this,[=](){ qDebug()<<"跳过窗口选择器"<. * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include using namespace kdk; int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationDisplayName("myAppDisplayName"); a.setApplicationName("myAppName"); Widget w; w.show(); return a.exec(); } ././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootrootlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.571243clibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.0000664000175000017500000005317614474244076032771 0ustar adminadmin EnvironmentId {571243c9-c3e3-4014-9572-ad7097494e31} ProjectExplorer.Project.ActiveTarget 0 ProjectExplorer.Project.EditorSettings true false true Cpp CppGlobal QmlJS QmlJSGlobal 2 UTF-8 false 4 false 80 true true 1 true false 0 true true 0 8 true 1 true true true false ProjectExplorer.Project.PluginSettings ProjectExplorer.Project.Target.0 桌面 桌面 {7903fb4a-39d3-4047-9fbe-2af188f749f8} 0 0 0 /home/kylin/sunzhen/waylandhelper/build true QtProjectManager.QMakeBuildStep true false false false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 /home/kylin/sunzhen/waylandhelper/test/build-testWindowManager-unknown-Release true QtProjectManager.QMakeBuildStep false false false false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Release Qt4ProjectManager.Qt4BuildConfiguration 0 /home/kylin/sunzhen/waylandhelper/test/build-testWindowManager-unknown-Profile true QtProjectManager.QMakeBuildStep true false true false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Profile Qt4ProjectManager.Qt4BuildConfiguration 0 3 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 ProjectExplorer.DefaultDeployConfiguration 1 dwarf cpu-cycles 250 -e cpu-cycles --call-graph dwarf,4096 -F 250 -F true 4096 false false 1000 true false false false false true 0.01 10 true kcachegrind 1 25 1 true false true valgrind 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 Qt4ProjectManager.Qt4RunConfiguration:/home/kylin/sunzhen/waylandhelper/test/testWindowManager/testWindowManager.pro /home/kylin/sunzhen/waylandhelper/test/testWindowManager/testWindowManager.pro false false true true false false true /home/kylin/sunzhen/waylandhelper/build 1 ProjectExplorer.Project.TargetCount 1 ProjectExplorer.Project.Updater.FileVersion 22 Version 22 libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/widget.h0000664000175000017500000000413014474244170027163 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include #include #include #include #include #include "windowmanager/windowmanager.h" using namespace kdk; class QSpinBox; class QComboBox; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); void initUI(); void initConnection(); private: QLabel* m_label; QWidget* m_subWidget; QPushButton* m_btnMinimize; QPushButton* m_btnMaximum; QPushButton* m_btnActivate; QPushButton* m_btnStayOnTop; QPushButton* m_btnClose; QPushButton* m_btnShowDesktop; QPushButton* m_btnChangeIcon; QPushButton* m_btnChangeTitle; QPushButton* m_btnShowGroup; QPushButton* m_shwWdgbtn; QPushButton* m_shwWindowTitle; QPushButton* m_shwWindowIcon; QPushButton* m_btnprintList; QPushButton* m_btnSetGeometry; QPushButton* m_btnGetType; QComboBox* m_setTypeBox; kdk::WindowManager *m_manager; QSpinBox *m_posX; QSpinBox *m_posY; QSpinBox *m_width; QSpinBox *m_height; QTimer* m_timer; WindowId m_lastestWindowId; QPushButton* m_skipTaskbarBtn; QPushButton* m_skipSwitcherBtn; QPushButton* m_showOnAllDesktop; QPushButton* m_isDesktopShowing; QPushButton* m_isOnCurrentDesktop; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro0000664000175000017500000000176614474244076031734 0ustar adminadminQT += core gui KWindowSystem greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 link_pkgconfig PKGCONFIG += kysdk-waylandhelper # 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 libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowInfo/0000775000175000017500000000000014474244170025052 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowInfo/widget.cpp0000664000175000017500000000714714474244170027052 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include Widget::Widget(QWidget *parent) : QWidget(parent) { this->setWindowTitle("testWindowInfo"); initUi(); initConnections(); } Widget::~Widget() { } void Widget::initUi() { QHBoxLayout *hLayout = new QHBoxLayout(); m_btnActivate = new QPushButton("Activate",this); m_btnMaximum = new QPushButton("Maximum",this); m_btnMinimize = new QPushButton("Minimum",this); m_btnClose = new QPushButton("Close",this); m_btnStayOnTop = new QPushButton("StayOnTop",this); hLayout->addWidget(m_btnActivate); hLayout->addWidget(m_btnMaximum); hLayout->addWidget(m_btnMinimize); hLayout->addWidget(m_btnClose); hLayout->addWidget(m_btnStayOnTop); QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->addLayout(hLayout); } void Widget::initConnections() { connect(WindowManager::self(),&WindowManager::windowAdded,this,[=](const WindowId& windowId){ if(WindowManager::getWindowTitle(windowId) == "testWindowInfo") m_lastestWindowId = windowId; }); connect(m_btnActivate,&QPushButton::clicked,this,[=](){ WindowManager::activateWindow(m_lastestWindowId); }); connect(m_btnClose,&QPushButton::clicked,this,[=](){ WindowManager::closeWindow(m_lastestWindowId); }); connect(m_btnMaximum,&QPushButton::clicked,this,[=](){ WindowManager::maximizeWindow(m_lastestWindowId); }); connect(m_btnMinimize,&QPushButton::clicked,this,[=](){ WindowManager::minimizeWindow(m_lastestWindowId); }); connect(m_btnStayOnTop,&QPushButton::clicked,this,[=](){ WindowManager::keepWindowAbove(m_lastestWindowId); }); connect(WindowManager::self(),&WindowManager::windowChanged,this,[=](const WindowId& windowId){ if(m_lastestWindowId == windowId) { kdk::WindowInfo windowInfo = WindowManager::getwindowInfo(m_lastestWindowId); qDebug() << "-----------window state-----------"; qDebug() << "isActive:"<< windowInfo.isActive(); qDebug() << "isMaximized:"<. * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowInfo/testWindowInfo.pro0000664000175000017500000000176714474244076030577 0ustar adminadminQT += core gui KWindowSystem greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 link_pkgconfig PKGCONFIG += kysdk-waylandhelper # 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 libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowInfo/widget.h0000664000175000017500000000252214474244170026507 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include #include "windowmanager/windowinfo.h" #include "windowmanager/windowmanager.h" using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); void initUi(); void initConnections(); private: QPushButton* m_btnMinimize; QPushButton* m_btnMaximum; QPushButton* m_btnActivate; QPushButton* m_btnStayOnTop; QPushButton* m_btnClose; kdk::WindowManager *m_manager; WindowId m_lastestWindowId; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testukuistylehelper/0000775000175000017500000000000014474244170026225 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testukuistylehelper/widget.cpp0000664000175000017500000000155114474244170030216 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) { } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testukuistylehelper/main.cpp0000664000175000017500000000203014474244170027650 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include "ukuistylehelper/ukuistylehelper.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; kdk::UkuiStyleHelper::self()->removeHeader(&w); w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testukuistylehelper/testukuistylehelper.pro0000664000175000017500000000175014474244076033115 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 link_pkgconfig PKGCONFIG += kysdk-waylandhelper # 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 libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testukuistylehelper/widget.h0000664000175000017500000000167314474244170027670 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/0000775000175000017500000000000014474244170020264 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/readme.md0000664000175000017500000000000014474244076022036 0ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/res.qrc0000664000175000017500000000022714474244170021565 0ustar adminadmin translations/gui_zh_CN.qm translations/gui_bo_CN.qm libkysdk-applications-2.2.1.1/kysdk-qtwidgets/translations/0000775000175000017500000000000014474244170023005 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/translations/gui_zh_CN.qm0000664000175000017500000000436714474244170025223 0ustar adminadmin kdk::KAboutDialog No mail application accessible in your system. Unable to open mail application Service & Support: ᠦᠢᠯᠡᠴᠢᠯᠡᠬᠦ ᠪᠠ ᠳᠡᠮᠵᠢᠬᠦ ᠪᠦᠯᠬᠦᠮ: Privacy statement kdk::KAboutDialogPrivate version : Version number not found kdk::KInputDialog Enter a value: ᠲᠤᠭ᠎ᠠ ᠬᠡᠮᠵᠢᠭᠳᠡᠯ ᠢ ᠤᠷᠤᠭᠤᠯᠤᠭᠠᠷᠠᠢ: kdk::KInputDialogPrivate ok ᠪᠠᠳᠤᠯᠠᠬᠤ cancel ᠦᠬᠡᠢᠰᠬᠡᠬᠦ kdk::KMenuButton Options Setting ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ Theme ᠭᠤᠤᠯ ᠰᠡᠳᠦᠪ Assist ᠳᠤᠰᠠᠯᠠᠬᠤ About ᠲᠤᠬᠠᠢ Quit ᠪᠤᠴᠠᠵᠤ ᠭᠠᠷᠬᠤ Auto ᠭᠤᠤᠯ ᠰᠡᠳᠦᠪ ᠢ ᠳᠠᠭᠠᠬᠤ Light ᠬᠦᠶᠦᠬᠡᠨ ᠦᠩᠭᠡ ᠲᠠᠢ ᠭᠤᠤᠯ ᠰᠡᠳᠦᠪ Dark ᠬᠦᠨ ᠦᠩᠭᠡ ᠲᠠᠢ ᠭᠤᠤᠯ ᠰᠡᠳᠦᠪ kdk::KProgressDialog cancel ᠦᠬᠡᠢᠰᠬᠡᠬᠦ kdk::KSearchLineEditPrivate search ᠬᠠᠢᠯᠳᠠ Search ᠬᠠᠢᠯᠳᠠ kdk::KSecurityLevelBar Low ᠳᠤᠤᠷ᠎ᠠ Medium ᠳᠤᠮᠳᠠ High ᠦᠨᠳᠦᠷ kdk::KSecurityLevelBarPrivate Low ᠳᠤᠤᠷ᠎ᠠ kdk::KUninstallDialog uninstall ᠲᠡᠷᠡ ᠳᠠᠷᠤᠢ ᠪᠠᠭᠤᠯᠭᠠᠬᠤ deb name: ᠪᠠᠭᠳᠠᠬᠤ ᠨᠡᠷ᠎ᠡ : deb version: ᠬᠡᠪᠯᠡᠯ: kdk::KUninstallDialogPrivate deb name: ᠪᠠᠭᠳᠠᠬᠤ ᠨᠡᠷ᠎ᠡ: deb version: ᠬᠡᠪᠯᠡᠯ: kdk::KWindowButtonBarPrivate Minimize ᠬᠠᠮᠤᠭ ᠤᠨ ᠪᠠᠭᠠᠴᠢᠯᠠᠯ Close ᠬᠠᠭᠠᠬᠤ Maximize ᠬᠠᠮᠤᠭ ᠤᠨ ᠶᠡᠬᠡᠴᠢᠯᠡᠯ Restore libkysdk-applications-2.2.1.1/kysdk-qtwidgets/translations/gui_bo_CN.qm0000664000175000017500000000637314474244170025201 0ustar adminadmin2$- ,!.5"-3!/ " $7$-$/$- 7 "Enter a value:kdk::KInputDialog&,!"0,!,&cancelkdk::KInputDialogPrivate* 3$/ ,$okkdk::KInputDialogPrivate 2$, "Aboutkdk::KMenuButton3$0 / ,$Assistkdk::KMenuButton&-$$/ 0!3&* " 3 - ,$Autokdk::KMenuButton.,&( &)-! 2 " -$$/ 0!3&*Darkkdk::KMenuButton6,&6&,!( &)-! 2 " -$$/ 0!3&*Lightkdk::KMenuButton*$4 5$ - 7,$Quitkdk::KMenuButton3$,"7 -$/,$Settingkdk::KMenuButton-$$/ 0!3&*Themekdk::KMenuButton&,!"0,!,&cancelkdk::KProgressDialog , "/3 Searchkdk::KSearchLineEditPrivate , "/3 searchkdk::KSearchLineEditPrivate &(3&7Highkdk::KSecurityLevelBar 3$$7 Lowkdk::KSecurityLevelBar 3$.3 Mediumkdk::KSecurityLevelBar 3$$7 Lowkdk::KSecurityLevelBarPrivate* -3 ,$ (!7!  deb name:kdk::KUninstallDialog,!*/!/ deb version:kdk::KUninstallDialog(2!7! 3 7$" * -$/- ,$ uninstallkdk::KUninstallDialog* -3 ,$ (!7! deb name:kdk::KUninstallDialogPrivate,!*/!/ deb version:kdk::KUninstallDialogPrivate , - ,$Closekdk::KWindowButtonBarPrivate$, .$- $( 6!,!4"/!/Maximizekdk::KWindowButtonBarPrivate$, .$- $( * - 4"/ /Minimizekdk::KWindowButtonBarPrivatelibkysdk-applications-2.2.1.1/kysdk-qtwidgets/translations/gui_zh_CN.ts0000664000175000017500000001635114474244170025230 0ustar adminadmin kdk::KAboutDialog No mail application accessible in your system. 您的系统未安装任何电子邮件应用 Unable to open mail application 无法打开邮件客户端 Service & Support: 服务与支持团队: 服务与支持团队: Privacy statement 《隐私声明》 kdk::KAboutDialogPrivate version : 版本: Version number not found 未找到对应版本号 kdk::KInputDialog Enter a value: 请输入数值: kdk::KInputDialogPrivate ok 确认 cancel 取消 kdk::KMenuButton Option 选项 Options 选项 Setting 设置 设置 Theme 外观 Assist 帮助 About 关于 Quit 退出 Auto 跟随系统 Light 浅色 Dark 深色 kdk::KProgressDialog cancel 取消 kdk::KSearchLineEditPrivate search 搜索 Search 搜索 kdk::KSecurityLevelBar Low Medium High kdk::KSecurityLevelBarPrivate Low kdk::KUninstallDialog uninstall 立即卸载 立即卸载 deb name: 包名: deb version: 版本: kdk::KUninstallDialogPrivate deb name: 包名: deb version: 版本: kdk::KWindowButtonBarPrivate Minimize 最小化 Close 关闭 Maximize 最大化 Restore 还原 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/translations/gui_bo_CN.ts0000664000175000017500000002111014474244170025174 0ustar adminadmin kdk::KAboutDialog No mail application accessible in your system. ཁྱེད་རང་གི་མ་ལག་ལ་སྦྲག་རྫས་ཉེར་སྤྱོད་གོ་རིམ་གང་ཡང་སྒྲིག་སྦྱོར་བྱས་མེད་། Unable to open mail application སྦྲག་རྫས་ཉེར་སྤྱོད་བྱ་རིམ་ཁ་ཕྱེ་མི་ཐུབ་། Service & Support: ཞབས་ཞུ་དང་རྒྱབ་སྐྱོར་ཚོགས་པ་ Privacy statement 《གསང་བའི་གསལ་བསྒྲགས། 》 kdk::KAboutDialogPrivate version : པར་གཞི། Version number not found པར་གཞིའི་ཨང་གྲངས་རྙེད་མ་བྱུང་། kdk::KInputDialog Enter a value: ཁྱོད་ཀྱིས་གྲངས་ཀ་ནང་འཇུག་གནང་རོགས། kdk::KInputDialogPrivate ok དངོས་སུ་ཁས་ལེན་པ། cancel མེད་པར་བཟོ་དགོས། kdk::KMenuButton Option འདེམས་ཚན་ Options འདེམས་ཚན་ Setting བཀོད་སྒྲིག་བཅས་བྱ་དགོས། Theme ཕྱི་ཚུལ། Assist རོགས་རམ་བྱེད་དགོས། About དེའི་སྐོར། Quit ཕྱིར་འཐེན་བྱ་དགོས། Auto མ་ལག་གི་རྗེས་སུ་འབྲང་བ Light མདོག་སྨུག་པོ། Dark ཚོས་གཞི་ཟབ་པ། kdk::KProgressDialog cancel མེད་པར་བཟོ་དགོས། kdk::KSearchLineEditPrivate search འཚོལ་ཞིབ་བྱེད་པ། Search འཚོལ་ཞིབ་བྱེད་པ། kdk::KSecurityLevelBar Low དམའ་བ། Medium ཀྲུང་གོའི་གུང་ཀྲུང་ High མཐོན་པོ། kdk::KSecurityLevelBarPrivate Low དམའ་བ། kdk::KUninstallDialog uninstall འཕྲལ་མར་ཕབ་ལེན་བྱེད་དགོས། deb name: འགན་གཙང་ལེན་པའི་མིང་འདི deb version: པར་གཞི། kdk::KUninstallDialogPrivate deb name: འགན་གཙང་ལེན་པའི་མིང་འདི deb version: པར་གཞི། kdk::KWindowButtonBarPrivate Minimize ཆེས་ཆུང་ཅན་ Close སྒོ་རྒྱག་པ་ Maximize ཆེ་ཤོས་སུ་སྒྱུར་བ་ Restore སླར་གསོ་བྱེད་དགོས། libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/0000775000175000017500000000000014474244170021053 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktag.cpp0000664000175000017500000001341614474244170022512 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ktag.h" #include "themeController.h" #include "ktoolbutton.h" #include #include #include #include #include #include #include #include "parmscontroller.h" namespace kdk { class KTagPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KTag) public: KTagPrivate(KTag*parent); void changeTheme(); private: KTag* q_ptr; QString m_text; bool m_isClosable; KToolButton* m_pDeleteBtn; TagStyle m_style; }; KTag::KTag(QWidget *parent) :QPushButton(parent) ,d_ptr(new KTagPrivate(this)) { Q_D(KTag); setClosable(false); d->changeTheme(); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](bool flag){ updateGeometry(); }); } void KTag::setClosable(bool flag) { Q_D(KTag); d->m_isClosable = flag; if(flag) setMinimumWidth(88); update(); } bool KTag::closable() { Q_D(KTag); return d->m_isClosable; } void KTag::setText(const QString &text) { Q_D(KTag); d->m_text = text; update(); } void KTag::setTagStyle(TagStyle style) { Q_D(KTag); d->m_style = style; d->changeTheme(); } TagStyle KTag::tagStyle() { Q_D(KTag); return d->m_style; } QString KTag::text() { Q_D(KTag); return d->m_text; } void KTag::paintEvent(QPaintEvent *event) { Q_D(KTag); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect rect = this->rect(); if(d->m_isClosable) { d->m_pDeleteBtn->show(); d->m_pDeleteBtn->move(width()-d->m_pDeleteBtn->width(),(height()-d->m_pDeleteBtn->height())/2+2); rect.adjust(0,0,-16,0); } else { d->m_pDeleteBtn->hide(); } QColor color = palette().color(QPalette::Highlight); switch (d->m_style) { case HighlightTag: painter.setBrush(color); painter.setPen(Qt::PenStyle::NoPen); painter.drawRoundedRect(this->rect(),6,6); painter.setPen(QColor("#FFFFFF")); painter.drawText(rect,Qt::AlignCenter,d->m_text); break; case BoderTag: painter.setBrush(QColor(Qt::transparent)); painter.setPen(color); painter.drawRoundedRect(this->rect(),6,6); painter.drawText(rect,Qt::AlignCenter,d->m_text); break; case BaseBoderTag: painter.setBrush(QColor(55,144,250,38)); painter.setPen(color); painter.drawRoundedRect(this->rect(),6,6); painter.drawText(rect,Qt::AlignCenter,d->m_text); break; case GrayTag: painter.setBrush(this->palette().color(QPalette::Disabled,QPalette::Highlight)); painter.setPen(Qt::PenStyle::NoPen); painter.drawRoundedRect(this->rect(),6,6); painter.setPen(this->palette().color(QPalette::Text)); painter.drawText(rect,Qt::AlignCenter,d->m_text); break; default: break; } } QSize KTag::sizeHint() const { auto size= QPushButton::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_TagHeight)); return size; } KTagPrivate::KTagPrivate(KTag *parent) :q_ptr(parent), m_isClosable(false), m_text(""), m_style(HighlightTag) { Q_Q(KTag); m_pDeleteBtn = new KToolButton(q); m_pDeleteBtn->setIconSize(QSize(16,16)); connect(m_pDeleteBtn,&KToolButton::clicked,q,&KTag::close); m_pDeleteBtn->hide(); QPalette btnPalette; btnPalette.setBrush(QPalette::Active, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Inactive, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Disabled, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Active, QPalette::Highlight, Qt::transparent); btnPalette.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::transparent); btnPalette.setBrush(QPalette::Disabled, QPalette::Highlight, Qt::transparent); m_pDeleteBtn->setAutoFillBackground(true); m_pDeleteBtn->setPalette(btnPalette); m_pDeleteBtn->setFocusPolicy(Qt::NoFocus); m_pDeleteBtn->setCursor(Qt::ArrowCursor); connect(m_gsetting,&QGSettings::changed,this,[=](){changeTheme();}); } void KTagPrivate::changeTheme() { Q_Q(KTag); initThemeStyle(); QIcon icon = QIcon::fromTheme("application-exit-symbolic"); QPalette palette = q->palette(); QSize size(m_pDeleteBtn->iconSize()); switch (m_style) { case HighlightTag: m_pDeleteBtn->setIcon(drawColoredPixmap(icon.pixmap(size),QColor("#FFFFFF"))); break; case BoderTag: m_pDeleteBtn->setIcon(drawColoredPixmap(icon.pixmap(size),palette.color(QPalette::Text))); break; case BaseBoderTag: m_pDeleteBtn->setIcon(drawColoredPixmap(icon.pixmap(size),palette.color(QPalette::Text))); break; case GrayTag: m_pDeleteBtn->setIcon(drawColoredPixmap(icon.pixmap(size),palette.color(QPalette::Text))); break; default: break; } } } #include "ktag.moc" #include "moc_ktag.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kwidget.cpp0000664000175000017500000003716214474244170023226 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kwidget.h" #include "gui_g.h" #include "xatom-helper.h" #include #include #include #include #include "parmscontroller.h" #include "KWindowEffects" #include #include "ukuistylehelper/ukui-decoration-manager.h" namespace kdk { #define FocusIn QEvent::FocusIn #define FocusOut QEvent::FocusOut class KWidgetPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KWidget) public: KWidgetPrivate(KWidget*parent); private: KWidget *q_ptr; KIconBar* m_pIconBar; KWindowButtonBar* m_pWindowButtonBar; QHBoxLayout* m_pTitleLayout; QHBoxLayout* m_pWidgetLayout; QVBoxLayout* m_pMainLayout; QWidget* m_pBaseWidget; QWidget* m_pSideWidget; QString m_IconName; QGSettings* m_pTransparency; double tranSparency; LayoutType m_layoutType; bool m_sidebarFollowMode; void adjustBackground(); void adjustFlagsTitleStatus(Qt::WindowFlags type); void adjustFlagTitleStatus(Qt::WindowFlags type); }; KWidget::KWidget(QWidget *parent) :QWidget(parent), d_ptr(new KWidgetPrivate(this)) { Q_D(KWidget); setFocusPolicy(Qt::ClickFocus); setObjectName("Kwidget"); this->setAttribute(Qt::WA_TranslucentBackground, true); //透明 // bug 163681 弃用主题毛玻璃,改用kwindowsystem毛玻璃接口 // this->setProperty("useSystemStyleBlur", true); /* 开启背景模糊效果(毛玻璃) */ KWindowEffects::enableBlurBehind(this->winId()); if(Parmscontroller::isTabletMode()) { d->m_pWindowButtonBar->maximumButton()->hide(); } else { d->m_pWindowButtonBar->maximumButton()->show(); } connect(d->m_pWindowButtonBar->minimumButton(),&QPushButton::clicked,this,&KWidget::showMinimized); connect(d->m_pWindowButtonBar->maximumButton(),&QPushButton::clicked,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); connect(d->m_pWindowButtonBar->closeButton(),&QPushButton::clicked,this,&KWidget::close); connect(d->m_pWindowButtonBar,&KWindowButtonBar::doubleClick,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); connect(d->m_pIconBar,&KIconBar::doubleClick,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); changeIconStyle(); connect(m_gsetting,&QGSettings::changed,this,[=](){changeIconStyle();}); if (QGSettings::isSchemaInstalled("org.ukui.control-center.personalise")) { d->m_pTransparency = new QGSettings("org.ukui.control-center.personalise"); d->tranSparency = d->m_pTransparency->get("transparency").toDouble(); connect(d->m_pTransparency, &QGSettings::changed, this, [=](QString value) { if (value == "transparency") { d->tranSparency = d->m_pTransparency->get("transparency").toDouble(); d->adjustBackground(); } }); } d->adjustBackground(); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ if(d->m_sidebarFollowMode) { d->m_pSideWidget->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width)); d->m_pIconBar->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width)); } if(Parmscontroller::isTabletMode()) { if(d->m_pWindowButtonBar->followMode()) d->m_pWindowButtonBar->maximumButton()->hide(); } else { 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)) { MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_ALL; hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); } installEventFilter(this); resize(800,600); } KWidget::~KWidget() { } void KWidget::setIcon(const QIcon &icon) { Q_D(KWidget); d->m_IconName = icon.name(); d->m_pIconBar->setIcon(icon); // setWindowIcon(icon.pixmap(QSize(36,36))); setWindowIcon(icon); } void KWidget::setIcon(const QString &iconName) { Q_D(KWidget); d->m_IconName = iconName; d->m_pIconBar->setIcon(iconName); // setWindowIcon(QIcon::fromTheme(iconName).pixmap(QSize(36,36))); setWindowIcon(QIcon::fromTheme(iconName)); } void KWidget::setWidgetName(const QString &widgetName) { Q_D(KWidget); d->m_pIconBar->setWidgetName(widgetName); QWidget::setWindowTitle(widgetName); } QWidget *KWidget::sideBar() { Q_D(KWidget); return d->m_pSideWidget; } QWidget *KWidget::baseBar() { Q_D(KWidget); return d->m_pBaseWidget; } KWindowButtonBar *KWidget::windowButtonBar() { Q_D(KWidget); return d->m_pWindowButtonBar; } KIconBar *KWidget::iconBar() { Q_D(KWidget); return d->m_pIconBar; } void KWidget::setLayoutType(LayoutType type) { Q_D(KWidget); d->m_layoutType = type; d->adjustBackground(); } 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)) { MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_ALL; hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); } } 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)) { MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_ALL; hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); } } bool KWidget::eventFilter(QObject *target, QEvent *event) { Q_D(KWidget); if(target == this && (event->type() == QEvent::WindowStateChange|| event->type() == QEvent::Show)) { if(this->isMaximized()) d->m_pWindowButtonBar->setMaximumButtonState(MaximumButtonState::Restore); else d->m_pWindowButtonBar->setMaximumButtonState(MaximumButtonState::Maximum); } if(target == this && (event->type() == FocusIn|| event->type() == FocusOut) || event->type() == QEvent::ActivationChange) d->adjustBackground(); QString platform = QGuiApplication::platformName(); if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { if((event->type() == QEvent::PlatformSurface || event->type() == QEvent::Show || event->type() == QEvent::Paint)) { UKUIDecorationManager::getInstance()->removeHeaderBar(this->windowHandle()); } } return QWidget::eventFilter(target, event); } void KWidget::changeIconStyle() { Q_D(KWidget); initThemeStyle(); setIcon(d->m_IconName); } void KWidget::changeTheme() { Q_D(KWidget); initThemeStyle(); d->adjustBackground(); } KWidgetPrivate::KWidgetPrivate(KWidget *parent) :q_ptr(parent), m_sidebarFollowMode(true) { Q_Q(KWidget); m_pMainLayout = new QVBoxLayout(); m_pTitleLayout = new QHBoxLayout(); m_layoutType = VerticalType; //图标和标题名称 m_pIconBar = new KIconBar(q); m_pIconBar->setObjectName("IconBar"); m_pIconBar->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width)); m_pIconBar->setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight)); //窗口三联 m_pWindowButtonBar = new KWindowButtonBar(q); m_pWindowButtonBar->setObjectName("TitleBar"); m_pWindowButtonBar->setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight)); m_pTitleLayout->addWidget(m_pIconBar); m_pTitleLayout->addWidget(m_pWindowButtonBar); m_pTitleLayout->setSpacing(0); m_pTitleLayout->setContentsMargins(0,0,0,0); m_pWidgetLayout = new QHBoxLayout(); m_pBaseWidget = new QWidget(q); m_pBaseWidget->setObjectName("BaseWidget"); m_pSideWidget = new QWidget(q); m_pSideWidget->setObjectName("SideWidget"); m_pSideWidget->setFixedWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_Widget_SideWidget_Width)); m_pWidgetLayout->addWidget(m_pSideWidget); m_pWidgetLayout->addWidget(m_pBaseWidget); m_pMainLayout->addLayout(m_pTitleLayout); m_pMainLayout->addLayout(m_pWidgetLayout); m_pMainLayout->setSpacing(0); m_pMainLayout->setContentsMargins(0,0,0,0); q->setLayout(m_pMainLayout); m_pBaseWidget->setAutoFillBackground(true); m_pBaseWidget->setBackgroundRole(QPalette::Base); m_pWindowButtonBar->setAutoFillBackground(true); m_pWindowButtonBar->setBackgroundRole(QPalette::Base); setParent(parent); } void KWidgetPrivate::adjustBackground() { Q_Q(KWidget); m_pIconBar->setAutoFillBackground(true); m_pSideWidget->setAutoFillBackground(true); QColor sideColor = q->palette().color(QPalette::Window); sideColor.setAlphaF(tranSparency); QPalette sidePalette = q->palette(); sidePalette.setColor(QPalette::Window,sideColor); switch (m_layoutType) { case VerticalType: m_pIconBar->setBackgroundRole(QPalette::Base); m_pSideWidget->hide(); break; case HorizontalType: m_pSideWidget->setPalette(sidePalette); m_pIconBar->setBackgroundRole(QPalette::Window); m_pIconBar->setPalette(sidePalette); m_pSideWidget->show(); break; case MixedType: m_pIconBar->setBackgroundRole(QPalette::Base); m_pSideWidget->setPalette(sidePalette); m_pSideWidget->show(); break; default: 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" #include "moc_kwidget.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcolorcombobox.cpp0000664000175000017500000002077714474244170024616 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kcolorcombobox.h" #include "themeController.h" #include #include #include #include #include #include #include #include #include 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 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 &list) { Q_D(KColorComboBox); d->m_colorList = list; d->updateList(); } QList 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(); 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" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbadge.cpp0000664000175000017500000001041114474244170022771 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kbadge.h" #include "themeController.h" #include #include #include #include #include namespace kdk { class KBadgePrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KBadge) public: KBadgePrivate(KBadge* parent); private: KBadge* q_ptr; QColor m_color; int m_value; int m_fontSize; bool m_isShowValue; bool m_useCustomColor; }; KBadgePrivate::KBadgePrivate(KBadge *parent) :q_ptr(parent) { Q_Q(KBadge); m_value = -1; m_color = q->palette().color(QPalette::Highlight); m_fontSize = 14; m_isShowValue = true; m_useCustomColor=false; setParent(parent); } KBadge::KBadge(QWidget *parent) :QWidget(parent), d_ptr(new KBadgePrivate(this)) { Q_D(KBadge); setMinimumSize(40,30); } void KBadge::setValue(int value) { Q_D(KBadge); d->m_value = value; } void KBadge::setValueVisiable(bool flag) { Q_D(KBadge); d->m_isShowValue = flag; } bool KBadge::isValueVisiable() const { Q_D(const KBadge); return d->m_isShowValue; } int KBadge::value() { Q_D(KBadge); return d->m_value; } QColor KBadge::color() { Q_D(KBadge); return d->m_color; } void KBadge::setColor(const QColor &color) { Q_D(KBadge); d->m_useCustomColor=true; d->m_color = color; } int KBadge::fontSize() { Q_D(KBadge); return d->m_fontSize; } void KBadge::setFontSize(int size) { Q_D(KBadge); if(size<1 ||size >100) return; d->m_fontSize = size; } void KBadge::paintEvent(QPaintEvent *event) { Q_D(KBadge); QFont font(QApplication::font()); font.setPixelSize(d->m_fontSize); QFontMetrics fm(font); int height = fm.height(); int width; if(d->m_value <1 ||!d->m_isShowValue) { width = 10; height = 10; } else if(d->m_value >= 1 && d->m_value < 1000) { width = fm.width(QString::number(d->m_value)) + 10; width = width > height ? width:height; } else { width = fm.width(QString::number(999)) + 10; width = width > height ? width:height; } QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); if(d->m_useCustomColor) painter.setBrush(d->m_color); else painter.setBrush(palette().color(QPalette::Highlight)); QRect tmpRect(rect().center().x()-width/2,rect().center().y()-height/2,width,height); painter.drawRoundedRect(tmpRect,height/2,height/2); //文字颜色固定 painter.setPen(QWidget::palette().color(QPalette::Light)); if(d->m_value >= 1 && d->m_value<1000 && d->m_isShowValue) { QFont font(QApplication::font()); font.setPixelSize(d->m_fontSize); painter.setFont(font); painter.drawText(tmpRect,Qt::AlignCenter,QString::number(d->m_value)); } if(d->m_value >= 1000 && d->m_value < INTMAX_MAX && d->m_isShowValue) { painter.setBrush(QWidget::palette().color(QPalette::Light)); QPointF pointf(rect().center().x(),rect().center().y()); painter.drawEllipse(pointf,qreal(1.5),qreal(1.5)); QPointF leff(pointf.x()-10,pointf.y()); QPointF rightf(pointf.x()+10,pointf.y()); painter.drawEllipse(leff,qreal(1.5),qreal(1.5)); painter.drawEllipse(rightf,qreal(1.5),qreal(1.5)); } } void KBadge::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); repaint(); } } #include "kbadge.moc" #include "moc_kbadge.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktranslucentfloor.cpp0000664000175000017500000000710614474244170025342 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "ktranslucentfloor.h" #include #include #include #include "kshadowhelper.h" #include #include #include namespace kdk { class KTranslucentFloorPrivate :public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KTranslucentFloor) public: KTranslucentFloorPrivate(KTranslucentFloor* parent); private: KTranslucentFloor* q_ptr; int m_radius; bool m_shadowFlag; bool m_enableBlur; qreal m_opacity; }; KTranslucentFloor::KTranslucentFloor(QWidget *parent) :QFrame(parent), d_ptr(new KTranslucentFloorPrivate(this)) { Q_D(KTranslucentFloor); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground,true); } void KTranslucentFloor::setBorderRadius(int radius) { Q_D(KTranslucentFloor); d->m_radius = radius; if(shadow()) { effects::KShadowHelper::self()->setWidget(this,d->m_radius); } } int KTranslucentFloor::borderRadius() { Q_D(KTranslucentFloor); return d->m_radius; } void KTranslucentFloor::setShadow(bool flag) { Q_D(KTranslucentFloor); d->m_shadowFlag = flag; if(d->m_shadowFlag) effects::KShadowHelper::self()->setWidget(this,d->m_radius); } bool KTranslucentFloor::shadow() { Q_D(KTranslucentFloor); return d->m_shadowFlag; } void KTranslucentFloor::setEnableBlur(bool flag) { Q_D(KTranslucentFloor); d->m_enableBlur = flag; } bool KTranslucentFloor::enableBlur() { Q_D(KTranslucentFloor); return d->m_enableBlur; } void KTranslucentFloor::setOpacity(qreal opacity) { Q_D(KTranslucentFloor); d->m_opacity = opacity; } qreal KTranslucentFloor::opacity() { Q_D(KTranslucentFloor); return d->m_opacity; } void KTranslucentFloor::paintEvent(QPaintEvent *event) { Q_D(KTranslucentFloor); QPainterPath path; QRect rect = this->rect(); path.addRoundedRect(rect,d->m_radius,d->m_radius); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); painter.setRenderHints(QPainter::HighQualityAntialiasing); if(d->m_enableBlur) { //开启毛玻璃时 QRegion region(path.toFillPolygon().toPolygon()); KWindowEffects::enableBlurBehind(this->winId(),true,region); this->setMask(region); painter.setOpacity(d->m_opacity); } else { //未开启毛玻璃时 painter.setOpacity(1); } painter.setPen(Qt::NoPen); painter.setBrush(this->palette().color(this->backgroundRole())); painter.drawPath(path); } KTranslucentFloorPrivate::KTranslucentFloorPrivate(KTranslucentFloor *parent) :q_ptr(parent), m_radius(12), m_shadowFlag(true), m_enableBlur(true), m_opacity(0.5) { } } #include "ktranslucentfloor.moc" #include "moc_ktranslucentfloor.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kitemwidget.cpp0000664000175000017500000000737214474244170024105 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "kitemwidget.h" #include "klistwidget.h" #include #include #include namespace kdk { class KItemWidgetPrivate : public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KItemWidget) public: KItemWidgetPrivate(KItemWidget* parent); protected: void changeTheme(); private: KItemWidget* q_ptr; QIcon m_icon; QString m_maintext; QString m_sectext; QSize m_iconsize; QPixmap pixmap; int x; int y; KItemWidget* m_ltem; bool flag = false; }; KItemWidgetPrivate::KItemWidgetPrivate (KItemWidget* parent):q_ptr(parent) { Q_Q(KItemWidget); setParent(parent); m_iconsize=QSize(35,35); x = m_iconsize.width(); y = m_iconsize.height(); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KItemWidgetPrivate::changeTheme); } void KItemWidgetPrivate::changeTheme() { Q_Q(KItemWidget); initThemeStyle(); } KItemWidget::KItemWidget(const QIcon &Myicon, QString MmainText, QString MsecText, QWidget *parent):QWidget(parent),d_ptr(new KItemWidgetPrivate(this)) { Q_D(KItemWidget); setMinimumSize(800,800); d->pixmap=Myicon.pixmap(QSize(d->m_iconsize)); d->m_maintext=MmainText; d->m_sectext=MsecText; } void KItemWidget::SetInverse() { Q_D(KItemWidget); d->flag = true; update(); } void KItemWidget::CancelInverse() { Q_D(KItemWidget); d->flag = false; update(); } void KItemWidget::SetIconSize(QSize size) { Q_D(KItemWidget); d->m_iconsize=size; d->x = d->m_iconsize.width(); d->y = d->m_iconsize.height(); update(); } void KItemWidget::paintEvent(QPaintEvent *event) { Q_D(KItemWidget); QPainter painter(this); painter.drawPixmap(8,10,d->x,d->y,d->pixmap); //画图片 QFont font=painter.font(); font.setPointSize(10);//设置字体 painter.setFont(font); if(ThemeController::themeMode()==LightTheme) //判断主题 { if(d->flag) { painter.setPen(QColor(255,255,255)); //白色 painter.drawText(QRect(52,10,1000,16),d->m_maintext);//画文本 } else { painter.setPen(QColor(54,54,54));//黑色 painter.drawText(QRect(52,10,1000,16),d->m_maintext);//画文本 } painter.setPen(QColor(150,150,150));//褐色 painter.drawText(QRect(52,28,1000,16),d->m_sectext); } else if(ThemeController::themeMode() == DarkTheme) { painter.setPen(QColor(255,255,255)); //白色 painter.drawText(QRect(52,10,1000,16),d->m_maintext);//画文本 painter.setPen(QColor(150,150,150));//褐色 painter.drawText(QRect(52,28,1000,16),d->m_sectext); } painter.setRenderHint(QPainter::Antialiasing); /* 尽可能消除文本锯齿边缘 */ painter.setRenderHint(QPainter::TextAntialiasing); this->setContentsMargins(8,10,10,5);//边距 } } #include "kitemwidget.moc" #include "moc_kitemwidget.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kiconbar.cpp0000664000175000017500000001344614474244170023357 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include "kiconbar.h" #include "themeController.h" #include "parmscontroller.h" #include namespace kdk { class KIconBarPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KIconBar) public: KIconBarPrivate(KIconBar*parent); void elideWidgetName(); protected: void changeTheme(); void changeIconStyle(); private: KIconBar* q_ptr; QLabel *m_pIconLabel; QLabel *m_pNameLabel; QHBoxLayout *m_pMainLayout; QString m_IconName; QString m_widgetName; }; KIconBar::KIconBar(QWidget*parent) :QFrame(parent), d_ptr(new KIconBarPrivate(this)) { Q_D(KIconBar); setObjectName("IconBar"); 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)))); updateGeometry(); }); } KIconBar::KIconBar(const QString &iconName, const QString &text, QWidget *parent) :KIconBar(parent) { setIcon(iconName); setWidgetName(text); } KIconBar::~KIconBar() { } void KIconBar::setIcon(const QString &iconName) { Q_D(KIconBar); if(iconName.isEmpty()) return; if(!d->m_pIconLabel) return; d->m_IconName = iconName; d->m_pIconLabel->setPixmap(QIcon::fromTheme(iconName).pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize)))); setWindowIcon(QIcon::fromTheme(iconName).pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize),Parmscontroller::parm(Parmscontroller::Parm::PM_IconBarIconSize)))); } void KIconBar::setIcon(const QIcon &icon) { Q_D(KIconBar); if(!d->m_pIconLabel) return; 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)))); } void KIconBar::setWidgetName(const QString &widgetName) { Q_D(KIconBar); if(widgetName.isEmpty()) return; if(!d->m_pNameLabel) return; d->m_widgetName = 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); return d->m_pNameLabel; } QLabel *KIconBar::iconLabel() { Q_D(KIconBar); return d->m_pIconLabel; } void KIconBar::mouseDoubleClickEvent(QMouseEvent *event) { Q_D(KIconBar); if(event->button() == Qt::LeftButton) Q_EMIT doubleClick(); } void KIconBar::resizeEvent(QResizeEvent *event) { Q_D(KIconBar); QFrame::resizeEvent(event); d->elideWidgetName(); } KIconBarPrivate::KIconBarPrivate(KIconBar *parent) :q_ptr(parent) { Q_Q(KIconBar); setParent(parent); q->setContentsMargins(0,8,4,8); 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->setSpacing(0); m_pMainLayout->addSpacing(8); m_pMainLayout->addWidget(m_pIconLabel); m_pMainLayout->addSpacing(4); m_pMainLayout->addWidget(m_pNameLabel); m_pMainLayout->setContentsMargins(0,0,0,0); m_pMainLayout->addStretch(); changeIconStyle(); connect(m_gsetting,&QGSettings::changed,this,&KIconBarPrivate::changeIconStyle); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KIconBarPrivate::changeTheme); connect(m_gsetting,&QGSettings::changed,this,[=](const QString &key){ if(key.contains("systemFontSize")) elideWidgetName(); }); } void KIconBarPrivate::elideWidgetName() { Q_Q(KIconBar); QFontMetrics fm = QApplication::fontMetrics(); // bug 175664 修正1px auto visualWidth = q->width()-m_pNameLabel->geometry().left()-1; QString elidedText = fm.elidedText(m_widgetName,Qt::TextElideMode::ElideRight, visualWidth); m_pNameLabel->setText(elidedText); if(fm.width(m_widgetName) >= visualWidth) m_pNameLabel->setToolTip(m_widgetName); else m_pNameLabel->setToolTip(""); } void KIconBarPrivate::changeTheme() { initThemeStyle(); } void KIconBarPrivate::changeIconStyle() { Q_Q(KIconBar); initThemeStyle(); q->setIcon(m_IconName); } } #include "kiconbar.moc" #include "moc_kiconbar.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kmessagebox.h0000664000175000017500000001755314474244170023547 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KMESSAGEBOX_H #define KMESSAGEBOX_H #include #include #include "gui_g.h" #include "kdialog.h" #include 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 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbadge.h0000664000175000017500000000421414474244170022442 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBADGE_H #define KBADGE_H #include "gui_g.h" #include #include #include namespace kdk { class KBadgePrivate; /** @defgroup 消息提示模块 * @{ */ /** * @brief KBadge,消息提醒气泡 */ class GUI_EXPORT KBadge:public QWidget { Q_OBJECT public: KBadge(QWidget*parent); /** * @brief 返回值 * @return */ int value(); /** * @brief 设置值,最大显示数值为999,大于999显示"..." * @param value */ void setValue(int value); /** * @brief 设置值是否可见 * @param flag */ void setValueVisiable(bool flag); /** * @brief 获取值是否可见 */ bool isValueVisiable() const; /** * @brief 获取背景色 * @return */ QColor color(); /** * @brief 设置背景色 * @param color */ void setColor(const QColor& color); /** * @brief 获取字体大小 * @return */ int fontSize(); /** * @brief 设置字体大小 * @param size */ void setFontSize(int size); protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); private: Q_DECLARE_PRIVATE(KBadge) KBadgePrivate*const d_ptr; }; } /** * @example testbadge/widget.h * @example testbadge/widget.cpp * @} */ #endif // KBADGE_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kaboutdialog.h0000664000175000017500000000614014474244170023672 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KABOUTDIALOG_H #define KABOUTDIALOG_H #include #include #include #include "gui_g.h" #include "themeController.h" #include "kdialog.h" namespace kdk { /** @defgroup 对话框模块 * @{ */ class KAboutDialogPrivate; /** * @brief 关于对话框,支持两种样式,一种不包含具体说明,另一种则包含具体说明 */ class GUI_EXPORT KAboutDialog:public KDialog { Q_OBJECT public: KAboutDialog(QWidget*parent = nullptr,const QIcon& appIcon = QIcon(),const QString& appName = "",const QString& appVersion = "",const QString& appInfo = ""); ~KAboutDialog(); /** * @brief 设置应用程序图标 * @param icon */ void setAppIcon(const QIcon& icon); /** * @brief 设置应用程序名称 * @param appName */ void setAppName(const QString& appName); /** * @brief 获取应用程序名称 * @return */ QString appName(); /** * @brief 设置应用程序版本号 * @param appVersion */ void setAppVersion(const QString& appVersion); /** * @brief 获取应用程序版本号 * @return */ QString appVersion(); /** * @brief 设置具体的说明内容 * @param bodyText */ void setBodyText(const QString& bodyText); /** * @brief 获取具体的说明内容 * @return */ QString bodyText(); /** * @brief 设置服务与支持邮箱,有默认缺省 * @param appSupport */ void setAppSupport(const QString& appSupport); /** * @brief 获取服务与支持邮箱 * @return */ QString appSupport(); /** * @brief 设置是否显示说明内容,应设计要求,1.2.0.9中不再显示说明内容 * @param flag */ void setBodyTextVisiable(bool flag); /** * @brief 设置隐私按钮是否可见 * @param flag */ void setAppPrivacyLabelVisible(bool flag); /** * @brief 返回隐私按钮是否可见 * @return */ bool AppPrivacyLabelIsVisible(); protected: void changeTheme() override; void paintEvent(QPaintEvent*paintEvent) override; private: Q_DECLARE_PRIVATE(KAboutDialog) KAboutDialogPrivate* const d_ptr; }; } /** * @example testDialog/widget.h * @example testDialog/widget.cpp * @} */ #endif libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kballontip.h0000664000175000017500000000463614474244170023374 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBALLONTIP_H #define KBALLONTIP_H #include #include "gui_g.h" namespace kdk { /** @defgroup 消息提示模块 * @{ */ /** * @brief 支持五种样式 */ enum TipType { Nothing, Normal, Info, Warning, Error }; class KBallonTipPrivate; /** * @brief KBallonTip,消息提示框,支持五种样式 */ class GUI_EXPORT KBallonTip : public QWidget { Q_OBJECT public: explicit KBallonTip(QWidget *parent = nullptr); explicit KBallonTip(const QString& content,const TipType& type,QWidget *parent = nullptr); void showInfo(); /** * @brief 设置类型 * @param type */ void setTipType(const TipType& type); /** * @brief 返回类型 * @return */ TipType tipType(); /** * @brief 设置文本内容 * @param text */ void setText(const QString& text); /** * @brief text * @return */ QString text(); /** * @brief 设置内容边距 * @param left * @param top * @param right * @param bottom */ void setContentsMargins(int left, int top, int right, int bottom); /** * @brief 设置内容边距 * @param margins */ void setContentsMargins(const QMargins &margins); /** * 设置持续时间 */ void setTipTime(int my_time); private Q_SLOTS: void onTimeupDestroy(); protected: void paintEvent(QPaintEvent* event) override; private: Q_DECLARE_PRIVATE(KBallonTip) KBallonTipPrivate* const d_ptr; }; } /** * @example testballontip/widget.h * @example testballontip/widget.cpp * @} */ #endif // KBALLONTIP_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcolorbutton.h0000664000175000017500000000375614474244170023764 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KCOLORBUTTON_H #define KCOLORBUTTON_H #include #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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kshadowhelper.h0000664000175000017500000000246514474244170024073 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KSHADOWHELPER_H #define KSHADOWHELPER_H #include #include #include "gui_g.h" namespace kdk { namespace effects { class KShadowHelperPrivate; class KShadowHelper : public QObject { Q_OBJECT public: static KShadowHelper* self(); void setWidget(QWidget* widget,int borderRadius = 12, int shadowWidth = 20,qreal darkness = 0.5); private: KShadowHelper(QObject *parent = nullptr); Q_DECLARE_PRIVATE(KShadowHelper) KShadowHelperPrivate* const d_ptr; }; } } #endif // KSHADOWHELPER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogressbar.cpp0000664000175000017500000003423414474244170024271 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kprogressbar.h" #include "themeController.h" #include #include #include #include #include #include namespace kdk { class KProgressBarPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KProgressBar) public: KProgressBarPrivate(KProgressBar*parent); void calculateTextRect(); void calculateRect(); void calculateContenteRect(); void changeTheme(); Q_SIGNALS: void progressStateChanged(); private: KProgressBar* q_ptr; ProgressBarState m_state; int m_contentMargin; QRect m_textRect; QRect m_contentRect; QRect m_rect; int m_bodyWidth; }; KProgressBar::KProgressBar(QWidget *parent) :QProgressBar(parent), d_ptr(new KProgressBarPrivate(this)) { Q_D(KProgressBar); d->changeTheme(); connect(d->m_gsetting,&QGSettings::changed,d,&KProgressBarPrivate::changeTheme); connect(this,&KProgressBar::valueChanged,this,[=](){ if(this->value()==this->maximum()) setState(SuccessProgress); }); setContentsMargins(6,6,6,6); setValue(0); } ProgressBarState KProgressBar::state() { Q_D(KProgressBar); return d->m_state; } void KProgressBar::setState(ProgressBarState state) { Q_D(KProgressBar); d->m_state = state; update(); } void KProgressBar::paintEvent(QPaintEvent *event) { Q_D(KProgressBar); d->calculateTextRect(); d->calculateRect(); d->calculateContenteRect(); //以上三个函数有逻辑关系,相对位置不能改变 QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); if(this->orientation() == Qt::Horizontal) { if(ThemeController::themeMode() == LightTheme) painter.setBrush(QColor(230,230,230)); else painter.setBrush(QColor(55,55,59)); painter.drawRoundedRect(d->m_rect,6,6); QLinearGradient linear(this->rect().topLeft(), this->rect().bottomRight()); QColor color = palette().color(QPalette::Highlight); switch (d->m_state) { case NormalProgress: if(ThemeController::widgetTheme() == FashionTheme) { QColor startColor = ThemeController::mixColor(color,Qt::white,0.2); QColor endColor = ThemeController::mixColor(color,Qt::white,0.05); linear.setColorAt(0, startColor); linear.setColorAt(1, endColor); } else { QColor startColor = ThemeController::mixColor(color,Qt::white,0.2); QColor endColor = ThemeController::mixColor(color,Qt::white,0.05); linear.setColorAt(0, startColor); linear.setColorAt(1, endColor); // linear.setColorAt(0, QColor(97,173,255)); // linear.setColorAt(1, QColor(55,144,250)); } linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { painter.setPen(QWidget::palette().color(QPalette::Text)); painter.drawText(d->m_textRect,Qt::AlignCenter,text()); } break; case FailedProgress: { linear.setColorAt(0, QColor(255,77,79)); linear.setColorAt(1, QColor(243,34,45)); linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { QPixmap pixmap = QIcon::fromTheme("dialog-error").pixmap(16,16); QRect rect(0,0,16,16); rect.moveCenter(d->m_textRect.center()); painter.drawPixmap(rect,pixmap); } break; } case SuccessProgress: { if(ThemeController::widgetTheme() == FashionTheme) { if(ThemeController::themeMode() == LightTheme) { linear.setColorAt(0, QColor("#8DF063")); linear.setColorAt(1, QColor("#4ED42D")); } else { linear.setColorAt(0, QColor("#75D14D")); linear.setColorAt(1, QColor("#52C429")); } } else { linear.setColorAt(0, QColor(117,209,77)); linear.setColorAt(1, QColor(82,196,41)); } linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { QPixmap pixmap = QIcon::fromTheme("ukui-dialog-success").pixmap(16,16); QRect rect(0,0,16,16); rect.moveCenter(d->m_textRect.center()); painter.drawPixmap(rect,pixmap); } break; } default: break; } } else { if(ThemeController::themeMode() == LightTheme) painter.setBrush(QColor(230,230,230)); else painter.setBrush(QColor(55,55,59)); painter.drawRoundedRect(d->m_rect,6,6); QLinearGradient linear(this->rect().topLeft(), this->rect().bottomRight()); QColor color = palette().color(QPalette::Highlight); switch (d->m_state) { case NormalProgress: if(ThemeController::widgetTheme() == FashionTheme) { QColor startColor = ThemeController::mixColor(color,Qt::white,0.2); QColor endColor = ThemeController::mixColor(color,Qt::white,0.05); linear.setColorAt(0, startColor); linear.setColorAt(1, endColor); } else { QColor startColor = ThemeController::mixColor(color,Qt::white,0.2); QColor endColor = ThemeController::mixColor(color,Qt::white,0.05); linear.setColorAt(0, startColor); linear.setColorAt(1, endColor); // linear.setColorAt(0, QColor(97,173,255)); // linear.setColorAt(1, QColor(55,144,250)); } linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { painter.setPen(QWidget::palette().color(QPalette::Text)); painter.drawText(d->m_textRect,Qt::AlignCenter,text()); } break; case FailedProgress: { linear.setColorAt(0, QColor(255,77,79)); linear.setColorAt(1, QColor(243,34,45)); linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { QPixmap pixmap = QIcon::fromTheme("dialog-error").pixmap(16,16); QRect rect(0,0,16,16); rect.moveCenter(d->m_textRect.center()); painter.drawPixmap(rect,pixmap); } break; } case SuccessProgress: { if(ThemeController::widgetTheme()== FashionTheme) { if(ThemeController::themeMode() == LightTheme) { linear.setColorAt(0, QColor("#8DF063")); linear.setColorAt(1, QColor("#4ED42D")); } else { linear.setColorAt(0, QColor("#75D14D")); linear.setColorAt(1, QColor("#52C429")); } } else { linear.setColorAt(0, QColor(117,209,77)); linear.setColorAt(1, QColor(82,196,41)); } linear.setSpread(QGradient::PadSpread); painter.setBrush(linear); painter.drawRoundedRect(d->m_contentRect,6,6); if(isTextVisible()) { QPixmap pixmap = QIcon::fromTheme("ukui-dialog-success").pixmap(16,16); //painter.drawPixmap(d->m_textRect,pixmap); QRect rect(0,0,16,16); rect.moveCenter(d->m_textRect.center()); painter.drawPixmap(rect,pixmap); } break; } default: break; } } } QSize KProgressBar::sizeHint() const { QSize size = QProgressBar::sizeHint(); if(this->orientation()==Qt::Horizontal) size.setHeight(30); else size.setWidth(30); return size; } QString KProgressBar::text() const { Q_D(const KProgressBar); if ((maximum() == 0 && minimum() == 0) || value() < minimum() || (minimum() == INT_MIN && minimum() == INT_MIN)) return QString(); qint64 totalSteps = qint64(maximum()) - minimum(); QString result = format(); QLocale locale = this->locale(); // Omit group separators for compatibility with previous versions that were non-localized. locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator); result.replace(QLatin1String("%m"), locale.toString(totalSteps)); result.replace(QLatin1String("%v"), locale.toString(value())); // If max and min are equal and we get this far, it means that the // progress bar has one step and that we are on that step. Return // 100% here in order to avoid division by zero further down. if (totalSteps == 0) { result.replace(QLatin1String("%p"), locale.toString(100)); return result; } const auto progress = static_cast((qint64(value()) - minimum()) * 100.0 / totalSteps); result.replace(QLatin1String("%p"), locale.toString(progress)); return result; } void KProgressBar::setOrientation(Qt::Orientation orientation) { if(orientation == Qt::Vertical) this->setMinimumHeight(200); 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() { Q_Q(KProgressBar); if(!q->isTextVisible()) m_textRect = QRect(); else { QFont font(QApplication::font()); QFontMetrics fm(font); m_textRect = QRect(0,0,fm.width(q->text()),fm.height()); m_textRect.moveCenter(q->rect().center()); if(q->orientation()==Qt::Horizontal) { if(q->alignment() & Qt::AlignCenter) return; else m_textRect.moveRight(q->rect().right()); } else { if(q->alignment() & Qt::AlignCenter) return; else m_textRect.moveTop(q->rect().top()); } } } void KProgressBarPrivate::calculateRect() //背景矩形 { Q_Q(KProgressBar); QMargins margins = q->contentsMargins(); m_rect = q->rect(); if(q->orientation() == Qt::Horizontal) { if(m_bodyWidth != 0) m_rect.setHeight(m_bodyWidth); if(!q->isTextVisible()) return; else { m_rect.moveCenter(q->rect().center()); if(q->alignment() & Qt::AlignCenter) return; else { m_rect.setRight(q->rect().width() - margins.right() - m_textRect.width()/*-gSpace*/); } } } else { if(m_bodyWidth != 0) m_rect.setWidth(m_bodyWidth); if(!q->isTextVisible()) return; else { m_rect.moveCenter(q->rect().center()); if(q->alignment() & Qt::AlignCenter) return; else { m_rect.setTop(margins.top() + m_textRect.height()/* + gSpace*/); } } } } void KProgressBarPrivate::calculateContenteRect()//填充矩形 { Q_Q(KProgressBar); m_contentRect = m_rect; if(q->orientation() == Qt::Horizontal) { int width; qint64 totalSteps = qint64(q->maximum()) - q->minimum(); width = m_rect.width() * (q->value() - q->minimum()) /totalSteps; if(!width) { m_contentRect = QRect(); } //没设置反方向的情况下,即普通情况下 if(!q->invertedAppearance()) { m_contentRect.setRight(width+m_rect.left()); } else { m_contentRect.setLeft(m_rect.width() - width); } } else { int height; qint64 totalSteps = q->maximum() - q->minimum(); height = m_rect.height() * (q->value() - q->minimum()) /totalSteps; if(!height) { m_contentRect = QRect(); } //没设置反方向的情况下,即普通情况下 if(!q->invertedAppearance()) { m_contentRect.setTop(m_rect.top() + m_rect.height() - height); } else { m_contentRect.setBottom(m_rect.top() +height); } } } void KProgressBarPrivate::changeTheme() { Q_Q(KProgressBar); initThemeStyle(); q->repaint(); } } #include "kprogressbar.moc" #include "moc_kprogressbar.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbreadcrumb.h0000664000175000017500000000257714474244170023520 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBREADCRUMB_H #define KBREADCRUMB_H #include namespace kdk { class KBreadCrumbPrivate; enum KBreadCrumbType { FlatBreadCrumb, CubeBreadCrumb }; class KBreadCrumb : public QTabBar { Q_OBJECT public: explicit KBreadCrumb(QWidget *parent = nullptr); void setIcon(const QIcon &icon); QIcon icon() const; bool isFlat() const; void setFlat(bool flat); protected: QSize tabSizeHint(int index) const; void paintEvent(QPaintEvent *event); private: Q_DECLARE_PRIVATE(KBreadCrumb) KBreadCrumbPrivate*const d_ptr; }; } #endif // KBREADCRUMB_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/gui_g.h0000664000175000017500000000174714474244170022327 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef GUI_G_H #define GUI_G_H #include #if defined(GUI_LIBRARY) # define GUI_EXPORT Q_DECL_EXPORT #else # define GUI_EXPORT Q_DECL_IMPORT #endif #endif // KYSDKTEST_GLOBAL_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbuttonbox.h0000664000175000017500000000676314474244170023437 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBUTTONBOX_H #define KBUTTONBOX_H #include "gui_g.h" #include "kpushbutton.h" #include #include 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 &list); /** * @brief 获取KButtonBox中的按钮列表 * @return */ QList 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kmenubutton.h0000664000175000017500000000471414474244170023605 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KMENUBUTTON_H #define KMENUBUTTON_H #include "gui_g.h" #include "themeController.h" #include #include #include #include namespace kdk { /** @defgroup 按钮模块 * @{ */ class KMenuButtonPrivate; /** * @brief 下拉菜单按钮 */ class GUI_EXPORT KMenuButton:public QToolButton,public ThemeController { Q_OBJECT public: KMenuButton(QWidget*parent=nullptr); ~KMenuButton(); /** * @brief 获取主菜单 * @return */ QMenu* menu(); /** * @brief 获取主题菜单 * @return */ QMenu* themeMenu(); /** * @brief 获取设置action * @return */ QAction* settingAction(); /** * @brief 获取主题Action * @return */ QAction* themeAction(); /** * @brief 获取帮助Action * @return */ QAction* assistAction(); /** * @brief 获取关于Action * @return */ QAction* aboutAction(); /** * @brief 获取离开Action * @return */ QAction* quitAction(); /** * @brief 获取跟随主题Action * @return */ QAction* autoAction(); /** * @brief 获取浅色主题Action * @return */ QAction* lightAction(); /** * @brief 获取深色Action * @return */ QAction* darkAction(); protected: void changeTheme() override; void paintEvent(QPaintEvent*painteEvent); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KMenuButton) KMenuButtonPrivate* const d_ptr; }; } /** * @example testWidget/testwidget.h * @example testWidget/testwidget.cpp * @} */ #endif // KMENUBUTTON_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kslider.h0000664000175000017500000000621414474244170022664 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KSLIDER_H #define KSLIDER_H #include #include #include "gui_g.h" namespace kdk { /** @defgroup 滑动条模块 * @{ */ enum KSliderType { SmoothSlider, StepSlider, NodeSlider, SingleSelectSlider }; class KSliderPrivate; /** * @brief 支持三种样式的滑动条 * 非步数关系:步数为1,可以在任意位置点击和拖拽 * 步数关系:步数为固定值,可根据步数值点击和拖拽 * 节点关系:步数为节点间隔,可根据节点间隔点击和拖拽 */ class KSlider:public QSlider { Q_OBJECT public: KSlider(QWidget*parent); KSlider(Qt::Orientation orientation, QWidget *parent = nullptr); /** * @brief 设置节点间隔 * @param interval */ void setTickInterval(int interval); /** * @brief 设置滑动条类型 * @param type */ void setSliderType(KSliderType type); /** * @brief 获取滑动条类型 * @return */ KSliderType sliderType(); /** * @brief 获取节点间隔 * @return */ int tickInterval() const; /** * @brief 设置值 */ void setValue(int); /** * @brief 设置是否显示节点 * @return */ void setNodeVisible(bool flag); /** * @brief 获取是否显示节点 * @return */ bool nodeVisible(); /** * @brief 设置tooltip */ void setToolTip(const QString&); /** * @brief 获取toolTip,since 1.2.0.10 * @return */ QString toolTip() const; /** * @brief 设置是否启用半透明效果,since 1.2.0.10 * @param flag */ void setTranslucent(bool flag); /** * @brief 获取是否启用半透明效果,since 1.2.0.10 * @return flag */ bool isTranslucent(); protected: void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void wheelEvent(QWheelEvent *event); bool eventFilter(QObject *watched, QEvent *event); QSize sizeHint() const override; private: KSliderPrivate *const d_ptr; Q_DISABLE_COPY(KSlider) Q_DECLARE_PRIVATE(KSlider) }; } /** * @example testslider/widget.h * @example testslider/widget.cpp * @} */ #endif // KSLIDER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kwindowbuttonbar.h0000664000175000017500000000530214474244170024627 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KTITLEBAR_H #define KTITLEBAR_H #include "gui_g.h" #include "kmenubutton.h" #include #include #include #include namespace kdk { /** @defgroup 对话框模块 * @{ */ enum MaximumButtonState { Maximum, Restore }; class KWindowButtonBarPrivate; /** * @brief 窗口三联按钮和菜单按钮的集合 */ class GUI_EXPORT KWindowButtonBar:public QFrame { Q_OBJECT public: KWindowButtonBar(QWidget*parent=nullptr); ~KWindowButtonBar(); /** * @brief 获取最小化按钮 * @return */ QPushButton* minimumButton(); /** * @brief 获取最大化按钮 * @return */ QPushButton* maximumButton(); /** * @brief 获取关闭按钮 * @return */ QPushButton* closeButton(); /** * @brief 获取菜单按钮 * @return */ KMenuButton* menuButton(); /** * @brief 获取最大化按钮的状态(最大化/恢复) * @return */ MaximumButtonState maximumButtonState(); /** * @brief 设置最大化按钮图标状态(最大化/恢复) * @param state */ 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: /** * @brief 双击会发出双击信号,父widget可以绑定相应槽函数 */ void doubleClick(); protected: void mouseDoubleClickEvent(QMouseEvent *event); bool eventFilter(QObject *watched, QEvent *event); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KWindowButtonBar) KWindowButtonBarPrivate *d_ptr; }; } /** * @example testWidget/testwidget.h * @example testWidget/testwidget.cpp * @} */ #endif //KTITLEBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kborderlessbutton.h0000664000175000017500000000363414474244170025005 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBORDERLESSBUTTON_H #define KBORDERLESSBUTTON_H #include "gui_g.h" #include #include #include #include namespace kdk { /** @defgroup 按钮模块 * @{ */ class KBorderlessButtonPrivate; /** * @brief 无边框按钮 */ class GUI_EXPORT KBorderlessButton:public QPushButton { Q_OBJECT public: KBorderlessButton(QWidget* parent = nullptr); KBorderlessButton(const QString &text, QWidget *parent = nullptr); KBorderlessButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr); KBorderlessButton(const QIcon &icon, QWidget *parent = nullptr); ~KBorderlessButton(); /** * @brief 设置按钮图标 * @param icon */ void setIcon(const QIcon &icon); protected: bool eventFilter(QObject *watched, QEvent *event); void paintEvent(QPaintEvent *event); QSize sizeHint() const; private: KBorderlessButtonPrivate* const d_ptr; Q_DECLARE_PRIVATE(KBorderlessButton) Q_PRIVATE_SLOT(d_ptr, void changeTheme()) }; } /** * @example testPushbutton/widget.h * @example testPushbutton/widget.cpp * @} */ #endif libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kwidget.h0000664000175000017500000000657114474244170022673 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KWIDGET_H #define KWIDGET_H #include #include #include #include "kwindowbuttonbar.h" #include "kiconbar.h" namespace kdk { /** * @brief 支持切换三种结构布局 */ enum LayoutType { VerticalType, //上下结构 HorizontalType, //左右结构 MixedType //过渡结构 }; /** @defgroup 窗体模块 * @{ */ class KWidgetPrivate; /** * @brief 继承自QWidget,支持响应主题背景切换,图标主题切换,标题颜色响应窗口激活状态,内容区域分为side区和base区 */ class GUI_EXPORT KWidget : public QWidget,public ThemeController { Q_OBJECT public: explicit KWidget(QWidget *parent = nullptr); ~KWidget(); /** * @brief 设置窗体图标 * @param icon */ void setIcon(const QIcon& icon); /** * @brief 设置窗体图标 * @param iconName 直接指定系统目录中的图标名称,如"kylin-music" */ void setIcon(const QString& iconName); /** * @brief 设置窗体名称 * @param widgetName */ void setWidgetName(const QString& widgetName); /** * @brief 获取左边栏widget,通过setlayout添加自定义内容 * @return 返回左边栏widget */ QWidget* sideBar(); /** * @brief 获取主内容区widget,通过setlayout添加自定义内容 * @return 返回主内容区widget */ QWidget* baseBar(); /** * @brief 获取窗口三联组合控件,以控制是否显示最大化、最小化按钮和下拉菜单按钮;也可增加自定义按钮 * @return 返回窗口三联组合控件 */ KWindowButtonBar* windowButtonBar(); /** * @brief 获取窗口标题、图标组合控件,以控制相关样式 * @return 返回窗口标题、图标组合控件 */ KIconBar* iconBar(); /** * @brief 设置布局结构类型 */ void setLayoutType(LayoutType type); void setWindowFlags(Qt::WindowFlags type); void setWindowFlag(Qt::WindowType flag, bool on = true); /** * @brief 设置sidebar是否遵循系统更改宽度 * @param flag */ void setSidebarFollowMode(bool flag); /** * @brief 返回sidebar是否遵循系统更改宽度 * @return */ bool sidebarFollowMode(); protected: bool eventFilter(QObject *target, QEvent *event) override; virtual void changeIconStyle(); virtual void changeTheme(); private: Q_DECLARE_PRIVATE(KWidget) KWidgetPrivate*const d_ptr; }; } /** * @example testWidget/testwidget.h * @example testWidget/testwidget.cpp * @} */ #endif // KWIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpressbutton.cpp0000775000175000017500000002714614474244170024337 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "kpressbutton.h" #include "themeController.h" #include #include #include #include #include #include namespace kdk { class KPressButtonPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KPressButton) public: KPressButtonPrivate(KPressButton* parent); void changeTheme(); private: KPressButton *q_ptr; QColor m_pbkgColor; QTimer* m_pTimer; KPressButton::ButtonType m_pButtonType; QIcon m_pIcon; int m_flashState; int m_pTopLeftRadius; int m_pTopRightRadius; int m_pBottomLeftRadius; int m_pBottomRightRadius; bool m_pLoading; //loafing标志位 bool m_pCheackable; //开启标志位 bool m_pTranslucent; }; KPressButtonPrivate::KPressButtonPrivate(KPressButton *parent) :q_ptr(parent) { Q_Q(KPressButton); } void KPressButtonPrivate::changeTheme() { Q_Q(KPressButton); initThemeStyle(); } KPressButton::KPressButton(QWidget *parent) :QPushButton(parent), d_ptr(new KPressButtonPrivate(this)) { Q_D(KPressButton); d->m_pTopLeftRadius = 6; d->m_pTopRightRadius = 6; d->m_pBottomLeftRadius = 6; d->m_pBottomRightRadius = 6; d->m_pButtonType = KPressButton::NormalType; d->m_pCheackable = false; d->m_pTranslucent = false; d->m_pTimer = new QTimer(this); d->m_pTimer->setInterval(100); d->m_flashState =0; setCheckable(true); connect(d->m_pTimer,&QTimer::timeout,this,[=](){ if(d->m_flashState < 7) d->m_flashState++; else d->m_flashState = 0; setIcon(QIcon::fromTheme(QString("ukui-loading-%1.symbolic").arg(d->m_flashState))); }); connect(d->m_gsetting,&QGSettings::changed,this,[=](){d->changeTheme();}); } void KPressButton::setBorderRadius(int radius) { Q_D(KPressButton); d->m_pTopLeftRadius = radius; d->m_pTopRightRadius = radius; d->m_pBottomLeftRadius = radius; d->m_pBottomRightRadius = radius; } void KPressButton::setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight) { Q_D(KPressButton); d->m_pBottomLeftRadius = bottomLeft; d->m_pTopLeftRadius = topLeft; d->m_pTopRightRadius = topRight; d->m_pBottomRightRadius = bottomRight; } void KPressButton::setCheckable(bool flag) { QPushButton::setCheckable(flag); } bool KPressButton::isCheckable() const { return QPushButton::isCheckable(); } void KPressButton::setChecked(bool flag) { QPushButton::setChecked(flag); } bool KPressButton::isChecked() const { return QPushButton::isChecked(); } void KPressButton::setButtonType(ButtonType type) { Q_D(KPressButton); d->m_pButtonType = type; } KPressButton::ButtonType KPressButton::buttonType() { Q_D(KPressButton); return d->m_pButtonType; } void KPressButton::setLoaingStatus(bool flag) { Q_D(KPressButton); d->m_pLoading = flag; if(flag) d->m_pTimer->start(); else d->m_pTimer->stop(); update(); } bool KPressButton::isLoading() { Q_D(KPressButton); return d->m_pLoading; } void KPressButton::setTranslucent(bool flag) { Q_D(KPressButton); d->m_pTranslucent = flag; } bool KPressButton::isTranslucent() { Q_D(KPressButton); return d->m_pTranslucent; } void KPressButton::paintEvent(QPaintEvent *event) { Q_D(KPressButton); QStyleOptionButton opt; 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) { if(ThemeController::themeMode() == LightTheme) // 开启透明度 浅色模式 { if(isChecked() /*&& !isLoading()*/) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else { d->m_pbkgColor = opt.palette.color(QPalette::BrightText); d->m_pbkgColor.setAlphaF(0.10); } if(opt.state.testFlag(QStyle::State_MouseOver) && isCheckable() /*&& !isLoading()*/) { if(isChecked()) { if(opt.state & QStyle::State_Sunken) { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.2); //点击变深 } else { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.05); //悬浮变浅 } } else { if(opt.state & QStyle::State_Sunken) { d->m_pbkgColor = opt.palette.brightText().color(); //点击变深 d->m_pbkgColor.setAlphaF(0.21); } else { d->m_pbkgColor = opt.palette.brightText().color(); //悬浮变浅 d->m_pbkgColor.setAlphaF(0.16); } } } else if(opt.state.testFlag(QStyle::State_Selected) ) { if(isChecked() ) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else { d->m_pbkgColor = opt.palette.color(QPalette::BrightText); d->m_pbkgColor.setAlphaF(0.10); } } } else //开启透明度 深色模式 { if(isChecked() /*&& !isLoading()*/) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else { d->m_pbkgColor = opt.palette.color(QPalette::BrightText); d->m_pbkgColor.setAlphaF(0.10); } if(opt.state.testFlag(QStyle::State_MouseOver) && isCheckable() /*&& !isLoading()*/) { if(isChecked()) { if(opt.state & QStyle::State_Sunken) { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.2); //点击变深 } else { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.05); //悬浮变浅 } } else { if(opt.state & QStyle::State_Sunken) { d->m_pbkgColor = opt.palette.brightText().color(); //点击变深 d->m_pbkgColor.setAlphaF(0.3); } else { d->m_pbkgColor = opt.palette.brightText().color(); //悬浮变浅 d->m_pbkgColor.setAlphaF(0.2); } } } else if(opt.state.testFlag(QStyle::State_Selected) ) { if(isChecked() ) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else { d->m_pbkgColor = opt.palette.color(QPalette::BrightText); d->m_pbkgColor.setAlphaF(0.10); } } } } else // 关闭透明度 { if(isChecked() /*&& !isLoading()*/) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else d->m_pbkgColor = opt.palette.color(QPalette::Button); if(opt.state.testFlag(QStyle::State_MouseOver) && isCheckable() /*&& !isLoading()*/) { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.05); //悬浮变浅 if(opt.state & QStyle::State_Sunken) { d->m_pbkgColor = ThemeController::mixColor(d->m_pbkgColor,opt.palette.brightText().color(),0.2); //点击变深 } } else if(opt.state.testFlag(QStyle::State_Selected) ) { if(isChecked() ) d->m_pbkgColor = opt.palette.color(QPalette::Highlight); else d->m_pbkgColor = opt.palette.color(QPalette::Button); } } if(opt.icon.name() != "ukui-loading-0.symbolic" && opt.icon.name() != "ukui-loading-1.symbolic" && opt.icon.name() != "ukui-loading-2.symbolic" && opt.icon.name()!= "ukui-loading-3.symbolic"&& opt.icon.name()!= "ukui-loading-4.symbolic"&&opt.icon.name() != "ukui-loading-5.symbolic"&& opt.icon.name() != "ukui-loading-6.symbolic"&&opt.icon.name() != "ukui-loading-7.symbolic") d->m_pIcon = opt.icon; QRect rect = this->rect(); QPainterPath path; switch (d->m_pButtonType) { case NormalType: path.moveTo(rect.topLeft() + QPointF(0 , d->m_pTopLeftRadius)); path.lineTo(rect.bottomLeft() - QPointF ( 0 , d->m_pBottomLeftRadius)); path.quadTo(rect.bottomLeft() , rect.bottomLeft() + QPointF(d->m_pBottomLeftRadius , 0)); path.lineTo(rect.bottomRight() - QPointF(d->m_pBottomRightRadius , 0)); path.quadTo(rect.bottomRight() , rect.bottomRight() - QPointF(0 ,d->m_pBottomRightRadius)); path.lineTo(rect.topRight() + QPointF(0 , d->m_pTopRightRadius)); path.quadTo(rect.topRight(),rect.topRight() - QPointF(d->m_pTopRightRadius , 0)); path.lineTo(rect.topLeft() + QPointF(d->m_pTopLeftRadius , 0)); path.quadTo(rect.topLeft() , rect.topLeft() + QPointF(0 , d->m_pTopLeftRadius)); p.setPen(Qt::NoPen); p.setBrush(d->m_pbkgColor); p.drawPath(path); break; case CircleType: p.setPen(Qt::NoPen); p.setBrush(d->m_pbkgColor); p.drawEllipse(rect); default: break; } int iconSize = opt.iconSize.width(); if(isChecked() || ThemeController::themeMode() == DarkTheme) { opt.icon = ThemeController::drawColoredPixmap(opt.icon.pixmap(iconSize,iconSize),QColor(255,255,255)); d->m_pIcon= ThemeController::drawColoredPixmap(d->m_pIcon.pixmap(iconSize,iconSize),QColor(255,255,255)); } else { opt.icon = ThemeController::drawColoredPixmap(opt.icon.pixmap(iconSize,iconSize),QColor(0,0,0)); d->m_pIcon= ThemeController::drawColoredPixmap(d->m_pIcon.pixmap(iconSize,iconSize),QColor(0,0,0)); } if(isLoading()) p.drawPixmap(rect.center().x()-iconSize/2,rect.center().y()-iconSize/2,iconSize,iconSize,opt.icon.pixmap(iconSize,iconSize)); //opt.icon loading else p.drawPixmap(rect.center().x()-iconSize/2,rect.center().y()-iconSize/2,iconSize,iconSize,d->m_pIcon.pixmap(iconSize,iconSize)); } } #include "kpressbutton.moc" #include "moc_kpressbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcommentpanel.cpp0000664000175000017500000002104714474244170024420 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kcommentpanel.h" #include "themeController.h" #include #include #include #include namespace kdk { class StarWidget: public QWidget { public: StarWidget(QWidget*parent); void setGrade(StarLevel level); private: void doFresh(); StarLevel m_starLevel; QLabel *m_plbl1; QLabel *m_plbl2; QLabel *m_plbl3; QLabel *m_plbl4; QLabel *m_plbl5; }; StarWidget::StarWidget(QWidget *parent) :QWidget(parent), m_starLevel(LevelZero) { setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); QHBoxLayout *hLayout = new QHBoxLayout(this); hLayout->setContentsMargins(0,0,0,0); hLayout->setSpacing(2); m_plbl1 = new QLabel(this); m_plbl2 = new QLabel(this); m_plbl3 = new QLabel(this); m_plbl4 = new QLabel(this); m_plbl5 = new QLabel(this); m_plbl1->setAlignment(Qt::AlignTop); m_plbl2->setAlignment(Qt::AlignTop); m_plbl3->setAlignment(Qt::AlignTop); m_plbl4->setAlignment(Qt::AlignTop); m_plbl5->setAlignment(Qt::AlignTop); m_plbl1->setFixedSize(14,14); m_plbl2->setFixedSize(14,14); m_plbl3->setFixedSize(14,14); m_plbl4->setFixedSize(14,14); m_plbl5->setFixedSize(14,14); hLayout->addWidget(m_plbl1); hLayout->addWidget(m_plbl2); hLayout->addWidget(m_plbl3); hLayout->addWidget(m_plbl4); hLayout->addWidget(m_plbl5); } void StarWidget::setGrade(StarLevel level) { if(level != m_starLevel) { m_starLevel = level; doFresh(); } } void StarWidget::doFresh() { switch(m_starLevel) { case LevelZero: break; case LevelOne: m_plbl1->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl2->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl3->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl4->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl5->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); break; case LevelTwo: m_plbl1->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl2->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl3->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl4->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl5->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); break; case LevelThree: m_plbl1->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl2->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl3->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl4->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); m_plbl5->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); break; case LevelFour: m_plbl1->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl2->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl3->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl4->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl5->setPixmap(QIcon::fromTheme("ukui-starred-symbolic").pixmap(12,12)); break; case LevelFive: m_plbl1->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl2->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl3->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl4->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); m_plbl5->setPixmap(QIcon::fromTheme("ukui-starred-on-symbolic").pixmap(12,12)); break; } } class KCommentPanelPrivate :public QObject,public ThemeController { Q_DECLARE_PUBLIC(KCommentPanel) Q_OBJECT public: KCommentPanelPrivate(KCommentPanel*parent); void changeTheme(); private: QLabel* m_pContentLabel; QLabel* m_pPicLabel; QLabel* m_pTimeLabel; QLabel* m_pNameLabel; StarWidget* m_pStarWidget; QColor m_color; KCommentPanel* q_ptr; }; KCommentPanel::KCommentPanel(QWidget *parent) : QWidget(parent), d_ptr(new KCommentPanelPrivate(this)) { setFixedSize(516,215); } void KCommentPanel::setIcon(const QIcon &icon) { Q_D(KCommentPanel); d->m_pPicLabel->setPixmap(icon.pixmap(50,50)); } void KCommentPanel::setTime(const QString &str) { Q_D(KCommentPanel); d->m_pTimeLabel->setText(str); } void KCommentPanel::setName(const QString &str) { Q_D(KCommentPanel); d->m_pNameLabel->setText(str); } void KCommentPanel::setText(const QString &str) { Q_D(KCommentPanel); d->m_pContentLabel->setText(str); } void KCommentPanel::setGrade(StarLevel level) { Q_D(KCommentPanel); d->m_pStarWidget->setGrade(level); } void KCommentPanel::paintEvent(QPaintEvent *event) { Q_D(KCommentPanel); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setPen(Qt::NoPen); painter.setBrush(d->m_color); QRect rect = this->rect(); rect.setWidth(rect.width() ); rect.setHeight(rect.height()); painter.drawRoundedRect(rect, 6, 6); } KCommentPanelPrivate::KCommentPanelPrivate(KCommentPanel *parent) :q_ptr(parent) { Q_Q(KCommentPanel); QVBoxLayout* mainLayout = new QVBoxLayout(q); mainLayout->setContentsMargins(16,16,16,16); QHBoxLayout* controlLayout = new QHBoxLayout; m_pPicLabel = new QLabel(q); m_pPicLabel->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); m_pPicLabel->setFixedSize(50,50); controlLayout->addWidget(m_pPicLabel); QVBoxLayout* vLayout = new QVBoxLayout; vLayout->setSpacing(1); vLayout->setContentsMargins(0,0,0,0); controlLayout->addLayout(vLayout); QHBoxLayout*hLayout = new QHBoxLayout; hLayout->setContentsMargins(0,0,0,0); m_pNameLabel = new QLabel(q); m_pNameLabel->setAlignment(Qt::AlignBottom); m_pNameLabel->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); m_pTimeLabel = new QLabel(q); m_pTimeLabel->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); hLayout->addWidget(m_pNameLabel); hLayout->addStretch(); hLayout->addWidget(m_pTimeLabel); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout; hLayout->setContentsMargins(0,0,0,0); m_pStarWidget = new StarWidget(q); hLayout->addWidget(m_pStarWidget); hLayout->addStretch(); vLayout->addLayout(hLayout); m_pContentLabel = new QLabel(q); m_pContentLabel->setWordWrap(true); m_pContentLabel->setAlignment(Qt::AlignTop); m_pContentLabel->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); mainLayout->addLayout(controlLayout); mainLayout->addWidget(m_pContentLabel); mainLayout->addStretch(); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KCommentPanelPrivate::changeTheme); } void KCommentPanelPrivate::changeTheme() { Q_Q(KCommentPanel); initThemeStyle(); if (ThemeController::themeMode() == LightTheme) { m_pTimeLabel->setStyleSheet("font-size:14px;color:#8C8C8C;"); m_pNameLabel->setStyleSheet("font-size:16px;font-weight:500;color:#262626;"); m_color = QColor("#F5F5F5"); m_pContentLabel->setStyleSheet("color:#595959"); } else { m_pTimeLabel->setStyleSheet("font-size:14px;color:#737373;"); m_pNameLabel->setStyleSheet("font-size:16px;font-weight:500;color:#FFFFFF;"); m_color = QColor("#232426"); m_pContentLabel->setStyleSheet("color:#D9D9D9"); } } } #include "kcommentpanel.moc" #include "moc_kcommentpanel.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kaboutdialog.cpp0000664000175000017500000003024014474244170024223 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kaboutdialog.h" namespace kdk { #define MAILTYPE "x-scheme-handler/mailto" #define LOCAL_CONFIG_DIR "/.config/" #define SYSTEM_CONFIG_DIR "/usr/share/applications/" class LinkLabel :public QLabel { Q_OBJECT public: LinkLabel(QWidget *parent=nullptr); protected: void mousePressEvent(QMouseEvent *event); }; class KAboutDialogPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KAboutDialog) public: KAboutDialogPrivate(KAboutDialog*parent); void adjustMiniMode(); QString getDefaultAppId(const char *contentType); bool isOpenKylin(); void updateAppVersionText(); private: KAboutDialog *q_ptr; QLabel *m_pAppIconLabel; QLabel *m_pAppNameLabel; QLabel *m_pAppVersionLabel; QLabel *m_pAppSupportLabel; LinkLabel *m_pAppPrivacyLabel; QString m_iconName; QString m_bodyText; bool m_appVersionFlag; }; KAboutDialog::KAboutDialog(QWidget*parent,const QIcon& appIcon,const QString& appName,const QString& appVersion,const QString& appInfo) :KDialog(parent), d_ptr(new KAboutDialogPrivate(this)) { Q_D(KAboutDialog); setProperty("isAboutDialog",true); mainLayout()->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize); d->m_iconName = appIcon.name(); d->m_pAppIconLabel = new QLabel(this); QPixmap pix(appIcon.pixmap(QSize(96,96))); d->m_pAppIconLabel->setPixmap(pix); d->m_pAppIconLabel->setAlignment(Qt::AlignCenter); d->m_pAppNameLabel = new QLabel(this); d->m_pAppNameLabel->setText(appName); d->m_pAppNameLabel->setAlignment(Qt::AlignCenter); if(!(appVersion=="") && (!(appVersion.isNull())) ) d->m_appVersionFlag =false; d->m_pAppVersionLabel = new QLabel(this); d->m_pAppVersionLabel->setText(appVersion); d->m_pAppVersionLabel->setAlignment(Qt::AlignCenter); d->m_pAppSupportLabel = new QLabel(this); d->m_pAppSupportLabel->setFixedWidth(400); d->m_pAppPrivacyLabel = new LinkLabel(this); d->m_pAppPrivacyLabel->setAlignment(Qt::AlignCenter); d->m_pAppPrivacyLabel->setVisible(false); d->adjustMiniMode(); connect(d->m_pAppSupportLabel,&QLabel::linkActivated,this,[=](const QString url){ QString appid = d->getDefaultAppId(MAILTYPE); if(appid.isEmpty()) { QMessageBox msg(this); msg.setIcon(QMessageBox::Icon::Information); msg.setIconPixmap(QIcon::fromTheme("dialog-info").pixmap(24,24)); msg.setInformativeText(tr("No mail application accessible in your system.")); msg.setText(tr("Unable to open mail application")); msg.exec(); } else QDesktopServices::openUrl(QUrl(url)); }); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,[=](){changeTheme();}); QString qtTransPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); QTranslator *trans_qt = new QTranslator(this); if (trans_qt->load(QLocale(), "qt", "_", qtTransPath)) qApp->installTranslator(trans_qt); QTranslator *trans = new QTranslator(this); if(trans->load(QString(":/translations/gui_%1.qm").arg(QLocale::system().name()))) qApp->installTranslator(trans); if(d->isOpenKylin()) d->m_pAppSupportLabel->hide(); } KAboutDialog::~KAboutDialog() { } void KAboutDialog::setAppIcon(const QIcon& icon) { Q_D(KAboutDialog); d->m_iconName = icon.name(); QPixmap pix(icon.pixmap(QSize(96,96))); d->m_pAppIconLabel->setPixmap(pix); d->m_pAppIconLabel->setAlignment(Qt::AlignCenter); update(); } void KAboutDialog::setAppName(const QString& appName) { Q_D(KAboutDialog); d->m_pAppNameLabel->setText(appName); update(); } QString KAboutDialog::appName() { Q_D(KAboutDialog); return d->m_pAppNameLabel->text(); } void KAboutDialog::setAppVersion(const QString& appVersion) { Q_D(KAboutDialog); if(!appVersion.isNull()) { d->m_appVersionFlag = false; d->m_pAppVersionLabel->setText(appVersion); update(); } } QString KAboutDialog::appVersion() { Q_D(KAboutDialog); return d->m_pAppVersionLabel->text(); } void KAboutDialog::setBodyText(const QString& bodyText) { Q_D(KAboutDialog); d->m_bodyText = bodyText; } QString KAboutDialog::bodyText() { Q_D(KAboutDialog); return d->m_bodyText; } void KAboutDialog::setAppSupport(const QString& appSupport) { Q_D(KAboutDialog); d->m_pAppSupportLabel->setText(appSupport); update(); } QString KAboutDialog::appSupport() { Q_D(KAboutDialog); return d->m_pAppSupportLabel->text(); } void KAboutDialog::setBodyTextVisiable(bool flag) { Q_D(KAboutDialog); //do nothing } void KAboutDialog::setAppPrivacyLabelVisible(bool flag) { Q_D(KAboutDialog); d->m_pAppPrivacyLabel->setVisible(flag); } bool KAboutDialog::AppPrivacyLabelIsVisible() { Q_D(KAboutDialog); return d->m_pAppPrivacyLabel->isVisible(); } void KAboutDialog::changeTheme() { Q_D(KAboutDialog); KDialog::changeTheme(); auto icon = QIcon::fromTheme(d->m_iconName); if(!icon.isNull()) { QPixmap pix(icon.pixmap(QSize(96,96))); d->m_pAppIconLabel->setPixmap(pix); } QFont font; font.setPixelSize(ThemeController::systemFontSize() * 1.7); font.setWeight(QFont::Medium); d->m_pAppNameLabel->setFont(font); QPalette palette = qApp->palette(); if(ThemeController::themeMode() == LightTheme) { palette.setColor(QPalette::Text,QColor("#595959")); palette.setColor(QPalette::WindowText,QColor("#595959")); palette.setColor(QPalette::Base,QColor(0,0,0,0)); d->m_pAppSupportLabel->setPalette(palette); d->m_pAppVersionLabel->setPalette(palette); d->m_pAppSupportLabel->setText(tr("Service & Support: ") + "" "support@kylinos.cn"); palette.setColor(QPalette::WindowText,QColor("#307FF5")); d->m_pAppPrivacyLabel->setPalette(palette); d->m_pAppPrivacyLabel->setText(tr("Privacy statement")); } else { palette.setColor(QPalette::ButtonText,QColor("#D9D9D9")); palette.setColor(QPalette::WindowText,QColor("#D9D9D9")); d->m_pAppSupportLabel->setPalette(palette); d->m_pAppVersionLabel->setPalette(palette); d->m_pAppSupportLabel->setText(tr("Service & Support: ") + "" "support@kylinos.cn"); palette.setColor(QPalette::WindowText,QColor("#307FF5")); d->m_pAppPrivacyLabel->setPalette(palette); d->m_pAppPrivacyLabel->setText(tr("Privacy statement")); } } void KAboutDialog::paintEvent(QPaintEvent *paintEvent) { Q_D(KAboutDialog); if(d->m_appVersionFlag) d->updateAppVersionText(); QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); if(ThemeController::widgetTheme() == FashionTheme) { auto pixmap = ThemeController::drawFashionBackground(opt.rect,32,36,8,0); p.drawPixmap(opt.rect,pixmap); } } KAboutDialogPrivate::KAboutDialogPrivate(KAboutDialog *parent) :q_ptr(parent),m_appVersionFlag(true) { setParent(parent); } void KAboutDialogPrivate::adjustMiniMode() { Q_Q(KAboutDialog); if(q->mainWidget()->layout()) delete q->mainWidget()->layout(); m_pAppSupportLabel->setAlignment(Qt::AlignCenter); QVBoxLayout *vBoxLayout = new QVBoxLayout(); vBoxLayout->setSpacing(0); vBoxLayout->addSpacing(20); vBoxLayout->addWidget(m_pAppIconLabel); vBoxLayout->addSpacing(24); vBoxLayout->addWidget(m_pAppNameLabel); vBoxLayout->addSpacing(16); vBoxLayout->addWidget(m_pAppVersionLabel); vBoxLayout->addSpacing(16); vBoxLayout->addWidget(m_pAppSupportLabel); vBoxLayout->addSpacing(16); vBoxLayout->addWidget(m_pAppPrivacyLabel); vBoxLayout->setContentsMargins(25,0,25,0); vBoxLayout->addSpacing(35); q->mainWidget()->setLayout(vBoxLayout); } QString KAboutDialogPrivate::getDefaultAppId(const char *contentType) { QString localfile = QDir::homePath() + LOCAL_CONFIG_DIR + "mimeapps.list"; QString systemfile = SYSTEM_CONFIG_DIR + QString("ukui-mimeapps.list"); if (QFile(localfile).exists()) { QSettings* mimeappFile = new QSettings(localfile, QSettings::IniFormat); mimeappFile->setIniCodec("utf-8"); QString str = mimeappFile->value(QString("Default Applications/%1").arg(contentType)).toString(); if (!str.isEmpty()) { if (QFile(SYSTEM_CONFIG_DIR +str).exists()) { return str; } else { return QString(""); } } delete mimeappFile; mimeappFile = nullptr; } if (QFile(systemfile).exists()) { QSettings* mimeappFile = new QSettings(systemfile, QSettings::IniFormat); mimeappFile->setIniCodec("utf-8"); QString str = mimeappFile->value(QString("Default Applications/%1").arg(contentType)).toString(); if (!str.isEmpty()) { if (QFile(SYSTEM_CONFIG_DIR +str).exists()) { return str; } else { return QString(""); } } delete mimeappFile; mimeappFile = nullptr; } return QString(""); } bool KAboutDialogPrivate::isOpenKylin() { QString filename = "/etc/os-release"; QSettings osSettings(filename, QSettings::IniFormat); QString versionID = osSettings.value("ID").toString(); if (versionID.compare("openkylin", Qt::CaseInsensitive)) { return false; } return true; } void KAboutDialogPrivate::updateAppVersionText() { Q_Q(KAboutDialog); QProcess process; if( QCoreApplication::applicationFilePath().contains(QApplication::applicationName())) { QStringList list; QString str("dpkg -l | grep "+QApplication::applicationName() +" | awk '{print $3}'"); list<<"-c"<setText(result); } process.close(); } LinkLabel::LinkLabel(QWidget *parent) :QLabel(parent) { } void LinkLabel::mousePressEvent(QMouseEvent *event) { if(event->button() == Qt::LeftButton) { QProcess *process = new QProcess(this); QStringList l; l <<"-A"<<"kylin-os"; process->start("kylin-user-guide",l); } QLabel::mousePressEvent(event); } } #include "kaboutdialog.moc" #include "moc_kaboutdialog.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/xatom-helper.cpp0000664000175000017500000001367414474244076024204 0ustar adminadmin/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan */ #include "xatom-helper.h" #include #include #include #include //#include using namespace kdk; static XAtomHelper *global_instance = nullptr; XAtomHelper *XAtomHelper::getInstance() { if (!global_instance) global_instance = new XAtomHelper; return global_instance; } bool XAtomHelper::isFrameLessWindow(int winId) { auto hints = getInstance()->getWindowMotifHint(winId); if (hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) { return true; } return false; } bool XAtomHelper::isWindowDecorateBorderOnly(int winId) { return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId)); } bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint) { bool isDeco = false; if (hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) { if (hint.decorations == MWM_DECOR_BORDER) isDeco = true; } return isDeco; } bool XAtomHelper::isUKUICsdSupported() { // fixme: return false; } bool XAtomHelper::isUKUIDecorationWindow(int winId) { if (m_ukuiDecorationAtion == None) return false; Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; bool isUKUIDecoration = false; XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, 0, LONG_MAX, false, m_ukuiDecorationAtion, &type, &format, &nitems, &bytes_after, &data); if (type == m_ukuiDecorationAtion) { if (nitems == 1) { isUKUIDecoration = data[0]; } } return isUKUIDecoration; } UnityCorners XAtomHelper::getWindowBorderRadius(int winId) { UnityCorners corners; Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; if (m_unityBorderRadiusAtom != None) { XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, 0, LONG_MAX, false, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &data); if (type == XA_CARDINAL) { if (nitems == 4) { corners.topLeft = static_cast(data[0]); corners.topRight = static_cast(data[1*sizeof (ulong)]); corners.bottomLeft = static_cast(data[2*sizeof (ulong)]); corners.bottomRight = static_cast(data[3*sizeof (ulong)]); } XFree(data); } } return corners; } void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight}; XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, 32, 0, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight}; XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, 32, 0, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set) { if (m_ukuiDecorationAtion == None) return; XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, 0, (const unsigned char *) &set, 1); } void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints) { if (m_unityBorderRadiusAtom == None) return; XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom, 32, 0, (const unsigned char *)&hints, sizeof (MotifWmHints)/ sizeof (ulong)); } MotifWmHints XAtomHelper::getWindowMotifHint(int winId) { MotifWmHints hints; if (m_unityBorderRadiusAtom == None) return hints; uchar *data; Atom type; int format; ulong nitems; ulong bytes_after; XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom, 0, sizeof (MotifWmHints)/sizeof (long), false, AnyPropertyType, &type, &format, &nitems, &bytes_after, &data); if (type == None) { return hints; } else { hints = *(MotifWmHints *)data; XFree(data); } return hints; } XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent) { if (!QX11Info::isPlatformX11()) return; m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true); m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false); m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false); } Atom XAtomHelper::registerUKUICsdNetWmSupportAtom() { // fixme: return None; } void XAtomHelper::unregisterUKUICsdNetWmSupportAtom() { // fixme: } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogressdialog.cpp0000664000175000017500000002074314474244170024764 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kprogressdialog.h" namespace kdk { class KProgressDialogPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KProgressDialog) public: KProgressDialogPrivate(KProgressDialog*parent); void adjustNormalMode(); void infoReset(); private: KProgressDialog* const q_ptr; QProgressBar *m_pProgressBar; QLabel *m_pMainLabel; QLabel *m_pPercentLabel; QLabel *m_pSubContentLabel; QLabel *m_pProgressLabel; QPushButton* m_pCanelButton; QVBoxLayout* m_pMainLayout; QString m_suffix; bool m_autoClose; bool m_autoReset; bool m_forceHide; }; KProgressDialog::KProgressDialog(QWidget *parent) :KDialog(parent), d_ptr(new KProgressDialogPrivate(this)) { Q_D(KProgressDialog); // setFixedSize(440,265); this->layout()->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize); d->m_pMainLayout = new QVBoxLayout(); d->m_pMainLayout->setContentsMargins(25,0,25,30); d->m_pMainLayout->setSpacing(0); d->m_pMainLabel = new QLabel(this); d->m_pMainLabel->setAlignment(Qt::AlignLeft); d->m_pProgressBar = new QProgressBar(this); d->m_pCanelButton = new QPushButton(this); d->m_pCanelButton->setText(tr("cancel")); d->m_pSubContentLabel = new QLabel(this); d->m_pPercentLabel = new QLabel(this); d->m_pProgressLabel = new QLabel(this); d->m_autoClose = true; d->m_autoReset = true; d->m_forceHide = false; d->adjustNormalMode(); setShowDetail(false); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KProgressDialog::changeTheme); connect(this, SIGNAL(canceled()), this, SLOT(cancel())); connect(d->m_pCanelButton, SIGNAL(clicked()), this, SIGNAL(canceled())); } KProgressDialog::KProgressDialog(const QString &labelText, const QString &cancelButtonText, int minimum, int maximum, QWidget *parent) :KProgressDialog(parent) { Q_D(KProgressDialog); d->m_pMainLabel->setText(labelText); d->m_pProgressBar->setRange(minimum,maximum); d->m_pCanelButton->setText(cancelButtonText); d->adjustNormalMode(); setShowDetail(true); } KProgressDialog::~KProgressDialog() { } void KProgressDialog::setLabel(QLabel *label) { Q_D(KProgressDialog); if(!label) return; if(d->m_pMainLabel) delete d->m_pMainLabel; d->m_pMainLabel = label; d->m_pMainLabel->setVisible(true); } void KProgressDialog::setCancelButton(QPushButton *button) { Q_D(KProgressDialog); if(!button) return; if(d->m_pCanelButton) delete d->m_pCanelButton; d->m_pCanelButton = button; } void KProgressDialog::setBar(QProgressBar *bar) { Q_D(KProgressDialog); if(!bar) return; if(d->m_pProgressBar) delete d->m_pProgressBar; d->m_pProgressBar = bar; } void KProgressDialog::setSuffix(const QString &suffix) { Q_D(KProgressDialog); d->m_suffix = suffix; } void KProgressDialog::setShowDetail(bool flag) { Q_D(KProgressDialog); if(flag) { d->m_pSubContentLabel->setVisible(true); d->m_pProgressLabel->setVisible(true); d->m_pPercentLabel->setVisible(true); } else { d->m_pSubContentLabel->setVisible(false); d->m_pProgressLabel->setVisible(false); d->m_pPercentLabel->setVisible(false); } } int KProgressDialog::minimum() const { Q_D(const KProgressDialog); if(d->m_pProgressBar) return d->m_pProgressBar->minimum(); else return -1; } int KProgressDialog::maximum() const { Q_D(const KProgressDialog); if(d->m_pProgressBar) return d->m_pProgressBar->maximum(); else return -1; } int KProgressDialog::value() const { Q_D(const KProgressDialog); if(d->m_pProgressBar) return d->m_pProgressBar->value(); else return -1; } QString KProgressDialog::labelText() const { Q_D(const KProgressDialog); if(d->m_pMainLabel) return d->m_pMainLabel->text(); else { return QString(); } } void KProgressDialog::setAutoReset(bool reset) { Q_D(KProgressDialog); d->m_autoReset = reset; } bool KProgressDialog::autoReset() const { Q_D(const KProgressDialog); return d->m_autoReset; } void KProgressDialog::setAutoClose(bool close) { Q_D(KProgressDialog); d->m_autoClose = close; } bool KProgressDialog::autoClose() const { Q_D(const KProgressDialog); return d->m_autoClose; } QProgressBar *KProgressDialog::progressBar() { Q_D(KProgressDialog); return d->m_pProgressBar; } void KProgressDialog::cancel() { Q_D(KProgressDialog); d->m_forceHide = true; reset(); d->m_forceHide = false; } void KProgressDialog::reset() { Q_D(KProgressDialog); if (d->m_autoClose || d->m_forceHide) hide(); d->m_pProgressBar->reset(); d->infoReset(); } void KProgressDialog::setMaximum(int maximum) { Q_D(KProgressDialog); if(d->m_pProgressBar) d->m_pProgressBar->setMaximum(maximum); } void KProgressDialog::setMinimum(int minimum) { Q_D(KProgressDialog); if(d->m_pProgressBar) d->m_pProgressBar->setMinimum(minimum); } void KProgressDialog::setRange(int minimum, int maximum) { Q_D(KProgressDialog); if(d->m_pProgressBar) d->m_pProgressBar->setRange(minimum,maximum); } void KProgressDialog::setValue(int progress) { Q_D(KProgressDialog); if(d->m_pProgressBar) d->m_pProgressBar->setValue(progress); if(d->m_pPercentLabel) d->m_pPercentLabel->setText(QString::number(progress*100/maximum())+"%"); if(d->m_pProgressLabel) d->m_pProgressLabel->setText(QString("%1%2/%3%4").arg(progress).arg(d->m_suffix).arg(maximum()).arg(d->m_suffix)); } void KProgressDialog::setLabelText(const QString &text) { Q_D(KProgressDialog); if(d->m_pMainLabel) d->m_pMainLabel->setText(text); } void KProgressDialog::setCancelButtonText(const QString &text) { Q_D(KProgressDialog); if(d->m_pCanelButton) d->m_pCanelButton->setText(text); } void KProgressDialog::setSubContent(const QString &text) { Q_D(KProgressDialog); if(d->m_pSubContentLabel) { d->m_pSubContentLabel->setText(text); setShowDetail(true); } } void KProgressDialog::changeTheme() { Q_D(KProgressDialog); KDialog::changeTheme(); QFont font; font.setPixelSize(ThemeController::systemFontSize() * 1.7); d->m_pMainLabel->setFont(font); font.setPixelSize(ThemeController::systemFontSize() * 1.2); d->m_pPercentLabel->setFont(font); d->m_pSubContentLabel->setFont(font); d->m_pProgressLabel->setFont(font); } KProgressDialogPrivate::KProgressDialogPrivate(KProgressDialog *parent) :q_ptr(parent) { setParent(parent); } void KProgressDialogPrivate::adjustNormalMode() { Q_Q(KProgressDialog); QHBoxLayout* hLayout = new QHBoxLayout; hLayout->setSpacing(0); hLayout->addWidget(m_pSubContentLabel); hLayout->addStretch(); hLayout->addWidget(m_pPercentLabel); hLayout->addSpacing(15); hLayout->addWidget(m_pProgressLabel); m_pMainLayout->addStretch(); m_pMainLayout->addWidget(m_pMainLabel); m_pMainLayout->addSpacing(10); m_pMainLayout->addWidget(m_pProgressBar); m_pMainLayout->addLayout(hLayout); hLayout = new QHBoxLayout; hLayout->addStretch(); hLayout->addWidget(m_pCanelButton); m_pMainLayout->addSpacing(30); m_pMainLayout->addLayout(hLayout); q->mainWidget()->setLayout(m_pMainLayout); } void KProgressDialogPrivate::infoReset() { Q_Q(KProgressDialog); if(m_pPercentLabel) m_pPercentLabel->setText(+"0%"); if(m_pProgressLabel) m_pProgressLabel->setText(QString("%1%2/%3%4").arg(0).arg(m_suffix).arg(q->maximum()).arg(m_suffix)); } } #include "kprogressdialog.moc" #include "moc_kprogressdialog.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kballontip.cpp0000664000175000017500000001601514474244170023721 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include "kballontip.h" #include #include #include "themeController.h" namespace kdk { class KBallonTipPrivate:public QObject,public ThemeController { Q_DECLARE_PUBLIC(KBallonTip) Q_OBJECT public: KBallonTipPrivate(KBallonTip*parent); void adjustStyle(); protected: void changeTheme(); private: KBallonTip* q_ptr; QLabel* m_pContentLabel; QLabel* m_pIconLabel; TipType m_type; QIcon m_icon; QColor m_color; QHBoxLayout* m_pLayout; QVBoxLayout* m_pVLayout; int m_time; QGraphicsDropShadowEffect *m_pShadow_effect; }; KBallonTip::KBallonTip(QWidget *parent) : 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(12); this->setContentsMargins(24,18,24,18); d->m_pContentLabel = new QLabel(this); d->m_pContentLabel->setWordWrap(true); //设置具体阴影 d->m_pShadow_effect = new QGraphicsDropShadowEffect(this); d->m_pShadow_effect->setOffset(0, 0); //阴影颜色 d->m_pShadow_effect->setColor(this->palette().color(QPalette::Disabled,QPalette::Text)); //阴影半径 if(ThemeController::themeMode() == LightTheme) d->m_pShadow_effect->setBlurRadius(15); else d->m_pShadow_effect->setBlurRadius(0); this->setGraphicsEffect(d->m_pShadow_effect); d->m_pIconLabel = new QLabel(this); QVBoxLayout*vLayout = new QVBoxLayout; vLayout->addWidget(d->m_pIconLabel); vLayout->addStretch(); d->m_pLayout->addLayout(vLayout); d->m_pLayout->addWidget(d->m_pContentLabel); d->m_pLayout->setAlignment(Qt::AlignVCenter); d->m_type = TipType::Nothing; d->m_pVLayout->addStretch(); d->m_pVLayout->addLayout(d->m_pLayout); d->m_pVLayout->addStretch(); d->adjustStyle(); d->m_pVLayout->setSizeConstraint(QLayout::SizeConstraint::SetMinimumSize); if(ThemeController::systemFontSize() > 11) vLayout->setContentsMargins(0,(ThemeController::systemFontSize()-11),0,0); else vLayout->setContentsMargins(0,0,0,0); connect(d->m_gsetting,&QGSettings::changed,this,[=](){ if(ThemeController::themeMode() == LightTheme) d->m_pShadow_effect->setBlurRadius(15); else d->m_pShadow_effect->setBlurRadius(0); }); connect(d->m_gsetting,&QGSettings::changed,this,[=](const QString &key){ if(key.contains("systemFontSize")) if(ThemeController::systemFontSize() > 11) vLayout->setContentsMargins(0,(ThemeController::systemFontSize()-11),0,0); else vLayout->setContentsMargins(0,0,0,0); }); } KBallonTip::KBallonTip(const QString &content, const TipType &type, QWidget *parent) :KBallonTip(parent) { Q_D(KBallonTip); d->m_pContentLabel->setText(content); d->m_type = type; d->adjustStyle(); } void KBallonTip::showInfo() { Q_D(KBallonTip); show(); QTimer* timer = new QTimer(this); timer->start(d->m_time); timer->setSingleShot(true); connect(timer, SIGNAL(timeout()), this, SLOT(onTimeupDestroy())); } void KBallonTip::setTipType(const TipType& type) { Q_D(KBallonTip); d->m_type = type; d->adjustStyle(); } TipType KBallonTip::tipType() { Q_D(KBallonTip); return d->m_type; } void KBallonTip::setText(const QString &text) { Q_D(KBallonTip); d->m_pContentLabel->setText(text); } QString KBallonTip::text() { Q_D(KBallonTip); return d->m_pContentLabel->text(); } void KBallonTip::setContentsMargins(int left, int top, int right, int bottom) { Q_D(KBallonTip); d->m_pLayout->setContentsMargins(left,top,right,bottom); repaint(); } void KBallonTip::setContentsMargins(const QMargins &margins) { Q_D(KBallonTip); d->m_pLayout->setContentsMargins(margins); repaint(); } void KBallonTip::setTipTime(int my_time) { Q_D(KBallonTip); d->m_time=my_time; } void KBallonTip::onTimeupDestroy() { this->close(); } void KBallonTip::paintEvent(QPaintEvent *event) { Q_D(KBallonTip); // bug 173714 173165 adjustSize(); d->m_pShadow_effect->setColor(this->palette().color(QPalette::Disabled,QPalette::Text)); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; auto color = ThemeController::mixColor(this->palette().color(QPalette::Mid),QColor(100,100,100),0.5); QPen pen; pen.setColor(color); pen.setWidthF(0.2); painter.setPen(pen); painter.setBrush(this->palette().color(QPalette::Window)); QRect rect = this->rect(); painter.drawRoundedRect(rect.adjusted(8,8,-8,-8), 6, 6); if(ThemeController::widgetTheme() == FashionTheme) { auto pixmap = ThemeController::drawFashionBackground(this->rect(),15,20,8,1); painter.drawPixmap(rect.adjusted(8,8,-8,-8),pixmap); } } KBallonTipPrivate::KBallonTipPrivate(KBallonTip *parent) :q_ptr(parent) { Q_Q(KBallonTip); m_time = 1000; setParent(parent); } void KBallonTipPrivate::adjustStyle() { Q_Q(KBallonTip); switch (m_type) { case TipType::Nothing: m_icon = QIcon(); m_pIconLabel->hide(); break; case TipType::Normal: // 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:; m_icon = QIcon::fromTheme("dialog-info"); m_pIconLabel->show(); break; case TipType::Warning: m_icon = QIcon::fromTheme("dialog-warning"); m_pIconLabel->show(); break; case TipType::Error: m_icon = QIcon::fromTheme("dialog-error"); m_pIconLabel->show(); break; default: break; } m_pIconLabel->setPixmap(m_icon.pixmap(22,22)); m_pIconLabel->setFixedSize(22,22); m_pContentLabel->setAlignment(Qt::AlignLeft); } void KBallonTipPrivate::changeTheme() { } } #include "kballontip.moc" #include "moc_kballontip.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kshadowhelper.cpp0000664000175000017500000001577114474244170024432 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kshadowhelper.h" #include #include #include #include #include #include #include extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); namespace kdk { namespace effects { class KShadowHelperPrivate:public QObject { Q_DECLARE_PUBLIC(KShadowHelper) Q_OBJECT public: KShadowHelperPrivate(KShadowHelper*parent); QPixmap getShadowPixmap(QColor color, int shadowBorder, qreal darkness, int borderRadius = 0); KWindowShadow *getShadow(QColor color, int shadowBorder, qreal darkness, int borderRadius = 0); protected: bool eventFilter(QObject *watched, QEvent *event); private: KShadowHelper* q_ptr; QMap m_shadows; }; static KShadowHelper* g_kshadowHelper = nullptr; KShadowHelper *KShadowHelper::self() { if(g_kshadowHelper) return g_kshadowHelper; g_kshadowHelper = new KShadowHelper(); return g_kshadowHelper; } void KShadowHelper::setWidget(QWidget *widget, int borderRadius, int shadowWidth, qreal darkness) { Q_D(KShadowHelper); KWindowShadow* shadow = d->getShadow(QColor(26,26,26),shadowWidth,darkness,borderRadius); shadow->setPadding(QMargins(shadowWidth,shadowWidth,shadowWidth,shadowWidth)); widget->installEventFilter(d); d->m_shadows.insert(widget, shadow); connect(widget, &QWidget::destroyed, this, [=](){ if (auto shadowToBeDelete = d->m_shadows.value(widget)) { if (shadowToBeDelete->isCreated()) shadowToBeDelete->destroy(); shadowToBeDelete->deleteLater(); d->m_shadows.remove(widget); } }); } KShadowHelper::KShadowHelper(QObject *parent) : QObject(parent), d_ptr(new KShadowHelperPrivate(this)) { } KShadowHelperPrivate::KShadowHelperPrivate(KShadowHelper *parent) :q_ptr(parent) { } QPixmap KShadowHelperPrivate::getShadowPixmap(QColor color, int shadowBorder, qreal darkness, int borderRadius) { QPixmap pixmap(QSize(100,100)); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter.setBrush(color); painter.setPen(Qt::NoPen); painter.drawRoundedRect(pixmap.rect().adjusted(shadowBorder,shadowBorder,-shadowBorder,-shadowBorder),borderRadius,borderRadius); QImage rawImg = pixmap.toImage(); qt_blurImage(rawImg, shadowBorder, true, true); for (int x = 0; x < rawImg.width(); x++) { for (int y = 0; y < rawImg.height(); y++) { auto color = rawImg.pixelColor(x, y); if (color.alpha() == 0) continue; color.setAlphaF(darkness * color.alphaF()); rawImg.setPixelColor(x, y, color); } } QPixmap target = QPixmap::fromImage(rawImg); QPainter painter2(&target); painter2.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter2.setCompositionMode(QPainter::CompositionMode_Clear); painter2.setBrush(Qt::transparent); painter2.setPen(Qt::NoPen); painter2.drawRoundedRect(target.rect().adjusted(shadowBorder,shadowBorder,-shadowBorder,-shadowBorder),borderRadius,borderRadius); return target; } KWindowShadow *KShadowHelperPrivate::getShadow(QColor color, int shadowBorder, qreal darkness, int borderRadius) { QPixmap pixmap = getShadowPixmap(color,shadowBorder,darkness,borderRadius); int parm = shadowBorder*2; QPixmap topLeftPixmap = pixmap.copy(0, 0, parm, parm); QPixmap topPixmap = pixmap.copy(parm, 0, pixmap.width()-parm*2, parm); QPixmap topRightPixmap = pixmap.copy(pixmap.width()-parm, 0, parm, parm); QPixmap leftPixmap = pixmap.copy(0, parm, parm, pixmap.height()-parm*2); QPixmap rightPixmap = pixmap.copy(pixmap.width()-parm, parm, parm, pixmap.height()-parm*2); QPixmap bottomLeftPixmap = pixmap.copy(0, pixmap.height()-parm, parm, parm); QPixmap bottomPixmap = pixmap.copy(parm, pixmap.height()-parm, pixmap.width()-parm*2, parm); QPixmap bottomRightPixmap = pixmap.copy(pixmap.width()-parm,pixmap.height()-parm, parm, parm); KWindowShadow *shadow = new KWindowShadow; KWindowShadowTile::Ptr topLeftTile = KWindowShadowTile::Ptr::create(); topLeftTile.get()->setImage(topLeftPixmap.toImage()); shadow->setTopLeftTile(topLeftTile); KWindowShadowTile::Ptr topTile = KWindowShadowTile::Ptr::create(); topTile.get()->setImage(topPixmap.toImage()); shadow->setTopTile(topTile); KWindowShadowTile::Ptr topRightTile = KWindowShadowTile::Ptr::create(); topRightTile.get()->setImage(topRightPixmap.toImage()); shadow->setTopRightTile(topRightTile); KWindowShadowTile::Ptr leftTile = KWindowShadowTile::Ptr::create(); leftTile.get()->setImage(leftPixmap.toImage()); shadow->setLeftTile(leftTile); KWindowShadowTile::Ptr rightTile = KWindowShadowTile::Ptr::create(); rightTile.get()->setImage(rightPixmap.toImage()); shadow->setRightTile(rightTile); KWindowShadowTile::Ptr bottomLeftTile = KWindowShadowTile::Ptr::create(); bottomLeftTile.get()->setImage(bottomLeftPixmap.toImage()); shadow->setBottomLeftTile(bottomLeftTile); KWindowShadowTile::Ptr bottomTile = KWindowShadowTile::Ptr::create(); bottomTile.get()->setImage(bottomPixmap.toImage()); shadow->setBottomTile(bottomTile); KWindowShadowTile::Ptr bottomRightTile = KWindowShadowTile::Ptr::create(); bottomRightTile.get()->setImage(bottomRightPixmap.toImage()); shadow->setBottomRightTile(bottomRightTile); return shadow; } bool KShadowHelperPrivate::eventFilter(QObject *watched, QEvent *event) { if(watched->isWidgetType()) { auto widget = qobject_cast(watched); if(widget->isTopLevel() && event->type() == QEvent::Show) { if (auto shadow = m_shadows.value(widget)) { shadow->setWindow(widget->windowHandle()); shadow->create(); } } } return QObject::eventFilter(watched,event); } } } #include "kshadowhelper.moc" #include "moc_kshadowhelper.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kuninstalldialog.cpp0000664000175000017500000002670314474244170025133 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include "kuninstalldialog.h" namespace kdk { class KUninstallDialogPrivate:public QObject { Q_DECLARE_PUBLIC(KUninstallDialog) Q_OBJECT public: KUninstallDialogPrivate(KUninstallDialog*parent); QString getIconPath(QString appName); QString setLabelStringBody(QString text, QLabel *lable); QString getAppCnName(QString appName); void resetAppInfo(QString appName, QString appVersion); void fontGsettingInit(); void setLabelText(); private: KUninstallDialog* q_ptr; QString m_appName; QString m_appVersion; QVBoxLayout *debInfoLayout; QWidget *IconAndAppNameWidget; QHBoxLayout *IconAndAppNameLayout; QWidget *debNameAndVersionWidget; QHBoxLayout *debNameAndVersionLayout; QWidget *nameVersionWidget; QVBoxLayout *nameVersionVLayout; QGSettings *m_pGsettingFontSize; QLabel *debIconLabel; QLabel *debAppNameLabel; QLabel *debNameLabel; QLabel *debVersionLabel; QPushButton * m_pUninstallBtn; }; KUninstallDialog::~KUninstallDialog() { } QLabel *KUninstallDialog::debAppNameLabel() { Q_D(KUninstallDialog); return d->debAppNameLabel; } QLabel *KUninstallDialog::debNameLabel() { Q_D(KUninstallDialog); return d->debNameLabel; } QLabel *KUninstallDialog::debIconLabel() { Q_D(KUninstallDialog); return d->debIconLabel; } QLabel *KUninstallDialog::debVersionLabel() { Q_D(KUninstallDialog); return d->debVersionLabel; } QPushButton *KUninstallDialog::uninstallButtton() { Q_D(KUninstallDialog); return d->m_pUninstallBtn; } void KUninstallDialog::changeTheme() { KDialog::changeTheme(); if(ThemeController::themeMode() == LightTheme) { //to do 还没有具体的设计图 只有截图 } else { //to do 还没有具体的设计图 只有截图 } } KUninstallDialog::KUninstallDialog(QString appName, QString appVersion, QWidget *parent) :KDialog(parent), d_ptr(new KUninstallDialogPrivate(this)) { Q_D(KUninstallDialog); d->m_appName = appName; d->m_appVersion = appVersion; setWindowTitle(tr("uninstall")); this->setFixedSize(550,450); d->debInfoLayout = new QVBoxLayout(); d->debInfoLayout->setContentsMargins(0, 0, 0, 0); d->IconAndAppNameWidget = new QWidget(); d->IconAndAppNameWidget->setContentsMargins(0, 0, 0, 0); d->IconAndAppNameLayout = new QHBoxLayout(); d->IconAndAppNameLayout->setContentsMargins(0,0,0,0); d->IconAndAppNameLayout->setSpacing(0); d->debIconLabel = new QLabel(); d->debIconLabel->setFixedSize(48, 48); /*先判断主题中是否有icon*/ if (QIcon::fromTheme(d->m_appName).isNull()) { QPixmap pixmap = QPixmap(d->getIconPath(d->m_appName)); pixmap.scaled(QSize(48,48), Qt::KeepAspectRatio); d->debIconLabel->setPixmap(QIcon(QPixmap(d->getIconPath(d->m_appName))).pixmap(QSize(48,48))); setWindowIcon(QIcon(QPixmap(d->getIconPath(d->m_appName))).pixmap(QSize(24,24))); } else { d->debIconLabel->setPixmap(QIcon::fromTheme(d->m_appName).pixmap(QSize(48,48))); setWindowIcon(QIcon::fromTheme(d->m_appName).pixmap(QSize(24,24))); } d->debIconLabel->adjustSize(); d->fontGsettingInit(); d->debAppNameLabel = new QLabel(); QFont font2 = d->debAppNameLabel->font(); font2.setPixelSize(d->m_pGsettingFontSize->get(GSETTING_FONT_KEY).toInt() * 2.5); d->debAppNameLabel->setFont(font2); d->debAppNameLabel->setFixedWidth(331); QLocale locale; if (locale.language() == QLocale::Chinese) { if (d->getAppCnName(d->m_appName).isNull()) { d->debAppNameLabel->setText(d->setLabelStringBody(d->m_appName, d->debAppNameLabel)); } else { d->debAppNameLabel->setText(d->setLabelStringBody(d->getAppCnName(d->m_appName), d->debAppNameLabel)); } } else { d->debAppNameLabel->setText(d->setLabelStringBody(d->m_appName, d->debAppNameLabel)); } d->debAppNameLabel->adjustSize(); d->IconAndAppNameLayout->addItem(new QSpacerItem(124, 10, QSizePolicy::Fixed)); d->IconAndAppNameLayout->addWidget(d->debIconLabel); d->IconAndAppNameLayout->addItem(new QSpacerItem(12, 10, QSizePolicy::Fixed)); d->IconAndAppNameLayout->addWidget(d->debAppNameLabel); d->IconAndAppNameLayout->addItem(new QSpacerItem(400, 10, QSizePolicy::Expanding)); d->IconAndAppNameWidget->setLayout(d->IconAndAppNameLayout); d->debNameAndVersionWidget = new QWidget(); d->debNameAndVersionLayout = new QHBoxLayout(); d->debNameAndVersionLayout->setContentsMargins(0,0,0,0); d->debNameAndVersionLayout->setSpacing(0); d->debNameLabel = new QLabel(); QString debName = tr("deb name:"); debName.append(appName); d->debNameLabel->setText(debName); d->debNameLabel->adjustSize(); d->debVersionLabel = new QLabel(); QString debVersion = tr("deb version:"); debVersion.append(appVersion); d->debVersionLabel->setText(debVersion); d->debVersionLabel->adjustSize(); if (d->debVersionLabel->width() > 329) { d->debVersionLabel->setText(debVersion.left(20) + "..."); d->debVersionLabel->setToolTip(debVersion); } d->nameVersionWidget = new QWidget(); d->nameVersionVLayout = new QVBoxLayout(); d->nameVersionVLayout->setContentsMargins(0, 0, 0, 0); d->nameVersionVLayout->addWidget(d->debNameLabel); d->nameVersionVLayout->addWidget(d->debVersionLabel); d->nameVersionVLayout->setSpacing(0); d->nameVersionWidget->setLayout(d->nameVersionVLayout); d->debNameAndVersionLayout->addItem(new QSpacerItem(184, 10, QSizePolicy::Fixed)); d->debNameAndVersionLayout->addWidget(d->nameVersionWidget); d->debNameAndVersionLayout->addItem(new QSpacerItem(330, 10, QSizePolicy::Expanding)); d->debNameAndVersionWidget->setLayout(d->debNameAndVersionLayout); d->debInfoLayout->addStretch(); d->debInfoLayout->addWidget(d->IconAndAppNameWidget); d->debInfoLayout->addWidget(d->debNameAndVersionWidget); d->debInfoLayout->addSpacing(25); d->m_pUninstallBtn = new QPushButton(tr("uninstall"),this); d->m_pUninstallBtn->setFixedSize(122,40); QWidget *pBtnWidget = new QWidget(); QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->addItem(new QSpacerItem(184, 10, QSizePolicy::Fixed)); hLayout->addWidget(d->m_pUninstallBtn); hLayout->addStretch(); pBtnWidget->setLayout(hLayout); d->debInfoLayout->addWidget(pBtnWidget); d->debInfoLayout->addStretch(); mainWidget()->setLayout(d->debInfoLayout); changeTheme(); } KUninstallDialogPrivate::KUninstallDialogPrivate(KUninstallDialog *parent) :q_ptr(parent) { setParent(parent); } QString KUninstallDialogPrivate::getIconPath(QString appName) { QString iconFilePath; /*cr判断~/.cache/icons下是否有icon*/ iconFilePath.clear(); iconFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.cache/uksc/icons/"+appName + ".png"; if (QFile::exists(iconFilePath)) { return iconFilePath; } /*最后判断/usr/share/ubuntu-kylin-software-center/data/icons下面是否有*/ iconFilePath.clear(); iconFilePath = "/usr/share/kylin-software-center/data/icons/" + appName + ".png"; if (QFile::exists(iconFilePath)) { return iconFilePath; } return nullptr; } QString KUninstallDialogPrivate::setLabelStringBody(QString text, QLabel *lable) { QFontMetrics fontMetrics(lable->font()); int LableWidth = lable->width(); int fontSize = fontMetrics.width(text); QString formatBody = text; if(fontSize > (LableWidth - 10)) { formatBody = fontMetrics.elidedText(formatBody, Qt::ElideRight, LableWidth - 10); return formatBody; } return formatBody; } QString KUninstallDialogPrivate::getAppCnName(QString appName) { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.cache/uksc/uksc.db"); if (!db.open()) { return nullptr; } QSqlQuery query; query.exec(QString("SELECT * FROM application WHERE app_name IS '%1'").arg(appName)); //执行 while(query.next()) { return query.value(4).toString(); } db.close(); return nullptr; } void KUninstallDialogPrivate::resetAppInfo(QString appName, QString appVersion) { Q_Q(KUninstallDialog); m_appName = appName; m_appVersion = appVersion; /*先判断主题中是否有icon*/ if (QIcon::fromTheme(m_appName).isNull()) { QPixmap pixmap = QPixmap(getIconPath(m_appName)); pixmap.scaled(QSize(48,48), Qt::KeepAspectRatio); debIconLabel->setPixmap(QIcon(QPixmap(getIconPath(m_appName))).pixmap(QSize(48,48))); } else { debIconLabel->setPixmap(QIcon::fromTheme(m_appName).pixmap(QSize(48,48))); } if (getAppCnName(m_appName).isNull()) debAppNameLabel->setText(m_appName); else debAppNameLabel->setText(getAppCnName(m_appName)); QString debName = tr("deb name:"); debName.append(appName); debNameLabel->setText(debName); QString debVersion = tr("deb version:"); debVersion.append(appVersion); debVersionLabel->setText(debVersion); debVersionLabel->adjustSize(); if (debVersionLabel->width() > 329) { debVersionLabel->setText(debVersion.left(20) + "..."); debVersionLabel->setToolTip(debVersion); } } void KUninstallDialogPrivate::fontGsettingInit() { Q_Q(KUninstallDialog); const QByteArray style_id(ORG_UKUI_STYLE_FONT); m_pGsettingFontSize = new QGSettings(style_id); connect(m_pGsettingFontSize, &QGSettings::changed, this, [=] (const QString &key) { if (key == GSETTING_FONT_KEY) { setLabelText(); } }); } void KUninstallDialogPrivate::setLabelText() { Q_Q(KUninstallDialog); QFont font; font.setPixelSize(m_pGsettingFontSize->get(GSETTING_FONT_KEY).toDouble() * 2.5); debAppNameLabel->setFont(font); QLocale locale; if (locale.language() == QLocale::Chinese) { if (getAppCnName(m_appName).isNull()) { q->setWindowTitle(setLabelStringBody(m_appName, debAppNameLabel)); } else { q->setWindowTitle(setLabelStringBody(getAppCnName(m_appName), debAppNameLabel)); } } else { q->setWindowTitle(setLabelStringBody(m_appName, debAppNameLabel)); } } } #include "kuninstalldialog.moc"; #include "moc_kuninstalldialog.cpp"; libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbackgroundgroup.h0000664000175000017500000000572714474244170024606 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBACKGROUNDGROUP_H #define KBACKGROUNDGROUP_H #include "gui_g.h" #include #include 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 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 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 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 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogresscircle.cpp0000664000175000017500000002567414474244170024776 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kprogresscircle.h" #include #include #include #include #include "themeController.h" namespace kdk { class KProgressCirclePrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KProgressCircle) public: KProgressCirclePrivate(KProgressCircle*parent); void initDefaultFormat(); void drawBaseCircle(QPainter*painter); void dawColoredCircle(QPainter*painter); void drawText(QPainter*painter); void calculateCircleRect(); void changeTheme(); private: KProgressCircle *q_ptr; int m_minimum; int m_maximum; int m_value; QString m_format; QString m_text; bool m_defaultFormat; bool m_isTextVisiable; ProgressBarState m_state; QColor m_color; QColor m_baseColor; QColor m_baseCircleColor; QRect m_baseRect; QRect m_contentRect; int m_cirleWidth; int m_startAngel; int m_pixWidth; int m_textWidth; }; KProgressCircle::KProgressCircle(QWidget *parent) : QWidget(parent), d_ptr(new KProgressCirclePrivate(this)) { setFixedSize(60,60); connect(this,&KProgressCircle::valueChanged,this,[=](){ if(this->value()==this->maximum()) setState(SuccessProgress); }); } int KProgressCircle::minimum() const { Q_D(const KProgressCircle); return d->m_minimum; } int KProgressCircle::maximum() const { Q_D(const KProgressCircle); return d->m_maximum; } int KProgressCircle::value() const { Q_D(const KProgressCircle); return d->m_value; } QString KProgressCircle::text() const { Q_D(const KProgressCircle); if ((d->m_maximum == 0 && d->m_minimum == 0) || d->m_value < d->m_minimum || (d->m_value == INT_MIN && d->m_minimum == INT_MIN)) return QString(); qint64 totalSteps = qint64(d->m_maximum) - d->m_minimum; QString result = d->m_format; QLocale locale = QWidget::locale(); locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator); result.replace(QLatin1String("%m"), QString::number(totalSteps)); result.replace(QLatin1String("%v"), QString::number(d->m_value)); if (totalSteps == 0) { result.replace(QLatin1String("%p"), locale.toString(100)); return result; } const auto progress = static_cast((qint64(d->m_value) - d->m_minimum) * 100.0 / totalSteps); result.replace(QLatin1String("%p"), QString::number(progress)); return result; } void KProgressCircle::setTextVisible(bool visible) { Q_D(KProgressCircle); d->m_isTextVisiable = visible; update(); } bool KProgressCircle::isTextVisible() const { Q_D(const KProgressCircle); return d->m_isTextVisiable; } ProgressBarState KProgressCircle::state() { Q_D(const KProgressCircle); return d->m_state; } void KProgressCircle::setState(ProgressBarState state) { Q_D(KProgressCircle); d->m_state = state; switch (d->m_state) { case FailedProgress: d->m_color = "#FF4D4F"; break; case SuccessProgress: d->m_color = "#52C429"; break; case NormalProgress: default: d->m_color = "#3790FA"; break; } update(); } void KProgressCircle::reset() { Q_D(KProgressCircle); if (d->m_minimum == INT_MIN) d->m_value = INT_MIN; else d->m_value = d->m_minimum - 1; repaint(); } void KProgressCircle::setRange(int minimum, int maximum) { Q_D(KProgressCircle); if (minimum != d->m_minimum || maximum != d->m_maximum) { d->m_minimum = minimum; d->m_maximum = qMax(minimum, maximum); if (d->m_value < qint64(d->m_minimum) - 1 || d->m_value > d->m_maximum) reset(); else update(); } } void KProgressCircle::setMinimum(int minimum) { Q_D(KProgressCircle); setRange(minimum, qMax(d->m_maximum, minimum)); } void KProgressCircle::setMaximum(int maximum) { Q_D(KProgressCircle); setRange(qMin(d->m_minimum, maximum), maximum); } void KProgressCircle::setValue(int value) { Q_D(KProgressCircle); if (d->m_value == value || ((value > d->m_maximum || value < d->m_minimum) && (d->m_maximum != 0 || d->m_minimum != 0))) return; d->m_value = value; Q_EMIT valueChanged(value); repaint(); } void KProgressCircle::paintEvent(QPaintEvent *) { Q_D(KProgressCircle); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); d->calculateCircleRect(); d->drawBaseCircle(&painter); d->dawColoredCircle(&painter); d->drawText(&painter); } KProgressCirclePrivate::KProgressCirclePrivate(KProgressCircle *parent) :q_ptr(parent), m_minimum(0), m_maximum(100), m_value(0), m_cirleWidth(6), m_isTextVisiable(true), m_startAngel(90), m_pixWidth(20), m_textWidth(30), m_state(NormalProgress), m_color("#3790FA"), m_defaultFormat(true) { initDefaultFormat(); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KProgressCirclePrivate::changeTheme); } void KProgressCirclePrivate::initDefaultFormat() { Q_Q(KProgressCircle); if (m_defaultFormat) { QLocale locale = q->locale(); m_format = QLatin1String("%p") + locale.percent(); } } void KProgressCirclePrivate::drawBaseCircle(QPainter *painter) { Q_Q(KProgressCircle); QPen pen; if(m_isTextVisiable) { pen.setColor(m_baseColor); pen.setWidth(m_cirleWidth); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(m_baseRect); } else { painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(QBrush(m_baseColor)); painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(m_baseRect); painter->restore(); pen.setColor(m_baseCircleColor); pen.setWidth(m_cirleWidth); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(m_contentRect); } } void KProgressCirclePrivate::dawColoredCircle(QPainter *painter) { Q_Q(KProgressCircle); QPen pen; int angleSpan = m_value*360/m_maximum; if(m_state == ProgressBarState::NormalProgress){ m_color = q->palette().color(QPalette::Highlight); } if(m_isTextVisiable) { pen.setColor(m_color); pen.setWidth(m_cirleWidth); pen.setCapStyle(Qt::RoundCap); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->setRenderHint(QPainter::Antialiasing); painter->drawArc(m_baseRect,m_startAngel*16,-angleSpan*16); } else { pen.setColor(m_color); pen.setWidth(m_cirleWidth); pen.setCapStyle(Qt::RoundCap); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->setRenderHint(QPainter::Antialiasing); painter->drawArc(m_contentRect,m_startAngel*16,-angleSpan*16); } } void KProgressCirclePrivate::drawText(QPainter *painter) { Q_Q(KProgressCircle); QRect pixRect; pixRect.setLeft(q->rect().center().x()-m_pixWidth/2); pixRect.setTop(q->rect().center().y()-m_pixWidth/2); pixRect.setRight(q->rect().center().x()+m_pixWidth/2); pixRect.setBottom(q->rect().center().y()+m_pixWidth/2); QRect textRect; textRect.setLeft(q->rect().center().x()-m_textWidth/2); textRect.setTop(q->rect().center().y()-m_textWidth/2); textRect.setRight(q->rect().center().x()+m_textWidth/2); textRect.setBottom(q->rect().center().y()+m_textWidth/2); if(m_isTextVisiable) { switch (m_state) { case NormalProgress: { painter->setRenderHint(QPainter::Antialiasing); painter->drawText(textRect,Qt::AlignCenter,q->text()); } break; case SuccessProgress: { QColor green; if(ThemeController::widgetTheme() == FashionTheme) { if(ThemeController::themeMode() == LightTheme) green = QColor("#65E944"); else green = QColor("#52C429"); } else green = QColor("#52C429"); QPixmap pixmap = ThemeController::drawColoredPixmap(QIcon::fromTheme("object-select-symbolic").pixmap(m_pixWidth,m_pixWidth),green); painter->setRenderHint(QPainter::Antialiasing); painter->drawPixmap(pixRect,pixmap); break; } case FailedProgress: { QColor red; if(ThemeController::widgetTheme() == FashionTheme) { if(ThemeController::themeMode() == LightTheme) red = QColor("#EC334C"); else red = QColor("#FF4D4F"); } else red = QColor("#FF4D4F"); QPixmap pixmap = ThemeController::drawColoredPixmap(QIcon::fromTheme("window-close-symbolic").pixmap(20,20),red); painter->setRenderHint(QPainter::Antialiasing); painter->drawPixmap(pixRect,pixmap); break; } default: break; } } } void KProgressCirclePrivate::calculateCircleRect() { Q_Q(KProgressCircle); m_baseRect.setTop(1+m_cirleWidth/2); m_baseRect.setLeft(1+m_cirleWidth/2); m_baseRect.setBottom(q->rect().height()-1-m_cirleWidth/2); m_baseRect.setRight(q->rect().right()-1-m_cirleWidth/2); m_contentRect.setTop(1+m_cirleWidth*2); m_contentRect.setLeft(1+m_cirleWidth*2); m_contentRect.setBottom(q->rect().height()-1-m_cirleWidth*2); m_contentRect.setRight(q->rect().right()-1-m_cirleWidth*2); } void KProgressCirclePrivate::changeTheme() { Q_Q(KProgressCircle); initThemeStyle(); if(ThemeController::themeMode() == LightTheme) { m_baseColor = QColor("#E6E6E6"); m_baseCircleColor = QColor("#BFBFBF"); } else { m_baseColor = QColor("#37373B"); m_baseCircleColor = QColor("#232426"); } q->update(); } } #include "kprogresscircle.moc" #include "moc_kprogresscircle.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kitemwidget.h0000664000175000017500000000352614474244170023547 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KITEMWIDGET_H #define KITEMWIDGET_H #include #include #include #include #include #include #include #include #include #include #include #include "gui_g.h" #include "themeController.h" namespace kdk { class KItemWidgetPrivate; class GUI_EXPORT KItemWidget :public QWidget { Q_OBJECT public: /* * Myicon 需要显示的图片 * MmainText 需要写入的miantext * MsecText 需要写入的sectext */ KItemWidget(const QIcon &Myicon,QString MmainText,QString MsecText,QWidget *parent); /* * 设置反白效果 */ void SetInverse(); /* * 取消反白效果 */ void CancelInverse(); /* * 设置图片大小 */ void SetIconSize(QSize size); protected: void paintEvent(QPaintEvent *event); /*void mousePressEvent(QMouseEvent *event);*/ private: Q_DECLARE_PRIVATE(KItemWidget); KItemWidgetPrivate* const d_ptr; }; } #endif // KITEMWIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ksecuritylevelbar.h0000664000175000017500000000341014474244170024761 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KSECURITYLEVELBAR_H #define KSECURITYLEVELBAR_H #include "gui_g.h" #include namespace kdk { /** @defgroup 消息提示模块 * @{ */ /** * @brief 分为三个安全等级 */ enum SecurityLevel { Low, Medium, High }; class KSecurityLevelBarPrivate; /** * @brief 密码安全等级提示条,支持三个安全等级 */ class GUI_EXPORT KSecurityLevelBar : public QWidget { Q_OBJECT public: explicit KSecurityLevelBar(QWidget *parent = nullptr); /** * @brief 设置安全等级 * @param level */ void setSecurityLevel(SecurityLevel level); /** * @brief 获取安全等级 * @return */ SecurityLevel securityLevel(); protected: void paintEvent(QPaintEvent* event); private: Q_DECLARE_PRIVATE(KSecurityLevelBar) KSecurityLevelBarPrivate*const d_ptr; }; } /** * @example testsecuritylevelbar/widget.h * @example testsecuritylevelbar/widget.cpp * @} */ #endif // KSECURITYLEVELBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/xatom-helper.h0000664000175000017500000000630314474244076023640 0ustar adminadmin/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan */ #ifndef XATOMHELPER_H #define XATOMHELPER_H #include #include //#include struct UnityCorners { ulong topLeft = 0; ulong topRight = 0; ulong bottomLeft = 0; ulong bottomRight = 0; }; typedef struct { ulong flags = 0; ulong functions = 0; ulong decorations = 0; long input_mode = 0; ulong status = 0; } MotifWmHints, MwmHints; #define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_INPUT_MODE (1L << 2) #define MWM_HINTS_STATUS (1L << 3) #define MWM_FUNC_ALL (1L << 0) #define MWM_FUNC_RESIZE (1L << 1) #define MWM_FUNC_MOVE (1L << 2) #define MWM_FUNC_MINIMIZE (1L << 3) #define MWM_FUNC_MAXIMIZE (1L << 4) #define MWM_FUNC_CLOSE (1L << 5) #define MWM_DECOR_ALL (1L << 0) #define MWM_DECOR_BORDER (1L << 1) #define MWM_DECOR_RESIZEH (1L << 2) #define MWM_DECOR_TITLE (1L << 3) #define MWM_DECOR_MENU (1L << 4) #define MWM_DECOR_MINIMIZE (1L << 5) #define MWM_DECOR_MAXIMIZE (1L << 6) #define MWM_INPUT_MODELESS 0 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 #define MWM_INPUT_SYSTEM_MODAL 2 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL #define MWM_TEAROFF_WINDOW (1L<<0) namespace kdk { class Decoration; class XAtomHelper : public QObject { // friend class UKUI::Decoration; Q_OBJECT public: static XAtomHelper *getInstance(); static bool isFrameLessWindow(int winId); static bool isWindowDecorateBorderOnly(int winId); static bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint); bool isUKUICsdSupported(); bool isUKUIDecorationWindow(int winId); UnityCorners getWindowBorderRadius(int winId); void setWindowBorderRadius(int winId, const UnityCorners &data); void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight); void setUKUIDecoraiontHint(int winId, bool set = true); void setWindowMotifHint(int winId, const MotifWmHints &hints); MotifWmHints getWindowMotifHint(int winId); private: explicit XAtomHelper(QObject *parent = nullptr); Atom registerUKUICsdNetWmSupportAtom(); void unregisterUKUICsdNetWmSupportAtom(); Atom m_motifWMHintsAtom = None; Atom m_unityBorderRadiusAtom = None; Atom m_ukuiDecorationAtion = None; }; } #endif // XATOMHELPER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ksecuritylevelbar.cpp0000664000175000017500000001130314474244170025314 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ksecuritylevelbar.h" #include #include #include #include namespace kdk { class KSecurityLevelBarPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KSecurityLevelBar) public: KSecurityLevelBarPrivate(KSecurityLevelBar* parent); private: KSecurityLevelBar* q_ptr; SecurityLevel m_level; QLabel* m_pLabel; int m_contentMargin = 5; int m_textWidth = 0; int m_space = 5; }; KSecurityLevelBar::KSecurityLevelBar(QWidget *parent) : QWidget(parent), d_ptr(new KSecurityLevelBarPrivate(this)) { Q_D(KSecurityLevelBar); setFixedSize(300,30); } void KSecurityLevelBar::setSecurityLevel(SecurityLevel level) { Q_D(KSecurityLevelBar); d->m_level = level; switch (level) { case Low: d->m_pLabel->setText(tr("Low")); break; case Medium: d->m_pLabel->setText(tr("Medium")); break; case High: d->m_pLabel->setText(tr("High")); break; default: break; } repaint(); } SecurityLevel KSecurityLevelBar::securityLevel() { Q_D(KSecurityLevelBar); return d->m_level; } void KSecurityLevelBar::paintEvent(QPaintEvent *event) { Q_D(KSecurityLevelBar); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); d->m_pLabel->adjustSize(); d->m_textWidth = this->fontMetrics().width(d->m_pLabel->text()) + d->m_space; int rectWitdth = (rect().width() - d->m_textWidth - d->m_contentMargin*2)/3 - d->m_space; int rectHeight = height() > 6 ? 6 : height(); int currentPos = d->m_contentMargin + d->m_textWidth + d->m_space; switch (d->m_level) { case Low: painter.setBrush(QColor(243,34,45)); painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.setBrush(this->palette().color(QPalette::Button)); painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); break; case Medium: painter.setBrush(QColor(249,197,61)); painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.setBrush(this->palette().color(QPalette::Button)); painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); break; case High: painter.setBrush(QColor(82,196,41)); painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); currentPos = currentPos + d->m_space + rectWitdth; painter.drawRoundedRect(currentPos,(rect().height()-rectHeight)/2,rectWitdth,rectHeight,rectHeight,rectHeight); break; default: break; } } KSecurityLevelBarPrivate::KSecurityLevelBarPrivate(KSecurityLevelBar *parent) :q_ptr(parent) { Q_Q(KSecurityLevelBar); m_pLabel = new QLabel(q); m_pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter); m_pLabel->setGeometry(q->rect().top(),q->rect().left(),m_textWidth,q->rect().height()); m_level = Low; m_pLabel->setText(tr("Low")); setParent(parent); } } #include "ksecuritylevelbar.moc" #include "moc_ksecuritylevelbar.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpushbutton.cpp0000664000175000017500000003112514474244170024147 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Xiangwei Liu * */ #include "kpushbutton.h" #include "themeController.h" #include #include #include #include #include namespace kdk { class KPushButtonPrivate:public QObject,public ThemeController { Q_DECLARE_PUBLIC(KPushButton) Q_OBJECT public: KPushButtonPrivate(KPushButton *parent):q_ptr(parent) {setParent(parent);} void changeTheme(); private: KPushButton* q_ptr; int m_radius; int m_bottomLeft; int m_topLeft; int m_topRight; int m_bottomRight; QColor m_backgroundColor; bool m_useCustomColor; bool m_hasOneParam; bool m_isTranslucent; bool m_isIconHighlight; QColor m_iconColor; bool m_useCustomIconColor; bool m_isBackgroundColorHighlight; KPushButton::ButtonType m_buttonType; }; KPushButton::KPushButton(QWidget *parent):QPushButton(parent),d_ptr(new KPushButtonPrivate(this)) { Q_D(KPushButton); d->m_radius = 6; d->m_bottomLeft = 6; d->m_topLeft = 6; d->m_topRight = 6; d->m_bottomRight = 6; d->m_backgroundColor = palette().color(QPalette::Button); d->m_useCustomColor = false; d->m_hasOneParam = true; d->m_buttonType = NormalType; d->m_isTranslucent = false; d->m_isIconHighlight = false; d->m_iconColor = palette().color(QPalette::ButtonText); d->m_useCustomIconColor = false; d->m_isBackgroundColorHighlight = false; connect(d->m_gsetting,&QGSettings::changed, d,&KPushButtonPrivate::changeTheme); } KPushButton::~KPushButton() { } void KPushButton::setBorderRadius(int radius) { Q_D(KPushButton); d->m_hasOneParam = true; d->m_radius = radius; update(); } void KPushButton::setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight) { Q_D(KPushButton); d->m_hasOneParam = false; d->m_bottomLeft = bottomLeft; d->m_topLeft = topLeft; d->m_topRight = topRight; d->m_bottomRight = bottomRight; update(); } int KPushButton::borderRadius() { Q_D(KPushButton); return d->m_radius; } void KPushButton::setBackgroundColor(QColor color) { Q_D(KPushButton); if(d->m_isBackgroundColorHighlight) d->m_isBackgroundColorHighlight = false; d->m_useCustomColor = true; d->m_backgroundColor = color; update(); } QColor KPushButton::backgroundColor() { Q_D(KPushButton); return d->m_backgroundColor; } void KPushButton::setButtonType(ButtonType type) { Q_D(KPushButton); d->m_buttonType = type; } KPushButton::ButtonType KPushButton::buttonType() { Q_D(KPushButton); return d->m_buttonType; } void KPushButton::setTranslucent(bool flag) { Q_D(KPushButton); d->m_isTranslucent = flag; } bool KPushButton::isTranslucent() { Q_D(KPushButton); return d->m_isTranslucent; } void KPushButton::setIconHighlight(bool flag) { Q_D(KPushButton); d->m_isIconHighlight = flag; } bool KPushButton::isIconHighlight() { Q_D(KPushButton); return d->m_isIconHighlight; } void KPushButton::setIconColor(QColor color) { Q_D(KPushButton); d->m_useCustomIconColor = true; d->m_iconColor = color; update(); } QColor KPushButton::IconColor() { Q_D(KPushButton); return d->m_iconColor; } void KPushButton::setBackgroundColorHighlight(bool flag) { Q_D(KPushButton); if(d->m_useCustomColor) d->m_useCustomColor = false; d->m_isBackgroundColorHighlight = flag; } bool KPushButton::isBackgroundColorHighlight() { Q_D(KPushButton); return d->m_isBackgroundColorHighlight; } bool KPushButton::eventFilter(QObject *watched, QEvent *event) { Q_D(KPushButton); return QPushButton::eventFilter(watched,event); } void KPushButton::paintEvent(QPaintEvent *event) { Q_D(KPushButton); QStyleOptionButton option; initStyleOption(&option); QPainter p(this); QColor fontColor = option.palette.buttonText().color(); QColor mix = option.palette.brightText().color(); QColor highlight = option.palette.highlight().color(); QColor backgroundColor; if(d->m_isTranslucent){ /*判断使用用户设置的背景色、跟随系统高亮色或是使用默认的背景色*/ if(d->m_useCustomColor){ backgroundColor = d->m_backgroundColor; }else if(d->m_isBackgroundColorHighlight){ backgroundColor = highlight; }else{ backgroundColor = option.palette.brightText().color(); } if(ThemeController::themeMode() == LightTheme){ /*按钮处于不可用(Disabled)状态*/ if(!option.state.testFlag(QStyle::State_Enabled)) { fontColor = option.palette.color(QPalette::Disabled,QPalette::ButtonText); backgroundColor.setAlphaF(0.1); } else{ /*按钮处于可用(Enabled)状态*/ if(option.state.testFlag(QStyle::State_MouseOver)) /*鼠标在按钮上(hover状态)*/ { if(option.state.testFlag(QStyle::State_Sunken)) /*按钮被选中(clicked)*/ backgroundColor.setAlphaF(0.21); else backgroundColor.setAlphaF(0.16); } else{ backgroundColor.setAlphaF(0.1); } } } else{ /*按钮处于不可用(Disabled)状态*/ if(!option.state.testFlag(QStyle::State_Enabled)) { fontColor = option.palette.color(QPalette::Disabled,QPalette::ButtonText); backgroundColor.setAlphaF(0.1); } else { /*按钮处于可用(Enabled)状态*/ if(option.state.testFlag(QStyle::State_MouseOver)) /*鼠标在按钮上(hover状态)*/ { if(option.state.testFlag(QStyle::State_Sunken)) /*按钮被选中(clicked)*/ backgroundColor.setAlphaF(0.3); else backgroundColor.setAlphaF(0.2); } else{ backgroundColor.setAlphaF(0.1); } } } } else{ /*判断使用用户设置的背景色或是使用默认的背景色*/ if(d->m_useCustomColor){ backgroundColor = d->m_backgroundColor; }else if(d->m_isBackgroundColorHighlight){ backgroundColor = highlight; }else{ backgroundColor = palette().color(QPalette::Button); } /*按钮处于不可用(Disabled)状态*/ if(!option.state.testFlag(QStyle::State_Enabled)) { fontColor = option.palette.color(QPalette::Disabled,QPalette::ButtonText); } else { if(d->m_useCustomColor || d->m_isBackgroundColorHighlight){ if(option.state.testFlag(QStyle::State_MouseOver)) /*鼠标在按钮上(hover状态)*/ { if(option.state.testFlag(QStyle::State_Sunken)) /*按钮被选中(clicked)*/ backgroundColor = ThemeController::mixColor(backgroundColor,mix,0.2); else backgroundColor = ThemeController::mixColor(backgroundColor,mix,0.05); fontColor = option.palette.color(QPalette::HighlightedText); } } else{ /*按钮处于可用(Enabled)状态*/ if(option.state.testFlag(QStyle::State_MouseOver)) /*鼠标在按钮上(hover状态)*/ { if(option.state.testFlag(QStyle::State_Sunken)) /*按钮被选中(clicked)*/ backgroundColor = ThemeController::mixColor(highlight,mix,0.2); else backgroundColor = ThemeController::mixColor(highlight,mix,0.05); fontColor = option.palette.color(QPalette::HighlightedText); } else { backgroundColor = palette().color(QPalette::Button); } } } if(isChecked()) backgroundColor = highlight; } 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) { case NormalType: { if(d->m_hasOneParam) { p.drawRoundedRect(option.rect.adjusted(0,0,-1,-1),d->m_radius,d->m_radius); } else { QPainterPath path; path.moveTo(option.rect.topLeft() + QPointF(0,d->m_topLeft)); path.lineTo(option.rect.bottomLeft() - QPointF(0,d->m_bottomLeft)); path.quadTo(option.rect.bottomLeft(),option.rect.bottomLeft() + QPointF(d->m_bottomLeft,0)); path.lineTo(option.rect.bottomRight() - QPointF(d->m_bottomRight,0)); path.quadTo(option.rect.bottomRight(),option.rect.bottomRight() - QPointF(0,d->m_bottomRight)); path.lineTo(option.rect.topRight() + QPointF(0,d->m_topRight)); path.quadTo(option.rect.topRight(),option.rect.topRight() - QPointF(d->m_topRight,0)); path.lineTo(option.rect.topLeft() + QPointF(d->m_topLeft,0)); path.quadTo(option.rect.topLeft(),option.rect.topLeft() + QPointF(0,d->m_topLeft)); p.drawPath(path); } p.restore(); break; } case CircleType: p.drawEllipse(option.rect.adjusted(0,0,-1,-1)); p.restore(); break; default: break; } /*绘制图标和文字*/ QPen pen; pen.setColor(fontColor); p.setBrush(Qt::NoBrush); p.setPen(pen); QPoint point; QRect ir = option.rect; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); if(d->m_isIconHighlight){ pixmap = ThemeController::drawColoredPixmap(this->icon().pixmap(iconSize()),highlight); }else if(d->m_useCustomIconColor){ pixmap = ThemeController::drawColoredPixmap(this->icon().pixmap(iconSize()),d->m_iconColor); }else{ pixmap = ThemeController::drawColoredPixmap(this->icon().pixmap(iconSize()),fontColor); } int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!option.text.isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, option.text).width() + 2; point = QPoint(ir.x() + ir.width() / 2 - w / 2, ir.y() + ir.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (option.direction == Qt::RightToLeft) ir.translate(-point.x() - 2, 0); else ir.translate(point.x() + w + 4, 0); // left-align text if there is if (!option.text.isEmpty()) tf |= Qt::AlignLeft; } else { tf |= Qt::AlignHCenter; } p.drawText(ir,tf,option.text); } void KPushButtonPrivate::changeTheme() { Q_Q(KPushButton); initThemeStyle(); } } #include "kpushbutton.moc" #include "moc_kpushbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcolorcombobox.h0000664000175000017500000000455714474244170024261 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KCOLORCOMBOBOX_H #define KCOLORCOMBOBOX_H #include #include #include #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& list); /** * @brief 获取颜色列表 * @return */ QList 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpushbutton.h0000664000175000017500000000723014474244170023614 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Xiangwei Liu * */ #ifndef KPUSHBUTTON_H #define KPUSHBUTTON_H #include "gui_g.h" #include #include namespace kdk { class KPushButtonPrivate; /** * @brief The KPushButton class since 1.2.0.10 * 1.提供半透明效果 * 2.可以设置按钮圆角、背景色、图标是否跟随系统高亮 * 3.可以设置按钮类型,分为正常类型和圆形(需要设置大小实现正圆),其余同QPushButton */ class GUI_EXPORT KPushButton:public QPushButton { Q_OBJECT public: enum ButtonType { NormalType, CircleType }; KPushButton(QWidget* parent = nullptr); ~KPushButton(); /** * @brief 设置按钮圆角 * 通过圆角半径设置按钮圆角(每个圆角相同) * @param radius */ void setBorderRadius(int radius); /** * @brief 设置按钮圆角 * 通过四个点来设置圆角 * @param bottomLeft(左下) * @param topLeft(左上) * @param topRight(右上) * @param bottomRight(右下) */ void setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight); /** * @brief 获取按钮圆角 * @return radius */ int borderRadius(); /** * @brief 设置按钮背景色 * @param color */ void setBackgroundColor(QColor color); /** * @brief 获取按钮背景色 * @return color */ QColor backgroundColor(); /** * @brief 设置KPushButton的类型 * @param type */ void setButtonType(ButtonType type); /** * @brief 获取KPushButton的类型 * @return */ ButtonType buttonType(); /** * @brief 设置KPushButton是否为半透明 * @param flag */ void setTranslucent(bool flag); /** * @brief 判断KPushButton是否为半透明 * @return */ bool isTranslucent(); /** * @brief 设置图标是否跟随系统高亮色,默认不跟随 * @param flag */ void setIconHighlight(bool flag); /** * @brief 判断图标是否跟随系统高亮色 * @return */ bool isIconHighlight(); /** * @brief 设置按钮添加图标的颜色 * @param color */ void setIconColor(QColor color); /** * @brief 获取按钮添加图标的颜色 * @return */ QColor IconColor(); /** * @brief 设置按钮背景色是否跟随系统高亮色,默认不跟随 * @param flag */ void setBackgroundColorHighlight(bool flag); /** * @brief 判断按钮背景色是否跟随系统高亮色 * @return */ bool isBackgroundColorHighlight(); protected: bool eventFilter(QObject *watched, QEvent *event); void paintEvent(QPaintEvent *event); private: Q_DECLARE_PRIVATE(KPushButton) KPushButtonPrivate * const d_ptr; }; } #endif // KPUSHBUTTON_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/knavigationbar.cpp0000664000175000017500000003531214474244170024562 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "knavigationbar.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "themeController.h" #include "parmscontroller.h" namespace kdk { enum ItemType { StandardItem = 0, SubItem, TagItem }; class Delegate:public QStyledItemDelegate,public ThemeController { public: Delegate(QObject*parent,QListView*view); protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: QListView *m_listView; }; class ListView : public QListView { public: ListView(QWidget*parent); protected: void mousePressEvent(QMouseEvent* event); }; class KNavigationBarPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KNavigationBar) public: KNavigationBarPrivate(KNavigationBar*parent); void changeTheme(); private: KNavigationBar* q_ptr; ListView* m_pView; QStandardItemModel* m_pModel; Delegate* m_pDelegate; }; KNavigationBar::KNavigationBar(QWidget* parent) :QScrollArea(parent), d_ptr(new KNavigationBarPrivate(this)) { Q_D(KNavigationBar); setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding); d->m_pView = new ListView (this); d->m_pModel = new QStandardItemModel(d->m_pView); d->m_pView->setModel(d->m_pModel); QVBoxLayout* vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(0,0,0,0); vLayout->setSpacing(0); vLayout->addWidget(d->m_pView); d->m_pView->setFocus(); QPalette p = this->palette(); QColor color(0,0,0,0); p.setColor(QPalette::Base,color); d->m_pView->setPalette(p); this->setPalette(p); d->m_pView->setFrameStyle(0); d->m_pDelegate = new Delegate(this,d->m_pView); d->m_pView->setItemDelegate(d->m_pDelegate); d->m_pView->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setFrameStyle(0); this->setBackgroundRole(QPalette::Base); this->setAutoFillBackground(true); 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) { Q_D(KNavigationBar); item->setData(ItemType::StandardItem,Qt::UserRole); d->m_pModel->appendRow(item); } void KNavigationBar::addSubItem(QStandardItem *subItem) { Q_D(KNavigationBar); subItem->setData(ItemType::SubItem,Qt::UserRole); QPixmap pix(24,24); pix.fill(Qt::transparent); QIcon icon(pix); subItem->setIcon(icon); d->m_pModel->appendRow(subItem); } void KNavigationBar::addGroupItems(QList items, const QString &tag) { Q_D(KNavigationBar); QStandardItem *item = new QStandardItem(tag); item->setEnabled(false); item->setData(ItemType::TagItem,Qt::UserRole); d->m_pModel->appendRow(item); for (auto item : items) { item->setData(ItemType::StandardItem,Qt::UserRole); d->m_pModel->appendRow(item); } } void KNavigationBar::addTag(const QString &tag) { Q_D(KNavigationBar); QStandardItem *item = new QStandardItem(tag); item->setEnabled(false); item->setData(ItemType::TagItem,Qt::UserRole); d->m_pModel->appendRow(item); } QStandardItemModel *KNavigationBar::model() { Q_D(KNavigationBar); return d->m_pModel; } QListView *KNavigationBar::listview() { Q_D(KNavigationBar); return d->m_pView; } KNavigationBarPrivate::KNavigationBarPrivate(KNavigationBar *parent) :q_ptr(parent) { setParent(parent); } void KNavigationBarPrivate::changeTheme() { Q_Q(KNavigationBar); m_pDelegate->initThemeStyle(); } Delegate::Delegate(QObject *parent, QListView *view) :QStyledItemDelegate(parent), m_listView(view) { } void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QLinearGradient m_linearGradient; QRectF rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()+1); rect.setWidth(option.rect.width()); // 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; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); path.lineTo(rect.bottomRight() - QPointF(radius, 0)); path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); 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)) { color=QColor("#FFB3B3B3"); } else if(((m_listView->currentIndex() == index) ||(option.state & QStyle::State_Selected)|| (option.state & QStyle::State_MouseOver)) && flag != 2) { if((m_listView->currentIndex() == index) ||(option.state & QStyle::State_Selected)) { color = option.palette.highlight().color(); // color = option.palette.windowText().color(); // color.setAlphaF(0.15); if(ThemeController::themeMode() == LightTheme) { m_linearGradient.setColorAt(0,color); m_linearGradient.setColorAt(1,color); } else { m_linearGradient.setColorAt(0,color); m_linearGradient.setColorAt(1,color); } } else { //hover时 if(ThemeController::widgetTheme() == FashionTheme) { if(ThemeController::themeMode() == LightTheme) { color = option.palette.windowText().color(); color.setAlphaF(0.05); QColor m_color("#E6E6E6"); QColor startColor = mixColor(m_color,QColor(Qt::black),0.05); QColor endLightColor = mixColor(m_color,QColor(Qt::black),0.2); m_linearGradient.setColorAt(0,startColor); m_linearGradient.setColorAt(1,endLightColor); } else { color = option.palette.windowText().color(); color.setAlphaF(0.05); QColor color("#373737"); QColor startColor = mixColor(color,QColor(Qt::white),0.2); QColor endLightColor = mixColor(color,QColor(Qt::white),0.05); m_linearGradient.setColorAt(0,startColor); m_linearGradient.setColorAt(1,endLightColor); } } else { color = option.palette.windowText().color(); color.setAlphaF(0.05); } } painter->save(); painter->setPen(QPen(Qt::NoPen)); if(ThemeController::widgetTheme() == FashionTheme ) { painter->setBrush(m_linearGradient); } else { painter->setBrush(color); } painter->drawPath(path); painter->restore(); } switch (flag) { case 0://standardItem { QRect iconRect=QRect(rect.x()+16,rect.y()+(rect.height()-16)/2,16,16); //图片大小16*16 左边距16 auto *model =dynamic_cast(const_cast(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)) icon = ThemeController::drawColoredPixmap(icon.pixmap(16,16),QColor(255,255,255)); if(!(option.state & QStyle::State_Enabled)) icon = ThemeController::drawColoredPixmap(icon.pixmap(16,16),QColor("#FF979797")); icon.paint(painter,iconRect); QFontMetrics fm = painter->fontMetrics(); QString elidedText = fm.elidedText(index.model()->data(index,Qt::DisplayRole).toString(),Qt::ElideRight,rect.width()-56); //左边距+图片宽度+文本图片间距+右边距 QString mainText = index.data(Qt::DisplayRole).toString(); if(fm.width(mainText) > rect.width()-56) model->item(index.row())->setToolTip(mainText); painter->save(); if((m_listView->currentIndex() == index)||(option.state & QStyle::State_Selected)) painter->setPen(option.palette.highlightedText().color()); QFont font; font.setPointSize(ThemeController::systemFontSize()); if(!(option.state & QStyle::State_Enabled)) { painter->setPen(color); } painter->setFont(font); if(!icon.isNull()){ painter->drawText(QRect(iconRect.right()+8,rect.y(), rect.width()-56,rect.height()),Qt::AlignVCenter,elidedText); //文本 图片间距8px } else { painter->drawText(QRect(rect.x()+16,rect.y(), rect.width()-56,rect.height()),Qt::AlignVCenter,elidedText); } painter->restore(); break; } case 1://subItem { QRect iconRect=QRect(rect.x()+16,rect.y()+(rect.height()-16)/2,16,16); //图片大小16*16 左边距16 auto *model =dynamic_cast(const_cast(index.model())); QFontMetrics fm = painter->fontMetrics(); QString elidedText = fm.elidedText(index.model()->data(index,Qt::DisplayRole).toString(),Qt::ElideRight,rect.width()-56); //左边距+图片宽度+文本图片间距+右边距 QString mainText = index.data(Qt::DisplayRole).toString(); if(fm.width(mainText) > rect.width()-56) model->item(index.row())->setToolTip(mainText); painter->save(); if(/*(option.state & QStyle::State_HasFocus) &&*/ (option.state & QStyle::State_Selected)) painter->setPen(option.palette.highlightedText().color()); QFont font; font.setPointSize(ThemeController::systemFontSize()); if(!(option.state & QStyle::State_Enabled)) { painter->setPen(color); } painter->setFont(font); painter->drawText(QRect(iconRect.right()+8,rect.y(), rect.width()-56,rect.height()),Qt::AlignVCenter,elidedText); //文本 图片间距8px painter->restore(); break; } case 2://tagItem { painter->save(); auto *model =dynamic_cast(const_cast(index.model())); QFontMetrics fm = painter->fontMetrics(); QString elidedText = fm.elidedText(index.model()->data(index,Qt::DisplayRole).toString(),Qt::ElideRight,rect.width()-56); //左边距+图片宽度+文本图片间距+右边距 QString mainText = index.data(Qt::DisplayRole).toString(); if(fm.width(mainText) > rect.width()-56) model->item(index.row())->setToolTip(mainText); if(ThemeController::themeMode() == ThemeFlag::DarkTheme) painter->setPen(QColor(115,115,115)); else painter->setPen(QColor(140,140,140)); QRect textRect = option.rect; textRect = textRect.adjusted(16,12,0,0); QFont font; font.setPointSize(ThemeController::systemFontSize()); painter->setFont(font); painter->drawText(textRect,Qt::AlignVCenter,elidedText); painter->restore(); break; } default: break; } } QSize Delegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { int flag = index.model()->data(index,Qt::UserRole).toInt(); QSize size; switch (flag) { case 2://tagItem 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)); break; } size.setWidth(option.rect.width()); return size; } ListView::ListView(QWidget *parent) :QListView(parent) { } void ListView::mousePressEvent(QMouseEvent *event) { if(event->button() & Qt::RightButton) return ; else if(event->button() & Qt::LeftButton) QListView::mousePressEvent(event); } } #include "knavigationbar.moc"; #include "moc_knavigationbar.cpp"; libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kinputdialog.cpp0000664000175000017500000006773414474244170024272 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "qvalidator.h" #include "qevent.h" #include "kinputdialog.h" namespace kdk { enum CandidateSignal { TextValueSelectedSignal, IntValueSelectedSignal, DoubleValueSelectedSignal, NumCandidateSignals }; static const char *candidateSignal(int which) { switch (CandidateSignal(which)) { case TextValueSelectedSignal: return SIGNAL(textValueSelected(QString)); case IntValueSelectedSignal: return SIGNAL(intValueSelected(int)); case DoubleValueSelectedSignal: return SIGNAL(doubleValueSelected(double)); case NumCandidateSignals: break; }; Q_UNREACHABLE(); return nullptr; } static const char *signalForMember(const char *member) { QByteArray normalizedMember(QMetaObject::normalizedSignature(member)); for (int i = 0; i < NumCandidateSignals; ++i) if (QMetaObject::checkConnectArgs(candidateSignal(i), normalizedMember)) return candidateSignal(i); return SIGNAL(accepted()); } QT_BEGIN_NAMESPACE class KInputDialogSpinBox : public QSpinBox { Q_OBJECT public: KInputDialogSpinBox(QWidget *parent) : QSpinBox(parent) { connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged())); connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged())); } protected: QSize sizeHint() const; Q_SIGNALS: void textChanged(int); private Q_SLOTS: void notifyTextChanged() { Q_EMIT textChanged(hasAcceptableInput()?1:0); } private: void keyPressEvent(QKeyEvent *event) override { if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) { #ifndef QT_NO_PROPERTIES setProperty("value", property("value")); #endif } else { QSpinBox::keyPressEvent(event); } notifyTextChanged(); } void mousePressEvent(QMouseEvent *event) override { QSpinBox::mousePressEvent(event); notifyTextChanged(); } }; class KInputDialogDoubleSpinBox : public QDoubleSpinBox { Q_OBJECT public: KInputDialogDoubleSpinBox(QWidget *parent = nullptr) : QDoubleSpinBox(parent) { connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged())); connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged())); } protected: QSize sizeHint() const; Q_SIGNALS: void textChanged(int); private Q_SLOTS: void notifyTextChanged() { Q_EMIT textChanged(hasAcceptableInput()?1:0); } private: void keyPressEvent(QKeyEvent *event) override { if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) { #ifndef QT_NO_PROPERTIES setProperty("value", property("value")); #endif } else { QDoubleSpinBox::keyPressEvent(event); } notifyTextChanged(); } void mousePressEvent(QMouseEvent *event) override { QDoubleSpinBox::mousePressEvent(event); notifyTextChanged(); } }; class KInputDialogLineEdit :public QLineEdit { public: KInputDialogLineEdit(QWidget *parent = nullptr) : QLineEdit(parent){} protected: QSize sizeHint() const; }; 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 KInputDialogPrivate : public QObject { Q_DECLARE_PUBLIC(KInputDialog) public: KInputDialogPrivate(KInputDialog*parent); void ensureLayout(); void ensureLineEdit(); void ensurePlainTextEdit(); void ensureComboBox(); void ensureListView(); void ensureIntSpinBox(); void ensureDoubleSpinBox(); void ensureEnabledConnection(QAbstractSpinBox *spinBox); void setInputWidget(QWidget *widget); void chooseRightTextInputWidget(); void setComboBoxText(const QString &text); void setListViewText(const QString &text); QString listViewText() const; void ensureLayout() const { const_cast(this)->ensureLayout(); } bool useComboBoxOrListView() const { return comboBox && comboBox->count() > 0; } void _q_textChanged(const QString &text); void _q_plainTextEditTextChanged(); void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex); mutable QLabel *label; mutable QPushButton *okButton; mutable QPushButton *cancelButton; mutable KInputDialogLineEdit *lineEdit; mutable QPlainTextEdit *plainTextEdit; mutable QSpinBox *intSpinBox; mutable QDoubleSpinBox *doubleSpinBox; mutable QComboBox *comboBox; mutable KInputDialogListView *listView; mutable QWidget *inputWidget; mutable QVBoxLayout *mainLayout; KInputDialog::InputDialogOptions opts; QString textValue; QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; private: KInputDialog* q_ptr; }; 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) { Q_Q(KInputDialog); q->setMinimumHeight(198); q->setMinimumWidth(336); connect(q->m_gsetting,&QGSettings::changed,q,&KInputDialog::changeTheme); } void KInputDialogPrivate::ensureLayout() { Q_Q(KInputDialog); if (mainLayout) return; if (!inputWidget) { ensureLineEdit(); inputWidget = lineEdit; } if (!label) label = new QLabel(KInputDialog::tr("Enter a value:"), q); q->mainLayout()->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize); #ifndef QT_NO_SHORTCUT label->setBuddy(inputWidget); #endif label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); label->setWordWrap(true); 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(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(24,0,24,24); mainLayout->addWidget(label); mainLayout->addSpacing(8); mainLayout->addWidget(inputWidget); mainLayout->addSpacing(32); //mainLayout->addStretch(); mainLayout->addLayout(hLayout); q->mainWidget()->setLayout(mainLayout); q->changeTheme(); ensureEnabledConnection(qobject_cast(inputWidget)); inputWidget->show(); } 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))); } } void KInputDialogPrivate::ensurePlainTextEdit() { Q_Q(KInputDialog); if (!plainTextEdit) { plainTextEdit = new QPlainTextEdit(q); plainTextEdit->setLineWrapMode(QPlainTextEdit::NoWrap); plainTextEdit->hide(); QObject::connect(plainTextEdit, SIGNAL(textChanged()), q, SLOT(_q_plainTextEditTextChanged())); } } void KInputDialogPrivate::ensureComboBox() { Q_Q(KInputDialog); if (!comboBox) { comboBox = new QComboBox(q); comboBox->hide(); QObject::connect(comboBox, SIGNAL(editTextChanged(QString)), q, SLOT(_q_textChanged(QString))); QObject::connect(comboBox, SIGNAL(currentIndexChanged(QString)), q, SLOT(_q_textChanged(QString))); } } void KInputDialogPrivate::ensureListView() { Q_Q(KInputDialog); if (!listView) { ensureComboBox(); listView = new KInputDialogListView(q); listView->hide(); listView->setEditTriggers(QAbstractItemView::NoEditTriggers); listView->setSelectionMode(QAbstractItemView::SingleSelection); listView->setModel(comboBox->model()); listView->setCurrentIndex(QModelIndex()); QObject::connect(listView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), q, SLOT(_q_currentRowChanged(QModelIndex,QModelIndex))); } } void KInputDialogPrivate::ensureIntSpinBox() { Q_Q(KInputDialog); if (!intSpinBox) { intSpinBox = new KInputDialogSpinBox(q); intSpinBox->hide(); QObject::connect(intSpinBox, SIGNAL(valueChanged(int)), q, SIGNAL(intValueChanged(int))); } } void KInputDialogPrivate::ensureDoubleSpinBox() { Q_Q(KInputDialog); if (!doubleSpinBox) { doubleSpinBox = new KInputDialogDoubleSpinBox(q); doubleSpinBox->hide(); QObject::connect(doubleSpinBox, SIGNAL(valueChanged(double)), q, SIGNAL(doubleValueChanged(double))); } } void KInputDialogPrivate::ensureEnabledConnection(QAbstractSpinBox *spinBox) { if (spinBox) { QAbstractButton *okBtn = okButton; QObject::connect(spinBox, SIGNAL(textChanged(int)), okBtn, SLOT(setEnabled(bool)), Qt::UniqueConnection); } } void KInputDialogPrivate::setInputWidget(QWidget *widget) { Q_Q(KInputDialog); Q_ASSERT(widget); if (inputWidget == widget) return; if (mainLayout) { Q_ASSERT(inputWidget); mainLayout->removeWidget(inputWidget); inputWidget->hide(); mainLayout->insertWidget(1, widget); widget->show(); QAbstractButton *okBtn = okButton; if (QAbstractSpinBox *spinBox = qobject_cast(inputWidget)) QObject::disconnect(spinBox, SIGNAL(textChanged(int)), okBtn, SLOT(setEnabled(bool))); QAbstractSpinBox *spinBox = qobject_cast(widget); ensureEnabledConnection(spinBox); okButton->setEnabled(!spinBox || spinBox->hasAcceptableInput()); q->changeTheme(); } inputWidget = widget; if (widget == lineEdit) { lineEdit->setText(textValue); } else if (widget == plainTextEdit) { plainTextEdit->setPlainText(textValue); } else if (widget == comboBox) { setComboBoxText(textValue); } else if (widget == listView) { setListViewText(textValue); ensureLayout(); okButton->setEnabled(listView->selectionModel()->hasSelection()); } } void KInputDialogPrivate::chooseRightTextInputWidget() { QWidget *widget; if (useComboBoxOrListView()) { if ((opts & KInputDialog::UseListViewForComboBoxItems) && !comboBox->isEditable()) { ensureListView(); widget = listView; } else { widget = comboBox; } } else if (opts & KInputDialog::UsePlainTextEditForTextInput) { ensurePlainTextEdit(); widget = plainTextEdit; } else { ensureLineEdit(); widget = lineEdit; } setInputWidget(widget); if (inputWidget == comboBox) { _q_textChanged(comboBox->currentText()); } else if (inputWidget == listView) { _q_textChanged(listViewText()); } } void KInputDialogPrivate::setComboBoxText(const QString &text) { int index = comboBox->findText(text); if (index != -1) { comboBox->setCurrentIndex(index); } else if (comboBox->isEditable()) { comboBox->setEditText(text); } } void KInputDialogPrivate::setListViewText(const QString &text) { int row = comboBox->findText(text); if (row != -1) { QModelIndex index(comboBox->model()->index(row, 0)); listView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); } } QString KInputDialogPrivate::listViewText() const { if (listView->selectionModel()->hasSelection()) { int row = listView->selectionModel()->selectedRows().value(0).row(); return comboBox->itemText(row); } else { return QString(); } } void KInputDialogPrivate::_q_textChanged(const QString &text) { Q_Q(KInputDialog); if (textValue != text) { textValue = text; Q_EMIT q->textValueChanged(text); } } void KInputDialogPrivate::_q_plainTextEditTextChanged() { Q_Q(KInputDialog); QString text = plainTextEdit->toPlainText(); if (textValue != text) { textValue = text; Q_EMIT q->textValueChanged(text); } } void KInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex & /* oldIndex */) { _q_textChanged(comboBox->model()->data(newIndex).toString()); okButton->setEnabled(true); } KInputDialog::KInputDialog(QWidget *parent) : KDialog(parent),d_ptr(new KInputDialogPrivate(this)) { } KInputDialog::~KInputDialog() { } void KInputDialog::setInputMode(InputMode mode) { Q_D(KInputDialog); QWidget *widget; /* Warning: Some functions in KInputDialog rely on implementation details of the code below. Look for the comments that accompany the calls to setInputMode() throughout this file before you change the code below. */ switch (mode) { case IntInput: d->ensureIntSpinBox(); widget = d->intSpinBox; break; case DoubleInput: d->ensureDoubleSpinBox(); widget = d->doubleSpinBox; break; default: Q_ASSERT(mode == TextInput); d->chooseRightTextInputWidget(); return; } d->setInputWidget(widget); } KInputDialog::InputMode KInputDialog::inputMode() const { Q_D(const KInputDialog); if (d->inputWidget) { if (d->inputWidget == d->intSpinBox) { return IntInput; } else if (d->inputWidget == d->doubleSpinBox) { return DoubleInput; } } return TextInput; } void KInputDialog::setLabelText(const QString &text) { Q_D(KInputDialog); if (!d->label) { d->label = new QLabel(text, this); } else { d->label->setText(text); } } QString KInputDialog::labelText() const { Q_D(const KInputDialog); d->ensureLayout(); return d->label->text(); } void KInputDialog::setOption(InputDialogOption option, bool on) { Q_D(KInputDialog); if (!(d->opts & option) != !on) setOptions(d->opts ^ option); } bool KInputDialog::testOption(InputDialogOption option) const { Q_D(const KInputDialog); return (d->opts & option) != 0; } void KInputDialog::setOptions(InputDialogOptions options) { Q_D(KInputDialog); InputDialogOptions changed = (options ^ d->opts); if (!changed) return; d->opts = options; d->ensureLayout(); if (changed & NoButtons) { d->okButton->setVisible(!(options & NoButtons)); d->cancelButton->setVisible(!(options & NoButtons)); } if ((changed & UseListViewForComboBoxItems) && inputMode() == TextInput) d->chooseRightTextInputWidget(); if ((changed & UsePlainTextEditForTextInput) && inputMode() == TextInput) d->chooseRightTextInputWidget(); } KInputDialog::InputDialogOptions KInputDialog::options() const { Q_D(const KInputDialog); return d->opts; } void KInputDialog::setTextValue(const QString &text) { Q_D(KInputDialog); setInputMode(TextInput); if (d->inputWidget == d->lineEdit) { d->lineEdit->setText(text); } else if (d->inputWidget == d->plainTextEdit) { d->plainTextEdit->setPlainText(text); } else if (d->inputWidget == d->comboBox) { d->setComboBoxText(text); } else { d->setListViewText(text); } } QString KInputDialog::textValue() const { Q_D(const KInputDialog); return d->textValue; } void KInputDialog::setTextEchoMode(QLineEdit::EchoMode mode) { Q_D(KInputDialog); d->ensureLineEdit(); d->lineEdit->setEchoMode(mode); } QLineEdit::EchoMode KInputDialog::textEchoMode() const { Q_D(const KInputDialog); if (d->lineEdit) { return d->lineEdit->echoMode(); } else { return QLineEdit::Normal; } } void KInputDialog::setComboBoxEditable(bool editable) { Q_D(KInputDialog); d->ensureComboBox(); d->comboBox->setEditable(editable); if (inputMode() == TextInput) d->chooseRightTextInputWidget(); } bool KInputDialog::isComboBoxEditable() const { Q_D(const KInputDialog); if (d->comboBox) { return d->comboBox->isEditable(); } else { return false; } } void KInputDialog::setComboBoxItems(const QStringList &items) { Q_D(KInputDialog); d->ensureComboBox(); { const QSignalBlocker blocker(d->comboBox); d->comboBox->clear(); d->comboBox->addItems(items); } if (inputMode() == TextInput) d->chooseRightTextInputWidget(); } QStringList KInputDialog::comboBoxItems() const { Q_D(const KInputDialog); QStringList result; if (d->comboBox) { const int count = d->comboBox->count(); result.reserve(count); for (int i = 0; i < count; ++i) result.append(d->comboBox->itemText(i)); } return result; } void KInputDialog::setIntValue(int value) { Q_D(KInputDialog); setInputMode(IntInput); d->intSpinBox->setValue(value); } int KInputDialog::intValue() const { Q_D(const KInputDialog); if (d->intSpinBox) { return d->intSpinBox->value(); } else { return 0; } } void KInputDialog::setIntMinimum(int min) { Q_D(KInputDialog); d->ensureIntSpinBox(); d->intSpinBox->setMinimum(min); } int KInputDialog::intMinimum() const { Q_D(const KInputDialog); if (d->intSpinBox) { return d->intSpinBox->minimum(); } else { return 0; } } void KInputDialog::setIntMaximum(int max) { Q_D(KInputDialog); d->ensureIntSpinBox(); d->intSpinBox->setMaximum(max); } int KInputDialog::intMaximum() const { Q_D(const KInputDialog); if (d->intSpinBox) { return d->intSpinBox->maximum(); } else { return 99; } } void KInputDialog::setIntRange(int min, int max) { Q_D(KInputDialog); d->ensureIntSpinBox(); d->intSpinBox->setRange(min, max); } void KInputDialog::setIntStep(int step) { Q_D(KInputDialog); d->ensureIntSpinBox(); d->intSpinBox->setSingleStep(step); } int KInputDialog::intStep() const { Q_D(const KInputDialog); if (d->intSpinBox) { return d->intSpinBox->singleStep(); } else { return 1; } } void KInputDialog::setDoubleValue(double value) { Q_D(KInputDialog); setInputMode(DoubleInput); d->doubleSpinBox->setValue(value); } double KInputDialog::doubleValue() const { Q_D(const KInputDialog); if (d->doubleSpinBox) { return d->doubleSpinBox->value(); } else { return 0.0; } } void KInputDialog::setDoubleMinimum(double min) { Q_D(KInputDialog); d->ensureDoubleSpinBox(); d->doubleSpinBox->setMinimum(min); } double KInputDialog::doubleMinimum() const { Q_D(const KInputDialog); if (d->doubleSpinBox) { return d->doubleSpinBox->minimum(); } else { return 0.0; } } void KInputDialog::setDoubleMaximum(double max) { Q_D(KInputDialog); d->ensureDoubleSpinBox(); d->doubleSpinBox->setMaximum(max); } double KInputDialog::doubleMaximum() const { Q_D(const KInputDialog); if (d->doubleSpinBox) { return d->doubleSpinBox->maximum(); } else { return 99.99; } } void KInputDialog::setDoubleRange(double min, double max) { Q_D(KInputDialog); d->ensureDoubleSpinBox(); d->doubleSpinBox->setRange(min, max); } void KInputDialog::setDoubleDecimals(int decimals) { Q_D(KInputDialog); d->ensureDoubleSpinBox(); d->doubleSpinBox->setDecimals(decimals); } int KInputDialog::doubleDecimals() const { Q_D(const KInputDialog); if (d->doubleSpinBox) { return d->doubleSpinBox->decimals(); } else { return 2; } } void KInputDialog::setOkButtonText(const QString &text) { Q_D(const KInputDialog); d->ensureLayout(); d->okButton->setText(text); } QString KInputDialog::okButtonText() const { Q_D(const KInputDialog); d->ensureLayout(); return d->okButton->text(); } void KInputDialog::setCancelButtonText(const QString &text) { Q_D(const KInputDialog); d->ensureLayout(); d->cancelButton->setText(text); } QString KInputDialog::cancelButtonText() const { Q_D(const KInputDialog); d->ensureLayout(); return d->cancelButton->text(); } void KInputDialog::open(QObject *receiver, const char *member) { Q_D(KInputDialog); connect(this, signalForMember(member), receiver, member); d->receiverToDisconnectOnClose = receiver; d->memberToDisconnectOnClose = member; QDialog::open(); } QSize KInputDialog::minimumSizeHint() const { Q_D(const KInputDialog); d->ensureLayout(); return QDialog::minimumSizeHint(); } QSize KInputDialog::sizeHint() const { Q_D(const KInputDialog); d->ensureLayout(); return QDialog::sizeHint(); } void KInputDialog::setVisible(bool visible) { Q_D(const KInputDialog); if (visible) { d->ensureLayout(); d->inputWidget->setFocus(); if (d->inputWidget == d->lineEdit) { d->lineEdit->selectAll(); } else if (d->inputWidget == d->plainTextEdit) { d->plainTextEdit->selectAll(); } else if (d->inputWidget == d->intSpinBox) { d->intSpinBox->selectAll(); } else if (d->inputWidget == d->doubleSpinBox) { d->doubleSpinBox->selectAll(); } } QDialog::setVisible(visible); } QString KInputDialog::placeholderText() const { Q_D(const KInputDialog); if(d->lineEdit) return d->lineEdit->placeholderText(); else return QString(); } void KInputDialog::setPlaceholderText(const QString &str) { Q_D(const KInputDialog); if(d->lineEdit) d->lineEdit->setPlaceholderText(str); } void KInputDialog::done(int result) { Q_D(KInputDialog); QDialog::done(result); if (result) { InputMode mode = inputMode(); switch (mode) { case DoubleInput: Q_EMIT doubleValueSelected(doubleValue()); break; case IntInput: Q_EMIT intValueSelected(intValue()); break; default: Q_ASSERT(mode == TextInput); Q_EMIT textValueSelected(textValue()); } } if (d->receiverToDisconnectOnClose) { disconnect(this, signalForMember(d->memberToDisconnectOnClose), d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); } void KInputDialog::changeTheme() { Q_D(KInputDialog); KDialog::changeTheme(); if(d->okButton) d->okButton->setProperty("isImportant",true); } QString KInputDialog::getText(QWidget *parent,const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { KInputDialog* dialog = new KInputDialog(parent); dialog->setLabelText(label); dialog->setTextValue(text); dialog->setTextEchoMode(mode); dialog->setInputMethodHints(inputMethodHints); const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { return dialog->textValue(); } else { return QString(); } } QString KInputDialog::getMultiLineText(QWidget *parent,const QString &label, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { KInputDialog* dialog = new KInputDialog(parent); dialog->setOptions(KInputDialog::UsePlainTextEditForTextInput); dialog->setLabelText(label); dialog->setTextValue(text); dialog->setInputMethodHints(inputMethodHints); const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { return dialog->textValue(); } else { return QString(); } } int KInputDialog::getInt(QWidget *parent,const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags) { KInputDialog* dialog = new KInputDialog(parent); dialog->setLabelText(label); dialog->setIntRange(min, max); dialog->setIntValue(value); dialog->setIntStep(step); const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { return dialog->intValue(); } else { return value; } } double KInputDialog::getDouble(QWidget *parent,const QString &label, double value, double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags) { KInputDialog* dialog = new KInputDialog(parent); dialog->setLabelText(label); dialog->setDoubleDecimals(decimals); dialog->setDoubleRange(minValue, maxValue); dialog->setDoubleValue(value); const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { return dialog->doubleValue(); } else { return value; } } QString KInputDialog::getItem(QWidget *parent,const QString &label, const QStringList &items, int current, bool editable, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { QString text(items.value(current)); KInputDialog* dialog = new KInputDialog(parent); dialog->setLabelText(label); dialog->setComboBoxItems(items); dialog->setTextValue(text); dialog->setComboBoxEditable(editable); dialog->setInputMethodHints(inputMethodHints); const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { return dialog->textValue(); } else { return text; } } void KInputDialog::setDoubleStep(double step) { Q_D(KInputDialog); d->ensureDoubleSpinBox(); d->doubleSpinBox->setSingleStep(step); } double KInputDialog::doubleStep() const { Q_D(const KInputDialog); if (d->doubleSpinBox) return d->doubleSpinBox->singleStep(); else return 1.0; } QSize KInputDialogSpinBox::sizeHint() const { QSize size; size.setWidth(288); size.setHeight(36); return size; } QSize KInputDialogLineEdit::sizeHint() const { QSize size; size.setWidth(288); size.setHeight(36); return size; } QSize KInputDialogDoubleSpinBox::sizeHint() const { QSize size; size.setWidth(288); size.setHeight(36); return size; } } #include "kinputdialog.moc" #include "moc_kinputdialog.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kslider.cpp0000664000175000017500000006133414474244170023223 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kslider.h" #include "themeController.h" #include #include #include #include #include #include #include #include #include #include #include "parmscontroller.h" using namespace kdk; namespace kdk { static const int node_radius = 5; 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; class KSliderPrivate :public QObject,public ThemeController { Q_DECLARE_PUBLIC(KSlider) public: KSliderPrivate(KSlider*parent); ~KSliderPrivate(); private: KSlider* q_ptr; KSliderType m_sliderType; void drawCoverNode(QPainter*painter); void drawSlider(QPainter*painter); void locateNode(); void drawBasePath(QPainter*painter); void drawCoverLine(QPainter*painter); void updateValuePosition(); void updateValue(); void updateColor(QPalette palette); void changeTheme(); QRect baseLineRect(); QRect coverLineRect(); QListm_nodes; bool m_isPressed; bool m_isHovered; int m_valuePosition; QPoint m_currentpos; QColor m_baseColor; QColor m_coverColor; QColor m_startColor; QColor m_endColor; bool m_nodeVisible; QRect m_rect; QString m_pToolTipText; QLinearGradient m_linearGradient; bool m_isTranslucent; int m_handleRadius; QVariantAnimation *m_animation; bool m_animationStarted; bool m_ismoving; bool m_resize; bool isInit; }; KSliderPrivate::KSliderPrivate(KSlider *parent) :q_ptr(parent), m_sliderType(SmoothSlider), m_isPressed(false), m_isHovered(false), m_valuePosition(0), m_currentpos(QPoint(0,0)), m_nodeVisible(true), m_handleRadius(0), m_animationStarted(false), m_ismoving(false), m_resize(false), isInit(true) { Q_Q(KSlider); QStyleOptionSlider sliderOption; m_animation = new QVariantAnimation(this); m_animation->setDuration(150); m_animation->setEasingCurve(QEasingCurve::InOutQuad); connect(m_animation, &QVariantAnimation::finished, q, [=](){ m_animationStarted = false; }); connect(m_animation, &QVariantAnimation::valueChanged, q, [=](){ q->update(); }); //获取滑动块大小 QRect handle = q->style()->proxy()->subControlRect(QStyle::CC_Slider, &sliderOption, QStyle::SC_SliderHandle, q); m_handleRadius =handle.width()/2; } KSliderPrivate::~KSliderPrivate() { } void KSliderPrivate::drawCoverNode(QPainter*painter) { Q_Q(KSlider); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); painter->setBrush(q->palette().color(QPalette::Highlight)); int side = 0; if(q->orientation() == Qt::Horizontal) { for(auto point : m_nodes) { if(m_ismoving) side = m_currentpos.x(); else if(m_resize) side = m_valuePosition; else side = m_animation->currentValue().toInt(); if(point.x()<= side) painter->drawEllipse(point,Parmscontroller::parm(Parmscontroller::Parm::PM_SliderNodeRadius)/2,Parmscontroller::parm(Parmscontroller::Parm::PM_SliderNodeRadius)/2);//选中基点 } } else { for(auto point : m_nodes) { if(m_ismoving) side = m_currentpos.y(); else if(m_resize) side = m_valuePosition; else side = m_animation->currentValue().toInt(); if(point.y()>= side) painter->drawEllipse(point,Parmscontroller::parm(Parmscontroller::Parm::PM_SliderNodeRadius)/2,Parmscontroller::parm(Parmscontroller::Parm::PM_SliderNodeRadius)/2); } } } void KSliderPrivate::drawSlider(QPainter*painter) { Q_Q(KSlider); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); //填充颜色待定 if(ThemeController::widgetTheme() == FashionTheme && m_isHovered&&!m_isPressed && q->isEnabled()) { painter->setBrush(m_linearGradient); } else painter->setBrush(m_startColor); //获取滑动块大小 int handle_radius = Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)/2; QPoint point; if(q->orientation() == Qt::Horizontal) { int x = 0; if(m_ismoving) x = m_currentpos.x(); else if(m_resize) x = m_valuePosition; else x= m_animation->currentValue().toInt(); point = QPoint(x,q->height()/2); } else { int y = 0; if(m_ismoving) y = m_currentpos.y(); else if(m_resize) y = m_valuePosition; else y = m_animation->currentValue().toInt(); point = QPoint(q->width()/2,y); } painter->drawEllipse(point,handle_radius,handle_radius); m_rect=QRect(point.x()-handle_radius,point.y()-handle_radius,handle_radius*2,handle_radius*2); } void KSliderPrivate::locateNode() { Q_Q(KSlider); if(q->orientation() == Qt::Horizontal) { m_nodes.clear(); QPoint beginNode(baseLineRect().left(),q->height()/2); QPoint endNode(baseLineRect().right(),q->height()/2); m_nodes.append(beginNode); if(!q->tickInterval()) { m_nodes.append(endNode); return; } for(int i = q->minimum() + q->tickInterval();i < q->maximum();i += q->tickInterval()) { QPoint point; int x = baseLineRect().left()+baseLineRect().width()*(i-q->minimum())/(q->maximum()-q->minimum()); int y = q->height()/2; point.setX(x); point.setY(y); m_nodes.append(point); } m_nodes.append(endNode); } else { m_nodes.clear(); QPoint beginNode(q->width()/2,baseLineRect().bottom()); QPoint endNode(q->width()/2,baseLineRect().top()); m_nodes.append(beginNode); if(!q->tickInterval()) { m_nodes.append(endNode); return; } for(int i = q->minimum() + q->tickInterval();i < q->maximum();i += q->tickInterval()) { QPoint point; int x = q->width()/2; int y = baseLineRect().top() + baseLineRect().height()*(i-q->minimum())/(q->maximum()-q->minimum()); point.setX(x); point.setY(y); m_nodes.append(point); } m_nodes.append(endNode); } } void KSliderPrivate::drawBasePath(QPainter*painter) { Q_Q(KSlider); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); painter->setBrush(m_baseColor); QPainterPath basePath; basePath.addRoundedRect(this->baseLineRect(),line_border_radius,line_border_radius); if(m_nodeVisible) { for(auto point : m_nodes) { basePath.addEllipse(point,node_radius,node_radius); } } basePath.setFillRule(Qt::FillRule::WindingFill); painter->drawPath(basePath.simplified()); } void KSliderPrivate::drawCoverLine(QPainter*painter) { Q_Q(KSlider); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); painter->setBrush(m_coverColor); painter->drawRoundedRect(this->coverLineRect(),line_border_radius,line_border_radius); } void KSliderPrivate::updateValuePosition() { Q_Q(KSlider); int prePosition = m_valuePosition; if(q->orientation() == Qt::Horizontal) { m_valuePosition =this->baseLineRect().left() + this->baseLineRect().width()*(q->value()-q->minimum())/(q->maximum()-q->minimum()); } else { m_valuePosition =this->baseLineRect().top()+this->baseLineRect().height() -this->baseLineRect().height()*(q->value()-q->minimum())/(q->maximum()-q->minimum()); } if(!m_animationStarted && !m_ismoving) { if(isInit) { m_animation->stop(); m_animation->setStartValue(m_valuePosition); m_animation->setEndValue(m_valuePosition); m_animation->start(); m_animationStarted = true; m_resize = false; isInit=false; } else { m_animation->stop(); m_animation->setStartValue(prePosition); m_animation->setEndValue(m_valuePosition); m_animation->start(); m_animationStarted = true; m_resize = false; } } } void KSliderPrivate::updateValue() { Q_Q(KSlider); int dur = q->maximum() - q->minimum(); int pos,value; int step = q->singleStep(); int nodeInterval =q->tickInterval(); if(q->orientation() == Qt::Horizontal) { if(m_currentpos.x() > baseLineRect().right()) value = q->maximum(); else if(m_currentpos.x() < baseLineRect().left()) value = q->minimum(); pos = qRound(q->minimum()+dur*((double)m_currentpos.x()-baseLineRect().left())/baseLineRect().width()); int left = baseLineRect().left(); int width = baseLineRect().width(); switch (m_sliderType) { case SingleSelectSlider: case SmoothSlider: value = pos; break; case StepSlider: { int frontIndex = (pos-q->minimum()) / step; int backIndex = (pos-q->minimum()) / step + 1; if((m_currentpos.x()-left-frontIndex*step*width/dur) <(backIndex*step*width/dur - (m_currentpos.x()-left))) pos = frontIndex * step + q->minimum(); else pos = backIndex * step + q->minimum(); value = pos; } break; case NodeSlider: { int frontIndex = (pos-q->minimum()) / nodeInterval; int backIndex = (pos-q->minimum()) / nodeInterval + 1; if((m_currentpos.x()-left-frontIndex*nodeInterval*width/dur) <(backIndex*nodeInterval*width/dur - (m_currentpos.x()-left))) pos = frontIndex * nodeInterval + q->minimum(); else pos = backIndex * nodeInterval + q->minimum(); value = pos; } break; default: break; } } else { if(m_currentpos.y() < baseLineRect().top()) value = q->maximum(); else if(m_currentpos.y() > baseLineRect().bottom()) value = q->minimum(); pos = qRound(q->minimum()+dur*((double)q->height()-m_currentpos.y())/q->height()); int top = baseLineRect().top(); int height = baseLineRect().height(); switch (m_sliderType) { case SingleSelectSlider: case SmoothSlider: value = pos; break; case StepSlider: { int frontIndex = (pos-q->minimum()) / step + 1; int backIndex = (pos-q->minimum()) / step ; if((m_currentpos.y()-top - (height-frontIndex*step*height/dur))< ((height-backIndex*step*height/dur) - (m_currentpos.y()-top))) pos = frontIndex * step + q->minimum(); else pos = backIndex * step + q->minimum(); value = pos; } break; case NodeSlider: { int frontIndex = (pos-q->minimum()) / nodeInterval + 1; int backIndex = (pos-q->minimum()) / nodeInterval ; if((m_currentpos.y()-top - (height-frontIndex*nodeInterval*height/dur))< ((height-backIndex*nodeInterval*height/dur) - (m_currentpos.y()-top))) pos = frontIndex * nodeInterval + q->minimum(); else pos = backIndex * nodeInterval + q->minimum(); value = pos; } break; default: break; } } if(!m_ismoving) q->setValue(value); } void KSliderPrivate::updateColor(QPalette palette) { Q_Q(KSlider); QColor highlightColor = palette.color(QPalette::Highlight); QColor mix=q->palette().color(QPalette::BrightText); if(m_isTranslucent) { m_baseColor = palette.color(QPalette::BrightText); m_baseColor.setAlphaF(0.1); } else m_baseColor = palette.color(QPalette::Button); if(!q->isEnabled()) { m_coverColor = palette.color(QPalette::Disabled,QPalette::ButtonText); m_startColor = palette.color(QPalette::Disabled,QPalette::ButtonText); return; } if(ThemeController::themeMode() == LightTheme) { QColor whiteColor("#FFFFFF"); QColor darkColor("#000000"); m_coverColor = ThemeController::mixColor(highlightColor,mix,0.2); if(m_isPressed) { // m_coverColor = highlightColor.darker(120).darker(120); //取消lineRect三态 m_startColor = highlightColor.darker(120); return; } else if(m_isHovered) { // m_coverColor = highlightColor.darker(120);//取消lineRect三态 if(ThemeController::widgetTheme() == FashionTheme) { m_startColor = ThemeController::mixColor(highlightColor,whiteColor,0.2); m_endColor = ThemeController::mixColor(highlightColor,darkColor,0.05); m_linearGradient.setColorAt(0,m_startColor); m_linearGradient.setColorAt(1,m_endColor); } else m_startColor = highlightColor.darker(105); return; } else { // m_coverColor = highlightColor.darker(120);//取消lineRect三态 m_startColor = highlightColor; } } else { QColor whiteColor("#FFFFFF"); m_coverColor = ThemeController::mixColor(highlightColor,mix,0.05); if(m_isPressed) { // m_coverColor = highlightColor.lighter(120).lighter(120);//取消lineRect三态 m_startColor = ThemeController::mixColor(highlightColor,mix,0.1); return; } else if(m_isHovered) { // m_coverColor = highlightColor.lighter(120);//取消lineRect三态 if(ThemeController::widgetTheme() == FashionTheme) { m_startColor = ThemeController::mixColor(highlightColor,whiteColor,0.2); m_endColor = highlightColor; m_linearGradient.setColorAt(0,m_startColor); m_linearGradient.setColorAt(1,m_endColor); } else m_startColor = highlightColor.lighter(105); return; } else { // m_coverColor = highlightColor.lighter(120);//取消lineRect三态 m_startColor = highlightColor; } } } void KSliderPrivate::changeTheme() { Q_Q(KSlider); initThemeStyle(); } QRect KSliderPrivate::baseLineRect() { Q_Q(KSlider); QRect rect; if(q->orientation() == Qt::Horizontal) { rect.setBottom(q->height()/2 + line_width/2); rect.setTop(q->height()/2 - line_width/2); rect.setLeft(spaceing +Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)/2); rect.setRight(q->width() - spaceing -Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)/2); } else { 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); } return rect; } QRect KSliderPrivate::coverLineRect() { Q_Q(KSlider); QRect rect; if(q->orientation() == Qt::Horizontal) { rect.setBottom(q->height()/2 + line_width/2); rect.setTop(q->height()/2 - line_width/2); rect.setLeft(spaceing + Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)/2); if(m_ismoving) rect.setRight(m_currentpos.x()); else if(m_resize) rect.setRight(m_valuePosition); else rect.setRight(m_animation->currentValue().toInt()); } else { rect.setBottom(q->height() - spaceing -m_handleRadius); rect.setLeft(q->width()/2 - line_width/2); rect.setRight(q->width()/2 + line_width/2); if(m_ismoving) rect.setTop(m_currentpos.y()); else if(m_resize) rect.setTop(m_valuePosition); else rect.setTop(m_animation->currentValue().toInt()); } return rect; } KSlider::KSlider(QWidget *parent) :KSlider(Qt::Horizontal,parent) { } KSlider::KSlider(Qt::Orientation orientation, QWidget *parent) :QSlider(orientation,parent),d_ptr(new KSliderPrivate(this)) { Q_D(KSlider); d->changeTheme(); connect(d->m_gsetting,&QGSettings::changed, d,&KSliderPrivate::changeTheme); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); update(); }); installEventFilter(this); setFocusPolicy(Qt::ClickFocus); } void KSlider::setTickInterval(int interval) { QSlider::setTickInterval(interval); update(); } void KSlider::setSliderType(KSliderType type) { Q_D(KSlider); d->m_sliderType = type; if(!tickInterval() && type == KSliderType::NodeSlider) setTickInterval(10); if(!singleStep() && type == KSliderType::StepSlider) setSingleStep(10); if(type == KSliderType::SingleSelectSlider) { setTickInterval(1); setSingleStep(1); setRange(0,2); } } KSliderType KSlider::sliderType() { Q_D(KSlider); return d->m_sliderType; } int KSlider::tickInterval() const { return QSlider::tickInterval(); } void KSlider::setValue(int value) { Q_D(KSlider); QSlider::setValue(value); update(); } void KSlider::setNodeVisible(bool flag) { Q_D(KSlider); if(d->m_nodeVisible != flag) { d->m_nodeVisible = flag; repaint(); } } bool KSlider::nodeVisible() { Q_D(KSlider); return d->m_nodeVisible; } void KSlider::setToolTip(const QString &str) { Q_D(KSlider); d->m_pToolTipText = str; } QString KSlider::toolTip() const { Q_D(const KSlider); return d->m_pToolTipText; } void KSlider::setTranslucent(bool flag) { Q_D(KSlider); d->m_isTranslucent = flag; } bool KSlider::isTranslucent() { Q_D(KSlider); return d->m_isTranslucent; } void KSlider::paintEvent(QPaintEvent *event) { Q_D(KSlider); if(orientation() == Qt::Horizontal) { for(auto point : d->m_nodes) { if(point.x()<= d->m_valuePosition) d->m_linearGradient=QLinearGradient(point.x(),point.y()-node_radius,point.x(),point.y()+node_radius); } } else { for(auto point : d->m_nodes) { if(point.y()>= d->m_valuePosition) d->m_linearGradient = QLinearGradient(point.x(),point.y()-node_radius,point.x(),point.y()+node_radius); } } d->updateColor(palette()); d->locateNode(); d->updateValuePosition(); QPainter p(this); d->drawBasePath(&p); if(d->m_sliderType != SingleSelectSlider) d->drawCoverLine(&p); if(d->m_nodeVisible) { if(d->m_sliderType != SingleSelectSlider) d->drawCoverNode(&p); } d->drawSlider(&p); } void KSlider::resizeEvent(QResizeEvent *event) { Q_D(KSlider); d->m_resize = true; QSlider::resizeEvent(event); } void KSlider::mousePressEvent(QMouseEvent *event) { Q_D(KSlider); if(event->button() == Qt::LeftButton) { d->m_currentpos = event->pos(); d->m_isPressed = true; d->updateColor(palette()); d->updateValue(); update(); } } void KSlider::mouseReleaseEvent(QMouseEvent *event) { Q_D(KSlider); if(event->button() == Qt::LeftButton) { if(orientation() == Qt::Horizontal) { if( event->pos().x() >= d->baseLineRect().left() && event->pos().x() <= d->baseLineRect().adjusted(0,0,1,0).right() ) d->m_currentpos = event->pos(); else if( event->pos().x() < d->baseLineRect().left() ) d->m_currentpos.setX(d->baseLineRect().left()); else if( event->pos().x() > d->baseLineRect().adjusted(0,0,1,0).right() ) d->m_currentpos.setX(d->baseLineRect().adjusted(0,0,1,0).right()); } else { if( event->pos().y() >= d->baseLineRect().top() && event->pos().y() <= d->baseLineRect().adjusted(0,0,0,1).bottom() ) d->m_currentpos = event->pos(); else if( event->pos().y() > d->baseLineRect().adjusted(0,0,0,1).bottom() ) d->m_currentpos.setY(d->baseLineRect().adjusted(0,0,0,1).bottom()); else if( event->pos().y() < d->baseLineRect().top() ) d->m_currentpos.setY(d->baseLineRect().top()); } if(d->m_ismoving) { if(orientation() == Qt::Horizontal) d->m_valuePosition = d->m_currentpos.x(); else d->m_valuePosition = d->m_currentpos.y(); } d->m_isPressed = false; d->m_ismoving = false; d->updateColor(palette()); d->updateValue(); update(); } } void KSlider::mouseMoveEvent(QMouseEvent *event) { Q_D(KSlider); if(d->m_isPressed) { if(orientation() == Qt::Horizontal) { if(event->pos().x() >= d->baseLineRect().left() &&event->pos().x() <= d->baseLineRect().adjusted(0,0,1,0).right()) d->m_currentpos = event->pos(); else if(event->pos().x() < d->baseLineRect().left()) d->m_currentpos.setX(d->baseLineRect().left()); else if(event->pos().x() > d->baseLineRect().adjusted(0,0,1,0).right()) d->m_currentpos.setX(d->baseLineRect().adjusted(0,0,1,0).right()); d->m_ismoving = true; d->updateValue(); update(); } else { if( event->pos().y() >= d->baseLineRect().top() && event->pos().y() <= d->baseLineRect().adjusted(0,0,0,1).bottom() ) d->m_currentpos = event->pos(); else if( event->pos().y() > d->baseLineRect().adjusted(0,0,0,1).bottom() ) d->m_currentpos.setY(d->baseLineRect().adjusted(0,0,0,1).bottom()); else if( event->pos().y() < d->baseLineRect().top() ) d->m_currentpos.setY(d->baseLineRect().top()); d->m_ismoving = true; d->updateValue(); update(); } } else { d->m_ismoving = false; } } void KSlider::wheelEvent(QWheelEvent *event) { QSlider::wheelEvent(event); } bool KSlider::eventFilter(QObject *watched, QEvent *event) { Q_D(KSlider); if(watched == this) { switch (event->type()) { case QEvent::Enter: d->m_isHovered = true; d->updateColor(palette()); break; case QEvent::Leave: d->m_isHovered = false; d->updateColor(palette()); case QEvent::ToolTip: { QHelpEvent* ex = static_cast(event); d->m_rect = QRect(d->m_currentpos.x()-handle_radius,d->m_currentpos.y()-handle_radius,handle_radius*2,handle_radius*2); if(d->m_rect.contains(ex->pos())) { QToolTip::showText(cursor().pos(),d->m_pToolTipText); } else return true; break; } case QEvent::Wheel: { if(d->m_animationStarted) return true; } case QEvent::KeyPress: { if(d->m_animationStarted) return true; } default: break; } } return QSlider::eventFilter(watched,event); } QSize KSlider::sizeHint() const { auto size = QSlider::sizeHint(); if(orientation() == Qt::Horizontal) size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)+2); else size.setWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_SliderHandleRadius)+2); return size; } } //#include "kslider.moc" #include "moc_kslider.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcommentpanel.h0000664000175000017500000000276314474244170024071 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KCOMMENTPANEL_H #define KCOMMENTPANEL_H #include #include "gui_g.h" namespace kdk { class KCommentPanelPrivate; enum StarLevel { LevelZero = 0, LevelOne, LevelTwo, LevelThree, LevelFour, LevelFive }; class GUI_EXPORT KCommentPanel : public QWidget { Q_OBJECT public: explicit KCommentPanel(QWidget *parent = nullptr); void setIcon(const QIcon&); void setTime(const QString&); void setName(const QString&); void setText(const QString&); void setGrade(StarLevel level); protected: void paintEvent(QPaintEvent* event) override; private: Q_DECLARE_PRIVATE(KCommentPanel) KCommentPanelPrivate * const d_ptr; }; } #endif // KCOMMENTPANEL_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpixmapcontainer.h0000664000175000017500000000466214474244170024610 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KPIXMAPCONTAINER_H #define KPIXMAPCONTAINER_H #include "gui_g.h" #include #include namespace kdk { /** @defgroup bar模块 * @{ */ class KPixmapContainerPrivate; /** * @brief KPixmapContainer,为指定的pixmap添加右上角消息提示气泡,样式类似微信头像的消息提示 */ class GUI_EXPORT KPixmapContainer:public QWidget { Q_OBJECT public: KPixmapContainer(QWidget *parent = nullptr); /** * @brief 获取值 */ int value() const; /** * @brief 设置值 * @param value */ void setValue(int value); /** * @brief 设置值是否可见 * @param flag */ void setValueVisiable(bool flag); /** * @brief 获取值是否可见 */ bool isValueVisiable() const; /** * @brief 设置pixmap * @param pixmap */ void setPixmap(const QPixmap& pixmap); /** * @brief 获取pixmap */ QPixmap pixmap()const; /** * @brief 清除值 */ void clearValue(); /** * @brief 返回背景色 * @return */ QColor color(); /** * @brief 设置背景色 * @param color */ void setColor(const QColor& color); /** * @brief 返回字体大小 * @return */ int fontSize(); /** * @brief 设置字体大小 * @param size */ void setFontSize(int size); protected: void paintEvent(QPaintEvent*event); private: Q_DECLARE_PRIVATE(KPixmapContainer) KPixmapContainerPrivate*const d_ptr; }; } /** * @example testbadge/widget.h * @example testbadge/widget.cpp * @} */ #endif // KPIXMAPCONTAINER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbubblewidget.h0000664000175000017500000000566414474244170024051 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KBubbleWidget_H #define KBubbleWidget_H #include #include namespace kdk { /** * @brief 指定气泡尾部的显示方向 */ enum TailDirection { TopDirection, LeftDirection, BottomDirection, RightDirection, None }; /** * @brief 指定气泡尾部的显示位置 */ enum TailLocation { LeftLocation, MiddleLocation, RightLocation }; class KBubbleWidgetPrivate; class KBubbleWidget : public QWidget { Q_OBJECT public: KBubbleWidget (QWidget *parent = nullptr); /** * @brief 设置气泡尾部尺寸 * @param size */ void setTailSize(const QSize& size); /** * @brief 获取气泡尾部尺寸 * @return */ QSize tailSize(); /** * @brief 设置气泡尾部显示位置 * @param dirType * @param locType */ void setTailPosition(TailDirection dirType, TailLocation locType=MiddleLocation); /** * @brief 获取气泡尾部显示方向 * @return 左、上、右、下 */ TailDirection tailDirection(); /** * @brief 获取气泡尾部显示位置 * @return 居左、居中、居右 */ TailLocation tailLocation(); /** * @brief 设置窗体圆角半径 * @param bottomLeft * @param topLeft * @param topRight * @param bottomRight */ void setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight); /** * @brief 设置窗体圆角半径 * @param radius */ void setBorderRadius(int radius); /** * @brief 设置是否启用毛玻璃效果 * @param flag */ void setEnableBlur(bool flag); /** * @brief 获取是否已启用毛玻璃效果 * @return */ bool enableBlur(); /** * @brief 设置透明度 * @param opacity */ void setOpacity(qreal opacity); /** * @brief 获取透明度 * @return */ qreal opacity(); protected: void paintEvent(QPaintEvent *); private: Q_DECLARE_PRIVATE(KBubbleWidget) KBubbleWidgetPrivate* const d_ptr; }; } #endif // KBubbleWidget_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ksearchlineedit.cpp0000664000175000017500000004751514474244170024731 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ksearchlineedit.h" #include "themeController.h" #include #include #include #include #include "kshadowhelper.h" #include "parmscontroller.h" namespace kdk { class MyStyle:public QProxyStyle { public: MyStyle(){} ~MyStyle(){} void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override; QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const override; }; class ListViewDelegate:public QStyledItemDelegate,public ThemeController { public: ListViewDelegate(QObject*parent); protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 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; class KSearchLineEditPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KSearchLineEdit) public: KSearchLineEditPrivate(KSearchLineEdit*parent); void adjustHolderRect(); public Q_SLOTS: void doAnimationFinished(); void doEditingFinished(); protected: void changeTheme(); private: KSearchLineEdit* q_ptr; QHBoxLayout* m_pWidgetLayout; QWidget* m_pWidget; QLabel* m_pTextLabel; QLabel* m_pIconLabel; QPropertyAnimation* m_pAnimation; bool m_isSearching; QStringListModel* m_pListModel; QStringList m_List; QCompleter* m_pCompleter; QString m_placeHolderText; Qt::Alignment m_placeHolderAlignment; bool m_hasFocus; QRect m_holderRect; QRect m_sideRect; ListViewDelegate *m_pListViewDelegate; bool m_isTranslucent; bool isTextEmpty; void init(); }; KSearchLineEdit::KSearchLineEdit(QWidget *parent) :QLineEdit(parent), d_ptr(new KSearchLineEditPrivate(this)) { Q_D(KSearchLineEdit); setFocusPolicy(Qt::ClickFocus); //应设计师要求,1.2.0.8之后的版本默认显示右键菜单 //setContextMenuPolicy(Qt::NoContextMenu); d->init(); installEventFilter(this); connect(d->m_pAnimation,&QPropertyAnimation::finished,d,&KSearchLineEditPrivate::doAnimationFinished); connect(d->m_gsetting,&QGSettings::changed,d,&KSearchLineEditPrivate::changeTheme); connect(this,&KSearchLineEdit::editingFinished,d,&KSearchLineEditPrivate::doEditingFinished); connect(this,&KSearchLineEdit::returnPressed,this,&KSearchLineEdit::clearFocus); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); }); d->changeTheme(); } KSearchLineEdit::~KSearchLineEdit() { } void KSearchLineEdit::setEnabled(bool enable) { Q_D(KSearchLineEdit); QLineEdit::setEnabled(enable); d->changeTheme(); } bool KSearchLineEdit::isEnabled() { Q_D(KSearchLineEdit); return QLineEdit::isEnabled(); } void KSearchLineEdit::setClearButtonEnabled(bool enable) { Q_D(KSearchLineEdit); QLineEdit::setClearButtonEnabled(enable); } bool KSearchLineEdit::isClearButtonEnabled() const { Q_D(const KSearchLineEdit); QLineEdit::isClearButtonEnabled(); } QString KSearchLineEdit::placeholderText() const { Q_D(const KSearchLineEdit); return d->m_placeHolderText; } void KSearchLineEdit::setPlaceholderText(const QString &text) { Q_D(KSearchLineEdit); d->m_placeHolderText = text; d->m_pTextLabel->setText(text); } Qt::Alignment KSearchLineEdit::placeholderAlignment() const { Q_D(const KSearchLineEdit); return d->m_placeHolderAlignment; } void KSearchLineEdit::setPlaceholderAlignment(Qt::Alignment flag) { Q_D(KSearchLineEdit); d->m_placeHolderAlignment = flag; } Qt::Alignment KSearchLineEdit::alignment() const { return QLineEdit::alignment(); } void KSearchLineEdit::setAlignment(Qt::Alignment flag) { Q_D(KSearchLineEdit); QLineEdit::setAlignment(flag); } void KSearchLineEdit::setTranslucent(bool flag) { Q_D(KSearchLineEdit); d->m_isTranslucent = flag; setProperty("needTranslucent",flag); } bool KSearchLineEdit::isTranslucent() { Q_D(KSearchLineEdit); return d->m_isTranslucent; } void KSearchLineEdit::reloadStyle() { Q_D(KSearchLineEdit); QAbstractItemView *popup = completer()->popup(); kdk::effects::KShadowHelper::self()->setWidget(popup); popup->setItemDelegate(d->m_pListViewDelegate); MyStyle *style = new MyStyle; popup->setStyle(style); } void KSearchLineEdit::clear() { Q_D(KSearchLineEdit); if(this->text().isEmpty()) return; QLineEdit::clear(); d->isTextEmpty = true; if(this->hasFocus()) { d->m_pTextLabel->setVisible(false); d->m_pTextLabel->adjustSize(); d->m_pWidget->update(); } else { d->m_pTextLabel->setVisible(true); d->m_pTextLabel->adjustSize(); d->adjustHolderRect(); d->m_pAnimation->setStartValue(d->m_sideRect); d->m_pAnimation->setEndValue(d->m_holderRect); d->m_pAnimation->start(); } } bool KSearchLineEdit::eventFilter(QObject *watched, QEvent *event) { Q_D(KSearchLineEdit); QFont font; font=QApplication::font(); QFontMetrics fm(font); if(watched == this) { if(event->type() == QEvent::Show) { d->adjustHolderRect(); if(text().isEmpty()) d->m_pWidget->setGeometry(d->m_holderRect); else d->m_pWidget->setGeometry(d->m_sideRect); } if(event->type() == QEvent::FocusIn) { d->m_isSearching = true; d->m_hasFocus = false; if(!this->text().isEmpty()) { if(d->isTextEmpty) { d->m_pTextLabel->setVisible(false); d->isTextEmpty=false; } } else { d->m_pTextLabel->setVisible(false); if(d->isTextEmpty) { d->adjustHolderRect(); d->m_pAnimation->setStartValue(d->m_holderRect); d->m_pAnimation->setEndValue(d->m_sideRect); d->m_pAnimation->start(); d->isTextEmpty = false; } } } else if(event->type() == QEvent::FocusOut) { d->m_isSearching = false; d->m_hasFocus = true; if(!this->text().isEmpty()) { d->m_pTextLabel->setVisible(false); } else { d->m_pTextLabel->setVisible(true); d->adjustHolderRect(); d->m_pAnimation->setStartValue(d->m_sideRect); d->m_pAnimation->setEndValue(d->m_holderRect); d->m_pAnimation->start(); d->isTextEmpty = true; } } else if(event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove ) { if(width()-icontextSpacing-d->m_pIconLabel->width()m_placeHolderText)) { if(d->m_hasFocus) setToolTip(d->m_placeHolderText); else setToolTip(""); } } } return QLineEdit::eventFilter(watched,event); } void KSearchLineEditPrivate::adjustHolderRect() { Q_Q(KSearchLineEdit); m_pWidget->adjustSize(); auto maxVisualWidth = q->width()-icontextSpacing-m_pIconLabel->width(); QFont font(QApplication::font()); QFontMetrics fm(font); auto elidedText = fm.elidedText(m_placeHolderText,Qt::ElideRight,maxVisualWidth); m_pTextLabel->setText(elidedText); m_pWidget->adjustSize(); m_sideRect = m_pWidget->rect(); m_sideRect.moveTop((q->rect().height()-m_pWidget->height())/2); m_sideRect.moveLeft(iconMargin); if(m_placeHolderAlignment & Qt::AlignCenter) { m_holderRect = m_pWidget->rect(); m_holderRect.moveCenter(q->rect().center()); } else if(m_placeHolderAlignment & Qt::AlignLeft) { m_holderRect = m_pWidget->rect(); m_holderRect.moveTop((q->rect().height()-m_pWidget->height())/2); m_holderRect.moveLeft(iconMargin); } else if(m_placeHolderAlignment & Qt::AlignRight) { m_holderRect = m_pWidget->rect(); m_holderRect.moveTop((q->height()-m_pWidget->height())/2); m_holderRect.moveRight(q->width() - iconMargin); } } void KSearchLineEdit::resizeEvent(QResizeEvent *event) { Q_D(KSearchLineEdit); QLineEdit::resizeEvent(event); d->adjustHolderRect(); if(text().isEmpty() && !hasFocus()) d->m_pWidget->setGeometry(d->m_holderRect); else d->m_pWidget->setGeometry(d->m_sideRect); } void KSearchLineEdit::setVisible(bool visible) { Q_D(KSearchLineEdit); QLineEdit::setVisible(visible); if(!text().isEmpty()) { d->m_pTextLabel->setVisible(false); d->adjustHolderRect(); d->m_pWidget->setGeometry(d->m_sideRect); } else { d->m_pTextLabel->setVisible(true); } } QSize KSearchLineEdit::sizeHint() const { auto size = QLineEdit::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_SearchLineEditHeight)); return size; } KSearchLineEditPrivate::KSearchLineEditPrivate(KSearchLineEdit *parent) :q_ptr(parent), m_placeHolderText(tr("search")), m_placeHolderAlignment(Qt::AlignCenter), m_hasFocus(true), isTextEmpty(true) { Q_Q(KSearchLineEdit); m_pCompleter = new QCompleter(this); m_pCompleter->setCaseSensitivity(Qt::CaseInsensitive); m_pListModel = new QStringListModel(m_List, this); m_pCompleter->setModel(m_pListModel); q->setCompleter(m_pCompleter); QAbstractItemView *popup = m_pCompleter->popup(); kdk::effects::KShadowHelper::self()->setWidget(popup); m_pListViewDelegate = new ListViewDelegate(popup); popup->setItemDelegate(m_pListViewDelegate); MyStyle *style = new MyStyle; popup->setStyle(style); setParent(parent); } void KSearchLineEditPrivate::doAnimationFinished() { Q_Q(KSearchLineEdit); if(m_isSearching) q->setTextMargins(iconMargin + m_pIconLabel->width(),0,0,0); } void KSearchLineEditPrivate::doEditingFinished() { Q_Q(KSearchLineEdit); QString text = q->text(); if(QString::compare(text,"") != 0) { bool flag = m_List.contains(text, Qt::CaseInsensitive); if(!flag) { m_List.append(text); m_pListModel->setStringList(m_List); } } } void KSearchLineEditPrivate::changeTheme() { Q_Q(KSearchLineEdit); adjustHolderRect(); if(q->text().isEmpty()) m_pWidget->setGeometry(m_holderRect); else m_pWidget->setGeometry(m_sideRect); QPixmap pixmap = QIcon::fromTheme("search-symbolic").pixmap(QSize(16,16)); initThemeStyle(); if(!q->isEnabled()) { QPalette palette = q->palette(); palette.setColor(QPalette::Text,q->palette().color(QPalette::Disabled,QPalette::ButtonText)); m_pTextLabel->setPalette(palette); } else { QPalette palette = q->palette(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) palette.setColor(QPalette::Text,q->palette().color(QPalette::PlaceholderText)); #else if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) palette.setColor(QPalette::Text,q->palette().color(QPalette::Shadow)); #endif m_pTextLabel->setPalette(palette); } if(ThemeController::themeMode() == LightTheme) { m_pIconLabel->setPixmap(pixmap); auto palette = qApp->palette(); palette.setColor(QPalette::Base,Qt::transparent); m_pCompleter->popup()->setPalette(palette); m_pCompleter->popup()->setBackgroundRole(QPalette::Base); m_pCompleter->popup()->setAutoFillBackground(true); } else { m_pIconLabel->setPixmap(drawSymbolicColoredPixmap(pixmap)); auto palette = qApp->palette(); palette.setColor(QPalette::Base,Qt::transparent); m_pCompleter->popup()->setPalette(palette); m_pCompleter->popup()->setBackgroundRole(QPalette::Base); m_pCompleter->popup()->setAutoFillBackground(true); QPalette pal=qApp->palette(); m_pTextLabel->setPalette(pal); } } void KSearchLineEditPrivate::init() { Q_Q(KSearchLineEdit); m_isSearching = false; m_pTextLabel = new QLabel(tr("Search")); 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); m_pWidget->setFocusPolicy(Qt::NoFocus); m_pWidgetLayout = new QHBoxLayout(); m_pWidgetLayout->setContentsMargins(0,0,0,0); m_pWidgetLayout->setMargin(0); m_pWidgetLayout->setSpacing(0); m_pWidgetLayout->addWidget(m_pIconLabel,Qt::AlignVCenter); m_pWidgetLayout->addSpacing(icontextSpacing); m_pWidgetLayout->addWidget(m_pTextLabel,Qt::AlignVCenter); m_pWidgetLayout->addStretch(); m_pWidgetLayout->setSizeConstraint(QLayout::SizeConstraint::SetFixedSize); m_pWidget->setLayout(m_pWidgetLayout); m_pAnimation = new QPropertyAnimation(m_pWidget,"geometry"); m_pAnimation->setEasingCurve(QEasingCurve::InOutQuad); m_pAnimation->setDuration(100); q->setTextMargins(iconMargin + m_pIconLabel->width(),0,0,0); } ListViewDelegate::ListViewDelegate(QObject *parent):QStyledItemDelegate(parent) { } void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QRect rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()); rect.setWidth(option.rect.width()); rect.setHeight(option.rect.height()); const qreal radius = 6; QPainterPath path; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); path.lineTo(rect.bottomRight() - QPointF(radius, 0)); path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); painter->setRenderHint(QPainter::Antialiasing); QColor color = Qt::transparent; QColor fontColor = qApp->palette().color(QPalette::ButtonText); if(ThemeController::themeMode() == ThemeFlag::LightTheme){ if(!(option.state & QStyle::State_Enabled)) { color=QColor("#FFB3B3B3"); } else if(((option.state & QStyle::State_HasFocus) || (option.state & QStyle::State_Selected)|| (option.state & QStyle::State_MouseOver))) { if(option.state.testFlag(QStyle::State_HasFocus) && option.state.testFlag(QStyle::State_Selected)) //QStyle::State_Enabled { color = option.palette.highlight().color(); fontColor = QColor(255,255,255); } else if((option.state & QStyle::State_MouseOver)) { color = option.palette.highlight().color(); fontColor = QColor(255,255,255); } else { color = option.palette.windowText().color(); color.setAlphaF(0.05); } painter->save(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); painter->restore(); } } else{ if(!(option.state & QStyle::State_Enabled)) { color=QColor("#FFB3B3B3"); } else if(((option.state & QStyle::State_HasFocus) || (option.state & QStyle::State_Selected)|| (option.state & QStyle::State_MouseOver))) { if(option.state.testFlag(QStyle::State_HasFocus) && option.state.testFlag(QStyle::State_Selected)) //QStyle::State_Enabled { color = option.palette.highlight().color(); fontColor = QColor(255,255,255); } else if((option.state & QStyle::State_MouseOver)) { color = option.palette.highlight().color(); fontColor = QColor(255,255,255); } else { color = option.palette.windowText().color(); color.setAlphaF(0.15); } painter->save(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); painter->restore(); } } QPen pen; pen.setWidth(1); pen.setColor(fontColor); painter->setPen(pen); auto str = index.model()->data(index,Qt::DisplayRole).toString(); painter->drawText(rect.adjusted(12,0,0,0),Qt::AlignLeft|Qt::AlignVCenter,str); } QSize ListViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize size; size.setWidth(option.widget->width()); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_SearchLineEditItemHeight)); return size; } void MyStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { switch (element) { case CE_ShapedFrame: { painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::HighQualityAntialiasing); QColor color; if(ThemeController::themeMode() == LightTheme) { color = QColor("#262626"); color.setAlphaF(0.15); painter->setBrush(QColor("#FFFFFF")); } else { color = QColor("#333333"); painter->setBrush(color); } painter->setPen(color); painter->drawRoundedRect(option->rect,8,8); break; } default: QProxyStyle::drawControl(element,option,painter,widget); } } QRect MyStyle::subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const { switch (element) { case SE_ShapedFrameContents: return QProxyStyle::subElementRect(element,option,widget).adjusted(0,4,0,2); default: return QProxyStyle::subElementRect(element,option,widget); } } } #include "ksearchlineedit.moc" #include "moc_ksearchlineedit.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktranslucentfloor.h0000664000175000017500000000401014474244170024776 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KTRANSLUCENTFLOOR_H #define KTRANSLUCENTFLOOR_H #include "gui_g.h" #include namespace kdk { class KTranslucentFloorPrivate; class GUI_EXPORT KTranslucentFloor : public QFrame { Q_OBJECT public: KTranslucentFloor(QWidget* parent =nullptr); /** * @brief 设置圆角半径 * @param radius */ void setBorderRadius(int radius); /** * @brief 返回圆角半径 * @return */ int borderRadius(); /** * @brief 设置是否显示阴影 * @param flag */ void setShadow(bool flag); /** * @brief 返回是否显示阴影 * @return */ bool shadow(); /** * @brief 设置是否启用毛玻璃效果 * @param flag */ void setEnableBlur(bool flag); /** * @brief 获取是否已启用毛玻璃效果 * @return */ bool enableBlur(); /** * @brief 设置透明度 * @param opacity */ void setOpacity(qreal opacity); /** * @brief 获取透明度 * @return */ qreal opacity(); protected: void paintEvent(QPaintEvent *); private: KTranslucentFloorPrivate*const d_ptr; Q_DECLARE_PRIVATE(KTranslucentFloor) }; } #endif // KTRANSLUCENTFLOOR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktag.h0000664000175000017500000000264714474244170022163 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KTAG_H #define KTAG_H #include "gui_g.h" #include namespace kdk { class KTagPrivate; enum TagStyle { HighlightTag, BoderTag, BaseBoderTag, GrayTag }; class GUI_EXPORT KTag : public QPushButton { Q_OBJECT public: explicit KTag(QWidget *parent = nullptr); void setClosable(bool); bool closable(); void setText(const QString&); QString text(); void setTagStyle(TagStyle); TagStyle tagStyle(); protected: void paintEvent(QPaintEvent* event); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KTag) KTagPrivate * const d_ptr; }; } #endif // KTAG_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogressdialog.h0000664000175000017500000001014414474244170024423 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KPROGRESSDIALOG_H #define KPROGRESSDIALOG_H #include #include #include #include #include "kwidget.h" #include "gui_g.h" #include "themeController.h" #include "kwindowbuttonbar.h" #include "kiconbar.h" #include "kdialog.h" namespace kdk { /** @defgroup 对话框模块 * @{ */ class KProgressDialogPrivate; /** * @brief 进度对话框 */ class GUI_EXPORT KProgressDialog:public KDialog { Q_OBJECT public: explicit KProgressDialog(QWidget *parent = nullptr); KProgressDialog(const QString &labelText, const QString &cancelButtonText="cancel", int minimum=0, int maximum=100, QWidget *parent = nullptr); ~KProgressDialog(); /** * @brief 设置提示文字 * @param label */ void setLabel(QLabel *label); /** * @brief 设置取消按钮 * @param button */ void setCancelButton(QPushButton *button); /** * @brief 设置进度条 * @param bar */ void setBar(QProgressBar *bar); /** * @brief 设置detail的后缀 * @param suffix */ void setSuffix(const QString& suffix); /** * @brief 设置是否显示详细信息 * @param flag */ void setShowDetail(bool flag); /** * @brief 返回最小值 * @return */ int minimum() const; /** * @brief 返回最大值 * @return */ int maximum() const; /** * @brief 返回当前值 * @return */ int value() const; /** * @brief 返回提示内容 * @return */ QString labelText() const; /** * @brief 设置自动重置 * @param reset */ void setAutoReset(bool reset); /** * @brief 返回是否自动重置 * @return */ bool autoReset() const; /** * @brief 设置是否自动关闭对话框 * @param close */ void setAutoClose(bool close); /** * @brief 返回是否自动关闭对话框 * @return */ bool autoClose() const; /** * @brief 获取进度条 * @return */ QProgressBar* progressBar(); Q_SIGNALS: void canceled(); public Q_SLOTS: /** * @brief 取消进度条 */ void cancel(); /** * @brief 重置进度条 */ void reset(); /** * @brief 设置最大值 * @param maximum */ void setMaximum(int maximum); /** * @brief 设置最小值 * @param minimum */ void setMinimum(int minimum); /** * @brief 设置范围 * @param minimum * @param maximum */ void setRange(int minimum, int maximum); /** * @brief 设置当前值 * @param progress */ void setValue(int progress); /** * @brief 设置提示内容 * @param text */ void setLabelText(const QString &text); /** * @brief 设置取消按钮内容 * @param text */ void setCancelButtonText(const QString &text); /** * @brief 设置次级内容 * @param text */ void setSubContent(const QString&text); protected: void changeTheme(); private: Q_DECLARE_PRIVATE(KProgressDialog) KProgressDialogPrivate *const d_ptr; }; } /** * @example testprogressdialog/widget.h * @example testprogressdialog/widget.cpp * @} */ #endif // KPROGRESSDIALOG_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/parmscontroller.h0000664000175000017500000000360314474244170024454 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef PARMSCONTROLLER_H #define PARMSCONTROLLER_H #include class QDBusConnection; namespace kdk { class Parmscontroller : public QObject { Q_OBJECT public: enum Parm { PM_TabBarHeight, PM_PushButtonHeight, PM_ToolButtonHeight, PM_SearchLineEditHeight, PM_PasswordEditHeight, PM_NavigationBatHeight, PM_TagHeight, PM_SearchLineEditItemHeight, PM_SliderHandleRadius, PM_SliderNodeRadius, PM_BadgeHeight, PM_IconbarHeight, PM_IconBarIconSize, PM_WindowButtonBarSize, PM_NavigationBatInterval, // PM_NavigationBarWidth, PM_Widget_SideWidget_Width, PM_InputDialog_Height, PM_InputDialog_Width, PM_InputDialog_Label_Spacing, PM_InputDialog_Widget_Spacing, PM_InputDialog_Button_Spacing, PM_InputDialog_Bottom_Spacing, PM_InputDialog_Right_Spacing, }; static Parmscontroller* self(); static bool isTabletMode(); static int parm(Parm p); Q_SIGNALS: void modeChanged(bool); private: explicit Parmscontroller(QObject *parent = nullptr); ~Parmscontroller(); }; } #endif // PARMSCONTROLLER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kmessagebox.cpp0000775000175000017500000005350214474244170024077 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kmessagebox.h" #include #include #include #include #include #include #include #include #include #include #include #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 }; static QString iconName=""; class KMessageBoxPrivate: public QObject, 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 *); protected: void changeTheme(); private: KMessageBox *q_ptr; QLabel *iconLabel; QLabel *label; QLabel *informativeLabel; QDialogButtonBox *buttonBox; QList customButtonList; KMessageBox::Icon icon; QAbstractButton *clickedButton; QCheckBox *checkbox; QPushButton *defaultButton; bool autoAddOkButton; bool compatMode; QString m_iconName; }; 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->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); pushButton->setIcon(QIcon()); 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 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 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(); 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(); 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(); 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(); 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(); 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), informativeLabel(0), checkbox(0), compatMode(false), clickedButton(0), defaultButton(0) { Q_Q(KMessageBox); setParent(parent); } 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); iconName = tmpIcon.name(); break; case KMessageBox::Warning: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb); iconName = tmpIcon.name(); break; case KMessageBox::Critical: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb); iconName = tmpIcon.name(); break; case KMessageBox::Question: tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb); iconName = tmpIcon.name(); 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); } 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(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); if(iconName != "") m_iconName = iconName; q->setIconPixmap(QIcon::fromTheme(m_iconName).pixmap(24,24)); } } #include "moc_kmessagebox.cpp" #include "kmessagebox.moc" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kswitchbutton.h0000664000175000017500000000446414474244170024144 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KSWITCHBUTTON_H #define KSWITCHBUTTON_H #include "gui_g.h" #include #include #include #include namespace kdk { /** @defgroup 按钮模块 * @{ */ class KSwitchButtonPrivate; /** * @brief KSwitchButton,指示打开/关闭两种状态 */ class GUI_EXPORT KSwitchButton:public QPushButton { Q_OBJECT public: KSwitchButton(QWidget* parent = 0); ~KSwitchButton(); /** * @brief 设置是否可选中 */ void setCheckable(bool); /** * @brief 返回是否可选中 * @return */ bool isCheckable() const; /** * @brief 返回是否选中 * @return */ bool isChecked() const; /** * @brief 设置是否选中 * @return */ void setChecked(bool); /** * @brief 设置是否启用半透明效果,since 1.2.0.10 * @param flag */ void setTranslucent(bool flag); /** * @brief 获取是否启用半透明效果,since 1.2.0.10 * @return flag */ bool isTranslucent(); Q_SIGNALS: /** * @brief 当选中状态发生变化时,发出此信号 */ void stateChanged(bool); protected: void paintEvent(QPaintEvent *event) override; void resizeEvent(QResizeEvent *event) override; QSize sizeHint() const; private: Q_DECLARE_PRIVATE(KSwitchButton) KSwitchButtonPrivate* const d_ptr; }; } /** * @example testSwitchbutton/widget.h * @example testSwitchbutton/widget.cpp * @} */ #endif //KSWITCHBUTTON_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kiconbar.h0000664000175000017500000000427714474244170023026 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KICONBAR_H #define KICONBAR_H #include "gui_g.h" #include #include #include #include namespace kdk { /** @defgroup bar模块 * @{ */ class KIconBarPrivate; /** * @brief 图标和标题组合控件 */ class GUI_EXPORT KIconBar:public QFrame { Q_OBJECT public: KIconBar(QWidget* parent = nullptr); KIconBar(const QString& iconName,const QString& text,QWidget* parent = nullptr); ~KIconBar(); /** * @brief 设置图标 * @param iconName */ void setIcon(const QString& iconName); /** * @brief 设置图标 * @param icon */ void setIcon(const QIcon& icon); /** * @brief 设置标题 * @param widgetName */ void setWidgetName(const QString& widgetName); /** * @brief 获取标题label * @return */ QLabel* nameLabel(); /** * @brief 获取图标label * @return */ QLabel* iconLabel(); Q_SIGNALS: /** * @brief 双击会发出双击信号,父widget可以绑定相应槽函数 */ void doubleClick(); protected: void mouseDoubleClickEvent(QMouseEvent *event); void resizeEvent(QResizeEvent *event); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KIconBar) KIconBarPrivate*const d_ptr; }; } /** * @example testWidget/testwidget.h * @example testWidget/testwidget.cpp * @} */ #endif // KICONBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ksearchlineedit.h0000664000175000017500000000602314474244170024363 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KSEARCHBAR_H #define KSEARCHBAR_H #include #include #include "gui_g.h" namespace kdk { /** @defgroup 输入框模块 * @{ */ class KSearchLineEditPrivate; /** * @brief 搜索输入框 */ class GUI_EXPORT KSearchLineEdit:public QLineEdit { Q_OBJECT public: explicit KSearchLineEdit(QWidget*parent = nullptr); ~KSearchLineEdit(); /** * @brief 设置是否可用 */ void setEnabled(bool); /** * @brief 返回是否可用 * @return */ bool isEnabled(); /** * @brief 设置是否显示清除按钮 * @return */ void setClearButtonEnabled(bool enable); /** * @brief 返回是否显示清除按钮 * @return */ bool isClearButtonEnabled() const; /** * @brief 返回placeholder * @return */ QString placeholderText() const; /** * @brief 设置placeholder * @return */ void setPlaceholderText(const QString &); /** * @brief 返回placeholder的对齐方式 * @return */ Qt::Alignment placeholderAlignment() const; /** * @brief 设置placeholder的对齐方式 * @return */ void setPlaceholderAlignment(Qt::Alignment flag); /** * @brief 设置输入文本的对齐方式 * @return */ Qt::Alignment alignment() const; /** * @brief 设置输入文本的对齐方式返回 * @return */ void setAlignment(Qt::Alignment flag); /** * @brief 设置是否启用半透明效果,since 1.2.0.10 * @param flag */ void setTranslucent(bool flag); /** * @brief 获取是否启用半透明效果,since 1.2.0.10 * @return flag */ bool isTranslucent(); /** * @brief 重新加载style ,since 2.0.2.1-0k0.5 */ void reloadStyle(); public Q_SLOTS: void clear(); protected: bool eventFilter(QObject *watched, QEvent *event); void resizeEvent(QResizeEvent *event); void setVisible(bool visible); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KSearchLineEdit) KSearchLineEditPrivate* d_ptr; }; } /** * @example testsearchlinedit/widget.h * @example testsearchlinedit/widget.cpp * @} */ #endif // KSEARCHBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kborderbutton.cpp0000664000175000017500000001400014474244170024436 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kborderbutton.h" #include "themeController.h" #include #include #include #include #include "parmscontroller.h" namespace kdk { class KBorderButtonPrivate:public QObject,public ThemeController { Q_DECLARE_PUBLIC(KBorderButton) Q_OBJECT public: KBorderButtonPrivate(KBorderButton*parent):q_ptr(parent) ,m_hoverd(false) ,m_radius(6) {setParent(parent);} protected: void changeTheme(); private: KBorderButton* q_ptr; bool m_hoverd; int m_radius; }; KBorderButton::KBorderButton(QWidget* parent) :QPushButton(parent) ,d_ptr(new KBorderButtonPrivate(this)) { Q_D(KBorderButton); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); }); } 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); return QPushButton::eventFilter(watched,event); } void KBorderButton::paintEvent(QPaintEvent *event) { Q_D(KBorderButton); QStyleOptionButton option; initStyleOption(&option); QPainter p(this); QColor borderColor; QColor fontColor; int borderWidth = 1 ; QColor mix = option.palette.brightText().color(); QColor highlight = option.palette.highlight().color(); if(!option.state.testFlag(QStyle::State_Enabled)) { borderColor = option.palette.color(QPalette::Disabled,QPalette::Button); fontColor = option.palette.color(QPalette::Disabled,QPalette::HighlightedText); } else if(option.state.testFlag(QStyle::State_MouseOver)) { if(option.state.testFlag(QStyle::State_Sunken)) { borderColor = ThemeController::mixColor(highlight,mix,0.2); fontColor = ThemeController::mixColor(highlight,mix,0.2); } else { borderColor = ThemeController::mixColor(highlight,mix,0.05); fontColor = ThemeController::mixColor(highlight,mix,0.05); } } else if(option.state.testFlag(QStyle::State_HasFocus)) { borderWidth = 2; fontColor = option.palette.buttonText().color(); borderColor = ThemeController::mixColor(highlight,mix,0.2); } else { fontColor = option.palette.buttonText().color(); borderColor = option.palette.button().color(); } p.setBrush(Qt::NoBrush); 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); p.save(); pen.setWidth(borderWidth); pen.setColor(borderColor); p.setPen(pen); p.drawRoundedRect(option.rect.adjusted(1,1,-1,-1),d->m_radius,d->m_radius); p.restore(); pen.setWidth(1); pen.setColor(fontColor); p.setPen(pen); QPoint point; QRect ir = option.rect; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { //Center both icon and text QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); pixmap = ThemeController::drawColoredPixmap(this->icon().pixmap(iconSize()),fontColor); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!option.text.isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, option.text).width() + 2; point = QPoint(ir.x() + ir.width() / 2 - w / 2, ir.y() + ir.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (option.direction == Qt::RightToLeft) ir.translate(-point.x() - 2, 0); else ir.translate(point.x() + w + 4, 0); // left-align text if there is if (!option.text.isEmpty()) tf |= Qt::AlignLeft; } else { tf |= Qt::AlignHCenter; } p.drawText(ir,tf,option.text); } KBorderButton::KBorderButton(const QString &text, QWidget *parent ):KBorderButton(parent) { setText(text); } KBorderButton::KBorderButton(const QIcon &icon, const QString &text, QWidget *parent):KBorderButton(parent) { setIcon(icon); setText(text); } void KBorderButton::setIcon(const QIcon &icon) { Q_D(KBorderButton); QPushButton::setIcon(icon); } void KBorderButtonPrivate::changeTheme() { Q_Q(KBorderButton); initThemeStyle(); } } #include "kborderbutton.moc" #include "moc_kborderbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpixmapcontainer.cpp0000664000175000017500000001205614474244170025137 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kpixmapcontainer.h" #include #include #include #include #include const static int margin = 10; namespace kdk { class KPixmapContainerPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KPixmapContainer) public: KPixmapContainerPrivate(KPixmapContainer*parent); private: KPixmapContainer* q_ptr; QPixmap m_pixmap; QColor m_color; int m_fontSize; int m_value; bool m_isShowValue; }; KPixmapContainer::KPixmapContainer(QWidget *parent) :QWidget(parent), d_ptr(new KPixmapContainerPrivate(this)) { Q_D(KPixmapContainer); setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); } int KPixmapContainer::value() const { Q_D(const KPixmapContainer); return d->m_value; } void KPixmapContainer::setValue(int value) { Q_D(KPixmapContainer); d->m_value = value; } void KPixmapContainer::setValueVisiable(bool flag) { Q_D(KPixmapContainer); d->m_isShowValue = flag; } bool KPixmapContainer::isValueVisiable() const { Q_D(const KPixmapContainer); return d->m_isShowValue; } void KPixmapContainer::setPixmap(const QPixmap& pixmap) { Q_D(KPixmapContainer); d->m_pixmap = pixmap; QSize size = QSize(d->m_pixmap.size().width()+20, d->m_pixmap.size().height()+20); this->setFixedSize(size); update(); } QPixmap KPixmapContainer::pixmap() const { Q_D(const KPixmapContainer); if(!d->m_pixmap.isNull()) return d->m_pixmap; else return QPixmap(); } void KPixmapContainer::clearValue() { Q_D(KPixmapContainer); d->m_value = 0; } QColor KPixmapContainer::color() { Q_D(KPixmapContainer); return d->m_color; } void KPixmapContainer::setColor(const QColor &color) { Q_D(KPixmapContainer); d->m_color = color; } int KPixmapContainer::fontSize() { Q_D(KPixmapContainer); return d->m_fontSize; } void KPixmapContainer::setFontSize(int size) { Q_D(KPixmapContainer); if(size<1 ||size >100) return; d->m_fontSize = size; update(); } void KPixmapContainer::paintEvent(QPaintEvent *event) { Q_D(KPixmapContainer); QWidget::paintEvent(event); QPainter p(this); p.setPen(Qt::NoPen); p.drawRect(this->rect()); QFont font(QApplication::font()); font.setPixelSize(d->m_fontSize); QFontMetrics fm(font); int height = fm.height(); int width; if(d->m_value <1 || !d->m_isShowValue) { width = 10; height = 10; } else if(d->m_value >= 1 && d->m_value < 1000) { width = fm.width(QString::number(d->m_value)); width = width > height ? width:height; } else { width = fm.width(QString::number(999)); width = width > height ? width:height; } QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); d->m_color = palette().color(QPalette::Highlight); painter.setBrush(d->m_color); painter.drawPixmap(margin,margin,d->m_pixmap.width(),d->m_pixmap.height(),d->m_pixmap); QRect tmpRect(this->rect().topRight().x()-width/2-margin,this->rect().topRight().y()-height/2+margin,width,height); painter.drawRoundedRect(tmpRect,height/2,height/2); painter.setPen(QColor(255,255,255)); if(d->m_value >= 1 && d->m_value<1000 && d->m_isShowValue) { QFont font(QApplication::font()); font.setPixelSize(d->m_fontSize); painter.setFont(font); painter.drawText(tmpRect,Qt::AlignCenter,QString::number(d->m_value)); } if(d->m_value >= 1000 && d->m_value < INTMAX_MAX && d->m_isShowValue) { painter.setBrush(QColor(255,255,255)); QPointF pointf(tmpRect.center().x(),tmpRect.center().y()); painter.drawEllipse(pointf,qreal(1.0),qreal(1.0)); QPointF leff(pointf.x()-5,pointf.y()); QPointF rightf(pointf.x()+5,pointf.y()); painter.drawEllipse(leff,qreal(1.0),qreal(1.0)); painter.drawEllipse(rightf,qreal(1.0),qreal(1.0)); } } KPixmapContainerPrivate::KPixmapContainerPrivate(KPixmapContainer *parent) :q_ptr(parent) { Q_Q(KPixmapContainer); m_value = -1; m_isShowValue = true; m_color = QColor(55,144,250); m_fontSize = 10; setParent(parent); } } #include "kpixmapcontainer.moc" #include "moc_kpixmapcontainer.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistview.cpp0000664000175000017500000000322214474244170023577 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "klistview.h" #include namespace kdk { class KListViewPrivate :public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KListView) public: KListViewPrivate(KListView* parent); private: KListView* q_ptr; }; KListViewPrivate::KListViewPrivate(KListView *parent) :q_ptr(parent) { Q_Q(KListView); setParent(parent); } KListView::KListView(QWidget *parent) :QListView(parent) ,d_ptr(new KListViewPrivate(this)) { Q_D(KListView); } void KListView::mousePressEvent(QMouseEvent *event) { Q_D(KListView); QPoint p = event->pos(); //获取点击坐标 QModelIndex index = indexAt(p); //点击位置是否为空 if(!index.isValid()) { setCurrentIndex(QModelIndex()); //实现点空白处取消选择 } QListView::mousePressEvent(event); } } #include "klistview.moc" #include "moc_klistview.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktoolbutton.h0000664000175000017500000000461614474244170023617 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KTOOLBUTTON_H #define KTOOLBUTTON_H #include #include #include #include "gui_g.h" namespace kdk { /** @defgroup 按钮模块 * @{ */ /** * @brief 支持三种样式,暂不支持文字显示 */ enum KToolButtonType { Flat, SemiFlat, Background }; class KToolButtonPrivate; /** * @brief KToolbutton */ class GUI_EXPORT KToolButton:public QToolButton { Q_OBJECT public: KToolButton(QWidget*parent); /** * @brief 返回类型 * @return */ KToolButtonType type(); /** * @brief 设置类型 * @param type */ void setType(KToolButtonType type); /** * @brief 设置Icon * @param icon */ void setIcon(const QIcon& icon); /** * @brief 设置正在加载状态,仅不带箭头的toolbuttuon支持该状态 * @param flag */ void setLoading(bool flag); /** * @brief 返回是否正在加载 * @return */ bool isLoading(); /** * @brief 获取Icon * @return */ QIcon icon(); /** * @brief 设置是否显示向下箭头,默认不显示 * @param flag */ void setArrow(bool flag); /** * @brief 返回是否显示箭头 * @return */ bool hasArrow() const; protected: bool eventFilter(QObject *watched, QEvent *event); QSize sizeHint() const; void paintEvent(QPaintEvent *event); private: Q_DECLARE_PRIVATE(KToolButton) KToolButtonPrivate*const d_ptr; }; } /** * @example testtoolbutton/widget.h * @example testtoolbutton/widget.cpp * @} */ #endif // KTOOLBUTTON_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistwidget.cpp0000664000175000017500000000466714474244170024126 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "klistwidget.h" #include namespace kdk { class KListWidgetPrivate : public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KListWidget) public: KListWidgetPrivate(KListWidget* parent); private: KListWidget* q_ptr; QListWidgetItem* item; QListWidgetItem * m_item; }; KListWidgetPrivate::KListWidgetPrivate(KListWidget* parent):q_ptr(parent) { Q_Q(KListWidget); setParent(parent); } KListWidget::KListWidget(QWidget* parent):d_ptr(new KListWidgetPrivate(this)) { Q_D(KListWidget); } void KListWidget::AddItemWidget(KItemWidget *m_itemwidget) { Q_D(KListWidget); if(!m_itemwidget) return ; d->item = new QListWidgetItem(this); d->item->setSizeHint(QSize(this->width(),54)); this->setItemWidget(d->item,m_itemwidget); //建立连接 connect(this,&KListWidget::itemClicked,this,[=](QListWidgetItem *current){ KItemWidget* curWidget = dynamic_cast(this->itemWidget(current)); if(curWidget) curWidget->SetInverse(); }); connect(this,&KListWidget::currentItemChanged,this,[=](QListWidgetItem *current, QListWidgetItem *previous){ KItemWidget* curWidget = dynamic_cast(this->itemWidget(current)); KItemWidget* preWidget = dynamic_cast(this->itemWidget(previous)); if(curWidget&&!preWidget) { curWidget->CancelInverse(); } else if(curWidget) { curWidget->SetInverse(); } if(preWidget) { preWidget->CancelInverse(); } }); } } #include "klistwidget.moc" #include "moc_klistwidget.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/themeController.cpp0000664000175000017500000002051714474244170024732 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "themeController.h" #include #include #include #include #include #include #include static WidgetThemeFlag g_widgetThemeFlag = DefaultTheme; static ThemeFlag g_themeFlag = LightTheme; static IconFlag g_iconFlag = ClassicStyle; static int g_fontSize = 11; static QGSettings* g_gsetting=nullptr; QStringList applist{ "kylin-nm", "ukui-menu", "ukui-panel", "ukui-sidebar", "ukui-volume-control-applet-qt", "panelukui-panel", "ukui-power-manager-tray", "ukui-bluetooth", "sogouimebs", "kylin-device-daemoon", "kylin-video" }; static inline qreal mixQreal(qreal a, qreal b, qreal bias) { return a + (b - a) * bias; } QPixmap ThemeController::drawSymbolicColoredPixmap(const QPixmap &source) { QColor gray(128,128,128); QColor standard (31,32,34); QImage img = source.toImage(); for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0) { if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); } else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); } else { img.setPixelColor(x, y, color); } } } } return QPixmap::fromImage(img); } QPixmap ThemeController::drawColoredPixmap(const QPixmap &source, const QColor &sampleColor) { // QColor gray(128,128,128); // QColor standard (31,32,34); QImage img = source.toImage(); for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0) { color.setRed(sampleColor.red()); color.setGreen(sampleColor.green()); color.setBlue(sampleColor.blue()); img.setPixelColor(x, y, color); } } } return QPixmap::fromImage(img); } QColor ThemeController::getCurrentIconColor() { QPixmap pixmap = QIcon::fromTheme("open-menu-symbolic").pixmap(16,16); QImage img = pixmap.toImage(); for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0) { return color; } } } } QColor ThemeController::mixColor(const QColor &c1, const QColor &c2, qreal bias) { if (bias <= 0.0) { return c1; } if (bias >= 1.0) { return c2; } if (qIsNaN(bias)) { return c1; } qreal r = mixQreal(c1.redF(), c2.redF(), bias); qreal g = mixQreal(c1.greenF(), c2.greenF(), bias); qreal b = mixQreal(c1.blueF(), c2.blueF(), bias); qreal a = mixQreal(c1.alphaF(), c2.alphaF(), bias); return QColor::fromRgbF(r, g, b, a); } WidgetThemeFlag ThemeController::widgetTheme() { return g_widgetThemeFlag; } ThemeFlag ThemeController::themeMode() { return g_themeFlag; } IconFlag ThemeController::iconTheme() { return g_iconFlag; } int ThemeController::systemFontSize() { if(!g_gsetting) return 11; if(g_gsetting->keys().contains("systemFontSize")) { g_fontSize = (int)g_gsetting->get("systemFontSize").toDouble(); } return g_fontSize; } QPixmap ThemeController::drawFashionBackground(const QRect&rect,int sub_width,int sub_height,int radius, int flag) { // int radius = 6; // int sub_width = 32; // int sub_height = 36; QPixmap framePixmap(rect.size()); framePixmap.fill(Qt::transparent); QRect drawRect; drawRect = rect.adjusted(0, 0, 1, 1); auto baseColor = qApp->palette().color(QPalette::Active, QPalette::Button); QColor startColor = mixColor(baseColor,QColor(Qt::white),0.5); QColor endColor = mixColor(baseColor,QColor(Qt::black),0.1); QLinearGradient linearGradient; QPainterPath path; if(flag) //right { path.moveTo(drawRect.bottomRight() - QPoint(0,radius + sub_height)); path.lineTo(drawRect.bottomRight() - QPoint(0,radius)); path.quadTo(drawRect.bottomRight(), drawRect.bottomRight() - QPoint(radius,0)); path.lineTo(drawRect.bottomRight() - QPoint(radius + sub_width,0)); path.quadTo(drawRect.bottomRight(),drawRect.bottomRight() - QPoint(0,radius + sub_height)); linearGradient.setColorAt(0, startColor); linearGradient.setColorAt(1, endColor); linearGradient.setStart(drawRect.right(), drawRect.bottom() - (radius + sub_height)); linearGradient.setFinalStop(drawRect.right(), drawRect.bottom()); } else //left { path.moveTo(drawRect.bottomLeft() - QPoint(0,radius + sub_height)); path.lineTo(drawRect.bottomLeft() - QPoint(0,radius)); path.quadTo(drawRect.bottomLeft(), drawRect.bottomLeft() + QPoint(radius,0)); path.lineTo(drawRect.bottomLeft() + QPoint(radius + sub_width,0)); path.quadTo(drawRect.bottomLeft(),drawRect.bottomLeft() - QPoint(0,radius + sub_height)); linearGradient.setColorAt(0, startColor); linearGradient.setColorAt(1, endColor); linearGradient.setStart(drawRect.left(), drawRect.bottom() - (radius + sub_height)); linearGradient.setFinalStop(drawRect.left(), drawRect.bottom()); } QPainter painter(&framePixmap); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::transparent); painter.setBrush(linearGradient); painter.drawPath(path); return framePixmap; } ThemeController::ThemeController() :m_gsetting(nullptr) { if(QGSettings::isSchemaInstalled(FITTHEMEWINDOW)) { m_gsetting = new QGSettings(FITTHEMEWINDOW); g_gsetting = m_gsetting; initThemeStyle(); } } ThemeController::~ThemeController() { } void ThemeController::initThemeStyle() { if(!m_gsetting) return; if(m_gsetting->keys().contains("styleName")) { QString styleName = m_gsetting->get("styleName").toString(); if(styleName == "ukui-dark" || styleName == "ukui-black" || (styleName == "ukui-default" && applist.contains(QApplication::applicationName()))) g_themeFlag = DarkTheme; else g_themeFlag = LightTheme; } //初始化图标主题 if(m_gsetting->keys().contains("iconThemeName")) { QString iconThemeName = m_gsetting->get("iconThemeName").toString(); if(iconThemeName == "ukui-icon-theme-default") g_iconFlag = DefaultStyle; else { g_iconFlag = ClassicStyle; } } if(m_gsetting->keys().contains("widgetThemeName")) { //初始化样式主题 QString widgetThemeName = m_gsetting->get("widgetThemeName").toString(); if(widgetThemeName == "default") g_widgetThemeFlag = DefaultTheme; else if(widgetThemeName == "classical") g_widgetThemeFlag = ClassicTheme; else g_widgetThemeFlag = FashionTheme; } } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kuninstalldialog.h0000664000175000017500000000415414474244170024574 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KUNINSTALLDIALOG_H #define KUNINSTALLDIALOG_H #include #include #include #include #include #include "gui_g.h" #include "themeController.h" #include "kdialog.h" namespace kdk { /** @defgroup 对话框模块 * @{ */ static const QByteArray ORG_UKUI_STYLE_FONT = "org.ukui.style"; static const QByteArray GSETTING_FONT_KEY = "systemFontSize"; class KUninstallDialogPrivate; /** * @brief 卸载对话框 */ class GUI_EXPORT KUninstallDialog:public KDialog { Q_OBJECT public: KUninstallDialog(QString appName, QString appVersion, QWidget *parent=nullptr); ~KUninstallDialog(); /** * @brief debAppNameLabel * @return */ QLabel* debAppNameLabel(); /** * @brief 包名Label * @return */ QLabel* debNameLabel(); /** * @brief 包IconLabel * @return */ QLabel* debIconLabel(); /** * @brief 包版本Label * @return */ QLabel* debVersionLabel(); /** * @brief 卸载按钮 * @return */ QPushButton* uninstallButtton(); protected: void changeTheme(); private: Q_DECLARE_PRIVATE(KUninstallDialog) KUninstallDialogPrivate*const d_ptr; }; } /** * @example testDialog/widget.h * @example testDialog/widget.cpp * @} */ #endif // KUNINSTALLDIALOG_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/knavigationbar.h0000664000175000017500000000415114474244170024224 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KNAVIGATIONBAR_H #define KNAVIGATIONBAR_H #include "gui_g.h" #include #include #include #include #include #include namespace kdk { /** @defgroup bar模块 * @{ */ class KNavigationBarPrivate; class ListView; /** * @brief 导航栏控件 */ class GUI_EXPORT KNavigationBar:public QScrollArea { Q_OBJECT public: KNavigationBar(QWidget*parent); /** * @brief 增加常规Item * @param item */ void addItem(QStandardItem*item); /** * @brief 增加次级Item * @param subItem */ void addSubItem(QStandardItem*subItem); /** * @brief 成组增加Item,在导航栏中会显示tag * @param items * @param tag */ void addGroupItems(QListitems,const QString& tag); /** * @brief 添加tag * @param tag */ void addTag(const QString& tag); /** * @brief 获取model * @return */ QStandardItemModel* model(); /** * @brief 获取view * @return */ QListView* listview(); private: Q_DECLARE_PRIVATE(KNavigationBar) KNavigationBarPrivate*const d_ptr; }; } /** * @example testnavigationbar/widget.h * @example testnavigationbar/widget.cpp * @} */ #endif // KNAVIGATIONBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbreadcrumb.cpp0000664000175000017500000000776014474244170024052 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kbreadcrumb.h" #include #include #include #include #include #include #include "themeController.h" namespace kdk { class KBreadCrumbPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KBreadCrumb) public: KBreadCrumbPrivate(KBreadCrumb*parent); private: KBreadCrumb* q_ptr; QIcon m_icon; bool m_isFlat; }; KBreadCrumb::KBreadCrumb(QWidget *parent) :QTabBar(parent), d_ptr(new KBreadCrumbPrivate(this)) { } void KBreadCrumb::setIcon(const QIcon &icon) { Q_D(KBreadCrumb); d->m_icon = icon; update(); } QIcon KBreadCrumb::icon() const { Q_D(const KBreadCrumb); return d->m_icon; } bool KBreadCrumb::isFlat() const { Q_D(const KBreadCrumb); return d->m_isFlat; } void KBreadCrumb::setFlat(bool flat) { Q_D(KBreadCrumb); d->m_isFlat = flat; update(); } QSize KBreadCrumb::tabSizeHint(int index) const { Q_D(const KBreadCrumb); QSize size = QTabBar::tabSizeHint(index); QFont font(QApplication::font()); QFontMetrics fm(font); int width = fm.width(tabText(index)); size.setWidth(width+40); if(index == 0 && !d->m_icon.isNull()) size.setWidth(size.width()+50); return size; } void KBreadCrumb::paintEvent(QPaintEvent *event) { Q_D(const KBreadCrumb); QColor highLightColor = palette().color(QPalette::Highlight); QColor baseColor; QColor focusColor; if(ThemeController::themeMode() == ThemeFlag::DarkTheme) { if(d->m_isFlat) baseColor = "#D9D9D9"; else baseColor = "#47474A"; focusColor = "#D9D9D9"; } else { if(d->m_isFlat) baseColor = "#262626"; else baseColor = "#B3B3B3"; 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); QStyleOptionTab option; initStyleOption(&option, i); p.setPen(Qt::NoPen); p.drawRect(rc); if(QStyle::State_MouseOver & option.state) p.setPen(highLightColor); else if(QStyle::State_Selected & option.state) p.setPen(focusColor); else p.setPen(baseColor); p.setBrush(Qt::NoBrush); if(i == 0 && !d->m_icon.isNull()) { p.drawPixmap(rc.left()+10,(rc.height()-24)/2,24,24, d->m_icon.pixmap(24,24)); p.drawText(rc.adjusted(30,0,-24,0),Qt::AlignCenter,tabText(i)); } else p.drawText(rc.adjusted(0,0,-24,0),Qt::AlignCenter,tabText(i)); if(i != count()-1) p.drawPixmap(rc.right()-24,(rc.height()-16)/2,16,16, ThemeController::drawColoredPixmap(QIcon::fromTheme("ukui-end-symbolic").pixmap(16,16),baseColor)); } } KBreadCrumbPrivate::KBreadCrumbPrivate(KBreadCrumb *parent) :q_ptr(parent), m_isFlat(true) { } } #include "kbreadcrumb.moc" #include "moc_kbreadcrumb.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kwindowbuttonbar.cpp0000664000175000017500000002350214474244170025164 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kwindowbuttonbar.h" #include "themeController.h" #include #include #include #include #include "parmscontroller.h" namespace kdk { class KWindowButtonBarPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KWindowButtonBar) public: KWindowButtonBarPrivate(KWindowButtonBar*parent); protected: void changeTheme() override; private: KWindowButtonBar* q_ptr; KMenuButton *m_pMenuBtn; QPushButton *m_pMinimumBtn; QPushButton *m_pmaximumBtn; QPushButton *m_pCloseBtn; MaximumButtonState m_maximumButtonState; QWidget*m_pParentWidget; QColor m_pixColor; bool m_followMode; }; KWindowButtonBar::KWindowButtonBar(QWidget *parent) :QFrame(parent), d_ptr(new KWindowButtonBarPrivate(this)) { Q_D(KWindowButtonBar); d->m_pParentWidget = parent; setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight)); // setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); d->m_pCloseBtn->installEventFilter(this); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ setFixedHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_IconbarHeight)); d->m_pMenuBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize)); d->m_pmaximumBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize)); d->m_pCloseBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize)); d->m_pMinimumBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize)); updateGeometry(); repaint(); }); } KWindowButtonBar::~KWindowButtonBar() { } QPushButton *KWindowButtonBar::minimumButton() { Q_D(KWindowButtonBar); return d->m_pMinimumBtn; } QPushButton *KWindowButtonBar::maximumButton() { Q_D(KWindowButtonBar); return d->m_pmaximumBtn; } QPushButton *KWindowButtonBar::closeButton() { Q_D(KWindowButtonBar); return d->m_pCloseBtn; } KMenuButton *KWindowButtonBar::menuButton() { Q_D(KWindowButtonBar); return d->m_pMenuBtn; } MaximumButtonState KWindowButtonBar::maximumButtonState() { Q_D(KWindowButtonBar); return d->m_maximumButtonState; } void KWindowButtonBar::setMaximumButtonState(MaximumButtonState state) { Q_D(KWindowButtonBar); d->m_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); if(event->button() == Qt::LeftButton && d->m_pmaximumBtn->isEnabled()) Q_EMIT doubleClick(); } bool KWindowButtonBar::eventFilter(QObject *watched, QEvent *event) { Q_D(KWindowButtonBar); if(watched == d->m_pCloseBtn) { //根据不同状态重绘icon颜色 switch (event->type()) { case QEvent::MouseButtonPress: if(isEnabled()) { auto mouseEvent = dynamic_cast(event); if(mouseEvent->button() == Qt::LeftButton) d->m_pixColor = QColor(255,255,255); auto closeIcon = ThemeController::drawColoredPixmap(QIcon::fromTheme("window-close-symbolic").pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize))),d->m_pixColor); d->m_pCloseBtn->setIcon(closeIcon); } break; case QEvent::Enter: if(isEnabled()) { d->m_pixColor = QColor(255,255,255); auto closeIcon = ThemeController::drawColoredPixmap(QIcon::fromTheme("window-close-symbolic").pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize))),d->m_pixColor); d->m_pCloseBtn->setIcon(closeIcon); } break; case QEvent::MouseButtonRelease: if(isEnabled()) { auto mouseEvent = dynamic_cast(event); if(mouseEvent->button() == Qt::LeftButton) d->m_pixColor = QColor(31,32,34); auto closeIcon = ThemeController::drawColoredPixmap(QIcon::fromTheme("window-close-symbolic").pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize))),d->m_pixColor); d->m_pCloseBtn->setIcon(closeIcon); } break; case QEvent::Leave: if(isEnabled()) { if (ThemeController::themeMode() == LightTheme) d->m_pixColor = QColor(31,32,34); else d->m_pixColor = QColor(255,255,255); auto closeIcon = ThemeController::drawColoredPixmap(QIcon::fromTheme("window-close-symbolic").pixmap(QSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize))),d->m_pixColor); d->m_pCloseBtn->setIcon(closeIcon); } break; default: break; } } return QFrame::eventFilter(watched,event); } QSize KWindowButtonBar::sizeHint() const { auto size = QFrame::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight)); return size; } KWindowButtonBarPrivate::KWindowButtonBarPrivate(KWindowButtonBar *parent) :q_ptr(parent),m_followMode(true) { Q_Q(KWindowButtonBar); QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->setSpacing(8); hLayout->setContentsMargins(0,0,0,0); //m_maximumButtonState = Maximum; m_pMenuBtn = new KMenuButton(q); m_pMenuBtn->setFixedSize(Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize),Parmscontroller::parm(Parmscontroller::Parm::PM_WindowButtonBarSize)); m_pMinimumBtn = new QPushButton(q); 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)); m_pCloseBtn->setToolTip(tr("Close")); hLayout->setContentsMargins(0,0,4,0); hLayout->setSpacing(4); hLayout->addStretch(); hLayout->addWidget(m_pMenuBtn); // hLayout->addSpacing(4); hLayout->addWidget(m_pMinimumBtn); // hLayout->addSpacing(4); hLayout->addWidget(m_pmaximumBtn); // hLayout->addSpacing(4); hLayout->addWidget(m_pCloseBtn); // hLayout->addSpacing(4); q->setLayout(hLayout); //控件自己控制样式、响应主题变化 m_pMinimumBtn->setProperty("isWindowButton", 0x1); m_pMinimumBtn->setProperty("useIconHighlightEffect", 0x2); m_pMinimumBtn->setFlat(true); m_pMinimumBtn->setIcon(QIcon::fromTheme("window-minimize-symbolic")); m_pmaximumBtn->setProperty("isWindowButton", 0x1); m_pmaximumBtn->setProperty("useIconHighlightEffect", 0x2); m_pmaximumBtn->setFlat(true); m_pCloseBtn->setProperty("isWindowButton", 0x02); m_pCloseBtn->setProperty("useIconHighlightEffect", 0x08); m_pCloseBtn->setFlat(true); m_pCloseBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,[=](){changeTheme();}); connect(m_pmaximumBtn,&QPushButton::clicked,this,[=]() { if(m_maximumButtonState == Maximum) m_maximumButtonState =Restore; else m_maximumButtonState = Maximum; changeTheme(); }); setParent(parent); } void KWindowButtonBarPrivate::changeTheme() { Q_Q(KWindowButtonBar); initThemeStyle(); if(m_maximumButtonState == Maximum) { m_pmaximumBtn->setIcon(QIcon::fromTheme("window-maximize-symbolic")); m_pmaximumBtn->setToolTip(tr("Maximize")); } else { m_pmaximumBtn->setIcon(QIcon::fromTheme("window-restore-symbolic")); m_pmaximumBtn->setToolTip(tr("Restore")); } } } #include "kwindowbuttonbar.moc" #include "moc_kwindowbuttonbar.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktabbar.h0000664000175000017500000000423714474244170022640 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KTABBAR_H #define KTABBAR_H #include "gui_g.h" #include #include namespace kdk { /** @defgroup bar模块 * @{ */ /** * @brief 支持三种样式 */ enum KTabBarStyle { SegmentDark, SegmentLight, Sliding }; class KTabBarPrivate; /** * @brief KTabBar,支持三种样式 */ class GUI_EXPORT KTabBar: public QTabBar { Q_OBJECT public: KTabBar(KTabBarStyle barStyle = SegmentLight,QWidget* parent = nullptr); ~KTabBar(); /** * @brief 设置TabBar样式 * @param barStyle */ void setTabBarStyle(KTabBarStyle barStyle); /** * @brief 返回TabBar样式 * @return */ KTabBarStyle barStyle(); /** * @brief 设置圆角半径,只对SegmentDark,SegmentLight样式生效 * @param radius */ void setBorderRadius(int radius); /** * @brief 获取圆角半径 * @return */ int borderRadius(); /** * @brief 设置背景色 * @param color */ void setBackgroundColor(const QColor& color); protected: QSize sizeHint() const; QSize minimumTabSizeHint(int index) const; QSize tabSizeHint(int index) const; void paintEvent(QPaintEvent *event); private: Q_DECLARE_PRIVATE(KTabBar) KTabBarPrivate*const d_ptr; }; } /** * @example testtabbar/widget.h * @example testtabbar/widget.cpp * @} */ #endif //KTABBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kdialog.h0000664000175000017500000000501114474244170022633 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KDIALOG_H #define KDIALOG_H #include #include #include #include "gui_g.h" #include "kiconbar.h" #include "kwindowbuttonbar.h" #include "themeController.h" namespace kdk { /** @defgroup 对话框模块 * @{ */ class KDialogPrivate; /** * @brief 继承自QDialog 支持响应主题背景切换,图标主题切换,标题颜色响应窗口激活状态 */ class GUI_EXPORT KDialog: public QDialog,public ThemeController { Q_OBJECT public: explicit KDialog(QWidget* parent=nullptr); ~KDialog(); /** * @brief 设置对话框图标 * @param icon */ void setWindowIcon(const QIcon &icon); /** * @brief 设置对话框图标 * @param iconName */ void setWindowIcon(const QString& iconName); /** * @brief 设置对话框标题名称 * @param widgetName */ void setWindowTitle(const QString &); /** * @brief 获取最大化按钮 * @return */ QPushButton* maximumButton(); /** * @brief 获取最小化按钮 * @return */ QPushButton* minimumButton(); /** * @brief 获取关闭按钮 * @return */ QPushButton* closeButton(); /** * @brief 获取下拉菜单按钮 * @return */ KMenuButton* menuButton(); /** * @brief 获取主内容区Widget * @return */ QWidget* mainWidget(); protected: bool eventFilter(QObject *target, QEvent *event) override; void changeTheme(); void changeIconStyle(); QBoxLayout* mainLayout(); private: Q_DECLARE_PRIVATE(KDialog) KDialogPrivate* const d_ptr; }; } /** * @example testDialog/widget.h * @example testDialog/widget.cpp * @} */ #endif // KDIALOG_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpasswordedit.cpp0000664000175000017500000003263214474244170024450 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kpasswordedit.h" #include #include #include #include #include #include #include #include #include #include "ktoolbutton.h" #include "themeController.h" #include "parmscontroller.h" namespace kdk { class KPasswordEditPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KPasswordEdit) public: KPasswordEditPrivate(KPasswordEdit*parent); void adjustLayout(); void repaintIcon(); protected: void changeTheme(); private: KPasswordEdit* q_ptr; KToolButton* m_pEchoModeBtn; LoginState m_state; KToolButton* m_pLoadingBtn; KToolButton* m_pClearBtn; QWidget* m_pWidget; QHBoxLayout* m_pWidgetLayout; QTimer *m_pTimer; bool m_isLoading; bool m_hasFocus; bool m_useCustomPalette; int m_flashState; }; KPasswordEdit::KPasswordEdit(QWidget*parent) :QLineEdit(parent), d_ptr(new KPasswordEditPrivate(this)) { Q_D(KPasswordEdit); connect(d->m_pEchoModeBtn,&QToolButton::clicked,this,[=](){ if(echoMode() == QLineEdit::Password) setEchoMode(QLineEdit::Normal); else setEchoMode(QLineEdit::Password); d->repaintIcon(); }); connect(this,&QLineEdit::textChanged,this,[=](){ if(!text().isEmpty()&&d->m_pClearBtn->isEnabled() &&hasFocus()) { d->m_pClearBtn->show(); d->adjustLayout(); } else { d->m_pClearBtn->hide(); d->adjustLayout(); } }); connect(d->m_pClearBtn,&QPushButton::clicked,this,[=](){this->clear();}); connect(d->m_pTimer,&QTimer::timeout,this,[=](){ if(d->m_flashState < 7) d->m_flashState++; else d->m_flashState = 0; d->m_pLoadingBtn->setIcon(QIcon::fromTheme(QString("ukui-loading-%1.symbolic").arg(d->m_flashState))); }); connect(d->m_gsetting,&QGSettings::changed,d,&KPasswordEditPrivate::changeTheme); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); }); d->repaintIcon(); installEventFilter(this); setContextMenuPolicy(Qt::NoContextMenu); setFocusPolicy(Qt::ClickFocus); setAttribute(Qt::WA_InputMethodEnabled, false); } 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) palette.setBrush(QPalette::Highlight,QColor("#3769DD")); else palette.setBrush(QPalette::Highlight,QGuiApplication::palette().color(QPalette::Highlight)); setPalette(palette); break; case LoginSuccess: if(ThemeController::widgetTheme() == FashionTheme) palette.setBrush(QPalette::Highlight,QColor("#3ECF20")); else palette.setBrush(QPalette::Highlight,QColor(15,206,117)); setPalette(palette); break; case LoginFailed: if(ThemeController::widgetTheme() == FashionTheme) palette.setBrush(QPalette::Highlight,QColor("#D2293F")); else palette.setBrush(QPalette::Highlight,QColor(243,34,45)); setPalette(palette); break; default: break; } } LoginState KPasswordEdit::state() { Q_D(KPasswordEdit); return d->m_state; } void KPasswordEdit::setLoading(bool flag) { Q_D(KPasswordEdit); d->m_isLoading = flag; if(flag) { d->m_pLoadingBtn->show(); d->m_pTimer->start(); QLineEdit::setEnabled(false); } else { d->m_pLoadingBtn->hide(); d->m_pTimer->stop(); QLineEdit::setEnabled(true); } d->adjustLayout(); } bool KPasswordEdit::isLoading() { Q_D(KPasswordEdit); return d->m_isLoading; } QString KPasswordEdit::placeholderText() { return QLineEdit::placeholderText(); } void KPasswordEdit::setPlaceholderText(QString &text) { QLineEdit::setPlaceholderText(text); } void KPasswordEdit::setClearButtonEnabled(bool enable) { Q_D(KPasswordEdit); d->m_pClearBtn->setEnabled(enable); } bool KPasswordEdit::isClearButtonEnabled() const { bool result = d_ptr->m_pClearBtn->isEnabled(); return result; } void KPasswordEdit::setEchoModeBtnVisible(bool enable) { Q_D(KPasswordEdit); d->m_pEchoModeBtn->setVisible(enable); } bool KPasswordEdit::echoModeBtnVisible() { Q_D(KPasswordEdit); return d->m_pEchoModeBtn->isVisible(); } void KPasswordEdit::setClearBtnVisible(bool enable) { Q_D(KPasswordEdit); d->m_pClearBtn->setEnabled(enable); } bool KPasswordEdit::clearBtnVisible() { Q_D(KPasswordEdit); return d->m_pClearBtn->isVisible(); } void KPasswordEdit::setEnabled(bool flag) { Q_D(KPasswordEdit); if(!flag) { d->m_pClearBtn->hide(); d->m_pLoadingBtn->hide(); } QLineEdit::setEnabled(flag); d->repaintIcon(); } void KPasswordEdit::setEchoMode(QLineEdit::EchoMode mode) { Q_D(KPasswordEdit); QLineEdit::setEchoMode(mode); d->repaintIcon(); } void KPasswordEdit::setUseCustomPalette(bool flag) { Q_D(KPasswordEdit); d->m_useCustomPalette =flag; } void KPasswordEdit::resizeEvent(QResizeEvent *event) { Q_D(KPasswordEdit); QLineEdit::resizeEvent(event); d->adjustLayout(); } bool KPasswordEdit::eventFilter(QObject *watched, QEvent *event) { Q_D(KPasswordEdit); if(watched == this) { if(event->type() == QEvent::FocusIn) { d->m_hasFocus = true; if(this->text().isEmpty()) d->m_pClearBtn->hide(); else { if(d->m_pClearBtn->isEnabled()) d->m_pClearBtn->show(); } d->adjustLayout(); d->changeTheme(); } if(event->type() == QEvent::FocusOut) { d->m_hasFocus = false; d->m_pClearBtn->hide(); d->adjustLayout(); d->changeTheme(); } } return QLineEdit::eventFilter(watched,event); } QSize KPasswordEdit::sizeHint() const { auto size = QLineEdit::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PasswordEditHeight)); return size; } KPasswordEditPrivate::KPasswordEditPrivate(KPasswordEdit *parent) :q_ptr(parent),m_useCustomPalette(false) { Q_Q(KPasswordEdit); m_flashState = 0; m_state = Ordinary; m_hasFocus = q->hasFocus(); m_isLoading = false; m_pTimer = new QTimer(this); m_pTimer->setInterval(100); q->QLineEdit::setEchoMode(QLineEdit::Password); QPalette btnPalette; btnPalette.setBrush(QPalette::Active, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Inactive, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Disabled, QPalette::Button, Qt::transparent); btnPalette.setBrush(QPalette::Active, QPalette::Highlight, Qt::transparent); btnPalette.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::transparent); 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)); m_pEchoModeBtn->setFocusPolicy(Qt::NoFocus); 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)); m_pLoadingBtn->setFocusPolicy(Qt::NoFocus); m_pLoadingBtn->setCursor(Qt::ArrowCursor); 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)); m_pClearBtn->setFocusPolicy(Qt::NoFocus); m_pClearBtn->setCursor(Qt::ArrowCursor); m_pClearBtn->setIcon(QIcon::fromTheme("application-exit-symbolic")); m_pClearBtn->setVisible(false); m_pWidget = new QWidget(q); m_pWidgetLayout = new QHBoxLayout(m_pWidget); m_pWidgetLayout->setContentsMargins(0,0,0,0); m_pWidgetLayout->setSpacing(5); m_pWidgetLayout->addWidget(m_pLoadingBtn); m_pWidgetLayout->addWidget(m_pClearBtn); m_pWidgetLayout->addWidget(m_pEchoModeBtn); m_pWidgetLayout->addSpacing(5); m_pWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); setParent(parent); } void KPasswordEditPrivate::adjustLayout() { Q_Q(KPasswordEdit); int spacing = 5; int width = spacing; if(!m_pEchoModeBtn->isHidden()) width +=(spacing + m_pEchoModeBtn->iconSize().width()); if(!m_pClearBtn->isHidden()) width +=(spacing + m_pClearBtn->iconSize().width()); if(!m_pLoadingBtn->isHidden()) width +=(spacing + m_pLoadingBtn->iconSize().width()); m_pWidget->setFixedSize(width,q->height()); m_pWidget->move(q->width()-m_pWidget->width(),0); q->setTextMargins(0,0,m_pWidget->width(),0); } void KPasswordEditPrivate::repaintIcon() { Q_Q(KPasswordEdit); if(ThemeController::themeMode() == LightTheme) { m_pClearBtn->setIcon(QIcon::fromTheme("application-exit-symbolic")); if(q->echoMode() == QLineEdit::Password) m_pEchoModeBtn->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic")); else m_pEchoModeBtn->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic")); } else { m_pClearBtn->setIcon(drawColoredPixmap(QIcon::fromTheme("application-exit-symbolic").pixmap(16,16),QColor(179,179,179))); if(q->echoMode() == QLineEdit::Password) { if(q->isEnabled()) m_pEchoModeBtn->setIcon(drawColoredPixmap(QIcon::fromTheme("ukui-eye-hidden-symbolic").pixmap(16,16),QColor(179,179,179))); else m_pEchoModeBtn->setIcon(drawColoredPixmap(QIcon::fromTheme("ukui-eye-hidden-symbolic").pixmap(16,16),QColor(50,50,50))); } else { if(q->isEnabled()) m_pEchoModeBtn->setIcon(drawColoredPixmap(QIcon::fromTheme("ukui-eye-display-symbolic").pixmap(16,16),QColor(179,179,179))); else m_pEchoModeBtn->setIcon(drawColoredPixmap(QIcon::fromTheme("ukui-eye-display-symbolic").pixmap(16,16),QColor(50,50,50))); } } } void KPasswordEditPrivate::changeTheme() { Q_Q(KPasswordEdit); initThemeStyle(); if(m_useCustomPalette) return; repaintIcon(); QPalette palette = q->palette(); if(q->hasFocus()) { QColor color = q->palette().color(QPalette::Base); palette.setBrush(QPalette::Button,color); if(ThemeController::themeMode() == LightTheme) palette.setBrush(QPalette::Text, QColor(38,38,38)); else palette.setBrush(QPalette::Active, QPalette::Text, QColor(255,255,255)); q->setPalette(palette); } else { if(ThemeController::themeMode() == LightTheme) { 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 { 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); } } } } #include "kpasswordedit.moc" #include "moc_kpasswordedit.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kcolorbutton.cpp0000664000175000017500000001337214474244170024312 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kcolorbutton.h" #include #include #include "themeController.h" #include 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" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogresscircle.h0000664000175000017500000000332114474244170024424 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KPROGRESSCIRCLE_H #define KPROGRESSCIRCLE_H #include "gui_g.h" #include #include "kprogressbar.h" namespace kdk { class KProgressCirclePrivate; class GUI_EXPORT KProgressCircle : public QWidget { Q_OBJECT public: explicit KProgressCircle(QWidget *parent = nullptr); int minimum() const; int maximum() const; int value() const; QString text() const; void setTextVisible(bool visible); bool isTextVisible() const; ProgressBarState state(); void setState(ProgressBarState state); Q_SIGNALS: void valueChanged(int value); public Q_SLOTS: void reset(); void setRange(int minimum, int maximum); void setMinimum(int minimum); void setMaximum(int maximum); void setValue(int value); protected: void paintEvent(QPaintEvent *) override; private: Q_DECLARE_PRIVATE(KProgressCircle) KProgressCirclePrivate* const d_ptr; }; } #endif // KPROGRESSCIRCLE_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistview.h0000664000175000017500000000224414474244170023247 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KLISTVIEW_H #define KLISTVIEW_H #include #include namespace kdk { class KListViewPrivate; class KListView :public QListView { Q_OBJECT public: KListView(QWidget*parent); protected: void mousePressEvent ( QMouseEvent * event ) ; private: Q_DECLARE_PRIVATE(KListView); KListViewPrivate* const d_ptr; }; } #endif // KLISTVIEW_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbubblewidget.cpp0000664000175000017500000002132514474244170024374 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "kbubblewidget.h" #include #include #include #include #include "themeController.h" #include namespace kdk { class KBubbleWidgetPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KBubbleWidget) public: KBubbleWidgetPrivate(KBubbleWidget*parent); private: KBubbleWidget *q_ptr; int m_startX; int m_startY; int m_tailWidth; int m_tailHeight; TailDirection m_tailDirection; TailLocation m_tailLocation; int m_topLeftRadius; int m_topRightRadius; int m_bottomLeftRadius; int m_bottomRightRadius; bool m_enableBlur; qreal m_opacity; }; void KBubbleWidget::setTailPosition(TailDirection dirType, TailLocation locType) { Q_D(KBubbleWidget); d->m_tailDirection = dirType; d->m_tailLocation = locType; this->update(); } TailDirection KBubbleWidget ::tailDirection() { Q_D(KBubbleWidget); return d->m_tailDirection; } TailLocation KBubbleWidget::tailLocation() { Q_D(KBubbleWidget); return d->m_tailLocation; } void KBubbleWidget::setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight) { Q_D(KBubbleWidget); d->m_bottomRightRadius = bottomRight; d->m_topLeftRadius = topLeft; d->m_bottomLeftRadius = bottomLeft; d->m_topRightRadius = topRight; } void KBubbleWidget::setBorderRadius(int radius) { Q_D(KBubbleWidget); d->m_topLeftRadius = radius; d->m_bottomLeftRadius = radius; d->m_bottomRightRadius = radius; d->m_topRightRadius = radius; } void KBubbleWidget::setEnableBlur(bool flag) { Q_D(KBubbleWidget); d->m_enableBlur = flag; } bool KBubbleWidget::enableBlur() { Q_D(KBubbleWidget); return d->m_enableBlur; } void KBubbleWidget::setOpacity(qreal opacity) { Q_D(KBubbleWidget); if(opacity < 0 || opacity > 1) return; d->m_opacity = opacity; } qreal KBubbleWidget::opacity() { Q_D(KBubbleWidget); return d->m_opacity; } KBubbleWidget::KBubbleWidget(QWidget *parent) :QWidget(parent), d_ptr(new KBubbleWidgetPrivate(this)) { Q_D(KBubbleWidget); setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); } void KBubbleWidget::setTailSize(const QSize &size) { Q_D(KBubbleWidget); d->m_tailWidth = size.width(); d->m_tailHeight = size.height(); } QSize KBubbleWidget::tailSize() { Q_D(KBubbleWidget); QSize size; size.setWidth(d->m_tailWidth); size.setHeight(d->m_tailHeight); return size; } void KBubbleWidget ::paintEvent(QPaintEvent *) { Q_D(KBubbleWidget); QPolygon trianglePolygon; QPainterPath path; QRect targetRect = this->rect(); switch (d->m_tailDirection) { case TopDirection: targetRect = targetRect.adjusted(0,d->m_tailHeight,0,0); if(d->m_tailLocation == LeftLocation) d->m_startX = 18; else if(d->m_tailLocation == MiddleLocation) d->m_startX = (targetRect.width()-d->m_tailWidth*2)/2; else if(d->m_tailLocation == RightLocation) d->m_startX = targetRect.width()- d->m_tailHeight*2-d->m_tailWidth-19; d->m_startY = 0; trianglePolygon << QPoint(d->m_startX + d->m_tailHeight, d->m_tailHeight); trianglePolygon << QPoint(d->m_startX + d->m_tailWidth / 2 + d->m_tailHeight, 0); trianglePolygon << QPoint(d->m_startX + d->m_tailWidth + d->m_tailHeight, d->m_tailHeight); break; case LeftDirection: targetRect = targetRect.adjusted(d->m_tailHeight,0,0,0); if(d->m_tailLocation == LeftLocation) d->m_startY = d->m_tailHeight +18; else if(d->m_tailLocation == MiddleLocation) d->m_startY = targetRect.height()/2-d->m_tailWidth/2; else if(d->m_tailLocation == RightLocation) d->m_startY = d->m_tailHeight + static_cast((targetRect.height()-d->m_tailHeight*2 - d->m_tailWidth))-19; d->m_startX = 0; trianglePolygon << QPoint(d->m_startX + d->m_tailHeight, d->m_startY); trianglePolygon << QPoint(d->m_startX , d->m_startY + d->m_tailWidth/2); trianglePolygon << QPoint(d->m_startX + d->m_tailHeight , d->m_startY + d->m_tailWidth); break; case RightDirection: targetRect = targetRect.adjusted(0,0,-d->m_tailHeight,0); if(d->m_tailLocation == LeftLocation) d->m_startY = d->m_tailHeight +18; else if(d->m_tailLocation == MiddleLocation) d->m_startY = targetRect.height()/2-d->m_tailWidth/2; else if(d->m_tailLocation == RightLocation) d->m_startY = d->m_tailHeight + static_cast((targetRect.height()-d->m_tailHeight*2 - d->m_tailWidth))-19; d->m_startX = targetRect.width(); trianglePolygon << QPoint(d->m_startX - d->m_tailHeight - 1, d->m_startY); trianglePolygon << QPoint(d->m_startX - 1, d->m_startY + d->m_tailWidth/2); trianglePolygon << QPoint(d->m_startX - d->m_tailHeight - 1 , d->m_startY + d->m_tailWidth); break; case BottomDirection: targetRect = targetRect.adjusted(0,0,0,-d->m_tailHeight); if(d->m_tailLocation == LeftLocation) d->m_startX = 18; else if(d->m_tailLocation == MiddleLocation) d->m_startX = (this->rect().width()-d->m_tailWidth*2)/2; else if(d->m_tailLocation == RightLocation) d->m_startX = this->rect().width()- d->m_tailHeight*2-d->m_tailWidth-19; d->m_startY = this->rect().height(); trianglePolygon << QPoint(d->m_startX + d->m_tailHeight, d->m_startY - d->m_tailHeight-1); trianglePolygon << QPoint(d->m_startX + d->m_tailWidth / 2 + d->m_tailHeight, d->m_startY-1); trianglePolygon << QPoint(d->m_startX + d->m_tailWidth + d->m_tailHeight,d->m_startY - d->m_tailHeight-1); break; case None: break; } path.moveTo(targetRect.topRight() - QPoint(d->m_topRightRadius , 0) ); //右上 path.lineTo(targetRect.topLeft() + QPointF(d->m_topLeftRadius , 0)); //上方线 path.quadTo(targetRect.topLeft(), targetRect.topLeft() + QPointF(0 , d->m_topLeftRadius)); //圆角 path.lineTo(targetRect.bottomLeft() + QPointF(0,- d->m_bottomLeftRadius)); //左方线 path.quadTo(targetRect.bottomLeft(), targetRect.bottomLeft() + QPointF(d->m_bottomLeftRadius , 0));//圆角 path.lineTo(targetRect.bottomRight() - QPointF(d->m_bottomRightRadius , 0));//下方线 path.quadTo(targetRect.bottomRight(), targetRect.bottomRight() + QPointF(0, - d->m_bottomRightRadius));//圆角 path.lineTo(targetRect.topRight() + QPointF(0, d->m_topRightRadius));//右方线 path.quadTo(targetRect.topRight() , targetRect.topRight() - QPointF(d->m_topRightRadius, 0)); // 圆角 path.addPolygon(trianglePolygon); path = path.simplified();//合并subpath,取消交集部分的线 QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); painter.setRenderHints(QPainter::HighQualityAntialiasing); if(d->m_enableBlur) { //开启毛玻璃时 QRegion region(path.toFillPolygon().toPolygon()); KWindowEffects::enableBlurBehind(this->winId(),true,region); this->setMask(region); painter.setOpacity(d->m_opacity); } else { //未开启毛玻璃时 painter.setOpacity(1); } QPen pen; pen.setJoinStyle(Qt::RoundJoin); pen.setWidthF(1); pen.setColor(Qt::gray); painter.setPen(pen); painter.setBrush(this->palette().color(this->backgroundRole())); painter.drawPath(path); } KBubbleWidgetPrivate::KBubbleWidgetPrivate(KBubbleWidget *parent) :q_ptr(parent), m_bottomLeftRadius(8), m_topLeftRadius(8), m_bottomRightRadius(8), m_topRightRadius(8), m_tailHeight(8), m_tailWidth(16), m_enableBlur(false), m_opacity(0.5), m_tailLocation(TailLocation::LeftLocation), m_tailDirection(TailDirection::BottomDirection) { } } #include "kbubblewidget.moc" #include "moc_kbubblewidget.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kborderlessbutton.cpp0000664000175000017500000002012314474244170025330 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kborderlessbutton.h" #include "themeController.h" #include #include namespace kdk { class KBorderlessButtonPrivate:public QObject,public ThemeController { Q_DECLARE_PUBLIC(KBorderlessButton) Q_OBJECT public: KBorderlessButtonPrivate(KBorderlessButton*parent): q_ptr(parent),m_hoverd(false) { setParent(parent); } protected: void changeTheme(); private: KBorderlessButton *q_ptr; bool m_hoverd; }; KBorderlessButton::KBorderlessButton(QWidget* parent): QPushButton(parent) ,d_ptr(new KBorderlessButtonPrivate(this)) { Q_D(KBorderlessButton); setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); setFocusPolicy(Qt::NoFocus); } KBorderlessButton::KBorderlessButton(const QString &text, QWidget *parent):KBorderlessButton(parent) { setText(text); } KBorderlessButton::KBorderlessButton(const QIcon &icon, const QString &text, QWidget *parent):KBorderlessButton(parent) { setIcon(icon); setText(text); } KBorderlessButton::KBorderlessButton(const QIcon &icon, QWidget *parent):KBorderlessButton(parent) { setIcon(icon); } KBorderlessButton::~KBorderlessButton() { } void KBorderlessButton::setIcon(const QIcon &icon) { Q_D(KBorderlessButton); QPushButton::setIcon(icon); d->changeTheme(); } bool KBorderlessButton::eventFilter(QObject *watched, QEvent *event) { Q_D(KBorderlessButton); return QPushButton::eventFilter(watched,event); } void KBorderlessButton::paintEvent(QPaintEvent *event) { Q_D(KBorderlessButton); QStyleOptionButton option; initStyleOption(&option); QPainter p(this); QColor borderColor; QColor fontColor; QColor highlight = option.palette.highlight().color(); QColor mix = option.palette.brightText().color(); if(!option.state.testFlag(QStyle::State_Enabled)) { borderColor = option.palette.color(QPalette::Disabled,QPalette::Button); fontColor = option.palette.color(QPalette::Disabled,QPalette::HighlightedText); } else if(ThemeController::themeMode() == ThemeFlag::LightTheme){ if(option.state.testFlag(QStyle::State_MouseOver)) { if(option.state.testFlag(QStyle::State_Sunken)) { borderColor = ThemeController::mixColor(highlight,mix,0.2); fontColor = ThemeController::mixColor(highlight,mix,0.2); } else { borderColor = ThemeController::mixColor(highlight,mix,0.1); fontColor = ThemeController::mixColor(highlight,mix,0.1); } } else { if(!this->icon().isNull()){ fontColor = option.palette.buttonText().color(); borderColor = option.palette.button().color(); } else { borderColor = highlight; fontColor = highlight; } } } else{ if(option.state.testFlag(QStyle::State_MouseOver)) { if(option.state.testFlag(QStyle::State_Sunken)) { borderColor = ThemeController::mixColor(highlight,mix,0.05); fontColor = ThemeController::mixColor(highlight,mix,0.05); } else { borderColor = ThemeController::mixColor(highlight,mix,0.2); fontColor = ThemeController::mixColor(highlight,mix,0.2); } } else { if(!this->icon().isNull()){ fontColor = option.palette.buttonText().color(); borderColor = option.palette.button().color(); } else { borderColor = highlight; fontColor = highlight; } } } p.setBrush(Qt::NoBrush); 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); pen.setWidth(1); pen.setColor(fontColor); p.setPen(pen); QPoint point; // bug 170516 修正1px QRect ir = option.rect.adjusted(0,0,-1,0); uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { //Center both icon and text QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); pixmap = ThemeController::drawColoredPixmap(this->icon().pixmap(iconSize()),fontColor); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!option.text.isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, option.text).width() + 2; point = QPoint(ir.x() + ir.width() / 2 - w / 2, ir.y() + ir.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if (option.direction == Qt::RightToLeft) ir.translate(-point.x() - 2, 0); else ir.translate(point.x() + w + 4, 0); // left-align text if there is if (!option.text.isEmpty()) tf |= Qt::AlignLeft; QFontMetrics fm=option.fontMetrics; int width = option.iconSize.width(); int height = option.iconSize.height(); if(fm.width(option.text) > option.rect.width()-width-4) { QRect rect(option.rect.x(),(option.rect.height()-height)/2,width,height); p.drawPixmap(rect,pixmap); QRect rect1(width+4,0,option.rect.width()-width-4,option.rect.height()); QString elidedText1 = fm.elidedText(option.text,Qt::ElideRight,option.rect.width()-width-4); p.drawText(rect1,tf,elidedText1); if(toolTip().isNull()) setToolTip(option.text); } else { p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); p.drawText(ir,tf,option.text); } } else { tf |= Qt::AlignHCenter; QFontMetrics fm=option.fontMetrics; QString elidedText = fm.elidedText(option.text,Qt::ElideRight,option.rect.width()); p.drawText(option.rect,tf,elidedText); if(fm.width(option.text) > option.rect.width()) setToolTip(option.text); } } QSize KBorderlessButton::sizeHint() const { QFontMetrics fm(this->font()); QSize size; if(this->icon().isNull()) size = QSize(fm.width(this->text()) + 2, fm.height()); else { int height = std::max(fm.height(),this->iconSize().height()); int width = fm.width(this->text()) + this->iconSize().width() + 4; size = QSize(width,height); } return size; } void KBorderlessButtonPrivate::changeTheme() { Q_Q(KBorderlessButton); initThemeStyle(); } } #include "kborderlessbutton.moc" #include "moc_kborderlessbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klineframe.h0000664000175000017500000000260014474244170023337 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KLINEFRAME_H #define KLINEFRAME_H #include #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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistviewdelegate.cpp0000664000175000017500000002465414474244170025306 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "klistviewdelegate.h" #include #include #include #include #include #include #include #include #include #include #include "themeController.h" #include #include #include #include namespace kdk { class KListViewDelegatePrivate : public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KListViewDelegate) public: KListViewDelegatePrivate(KListViewDelegate* parent); ~KListViewDelegatePrivate(); private: KListViewDelegate* q_ptr; QAbstractItemView* m_listView; }; KListViewDelegatePrivate::KListViewDelegatePrivate(KListViewDelegate *parent) :q_ptr(parent) { Q_Q(KListViewDelegate); initThemeStyle(); connect(m_gsetting,&QGSettings::changed,this,[=](){initThemeStyle();}); } KListViewDelegatePrivate::~KListViewDelegatePrivate() { } KListViewDelegate::KListViewDelegate(QAbstractItemView*parent) :QStyledItemDelegate(parent) ,d_ptr(new KListViewDelegatePrivate(this)) { Q_D(KListViewDelegate); d->m_listView = parent; } KListViewDelegate::~KListViewDelegate() { } void KListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_D(const KListViewDelegate); QFont font; font = QApplication::font(); QFontMetrics fm(font); int height = fm.height(); if (index.isValid()) { QListView* view = dynamic_cast(d->m_listView); if(!view) return; if(view->viewMode() == QListView::ListMode) { QRectF rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()); rect.setWidth(option.rect.width()); rect.setHeight(option.rect.height()); //QPainterPath画圆角矩形 const qreal radius = 4; QPainterPath path; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); path.lineTo(rect.bottomRight() - QPointF(radius, 0)); path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); QString mainText = index.data(Qt::DisplayRole).toString();//获取主文本和副文本 QString subText = index.data(Qt::UserRole).toString(); if(subText.isNull()) { auto *model =dynamic_cast(const_cast(index.model()));//获取图标 QIcon icon = model->item(index.row())->icon(); QRect iconRect = QRect(rect.left()+8,rect.top()+10,d->m_listView->iconSize().width()+(height-23)*2,d->m_listView->iconSize().height()+(height-23)*2);// 绘制图标的位置 QRect MainText = QRect(iconRect.right()+8,rect.top()+10+iconRect.height()/2-height/2,rect.width(),height); // 绘制文本的位置 painter->save(); //item可选中 (单选) QColor color; if (option.state.testFlag(QStyle::State_MouseOver)&&!(option.state.testFlag(QStyle::State_Selected))) { if(ThemeController::themeMode() == ThemeFlag::DarkTheme) { color = option.palette.windowText().color(); color.setAlphaF(0.25); } else { color = option.palette.highlight().color().lighter(120); color.setAlphaF(0.5); } painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); } else if (option.state.testFlag(QStyle::State_Selected)) { color = option.palette.highlight().color(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); } //icon.paint(painter,iconRect); QPixmap pixmap=icon.pixmap(d->m_listView->iconSize().width()+(height-23)*2,d->m_listView->iconSize().width()+(height-23)*2); painter->drawPixmap(iconRect,pixmap); //点击反白效果,画icon和text if(ThemeController::themeMode() == ThemeFlag::LightTheme) { if(option.state.testFlag(QStyle::State_Selected)) { painter->setPen(QColor(230,230,230)); painter->drawText(MainText,mainText); } else { painter->setPen(QColor(38,38,38)); painter->drawText(MainText,mainText); } } else { painter->setPen(QColor(230,230,230)); painter->drawText(MainText,mainText); } painter->restore(); } else { auto *model =dynamic_cast(const_cast(index.model()));//获取图标 QIcon icon = model->item(index.row())->icon(); QRect iconRect = QRect(rect.left()+8,rect.top()+10,d->m_listView->iconSize().width()+(height-23)*2,d->m_listView->iconSize().height()+(height-23)*2);// 绘制图标的位置 QRect MainText = QRect(iconRect.right()+8,rect.top()+5,rect.width(),height); // 绘制两个文本的位置 QRect SubText = QRect(iconRect.right()+8,rect.bottom()-5-height,rect.width(),height); painter->save(); //item可选中 (单选) QColor color; if (option.state.testFlag(QStyle::State_MouseOver)&&!(option.state.testFlag(QStyle::State_Selected))) { if(ThemeController::themeMode()==ThemeFlag::DarkTheme) { color = option.palette.windowText().color(); color.setAlphaF(0.25); } else { color = option.palette.highlight().color().lighter(120); color.setAlphaF(0.5); } painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); } else if (option.state.testFlag(QStyle::State_Selected)) { color = option.palette.highlight().color(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); painter->drawPath(path); } //icon.paint(painter,iconRect); QPixmap pixmap=icon.pixmap(QSize(d->m_listView->iconSize().width()+(height-23)*2,d->m_listView->iconSize().height()+(height-23)*2)); painter->drawPixmap(iconRect,pixmap); //点击反白效果,画icon和text if(ThemeController::themeMode() == ThemeFlag::LightTheme) { if(option.state.testFlag(QStyle::State_Selected)) { painter->setPen(QColor(230,230,230)); painter->drawText(MainText,mainText); painter->setPen(QColor(169,169,169)); painter->drawText(SubText,subText); } else { painter->setPen(QColor(38,38,38)); painter->drawText(MainText,mainText); painter->setPen(QColor(169,169,169)); painter->drawText(SubText,subText); } } else { painter->setPen(QColor(230,230,230)); painter->drawText(MainText,mainText); painter->setPen(QColor(169,169,169)); painter->drawText(SubText,subText); } painter->restore(); } } else if(view->viewMode() == QListView::IconMode) { QStyleOptionViewItem styleOptionViewItem( option ); //定义 initStyleOption( &styleOptionViewItem, index); //初始化 QStyle *pStyle = styleOptionViewItem.widget->style(); pStyle->drawControl(QStyle::CE_ItemViewItem, &styleOptionViewItem, painter, styleOptionViewItem.widget); } } } QSize KListViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_D(const KListViewDelegate); QFont font; //获取系统字体大小 font = QApplication::font(); QFontMetrics fm(font); int height = fm.height(); return QSize(option.rect.width(),height*2 + 6); } } #include "klistviewdelegate.moc" #include "moc_klistviewdelegate.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kborderbutton.h0000664000175000017500000000352114474244170024111 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KBORDERBUTTON_H #define KBORDERBUTTON_H #include "gui_g.h" #include #include #include #include namespace kdk { /** @defgroup 按钮模块 * @{ */ class KBorderButtonPrivate; /** * @brief 带有边框的按钮 */ class GUI_EXPORT KBorderButton:public QPushButton { Q_OBJECT public: KBorderButton(QWidget* parent = nullptr); KBorderButton(const QString &text, QWidget *parent = nullptr); KBorderButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr); KBorderButton(const QIcon &icon, QWidget *parent = nullptr); /** * @brief 设置按钮图标 * @param icon */ void setIcon(const QIcon &icon); ~KBorderButton(); protected: bool eventFilter(QObject *watched, QEvent *event); void paintEvent(QPaintEvent *event); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KBorderButton) KBorderButtonPrivate * const d_ptr; }; } /** * @example testPushbutton/widget.h * @example testPushbutton/widget.cpp * @} */ #endif libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistwidget.h0000664000175000017500000000265714474244170023570 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KLISTWIDGET_H #define KLISTWIDGET_H #include #include "kitemwidget.h" #include "themeController.h" #include "gui_g.h" namespace kdk { class KListWidgetPrivate; class GUI_EXPORT KListWidget : public QListWidget { Q_OBJECT public: KListWidget(QWidget* parent); /* * 将Itemwidget插入到listwidget * m_itemwidget需要插入的Itemwidget */ void AddItemWidget(KItemWidget* m_itemwidget); //void mousePressEvent(QMouseEvent *event); //void itemClicked(QListWidgetItem * item); private: Q_DECLARE_PRIVATE(KListWidget); KListWidgetPrivate* const d_ptr; }; } #endif // KLISTWIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kmenubutton.cpp0000664000175000017500000001131214474244170024130 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kmenubutton.h" #include #include #include "parmscontroller.h" namespace kdk { class KMenuButtonPrivate:public QObject { Q_DECLARE_PUBLIC(KMenuButton) Q_OBJECT public: KMenuButtonPrivate(KMenuButton*parent); private: KMenuButton* q_ptr; QMenu *m_pMenu; QAction *m_pSettingAction; QAction *m_pThemeAction; QAction *m_pAssistAction; QAction *m_pAboutAction; QAction *m_pQuitAction; QMenu *m_pThemeMenu; QAction *m_pAutoAction; QAction *m_pLightAction; QAction *m_pDarkAction; }; KMenuButton::KMenuButton(QWidget *parent) :QToolButton(parent), d_ptr(new KMenuButtonPrivate(this)) { Q_D(KMenuButton); //setArrowType(Qt::NoArrow); d->m_pMenu =new QMenu(this); setMenu(d->m_pMenu); setToolTip(tr("Options")); 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); d->m_pAboutAction = new QAction(tr("About"),d->m_pMenu); d->m_pQuitAction = new QAction(tr("Quit"),d->m_pMenu); QList actionList; actionList<m_pSettingAction<m_pThemeAction<m_pAssistAction<m_pAboutAction<m_pQuitAction; d->m_pMenu->addActions(actionList); setPopupMode(QToolButton::InstantPopup); d->m_pThemeMenu = new QMenu(this); d->m_pAutoAction = new QAction(tr("Auto"),d->m_pThemeMenu); d->m_pAutoAction->setCheckable(true); d->m_pLightAction = new QAction(tr("Light"),d->m_pThemeMenu); d->m_pLightAction->setCheckable(true); d->m_pDarkAction = new QAction(tr("Dark"),d->m_pThemeMenu); d->m_pDarkAction->setCheckable(true); QActionGroup * group = new QActionGroup(this); group->addAction(d->m_pAutoAction); group->addAction(d->m_pLightAction); group->addAction(d->m_pDarkAction); QList list; list<m_pAutoAction<m_pLightAction<m_pDarkAction; d->m_pThemeMenu->addActions(list); d->m_pThemeAction->setMenu(d->m_pThemeMenu); setIcon(QIcon::fromTheme("open-menu-symbolic")); setProperty("isWindowButton", 0x1); setProperty("useIconHighlightEffect", 0x2); setAutoRaise(true); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,[=](){changeTheme();}); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); update(); }); } KMenuButton::~KMenuButton() { } QMenu *KMenuButton::menu() { Q_D(KMenuButton); return d->m_pMenu; } QMenu *KMenuButton::themeMenu() { Q_D(KMenuButton); return d->m_pThemeMenu; } QAction *KMenuButton::settingAction() { Q_D(KMenuButton); return d->m_pSettingAction; } QAction *KMenuButton::themeAction() { Q_D(KMenuButton); return d->m_pThemeAction; } QAction *KMenuButton::assistAction() { Q_D(KMenuButton); return d->m_pAssistAction; } QAction *KMenuButton::aboutAction() { Q_D(KMenuButton); return d->m_pAboutAction; } QAction *KMenuButton::quitAction() { Q_D(KMenuButton); return d->m_pQuitAction; } QAction *KMenuButton::autoAction() { Q_D(KMenuButton); return d->m_pAutoAction; } QAction *KMenuButton::lightAction() { Q_D(KMenuButton); return d->m_pLightAction; } QAction *KMenuButton::darkAction() { Q_D(KMenuButton); return d->m_pDarkAction; } void KMenuButton::changeTheme() { initThemeStyle(); } void KMenuButton::paintEvent(QPaintEvent *painteEvent) { QToolButton::paintEvent(painteEvent); } QSize KMenuButton::sizeHint() const { auto size = QToolButton::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight)); size.setWidth(Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight)); return size; } KMenuButtonPrivate::KMenuButtonPrivate(KMenuButton *parent) :q_ptr(parent) { setParent(parent); } } #include "kmenubutton.moc" #include "moc_kmenubutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kinputdialog.h0000664000175000017500000001654014474244170023724 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KINPUTDIALOG_H #define KINPUTDIALOG_H #include #include #include "kdialog.h" namespace kdk { /** @defgroup 对话框模块 * @{ */ class KInputDialogPrivate; /** * @brief 输入对话框,接口同QInputDialog */ class GUI_EXPORT KInputDialog : public KDialog { Q_OBJECT Q_ENUMS(InputMode InputDialogOption) QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode) QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText) QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions) QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged) QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged) QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged) QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode) QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable) QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems) QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum) QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum) QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep) QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum) QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum) QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals) QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText) QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText) QDOC_PROPERTY(double doubleStep READ doubleStep WRITE setDoubleStep) public: enum InputDialogOption { NoButtons = 0x00000001, UseListViewForComboBoxItems = 0x00000002, UsePlainTextEditForTextInput = 0x00000004 }; Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption) enum InputMode { TextInput, IntInput, DoubleInput }; KInputDialog(QWidget *parent = nullptr); ~KInputDialog(); void setInputMode(InputMode mode); InputMode inputMode() const; void setLabelText(const QString &text); QString labelText() const; void setOption(InputDialogOption option, bool on = true); bool testOption(InputDialogOption option) const; void setOptions(InputDialogOptions options); InputDialogOptions options() const; void setTextValue(const QString &text); QString textValue() const; void setTextEchoMode(QLineEdit::EchoMode mode); QLineEdit::EchoMode textEchoMode() const; void setComboBoxEditable(bool editable); bool isComboBoxEditable() const; void setComboBoxItems(const QStringList &items); QStringList comboBoxItems() const; void setIntValue(int value); int intValue() const; void setIntMinimum(int min); int intMinimum() const; void setIntMaximum(int max); int intMaximum() const; void setIntRange(int min, int max); void setIntStep(int step); int intStep() const; void setDoubleValue(double value); double doubleValue() const; void setDoubleMinimum(double min); double doubleMinimum() const; void setDoubleMaximum(double max); double doubleMaximum() const; void setDoubleRange(double min, double max); void setDoubleDecimals(int decimals); int doubleDecimals() const; void setOkButtonText(const QString &text); QString okButtonText() const; void setCancelButtonText(const QString &text); QString cancelButtonText() const; using QDialog::open; void open(QObject *receiver, const char *member); QSize minimumSizeHint() const override; QSize sizeHint() const override; void setVisible(bool visible) override; /** * @brief since 1.2.0.12 * @return */ QString placeholderText() const; /** * @brief since 1.2.0.12 */ void setPlaceholderText(const QString &); static QString getText(QWidget *parent,const QString &label, QLineEdit::EchoMode echo = QLineEdit::Normal, const QString &text = QString(), bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints = Qt::ImhNone); static QString getMultiLineText(QWidget *parent,const QString &label, const QString &text = QString(), bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints = Qt::ImhNone); static QString getItem(QWidget *parent,const QString &label, const QStringList &items, int current = 0, bool editable = true, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints = Qt::ImhNone); static int getInt(QWidget *parent,const QString &label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); static double getDouble(QWidget *parent,const QString &label, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); void setDoubleStep(double step); double doubleStep() const; Q_SIGNALS: // ### emit signals! void textValueChanged(const QString &text); void textValueSelected(const QString &text); void intValueChanged(int value); void intValueSelected(int value); void doubleValueChanged(double value); void doubleValueSelected(double value); public: void done(int result) override; protected: void changeTheme(); private: KInputDialogPrivate* const d_ptr; Q_DISABLE_COPY(KInputDialog) Q_DECLARE_PRIVATE(KInputDialog) Q_PRIVATE_SLOT(d_ptr, void _q_textChanged(const QString&)) Q_PRIVATE_SLOT(d_ptr, void _q_plainTextEditTextChanged()) Q_PRIVATE_SLOT(d_ptr, void _q_currentRowChanged(const QModelIndex&, const QModelIndex&)) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KInputDialog::InputDialogOptions) } /** * @example testinputdialog/widget.h * @example testinputdialog/widget.cpp * @} */ #endif // KINPUTDIALOG_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpressbutton.h0000775000175000017500000000525014474244170023774 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KPRESSBUTTON_H #define KPRESSBUTTON_H #include "gui_g.h" #include #include namespace kdk { class KPressButtonPrivate; /** * @brief The KPressButton class since 1.2.0.10 */ class GUI_EXPORT KPressButton:public QPushButton { Q_OBJECT public: enum ButtonType{ NormalType, CircleType }; KPressButton(QWidget* parent = 0); /** * @brief 设置圆角 * @param radius */ void setBorderRadius(int radius); /** * @brief 设置圆角 * @param buttomLeft * @param topLeft * @param topRight * @param bottomRight */ void setBorderRadius(int bottomLeft,int topLeft,int topRight,int bottomRight); /** * @brief 设置是否可选中 * @param flag */ void setCheckable(bool); /** * @brief 返回是否可选中 * @return */ bool isCheckable() const; /** * @brief 设置是否选中 * @return */ void setChecked(bool); /** * @brief 返回是否选中 * @return */ bool isChecked() const; /** * @brief 设置button类型 * @param type */ void setButtonType(ButtonType type); /** * @brief 返回button类型 * @return */ KPressButton::ButtonType buttonType(); /** * @brief 设置是否启用loading状态 * @param flag */ void setLoaingStatus(bool flag); /** * @brief 返回是否启用loading状态 * @return */ bool isLoading(); /** * @brief 设置是否启用透明度 * @param flag */ void setTranslucent(bool flag); /** * @brief 返回是否启用透明度 * @return */ bool isTranslucent(); protected: void paintEvent(QPaintEvent *event) override; private: Q_DECLARE_PRIVATE(KPressButton) KPressButtonPrivate* const d_ptr; }; } #endif // KPRESSBUTTON_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kswitchbutton.cpp0000664000175000017500000003217614474244170024500 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include "kswitchbutton.h" #include "themeController.h" #include namespace kdk { class KSwitchButtonPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KSwitchButton) public: KSwitchButtonPrivate(KSwitchButton*parent) :q_ptr(parent) { setParent(parent); } protected: void changeTheme(); private: KSwitchButton* q_ptr; QTimer *m_pTimer; int m_space; //滑块离背景间隔 int m_rectRadius; //圆角角度 int m_step; //每次移动的步长 int m_startX; //滑块开始X轴坐标 int m_endX; //滑块结束X轴坐标 QColor m_sliderColor; QColor m_bkgStartColor; QColor m_bkgEndColor; bool m_isHoverd; bool m_isTranslucent; QLinearGradient m_linearGradient; void updateColor(const QStyleOptionButton& opt); void drawBackground(QPainter *painter); void drawSlider(QPainter *painter); void stepChanged(); }; KSwitchButton::KSwitchButton(QWidget* parent) :QPushButton(parent),d_ptr(new KSwitchButtonPrivate(this)) { Q_D(KSwitchButton); d->m_pTimer = nullptr; d->m_isHoverd = false; this->setCheckable(true); d->changeTheme(); connect(d->m_gsetting,&QGSettings::changed, d,&KSwitchButtonPrivate::changeTheme); d->m_pTimer = new QTimer(this); d->m_pTimer->setInterval(5); connect(d->m_pTimer,&QTimer::timeout,d,&KSwitchButtonPrivate::stepChanged); connect(this,&KSwitchButton::toggled,this,[=](bool flag) { d->m_endX = width()>height() ? width()-height() : 0; d->m_pTimer->start(); Q_EMIT stateChanged(flag); }); d->m_space = 4; } KSwitchButton::~KSwitchButton() { } void KSwitchButton::setCheckable(bool flag) { QPushButton::setCheckable(flag); this->update(); } bool KSwitchButton::isCheckable() const { return QPushButton::isCheckable(); } bool KSwitchButton::isChecked() const { return QPushButton::isChecked(); } void KSwitchButton::setChecked(bool flag) { Q_D(KSwitchButton); QPushButton::setChecked(flag); if(signalsBlocked()&& isEnabled()) { d->m_pTimer->start(); } this->update(); } void KSwitchButton::setTranslucent(bool flag) { Q_D(KSwitchButton); d->m_isTranslucent = flag; } bool KSwitchButton::isTranslucent() { Q_D(KSwitchButton); return d->m_isTranslucent; } void KSwitchButton::paintEvent(QPaintEvent *event) { Q_D(KSwitchButton); d->m_linearGradient = QLinearGradient(this->width()/2,0,this->width()/2,this->height()); QStyleOptionButton opt; initStyleOption(&opt); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); d->updateColor(opt); d->drawBackground(&painter); d->drawSlider(&painter); painter.drawText(0, 0, width(), height(), Qt::AlignCenter, text()); } void KSwitchButton::resizeEvent(QResizeEvent *event) { Q_D(KSwitchButton); QPushButton::resizeEvent(event); if (this->isChecked()) d->m_startX = width()>height() ? width()-height() : 0; else d->m_startX = 0; d->m_rectRadius = height() / 2; d->m_step = width()/50 >0 ?(width()/50):1; d->m_endX = width()>height() ? width()-height() : 0; } QSize KSwitchButton::sizeHint() const { return QSize(50,24); } void KSwitchButtonPrivate::changeTheme() { Q_Q(KSwitchButton); initThemeStyle(); q->update(); } void KSwitchButtonPrivate::updateColor(const QStyleOptionButton& opt) { Q_Q(KSwitchButton); //根据option状态去指定以下两个子部件的颜色 //m_sliderColor //m_bkgColor if(m_isTranslucent && !q->isChecked())//半透明效果 { m_sliderColor = QColor("#FFFFFF"); m_bkgStartColor = opt.palette.color(QPalette::BrightText); if(ThemeController::themeMode() == LightTheme) //浅色模式 { if(!opt.state.testFlag(QStyle::State_Enabled)) //disable { m_sliderColor = opt.palette.color(QPalette::BrightText); m_sliderColor.setAlphaF(0.16); m_bkgStartColor.setAlphaF(0.1); return; } m_bkgStartColor.setAlphaF(0.1); //normal if(opt.state.testFlag(QStyle::State_MouseOver)) { if (opt.state & QStyle::State_Sunken) //clicked { m_isHoverd = false; m_bkgStartColor.setAlphaF(0.21); } else //hover { m_isHoverd = true; m_bkgStartColor.setAlphaF(0.21); } } } else { if(!opt.state.testFlag(QStyle::State_Enabled)) //disable { m_sliderColor = opt.palette.color(QPalette::BrightText); m_sliderColor.setAlphaF(0.2); m_bkgStartColor.setAlphaF(0.1); return; } m_bkgStartColor.setAlphaF(0.1); //normal if(opt.state.testFlag(QStyle::State_MouseOver)) { if (opt.state & QStyle::State_Sunken) //clicked { m_isHoverd = false; m_bkgStartColor.setAlphaF(0.3); } else //hover { m_isHoverd = true; m_bkgStartColor.setAlphaF(0.2); } } } } else //常规效果 { if(!opt.state.testFlag(QStyle::State_Enabled)) { m_sliderColor = opt.palette.color(QPalette::Disabled,QPalette::ButtonText); m_bkgStartColor = opt.palette.color(QPalette::Disabled,QPalette::Button); return; } QColor mix = opt.palette.brightText().color(); m_sliderColor = QColor("#FFFFFF"); if(q->isChecked()) m_bkgStartColor = opt.palette.highlight().color(); else m_bkgStartColor = opt.palette.button().color(); if(opt.state.testFlag(QStyle::State_MouseOver)) { if (opt.state & QStyle::State_Sunken) //clicked { m_isHoverd = false; m_bkgStartColor = ThemeController::mixColor(m_bkgStartColor,mix,0.2); } else //hover { m_isHoverd = true; if(ThemeController::themeMode() == LightTheme) //浅色模式 { if(ThemeController::widgetTheme() == FashionTheme) //和印主题 { if(q->isChecked())//开启 { QColor startColor = opt.palette.color(QPalette::Highlight); QColor startLightColor("#E6E6E6"); QColor endLightColor("#000000"); m_bkgStartColor = ThemeController::mixColor(startColor,startLightColor,0.2); m_bkgEndColor = ThemeController::mixColor(startColor,endLightColor,0.05); m_linearGradient.setColorAt(0,m_bkgStartColor); m_linearGradient.setColorAt(1,m_bkgEndColor); } else //关闭 { QColor startColor("#E6E6E6"); QColor startLightColor("#000000 "); m_bkgStartColor = ThemeController::mixColor(startColor,startLightColor,0.05); m_bkgEndColor = ThemeController::mixColor(startColor,startLightColor,0.2); m_linearGradient.setColorAt(0,m_bkgStartColor); m_linearGradient.setColorAt(1,m_bkgEndColor); } } else //寻光主题 { m_bkgStartColor = ThemeController::mixColor(m_bkgStartColor,mix,0.05); } } else //深色模式 { if(ThemeController::widgetTheme() == FashionTheme) //和印主题 { if(q->isChecked())//开启 { QColor startColor = opt.palette.color(QPalette::Highlight); QColor startDarkColor("#FFFFFF"); m_bkgStartColor = ThemeController::mixColor(startColor,startDarkColor,0.2); m_bkgEndColor = startColor; m_linearGradient.setColorAt(0,m_bkgStartColor); m_linearGradient.setColorAt(1,m_bkgEndColor); } else //关闭 { QColor startColor("#373737"); QColor startDarkColor("#FFFFFF"); m_bkgStartColor = ThemeController::mixColor(startColor,startDarkColor,0.2); m_bkgEndColor = ThemeController::mixColor(startColor,startDarkColor,0.05); m_linearGradient.setColorAt(0,m_bkgStartColor); m_linearGradient.setColorAt(1,m_bkgEndColor); } } else //寻光 { m_bkgStartColor = ThemeController::mixColor(m_bkgStartColor,mix,0.05); // deafult } } } } } } void KSwitchButtonPrivate::drawBackground(QPainter *painter) { Q_Q(KSwitchButton); painter->save(); painter->setPen(Qt::NoPen); if(ThemeController::widgetTheme() == FashionTheme) { if(m_isHoverd) { m_isHoverd = false; if(m_isTranslucent && !q->isChecked()) painter->setBrush(m_bkgStartColor); else painter->setBrush(m_linearGradient); } else painter->setBrush(m_bkgStartColor); } else { m_isHoverd = false; painter->setBrush(m_bkgStartColor); } QRect rect(0, 0, q->width(), q->height()); //背景框两边是半圆,所以圆角的半径应该固定是矩形高度的一半 int radius = rect.height() / 2; int circleWidth = rect.height(); QPainterPath path; path.moveTo(radius, rect.top()); path.arcTo(QRectF(rect.left(), rect.top(), circleWidth, circleWidth), 90, 180); path.lineTo(rect.width() - radius, rect.height()); path.arcTo(QRectF(rect.width() - rect.height(), rect.top(), circleWidth, circleWidth), 270, 180); path.lineTo(radius, rect.top()); painter->drawPath(path); painter->restore(); } void KSwitchButtonPrivate::drawSlider(QPainter *painter) { Q_Q(KSwitchButton); painter->save(); painter->setBrush(m_sliderColor); painter->setPen(Qt::NoPen); //滑块的直径 int sliderWidth = q->height() - m_space * 2; QRect sliderRect(m_startX + m_space, m_space, sliderWidth, sliderWidth); painter->drawEllipse(sliderRect); if(!q->isEnabled()) { //绘制disenable状态下的小矩形条 if(!q->isChecked()) { int topX = q->width()-sliderWidth/2-10; int topY = (q->height()-sliderWidth/4)/2; QRect lineRect(topX,topY,sliderWidth/2,sliderWidth/4); int radius = lineRect.height()/2; painter->drawRoundedRect(lineRect,radius,radius); } else { int topX = 10; int topY = (q->height()-sliderWidth/4)/2; QRect lineRect(topX,topY,sliderWidth/2,sliderWidth/4); int radius = lineRect.height()/2; painter->drawRoundedRect(lineRect,radius,radius); } } painter->restore(); } void KSwitchButtonPrivate::stepChanged() { Q_Q(KSwitchButton); if(q->isChecked()) { if(m_startX < m_endX) { m_startX += m_step; } else { m_startX = m_endX; m_pTimer->stop(); } } else { if (m_startX > 0) { m_startX = m_startX - m_step; } else { m_startX = 0; m_pTimer->stop(); } } q->update(); } } #include "kswitchbutton.moc" #include "moc_kswitchbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kdialog.cpp0000664000175000017500000001546714474244170023206 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kdialog.h" #include #include #include "xatom-helper.h" #include "parmscontroller.h" #include "ukuistylehelper/ukui-decoration-manager.h" namespace kdk { class KDialogPrivate:public QObject { Q_OBJECT Q_DECLARE_PUBLIC(KDialog) public: KDialogPrivate(KDialog*parent); private: KDialog *q_ptr; KIconBar *m_pIconBar; KWindowButtonBar* m_pWindowButtonBar; QHBoxLayout* m_pTitleLayout; QVBoxLayout* m_pMainLayout; QWidget* m_pMainWidget; QString m_IconName; }; KDialog::KDialog(QWidget *parent) :QDialog(parent), d_ptr(new KDialogPrivate(this)) { Q_D(KDialog); setFocusPolicy(Qt::ClickFocus); setObjectName("Kdialog"); QString platform = QGuiApplication::platformName(); if(platform.startsWith(QLatin1String("xcb"),Qt::CaseInsensitive)) { MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_ALL; hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); } connect(d->m_pWindowButtonBar->minimumButton(),&QPushButton::clicked,this,&KDialog::showMinimized); connect(d->m_pWindowButtonBar->maximumButton(),&QPushButton::clicked,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); connect(d->m_pWindowButtonBar->closeButton(),&QPushButton::clicked,this,&KDialog::close); connect(d->m_pWindowButtonBar,&KWindowButtonBar::doubleClick,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); connect(d->m_pIconBar,&KIconBar::doubleClick,this,[=]() { if(this->isMaximized()) showNormal(); else showMaximized(); }); changeIconStyle(); connect(m_gsetting,&QGSettings::changed,this,[=](){changeIconStyle();}); changeTheme(); connect(m_gsetting,&QGSettings::changed,this,&KDialog::changeTheme); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); }); installEventFilter(this); resize(600,480); } KDialog::~KDialog() { } void KDialog::setWindowIcon(const QIcon &icon) { Q_D(KDialog); d->m_pIconBar->setIcon(icon); d->m_IconName = icon.name(); QWidget::setWindowIcon(icon.pixmap(QSize(36,36))); } void KDialog::setWindowIcon(const QString &iconName) { Q_D(KDialog); d->m_IconName = iconName; d->m_pIconBar->setIcon(iconName); QWidget::setWindowIcon(QIcon::fromTheme(iconName).pixmap(QSize(36,36))); } void KDialog::setWindowTitle(const QString &title) { Q_D(KDialog); QVariant value = this->property("isAboutDialog"); if(value.isNull() || !value.toBool()) { d->m_pIconBar->setWidgetName(title); } QDialog::setWindowTitle(title); } QPushButton *KDialog::maximumButton() { Q_D(KDialog); return d->m_pWindowButtonBar->maximumButton(); } QPushButton *KDialog::minimumButton() { Q_D(KDialog); return d->m_pWindowButtonBar->minimumButton(); } QPushButton *KDialog::closeButton() { Q_D(KDialog); return d->m_pWindowButtonBar->closeButton(); } KMenuButton *KDialog::menuButton() { Q_D(KDialog); return d->m_pWindowButtonBar->menuButton(); } QWidget *KDialog::mainWidget() { Q_D(KDialog); if(d->m_pMainWidget) return d->m_pMainWidget; } bool KDialog::eventFilter(QObject *target, QEvent *event) { Q_D(KDialog); if(target == this && (event->type() == QEvent::WindowStateChange || event->type() == QEvent::Show)) { if(this->isMaximized()) d->m_pWindowButtonBar->setMaximumButtonState(MaximumButtonState::Restore); else d->m_pWindowButtonBar->setMaximumButtonState(MaximumButtonState::Maximum); } if(target == this && (event->type() == QEvent::WindowActivate|| event->type() == QEvent::WindowDeactivate)) { changeTheme(); } QString platform = QGuiApplication::platformName(); if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { if((event->type() == QEvent::PlatformSurface || event->type() == QEvent::Show || event->type() == QEvent::Paint)) { UKUIDecorationManager::getInstance()->removeHeaderBar(this->windowHandle()); } } return QDialog::eventFilter(target, event); } void KDialog::changeTheme() { Q_D(KDialog); initThemeStyle(); QPalette p = this->palette(); QColor color = p.color(QPalette::Base); p.setColor(QPalette::Window,color); this->setPalette(p); if(!d->m_IconName.isEmpty()) this->setWindowIcon(d->m_IconName); } void KDialog::changeIconStyle() { Q_D(KDialog); initThemeStyle(); setWindowIcon(d->m_IconName); } QBoxLayout *KDialog::mainLayout() { Q_D(KDialog); return d->m_pMainLayout; } KDialogPrivate::KDialogPrivate(KDialog *parent) :q_ptr(parent) { Q_Q(KDialog); m_pMainLayout = new QVBoxLayout(q); m_pTitleLayout = new QHBoxLayout(); m_pTitleLayout->setContentsMargins(0,0,0,0); m_pTitleLayout->setSpacing(0); m_pTitleLayout = new QHBoxLayout; m_pIconBar = new KIconBar(q); m_pWindowButtonBar = new KWindowButtonBar(q); m_pTitleLayout->addWidget(m_pIconBar); m_pTitleLayout->addWidget(m_pWindowButtonBar); m_pMainWidget = new QWidget(q); m_pMainLayout->setSpacing(0); m_pMainLayout->setContentsMargins(0,0,0,0); m_pMainLayout->addLayout(m_pTitleLayout,Qt::AlignTop); m_pMainLayout->addWidget(m_pMainWidget); //暂时先默认只显示关闭按钮 m_pWindowButtonBar->maximumButton()->hide(); m_pWindowButtonBar->menuButton()->hide(); m_pWindowButtonBar->minimumButton()->hide(); connect(m_pWindowButtonBar->minimumButton(),&QPushButton::clicked,q,&KDialog::showMinimized); connect(m_pWindowButtonBar->closeButton(),&QPushButton::clicked,q,&KDialog::close); setParent(parent); } } #include "kdialog.moc" #include "moc_kdialog.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbackgroundgroup.cpp0000664000175000017500000003542314474244170025135 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kbackgroundgroup.h" #include "themeController.h" #include #include "klineframe.h" #include #include #include 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 m_pwidgetList; QList 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 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 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 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 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;indexm_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(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" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kbuttonbox.cpp0000664000175000017500000001654014474244170023764 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kbuttonbox.h" #include #include #include #include #include #include #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 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 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 &list) { Q_D(KButtonBox); d->m_buttonList = list; d->updateButtonList(); } QList 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(d->m_buttonGroup->checkedButton()); return button; } KPushButton *KButtonBox::button(int id) { Q_D(KButtonBox); KPushButton * button = dynamic_cast(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 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" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktabbar.cpp0000664000175000017500000006556514474244170023206 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ktabbar.h" #include "themeController.h" #include #include #include #include #include #include #include #include #include "parmscontroller.h" namespace kdk { class KTabBarPrivate:public QObject,public ThemeController { Q_OBJECT Q_DECLARE_PUBLIC(KTabBar) public: KTabBarPrivate(KTabBar*parent) :q_ptr(parent) { setParent(parent); } void changeTheme(); private: KTabBar*q_ptr; KTabBarStyle m_kTabBarStyle; int m_borderRadius = 6; int m_horizontalMargin = 1; int m_topMargin = 0; QColor m_bkgrdColor; bool m_useCustomColor; }; KTabBar::KTabBar(KTabBarStyle barStyle,QWidget* parent): QTabBar(parent), d_ptr(new KTabBarPrivate(this)) { Q_D(KTabBar); d->m_borderRadius = 6; 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(); }); } KTabBar::~KTabBar() { } void KTabBar::setTabBarStyle(KTabBarStyle barStyle) { Q_D(KTabBar); d->m_kTabBarStyle = barStyle; d->changeTheme(); } KTabBarStyle KTabBar::barStyle() { Q_D(KTabBar); return d->m_kTabBarStyle; } void KTabBar::setBorderRadius(int radius) { Q_D(KTabBar); if(radius < 0 || radius > 20) return; d->m_borderRadius = radius; update(); } int KTabBar::borderRadius() { Q_D(KTabBar); if(d->m_kTabBarStyle == Sliding) return 0; else return d->m_borderRadius; } void KTabBar::setBackgroundColor(const QColor &color) { Q_D(KTabBar); d->m_useCustomColor = true; d->m_bkgrdColor = color; } QSize KTabBar::sizeHint() const { auto size = QTabBar::sizeHint(); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_TabBarHeight)); return size; } QSize KTabBar::minimumTabSizeHint(int index) const { Q_UNUSED(index) QSize size(100,Parmscontroller::parm(Parmscontroller::Parm::PM_PushButtonHeight)); return size; } QSize KTabBar::tabSizeHint(int index) const { Q_UNUSED(index) //判断外部是否设置了固定宽度或者固定高度,如果设置,走默认的tabSizeHint if((this->maximumHeight() == this->minimumHeight()) ||this->maximumWidth()==this->minimumWidth()) return QTabBar::tabSizeHint(index); auto size = QTabBar::tabSizeHint(index); size.setHeight(Parmscontroller::parm(Parmscontroller::Parm::PM_TabBarHeight)); return size; } 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; QFontMetrics fm = p.fontMetrics(); for (int i = 0; i < count(); ++i) { 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: { mix = option.palette.brightText().color(); fontColor = option.palette.buttonText().color(); QColor bkgrdColor = d->m_bkgrdColor; if(option.state.testFlag(QStyle::State_Selected)) { bkgrdColor = option.palette.highlight().color(); fontColor = QColor("#FFFFFF"); } else if(option.state.testFlag(QStyle::State_MouseOver)) { bkgrdColor = ThemeController::mixColor(bkgrdColor,mix,0.05); } if(option.position == QStyleOptionTab::Middle) { p.save(); p.setBrush(bkgrdColor); p.setPen(Qt::NoPen); //利用quadto绘制圆角矩形会出现一个像素的偏差,修正一下QRect底部高度 p.drawRect(rect.adjusted(0,0,0,-1)); p.restore(); p.setBrush(Qt::NoBrush); p.setPen(fontColor); QPoint point; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!tabText(i).isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, tabText(i)).width() + 2; point = QPoint(rect.x() + rect.width() / 2 - w / 2, rect.y() + rect.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) p.drawPixmap(option.rect.x()+4,this->style()->visualPos(option.direction, option.rect, point).y(), pixmap); else p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (!tabText(i).isEmpty()){ int subH = std::max(option.iconSize.height(),option.fontMetrics.height()); int icon_Y = (rect.height() - subH) / 2; int text_X = point.x() + option.iconSize.width() + 4; int text_Y = icon_Y; QRect textRect; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) { textRect = QRect(option.rect.x()+option.iconSize.width()+8, text_Y, option.rect.width()-option.iconSize.width()-7, option.fontMetrics.height()); setTabToolTip(i,tabText(i)); QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()-option.iconSize.width()-7); p.drawText(textRect,tf,elidedText); } else { textRect=QRect(text_X, text_Y, option.fontMetrics.width(tabText(i)), option.fontMetrics.height()); setTabToolTip(i,""); p.drawText(textRect,tf,tabText(i)); } } } else { tf |= Qt::AlignHCenter; if(fm.width(tabText(i)) >= option.rect.width()) { QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()); p.drawText(rect,tf,elidedText); setTabToolTip(i,tabText(i)); } else { setTabToolTip(i,""); p.drawText(rect,tf,tabText(i)); } } } else if(option.position == QStyleOptionTab::Beginning) { p.save(); p.setBrush(bkgrdColor); p.setPen(Qt::NoPen); QPainterPath path; auto tempRect = rect.adjusted(0,0,1,0); path.moveTo(tempRect.topLeft() + QPointF(0, d->m_borderRadius)); path.lineTo(tempRect.bottomLeft() - QPointF(0, d->m_borderRadius)); path.quadTo(tempRect.bottomLeft(), tempRect.bottomLeft() + QPointF(d->m_borderRadius, 0)); path.lineTo(tempRect.bottomRight()); path.lineTo(tempRect.topRight()); path.lineTo(tempRect.topLeft() + QPointF(d->m_borderRadius, 0)); path.quadTo(tempRect.topLeft(), tempRect.topLeft() + QPointF(0, d->m_borderRadius)); p.drawPath(path); p.restore(); p.setBrush(Qt::NoBrush); p.setPen(fontColor); QPoint point; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!tabText(i).isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, tabText(i)).width() + 2; point = QPoint(rect.x() + rect.width() / 2 - w / 2, rect.y() + rect.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) p.drawPixmap(option.rect.x()+4,this->style()->visualPos(option.direction, option.rect, point).y(), pixmap); else p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (option.direction == Qt::RightToLeft) rect.translate(-point.x() - 2, 0); else rect.translate(point.x() + w + 4, 0); if (!tabText(i).isEmpty()){ tf |= Qt::AlignLeft; int subH = std::max(option.iconSize.height(),option.fontMetrics.height()); int icon_Y = (rect.height() - subH) / 2; int text_X = point.x() + option.iconSize.width() + 4; int text_Y = icon_Y; QRect textRect; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) { textRect = QRect(option.rect.x()+option.iconSize.width()+8, text_Y, option.rect.width()-option.iconSize.width()-8, option.fontMetrics.height()); setTabToolTip(i,tabText(i)); QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()-option.iconSize.width()-8); p.drawText(textRect,tf,elidedText); } else { textRect=QRect(text_X, text_Y, option.fontMetrics.width(tabText(i)), option.fontMetrics.height()); setTabToolTip(i,""); p.drawText(textRect,tf,tabText(i)); } } } else { tf |= Qt::AlignHCenter; if(fm.width(tabText(i)) >= option.rect.width()) { QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()); p.drawText(rect,tf,elidedText); setTabToolTip(i,tabText(i)); } else { p.drawText(rect,tf,tabText(i)); setTabToolTip(i,""); } } } else { p.save(); p.setBrush(bkgrdColor); p.setPen(Qt::NoPen); QPainterPath path; path.moveTo(rect.topLeft()); path.lineTo(rect.bottomLeft()); path.lineTo(rect.bottomRight() - QPointF(d->m_borderRadius,0)); path.quadTo(rect.bottomRight(), rect.bottomRight() - QPointF(0, d->m_borderRadius)); path.lineTo(rect.topRight() + QPointF(0, d->m_borderRadius)); path.quadTo(rect.topRight(), rect.topRight() - QPointF(d->m_borderRadius,0)); path.lineTo(rect.topLeft()); p.drawPath(path); p.restore(); p.setBrush(Qt::NoBrush); p.setPen(fontColor); QPoint point; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!tabText(i).isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, tabText(i)).width() + 4; point = QPoint(rect.x() + rect.width() / 2 - w / 2, rect.y() + rect.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) p.drawPixmap(option.rect.x()+4,this->style()->visualPos(option.direction, option.rect, point).y(), pixmap); else p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (!tabText(i).isEmpty()){ int subH = std::max(option.iconSize.height(),option.fontMetrics.height()); int icon_Y = (rect.height() - subH) / 2; int text_X = point.x() + option.iconSize.width() + 4; int text_Y = icon_Y; QRect textRect; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) { textRect = QRect(option.rect.x()+option.iconSize.width()+8, text_Y, option.rect.width()-option.iconSize.width()-8, option.fontMetrics.height()); setTabToolTip(i,tabText(i)); QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()-option.iconSize.width()-8); p.drawText(textRect,elidedText); } else { textRect=QRect(text_X, text_Y, option.fontMetrics.width(tabText(i)), option.fontMetrics.height()); setTabToolTip(i,""); p.drawText(textRect,tabText(i)); } } } else { tf |= Qt::AlignHCenter; if(fm.width(tabText(i)) >= option.rect.width()) { QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()); p.drawText(rect,tf,elidedText); setTabToolTip(i,tabText(i)); } else { p.drawText(rect,tf,tabText(i)); setTabToolTip(i,""); } } } break; } case SegmentLight: { mix = option.palette.brightText().color(); fontColor = option.palette.buttonText().color(); QColor bkgrdColor = d->m_bkgrdColor; if(option.state.testFlag(QStyle::State_Selected)) { bkgrdColor = option.palette.highlight().color(); fontColor = QColor("#FFFFFF"); } else if(option.state.testFlag(QStyle::State_MouseOver)) { bkgrdColor = ThemeController::mixColor(bkgrdColor,mix,0.05); } p.save(); p.setBrush(bkgrdColor); p.setPen(Qt::NoPen); 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); /*QRect*/ rect = /*option.*/rect.adjusted(d->m_horizontalMargin,0,0,-d->m_topMargin); QPoint point; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!tabText(i).isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, tabText(i)).width() + 2; point = QPoint(rect.x() + rect.width() / 2 - w / 2, rect.y() + rect.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) p.drawPixmap(option.rect.x()+4,this->style()->visualPos(option.direction, option.rect, point).y(), pixmap); else p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (!tabText(i).isEmpty()){ int subH = std::max(option.iconSize.height(),option.fontMetrics.height()); int icon_Y = (rect.height() - subH) / 2; int text_X = point.x() + option.iconSize.width() + 4; int text_Y = icon_Y; QRect textRect; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) { textRect = QRect(option.rect.x()+option.iconSize.width()+8, text_Y, option.rect.width()-option.iconSize.width()-8, option.fontMetrics.height()); setTabToolTip(i,tabText(i)); QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()-option.iconSize.width()-8); p.drawText(textRect,elidedText); } else { textRect=QRect(text_X, text_Y, option.fontMetrics.width(tabText(i)), option.fontMetrics.height()); setTabToolTip(i,""); p.drawText(textRect,tabText(i)); } } } else { tf |= Qt::AlignHCenter; if(fm.width(tabText(i)) >= option.rect.width()) { QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()); p.drawText(rect,tf,elidedText); setTabToolTip(i,tabText(i)); } else { p.drawText(rect,tf,tabText(i)); setTabToolTip(i,""); } } break; } case Sliding: { mix = option.palette.brightText().color(); fontColor = option.palette.buttonText().color(); QColor bkgrdColor = d->m_bkgrdColor; if(option.state.testFlag(QStyle::State_Selected)) { bkgrdColor = option.palette.highlight().color(); fontColor = option.palette.highlight().color(); } else if(option.state.testFlag(QStyle::State_MouseOver)) { bkgrdColor = ThemeController::mixColor(bkgrdColor,mix,0.05); } p.save(); QPen pen; pen.setColor(bkgrdColor); pen.setWidth(2); p.setPen(pen); /*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); QPoint point; uint tf = Qt::AlignVCenter; if (!option.icon.isNull()) { QIcon::Mode mode = option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && option.state & QStyle::State_HasFocus) mode = QIcon::Active; QIcon::State state = QIcon::Off; if (option.state & QStyle::State_On) state = QIcon::On; QPixmap pixmap = option.icon.pixmap(option.iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); if (!tabText(i).isEmpty()) w += option.fontMetrics.boundingRect(option.rect, tf, tabText(i)).width() + 2; point = QPoint(rect.x() + rect.width() / 2 - w / 2, rect.y() + rect.height() / 2 - h / 2); w = pixmap.width() / pixmap.devicePixelRatio(); if (option.direction == Qt::RightToLeft) point.rx() += w; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) p.drawPixmap(option.rect.x()+4,this->style()->visualPos(option.direction, option.rect, point).y(), pixmap); else p.drawPixmap(this->style()->visualPos(option.direction, option.rect, point), pixmap); if (!tabText(i).isEmpty()){ int subH = std::max(option.iconSize.height(),option.fontMetrics.height()); int icon_Y = (rect.height() - subH) / 2; int text_X = point.x() + option.iconSize.width() + 4; int text_Y = icon_Y; QRect textRect; if(fm.width(tabText(i)) >= option.rect.width()-option.iconSize.width()-7) { textRect = QRect(option.rect.x()+option.iconSize.width()+8, text_Y, option.rect.width()-option.iconSize.width()-8, option.fontMetrics.height()); setTabToolTip(i,tabText(i)); QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()-option.iconSize.width()-8); p.drawText(textRect,elidedText); } else { textRect=QRect(text_X, text_Y, option.fontMetrics.width(tabText(i)), option.fontMetrics.height()); setTabToolTip(i,""); p.drawText(textRect,tabText(i)); } } } else { tf |= Qt::AlignHCenter; if(fm.width(tabText(i)) >= option.rect.width()) { QString elidedText = fm.elidedText(tabText(i),Qt::ElideRight,option.rect.width()); p.drawText(rect,tf,elidedText); setTabToolTip(i,tabText(i)); } else { p.drawText(rect,tf,tabText(i)); setTabToolTip(i,""); } } break; } default: break; } } } void KTabBarPrivate::changeTheme() { Q_Q(KTabBar); switch (m_kTabBarStyle) { case SegmentDark: { if(m_useCustomColor) return; else m_bkgrdColor = q->palette().button().color(); break; } case SegmentLight: { if(m_useCustomColor) return; else m_bkgrdColor = QColor(0,0,0,0); break; } case Sliding: if(m_useCustomColor) return; else m_bkgrdColor = q->palette().button().color(); break; default: break; } ; q->update(); } } #include "ktabbar.moc" #include "moc_ktabbar.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kprogressbar.h0000664000175000017500000000377014474244170023737 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KPROGRESSBAR_H #define KPROGRESSBAR_H #include "gui_g.h" #include namespace kdk { /** @defgroup bar模块 * @{ */ /** * @brief 支持三种状态 */ enum ProgressBarState { NormalProgress, FailedProgress, SuccessProgress }; class KProgressBarPrivate; /** * @brief 进度条,支持三种状态显示 */ class GUI_EXPORT KProgressBar:public QProgressBar { Q_OBJECT public: KProgressBar(QWidget*parent); /** * @brief 获取状态 * @return */ ProgressBarState state(); /** * @brief 设置状态 * @param state */ void setState(ProgressBarState state); /** * @brief 获取文本 * @return */ QString text() const override; /** * @brief 设置方向 */ void setOrientation(Qt::Orientation); /** * @brief 设置进度条宽度 * @param width */ void setBodyWidth(int width); protected: void paintEvent(QPaintEvent *event) override; QSize sizeHint() const; private: Q_DECLARE_PRIVATE(KProgressBar) KProgressBarPrivate* const d_ptr; }; } /** * @example testprogressbar/widget.h * @example testprogressbar/widget.cpp * @} */ #endif // KPROGRESSBAR_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klineframe.cpp0000664000175000017500000000762014474244170023701 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "klineframe.h" #include "themeController.h" #include #include 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" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/klistviewdelegate.h0000664000175000017500000000307614474244170024746 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef KLISTVIEWDELEGATE_H #define KLISTVIEWDELEGATE_H #include #include #include #include "themeController.h" #include namespace kdk { class KListViewDelegatePrivate; class KListViewDelegate :public QStyledItemDelegate,public ThemeController { Q_OBJECT public: KListViewDelegate(QAbstractItemView*parent); ~KListViewDelegate(); protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;//重写绘制事件 virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; private: Q_DECLARE_PRIVATE(KListViewDelegate); KListViewDelegatePrivate* const d_ptr; }; } #endif // KLISTVIEWDELEGATE_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/kpasswordedit.h0000664000175000017500000000614114474244170024111 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KPASSWORDEDIT_H #define KPASSWORDEDIT_H #include "gui_g.h" #include namespace kdk { /** @defgroup 输入框模块 * @{ */ /** * @brief 支持三种状态 */ enum LoginState { Ordinary, LoginSuccess, LoginFailed }; class KPasswordEditPrivate; /** * @brief 密码输入框 */ class GUI_EXPORT KPasswordEdit:public QLineEdit { Q_OBJECT public: KPasswordEdit(QWidget*parent); /** * @brief 设置状态 * @param state */ void setState(LoginState state); /** * @brief 返回状态 * @return */ LoginState state(); /** * @brief 设置加载状态 * @param flag */ void setLoading(bool flag); /** * @brief 判断是否处于加载状态 * @return */ bool isLoading(); /** * @brief 返回placeholderText * @return */ QString placeholderText(); /** * @brief 设置PlaceholderText * @param text */ void setPlaceholderText(QString&text); /** * @brief 设置是否启用ClearButton * @param enable */ void setClearButtonEnabled(bool enable); /** * @brief 返回是否启用了ClearButton * @return */ bool isClearButtonEnabled() const; /** * @brief 设置EchoModeBtn是否可见 * @return */ void setEchoModeBtnVisible(bool enable); /** * @brief 返回EchoModeBtn是否可见 * @return */ bool echoModeBtnVisible(); /** * @brief 设置ClearBtn是否可见 * @return */ void setClearBtnVisible(bool enable); /** * @brief 返回ClearBtn是否可见 * @return */ bool clearBtnVisible(); /** * @brief 设置KLineEdit是否可用 * @return */ void setEnabled(bool); /** * @brief setEchoMode */ void setEchoMode(EchoMode mode); /** * @brief 设置是否走默认palette * @param flag */ void setUseCustomPalette(bool flag); protected: void resizeEvent(QResizeEvent*event); bool eventFilter(QObject *watched, QEvent *event); QSize sizeHint() const override; private: Q_DECLARE_PRIVATE(KPasswordEdit) KPasswordEditPrivate* const d_ptr; }; } /** * @example testpasswordedit/widget.h * @example testpasswordedit/widget.cpp * @} */ #endif // KPASSWORDEDIT_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/ktoolbutton.cpp0000664000175000017500000003357714474244170024162 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "ktoolbutton.h" #include "themeController.h" #include #include #include #include #include #include #include "parmscontroller.h" namespace kdk { class KToolButtonPrivate:public QObject, public ThemeController { Q_DECLARE_PUBLIC(KToolButton) Q_OBJECT public: KToolButtonPrivate(KToolButton* parent); ~KToolButtonPrivate(){} void changePalette(); void doLoadingFlash(); protected: void changeTheme(); private: KToolButton* q_ptr; KToolButtonType m_type; QLinearGradient m_pLinearGradient; bool m_isLoading; QTimer *m_pTimer; int m_flashState; bool m_hasArrow; QPixmap m_arrowPixmap; QColor m_pixColor; QColor m_bkgColor; QColor m_clickColor; QColor m_focusColor; QColor m_hoverColor; QColor m_disableColor; QSize m_pixmapSize; }; KToolButton::KToolButton(QWidget *parent) :QToolButton(parent), d_ptr(new KToolButtonPrivate(this)) { Q_D(KToolButton); d->m_pTimer = new QTimer(this); d->m_pTimer->setInterval(100); d->m_flashState = 0; d->m_isLoading = false; setType(Flat); installEventFilter(this); QToolButton::setIcon(QIcon::fromTheme("open-menu-symbolic")); setFocusPolicy(Qt::FocusPolicy::ClickFocus); d->changeTheme(); connect(d->m_gsetting,&QGSettings::changed,d,&KToolButtonPrivate::changeTheme); connect(d->m_pTimer,&QTimer::timeout,d,&KToolButtonPrivate::doLoadingFlash); connect(Parmscontroller::self(),&Parmscontroller::modeChanged,this,[=](){ updateGeometry(); }); } KToolButtonType KToolButton::type() { Q_D(KToolButton); return d->m_type; } void KToolButton::setType(KToolButtonType type) { Q_D(KToolButton); d->m_type = type; d->changePalette(); } void KToolButton::setIcon(const QIcon &icon) { Q_D(KToolButton); QToolButton::setIcon(icon); d->changeTheme(); } void KToolButton::setLoading(bool flag) { Q_D(KToolButton); if(!isEnabled()) return; if(hasArrow()) return; d->m_isLoading = flag; if(flag) d->m_pTimer->start(); else d->m_pTimer->stop(); } bool KToolButton::isLoading() { Q_D(KToolButton); return d->m_isLoading; } QIcon KToolButton::icon() { return QToolButton::icon(); } void KToolButton::setArrow(bool flag) { Q_D(KToolButton); if(!d->m_isLoading) d->m_hasArrow = flag; update(); } bool KToolButton::hasArrow() const { Q_D(const KToolButton); return d->m_hasArrow; } bool KToolButton::eventFilter(QObject *watched, QEvent *event) { Q_D(KToolButton); QColor highlightColor = this->palette().color(QPalette::Highlight); if(watched == this) { //根据不同状态重绘icon颜色 switch (event->type()) { case QEvent::MouseButtonPress: if(isEnabled()&& !d->m_isLoading) { if (ThemeController::themeMode() == LightTheme) d->m_pixColor = highlightColor.darker(120); else d->m_pixColor = highlightColor.lighter(120); } break; case QEvent::Enter: if(isEnabled()&& !d->m_isLoading) { if (ThemeController::themeMode() == LightTheme) d->m_pixColor = highlightColor.darker(105); else d->m_pixColor = highlightColor.lighter(105); } break; case QEvent::FocusIn: if(isEnabled()&& !d->m_isLoading) { if (ThemeController::themeMode()== LightTheme) d->m_pixColor = highlightColor.darker(120); else d->m_pixColor = highlightColor.lighter(120); } break; case QEvent::EnabledChange: { if(!isEnabled()&& !d->m_isLoading) { if(d->m_isLoading) { d->m_isLoading = false; d->m_pTimer->stop(); } if (ThemeController::themeMode() == LightTheme) d->m_pixColor = QColor(191,191,191); else d->m_pixColor = QColor(95,99,104); } } break; case QEvent::MouseButtonRelease: if(isEnabled()&& !d->m_isLoading) { if (ThemeController::themeMode() == LightTheme) d->m_pixColor = highlightColor.darker(105); else d->m_pixColor = highlightColor.lighter(105); } break; case QEvent::Paint: case QEvent::Leave: case QEvent::FocusOut: if(isEnabled()&& !d->m_isLoading) { if (ThemeController::themeMode() == LightTheme) d->m_pixColor = QColor(31,32,34); else d->m_pixColor = QColor(255,255,255); } break; default: break; } } return QToolButton::eventFilter(watched,event); } QSize KToolButton::sizeHint() const { Q_D(const KToolButton); 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; } void KToolButton::paintEvent(QPaintEvent *event) { Q_D( KToolButton); d->m_pLinearGradient.setStart(this->width()/2,0); d->m_pLinearGradient.setFinalStop(this->width()/2,this->height()); QPainter painter(this); painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); //绘制边框 QStyleOptionToolButton option; initStyleOption(&option); d->m_arrowPixmap = QIcon::fromTheme("ukui-down-symbolic").pixmap(option.iconSize); QPen pen; QColor color = palette().color(QPalette::Highlight); pen.setColor(color); pen.setWidth(2); if((QStyle::State_HasFocus & option.state) && isEnabled() && !isLoading() &&(this->focusPolicy() != Qt::FocusPolicy::NoFocus)) painter.setPen(pen); else painter.setPen(Qt::NoPen); if(!isEnabled()) painter.setBrush(d->m_disableColor); else if(QStyle::State_Sunken & option.state && !isLoading()) painter.setBrush(d->m_clickColor); else if(QStyle::State_MouseOver & option.state && !isLoading()) { if(ThemeController::widgetTheme()==FashionTheme && type() != Flat) { painter.setBrush(d->m_pLinearGradient); } else { painter.setBrush(d->m_hoverColor); } } else if(QStyle::State_HasFocus & option.state && !isLoading()) painter.setBrush(d->m_focusColor); else painter.setBrush(d->m_bkgColor); painter.drawRoundedRect(this->rect().adjusted(1,1,-1,-1),6,6); //绘制图标 QRect rect(0,0,option.iconSize.width(),option.iconSize.height()); QPixmap pixmap = this->icon().pixmap(option.iconSize); if(d->m_type == KToolButtonType::Flat || !isEnabled()) pixmap = ThemeController::drawColoredPixmap(pixmap,d->m_pixColor); else if(ThemeController::themeMode() == DarkTheme) pixmap = ThemeController::drawSymbolicColoredPixmap(pixmap); if(!hasArrow()) { rect.moveCenter(this->rect().center()); painter.drawPixmap(rect,pixmap); } else { QRect newRect = this->rect().adjusted(0,0,-20,0); rect.moveCenter(newRect.center()); this->style()->drawItemPixmap(&painter,rect,Qt::AlignCenter,pixmap); QRect arrowRect(0,0,option.iconSize.width(),option.iconSize.height()); arrowRect.moveLeft(this->rect().width()-option.iconSize.width()-8); arrowRect.moveTop((this->height()-option.iconSize.height())/2); QPixmap arrowPixmap = d->m_arrowPixmap; if(d->m_type == KToolButtonType::Flat || !isEnabled()) arrowPixmap = ThemeController::drawColoredPixmap(arrowPixmap,d->m_pixColor); else if(ThemeController::themeMode() == DarkTheme) arrowPixmap = ThemeController::drawSymbolicColoredPixmap(arrowPixmap); painter.drawPixmap(arrowRect,arrowPixmap); } } KToolButtonPrivate::KToolButtonPrivate(KToolButton *parent) :q_ptr(parent), m_hasArrow(false) { m_hoverColor = Qt::transparent; m_bkgColor = Qt::transparent; m_disableColor = Qt::transparent; m_clickColor = Qt::transparent; m_focusColor = Qt::transparent; setParent(parent); } void KToolButtonPrivate::changePalette() { Q_Q(KToolButton); switch (this->m_type) { case Flat: { if(ThemeController::themeMode() == LightTheme) { m_bkgColor = Qt::transparent; m_clickColor = Qt::transparent; m_focusColor = Qt::transparent; m_hoverColor = Qt::transparent; m_disableColor = Qt::transparent; } else { m_bkgColor = Qt::transparent; m_clickColor = Qt::transparent; m_focusColor = Qt::transparent; m_hoverColor = Qt::transparent; m_disableColor = q->palette().color(QPalette::Disabled,QPalette::Button); } break; } case SemiFlat: { QColor baseColor = q->palette().button().color(); QColor mix = q->palette().brightText().color(); m_bkgColor = Qt::transparent; m_clickColor = mixColor(baseColor,mix,0.2); m_focusColor = Qt::transparent; if(ThemeController::widgetTheme() == FashionTheme) { if(ThemeController::themeMode() == LightTheme) { QColor color("#E6E6E6"); QColor startColor = mixColor(color,QColor(Qt::black),0.05);//("#FFD9D9D9"); QColor endColor = mixColor(color,QColor(Qt::black),0.2);//("#FFBFBFBF"); m_pLinearGradient.setColorAt(0,startColor); m_pLinearGradient.setColorAt(1,endColor); } else { QColor color("#373737"); QColor startColor = mixColor(color,QColor(Qt::white),0.2);//("#FF5F5F5F"); QColor endColor = mixColor(color,QColor(Qt::white),0.05);//("#FF414141"); m_pLinearGradient.setColorAt(0,startColor); m_pLinearGradient.setColorAt(1,endColor); } } else { m_hoverColor = mixColor(baseColor,mix,0.05); } m_disableColor = Qt::transparent; break; } case Background: { QColor baseColor = q->palette().button().color(); QColor mix = q->palette().brightText().color(); m_bkgColor = baseColor; m_clickColor = mixColor(baseColor,mix,0.2); m_focusColor = baseColor; if(ThemeController::widgetTheme()==FashionTheme) { if(ThemeController::themeMode() == LightTheme) { QColor color("#E6E6E6"); QColor startColor = mixColor(color,QColor(Qt::black),0.05);//("#FFD9D9D9"); QColor endColor = mixColor(color,QColor(Qt::black),0.2);//("#FFBFBFBF"); m_pLinearGradient.setColorAt(0,startColor); m_pLinearGradient.setColorAt(1,endColor); } else { QColor color("#373737"); QColor startColor = mixColor(color,QColor(Qt::white),0.2);//("#FF5F5F5F"); QColor endColor = mixColor(color,QColor(Qt::white),0.05);//("#FF414141"); m_pLinearGradient.setColorAt(0,startColor); m_pLinearGradient.setColorAt(1,endColor); } } else { m_hoverColor = mixColor(baseColor,mix,0.05); } m_disableColor = q->palette().color(QPalette::Disabled,QPalette::Button); break; } default: break; } } void KToolButtonPrivate::doLoadingFlash() { Q_Q(KToolButton); if(m_flashState < 7) m_flashState++; else m_flashState = 0; if (ThemeController::themeMode() == LightTheme) { q->QToolButton::setIcon(QIcon::fromTheme(QString("ukui-loading-%1.symbolic").arg(m_flashState))); } else { q->QToolButton::setIcon(ThemeController::drawColoredPixmap(QIcon::fromTheme(QString("ukui-loading-%1.symbolic").arg(m_flashState)).pixmap(q->iconSize()),QColor(255,255,255))); } } void KToolButtonPrivate::changeTheme() { Q_Q(KToolButton); initThemeStyle(); changePalette(); if (ThemeController::themeMode() == LightTheme) { if(q->isEnabled()) m_pixColor = QColor(31,32,34); else m_pixColor = QColor(191,191,191); } else { if(q->isEnabled()) m_pixColor = QColor(255,255,255); else m_pixColor = QColor(95,99,104); } } } #include "ktoolbutton.moc" #include "moc_ktoolbutton.cpp" libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/parmscontroller.cpp0000664000175000017500000001703114474244170025007 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include "parmscontroller.h" #include 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; const static int TABLET_SLIDER_HANDLE_RADIUS = 40; const static int TABLET_SLIDER_NODE_RADIUS = 16; const static int TABLET_BADGE_HEIGHT = 20; const static int TABLET_ICONBAR_HEIGHT = 64; const static int TABLET_ICONBARICONSIZE =32; const static int TABLET_WINDOWBUTTONBAR_SIZE =48; const static int TABLET_NAVIGATION_INTERVAL = 4; //const static int TABLET_NAVIGATION_WIDTH = 230; const static int TABLET_WIDGET_SIDEWIDGET_WIDTH = 254; const static int TABLET_INPUTDIALOG_HEIGHT = 222; const static int TABLET_INPUTDIALOG_WIDTH = 352; const static int TABLET_INPUTDIALOG_LABEL_SPACING = 16; const static int TABLET_INPUTDIALOG_WIDGET_SPACING = 24; const static int TABLET_INPUTDIALOG_BUTTON_SPACING = 16; const static int TABLET_INPUTDIALOG_BOTTOM_SPACING = 16; const static int TABLET_INPUTDIALOG_RIGHT_SPACING = 32; const static int PC_CONTROL_HEIGHT = 36; const static int PC_SLIDER_HANDLE_RADIUS = 20; const static int PC_SLIDER_NODE_RADIUS = 10; const static int PC_BADGE_HEIGHT = 30; const static int PC_ICONBAR_HEIGHT = 40; const static int PC_ICONBARICONSIZE =24; const static int PC_WINDOWBUTTONBAR_SIZE =30; const static int PC_NAVIGATION_INTERVAL = 4; //const static int PC_NAVIGATION_WIDTH = 168; const static int PC_WIDGET_SIDEWIDGET_WIDTH = 200; const static int PC_INPUTDIALOG_HEIGHT = 198; const static int PC_INPUTDIALOG_WIDTH = 336; const static int PC_INPUTDIALOG_LABEL_SPACING = 8; const static int PC_INPUTDIALOG_WIDGET_SPACING = 32; const static int PC_INPUTDIALOG_BUTTON_SPACING = 10; const static int PC_INPUTDIALOG_BOTTOM_SPACING = 24; const static int PC_INPUTDIALOG_RIGHT_SPACING = 24; Parmscontroller *Parmscontroller::self() { if(g_parmscontroller) return g_parmscontroller; else { g_parmscontroller = new Parmscontroller; return g_parmscontroller; } } Parmscontroller::Parmscontroller(QObject *parent) : QObject(parent) { g_statusManagerDBus = new QDBusInterface(DBUS_STATUS_MANAGER, "/" ,DBUS_STATUS_MANAGER,QDBusConnection::sessionBus()); if (g_statusManagerDBus) { 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() { delete g_statusManagerDBus; g_statusManagerDBus = nullptr; } bool Parmscontroller::isTabletMode() { if (g_statusManagerDBus && g_statusManagerDBus->isValid()) { QDBusReply message = g_statusManagerDBus->call("get_current_tabletmode"); if (message.isValid()) return message.value(); else return false; } else return false; } int Parmscontroller::parm(Parmscontroller::Parm p) { if(g_isTablet) { switch (p) { case PM_TabBarHeight: case PM_PushButtonHeight: case PM_ToolButtonHeight: case PM_SearchLineEditHeight: case PM_PasswordEditHeight: case PM_NavigationBatHeight: case PM_TagHeight: case PM_SearchLineEditItemHeight: return TABLET_CONTROL_HEIGHT; case PM_SliderHandleRadius: return TABLET_SLIDER_HANDLE_RADIUS; case PM_SliderNodeRadius: return TABLET_SLIDER_NODE_RADIUS; case PM_BadgeHeight: return TABLET_BADGE_HEIGHT; case PM_IconbarHeight: return TABLET_ICONBAR_HEIGHT; case PM_IconBarIconSize: return TABLET_ICONBARICONSIZE; case PM_WindowButtonBarSize: return TABLET_WINDOWBUTTONBAR_SIZE; case PM_NavigationBatInterval: return TABLET_NAVIGATION_INTERVAL; // case PM_NavigationBarWidth: // return TABLET_NAVIGATION_WIDTH; case PM_Widget_SideWidget_Width: return TABLET_WIDGET_SIDEWIDGET_WIDTH; case PM_InputDialog_Height: return TABLET_INPUTDIALOG_HEIGHT; case PM_InputDialog_Width: return TABLET_INPUTDIALOG_WIDTH; case PM_InputDialog_Label_Spacing: return TABLET_INPUTDIALOG_LABEL_SPACING; case PM_InputDialog_Widget_Spacing: return TABLET_INPUTDIALOG_WIDGET_SPACING; case PM_InputDialog_Button_Spacing: return TABLET_INPUTDIALOG_BUTTON_SPACING; case PM_InputDialog_Bottom_Spacing: return TABLET_INPUTDIALOG_BOTTOM_SPACING; case PM_InputDialog_Right_Spacing: return TABLET_INPUTDIALOG_RIGHT_SPACING; default: return 0; break; } } else { switch (p) { case PM_TabBarHeight: case PM_PushButtonHeight: case PM_ToolButtonHeight: case PM_SearchLineEditHeight: case PM_PasswordEditHeight: case PM_NavigationBatHeight: case PM_TagHeight: case PM_SearchLineEditItemHeight: return PC_CONTROL_HEIGHT; case PM_SliderHandleRadius: return PC_SLIDER_HANDLE_RADIUS; case PM_SliderNodeRadius: return PC_SLIDER_NODE_RADIUS; case PM_BadgeHeight: return PC_BADGE_HEIGHT; case PM_IconbarHeight: return PC_ICONBAR_HEIGHT; case PM_IconBarIconSize: return PC_ICONBARICONSIZE; case PM_WindowButtonBarSize: return PC_WINDOWBUTTONBAR_SIZE; case PM_NavigationBatInterval: return PC_NAVIGATION_INTERVAL; // case PM_NavigationBarWidth: // return PC_NAVIGATION_WIDTH; case PM_Widget_SideWidget_Width: return PC_WIDGET_SIDEWIDGET_WIDTH; case PM_InputDialog_Height: return PC_INPUTDIALOG_HEIGHT; case PM_InputDialog_Width: return PC_INPUTDIALOG_WIDTH; case PM_InputDialog_Label_Spacing: return PC_INPUTDIALOG_LABEL_SPACING; case PM_InputDialog_Widget_Spacing: return PC_INPUTDIALOG_WIDGET_SPACING; case PM_InputDialog_Button_Spacing: return PC_INPUTDIALOG_BUTTON_SPACING; case PM_InputDialog_Bottom_Spacing: return PC_INPUTDIALOG_BOTTOM_SPACING; case PM_InputDialog_Right_Spacing: return PC_INPUTDIALOG_RIGHT_SPACING; default: return 0; break; } } } } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/src/themeController.h0000664000175000017500000000400714474244170024373 0ustar adminadmin/* * libkysdk-qtwidgets's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef THEMECONTROLLER_H #define THEMECONTROLLER_H #include #include static const QByteArray FITTHEMEWINDOW = "org.ukui.style"; enum ThemeFlag { LightTheme, DarkTheme }; enum IconFlag { DefaultStyle, ClassicStyle }; enum WidgetThemeFlag { DefaultTheme, //寻光 ClassicTheme, //启典 FashionTheme //和印 }; class ThemeController { public: static QPixmap drawSymbolicColoredPixmap(const QPixmap &source); static QPixmap drawColoredPixmap(const QPixmap &source,const QColor &sampleColor); static QColor getCurrentIconColor(); static QColor mixColor(const QColor &c1, const QColor &c2, qreal bias = 0.5); static WidgetThemeFlag widgetTheme(); static ThemeFlag themeMode(); static IconFlag iconTheme(); static int systemFontSize(); static QPixmap drawFashionBackground(const QRect&rect,int sub_width,int sub_height,int radius,int flag); // flag ? rightBottom : leftBottom; ThemeController(); ~ThemeController(); virtual void changeTheme(){} virtual void changeIconStyle(){} void initThemeStyle(); QGSettings *m_gsetting; //unused ThemeFlag m_themeFlag; IconFlag m_iconFlag; }; #endif // THEMECONTROLLER_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/0000775000175000017500000000000014474244076021250 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkbackground/0000775000175000017500000000000014474244170024435 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkbackground/testkbackground.pro0000664000175000017500000000175714474244076030370 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkbackground/widget.cpp0000664000175000017500000001352114474244170026426 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include "kbackgroundgroup.h" #include #include "klineframe.h" #include "kpushbutton.h" #include #include #include "kswitchbutton.h" #include "kborderlessbutton.h" #include "ktoolbutton.h" #include 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 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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkbackground/main.cpp0000664000175000017500000000164614474244170026074 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkbackground/widget.h0000664000175000017500000000174514474244170026100 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include "kwidget.h" using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtoolbutton/0000775000175000017500000000000014474244170024354 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtoolbutton/testtoolbutton.pro0000664000175000017500000000200114474244076030205 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtoolbutton/widget.cpp0000664000175000017500000000650714474244170026353 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; KToolButton* toolbtn1 = new KToolButton(this); //构建一个toolbutton,默认类型为Flat toolbtn1->setEnabled(false); //设置是否可用 KToolButton* toolbtn2 = new KToolButton(this); //默认图标为"open-menu-symbolic" //toolbtn2->setIcon(QIcon::fromTheme("camera-switch-symbolic")); //设置toolbutton的图标 KToolButton* toolbtn3 = new KToolButton(this); toolbtn3->setLoading(true); //设置正在加载状态,仅不带箭头的toolbuttuon支持该状态 QHBoxLayout* hLayout = new QHBoxLayout(); hLayout->addWidget(toolbtn1); hLayout->addWidget(toolbtn2); hLayout->addWidget(toolbtn3); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); KToolButton* toolbtn4 = new KToolButton(this); toolbtn4->setEnabled(false); toolbtn4->setArrow(true); //设置是否显示向下箭头,默认不显示 KToolButton* toolbtn5 = new KToolButton(this); toolbtn5->setArrow(true); KToolButton* toolbtn6 = new KToolButton(this); toolbtn6->setLoading(true); toolbtn6->setArrow(true); hLayout->addWidget(toolbtn4); hLayout->addWidget(toolbtn5); hLayout->addWidget(toolbtn6); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); KToolButton* toolbtn7 = new KToolButton(this); toolbtn7->setEnabled(false); toolbtn7->setType(KToolButtonType::SemiFlat); //设置toolbutton类型为SemiFlat KToolButton* toolbtn8 = new KToolButton(this); toolbtn8->setType(KToolButtonType::SemiFlat); KToolButton* toolbtn9 = new KToolButton(this); toolbtn9->setLoading(true); toolbtn9->setType(KToolButtonType::SemiFlat); hLayout->addWidget(toolbtn7); hLayout->addWidget(toolbtn8); hLayout->addWidget(toolbtn9); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); KToolButton* toolbtn10 = new KToolButton(this); toolbtn10->setEnabled(false); toolbtn10->setType(KToolButtonType::Background); //设置toolbutton类型为Background KToolButton* toolbtn11 = new KToolButton(this); toolbtn11->setType(KToolButtonType::Background); KToolButton* toolbtn12 = new KToolButton(this); toolbtn12->setLoading(true); toolbtn12->setType(KToolButtonType::Background); hLayout->addWidget(toolbtn10); hLayout->addWidget(toolbtn11); hLayout->addWidget(toolbtn12); mainLayout->addLayout(hLayout); baseBar()->setLayout(mainLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtoolbutton/main.cpp0000664000175000017500000000257014474244170026010 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtoolbutton/widget.h0000664000175000017500000000175414474244170026017 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "ktoolbutton.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkcolorcombobox/0000775000175000017500000000000014474244170025165 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkcolorcombobox/testkcolorcombobox.pro0000664000175000017500000000175714474244076031650 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkcolorcombobox/widget.cpp0000664000175000017500000000501414474244170027154 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include "kcolorcombobox.h" #include 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 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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkcolorcombobox/main.cpp0000664000175000017500000000164614474244170026624 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkcolorcombobox/widget.h0000664000175000017500000000167314474244170026630 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKButtonBox/0000775000175000017500000000000014474244170024202 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKButtonBox/widget.cpp0000664000175000017500000000637714474244170026206 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kbuttonbox.h" #include #include "kpushbutton.h" #include #include #include #include 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 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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKButtonBox/main.cpp0000664000175000017500000000164614474244170025641 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKButtonBox/widget.h0000664000175000017500000000167314474244170025645 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKButtonBox/testKButtonBox.pro0000664000175000017500000000175714474244076027702 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKTranslucentFloor/0000775000175000017500000000000014474244170025562 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKTranslucentFloor/testKTranslucentFloor.pro0000664000175000017500000000200114474244076032621 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKTranslucentFloor/widget.cpp0000664000175000017500000000425114474244170027553 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include "ktranslucentfloor.h" #include #include #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent) { QHBoxLayout* mainLayout = new QHBoxLayout(this); QPushButton* button1 = new QPushButton("常规效果",this); QPushButton* button2 = new QPushButton("毛玻璃效果",this); mainLayout->addWidget(button1); mainLayout->addWidget(button2); KTranslucentFloor* floor1 = new KTranslucentFloor(); floor1->setEnableBlur(false); floor1->setFixedSize(400,300); floor1->setShadow(true); QHBoxLayout* layout1 = new QHBoxLayout(floor1); QPushButton* subBtn1 = new QPushButton("关闭",this); layout1->addWidget(subBtn1); KTranslucentFloor* floor2 = new KTranslucentFloor(); floor2->setEnableBlur(true); floor2->setFixedSize(400,300); floor2->setShadow(true); QHBoxLayout* layout2 = new QHBoxLayout(floor2); QPushButton* subBtn2 = new QPushButton("关闭",this); layout2->addWidget(subBtn2); connect(subBtn1,&QPushButton::clicked,this,[=](){ floor1->close(); }); connect(subBtn2,&QPushButton::clicked,this,[=](){ floor2->close(); }); connect(button1,&QPushButton::clicked,this,[=](){ floor1->show(); }); connect(button2,&QPushButton::clicked,this,[=](){ floor2->show(); }); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKTranslucentFloor/main.cpp0000664000175000017500000000257614474244170027224 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKTranslucentFloor/widget.h0000664000175000017500000000170114474244170027215 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbadge/0000775000175000017500000000000014474244170023205 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbadge/testbadge.pro0000664000175000017500000000200214474244076025670 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbadge/widget.cpp0000664000175000017500000000626214474244170025202 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout(this); QHBoxLayout* hLayout = new QHBoxLayout(); m_pContainer1 = new KPixmapContainer(this); m_pContainer1->setPixmap(QIcon::fromTheme("edit-find-symbolic").pixmap(16,16)); m_pContainer1->setFontSize(8); m_pContainer1->setColor(QColor(255,0,0)); //设置背景色 m_pContainer2 = new KPixmapContainer(this); m_pContainer2->setPixmap(QIcon::fromTheme("edit-find-symbolic").pixmap(24,24)); m_pContainer2->setFontSize(10); m_pContainer2->setValue(99); //设置值 m_pContainer2->setValueVisiable(false); //设置值不可见 m_pContainer3 = new KPixmapContainer(this); m_pContainer3->setPixmap(QIcon::fromTheme("edit-find-symbolic").pixmap(36,36)); m_pContainer3->setFontSize(10); m_pContainer3->setValue(999); m_pContainer4 = new KPixmapContainer(this); m_pContainer4->setPixmap(QIcon::fromTheme("edit-find-symbolic").pixmap(48,48)); m_pContainer4->setFontSize(12); //设置字体大小 m_pContainer4->setValue(1000); hLayout->addWidget(m_pContainer1); hLayout->addWidget(m_pContainer2); hLayout->addWidget(m_pContainer3); hLayout->addWidget(m_pContainer4); vLayout->addStretch(); vLayout->addLayout(hLayout); QLabel*label = new QLabel("调整badge3大小:",this); QSpinBox*spinBox = new QSpinBox(this); spinBox->setValue(m_pContainer3->fontSize()); connect(spinBox,static_cast(&QSpinBox::valueChanged),this, [=](int i){m_pContainer3->setFontSize(spinBox->value());}); hLayout = new QHBoxLayout(); hLayout->addStretch(); hLayout->addWidget(label); hLayout->addWidget(spinBox); hLayout->addStretch(); vLayout->addLayout(hLayout); m_pBadge1 = new KBadge(this); m_pBadge1->setValue(0); m_pBadge2 = new KBadge(this); m_pBadge2->setValue(99); //m_pBadge2->setValueVisiable(false); m_pBadge3 = new KBadge(this); m_pBadge3->setValue(999); m_pBadge4 = new KBadge(this); m_pBadge4->setValue(1000); hLayout = new QHBoxLayout(this); hLayout->addWidget(m_pBadge1); hLayout->addWidget(m_pBadge2); hLayout->addWidget(m_pBadge3); hLayout->addWidget(m_pBadge4); vLayout->addLayout(hLayout); vLayout->addStretch(); baseBar()->setLayout(vLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbadge/main.cpp0000664000175000017500000000257014474244170024641 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kwidgetutils.h" #include #include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbadge/widget.h0000664000175000017500000000240014474244170024635 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kbadge.h" #include "kpixmapcontainer.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KPixmapContainer *m_pContainer1; KPixmapContainer *m_pContainer2; KPixmapContainer *m_pContainer3; KPixmapContainer *m_pContainer4; KBadge *m_pBadge1; KBadge *m_pBadge2; KBadge *m_pBadge3; KBadge *m_pBadge4; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressdialog/0000775000175000017500000000000014474244170025167 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressdialog/testprogressdialog.pro0000664000175000017500000000200114474244076031633 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressdialog/widget.cpp0000664000175000017500000000344714474244170027166 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kprogressbar.h" #include #include using namespace kdk; Widget::Widget(QWidget *parent) : KWidget(parent) { KProgressDialog *progressDialog = new KProgressDialog(tr("运行中"),tr("取消"),0,100,this); progressDialog->setSubContent("正在下载..."); //设置次级内容 progressDialog->setSuffix("MB"); //设置detail的后缀 progressDialog->setWindowTitle("进度对话框"); //设置窗口标题 progressDialog->setWindowIcon("kylin-music"); //设置窗口图标 progressDialog->setValue(98); //设置当前进度值 progressDialog->setShowDetail(true); //设置是否显示详细信息 progressDialog->setAutoReset(false); //设置进度条是否重置 QPushButton *pBtn = new QPushButton("显示",this); QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->addWidget(pBtn); baseBar()->setLayout(vLayout); connect(pBtn,&QPushButton::clicked,this,[=](){progressDialog->show();}); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressdialog/main.cpp0000664000175000017500000000257014474244170026623 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressdialog/widget.h0000664000175000017500000000176014474244170026627 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kprogressdialog.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testWidget/0000775000175000017500000000000014474244170023366 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testWidget/main.cpp0000664000175000017500000000314414474244170025020 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include "testwidget.h" #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(); 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); } } TestWidget widget; widget.setWidgetName("TestWidget"); widget.setIcon("kylin-music"); widget.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testWidget/testwidget.cpp0000664000175000017500000002420614474244170026261 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ksearchlineedit.h" #include "kborderbutton.h" #include "kswitchbutton.h" #include "ksearchlineedit.h" #include "kaboutdialog.h" #include "kborderlessbutton.h" #include "ktabbar.h" #include "kwindowbuttonbar.h" #include "xatom-helper.h" #include "kuninstalldialog.h" #include "kprogressdialog.h" #include "kinputdialog.h" #include "kslider.h" #include "knavigationbar.h" #include "testwidget.h" #include "ktoolbutton.h" #include "kballontip.h" #include "ksecuritylevelbar.h" #include "kbadge.h" #include "kpixmapcontainer.h" #include "kpasswordedit.h" #include "kprogressbar.h" TestWidget::TestWidget(QWidget*parent):KWidget(parent) { setMinimumSize(640,800); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); //窗体显示在中间 QDesktopWidget *screenResolution = QApplication::desktop(); this->move((screenResolution->width() - this->width())/2, (screenResolution->height() - this->height())/2); this->setWindowTitle("testWindow"); KBorderButton *pLeftBtn = new KBorderButton(this); pLeftBtn->setText("Left"); KSwitchButton *pSwitchBtn1 = new KSwitchButton(this); pSwitchBtn1->setFixedSize(100,26); pSwitchBtn1->setEnabled(false); KSwitchButton *pSwitchBtn2 = new KSwitchButton(this); pSwitchBtn2->setFixedSize(100,26); KBorderButton *pRightBtn = new KBorderButton(this); pRightBtn->setText("Right"); //pRightBtn->setEnabled(false); QIcon icon =QIcon::fromTheme("edit-find-symbolic"); pRightBtn->setIcon(icon); KSearchLineEdit *pSearchBar = new KSearchLineEdit(this); //默认是带completer的,如果不需要 可以设置为空 //pSearchBar->setCompleter(nullptr); QVBoxLayout *vLayout = new QVBoxLayout(); QHBoxLayout *hLayout = new QHBoxLayout(); vLayout->addLayout(hLayout); vLayout->addStretch(); vLayout->addWidget(pSearchBar); hLayout = new QHBoxLayout(); KSlider *slider = new KSlider(Qt::Horizontal,this); slider->setSliderType(KSliderType::NodeSlider); slider->setRange(0,100); slider->setTickInterval(20); slider->setValue(33); slider->setTickPosition(QSlider::TicksBothSides); hLayout->addWidget(slider); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); hLayout->addWidget(pLeftBtn); hLayout->addWidget(pRightBtn); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); hLayout->addWidget(pSwitchBtn1); hLayout->addWidget(pSwitchBtn2); vLayout->addLayout(hLayout); KBorderlessButton *borderlessButton1 = new KBorderlessButton(this); borderlessButton1->setText("borderless1"); KProgressDialog *progress1 = new KProgressDialog(this); connect(borderlessButton1,&KBorderlessButton::clicked,progress1,&QProgressDialog::show); progress1->setValue(20); progress1->setShowDetail(true); KBorderlessButton *borderlessButton2 = new KBorderlessButton(this); borderlessButton2->setText("borderless2"); KProgressDialog *progress2 = new KProgressDialog(tr("下载"),tr("取消"),0,100,this); progress2->setSubContent("下载中..."); progress2->setSuffix("MB"); progress2->setWindowTitle("进度对话框"); progress2->setWindowIcon("kylin-music"); progress2->setValue(50); progress2->setShowDetail(false); connect(borderlessButton2,&KBorderlessButton::clicked,progress2,&KProgressDialog::show); hLayout = new QHBoxLayout(); hLayout->addWidget(borderlessButton1); hLayout->addWidget(borderlessButton2); vLayout->addLayout(hLayout); KBorderlessButton *borderlessButton3 = new KBorderlessButton(QIcon::fromTheme("edit-find-symbolic"),this); KBorderlessButton *borderlessButton4 = new KBorderlessButton(QIcon::fromTheme("edit-find-symbolic"),"borderless4",this); hLayout = new QHBoxLayout(); hLayout->addWidget(borderlessButton3); hLayout->addWidget(borderlessButton4); vLayout->addLayout(hLayout); KPixmapContainer* container = new KPixmapContainer(this); // QPixmap pixmap; // pixmap.load("/home/sunzhen/my.jpg"); // pixmap = pixmap.scaled(36,36); // container->setPixmap(pixmap); container->setPixmap(QIcon::fromTheme("edit-find-symbolic").pixmap(36,36)); container->setValue(1000); hLayout = new QHBoxLayout(); hLayout->addWidget(container); vLayout->addLayout(hLayout); KPasswordEdit* edit = new KPasswordEdit(this); edit->setFixedWidth(200); edit->setText("adad"); //edit->setLoading(true); //edit->setState(LoginState::LoginFailed); edit->setClearButtonEnabled(true); KPasswordEdit* edit2 = new KPasswordEdit(this); edit2->setFixedWidth(200); edit2->setText("12313"); edit2->setEnabled(false); edit2->setClearButtonEnabled(true); hLayout = new QHBoxLayout(); hLayout->addWidget(edit); hLayout->addWidget(edit2); vLayout->addLayout(hLayout); KProgressBar* progressbar = new KProgressBar(this); progressbar->setRange(0,100); progressbar->setValue(100); progressbar->setTextVisible(true); progressbar->setAlignment(Qt::AlignRight); hLayout = new QHBoxLayout(); hLayout->addWidget(progressbar); vLayout->addLayout(hLayout); // KProgressBar* progressbar2 = new KProgressBar(this); // progressbar2->setOrientation(Qt::Vertical); // progressbar2->setValue(50); // progressbar2->setTextVisible(true); // progressbar2->setAlignment(Qt::AlignRight); // hLayout = new QHBoxLayout(); // hLayout->addWidget(progressbar2); // vLayout->addLayout(hLayout); KBallonTip* ballonTip = new KBallonTip("这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字",TipType::Error,this); ballonTip->setFixedWidth(400); hLayout = new QHBoxLayout(); hLayout->addWidget(ballonTip); vLayout->addLayout(hLayout); //ballonTip->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); KSecurityLevelBar* barrrr = new KSecurityLevelBar(this); barrrr->setSecurityLevel(SecurityLevel::Medium); hLayout = new QHBoxLayout(); hLayout->addWidget(barrrr); vLayout->addLayout(hLayout); KBadge* badge1 = new KBadge(this); badge1->setValue(-9); //badge1->setFontSize(20); KBadge* badge2 = new KBadge(this); badge2->setValue(99); //badge2->setFontSize(10); KBadge* badge3 = new KBadge(this); badge3->setValue(999); //badge3->setMinimumHeight(50); badge3->setFontSize(15); KBadge* badge4 = new KBadge(this); badge4->setValue(9991); // badge4->setColor(QColor(255,0,0)); hLayout = new QHBoxLayout(); hLayout->addWidget(badge1); hLayout->addWidget(badge2); hLayout->addWidget(badge3); hLayout->addWidget(badge4); vLayout->addLayout(hLayout); KTabBar *tabBar1 = new KTabBar(KTabBarStyle::SegmentLight,this); tabBar1->addTab("first"); tabBar1->addTab("second"); tabBar1->addTab("third"); KTabBar *tabBar2 = new KTabBar(KTabBarStyle::SegmentDark,this); tabBar2->addTab("first"); tabBar2->addTab("second"); tabBar2->addTab("third"); KTabBar *tabBar3 = new KTabBar(KTabBarStyle::Sliding,this); tabBar3->addTab("first"); tabBar3->addTab("second"); tabBar3->addTab("third"); KUninstallDialog *uninstallDialog = new KUninstallDialog("browser360-cn-stable","104",this); KAboutDialog *aboutDialog = new KAboutDialog(this,QIcon::fromTheme("edit-find-symbolic"),"麒麟引导修复工具",tr("Version:2020.1.0")); connect(pLeftBtn,&KBorderButton::clicked,uninstallDialog,&KUninstallDialog::show); connect(pRightBtn,&KBorderButton::clicked,aboutDialog,&KAboutDialog::show); vLayout->addWidget(tabBar1); vLayout->addWidget(tabBar2); vLayout->addWidget(tabBar3); vLayout->addStretch(); baseBar()->setLayout(vLayout); vLayout = new QVBoxLayout(); KNavigationBar* bar = new KNavigationBar(this); QStandardItem * item1 = new QStandardItem(QIcon::fromTheme("system-computer-symbolic"),tr("一级导航")); QStandardItem * item2 = new QStandardItem(QIcon::fromTheme("stock-people-symbolic"),tr("二级导航")); QList list; QStandardItem * item3 = new QStandardItem(QIcon::fromTheme("camera-switch-symbolic"),tr("一组一级导航")); QStandardItem * item4 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("一组一级导航")); list<addItem(item1); bar->addSubItem(item2); bar->addGroupItems(list,"测试一组"); QStandardItem * item5 = new QStandardItem(QIcon::fromTheme("camera-switch-symbolic"),tr("二组一级导航")); QStandardItem * item6 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("二组一级导航")); QStandardItem * item7 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("二组二级导航")); QList list2; list2<addGroupItems(list2,"测试二组"); bar->addSubItem(item7); vLayout->addWidget(bar); sideBar()->setLayout(vLayout); this->setLayoutType(HorizontalType); } TestWidget::~TestWidget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testWidget/testwidget.h0000664000175000017500000000202314474244170025717 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef TESTWIDGET_H #define TESTWIDGET_H #include "kwidget.h" #include using namespace kdk; class TestWidget:public KWidget { Q_OBJECT public: TestWidget(QWidget* parent = nullptr); ~TestWidget(); QSlider *slider; }; #endif // TESTWIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testWidget/testWidget.pro0000664000175000017500000000201114474244076026232 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 \ testwidget.cpp HEADERS += \ testwidget.h # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListWidget/0000775000175000017500000000000014474244170024222 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListWidget/widget.cpp0000664000175000017500000000356714474244170026224 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent) { QVBoxLayout* vlayout = new QVBoxLayout(this); m_listwidget = new KListWidget(this); this->setWindowTitle("test"); this->setWindowIcon(QIcon::fromTheme("kylin-music")); this->resize(800,500); //KItemWidget 构造函数 KItemWidget(const QIcon &Myicon,QString MmainText,QString MsecText,QWidget *parent); //Myicon 需要显示的图片 MmainText 需要写入的miantext MsecText 需要写入的sectext m_item = new KItemWidget(QIcon::fromTheme("kylin-music"),QString("IMG202202121544.JPG"),QString("1.6MB"),m_listwidget); m_item1 = new KItemWidget(QIcon::fromTheme("kylin-music"),QString("IMG202202121544.JPG"),QString("1.5MB"),m_listwidget); KItemWidget* m_item2 = new KItemWidget(QIcon::fromTheme("kylin-music"),QString("IMG202202121544.JPG"),QString("1.5MB"),m_listwidget); m_listwidget->AddItemWidget(m_item); m_listwidget->AddItemWidget(m_item1); m_listwidget->AddItemWidget(m_item2); vlayout->addWidget(m_listwidget); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListWidget/testListWidget.pro0000664000175000017500000000200114474244076027721 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListWidget/main.cpp0000664000175000017500000000257614474244170025664 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListWidget/widget.h0000664000175000017500000000221514474244170025656 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef WIDGET_H #define WIDGET_H #include #include "kwidget.h" #include "kitemwidget.h" #include "klistwidget.h" #include "gui_g.h" using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KItemWidget* m_item; KItemWidget* m_item1; KListWidget* m_listwidget; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListView/0000775000175000017500000000000014474244170023711 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListView/widget.cpp0000664000175000017500000000675314474244170025713 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include #include #include #include #include "klistview.h" #include "klistviewdelegate.h" #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent) { QHBoxLayout* hlayout = new QHBoxLayout(this); QListView* view = new QListView(this); view->setIconSize(QSize(32,32)); //设置图片大小 QStandardItemModel*model =new QStandardItemModel(this); KListViewDelegate *delegate =new KListViewDelegate(view); view->setModel(model); QStandardItem* item = new QStandardItem(); item->setIcon(QIcon::fromTheme("kylin-music")); item->setData(QVariant("Test"),Qt::DisplayRole); item->setData(QVariant("subTEST"),Qt::UserRole); QStandardItem* item1 = new QStandardItem(); item1->setIcon(QIcon::fromTheme("kylin-music")); item1->setData(QVariant("Test"),Qt::DisplayRole); item1->setData(QVariant("supTEST"),Qt::UserRole); QStandardItem* item2 = new QStandardItem(); item2->setIcon(QIcon::fromTheme("kylin-music")); item2->setData(QVariant("Test"),Qt::DisplayRole); item2->setData(QVariant("supTEST"),Qt::UserRole); model->appendRow(item); model->appendRow(item1); model->appendRow(item2); view->setItemDelegate(delegate); view->setViewMode(QListView::ListMode); //view->setGridSize(QSize(60,120));//IconMode下用 view->setFixedSize(300,480); hlayout->addWidget(view); QListView* view1 = new QListView(this); view1->setIconSize(QSize(32,32)); QStandardItemModel*model1 =new QStandardItemModel(this); KListViewDelegate *delegate1 =new KListViewDelegate(view1); view1->setModel(model1); QStandardItem* item3 = new QStandardItem(); item3->setIcon(QIcon::fromTheme("kylin-music")); item3->setData(QVariant("Test"),Qt::DisplayRole); QStandardItem* item4 = new QStandardItem(); item4->setIcon(QIcon::fromTheme("kylin-music")); item4->setData(QVariant("Test"),Qt::DisplayRole); QStandardItem* item5 = new QStandardItem(); item5->setIcon(QIcon::fromTheme("kylin-music")); item5->setData(QVariant("Test"),Qt::DisplayRole); model1->appendRow(item3); model1->appendRow(item4); model1->appendRow(item5); view1->setItemDelegate(delegate1); view1->setViewMode(QListView::ListMode); //view->setGridSize(QSize(60,120));//IconMode下用 hlayout->addWidget(view1); // view->setSelectionMode(QAbstractItemView::ContiguousSelection); // view->setSelectionMode(QAbstractItemView::MultiSelection); // view->setSelectionMode(QAbstractItemView::ExtendedSelection); view1->setFixedSize(300,480); // setFixedSize(800,600); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListView/main.cpp0000664000175000017500000000257614474244170025353 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListView/widget.h0000664000175000017500000000170114474244170025344 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testListView/testListView.pro0000664000175000017500000000200214474244076027100 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsearchlinedit/0000775000175000017500000000000014474244170024761 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsearchlinedit/widget.cpp0000664000175000017500000000566714474244170026766 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout*mainLayout = new QVBoxLayout; mainLayout->addStretch(); QHBoxLayout*hLayout = new QHBoxLayout; m_pSearchLineEdit1 = new KSearchLineEdit(this); //构造一个搜索框 //m_pSearchLineEdit1->setPlaceholderAlignment(Qt::AlignCenter); //设置placeholder的对齐方式 m_pSearchLineEdit1->setClearButtonEnabled(true); //是否启用清除键(true为启用) m_pSearchLineEdit1->setPlaceholderText("此处需要输入很长非常长的需要查找的内容"); //设置placeholder的文本内容 m_pSearchLineEdit1->setAlignment(Qt::AlignLeft); //设置输入内容的对齐方式 m_pLabel1 = new QLabel(this); hLayout->addWidget(m_pSearchLineEdit1); QPushButton* btn1 = new QPushButton(this); btn1->setText("隐藏"); QPushButton* btn2 = new QPushButton(this); btn2->setText("显示"); btn2->move(110,0); QPushButton* btn3 = new QPushButton(this); btn3->setText("清除"); btn3->move(220,0); connect(btn1,&QPushButton::clicked,this,[=]{ m_pSearchLineEdit1->hide(); }); connect(btn2,&QPushButton::clicked,this,[=]{ m_pSearchLineEdit1->show(); }); connect(btn3,&QPushButton::clicked,this,[=]{ m_pSearchLineEdit1->clear(); }); connect(m_pSearchLineEdit1,&KSearchLineEdit::returnPressed,this,[=](){ m_pLabel1->setText(QString("Search Content is:%1").arg(m_pSearchLineEdit1->text())); }); mainLayout->addLayout(hLayout); mainLayout->addWidget(m_pLabel1); hLayout = new QHBoxLayout; m_pSearchLineEdit2 = new KSearchLineEdit(this); m_pLabel2 = new QLabel(this); m_pSearchLineEdit2->setEnabled(false); //设置搜索框是否可用 hLayout->addWidget(m_pSearchLineEdit2); connect(m_pSearchLineEdit2,&KSearchLineEdit::returnPressed,this,[=](){ m_pLabel2->setText(QString("Search Content is:%1").arg(m_pSearchLineEdit2->text())); }); mainLayout->addLayout(hLayout); mainLayout->addWidget(m_pLabel2); mainLayout->addStretch(); baseBar()->setLayout(mainLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsearchlinedit/main.cpp0000664000175000017500000000257014474244170026415 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsearchlinedit/widget.h0000664000175000017500000000221314474244170026413 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "ksearchlineedit.h" #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KSearchLineEdit* m_pSearchLineEdit1; QLabel* m_pLabel1; KSearchLineEdit* m_pSearchLineEdit2; QLabel* m_pLabel2; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsearchlinedit/testsearchlinedit.pro0000664000175000017500000000200314474244076031221 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testslider/0000775000175000017500000000000014474244170023425 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testslider/testslider.pro0000664000175000017500000000200114474244076026327 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testslider/widget.cpp0000664000175000017500000001540214474244170025416 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include "ktabbar.h" Widget::Widget(QWidget *parent) : KWidget(parent) { QTabWidget* tabWidget = new QTabWidget(this); //horizontal QWidget *widget1 = new QWidget(this); QVBoxLayout* vLayout1 = new QVBoxLayout; QHBoxLayout* hLayout = new QHBoxLayout; QLabel*label1 = new QLabel(this); label1->setText("并列关系:"); m_pSlider1 = new KSlider(this); //构建一个滑动条 m_pSlider1->setFocusPolicy(Qt::ClickFocus); //设置是否显示节点 // m_pSlider1->setNodeVisible(false); m_pSlider1->setSliderType(KSliderType::SingleSelectSlider); //设置滑动条的类型,包含四种SmoothSlider,StepSlider,NodeSlider,SingleSelectSlider m_pSlider1->setRange(0,4); //设置滑动条值的范围 m_pSlider1->setMaximum(2); //设置滑动条的最大值 m_pSlider1->setValue(1); //设置滑动条的初始值 // m_pSlider1->setTickInterval(1); m_pSlider1->setFixedWidth(200); hLayout->addWidget(label1); hLayout->addWidget(m_pSlider1); QLabel* numLabel1 = new QLabel(this); numLabel1->setFixedWidth(30); numLabel1->setText(QString::number(m_pSlider1->value())); //获取滑动条当前的值 hLayout->addWidget(numLabel1); hLayout->addStretch(); vLayout1->addLayout(hLayout); QLabel*label2 = new QLabel(this); label2->setText("步数关系:"); m_pSlider2 = new KSlider(this); m_pSlider2->setSliderType(KSliderType::StepSlider); //设置滑动条的类型StepSlider m_pSlider2->setFocusPolicy(Qt::ClickFocus); //设置刻度间隔 m_pSlider2->setTickInterval(10); //设置步长 m_pSlider2->setSingleStep(20); //设置取值范围 m_pSlider2->setRange(-50,50); //设置初始值 m_pSlider2->setValue(20); qDebug()<value(); hLayout = new QHBoxLayout; hLayout->addWidget(label2); hLayout->addWidget(m_pSlider2); QLabel* numLabel2 = new QLabel(this); numLabel2->setText(QString::number(m_pSlider2->value())); numLabel2->setFixedWidth(30); hLayout->addWidget(numLabel2); vLayout1->addLayout(hLayout); QLabel*label3 = new QLabel(this); label3->setText("节点关系:"); m_pSlider3 = new KSlider(this); m_pSlider3->setSliderType(KSliderType::NodeSlider); m_pSlider3->setFocusPolicy(Qt::ClickFocus); m_pSlider3->setTickInterval(10); m_pSlider3->setSingleStep(20); m_pSlider3->setRange(-50,50); m_pSlider3->setValue(20); hLayout = new QHBoxLayout; hLayout->addWidget(label3); hLayout->addWidget(m_pSlider3); QLabel* numLabel3 = new QLabel(this); numLabel3->setText(QString::number(m_pSlider3->value())); numLabel3->setFixedWidth(30); hLayout->addWidget(numLabel3); vLayout1->addLayout(hLayout); connect(m_pSlider1,&QSlider::valueChanged,this,[=](){ numLabel1->setText(QString::number(m_pSlider1->value())); }); connect(m_pSlider2,&KSlider::valueChanged,this,[=](){ numLabel2->setText(QString::number(m_pSlider2->value())); }); connect(m_pSlider3,&KSlider::valueChanged,this,[=](){ numLabel3->setText(QString::number(m_pSlider3->value())); }); widget1->setLayout(vLayout1); tabWidget->addTab(widget1,"horizontal"); //vertical QWidget *widget2 = new QWidget(this); QHBoxLayout* hLayout2 = new QHBoxLayout; QVBoxLayout* vLayout2 = new QVBoxLayout; QLabel*label4 = new QLabel(this); label4->setText("非步数关系:"); m_pSlider4 = new KSlider(Qt::Vertical,this); //设置滑动条为垂直方向 m_pSlider4->setSliderType(KSliderType::SmoothSlider); m_pSlider4->setFocusPolicy(Qt::ClickFocus); m_pSlider4->setTickInterval(20); m_pSlider4->setSingleStep(10); m_pSlider4->setValue(10); m_pSlider4->setEnabled(false); QLabel* numLabel4 = new QLabel(this); numLabel4->setFixedWidth(30); numLabel4->setText(QString::number(m_pSlider4->value())); vLayout2->addWidget(numLabel4); vLayout2->addWidget(m_pSlider4); vLayout2->addWidget(label4); hLayout2->addLayout(vLayout2); QLabel*label5 = new QLabel(this); label5->setText("步数关系:"); m_pSlider5 = new KSlider(Qt::Vertical,this); m_pSlider5->setSliderType(KSliderType::StepSlider); m_pSlider5->setFocusPolicy(Qt::ClickFocus); m_pSlider5->setTickInterval(20); m_pSlider5->setSingleStep(10); m_pSlider5->setValue(20); QLabel* numLabel5 = new QLabel(this); numLabel5->setFixedWidth(30); numLabel5->setText(QString::number(m_pSlider5->value())); vLayout2 = new QVBoxLayout; vLayout2->addWidget(numLabel5); vLayout2->addWidget(m_pSlider5); vLayout2->addWidget(label5); hLayout2->addLayout(vLayout2); QLabel*label6 = new QLabel(this); label6->setText("节点关系:"); m_pSlider6 = new KSlider(this); m_pSlider6->setSliderType(KSliderType::NodeSlider); m_pSlider6->setFocusPolicy(Qt::ClickFocus); m_pSlider6->setTickInterval(20); m_pSlider6->setSingleStep(10); m_pSlider6->setValue(30); m_pSlider6->setOrientation(Qt::Vertical); QLabel* numLabel6 = new QLabel(this); numLabel6->setFixedWidth(30); numLabel6->setText(QString::number(m_pSlider6->value())); vLayout2 = new QVBoxLayout; vLayout2->addWidget(numLabel6); vLayout2->addWidget(m_pSlider6); vLayout2->addWidget(label6); hLayout2->addLayout(vLayout2); connect(m_pSlider4,&QSlider::valueChanged,this,[=](){ numLabel4->setText(QString::number(m_pSlider4->value())); }); connect(m_pSlider5,&KSlider::valueChanged,this,[=](){ numLabel5->setText(QString::number(m_pSlider5->value())); }); connect(m_pSlider6,&KSlider::valueChanged,this,[=](){ numLabel6->setText(QString::number(m_pSlider6->value())); }); widget2->setLayout(hLayout2); tabWidget->addTab(widget2,"vertical"); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addWidget(tabWidget); this->baseBar()->setLayout(mainLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testslider/main.cpp0000664000175000017500000000257014474244170025061 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testslider/widget.h0000664000175000017500000000223614474244170025064 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kslider.h" #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KSlider* m_pSlider1; KSlider* m_pSlider2; KSlider* m_pSlider3; KSlider* m_pSlider4; KSlider* m_pSlider5; KSlider* m_pSlider6; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKMessageBox/0000775000175000017500000000000014474244170024313 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKMessageBox/widget.cpp0000664000175000017500000000424614474244170026310 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKMessageBox/main.cpp0000664000175000017500000000256714474244170025755 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kwidgetutils.h" #include #include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKMessageBox/testKMessageBox.pro0000664000175000017500000000200114474244076030103 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKMessageBox/widget.h0000664000175000017500000000167314474244170025756 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testpasswordedit/0000775000175000017500000000000014474244170024653 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testpasswordedit/testpasswordedit.pro0000664000175000017500000000200214474244076031004 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testpasswordedit/widget.cpp0000664000175000017500000000737014474244170026651 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include static const QString password = "kylin"; Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout *vLayout = new QVBoxLayout(this); QHBoxLayout *hLayout = new QHBoxLayout(this); m_pPasswordEdit = new KPasswordEdit(this); hLayout->addWidget(m_pPasswordEdit); m_pPasswordEdit1 = new KPasswordEdit(this); m_pPasswordEdit2 = new KPasswordEdit(this); QPushButton *confirmBtn = new QPushButton("confirm",this); hLayout->addWidget(confirmBtn); vLayout->addLayout(hLayout); vLayout->addWidget(m_pPasswordEdit1); vLayout->addWidget(m_pPasswordEdit2); hLayout = new QHBoxLayout(this); QPushButton *enableBtn = new QPushButton("enable",this); hLayout->addWidget(enableBtn); QPushButton *loadingBtn = new QPushButton("isLoading:false",this); hLayout->addWidget(loadingBtn); vLayout->addLayout(hLayout); this->baseBar()->setLayout(vLayout); QString str("dwadwa"); m_pPasswordEdit1->setPlaceholderText(str);//设置背景文字 m_pPasswordEdit1->setClearButtonEnabled(false); //禁用ClearBtn按钮 m_pPasswordEdit2->setEchoModeBtnVisible(false); //隐藏EchoMode按钮 bool flag = m_pPasswordEdit2->echoModeBtnVisible();//返回EchoMode按钮是否隐藏 m_pPasswordEdit2->setEchoMode(QLineEdit::EchoMode::Normal);//明文输入 m_pPasswordEdit->setClearBtnVisible(false); //隐藏ClearBtn按钮(启用但隐藏) bool flag1 =m_pPasswordEdit->clearBtnVisible();//返回ClearBtn按钮是否隐藏 connect(confirmBtn,&QPushButton::clicked,this,[=](){ if(m_pPasswordEdit->text() == password) m_pPasswordEdit->setState(LoginState::LoginSuccess); //设置登录状态 else m_pPasswordEdit->setState(LoginState::LoginFailed); m_pPasswordEdit->setFocus(); }); connect(m_pPasswordEdit,&KPasswordEdit::returnPressed,this,[=](){ if(m_pPasswordEdit->text() == password) m_pPasswordEdit->setState(LoginState::LoginSuccess); else m_pPasswordEdit->setState(LoginState::LoginFailed); m_pPasswordEdit->setFocus(); }); connect(enableBtn,&QPushButton::clicked,this,[=](){ if(m_pPasswordEdit->isEnabled()) { m_pPasswordEdit->setEnabled(false); //设置KLineEdit不可用 enableBtn->setText("disable"); } else { m_pPasswordEdit->setEnabled(true); enableBtn->setText("enable"); } }); connect(loadingBtn,&QPushButton::clicked,this,[=](){ if(!m_pPasswordEdit->isLoading()) { qDebug()<<"is loading"; m_pPasswordEdit->setLoading(true); //设置启用加载状态 loadingBtn->setText("isLoading:true"); } else { qDebug()<<"is not loading"; m_pPasswordEdit->setLoading(false); loadingBtn->setText("isLoading:false"); } }); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testpasswordedit/main.cpp0000664000175000017500000000257014474244170026307 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testpasswordedit/widget.h0000664000175000017500000000214614474244170026312 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kpasswordedit.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KPasswordEdit* m_pPasswordEdit; KPasswordEdit* m_pPasswordEdit1; KPasswordEdit* m_pPasswordEdit2; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testPushbutton/0000775000175000017500000000000014474244170024316 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testPushbutton/widget.cpp0000664000175000017500000000612014474244170026304 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout; QGroupBox* groupBox1 = new QGroupBox("border",this); QGroupBox* groupBox2 = new QGroupBox("borderless",this); QGroupBox* groupBox3 = new QGroupBox("borderless tooltip",this); QHBoxLayout* hLayout =new QHBoxLayout; m_pBtn1 = new KBorderButton("border",this); //构造一个带边框按钮 m_pBtn2 = new KBorderButton("border",this); m_pBtn2->setIcon(QIcon::fromTheme("browser-download-symbolic")); //设置按钮图标 m_pBtn3 = new KBorderButton("border",this); m_pBtn3->setIcon(QIcon::fromTheme("browser-download-symbolic")); m_pBtn3->setEnabled(false); //设置不可点击 hLayout->addWidget(m_pBtn1); hLayout->addWidget(m_pBtn2); hLayout->addWidget(m_pBtn3); groupBox1->setLayout(hLayout); m_pBtn4 = new KBorderlessButton("borderless",this); //构造一个无边框按钮 m_pBtn5 = new KBorderlessButton("borderless",this); m_pBtn5->setIcon(QIcon::fromTheme("document-send-symbolic")); //设置按钮图标 m_pBtn6 = new KBorderlessButton("borderless",this); m_pBtn6->setIcon(QIcon::fromTheme("browser-download-symbolic")); m_pBtn6->setEnabled(false); //设置不可点击 hLayout = new QHBoxLayout; hLayout->addWidget(m_pBtn4); hLayout->addWidget(m_pBtn5); hLayout->addWidget(m_pBtn6); groupBox2->setLayout(hLayout); KBorderlessButton* m_pBtn7 = new KBorderlessButton("borderless test",this); //构造一个无边框按钮 m_pBtn7->setFixedWidth(80); KBorderlessButton* m_pBtn8 = new KBorderlessButton("borderless",this); m_pBtn8->setIcon(QIcon::fromTheme("document-send-symbolic")); //设置按钮图标 KBorderlessButton* m_pBtn9 = new KBorderlessButton("borderless",this); m_pBtn9->setFixedWidth(80); m_pBtn9->setIcon(QIcon::fromTheme("browser-download-symbolic")); hLayout = new QHBoxLayout; hLayout->addWidget(m_pBtn7); hLayout->addWidget(m_pBtn8); hLayout->addWidget(m_pBtn9); groupBox3->setLayout(hLayout); vLayout->addWidget(groupBox1); vLayout->addWidget(groupBox2); vLayout->addWidget(groupBox3); baseBar()->setLayout(vLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testPushbutton/main.cpp0000664000175000017500000000257014474244170025752 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testPushbutton/widget.h0000664000175000017500000000231314474244170025751 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kborderbutton.h" #include "kborderlessbutton.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KBorderButton* m_pBtn1; KBorderButton* m_pBtn2; KBorderButton* m_pBtn3; KBorderlessButton* m_pBtn4; KBorderlessButton* m_pBtn5; KBorderlessButton* m_pBtn6; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testPushbutton/testPushbutton.pro0000664000175000017500000000200114474244076030111 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKBubbleWidget/0000775000175000017500000000000014474244170024615 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKBubbleWidget/widget.cpp0000664000175000017500000000450214474244170026605 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include #include "kbubblewidget.h" #include "kwidget.h" #include 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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKBubbleWidget/testKBubbleWidget.pro0000664000175000017500000000175714474244076030730 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKBubbleWidget/main.cpp0000664000175000017500000000164614474244170026254 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKBubbleWidget/widget.h0000664000175000017500000000167314474244170026260 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtabbar/0000775000175000017500000000000014474244170023376 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtabbar/widget.cpp0000664000175000017500000000722514474244170025373 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "ktabbar.h" #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { /* 测试说明 * 1.tabbar1-tabbar3测试三种样式的显示以及添加tab的功能(在tabbar的开始、中间和末尾位置添加图标、文字以及二者都存在的tab) * 2.tabbar4测试设置tabbar样式、修改tabbar圆角(0-20)以及设置背景色。 */ QWidget *w = new QWidget(); KTabBar *tabBar1 = new KTabBar(KTabBarStyle::SegmentLight,w); tabBar1->addTab(QIcon::fromTheme("kylin-music"),"Segment1"); tabBar1->addTab("Segment2"); tabBar1->addTab(QIcon::fromTheme("kylin-music"),""); tabBar1->addTab("Segment4"); tabBar1->addTab("Segment5"); tabBar1->addTab("Segment6"); KTabBar *tabBar2 = new KTabBar(KTabBarStyle::SegmentDark,w); tabBar2->addTab("SegmentDark1"); tabBar2->addTab("SegmentDark2"); tabBar2->addTab(QIcon::fromTheme("kylin-music"),"SegmentDark3"); tabBar2->addTab("SegmentDark4"); tabBar2->addTab("SegmentDark5"); tabBar2->addTab(QIcon::fromTheme("kylin-music"),""); KTabBar *tabBar3 = new KTabBar(KTabBarStyle::Sliding,w); tabBar3->addTab(QIcon::fromTheme("kylin-music"),""); tabBar3->addTab("Sliding2"); tabBar3->addTab("Sliding3"); tabBar3->addTab("Sliding4"); tabBar3->addTab("Sliding5"); tabBar3->addTab(QIcon::fromTheme("kylin-music"),"Sliding6"); KTabBar *tabBar4 = new KTabBar(KTabBarStyle::Sliding,w); tabBar4->addTab("Segment1"); tabBar4->addTab("Segment2"); tabBar4->addTab("Segment3"); tabBar4->addTab("Segment4"); tabBar4->setTabBarStyle(KTabBarStyle::SegmentDark); //设置style tabBar4->setBorderRadius(10); //设置圆角半径,只对SegmentDark,SegmentLight样式生效 tabBar4->setBackgroundColor(QColor(0,255,0)); //设置背景色 QLabel* pLabel = new QLabel(w); pLabel->setAlignment(Qt::AlignCenter); connect(tabBar1,&KTabBar::tabBarClicked,this,[=](int index){pLabel->setText(tabBar1->tabText(index));}); connect(tabBar2,&KTabBar::tabBarClicked,this,[=](int index){pLabel->setText(tabBar2->tabText(index));}); connect(tabBar3,&KTabBar::tabBarClicked,this,[=](int index){pLabel->setText(tabBar3->tabText(index));}); connect(tabBar4,&KTabBar::tabBarClicked,this,[=](int index){pLabel->setText(tabBar4->tabText(index));}); QHBoxLayout *hlayout = new QHBoxLayout(); QLabel *label = new QLabel(); label->setText("just a test label"); hlayout->addWidget(label); QVBoxLayout*vLayout = new QVBoxLayout; vLayout->addStretch(); vLayout->addWidget(tabBar1); vLayout->addWidget(tabBar2); vLayout->addWidget(tabBar3); vLayout->addWidget(tabBar4); vLayout->addStretch(); vLayout->addWidget(pLabel); vLayout->addStretch(); vLayout->addLayout(hlayout); vLayout->addStretch(); baseBar()->setLayout(vLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtabbar/main.cpp0000664000175000017500000000257014474244170025032 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtabbar/widget.h0000664000175000017500000000172314474244170025035 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testtabbar/testtabbar.pro0000664000175000017500000000200214474244076026252 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/0000775000175000017500000000000014474244170022656 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/testTag.pro.user0000664000175000017500000005337214474244076026007 0ustar adminadmin EnvironmentId {2fbbdfe0-46ea-4bec-b909-73a0b852001a} ProjectExplorer.Project.ActiveTarget 0 ProjectExplorer.Project.EditorSettings true false true Cpp CppGlobal QmlJS QmlJSGlobal 2 UTF-8 false 4 false 80 true true 1 true false 0 true true 0 8 true 1 true true true false ProjectExplorer.Project.PluginSettings ProjectExplorer.Project.Target.0 桌面 桌面 {83abf94d-9435-41e8-bf16-20b2a6aa9fe3} 0 0 0 /home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/build-testTag-arm64-Debug true QtProjectManager.QMakeBuildStep true false false false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 /home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/build-testTag-arm64-Release true QtProjectManager.QMakeBuildStep false false false false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Release Qt4ProjectManager.Qt4BuildConfiguration 0 /home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/build-testTag-arm64-Profile true QtProjectManager.QMakeBuildStep true false true false true Qt4ProjectManager.MakeStep false false 2 Build Build ProjectExplorer.BuildSteps.Build true Qt4ProjectManager.MakeStep true clean false 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false Profile Qt4ProjectManager.Qt4BuildConfiguration 0 3 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 ProjectExplorer.DefaultDeployConfiguration 1 dwarf cpu-cycles 250 -e cpu-cycles --call-graph dwarf,4096 -F 250 -F true 4096 false false 1000 true false false false false true 0.01 10 true kcachegrind 1 25 1 true false true valgrind 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 Qt4ProjectManager.Qt4RunConfiguration:/home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/testTag/testTag.pro /home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/testTag/testTag.pro false false true true false false true /home/sunzhen/projects/kysdk-application/kysdk-qtwidgets/test/build-testTag-arm64-Debug 1 ProjectExplorer.Project.TargetCount 1 ProjectExplorer.Project.Updater.FileVersion 22 Version 22 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/widget.cpp0000664000175000017500000000474314474244170024655 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include #include #include "ktag.h" #include "kbreadcrumb.h" Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout *vLayout = new QVBoxLayout; KTag* tag1 = new KTag(this); tag1->setText("tag1"); //设置tag文本 //tag1->setTagStyle(TagStyle::HighlightTag); KTag* tag2 = new KTag(this); tag2->setText("tag2"); tag2->setTagStyle(TagStyle::BoderTag); //设置tag的style,有HighlightTag,BoderTag,BaseBoderTag,GrayTag四种 KTag* tag3 = new KTag(this); tag3->setText("tag3"); tag3->setTagStyle(TagStyle::BaseBoderTag); KTag* tag4 = new KTag(this); tag4->setText("tag4"); tag4->setTagStyle(TagStyle::GrayTag); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->addWidget(tag1); hLayout->addWidget(tag2); hLayout->addWidget(tag3); hLayout->addWidget(tag4); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout; KTag* tag5 = new KTag(this); tag5->setText("tag5"); tag5->setClosable(true); //设置tag是否可以关闭 KTag* tag6 = new KTag(this); tag6->setClosable(true); tag6->setText("tag6"); tag6->setTagStyle(TagStyle::BoderTag); KTag* tag7 = new KTag(this); tag7->setClosable(true); tag7->setText("tag7"); tag7->setTagStyle(TagStyle::BaseBoderTag); KTag* tag8 = new KTag(this); tag8->setClosable(true); tag8->setText("tag8"); tag8->setTagStyle(TagStyle::GrayTag); hLayout->addWidget(tag5); hLayout->addWidget(tag6); hLayout->addWidget(tag7); hLayout->addWidget(tag8); vLayout->addLayout(hLayout); baseBar()->setLayout(vLayout); sideBar()->hide(); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/main.cpp0000664000175000017500000000256714474244170024320 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/testTag.pro0000664000175000017500000000200114474244076025011 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTag/widget.h0000664000175000017500000000172314474244170024315 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTranslucent/0000775000175000017500000000000014474244170024445 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTranslucent/testTranslucent.pro0000664000175000017500000000176314474244076030405 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTranslucent/widget.cpp0000664000175000017500000001015414474244170026435 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kslider.h" #include "kswitchbutton.h" #include #include #include #include #include #include #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(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); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTranslucent/main.cpp0000664000175000017500000000207514474244170026101 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include //#include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testTranslucent/widget.h0000664000175000017500000000177614474244170026114 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); protected: bool eventFilter(QObject *watched, QEvent *event); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testballontip/0000775000175000017500000000000014474244170024127 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testballontip/widget.cpp0000664000175000017500000001077214474244170026125 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout(); QPushButton* button = new QPushButton(this); button->setText("NothingTip"); QPushButton* button1 = new QPushButton(this); button1->setText("NormalTip"); QPushButton* button2 = new QPushButton(this); button2->setText("InfoTip"); QPushButton* button3 = new QPushButton(this); button3->setText("WarningTip"); QPushButton* button4 = new QPushButton(this); button4->setText("ErrorTip"); vLayout->addWidget(button); vLayout->addWidget(button1); vLayout->addWidget(button2); vLayout->addWidget(button3); vLayout->addWidget(button4); // 提供了两种构造函数 m_pNothingTip 和 m_pInfoTip 分别为两种构造函数 m_pNothingTip = new KBallonTip(); m_pNothingTip->setWindowFlag(Qt::FramelessWindowHint); m_pNothingTip->setAttribute(Qt::WA_TranslucentBackground); m_pNothingTip->setTipType(TipType::Nothing); //设置KBallonTip类型 m_pNothingTip->setText("这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字"); // 设置文本内容 m_pNormalTip = new KBallonTip(); m_pNormalTip->setWindowFlag(Qt::FramelessWindowHint); m_pNormalTip->setAttribute(Qt::WA_TranslucentBackground); m_pNormalTip->setTipType(TipType::Normal); m_pNormalTip->setText("setContentsMargins调整边距"); //两种setmargins都支持 //m_pWarningTip->setContentsMargins(QMargins(0,0,0,0)); m_pNormalTip->setContentsMargins(20,20,20,20); //设置内容边距 m_pInfoTip = new KBallonTip("提供两种构造函数",TipType::Info); m_pInfoTip->setWindowFlag(Qt::FramelessWindowHint); m_pInfoTip->setAttribute(Qt::WA_TranslucentBackground); m_pWarningTip = new KBallonTip(); m_pWarningTip->setWindowFlag(Qt::FramelessWindowHint); m_pWarningTip->setAttribute(Qt::WA_TranslucentBackground); m_pWarningTip->setTipType(TipType::Warning); m_pWarningTip->setText("这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字"); QMargins marge(20,20,20,20); m_pErrorTip = new KBallonTip(); m_pErrorTip->setWindowFlag(Qt::FramelessWindowHint); m_pErrorTip->setAttribute(Qt::WA_TranslucentBackground); m_pErrorTip->setTipType(TipType::Error); m_pErrorTip->setContentsMargins(marge); //通过 QMargins 设置内容边距 m_pErrorTip->setText("这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字,这是一段操作信息描述的文字"); connect(button,&QPushButton::clicked,this,[=](){ m_pNothingTip->setTipTime(4000); //设置显示时间 m_pNothingTip->showInfo(); //定时显示KBallonTip,随后隐退 默认为1s }); connect(button1,&QPushButton::clicked,this,[=](){ m_pNormalTip->setTipTime(3000); m_pNormalTip->showInfo(); }); connect(button2,&QPushButton::clicked,this,[=](){ m_pInfoTip->setTipTime(2000); m_pInfoTip->showInfo(); }); connect(button3,&QPushButton::clicked,this,[=](){ m_pWarningTip->setTipTime(1000); m_pWarningTip->showInfo(); }); connect(button4,&QPushButton::clicked,this,[=](){ m_pErrorTip->showInfo(); }); // //vLayout->addWidget(m_pNothingTip); // vLayout->addWidget(m_pNormalTip); // vLayout->addWidget(m_pInfoTip); // vLayout->addWidget(m_pWarningTip); // vLayout->addWidget(m_pErrorTip); this->baseBar()->setLayout(vLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testballontip/main.cpp0000664000175000017500000000257014474244170025563 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kwidgetutils.h" #include #include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testballontip/widget.h0000664000175000017500000000233614474244170025567 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include "kwidget.h" #include "kballontip.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: //Nothing KBallonTip* m_pNothingTip; //Normal KBallonTip* m_pNormalTip; //Info KBallonTip* m_pInfoTip; //Warning KBallonTip* m_pWarningTip; //Error KBallonTip* m_pErrorTip; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testballontip/testballontip.pro0000664000175000017500000000200114474244076027533 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/test.pro0000664000175000017500000000125714474244076022756 0ustar adminadminTEMPLATE = subdirs SUBDIRS += \ testListWidget \ testbadge \ testbreadcrumb\ testballontip \ testDialog\ testinputdialog \ testnavigationbar \ testpasswordedit \ testprogressbar \ testProgressCircle \ testprogressdialog \ testPushbutton \ testsearchlinedit \ testsecuritylevelbar \ testslider \ testSwitchButton \ testtabbar \ testTag \ testtoolbutton \ testWidget \ testListWidget \ testListView \ testkpressbutton\ testKPushButton\ testKTranslucentFloor\ testTranslucent\ testKBubbleWidget\ testkcolorcombobox\ testKButtonBox\ testkbackground\ testcolorbutton\ testKMessageBox libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testinputdialog/0000775000175000017500000000000014474244170024462 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testinputdialog/widget.cpp0000664000175000017500000000357414474244170026462 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kinputdialog.h" #include #include #include using namespace kdk; Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vlayout = new QVBoxLayout(); auto btn1 = new QPushButton("inputText",this); auto btn2 = new QPushButton("inputMultiText",this); auto btn3 = new QPushButton("inputInt",this); auto btn4 = new QPushButton("inputDouble",this); vlayout->addWidget(btn1); vlayout->addWidget(btn2); vlayout->addWidget(btn3); vlayout->addWidget(btn4); connect(btn1,&QPushButton::clicked,this,[=](){KInputDialog::getText(this,tr("please input:"));}); //单行文本输入框 connect(btn2,&QPushButton::clicked,this,[=](){KInputDialog::getMultiLineText(this,tr("please input:"));}); //多行文本输入框 connect(btn3,&QPushButton::clicked,this,[=](){KInputDialog::getInt(this,tr("please input:"));}); //整型数字输入框 connect(btn4,&QPushButton::clicked,this,[=](){KInputDialog::getDouble(this,tr("please input:"));}); //浮点型数字输入框 baseBar()->setLayout(vlayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testinputdialog/main.cpp0000664000175000017500000000257114474244170026117 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include "kwidgetutils.h" int main(int argc, char *argv[]) { kdk::KWidgetUtils::highDpiScaling(); QApplication a(argc, argv); Widget w; 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); } } w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testinputdialog/testinputdialog.pro0000664000175000017500000000200114474244076030421 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testinputdialog/widget.h0000664000175000017500000000172214474244170026120 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testSwitchButton/0000775000175000017500000000000014474244170024600 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testSwitchButton/testSwitchButton.pro0000664000175000017500000000200114474244076030655 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testSwitchButton/widget.cpp0000664000175000017500000000744514474244170026601 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; QHBoxLayout* hLayout = new QHBoxLayout; m_pSwitchBtn1 = new KSwitchButton(this); //构造一个kswitchbutton m_pSwitchBtn1->setFixedSize(50,24); //设置button的大小 m_pSwitchBtn1->setCheckable(true); //设置是否可选中 m_pSwitchBtn1->setChecked(true); //设置是否为选中状态 m_pLabel1 = new QLabel(this); m_pLabel1->setText(m_pSwitchBtn1->isChecked()?"ON":"OFF"); //获取button是否是选中状态 //监听状态改变信号stateChanged connect(m_pSwitchBtn1,&KSwitchButton::stateChanged,this,[=](){m_pLabel1->setText(m_pSwitchBtn1->isChecked()?"ON":"OFF");}); m_pBtn1 = new KBorderlessButton(this); m_pBtn1->setChecked(true); m_pBtn1->setText(m_pSwitchBtn1->isEnabled()?"Enable":"Disable"); connect(m_pBtn1,&KBorderlessButton::clicked,this,[=](){ m_pSwitchBtn1->setEnabled(!m_pSwitchBtn1->isEnabled()); m_pBtn1->setText(m_pSwitchBtn1->isEnabled()?"Enable":"Disable");}); hLayout->addWidget(m_pSwitchBtn1); hLayout->addWidget(m_pLabel1); hLayout->addWidget(m_pBtn1); hLayout->addStretch(); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout; m_pSwitchBtn2 = new KSwitchButton(this); m_pSwitchBtn2->setFixedSize(100,48); m_pSwitchBtn2->setEnabled(false); //设置button状态为不可点击状态 m_pLabel2 = new QLabel(this); m_pLabel2->setText(m_pSwitchBtn2->isChecked()?"ON":"OFF"); connect(m_pSwitchBtn2,&KSwitchButton::stateChanged,this,[=](){m_pLabel2->setText(m_pSwitchBtn2->isChecked()?"ON":"OFF");}); m_pBtn2 = new KBorderlessButton(this); m_pBtn2->setText(m_pSwitchBtn2->isEnabled()?"Enable":"Disable"); connect(m_pBtn2,&KBorderlessButton::clicked,this,[=](){ m_pSwitchBtn2->setEnabled(!m_pSwitchBtn2->isEnabled()); m_pBtn2->setText(m_pSwitchBtn2->isEnabled()?"Enable":"Disable");}); hLayout->addWidget(m_pSwitchBtn2); hLayout->addWidget(m_pLabel2); hLayout->addWidget(m_pBtn2); hLayout->addStretch(); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout; m_pSwitchBtn3 = new KSwitchButton(this); m_pSwitchBtn3->setFixedSize(200,64); m_pLabel3 = new QLabel(this); m_pLabel3->setText(m_pSwitchBtn3->isChecked()?"ON":"OFF"); connect(m_pSwitchBtn3,&KSwitchButton::stateChanged,this,[=](){m_pLabel3->setText(m_pSwitchBtn3->isChecked()?"ON":"OFF");}); m_pBtn3 = new KBorderlessButton(this); m_pBtn3->setText(m_pSwitchBtn3->isEnabled()?"Enable":"Disable"); connect(m_pBtn3,&KBorderlessButton::clicked,this,[=](){ m_pSwitchBtn3->setEnabled(!m_pSwitchBtn3->isEnabled()); m_pBtn3->setText(m_pSwitchBtn3->isEnabled()?"Enable":"Disable");}); hLayout->addWidget(m_pSwitchBtn3); hLayout->addWidget(m_pLabel3); hLayout->addWidget(m_pBtn3); hLayout->addStretch(); mainLayout->addLayout(hLayout); baseBar()->setLayout(mainLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testSwitchButton/main.cpp0000664000175000017500000000257014474244170026234 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testSwitchButton/widget.h0000664000175000017500000000246414474244170026242 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kswitchbutton.h" #include "kborderlessbutton.h" #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KSwitchButton* m_pSwitchBtn1; QLabel* m_pLabel1; KBorderlessButton* m_pBtn1; KSwitchButton* m_pSwitchBtn2; QLabel* m_pLabel2; KBorderlessButton* m_pBtn2; KSwitchButton* m_pSwitchBtn3; QLabel* m_pLabel3; KBorderlessButton* m_pBtn3; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testnavigationbar/0000775000175000017500000000000014474244170024767 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testnavigationbar/widget.cpp0000664000175000017500000000567014474244170026766 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout(); m_pBar = new KNavigationBar(this); QStandardItem * item1 = new QStandardItem(QIcon::fromTheme("system-computer-symbolic"),tr("一级导航")); QStandardItem * item2 = new QStandardItem(QIcon::fromTheme("stock-people-symbolic"),tr("二级导航")); QList list; QStandardItem * item3 = new QStandardItem(QIcon::fromTheme("camera-switch-symbolic"),tr("一组一级导航1")); QStandardItem * item4 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("一组一级导航2")); list<addItem(item1); //增加常规Item m_pBar->addSubItem(item2); //增加次级Item m_pBar->addGroupItems(list,"测试一组"); //组增加Item,在导航栏中会显示tag QStandardItem * item5 = new QStandardItem(QIcon::fromTheme("camera-switch-symbolic"),tr("二组一级导航1")); QStandardItem * item6 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("二组一级导航2")); QStandardItem * item7 = new QStandardItem(QIcon::fromTheme("media-eq-symbolic"),tr("二组二级导航")); QList list2; list2<addGroupItems(list2,"测试二组"); m_pBar->addSubItem(item7); m_pBar->addTag("测试三组"); vLayout->addWidget(m_pBar); sideBar()->setLayout(vLayout); vLayout = new QVBoxLayout; QLabel* pLabel = new QLabel(this); pLabel->setAlignment(Qt::AlignCenter); vLayout->addWidget(pLabel); baseBar()->setLayout(vLayout); m_pBar->model()->item(1)->setEnabled(false); m_pBar->model()->item(2)->setEnabled(false); m_pBar->model()->item(3)->setEnabled(false); m_pBar->model()->item(4)->setEnabled(false); // QListView* ba= m_pBar->listview(); //获取listview // ba->setDisabled(true); //整体禁用 // QStandardItemModel* m_mode = m_pBar->model(); //获取mode connect(m_pBar->listview(),&QListView::clicked,this,[=](const QModelIndex &index){pLabel->setText(index.data().toString());}); this->setLayoutType(HorizontalType); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testnavigationbar/main.cpp0000664000175000017500000000257014474244170026423 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testnavigationbar/widget.h0000664000175000017500000000231614474244170026425 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include #include #include #include "knavigationbar.h" #include #include #include #include #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KNavigationBar* m_pBar; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testnavigationbar/testnavigationbar.pro0000664000175000017500000000200114474244076031233 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkpressbutton/0000775000175000017500000000000014474244170024706 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkpressbutton/widget.cpp0000664000175000017500000000526414474244170026704 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include "kwidget.h" #include "kpressbutton.h" #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent) { KPressButton* button1 = new KPressButton(); button1->setIcon(QIcon::fromTheme("stock-people-symbolic")); button1->setBorderRadius(20); button1->setTranslucent(true); button1->setChecked(true); KPressButton* button2 = new KPressButton(); button2->setCheckable(false); QHBoxLayout* layout = new QHBoxLayout(); layout->addWidget(button1); layout->addWidget(button2); KPressButton* button3 = new KPressButton(this); KPressButton* button4 = new KPressButton(); button4->setFixedSize(36,36); button4->setButtonType(KPressButton::CircleType); button4->setIcon(QIcon::fromTheme("system-computer-symbolic")); QHBoxLayout* layout1 = new QHBoxLayout(); layout1->addWidget(button3); layout1->addWidget(button4); KPressButton* button5 = new KPressButton(); button5->setLoaingStatus(true); button5->setChecked(true); KPressButton* button6 = new KPressButton(); QHBoxLayout* layout2 = new QHBoxLayout(); layout2->addWidget(button5); layout2->addWidget(button6); QVBoxLayout* vlayout = new QVBoxLayout(this); vlayout->addLayout(layout); vlayout->addLayout(layout1); vlayout->addLayout(layout2); connect(button4,&KPressButton::clicked,this,[=](){ if(button4->isChecked()) button4->setLoaingStatus(true); else button4->setLoaingStatus(false); }); connect(button5,&KPressButton::clicked,this,[=](){ if(button5->isChecked()) button5->setLoaingStatus(true); else button5->setLoaingStatus(false); }); connect(button2,&KPressButton::clicked,this,[=](bool flag){ qDebug() << flag << button2->isChecked()<isCheckable(); }); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkpressbutton/testkpressbutton.pro0000664000175000017500000000200114474244076031071 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkpressbutton/main.cpp0000664000175000017500000000257614474244170026350 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testkpressbutton/widget.h0000664000175000017500000000170114474244170026341 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhenyu Wang * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testDialog/0000775000175000017500000000000014474244170023342 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testDialog/widget.cpp0000664000175000017500000000562114474244170025335 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include "kdialog.h" #include "kuninstalldialog.h" #include "kaboutdialog.h" Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout; QPushButton*pBtn1 = new QPushButton("对话框",this); QPushButton*pBtn2 = new QPushButton("卸载对话框",this); QPushButton*pBtn3 = new QPushButton("关于对话框",this); KDialog*dialog = new KDialog(); //设置标题 dialog->setWindowTitle("对话框"); //设置icon dialog->setWindowIcon("kylin-music"); //显示最小化和最大化按钮 dialog->maximumButton()->show(); dialog->minimumButton()->show(); KUninstallDialog *uninstallDialog = new KUninstallDialog("browser360-cn-stable","104",this); KAboutDialog *aboutDialog = new KAboutDialog(this,QIcon::fromTheme("kylin-music"),"麒麟音乐",tr("版本:2020.1.0")); aboutDialog->setBodyText("关于对话框,包含的主要内容有:应用图标,应用名称,版本号,团队邮箱以及具体的应用描述,注意,默认应用描述是不显示的。"); aboutDialog->setBodyTextVisiable(true); vLayout->addStretch(); vLayout->addWidget(pBtn1); vLayout->addWidget(pBtn2); vLayout->addWidget(pBtn3); vLayout->addStretch(); connect(pBtn1,&QPushButton::clicked,this,[=](){dialog->show();}); connect(pBtn2,&QPushButton::clicked,this,[=](){uninstallDialog->show();}); connect(pBtn3,&QPushButton::clicked,this,[=](){aboutDialog->show();}); // QHBoxLayout* tmpLayout = dynamic_cast(windowButtonBar()->layout()); // QPushButton* btn = new QPushButton("btn",this); // tmpLayout->insertWidget(1,btn); QHBoxLayout *hLayout = new QHBoxLayout(dialog); QPushButton*pBtn5 = new QPushButton("对话框",dialog); hLayout->addWidget(pBtn5); dialog->mainWidget()->setLayout(hLayout); //获取主内容区,通过setLayout()添加内容 dialog->menuButton()->show();//获取下拉菜单按钮,默认是隐藏的,不显示 //dialog->closeButton()->show();//获取关闭按钮。 baseBar()->setLayout(vLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testDialog/testDialog.pro0000664000175000017500000000200114474244076026161 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testDialog/main.cpp0000664000175000017500000000257114474244170024777 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testDialog/widget.h0000664000175000017500000000172414474244170025002 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testProgressCircle/0000775000175000017500000000000014474244170025071 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testProgressCircle/testProgressCircle.pro0000664000175000017500000000200114474244076031437 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testProgressCircle/widget.cpp0000664000175000017500000000563414474244170027070 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kprogresscircle.h" #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout*vLayout = new QVBoxLayout; QHBoxLayout* hLayout = new QHBoxLayout; KProgressCircle *circle1 = new KProgressCircle(this); circle1->setValue(40); //设置初始值 hLayout->addWidget(circle1); KProgressCircle *circle2 = new KProgressCircle(this); circle2->setValue(10); circle2->setState(ProgressBarState::FailedProgress); //设置失败状态 hLayout->addWidget(circle2); KProgressCircle *circle3 = new KProgressCircle(this); circle3->setValue(75); circle3->setState(ProgressBarState::SuccessProgress); //设置成功状态 hLayout->addWidget(circle3); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout; KProgressCircle *circle4 = new KProgressCircle(this); circle4->setValue(40); circle4->setTextVisible(false); //设置文本不可见 hLayout->addWidget(circle4); KProgressCircle *circle5 = new KProgressCircle(this); circle5->setValue(93); circle5->setTextVisible(false); circle5->setState(ProgressBarState::FailedProgress); hLayout->addWidget(circle5); KProgressCircle *circle6 = new KProgressCircle(this); circle6->setValue(75); circle6->setTextVisible(false); circle6->setState(ProgressBarState::SuccessProgress); hLayout->addWidget(circle6); vLayout->addLayout(hLayout); baseBar()->setLayout(vLayout); m_pTimer = new QTimer(this); m_pTimer->setInterval(20); connect(m_pTimer,&QTimer::timeout,circle1,[=](){ if(circle1->value()maximum()) circle1->setValue(circle1->value()+1); else { circle1->setValue(circle1->minimum()); circle1->setState(NormalProgress); } }); connect(m_pTimer,&QTimer::timeout,circle4,[=](){ if(circle4->value()maximum()) circle4->setValue(circle4->value()+1); else { circle4->setValue(circle4->minimum()); circle4->setState(NormalProgress); } }); m_pTimer->start(); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testProgressCircle/main.cpp0000664000175000017500000000257014474244170026525 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testProgressCircle/widget.h0000664000175000017500000000200314474244170026520 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: QTimer* m_pTimer; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbreadcrumb/0000775000175000017500000000000014474244170024251 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbreadcrumb/testbreadcrumb.pro0000664000175000017500000000200114474244076027777 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 CONFIG += link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbreadcrumb/widget.cpp0000664000175000017500000000407514474244170026246 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* mainLayout = new QVBoxLayout; QHBoxLayout* hLayout = new QHBoxLayout; KBreadCrumb*crumb = new KBreadCrumb(this); //默认是true crumb->setFlat(true); crumb->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); crumb->addTab("页面目录一"); crumb->addTab("页面目录二"); crumb->addTab("页面目录三"); crumb->addTab("短的"); crumb->addTab("长的长的长的长的长的长的"); crumb->setIcon(QIcon::fromTheme("dialog-info")); //设置KBreadCrumb的图标 hLayout->addWidget(crumb); mainLayout->addLayout(hLayout); hLayout = new QHBoxLayout; KBreadCrumb*crumb2 = new KBreadCrumb(this); //默认是true crumb->setFlat(false); //设置KBreadCrumb是否为flat类型 crumb2->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); crumb2->addTab("页面目录一"); crumb2->addTab("页面目录二"); crumb2->addTab("页面目录三"); crumb2->addTab("短的"); crumb2->addTab("长的很长的特别长的特别特别长的"); crumb2->setIcon(QIcon::fromTheme("dialog-warning")); hLayout->addWidget(crumb2); mainLayout->addLayout(hLayout); baseBar()->setLayout(mainLayout); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbreadcrumb/main.cpp0000664000175000017500000000257014474244170025705 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kwidgetutils.h" #include #include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testbreadcrumb/widget.h0000664000175000017500000000177714474244170025721 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include "kwidget.h" #include "kbreadcrumb.h" using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/0000775000175000017500000000000014474244170024371 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/testKPushButton.pro0000664000175000017500000000202014474244076030240 0ustar adminadminQT += core gui KWindowSystem 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 kysdk-widgetutils # 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/widget.cpp0000664000175000017500000001005214474244170026356 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Xiangwei Liu * */ #include "widget.h" #include "kpushbutton.h" #include #include #include using namespace kdk; Widget::Widget(QWidget *parent) : QWidget(parent) { QHBoxLayout *layout1 = new QHBoxLayout(); /*半透明字体按钮布局,包括按钮1、2、3*/ KPushButton *btn1 = new KPushButton(this); /*不可用透明按钮*/ btn1->setText("button1"); btn1->setTranslucent(true); btn1->setEnabled(false); KPushButton *btn2 = new KPushButton(this); /*可用透明按钮*/ btn2->setText("button2"); btn2->setTranslucent(true); btn2->setBackgroundColor(Qt::blue); KPushButton *btn3 = new KPushButton(this); /*圆形透明按钮,如果需要设置为正圆需要自己设置大小,默认跟随layout*/ btn3->setText("button3"); btn3->setTranslucent(true); btn3->setButtonType(KPushButton::CircleType); layout1->addWidget(btn1); layout1->addWidget(btn2); layout1->addWidget(btn3); QHBoxLayout *layout2 = new QHBoxLayout(); /*半透明图标按钮,包括按钮4、5*/ KPushButton *btn4 = new KPushButton(this); btn4->setIcon(QIcon::fromTheme("go-previous-symbolic")); btn4->setTranslucent(true); btn4->setFixedSize(32,32); btn4->setIconSize(QSize(24,24)); btn4->setBackgroundColor(Qt::blue); KPushButton *btn5 = new KPushButton(this); btn5->setIcon(QIcon::fromTheme("go-next-symbolic")); btn5->setTranslucent(true); btn5->setFixedSize(32,32); btn5->setIconSize(QSize(24,24)); layout2->addWidget(btn4); layout2->addWidget(btn5); QHBoxLayout *layout3 = new QHBoxLayout(); /*正常带图标不透明按钮,包括6、7*/ KPushButton *btn6 = new KPushButton(this); btn6->setIcon(QIcon::fromTheme("go-previous-symbolic")); btn6->setFixedSize(32,32); btn6->setIconSize(QSize(24,24)); btn6->setIconHighlight(true); btn6->setBackgroundColor(Qt::transparent); KPushButton *btn7 = new KPushButton(this); btn7->setIcon(QIcon::fromTheme("go-next-symbolic")); btn7->setFixedSize(32,32); btn7->setIconSize(QSize(24,24)); btn7->setIconHighlight(true); btn7->setBackgroundColor(Qt::transparent); layout3->addWidget(btn6); layout3->addWidget(btn7); QHBoxLayout *layout4 = new QHBoxLayout(); KPushButton *btn8 = new KPushButton(this); /*设置文字且设置圆角的不透明按钮*/ btn8->setText("button8"); btn8->setBorderRadius(10); KPushButton *btn9 = new KPushButton(this); /*设置图标且设置圆角的不透明按钮*/ btn9->setIcon(QIcon::fromTheme("list-add-symbolic")); btn9->setIconColor(Qt::white); btn9->setBackgroundColorHighlight(true); /*设置按钮背景色跟随系统高亮色*/ //btn9->setBackgroundColor(Qt::red); /*用户设置自定义背景色(与跟随系统高亮存在先后关系,后设置的生效)*/ btn9->setFixedSize(40,40); btn9->setBorderRadius(20); btn9->setIconSize(QSize(24,24)); layout4->addWidget(btn8); layout4->addWidget(btn9); QVBoxLayout *layout = new QVBoxLayout(this); layout->addLayout(layout1); layout->addLayout(layout2); layout->addLayout(layout3); layout->addLayout(layout4); this->setLayout(layout); } Widget::~Widget() { } void Widget::onButtonClicked() { qDebug() << "clicked" ; } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/src.qrc0000664000175000017500000000006414474244076025674 0ustar adminadmin libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/main.cpp0000664000175000017500000000303414474244170026021 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Xiangwei Liu * */ #include "widget.h" #include #include #include #include #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); w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testKPushButton/widget.h0000664000175000017500000000175714474244170026037 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Xiangwei Liu * */ #ifndef WIDGET_H #define WIDGET_H #include class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); public slots: void onButtonClicked(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressbar/0000775000175000017500000000000014474244170024474 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressbar/testprogressbar.pro0000664000175000017500000000200214474244076030446 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressbar/widget.cpp0000664000175000017500000000702714474244170026471 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #include Widget::Widget(QWidget *parent) : KWidget(parent) { m_pTimer = new QTimer(this); m_pTimer->setInterval(50); QVBoxLayout* vLayout = new QVBoxLayout(this); QHBoxLayout* tmpLayout = new QHBoxLayout(); m_pVerticalBar = new KProgressBar(this); m_pVerticalBar->setOrientation(Qt::Vertical); //设置KProgressBar方向 m_pVerticalBar->setTextVisible(false); m_pVerticalBar->setRange(0,100); m_pVerticalBar->setValue(50); tmpLayout->addWidget(m_pVerticalBar); vLayout->addLayout(tmpLayout); QHBoxLayout* hLayout = new QHBoxLayout(this); m_pHorizontalBar = new KProgressBar(this); m_pHorizontalBar->setRange(0,100); m_pHorizontalBar->setValue(50); hLayout->addWidget(m_pHorizontalBar); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(this); m_pStartBtn = new QPushButton(this); m_pStartBtn->setText("开始"); m_pStopBtn = new QPushButton(this); m_pStopBtn->setText("停止"); m_pRestoreBtn = new QPushButton(this); m_pRestoreBtn->setText("恢复"); hLayout->addStretch(); hLayout->addWidget(m_pStartBtn); hLayout->addWidget(m_pStopBtn); hLayout->addWidget(m_pRestoreBtn); hLayout->addStretch(); vLayout->addLayout(hLayout); baseBar()->setLayout(vLayout); connect(m_pTimer,&QTimer::timeout,this,[=](){ if(m_pVerticalBar->value() != m_pVerticalBar->maximum()) m_pVerticalBar->setValue(m_pVerticalBar->value()+1); else { m_pVerticalBar->setValue(m_pVerticalBar->minimum()); m_pVerticalBar->setState(ProgressBarState::NormalProgress); //设置KprogressBar状态 } if(m_pHorizontalBar->value() != m_pHorizontalBar->maximum()) m_pHorizontalBar->setValue(m_pHorizontalBar->value()+1); else { m_pHorizontalBar->setValue(m_pHorizontalBar->minimum()); m_pHorizontalBar->setState(ProgressBarState::NormalProgress); } }); connect(m_pStartBtn,&QPushButton::clicked,this,[=](){ if(!m_pTimer->isActive()) m_pTimer->start(); //qDebug() << m_pVerticalBar->text(); //获取文本值 }); connect(m_pStopBtn,&QPushButton::clicked,this,[=]() { m_pTimer->stop(); m_pVerticalBar->setState(ProgressBarState::FailedProgress); m_pHorizontalBar->setState(ProgressBarState::FailedProgress); }); connect(m_pRestoreBtn,&QPushButton::clicked,this,[=]() { m_pTimer->start(); m_pVerticalBar->setValue(0); m_pVerticalBar->setState(ProgressBarState::NormalProgress); m_pHorizontalBar->setValue(0); m_pHorizontalBar->setState(ProgressBarState::NormalProgress); }); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressbar/main.cpp0000664000175000017500000000246514474244170026133 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include 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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testprogressbar/widget.h0000664000175000017500000000232614474244170026133 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "kprogressbar.h" #include #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KProgressBar* m_pVerticalBar; KProgressBar* m_pHorizontalBar; QPushButton* m_pStartBtn; QPushButton* m_pStopBtn; QPushButton* m_pRestoreBtn; QTimer* m_pTimer; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testcolorbutton/0000775000175000017500000000000014474244170024515 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testcolorbutton/widget.cpp0000664000175000017500000000775214474244170026517 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include "kcolorbutton.h" #include #include #include 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() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testcolorbutton/main.cpp0000664000175000017500000000164614474244170026154 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testcolorbutton/testcolorbutton.pro0000664000175000017500000000175714474244076030530 0ustar adminadminQT += 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testcolorbutton/widget.h0000664000175000017500000000174314474244170026156 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsecuritylevelbar/0000775000175000017500000000000014474244170025527 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsecuritylevelbar/testsecuritylevelbar.pro0000664000175000017500000000200114474244076032533 0ustar adminadminQT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += link_pkgconfig PKGCONFIG += kysdk-qtwidgets kysdk-widgetutils 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 += \ 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 libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsecuritylevelbar/widget.cpp0000664000175000017500000000405414474244170027521 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include Widget::Widget(QWidget *parent) : KWidget(parent) { QVBoxLayout* vLayout = new QVBoxLayout(); QHBoxLayout*hLayout = new QHBoxLayout(); m_pInfoLabel = new QLabel("请设置密码:",this); m_pLineEdit = new QLineEdit(this); m_pLineEdit->setEchoMode(QLineEdit::Password); hLayout->addWidget(m_pInfoLabel); hLayout->addWidget(m_pLineEdit); vLayout->addStretch(); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); m_pBar = new KSecurityLevelBar(this); //构建一个安全等级提示条 m_pBar->hide(); //隐藏安全等级提示条 hLayout->addWidget(m_pBar); vLayout->addLayout(hLayout); vLayout->addStretch(); baseBar()->setLayout(vLayout); //连接槽函数,根据输入密码的长度来设置安全等级进度条的等级并显示。 connect(m_pLineEdit,&QLineEdit::textChanged,this,[=](){ int length = m_pLineEdit->text().length(); if(length<8) m_pBar->setSecurityLevel(SecurityLevel::Low); //设置安全等级 else if(length >=8 && length<12) m_pBar->setSecurityLevel(SecurityLevel::Medium); else m_pBar->setSecurityLevel(SecurityLevel::High); m_pBar->show(); }); } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsecuritylevelbar/main.cpp0000664000175000017500000000257014474244170027163 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include #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(); } libkysdk-applications-2.2.1.1/kysdk-qtwidgets/test/testsecuritylevelbar/widget.h0000664000175000017500000000224714474244170027170 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include "kwidget.h" #include "ksecuritylevelbar.h" #include #include #include using namespace kdk; class Widget : public KWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); private: KSecurityLevelBar* m_pBar; QLineEdit* m_pLineEdit; QLabel* m_pInfoLabel; QPushButton* m_pBtn; }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-qtwidgets/kysdk-qtwidgets.pro0000664000175000017500000000717314474244170024154 0ustar adminadminQT += widgets core sql x11extras KWindowSystem dbus TEMPLATE = lib DEFINES += GUI_LIBRARY CONFIG += c++11 VERSION = 1.2.0 # 适配窗口管理器圆角阴影 LIBS +=-lX11 # 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 CONFIG += link_pkgconfig PKGCONFIG += gsettings-qt INCLUDEPATH += ../kysdk-waylandhelper/src LIBS += -L../kysdk-waylandhelper -lkysdk-waylandhelper TRANSLATIONS += ./translations/gui_zh_CN.ts \ ./translations/gui_bo_CN.ts \ ./translations/gui_mn.ts SOURCES += \ src/parmscontroller.cpp\ src/kbreadcrumb.cpp \ src/kcolorcombobox.cpp \ src/kpasswordedit.cpp \ src/kpixmapcontainer.cpp \ src/kprogressbar.cpp \ src/kprogresscircle.cpp \ src/ksecuritylevelbar.cpp \ src/kbadge.cpp \ src/kballontip.cpp \ src/kdialog.cpp \ src/kcommentpanel.cpp \ src/kiconbar.cpp \ src/kinputdialog.cpp \ src/kmenubutton.cpp \ src/knavigationbar.cpp \ src/kprogressdialog.cpp \ src/ksearchlineedit.cpp \ src/kslider.cpp \ src/ktag.cpp \ src/ktoolbutton.cpp \ src/kwindowbuttonbar.cpp \ src/kuninstalldialog.cpp \ src/kwidget.cpp \ src/themeController.cpp \ src/kaboutdialog.cpp \ src/kborderbutton.cpp \ src/kborderlessbutton.cpp \ src/kswitchbutton.cpp \ src/ktabbar.cpp \ src/xatom-helper.cpp\ src/kitemwidget.cpp\ src/klistwidget.cpp\ src/klistview.cpp\ src/klistviewdelegate.cpp\ src/kshadowhelper.cpp\ src/kpressbutton.cpp\ src/kpushbutton.cpp\ src/ktranslucentfloor.cpp\ src/kbubblewidget.cpp\ src/kbuttonbox.cpp\ src/kbackgroundgroup.cpp\ src/klineframe.cpp\ src/kcolorbutton.cpp\ src/kmessagebox.cpp HEADERS += \ src/parmscontroller.h\ src/kbreadcrumb.h \ src/kcolorcombobox.h \ src/kpasswordedit.h \ src/kpixmapcontainer.h \ src/kprogressbar.h \ src/kprogresscircle.h \ src/ksecuritylevelbar.h \ src/kbadge.h \ src/kballontip.h \ src/kdialog.h \ src/kcommentpanel.h \ src/kiconbar.h \ src/kinputdialog.h \ src/kmenubutton.h \ src/knavigationbar.h \ src/kprogressdialog.h \ src/ksearchlineedit.h \ src/kslider.h \ src/ktag.h \ src/ktoolbutton.h \ src/kwindowbuttonbar.h \ src/kuninstalldialog.h \ src/kwidget.h \ src/themeController.h \ src/kaboutdialog.h \ src/kborderbutton.h \ src/kborderlessbutton.h \ src/kswitchbutton.h \ src/ktabbar.h \ src/gui_g.h \ src/xatom-helper.h \ src/kitemwidget.h\ src/klistwidget.h\ src/klistview.h\ src/klistviewdelegate.h\ src/kshadowhelper.h\ src/kpressbutton.h\ src/kpushbutton.h\ src/ktranslucentfloor.h\ src/kbubblewidget.h\ src/kbuttonbox.h\ src/kbackgroundgroup.h\ src/klineframe.h\ src/kcolorbutton.h\ src/kmessagebox.h # Default rules for deployment. headers.files = $${HEADERS} headers.path = /usr/include/kysdk/applications/ target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu INSTALLS += target headers RESOURCES += \ res.qrc DISTFILES += \ translations/gui_bo_CN.ts libkysdk-applications-2.2.1.1/kysdk-widgetutils/0000775000175000017500000000000014474244170020615 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-widgetutils/src/0000775000175000017500000000000014474244170021404 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-widgetutils/src/kysdk-widgetutils_global.h0000664000175000017500000000207314474244170026566 0ustar adminadmin/* * libkysdk-widgetutils's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KYSDKWIDGETUTILS_GLOBAL_H #define KYSDKWIDGETUTILS_GLOBAL_H #include #if defined(KYSDKWIDGETUTILS_LIBRARY) # define KYSDKWIDGETUTILS_EXPORT Q_DECL_EXPORT #else # define KYSDKWIDGETUTILS_EXPORT Q_DECL_IMPORT #endif #endif // KYSDKWIDGETUTILS_GLOBAL_H libkysdk-applications-2.2.1.1/kysdk-widgetutils/src/kwidgetutils.cpp0000664000175000017500000000611114474244170024626 0ustar adminadmin/* * libkysdk-widgetutils's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "kwidgetutils.h" #include #include #include #include #include #include #include #define KWIN_SERVICE "org.ukui.KWin" #define KWIN_PATH "/Compositor" #define KWIN_INTERFACE "org.ukui.kwin.Compositing" using namespace kdk; KWidgetUtils::KWidgetUtils() { } void KWidgetUtils::highDpiScaling() { #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); qDebug()<<"setAttribute success"; #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); 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; } libkysdk-applications-2.2.1.1/kysdk-widgetutils/src/kwidgetutils.h0000664000175000017500000000261614474244170024301 0ustar adminadmin/* * libkysdk-widgetutils's Library * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef KWIDGETUTILS_H #define KWIDGETUTILS_H #include "kysdk-widgetutils_global.h" namespace kdk { class KYSDKWIDGETUTILS_EXPORT KWidgetUtils { public: KWidgetUtils(); /** * @brief 适配高分屏,需要在定义QApplication对象前,调用该函数 * KWidgetUtils::highDpiScaling(); * QApplication a(argc, argv); */ static void highDpiScaling(); /** * @brief 判断合成器是否开启 * * @param 无 * * @retval true 开启 * @retval false 没开启 */ static bool checkCompositorRunning(void); }; } #endif // KWIDGETUTILS_H libkysdk-applications-2.2.1.1/kysdk-widgetutils/test/0000775000175000017500000000000014474244076021601 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/build-testWidgetutils-unknown-Debug/0000775000175000017500000000000014474244076030623 5ustar adminadmin././@LongLink0000644000000000000000000000014700000000000011605 Lustar rootrootlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/build-testWidgetutils-unknown-Debug/moc_predefs.hlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/build-testWidgetutils-unknown-Debug/moc_predefs0000664000175000017500000003452614474244076033046 0ustar adminadmin#define __SSP_STRONG__ 3 #define __DBL_MIN_EXP__ (-1021) #define __FLT32X_MAX_EXP__ 1024 #define __cpp_attributes 200809 #define __UINT_LEAST16_MAX__ 0xffff #define __ARM_SIZEOF_WCHAR_T 4 #define __ATOMIC_ACQUIRE 2 #define __FLT128_MAX_10_EXP__ 4932 #define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define __INTMAX_C(c) c ## L #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __WINT_MAX__ 0xffffffffU #define __FLT32_MIN_EXP__ (-125) #define __cpp_static_assert 200410 #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffffffffffUL #define __WCHAR_MAX__ 0xffffffffU #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define __GCC_IEC_559 2 #define __FLT32X_DECIMAL_DIG__ 17 #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __cpp_binary_literals 201304 #define __FLT64_DECIMAL_DIG__ 17 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __cpp_variadic_templates 200704 #define __UINT_FAST64_MAX__ 0xffffffffffffffffUL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FLT16_EPSILON__ 9.76562500000000000000000000000000000e-4F16 #define __FINITE_MATH_ONLY__ 0 #define __ARM_FEATURE_UNALIGNED 1 #define __GNUC_PATCHLEVEL__ 0 #define __FLT32_HAS_DENORM__ 1 #define __UINT_FAST8_MAX__ 0xff #define __cpp_rvalue_reference 200610 #define __has_include(STR) __has_include__(STR) #define __DEC64_MAX_EXP__ 385 #define __INT8_C(c) c #define __INT_LEAST8_WIDTH__ 8 #define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L #define __ARM_FEATURE_IDIV 1 #define __FLT64X_MAX_10_EXP__ 4932 #define __ARM_FP 14 #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128 #define __UINTMAX_TYPE__ long unsigned int #define __linux 1 #define __DEC32_EPSILON__ 1E-6DF #define __FLT_EVAL_METHOD_TS_18661_3__ 0 #define __CHAR_UNSIGNED__ 1 #define __UINT32_MAX__ 0xffffffffU #define __GXX_EXPERIMENTAL_CXX0X__ 1 #define __AARCH64_CMODEL_SMALL__ 1 #define __LDBL_MAX_EXP__ 16384 #define __FLT128_MIN_EXP__ (-16381) #define __WINT_MIN__ 0U #define __linux__ 1 #define __FLT128_MIN_10_EXP__ (-4931) #define __INT_LEAST16_WIDTH__ 16 #define __SCHAR_MAX__ 0x7f #define __FLT128_MANT_DIG__ 113 #define __WCHAR_MIN__ 0U #define __INT64_C(c) c ## L #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __FLT64X_MANT_DIG__ 113 #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 8 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define __USER_LABEL_PREFIX__ #define __FLT64X_EPSILON__ 1.92592994438723585305597794258492732e-34F64x #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define __ARM_ALIGN_MAX_STACK_PWR 16 #define __FLT32_DIG__ 6 #define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F #define __GXX_WEAK__ 1 #define __SHRT_WIDTH__ 16 #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L #define __DEC32_MAX__ 9.999999E96DF #define __cpp_threadsafe_static_init 200806 #define __ARM_SIZEOF_MINIMAL_ENUM 4 #define __FLT64X_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F64x #define __FLT32X_HAS_INFINITY__ 1 #define __INT32_MAX__ 0x7fffffff #define __INT_WIDTH__ 32 #define __SIZEOF_LONG__ 8 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201706L #define __UINT16_C(c) c #define __PTRDIFF_WIDTH__ 64 #define __DECIMAL_DIG__ 36 #define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64 #define __gnu_linux__ 1 #define __INTMAX_WIDTH__ 64 #define __FLT64_MIN_EXP__ (-1021) #define __has_include_next(STR) __has_include_next__(STR) #define __FLT64X_MIN_10_EXP__ (-4931) #define __LDBL_HAS_QUIET_NAN__ 1 #define __FLT16_MIN_EXP__ (-13) #define __FLT64_MANT_DIG__ 53 #define __GNUC__ 9 #define __GXX_RTTI 1 #define __pie__ 2 #define __cpp_delegating_constructors 200604 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define __BIGGEST_ALIGNMENT__ 16 #define __STDC_UTF_16__ 1 #define __FLT64_MAX_10_EXP__ 308 #define __FLT16_MAX_10_EXP__ 4 #define __FLT32_HAS_INFINITY__ 1 #define __DBL_MAX__ double(1.79769313486231570814527423731704357e+308L) #define __cpp_raw_strings 200710 #define __INT_FAST32_MAX__ 0x7fffffffffffffffL #define __DBL_HAS_INFINITY__ 1 #define __HAVE_SPECULATION_SAFE_VALUE 1 #define __DEC32_MIN_EXP__ (-94) #define __INTPTR_WIDTH__ 64 #define __FLT32X_HAS_DENORM__ 1 #define __INT_FAST16_TYPE__ long int #define __LDBL_HAS_DENORM__ 1 #define __cplusplus 201103L #define __cpp_ref_qualifiers 200710 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define __DEC32_MIN__ 1E-95DF #define __DEPRECATED 1 #define __cpp_rvalue_references 200610 #define __DBL_MAX_EXP__ 1024 #define __WCHAR_WIDTH__ 32 #define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32 #define __DEC128_EPSILON__ 1E-33DL #define __FLT16_DECIMAL_DIG__ 5 #define __PTRDIFF_MAX__ 0x7fffffffffffffffL #define __FLT32_HAS_QUIET_NAN__ 1 #define __GNUG__ 9 #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 8 #define __ARM_ALIGN_MAX_PWR 28 #define __cpp_nsdmi 200809 #define __FLT64X_MIN_EXP__ (-16381) #define __SIZEOF_WINT_T__ 4 #define __LONG_LONG_WIDTH__ 64 #define __cpp_initializer_lists 200806 #define __FLT32_MAX_EXP__ 128 #define __cpp_hex_float 201603 #define __GCC_HAVE_DWARF2_CFI_ASM 1 #define __ARM_FP16_FORMAT_IEEE 1 #define __GXX_ABI_VERSION 1013 #define __FLT128_HAS_INFINITY__ 1 #define __FLT_MIN_EXP__ (-125) #define __FLT16_MANT_DIG__ 11 #define __cpp_lambdas 200907 #define __FLT64X_HAS_QUIET_NAN__ 1 #define __INT_FAST64_TYPE__ long int #define __FP_FAST_FMAF 1 #define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64 #define __DBL_MIN__ double(2.22507385850720138309023271733240406e-308L) #define __PIE__ 2 #define __FLT16_DENORM_MIN__ 5.96046447753906250000000000000000000e-8F16 #define __LP64__ 1 #define __FLT_EVAL_METHOD_C99__ 0 #define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x #define __aarch64__ 1 #define __FLT64_MIN_10_EXP__ (-307) #define __ARM_FP16_ARGS 1 #define __FLT16_MIN_10_EXP__ (-4) #define __FLT64X_DECIMAL_DIG__ 36 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32 #define __UINT8_TYPE__ unsigned char #define __NO_INLINE__ 1 #define __FLT_MANT_DIG__ 24 #define __LDBL_DECIMAL_DIG__ 36 #define __VERSION__ "9.3.0" #define __UINT64_C(c) c ## UL #define __cpp_unicode_characters 200704 #define _STDC_PREDEF_H 1 #define __ARM_FEATURE_FMA 1 #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __FLT128_MAX_EXP__ 16384 #define __FLT32_MANT_DIG__ 24 #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT32X_MIN_EXP__ (-1021) #define __FLT16_DIG__ 3 #define __STDC_IEC_559_COMPLEX__ 1 #define __FLT128_HAS_DENORM__ 1 #define __FLT128_DIG__ 33 #define __SCHAR_WIDTH__ 8 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __FLT32_MAX_10_EXP__ 38 #define __ARM_64BIT_STATE 1 #define __INT_FAST32_TYPE__ long int #define __UINT_LEAST16_TYPE__ short unsigned int #define __FLT64X_HAS_INFINITY__ 1 #define unix 1 #define __DBL_HAS_DENORM__ 1 #define __INT16_MAX__ 0x7fff #define __cpp_rtti 199711 #define __SIZE_TYPE__ long unsigned int #define __UINT64_MAX__ 0xffffffffffffffffUL #define __FLT64X_DIG__ 33 #define __INT8_TYPE__ signed char #define __ELF__ 1 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __ARM_ARCH_PROFILE 65 #define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L #define __UINTMAX_C(c) c ## UL #define __GLIBCXX_BITSIZE_INT_N_0 128 #define __ARM_PCS_AAPCS64 1 #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __SIZEOF_PTRDIFF_T__ 8 #define __FLT32X_MANT_DIG__ 53 #define __AARCH64EL__ 1 #define __FLT16_MAX_EXP__ 16 #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define __INT_FAST16_MAX__ 0x7fffffffffffffffL #define __FLT64_DIG__ 15 #define __UINT_FAST32_MAX__ 0xffffffffffffffffUL #define __UINT_LEAST64_TYPE__ long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_MAX_10_EXP__ 38 #define __LONG_MAX__ 0x7fffffffffffffffL #define __FLT64X_HAS_DENORM__ 1 #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define __unix 1 #define __cpp_unicode_literals 200710 #define __UINT_FAST16_TYPE__ long unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __INT_FAST32_WIDTH__ 64 #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __SIZE_WIDTH__ 64 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __INT64_MAX__ 0x7fffffffffffffffL #define __UINT_LEAST32_MAX__ 0xffffffffU #define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __SIG_ATOMIC_WIDTH__ 32 #define __INT_LEAST64_TYPE__ long int #define __ARM_FEATURE_CLZ 1 #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ signed char #define __FLT16_MAX__ 6.55040000000000000000000000000000000e+4F16 #define __DEC32_MAX_EXP__ 97 #define __INT_FAST8_MAX__ 0x7f #define __ARM_ARCH 8 #define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128 #define __INTPTR_MAX__ 0x7fffffffffffffffL #define linux 1 #define __cpp_range_based_for 200907 #define __FLT64_HAS_QUIET_NAN__ 1 #define __FLT32_MIN_10_EXP__ (-37) #define __EXCEPTIONS 1 #define __LDBL_MANT_DIG__ 113 #define __DBL_HAS_QUIET_NAN__ 1 #define __FLT64_HAS_INFINITY__ 1 #define __FLT64X_MAX__ 1.18973149535723176508575932662800702e+4932F64x #define __FLT16_HAS_INFINITY__ 1 #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __INTPTR_TYPE__ long int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ unsigned int #define __SIZEOF_FLOAT__ 4 #define __pic__ 2 #define __UINTPTR_MAX__ 0xffffffffffffffffUL #define __ARM_ARCH_8A 1 #define __INT_FAST64_WIDTH__ 64 #define __DEC64_MIN_EXP__ (-382) #define __cpp_decltype 200707 #define __FLT32_DECIMAL_DIG__ 9 #define __INT_FAST64_MAX__ 0x7fffffffffffffffL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __FLT_DIG__ 6 #define __FLT64X_MAX_EXP__ 16384 #define __UINT_FAST64_TYPE__ long unsigned int #define __INT_MAX__ 0x7fffffff #define __FLT16_HAS_QUIET_NAN__ 1 #define __INT64_TYPE__ long int #define __FLT_MAX_EXP__ 128 #define __ORDER_BIG_ENDIAN__ 4321 #define __DBL_MANT_DIG__ 53 #define __cpp_inheriting_constructors 201511 #define __INT_LEAST64_MAX__ 0x7fffffffffffffffL #define __FP_FAST_FMAF32 1 #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __LDBL_MIN_EXP__ (-16381) #define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64 #define __WINT_WIDTH__ 32 #define __FP_FAST_FMAF64 1 #define __INT_LEAST8_MAX__ 0x7f #define __FLT32X_MAX_10_EXP__ 308 #define __SIZEOF_INT128__ 16 #define __FLT16_MIN__ 6.10351562500000000000000000000000000e-5F16 #define __WCHAR_UNSIGNED__ 1 #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L) #define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128 #define _LP64 1 #define __UINT8_C(c) c #define __FLT64_MAX_EXP__ 1024 #define __INT_LEAST32_TYPE__ int #define __SIZEOF_WCHAR_T__ 4 #define __ARM_NEON 1 #define __FLT128_HAS_QUIET_NAN__ 1 #define __INT_FAST8_TYPE__ signed char #define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x #define __GNUC_STDC_INLINE__ 1 #define __FLT64_HAS_DENORM__ 1 #define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32 #define __FP_FAST_FMAF32x 1 #define __FLT16_HAS_DENORM__ 1 #define __DBL_DECIMAL_DIG__ 17 #define __STDC_UTF_32__ 1 #define __INT_FAST8_WIDTH__ 8 #define __DEC_EVAL_METHOD__ 2 #define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x #define __cpp_runtime_arrays 198712 #define __UINT64_TYPE__ long unsigned int #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffL #define __cpp_alias_templates 200704 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F #define __INT8_MAX__ 0x7f #define __LONG_WIDTH__ 64 #define __PIC__ 2 #define __UINT_FAST32_TYPE__ long unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F #define __FP_FAST_FMA 1 #define __cpp_constexpr 200704 #define __ARM_FEATURE_NUMERIC_MAXMIN 1 #define __INT32_TYPE__ int #define __SIZEOF_DOUBLE__ 8 #define __cpp_exceptions 199711 #define __FLT_MIN_10_EXP__ (-37) #define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64 #define __INT_LEAST32_WIDTH__ 32 #define __INTMAX_TYPE__ long int #define __DEC128_MAX_EXP__ 6145 #define __FLT32X_HAS_QUIET_NAN__ 1 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 3 #define __GLIBCXX_TYPE_INT_N_0 __int128 #define __INT_FAST16_WIDTH__ 64 #define __UINTMAX_MAX__ 0xffffffffffffffffUL #define __DEC32_MANT_DIG__ 7 #define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L #define __INT16_C(c) c #define __ARM_ARCH_ISA_A64 1 #define __STDC__ 1 #define __FLT32X_DIG__ 15 #define __PTRDIFF_TYPE__ long int #define __ATOMIC_SEQ_CST 5 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 #define __UINT32_TYPE__ unsigned int #define __FLT32X_MIN_10_EXP__ (-307) #define __UINTPTR_TYPE__ long unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128 #define __SIZEOF_LONG_LONG__ 8 #define __cpp_user_defined_literals 200809 #define __FLT128_DECIMAL_DIG__ 36 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x #define __LDBL_DIG__ 33 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffffffffffUL #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __INT_LEAST64_WIDTH__ 64 #define __UINT_FAST8_TYPE__ unsigned char #define _GNU_SOURCE 1 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_RELEASE 3 ././@LongLink0000644000000000000000000000014600000000000011604 Lustar rootrootlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/build-testWidgetutils-unknown-Debug/.qmake.stashlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/build-testWidgetutils-unknown-Debug/.qmake.stas0000664000175000017500000000126514474244076032677 0ustar adminadminQMAKE_CXX.QT_COMPILER_STDCXX = 201402L QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 9 QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 QMAKE_CXX.COMPILER_MACROS = \ QT_COMPILER_STDCXX \ QMAKE_GCC_MAJOR_VERSION \ QMAKE_GCC_MINOR_VERSION \ QMAKE_GCC_PATCH_VERSION QMAKE_CXX.INCDIRS = \ /usr/include/c++/9 \ /usr/include/aarch64-linux-gnu/c++/9 \ /usr/include/c++/9/backward \ /usr/lib/gcc/aarch64-linux-gnu/9/include \ /usr/local/include \ /usr/include/aarch64-linux-gnu \ /usr/include QMAKE_CXX.LIBDIRS = \ /usr/lib/gcc/aarch64-linux-gnu/9 \ /usr/lib/aarch64-linux-gnu \ /usr/lib \ /lib/aarch64-linux-gnu \ /lib libkysdk-applications-2.2.1.1/kysdk-widgetutils/test/testWidgetutils/0000775000175000017500000000000014474244170025000 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-widgetutils/test/testWidgetutils/widget.cpp0000664000175000017500000000155114474244170026771 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) { } Widget::~Widget() { } libkysdk-applications-2.2.1.1/kysdk-widgetutils/test/testWidgetutils/testWidgetutils.pro0000664000175000017500000000206514474244076030736 0ustar adminadminQT += core gui widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 link_pkgconfig 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 # 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 libkysdk-applications-2.2.1.1/kysdk-widgetutils/test/testWidgetutils/main.cpp0000664000175000017500000000205414474244170026431 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #include "widget.h" #include #include int main(int argc, char *argv[]) { KWidgetUtils::highDpiScaling(); QApplication a(argc, argv); Widget w; qDebug()<<"Compositor is running:"<< KWidgetUtils::checkCompositorRunning(); w.show(); return a.exec(); } libkysdk-applications-2.2.1.1/kysdk-widgetutils/test/testWidgetutils/widget.h0000664000175000017500000000175314474244170026442 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Zhen Sun * */ #ifndef WIDGET_H #define WIDGET_H #include #include using namespace kdk; class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = nullptr); ~Widget(); }; #endif // WIDGET_H libkysdk-applications-2.2.1.1/kysdk-widgetutils/kysdk-widgetutils.pro0000664000175000017500000000204214474244170025024 0ustar adminadminQT += widgets gui dbus TEMPLATE = lib DEFINES += KYSDKWIDGETUTILS_LIBRARY 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 # 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/kwidgetutils.cpp HEADERS += \ src/kysdk-widgetutils_global.h \ src/kwidgetutils.h # Default rules for deployment. headers.files = $${HEADERS} headers.path = /usr/include/kysdk/applications/ target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu INSTALLS += target headers libkysdk-applications-2.2.1.1/kysdk-application.pro0000664000175000017500000000032414474244076021302 0ustar adminadminTEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ kysdk-waylandhelper \ kysdk-widgetutils \ kysdk-qtwidgets \ kysdk-kabase/kabase \ kysdk-alm \ kysdk-ukenv \ kysdk-notification libkysdk-applications-2.2.1.1/COPYING0000664000175000017500000001674314474244170016174 0ustar adminadmin GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. libkysdk-applications-2.2.1.1/kysdk-alm/0000775000175000017500000000000014474244170017022 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-alm/kysdk-alm.pro0000664000175000017500000000075614474244170021450 0ustar adminadminQT += core network widgets KWindowSystem TARGET = kysdk-alm TEMPLATE = lib CONFIG += c++11 console HEADERS += src/singleapplication/singleapplication.h \ src/singleapplication/localpeer.h SOURCES += src/singleapplication/singleapplication.cpp \ src/singleapplication/localpeer.cpp # Default rules for deployment. headers.files = $${HEADERS} headers.path = /usr/include/kysdk/applications/ target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu INSTALLS += target headers libkysdk-applications-2.2.1.1/kysdk-alm/src/0000775000175000017500000000000014474244076017616 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/0000775000175000017500000000000014474244076023323 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/lockedfile.cpp0000664000175000017500000001373014474244076026134 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "lockedfile.h" /*! \class QtLockedFile \brief The QtLockedFile class extends QFile with advisory locking functions. A file may be locked in read or write mode. Multiple instances of \e QtLockedFile, created in multiple processes running on the same machine, may have a file locked in read mode. Exactly one instance may have it locked in write mode. A read and a write lock cannot exist simultaneously on the same file. The file locks are advisory. This means that nothing prevents another process from manipulating a locked file using QFile or file system functions offered by the OS. Serialization is only guaranteed if all processes that access the file use QLockedFile. Also, while holding a lock on a file, a process must not open the same file again (through any API), or locks can be unexpectedly lost. The lock provided by an instance of \e QtLockedFile is released whenever the program terminates. This is true even when the program crashes and no destructors are called. */ /*! \enum QtLockedFile::LockMode This enum describes the available lock modes. \value ReadLock A read lock. \value WriteLock A write lock. \value NoLock Neither a read lock nor a write lock. */ /*! Constructs an unlocked \e QtLockedFile object. This constructor behaves in the same way as \e QFile::QFile(). \sa QFile::QFile() */ QtLockedFile::QtLockedFile() : QFile() { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif m_lock_mode = NoLock; } /*! Constructs an unlocked QtLockedFile object with file \a name. This constructor behaves in the same way as \e QFile::QFile(const QString&). \sa QFile::QFile() */ QtLockedFile::QtLockedFile(const QString &name) : QFile(name) { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif m_lock_mode = NoLock; } /*! Opens the file in OpenMode \a mode. This is identical to QFile::open(), with the one exception that the Truncate mode flag is disallowed. Truncation would conflict with the advisory file locking, since the file would be modified before the write lock is obtained. If truncation is required, use resize(0) after obtaining the write lock. Returns true if successful; otherwise false. \sa QFile::open(), QFile::resize() */ bool QtLockedFile::open(OpenMode mode) { if (mode & QIODevice::Truncate) { qWarning("QtLockedFile::open(): Truncate mode not allowed."); return false; } return QFile::open(mode); } /*! Returns \e true if this object has a in read or write lock; otherwise returns \e false. \sa lockMode() */ bool QtLockedFile::isLocked() const { return m_lock_mode != NoLock; } /*! Returns the type of lock currently held by this object, or \e QtLockedFile::NoLock. \sa isLocked() */ QtLockedFile::LockMode QtLockedFile::lockMode() const { return m_lock_mode; } /*! \fn bool QtLockedFile::lock(LockMode mode, bool block = true) Obtains a lock of type \a mode. The file must be opened before it can be locked. If \a block is true, this function will block until the lock is aquired. If \a block is false, this function returns \e false immediately if the lock cannot be aquired. If this object already has a lock of type \a mode, this function returns \e true immediately. If this object has a lock of a different type than \a mode, the lock is first released and then a new lock is obtained. This function returns \e true if, after it executes, the file is locked by this object, and \e false otherwise. \sa unlock(), isLocked(), lockMode() */ /*! \fn bool QtLockedFile::unlock() Releases a lock. If the object has no lock, this function returns immediately. This function returns \e true if, after it executes, the file is not locked by this object, and \e false otherwise. \sa lock(), isLocked(), lockMode() */ /*! \fn QtLockedFile::~QtLockedFile() Destroys the \e QtLockedFile object. If any locks were held, they are released. */libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/singleapplication.cpp0000664000175000017500000002747714474244076027555 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include "singleapplication.h" #include "localpeer.h" /*! \class QtSingleApplication qtsingleapplication.h \brief The QtSingleApplication class provides an API to detect and communicate with running instances of an application. This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead. Another usecase is a client-server system, where the first started instance will assume the role of server, and the later instances will act as clients of that server. By default, the full path of the executable file is used to determine whether two processes are instances of the same application. You can also provide an explicit identifier string that will be compared instead. The application should create the QtSingleApplication object early in the startup phase, and call isRunning() to find out if another instance of this application is already running. If isRunning() returns false, it means that no other instance is running, and this instance has assumed the role as the running instance. In this case, the application should continue with the initialization of the application user interface before entering the event loop with exec(), as normal. The messageReceived() signal will be emitted when the running application receives messages from another instance of the same application. When a message is received it might be helpful to the user to raise the application so that it becomes visible. To facilitate this, QtSingleApplication provides the setActivationWindow() function and the activateWindow() slot. If isRunning() returns true, another instance is already running. It may be alerted to the fact that another instance has started by using the sendMessage() function. Also data such as startup parameters (e.g. the name of the file the user wanted this new instance to open) can be passed to the running instance with this function. Then, the application should terminate (or enter client mode). If isRunning() returns true, but sendMessage() fails, that is an indication that the running instance is frozen. Here's an example that shows how to convert an existing application to use QtSingleApplication. It is very simple and does not make use of all QtSingleApplication's functionality (see the examples for that). \code // Original int main(int argc, char **argv) { QApplication app(argc, argv); MyMainWidget mmw; mmw.show(); return app.exec(); } // Single instance int main(int argc, char **argv) { QtSingleApplication app(argc, argv); if (app.isRunning()) return !app.sendMessage(someDataString); MyMainWidget mmw; app.setActivationWindow(&mmw); mmw.show(); return app.exec(); } \endcode Once this QtSingleApplication instance is destroyed (normally when the process exits or crashes), when the user next attempts to run the application this instance will not, of course, be encountered. The next instance to call isRunning() or sendMessage() will assume the role as the new running instance. For console (non-GUI) applications, QtSingleCoreApplication may be used instead of this class, to avoid the dependency on the QtGui library. \sa QtSingleCoreApplication */ namespace kdk { void QtSingleApplication::sysInit(const QString &appId) { actWin = 0; peer = new QtLocalPeer(this, appId); connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); } /*! Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). \a argc, \a argv, and \a GUIenabled are passed on to the QAppliation constructor. If you are creating a console application (i.e. setting \a GUIenabled to false), you may consider using QtSingleCoreApplication instead. */ QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) : QApplication(argc, argv, GUIenabled) { sysInit(); } /*! Creates a QtSingleApplication object with the application identifier \a appId. \a argc and \a argv are passed on to the QAppliation constructor. */ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) : QApplication(argc, argv) { sysInit(appId); } #if QT_VERSION < 0x050000 /*! Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). \a argc, \a argv, and \a type are passed on to the QAppliation constructor. */ QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) : QApplication(argc, argv, type) { sysInit(); } #if defined(Q_WS_X11) /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, visual, cmap) { sysInit(); } /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a argv, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, argc, argv, visual, cmap) { sysInit(); } /*! Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be \a appId. \a dpy, \a argc, \a argv, \a visual, and \a cmap are passed on to the QApplication constructor. */ QtSingleApplication::QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, argc, argv, visual, cmap) { sysInit(appId); } #endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 /*! Returns true if another instance of this application is running; otherwise false. This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session). \sa sendMessage() */ bool QtSingleApplication::isRunning() { return peer->isClient(); } /*! Tries to send the text \a message to the currently running instance. The QtSingleApplication object in the running instance will emit the messageReceived() signal when it receives the message. This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within \a timeout milliseconds, this function return false. \sa isRunning(), messageReceived() */ bool QtSingleApplication::sendMessage(const QString &message, int timeout) { return peer->sendMessage(message, timeout); } /*! Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application. */ QString QtSingleApplication::id() const { return peer->applicationId(); } /*! Sets the activation window of this application to \a aw. The activation window is the widget that will be activated by activateWindow(). This is typically the application's main window. If \a activateOnMessage is true (the default), the window will be activated automatically every time a message is received, just prior to the messageReceived() signal being emitted. \sa activateWindow(), messageReceived() */ void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage) { actWin = aw; if (activateOnMessage) connect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow())); else disconnect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow())); } /*! Returns the applications activation window if one has been set by calling setActivationWindow(), otherwise returns 0. \sa setActivationWindow() */ QWidget *QtSingleApplication::activationWindow() const { return actWin; } /*! De-minimizes, raises, and activates this application's activation window. This function does nothing if no activation window has been set. This is a convenience function to show the user that this application instance has been activated when he has tried to start another instance. This function should typically be called in response to the messageReceived() signal. By default, that will happen automatically, if an activation window has been set. \sa setActivationWindow(), messageReceived(), initialize() */ void QtSingleApplication::activateWindow() { if (actWin) { // actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); // actWin->raise(); // actWin->activateWindow(); /* 改用窗管接口来激活界面 */ qDebug() << "kabase : activate window , window id is " << actWin->winId(); KWindowSystem::forceActiveWindow(actWin->winId()); actWin->update(); } } /*! \fn void QtSingleApplication::messageReceived(const QString& message) This signal is emitted when the current instance receives a \a message from another instance of this application. \sa sendMessage(), setActivationWindow(), activateWindow() */ /*! \fn void QtSingleApplication::initialize(bool dummy = true) \obsolete */ } // namespace kdk libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/lockedfile_unix.cpp0000664000175000017500000000655414474244076027205 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include #include #include "lockedfile.h" bool QtLockedFile::lock(LockMode mode, bool block) { if (!isOpen()) { qWarning("QtLockedFile::lock(): file is not opened"); return false; } if (mode == NoLock) return unlock(); if (mode == m_lock_mode) return true; if (m_lock_mode != NoLock) unlock(); struct flock fl; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; int cmd = block ? F_SETLKW : F_SETLK; int ret = fcntl(handle(), cmd, &fl); if (ret == -1) { if (errno != EINTR && errno != EAGAIN) qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } m_lock_mode = mode; return true; } bool QtLockedFile::unlock() { if (!isOpen()) { qWarning("QtLockedFile::unlock(): file is not opened"); return false; } if (!isLocked()) return true; struct flock fl; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_type = F_UNLCK; int ret = fcntl(handle(), F_SETLKW, &fl); if (ret == -1) { qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } m_lock_mode = NoLock; return true; } QtLockedFile::~QtLockedFile() { if (isOpen()) unlock(); }libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/singleapplication.h0000664000175000017500000000771414474244076027212 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef KYSDK_ALM_SINGLEAPPLICATION_SINGLEAPPLICATION_H_ #define KYSDK_ALM_SINGLEAPPLICATION_SINGLEAPPLICATION_H_ #include namespace kdk { class QtLocalPeer; #if defined(Q_OS_WIN) #if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) #define QT_QTSINGLEAPPLICATION_EXPORT #elif defined(QT_QTSINGLEAPPLICATION_IMPORT) #if defined(QT_QTSINGLEAPPLICATION_EXPORT) #undef QT_QTSINGLEAPPLICATION_EXPORT #endif #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) #elif defined(QT_QTSINGLEAPPLICATION_EXPORT) #undef QT_QTSINGLEAPPLICATION_EXPORT #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) #endif #else #define QT_QTSINGLEAPPLICATION_EXPORT #endif class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication { Q_OBJECT public: QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); QtSingleApplication(const QString &id, int &argc, char **argv); #if QT_VERSION < 0x050000 QtSingleApplication(int &argc, char **argv, Type type); #if defined(Q_WS_X11) QtSingleApplication(Display *dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); #endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 bool isRunning(); QString id() const; void setActivationWindow(QWidget *aw, bool activateOnMessage = true); QWidget *activationWindow() const; // Obsolete: void initialize(bool dummy = true) { isRunning(); Q_UNUSED(dummy) } public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); void activateWindow(); Q_SIGNALS: void messageReceived(const QString &message); private: void sysInit(const QString &appId = QString()); QtLocalPeer *peer; QWidget *actWin; }; } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/localpeer.cpp0000664000175000017500000001553714474244076026010 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include #include #include "localpeer.h" namespace kdk { #if defined(Q_OS_WIN) #include #include typedef BOOL(WINAPI *PProcessIdToSessionId)(DWORD, DWORD *); static PProcessIdToSessionId pProcessIdToSessionId = 0; #endif #if defined(Q_OS_UNIX) #include #include #include #endif namespace QtLP_Private { #include "lockedfile.cpp" #if defined(Q_OS_WIN) #include "qtlockedfile_win.cpp" #else #include "lockedfile_unix.cpp" #endif } // namespace QtLP_Private const char *QtLocalPeer::ack = "ack"; QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) : QObject(parent), id(appId) { QString prefix = id; if (id.isEmpty()) { id = QCoreApplication::applicationFilePath(); #if defined(Q_OS_WIN) id = id.toLower(); #endif prefix = id.section(QLatin1Char('/'), -1); } prefix.remove(QRegularExpression("[^a-zA-Z]")); prefix.truncate(6); QByteArray idc = id.toUtf8(); quint16 idNum = qChecksum(idc.constData(), idc.size()); socketName = QLatin1String("qtsingleapp-") + prefix + QLatin1Char('-') + QString::number(idNum, 16); #if defined(Q_OS_WIN) if (!pProcessIdToSessionId) { QLibrary lib("kernel32"); pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); } if (pProcessIdToSessionId) { DWORD sessionId = 0; pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); socketName += QLatin1Char('-') + QString::number(sessionId, 16); } #else socketName += QLatin1Char('-') + QString::number(getuid(), 16); #endif server = new QLocalServer(this); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName + QLatin1String("-lockfile"); lockFile.setFileName(lockName); lockFile.open(QIODevice::ReadWrite); } /* 服务端加锁 */ bool QtLocalPeer::isClient() { if (lockFile.isLocked()) return false; if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) return true; bool res = server->listen(socketName); #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) // ### Workaround if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { QFile::remove(QDir::cleanPath(QDir::tempPath()) + QLatin1Char('/') + socketName); res = server->listen(socketName); } #endif if (!res) qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); return false; } bool QtLocalPeer::sendMessage(const QString &message, int timeout) { if (!isClient()) return false; QLocalSocket socket; bool connOk = false; for (int i = 0; i < 2; i++) { // Try twice, in case the other instance is just starting up socket.connectToServer(socketName); connOk = socket.waitForConnected(timeout / 2); if (connOk || i) break; int ms = 250; #if defined(Q_OS_WIN) Sleep(DWORD(ms)); #else struct timespec ts = {ms / 1000, (ms % 1000) * 1000 * 1000}; nanosleep(&ts, NULL); #endif } if (!connOk) return false; QByteArray uMsg(message.toUtf8()); QDataStream ds(&socket); ds.writeBytes(uMsg.constData(), uMsg.size()); bool res = socket.waitForBytesWritten(timeout); if (res) { res &= socket.waitForReadyRead(timeout); // wait for ack if (res) res &= (socket.read(qstrlen(ack)) == ack); } return res; } void QtLocalPeer::receiveConnection() { QLocalSocket *socket = server->nextPendingConnection(); if (!socket) return; while (true) { if (socket->state() == QLocalSocket::UnconnectedState) { qWarning("QtLocalPeer: Peer disconnected"); delete socket; return; } if (socket->bytesAvailable() >= qint64(sizeof(quint32))) break; socket->waitForReadyRead(); } QDataStream ds(socket); QByteArray uMsg; quint32 remaining; ds >> remaining; uMsg.resize(remaining); int got = 0; char *uMsgBuf = uMsg.data(); do { got = ds.readRawData(uMsgBuf, remaining); remaining -= got; uMsgBuf += got; } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); if (got < 0) { qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); delete socket; return; } QString message(QString::fromUtf8(uMsg)); socket->write(ack, qstrlen(ack)); socket->waitForBytesWritten(1000); socket->waitForDisconnected(1000); // make sure client reads ack delete socket; Q_EMIT messageReceived(message); //### (might take a long time to return) } } // namespace kdk libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/lockedfile.h0000664000175000017500000000642514474244076025604 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef KYSDK_ALM_SINGLEAPPLICATION_LOCKEDFILE_H_ #define KYSDK_ALM_SINGLEAPPLICATION_LOCKEDFILE_H_ #include #ifdef Q_OS_WIN #include #endif #if defined(Q_OS_WIN) #if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) #define QT_QTLOCKEDFILE_EXPORT #elif defined(QT_QTLOCKEDFILE_IMPORT) #if defined(QT_QTLOCKEDFILE_EXPORT) #undef QT_QTLOCKEDFILE_EXPORT #endif #define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) #elif defined(QT_QTLOCKEDFILE_EXPORT) #undef QT_QTLOCKEDFILE_EXPORT #define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) #endif #else #define QT_QTLOCKEDFILE_EXPORT #endif namespace kdk { namespace QtLP_Private { class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { public: enum LockMode { NoLock = 0, ReadLock, WriteLock }; QtLockedFile(); QtLockedFile(const QString &name); ~QtLockedFile(); bool open(OpenMode mode); bool lock(LockMode mode, bool block = true); bool unlock(); bool isLocked() const; LockMode lockMode() const; private: #ifdef Q_OS_WIN Qt::HANDLE wmutex; Qt::HANDLE rmutex; QVector rmutexes; QString mutexname; Qt::HANDLE getMutexHandle(int idx, bool doCreate); bool waitMutex(Qt::HANDLE mutex, bool doBlock); #endif LockMode m_lock_mode; }; } // namespace QtLP_Private } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-alm/src/singleapplication/localpeer.h0000664000175000017500000000532514474244076025447 0ustar adminadmin/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef KYSDK_ALM_SINGLEAPPLICATION_LOCALPEER_H_ #define KYSDK_ALM_SINGLEAPPLICATION_LOCALPEER_H_ #include #include #include #include "lockedfile.h" namespace kdk { class QtLocalPeer : public QObject { Q_OBJECT public: QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); bool isClient(); bool sendMessage(const QString &message, int timeout); QString applicationId() const { return id; } Q_SIGNALS: void messageReceived(const QString &message); protected Q_SLOTS: void receiveConnection(); protected: QString id; QString socketName; QLocalServer *server; QtLP_Private::QtLockedFile lockFile; private: static const char *ack; }; } // namespace kdk #endif libkysdk-applications-2.2.1.1/kysdk-alm/test/0000775000175000017500000000000014474244076020006 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-alm/test/testsingleapplication/0000775000175000017500000000000014474244170024406 5ustar adminadminlibkysdk-applications-2.2.1.1/kysdk-alm/test/testsingleapplication/testsingleapplication.pro0000664000175000017500000000021014474244076031533 0ustar adminadminQT += widgets TARGET = testsingleapplication TEMPLATE = app CONFIG += c++11 link_pkgconfig PKGCONFIG += kysdk-alm SOURCES += main.cpplibkysdk-applications-2.2.1.1/kysdk-alm/test/testsingleapplication/main.cpp0000664000175000017500000000233414474244170026040 0ustar adminadmin/* * * * Copyright (C) 2023, KylinSoft Co., Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library. If not, see . * * Authors: Shengjie Ji * */ #include #include #include #include "singleapplication.h" int main(int argc, char *argv[]) { kdk::QtSingleApplication app(argc, argv); /* 设置单例 */ if (app.isRunning()) { qDebug() << "app is running"; app.sendMessage("running", 4000); return 0; } QWidget widget; /* 设置最小化拉起 */ app.setActivationWindow(&widget); widget.show(); return app.exec(); } libkysdk-applications-2.2.1.1/doxygen/0000775000175000017500000000000014474244076016610 5ustar adminadminlibkysdk-applications-2.2.1.1/doxygen/doxy_config0000664000175000017500000033106214474244076021050 0ustar adminadmin# Doxyfile 1.8.17 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the configuration # file that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "KYSDK gui" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER ="version:1.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all generated output in the proper direction. # Possible values are: None, LTR, RTL and Context. # The default value is: None. OUTPUT_TEXT_DIRECTION = None # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line # such as # /*************** # as being the beginning of a Javadoc-style comment "banner". If set to NO, the # Javadoc-style will behave just like regular comments and it will not be # interpreted by doxygen. # The default value is: NO. JAVADOC_BANNER = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines (in the resulting output). You can put ^^ in the value part of an # alias to insert a newline as if a physical newline was in the original file. # When you need a literal { or } or , in the value part of an alias you have to # escape them by means of a backslash (\), this can lead to conflicts with the # commands \{ and \} for these it is advised to use the version @{ and @} or use # a double escape (\\{ and \\}) ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice # sources only. Doxygen will then generate output that is more tailored for that # language. For instance, namespaces will be presented as modules, types will be # separated into more groups, etc. # The default value is: NO. OPTIMIZE_OUTPUT_SLICE = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, JavaScript, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # tries to guess whether the code is fixed or free formatted code, this is the # default for Fortran type files), VHDL, tcl. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is # Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 5. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 5 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. # The default value is: NO. EXTRACT_PRIV_VIRTUAL = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # declarations. If set to NO, these declarations will be included in the # documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # (including Cygwin) ands Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. If # EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. # The default value is: NO. WARN_AS_ERROR = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = ../src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: https://www.gnu.org/software/libiconv/) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), # *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen # C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd, # *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.h # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = XAtomHelper,MotifWmHints,TestWidget,ThemeController,UnityCorners # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = ../test # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = # If clang assisted parsing is enabled you can provide the clang parser with the # path to the compilation database (see: # http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files # were built. This is equivalent to specifying the "-p" option to a clang tool, # such as clang-check. These options will then be passed to the parser. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. CLANG_DATABASE_PATH = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that # are dynamically created via JavaScript. If disabled, the navigation index will # consists of multiple levels of tabs that are statically embedded in every HTML # page. Disable this option to support browsers that do not have JavaScript, # like the Qt help browser. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_MENUS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: https://developer.apple.com/xcode/), introduced with OSX # 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from https://www.mathjax.org before deployment. # The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/ # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /