From 150ce4a747e0fcc53cdce05a2a9d314d99cd494c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9F=AF?= Date: Thu, 28 May 2026 17:51:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5stable=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 13 +- debian/changelog | 6 + debian/control | 2 +- debian/qt5-ukui-platformtheme-coverage.xml | 2 + debian/qt5-ukui-platformtheme.install | 1 - debian/rules | 3 + libqt5-ukui-style/CMakeLists.txt | 4 + .../effects/highlight-effect.cpp | 193 +- libqt5-ukui-style/effects/highlight-effect.h | 3 + libqt5-ukui-style/settings/black-list.h | 22 +- .../settings/org.ukui.style.gschema.xml | 13 +- qt5-ukui-filedialog/CMakeLists.txt | 53 +- .../kyfiledialogrename.cpp | 86 +- .../kyfiledialogrename.h | 7 + qt5-ukui-filedialog/filedialogplugin.cpp | 22 + qt5-ukui-filedialog/filedialogplugin.h | 1 - qt5-ukui-filedialog/kyfiledialog.cpp | 524 ++- qt5-ukui-filedialog/kyfiledialog.h | 16 +- qt5-ukui-filedialog/menutoolbutoon.cpp | 8 +- qt5-ukui-filedialog/pathbar.cpp | 47 +- qt5-ukui-filedialog/sidebar.cpp | 77 +- qt5-ukui-filedialog/sidebar.h | 1 + .../translations/qt5-ukui-filedialog_bo_CN.ts | 136 +- .../translations/qt5-ukui-filedialog_cs.ts | 2 +- .../translations/qt5-ukui-filedialog_de.ts | 4 +- .../translations/qt5-ukui-filedialog_en_US.ts | 4 +- .../translations/qt5-ukui-filedialog_es.ts | 2 +- .../translations/qt5-ukui-filedialog_fa.ts | 2 +- .../translations/qt5-ukui-filedialog_fr.ts | 2 +- .../translations/qt5-ukui-filedialog_kk.ts | 392 +- .../translations/qt5-ukui-filedialog_ky.ts | 392 +- .../translations/qt5-ukui-filedialog_mn.ts | 123 +- .../translations/qt5-ukui-filedialog_ms.ts | 409 ++ .../translations/qt5-ukui-filedialog_th.ts | 409 ++ .../translations/qt5-ukui-filedialog_tr.ts | 2 +- .../translations/qt5-ukui-filedialog_ug.ts | 394 +- .../translations/qt5-ukui-filedialog_vi.ts | 409 ++ .../translations/qt5-ukui-filedialog_zh_CN.ts | 4 +- .../translations/qt5-ukui-filedialog_zh_HK.ts | 4 +- .../qt5-ukui-filedialog_zh_Hant.ts | 451 +-- qt5-ukui-filedialog/uikyfiledialog.cpp | 14 +- qt5-ukui-filedialog/uikyfiledialog.h | 2 +- qt5-ukui-platformtheme/CMakeLists.txt | 14 +- .../qt5-ukui-platform-theme.cpp | 58 +- .../qt5-ukui-platform-theme.h | 8 +- .../qt5-ukui-platformtheme_bo_CN.ts | 90 +- .../translations/qt5-ukui-platformtheme_de.ts | 2 +- .../qt5-ukui-platformtheme_en_US.ts | 4 +- .../translations/qt5-ukui-platformtheme_es.ts | 2 +- .../translations/qt5-ukui-platformtheme_fr.ts | 2 +- .../translations/qt5-ukui-platformtheme_kk.ts | 16 +- .../translations/qt5-ukui-platformtheme_ky.ts | 14 +- .../translations/qt5-ukui-platformtheme_mn.ts | 90 +- .../translations/qt5-ukui-platformtheme_ms.ts | 221 ++ .../translations/qt5-ukui-platformtheme_th.ts | 221 ++ .../translations/qt5-ukui-platformtheme_ug.ts | 16 +- .../translations/qt5-ukui-platformtheme_vi.ts | 221 ++ .../qt5-ukui-platformtheme_zh_CN.ts | 4 +- .../qt5-ukui-platformtheme_zh_HK.ts | 4 +- .../qt5-ukui-platformtheme_zh_Hant.ts | 255 +- .../widget/messagebox/message-box.cpp | 134 +- .../widget/messagebox/message-box.h | 4 + test/CMakeLists.txt | 21 +- test/auto-test/CMakeLists.txt | 216 ++ test/auto-test/test-settings.cpp | 3365 +++++++++++++++++ ukui-qml-style-helper/CMakeLists.txt | 4 + ukui-qml-style-helper/KyIcon.cpp | 3 +- ukui-qml-style-helper/KyIcon.h | 3 + ukui-qml-style-helper/qqc2styleplugin.cpp | 4 + .../styleparameter/appparameter.cpp | 107 +- .../styleparameter/appparameter.h | 14 + ukui-qml-style-helper/styleparameter/icon.h | 2 +- .../styleparameter/imageprovider.cpp | 64 +- .../styleparameter/imageprovider.h | 2 +- .../styleparameter/parsecolorinterface.cpp | 11 + .../styleparameter/parsecolorinterface.h | 1 + .../styleparameter/ukuibutton.cpp | 290 +- .../styleparameter/ukuibutton.h | 123 +- .../styleparameter/ukuicheckbox.cpp | 157 +- .../styleparameter/ukuicheckbox.h | 61 +- .../styleparameter/ukuicombobox.cpp | 144 +- .../styleparameter/ukuicombobox.h | 69 +- .../styleparameter/ukuiheaderview.cpp | 92 + .../styleparameter/ukuiheaderview.h | 86 + .../styleparameter/ukuiitemdelegate.cpp | 460 ++- .../styleparameter/ukuiitemdelegate.h | 215 ++ .../styleparameter/ukuilabel.cpp | 10 +- .../styleparameter/ukuimenu.cpp | 47 +- .../styleparameter/ukuimenu.h | 16 +- .../styleparameter/ukuimenuitem.cpp | 506 ++- .../styleparameter/ukuimenuitem.h | 252 +- .../styleparameter/ukuipopup.cpp | 45 +- .../styleparameter/ukuipopup.h | 14 + .../styleparameter/ukuipopupwindowhandle.cpp | 587 +-- .../styleparameter/ukuipopupwindowhandle.h | 98 +- .../styleparameter/ukuiprogressbar.cpp | 87 +- .../styleparameter/ukuiprogressbar.h | 24 + .../styleparameter/ukuiradiobutton.cpp | 159 +- .../styleparameter/ukuiradiobutton.h | 58 + .../styleparameter/ukuiscrollbar.cpp | 75 +- .../styleparameter/ukuiscrollbar.h | 30 + .../styleparameter/ukuislider.cpp | 141 +- .../styleparameter/ukuislider.h | 45 + .../styleparameter/ukuispinbox.cpp | 260 +- .../styleparameter/ukuispinbox.h | 115 + .../styleparameter/ukuiswitch.cpp | 152 +- .../styleparameter/ukuiswitch.h | 57 + .../styleparameter/ukuitabbar.cpp | 10 +- .../styleparameter/ukuitabbutton.cpp | 81 +- .../styleparameter/ukuitabbutton.h | 39 +- .../styleparameter/ukuitextarea.cpp | 415 ++ .../styleparameter/ukuitextarea.h | 256 ++ .../styleparameter/ukuitextfiled.cpp | 111 +- .../styleparameter/ukuitextfiled.h | 72 +- .../styleparameter/ukuitooltip.cpp | 65 +- .../styleparameter/ukuitooltip.h | 14 + .../org.ukui.style/BusyIndicator.qml | 28 +- ukui-qqc2-style/org.ukui.style/Button.qml | 61 +- ukui-qqc2-style/org.ukui.style/CheckBox.qml | 332 +- .../org.ukui.style/CheckDelegate.qml | 353 +- ukui-qqc2-style/org.ukui.style/ComboBox.qml | 408 +- .../org.ukui.style/HorizontalHeaderView.qml | 80 + .../org.ukui.style/ItemDelegate.qml | 57 +- ukui-qqc2-style/org.ukui.style/Label.qml | 33 +- ukui-qqc2-style/org.ukui.style/Menu.qml | 585 +-- ukui-qqc2-style/org.ukui.style/MenuItem.qml | 253 +- .../org.ukui.style/MenuSeparator.qml | 51 + ukui-qqc2-style/org.ukui.style/Pane.qml | 70 + ukui-qqc2-style/org.ukui.style/Popup.qml | 17 +- .../org.ukui.style/ProgressBar.qml | 189 +- .../org.ukui.style/RadioButton.qml | 192 +- .../org.ukui.style/RadioDelegate.qml | 200 +- .../org.ukui.style/RoundButton.qml | 22 +- ukui-qqc2-style/org.ukui.style/ScrollBar.qml | 65 +- ukui-qqc2-style/org.ukui.style/Slider.qml | 253 +- ukui-qqc2-style/org.ukui.style/SpinBox.qml | 137 +- ukui-qqc2-style/org.ukui.style/Switch.qml | 177 +- .../org.ukui.style/SwitchDelegate.qml | 186 +- ukui-qqc2-style/org.ukui.style/TabBar.qml | 16 +- ukui-qqc2-style/org.ukui.style/TabButton.qml | 43 +- ukui-qqc2-style/org.ukui.style/TextArea.qml | 199 + ukui-qqc2-style/org.ukui.style/TextField.qml | 187 +- ukui-qqc2-style/org.ukui.style/ToolButton.qml | 41 +- ukui-qqc2-style/org.ukui.style/ToolTip.qml | 436 ++- .../org.ukui.style/VerticalHeaderView.qml | 81 + .../private/BackGroundRectangle.qml | 114 +- .../private/ButtonIconLabelContent.qml | 281 +- .../private/IconLabelContent.qml | 68 +- .../org.ukui.style/private/NormalBack.qml | 240 ++ .../org.ukui.style/private/ParseInterface.qml | 98 +- .../private/RadiusRectangle.qml | 6 +- .../org.ukui.style/private/WindowBack.qml | 158 + ukui-qqc2-style/org.ukui.style/private/qmldir | 5 + ukui-qqc2-style/org.ukui.style/qmldir | 2 + ukui-qqc2-style/qml.qrc | 6 + ukui-styles/CMakeLists.txt | 13 + ukui-styles/blur-helper.cpp | 61 +- ukui-styles/blur-helper.h | 3 +- .../config-progressbar-animation-helper.cpp | 59 +- .../config-progressbar-animation-helper.h | 18 +- .../config-progressbar-animation.cpp | 4 +- .../config-radiobutton-animator.cpp | 94 +- .../animations/config-radiobutton-animator.h | 2 + .../animations/config-slider-animator.cpp | 114 +- .../animations/config-slider-animator.h | 6 + .../config-view-helper.cpp | 2 +- .../ukui-config-style-parameters.cpp | 1782 ++++++--- .../ukui-config-style-parameters.h | 70 +- .../ukui-config-style.cpp | 2867 +++++++++----- .../qt5-config-style-ukui/ukui-config-style.h | 12 + .../config-checkbox-parameters.cpp | 8 + .../config-checkbox-parameters.h | 9 + .../config-list-parameters.cpp | 4 + .../config-list-parameters.h | 5 +- .../config-menu-parameters.cpp | 3 +- .../config-menu-parameters.h | 3 + .../config-progressbar-parameters.cpp | 2 + .../config-progressbar-parameters.h | 2 + .../config-pushbutton-parameters.cpp | 1 + .../config-pushbutton-parameters.h | 11 +- .../config-radiobutton-parameters.h | 10 + .../config-scrollbar-parameters.h | 1 + .../config-slider-parameters.cpp | 2 + .../config-slider-parameters.h | 3 + .../config-spinbox-parameters.cpp | 4 + .../config-spinbox-parameters.h | 2 + .../config-table-parameters.h | 3 +- .../config-tabwidget-parameters.h | 4 + .../config-toolbutton-parameters.h | 9 +- .../config-tree-parameters.h | 5 +- .../widget-parameters/control-parameters.cpp | 9 +- .../widget-parameters/control-parameters.h | 20 + ukui-styles/readconfig.cpp | 1408 ++++--- ukui-styles/readconfig.h | 720 ++-- ukui-styles/ukui-style-plugin.cpp | 23 +- ukui-styles/window-manager.cpp | 10 + 196 files changed, 21854 insertions(+), 6260 deletions(-) create mode 100644 debian/qt5-ukui-platformtheme-coverage.xml create mode 100644 qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ms.ts create mode 100644 qt5-ukui-filedialog/translations/qt5-ukui-filedialog_th.ts create mode 100644 qt5-ukui-filedialog/translations/qt5-ukui-filedialog_vi.ts create mode 100644 qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ms.ts create mode 100644 qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_th.ts create mode 100644 qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_vi.ts mode change 100644 => 100755 test/CMakeLists.txt create mode 100755 test/auto-test/CMakeLists.txt create mode 100755 test/auto-test/test-settings.cpp create mode 100644 ukui-qml-style-helper/styleparameter/ukuiheaderview.cpp create mode 100644 ukui-qml-style-helper/styleparameter/ukuiheaderview.h create mode 100644 ukui-qml-style-helper/styleparameter/ukuitextarea.cpp create mode 100644 ukui-qml-style-helper/styleparameter/ukuitextarea.h create mode 100644 ukui-qqc2-style/org.ukui.style/HorizontalHeaderView.qml create mode 100644 ukui-qqc2-style/org.ukui.style/MenuSeparator.qml create mode 100644 ukui-qqc2-style/org.ukui.style/Pane.qml create mode 100644 ukui-qqc2-style/org.ukui.style/TextArea.qml create mode 100644 ukui-qqc2-style/org.ukui.style/VerticalHeaderView.qml create mode 100644 ukui-qqc2-style/org.ukui.style/private/NormalBack.qml create mode 100644 ukui-qqc2-style/org.ukui.style/private/WindowBack.qml create mode 100644 ukui-qqc2-style/org.ukui.style/private/qmldir diff --git a/CMakeLists.txt b/CMakeLists.txt index cc82ea7..2de6d1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,18 @@ project(qt5-ukui) + add_subdirectory(ukui-styles) add_subdirectory(libqt5-ukui-style) add_subdirectory(qt5-ukui-filedialog) add_subdirectory(qt5-ukui-platformtheme) add_subdirectory(ukui-qqc2-style) add_subdirectory(ukui-qml-style-helper) -add_subdirectory(test) -add_subdirectory(icon-engines) +# add_subdirectory(test) + +# 检查环境变量 PLATFORMTHEME_SKIP_TEST +if(NOT "$ENV{PLATFORMTHEME_SKIP_TEST}" STREQUAL "1") + add_subdirectory(test) + # 启用测试功能 + enable_testing() + # 添加测试用例 + add_test(NAME TestSettings COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test/auto-test/test-settings) +endif() diff --git a/debian/changelog b/debian/changelog index 69e821c..1519c66 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +qt5-ukui-platformtheme (4.10.0.1-ok2.2) huanghe; urgency=medium + + * 同步最新代码 + + -- 李柯 Thu, 28 May 2026 17:50:30 +0800 + qt5-ukui-platformtheme (4.10.0.1-ok2.1) huanghe; urgency=medium * 改动: diff --git a/debian/control b/debian/control index a8cddbe..2ec52fb 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,6 @@ Build-Depends: dbus-x11, libpeony-dev, libqt5svg5-dev, libqt5x11extras5-dev, - peony, pkg-config, pkg-kde-tools, cmake, @@ -44,6 +43,7 @@ Architecture: any Depends: libqt5-ukui-style1 (= ${binary:Version}), qml-module-org-ukui-qqc2desktopstyle (= ${binary:Version}), qml-module-org-ukui-stylehelper (= ${binary:Version}), + qt5-gesture-extensions, qt5-styles-ukui (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends} diff --git a/debian/qt5-ukui-platformtheme-coverage.xml b/debian/qt5-ukui-platformtheme-coverage.xml new file mode 100644 index 0000000..31f8931 --- /dev/null +++ b/debian/qt5-ukui-platformtheme-coverage.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/debian/qt5-ukui-platformtheme.install b/debian/qt5-ukui-platformtheme.install index 616fc16..834c1f2 100644 --- a/debian/qt5-ukui-platformtheme.install +++ b/debian/qt5-ukui-platformtheme.install @@ -1,3 +1,2 @@ usr/share/qt5-ukui-platformtheme/*.qm usr/lib/*/qt5/plugins/platformthemes/*.so -usr/lib/*/qt5/plugins/iconengines/*.so diff --git a/debian/rules b/debian/rules index a640923..5b92963 100755 --- a/debian/rules +++ b/debian/rules @@ -8,3 +8,6 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all override_dh_auto_configure: echo `pkg-config --cflags peony` dh_auto_configure + + # 跳过tests子项目 + export PLATFORMTHEME_SKIP_TEST=1 diff --git a/libqt5-ukui-style/CMakeLists.txt b/libqt5-ukui-style/CMakeLists.txt index 05af445..edacf0d 100644 --- a/libqt5-ukui-style/CMakeLists.txt +++ b/libqt5-ukui-style/CMakeLists.txt @@ -18,6 +18,10 @@ set(QT_MIN_VERSION "5.12.0") set(KF5_MIN_VERSION "5.66.0") find_package(Qt5Concurrent) +set(LIB_PATH ${imported_location}) +get_filename_component(PARENT_PATH "${LIB_PATH}" PATH) +message("libqt5-ukui-style PARENT_PATH: ${PARENT_PATH}") + find_package(Qt5Widgets) include_directories(${Qt5Widgets_PRIVATE_INCLUDE_DIRS}) diff --git a/libqt5-ukui-style/effects/highlight-effect.cpp b/libqt5-ukui-style/effects/highlight-effect.cpp index 81bec19..5d6601f 100644 --- a/libqt5-ukui-style/effects/highlight-effect.cpp +++ b/libqt5-ukui-style/effects/highlight-effect.cpp @@ -36,9 +36,9 @@ #include -#define ColorDifference 10 +#define ColorDifference 15 -QColor HighLightEffect::symbolic_color = QColor(38, 38, 38); +QColor HighLightEffect::symbolic_color = QColor(26, 26, 26); void HighLightEffect::setSkipEffect(QWidget *w, bool skip) { @@ -113,7 +113,7 @@ bool HighLightEffect::isSymbolicColor(const QPixmap &pixmap) if (image.pixelColor(x, y).alphaF() > 0.3) { QColor color = image.pixelColor(x, y); - //default symbolic color (38, 38, 38) + //default symbolic color (26, 26, 26) int dr = qAbs(color.red() - symbolic_color.red()); int dg = qAbs(color.green() - symbolic_color.green()); int db = qAbs(color.blue() - symbolic_color.blue()); @@ -201,11 +201,18 @@ QPixmap HighLightEffect::generatePixmap(const QPixmap &pixmap, const QStyleOptio { if (pixmap.isNull()) return pixmap; - if (!(option->state & QStyle::State_Enabled)) - return pixmap; - if (widget && !widget->isEnabled()) - return pixmap; - +// if (!(option->state & QStyle::State_Enabled)) +// return pixmap; +// if (widget && !widget->isEnabled()) +// return pixmap; + + HighLightMode hlmode; + if (widget && widget->property("useIconHighlightEffect").isValid()){ + hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } QPixmap target = pixmap; bool isPurePixmap = isPixmapPureColor(pixmap); if (force) { @@ -242,11 +249,7 @@ QPixmap HighLightEffect::generatePixmap(const QPixmap &pixmap, const QStyleOptio mode = EffectMode(widget->property("iconHighlightEffectMode").toBool()); } - HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); - - if (hlmode == skipHighlight) { - return pixmap; - } else if (hlmode == HighlightEffect) { + if (hlmode == HighlightEffect) { bool fillIconSymbolicColor = false; if (widget->property("fillIconSymbolicColor").isValid()) { fillIconSymbolicColor = widget->property("fillIconSymbolicColor").toBool(); @@ -302,7 +305,9 @@ QPixmap HighLightEffect::generatePixmap(const QPixmap &pixmap, const QStyleOptio } else { return filledSymbolicColoredGeneratePixmap(pixmap, option, widget, mode); } - } else { + } else if (hlmode == ForceHighlight) { + return forceGeneratePixmap(pixmap, option, widget, mode); + }else { return pixmap; } @@ -313,11 +318,28 @@ QPixmap HighLightEffect::ordinaryGeneratePixmap(const QPixmap &pixmap, const QSt { if (pixmap.isNull()) return pixmap; - if (!isPixmapPureColor(pixmap) || !(option->state & QStyle::State_Enabled)) - return pixmap; - if (!isSymbolicColor(pixmap)) + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + if (!isPixmapPureColor(pixmap)) return pixmap; + + if (widget && !widget->property("isLineEditHighLighting").isValid()) { + if (!isSymbolicColor(pixmap)) { + return pixmap; + } + } + + if (widget && widget->inherits("QLineEdit")) { + const_cast(widget)->setProperty("isLineEditHighLighting",true); + } + + QPixmap target = pixmap; QColor color; if (widget && widget->property("setIconHighlightEffectDefaultColor").isValid() && widget->property("setIconHighlightEffectDefaultColor").canConvert()) { @@ -331,7 +353,12 @@ QPixmap HighLightEffect::ordinaryGeneratePixmap(const QPixmap &pixmap, const QSt QPainter p(&target); p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); p.setCompositionMode(QPainter::CompositionMode_SourceIn); - p.fillRect(target.rect(), color.isValid() ? color : (mode ? option->palette.text() : defaultStyleDark(option))); + + if (widget && widget->inherits("QLineEdit")) { + p.fillRect(target.rect(), color.isValid() ? color : defaultStyleDark(option)); + } else { + p.fillRect(target.rect(), color.isValid() ? color : (mode ? option->palette.text() : defaultStyleDark(option))); + } return target; } @@ -339,7 +366,14 @@ QPixmap HighLightEffect::hoverGeneratePixmap(const QPixmap &pixmap, const QStyle { if (pixmap.isNull()) return pixmap; - if (!isPixmapPureColor(pixmap) || !(option->state & QStyle::State_Enabled)) + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + if (!isPixmapPureColor(pixmap)) return pixmap; if (!isSymbolicColor(pixmap)) return pixmap; @@ -376,13 +410,26 @@ QPixmap HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(const QPixmap &pixma { if (pixmap.isNull()) return pixmap; - if (!isPixmapPureColor(pixmap) || !(option->state & QStyle::State_Enabled)) + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + + if (!isPixmapPureColor(pixmap)) return pixmap; if (!isSymbolicColor(pixmap)) return pixmap; QPixmap target = pixmap; QColor defaultColor, hoverColor; + if(qApp && qApp->property("highlightedtext-active").isValid()){ + if(qApp->property("highlightedtext-active").canConvert()){ + hoverColor = qApp->property("highlightedtext-active").value().color(); + } + } if (widget && widget->property("setIconHighlightEffectDefaultColor").isValid() && widget->property("setIconHighlightEffectDefaultColor").canConvert()) { defaultColor = widget->property("setIconHighlightEffectDefaultColor").value(); } @@ -426,6 +473,14 @@ QPixmap HighLightEffect::filledSymbolicColoredGeneratePixmap(const QPixmap &pixm { if (pixmap.isNull()) return pixmap; + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + if (isPixmapPureColor(pixmap)) return bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget, mode); @@ -460,6 +515,99 @@ QPixmap HighLightEffect::filledSymbolicColoredGeneratePixmap(const QPixmap &pixm return target; } +QPixmap HighLightEffect::filledSymbolicColoredOrdinaryGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget, EffectMode mode) +{ + if (pixmap.isNull()) + return pixmap; + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + + if (isPixmapPureColor(pixmap)) + return ordinaryGeneratePixmap(pixmap, option, widget, mode); + + QPixmap target = pixmap; + QColor defaultColor, hoverColor; + if (widget && widget->property("setIconHighlightEffectDefaultColor").isValid() && widget->property("setIconHighlightEffectDefaultColor").canConvert()) { + defaultColor = widget->property("setIconHighlightEffectDefaultColor").value(); + } + if (widget && widget->property("setIconHighlightEffectHoverColor").isValid() && widget->property("setIconHighlightEffectHoverColor").canConvert()) { + hoverColor = widget->property("setIconHighlightEffectHoverColor").value(); + } + + if (widget && widget->property("iconHighlightEffectMode").isValid()) { + mode = EffectMode(widget->property("iconHighlightEffectMode").toBool()); + } + + return filledSymbolicColoredPixmap(target, defaultColor.isValid() ? defaultColor : (mode ? option->palette.color(QPalette::Text) : defaultStyleDark(option))); +} + + +QPixmap HighLightEffect::forceGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget, EffectMode mode) +{ + if (pixmap.isNull()) + return pixmap; + + if (widget && widget->property("useIconHighlightEffect").isValid()){ + HighLightMode hlmode = isWidgetIconUseHighlightEffect(widget); + if (hlmode == skipHighlight) { + return pixmap; + } + } + + QPixmap target = pixmap; + QColor defaultColor, hoverColor; + if (widget && widget->property("setIconHighlightEffectDefaultColor").isValid() && widget->property("setIconHighlightEffectDefaultColor").canConvert()) { + defaultColor = widget->property("setIconHighlightEffectDefaultColor").value(); + } + if (widget && widget->property("setIconHighlightEffectHoverColor").isValid() && widget->property("setIconHighlightEffectHoverColor").canConvert()) { + hoverColor = widget->property("setIconHighlightEffectHoverColor").value(); + } + + if (widget && widget->property("iconHighlightEffectMode").isValid()) { + mode = EffectMode(widget->property("iconHighlightEffectMode").toBool()); + } + bool isEnable = option->state.testFlag(QStyle::State_Enabled); + bool overOrDown = option->state.testFlag(QStyle::State_MouseOver) || + option->state.testFlag(QStyle::State_Sunken) || + option->state.testFlag(QStyle::State_On) || + option->state.testFlag(QStyle::State_Selected); + if (qobject_cast(widget)) { + if (!option->state.testFlag(QStyle::State_Selected)) + overOrDown = false; + } + + if (isPixmapPureColor(pixmap)){ + QPainter p(&target); + if (overOrDown) { + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + p.setCompositionMode(QPainter::CompositionMode_SourceIn); + p.fillRect(target.rect(), hoverColor.isValid() ? hoverColor : QColor(Qt::white)); + } else { + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + p.setCompositionMode(QPainter::CompositionMode_SourceIn); + p.fillRect(target.rect(), defaultColor.isValid() ? defaultColor : QColor(Qt::white)); + } + return target; + } + else{ + if (isEnable && overOrDown) { + return filledSymbolicColoredPixmap(target, hoverColor.isValid() ? hoverColor : QColor(Qt::white)); + } else { + return filledSymbolicColoredPixmap(target, defaultColor.isValid() ? defaultColor : QColor(Qt::white)); + } + return target; + } + + +} + + + HighLightEffect::HighLightEffect(QObject *parent) : QObject(parent) { @@ -474,8 +622,9 @@ QPixmap HighLightEffect::filledSymbolicColoredPixmap(const QPixmap &source, cons for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0.3) { - if (qAbs(color.red() - symbolic_color.red()) < 10 && qAbs(color.green() - symbolic_color.green()) < 10 - && qAbs(color.blue() - symbolic_color.blue()) < 10) { + if (qAbs(color.red() - symbolic_color.red()) < ColorDifference + && qAbs(color.green() - symbolic_color.green()) < ColorDifference + && qAbs(color.blue() - symbolic_color.blue()) < ColorDifference) { color.setRed(baseColor.red()); color.setGreen(baseColor.green()); color.setBlue(baseColor.blue()); diff --git a/libqt5-ukui-style/effects/highlight-effect.h b/libqt5-ukui-style/effects/highlight-effect.h index 4940324..f75ef27 100644 --- a/libqt5-ukui-style/effects/highlight-effect.h +++ b/libqt5-ukui-style/effects/highlight-effect.h @@ -40,6 +40,7 @@ public: hoverHighLight = 0x4, defaultHighLight = 0x8, filledSymbolicColorHighLight = 0x10, + ForceHighlight = 0x12 }; enum EffectMode { @@ -77,6 +78,8 @@ public: static QPixmap hoverGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, EffectMode mode = HighlightOnly); static QPixmap bothOrdinaryAndHoverGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, EffectMode mode = HighlightOnly); static QPixmap filledSymbolicColoredGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, EffectMode mode = HighlightOnly); + static QPixmap filledSymbolicColoredOrdinaryGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, EffectMode mode = HighlightOnly); + static QPixmap forceGeneratePixmap(const QPixmap &pixmap, const QStyleOption *option, const QWidget *widget = nullptr, EffectMode mode = HighlightOnly); private: explicit HighLightEffect(QObject *parent = nullptr); diff --git a/libqt5-ukui-style/settings/black-list.h b/libqt5-ukui-style/settings/black-list.h index 5614000..8aaf67b 100644 --- a/libqt5-ukui-style/settings/black-list.h +++ b/libqt5-ukui-style/settings/black-list.h @@ -63,23 +63,24 @@ static const QStringList useDarkPaletteList() { // l<<"kylin-nm"; //网络 // l<<"panelukui-panel"; //日历 // l<<"ukui-power-manager-tray"; -//// l<<"ukui-bluetooth"; +// l<<"ukui-bluetooth"; // l<<"sogouimebs"; //输入法 // l<<"kylin-device-daemon"; //U盘 - l<<"ukui-flash-disk"; +// l<<"ukui-flash-disk"; // l<<"ukui-bluetooth"; - l<<"mktip"; - l<<"kylin-video"; +// l<<"mktip"; +// l<<"kylin-video"; return l; } -static const QStringList useDefaultPaletteList() { - //use light palette +static const QStringList useLightPaletteList() { + //use light palette in default style. QStringList l; // l<<"kybackup"; // l<<"biometric-manager"; // l<<"kylin-video"; + l<<"ukui-screensaver-dialog"; return l; } @@ -128,4 +129,13 @@ static const QStringList windowManageBlackList() { // return l; // } +static const QStringList ukuiFiledialogBlackList() { + QStringList l; + l << "Notepad--"; + l << "mtxx"; + l << "keepassxc"; + + return l; +} + #endif // BLACKLIST_H diff --git a/libqt5-ukui-style/settings/org.ukui.style.gschema.xml b/libqt5-ukui-style/settings/org.ukui.style.gschema.xml index bdcb8f4..a95edde 100644 --- a/libqt5-ukui-style/settings/org.ukui.style.gschema.xml +++ b/libqt5-ukui-style/settings/org.ukui.style.gschema.xml @@ -21,7 +21,7 @@ System Font for Qt Applications. - "11" + "10" System Font Size for Qt Applications. System Font Size for Qt Applications. Use point size. @@ -34,12 +34,12 @@ - 72 + 65 Menu's transparency. The default transparency of menu. - 72 + 65 Peony::SideBar's transparency. The default transparency of the peony side bar. @@ -61,7 +61,7 @@ Set default system palette for UKUI desktop environment. - "#3790FA" + "55,144,250,1" theme color Set theme color for UKUI desktop environment.include default,daybreakBlue,jamPurple,magenta,sunRed,sunsetOrange,dustGold,polarGreen, and using rgba for example "(125,125,125) or #3790FA" @@ -93,5 +93,10 @@ Window Radius The first represents regular window corner, and second represents menu and tooltip radius + + "listview" + FileDialog view model + View display mode of the file dialog. + diff --git a/qt5-ukui-filedialog/CMakeLists.txt b/qt5-ukui-filedialog/CMakeLists.txt index 6f7b7da..bfd02dc 100644 --- a/qt5-ukui-filedialog/CMakeLists.txt +++ b/qt5-ukui-filedialog/CMakeLists.txt @@ -26,10 +26,18 @@ set(KF5_MIN_VERSION "5.66.0") #endif() find_package(Qt5Gui) +message(${imported_location}) +set(LIB_PATH ${imported_location}) +get_filename_component(PARENT_PATH "${LIB_PATH}" PATH) +get_filename_component(PARENT_PATH "${PARENT_PATH}" PATH) +message("qt5-ukui-filedialog PARENT_PATH: ${PARENT_PATH}") +set(TARGET_PATH ${PARENT_PATH}) + find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS DBus Widgets X11Extras + Concurrent ) include_directories(${Qt5Widgets_PRIVATE_INCLUDE_DIRS}) @@ -66,24 +74,29 @@ endif() include_directories(../libqt5-ukui-style/) -file(GLOB_RECURSE TS_FILES - translations/qt5-ukui-filedialog_zh_HK.ts - translations/qt5-ukui-filedialog_zh_Hant.ts - translations/qt5-ukui-filedialog_zh_Hans.ts - translations/qt5-ukui-filedialog_zh_CN.ts - translations/qt5-ukui-filedialog_ug.ts - translations/qt5-ukui-filedialog_tr.ts - translations/qt5-ukui-filedialog_mn.ts - translations/qt5-ukui-filedialog_ky.ts - translations/qt5-ukui-filedialog_kk.ts - translations/qt5-ukui-filedialog_fr.ts - translations/qt5-ukui-filedialog_fa.ts - translations/qt5-ukui-filedialog_es.ts - translations/qt5-ukui-filedialog_en_US.ts - translations/qt5-ukui-filedialog_de.ts - translations/qt5-ukui-filedialog_cs.ts - translations/qt5-ukui-filedialog_bo_CN.ts - ) +# file(GLOB_RECURSE TS_FILES +# translations/qt5-ukui-filedialog_zh_HK.ts +# translations/qt5-ukui-filedialog_zh_Hant.ts +# translations/qt5-ukui-filedialog_zh_Hans.ts +# translations/qt5-ukui-filedialog_zh_CN.ts +# translations/qt5-ukui-filedialog_ug.ts +# translations/qt5-ukui-filedialog_tr.ts +# translations/qt5-ukui-filedialog_mn.ts +# translations/qt5-ukui-filedialog_ky.ts +# translations/qt5-ukui-filedialog_kk.ts +# translations/qt5-ukui-filedialog_fr.ts +# translations/qt5-ukui-filedialog_fa.ts +# translations/qt5-ukui-filedialog_es.ts +# translations/qt5-ukui-filedialog_en_US.ts +# translations/qt5-ukui-filedialog_de.ts +# translations/qt5-ukui-filedialog_cs.ts +# translations/qt5-ukui-filedialog_bo_CN.ts +# ) +file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") + +# foreach(TS_FILE ${TS_FILES}) +# message(STATUS "对话框找到翻译文件vi ms th:${TS_FILE}") +# endforeach() set(Sources sidebar.cpp @@ -146,6 +159,7 @@ target_link_libraries(qt5-ukui-filedialog Qt5::DBus Qt5::Gui Qt5::X11Extras + Qt5::Concurrent ${QGSETTINGS_LIBRARIES} ${UKUIWINDOWHELPER_LIBRARIES} xcb @@ -159,6 +173,9 @@ add_definitions(-DQT5UKUIPLATFORMTHEME_LIBRARY) add_definitions(-DQT_DEPRECATED_WARNINGS) add_definitions(-DQT_MESSAGELOGCONTEXT) +set(PLUGIN_INSTALL_FILES /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/peony-extensions/libpeony-computer-view-plugin.so) +target_compile_definitions(${PROJECT_NAME} PRIVATE PLUGIN_INSTALL_FILES="${PLUGIN_INSTALL_FILES}") + if(UNIX) set(TARGET_PATH "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/plugins") diff --git a/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.cpp b/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.cpp index b9cc680..159e9f7 100644 --- a/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.cpp +++ b/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.cpp @@ -30,6 +30,9 @@ MyTextEdit:: MyTextEdit(QWidget *parent) : QTextEdit(parent) setReadOnly(true); setStyleSheet("QTextEdit { border: none; }"); setWordWrapMode(QTextOption::WrapAnywhere); + QObject::connect(qApp, &QApplication::fontChanged, this, [&](const QFont &font){ + this->setFont(font); + },Qt::UniqueConnection); } MyTextEdit::~MyTextEdit() @@ -46,8 +49,32 @@ KyFileDialogRename::KyFileDialogRename(QWidget *parent) : KyFileOperationDialog( KyFileDialogRename::~KyFileDialogRename() { + if(m_content){ + delete m_content; + m_content = nullptr; + } + if(m_iconTopLabel){ + delete m_iconTopLabel; + m_iconTopLabel = nullptr; + } +} + +void KyFileDialogRename::showEvent(QShowEvent *event) +{ + QDialog::showEvent(event); + if(event->type() == QEvent::Show) + { + QFontMetrics fm(m_content->fontMetrics()); + QString text = m_content->text(); + int textwidth = m_content->width() - 2*m_content->contentsMargins().left(); + textwidth = qMax(textwidth, 1); + QRect textrect = fm.boundingRect(0,0,textwidth,0, m_content->alignment() | Qt::TextWordWrap, m_content->text()); + + m_iconTopLabel->setFixedHeight((m_content->height() - textrect.height()) / 2); + } } + void KyFileDialogRename::handle(Peony::FileOperationError &error) { Peony::ExceptionResponse responseCode = Peony::ExceptionResponse::Cancel; @@ -56,6 +83,9 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) auto fsType = Peony::FileUtils::getFsTypeFromFile(m_currentUri); QString path = error.destDirUri.left(error.destDirUri.lastIndexOf("/")); + + if(path.startsWith("file://")) + path = path.remove(0,7); if(isFuseFileSystem(path)) fsType = "fuse.kyfs"; pDebug << "handle path......" << path << fsType; @@ -86,7 +116,7 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) line1 = tr("File \"%1\"").arg(newName); line2 = tr("Saving failed, the reason is: %1").arg(error.errorCode == G_IO_ERROR_FILENAME_TOO_LONG? tr("The file name is too long. "): error.errorStr) + - tr("Please choose the following processing method:") + ('\n'); + tr("Please choose the following processing method:"); break; } } @@ -94,6 +124,7 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) QString line; QStringList messages; line = qApp->fontMetrics().elidedText(line1, Qt::ElideMiddle, 500); + // messages.append(line); // line.append('\n'); // line2 = qApp->fontMetrics().elidedText(line2, Qt::ElideMiddle, 600); @@ -101,7 +132,7 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) // line = qApp->fontMetrics().elidedText(line3, Qt::ElideMiddle, 500); // messages.append(line); - auto labelText = line + line2; + m_labelText = line + line2; // page1: save to long file directory auto pageOne = new QWidget(this); @@ -121,17 +152,43 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) // save->setVisible(); QVBoxLayout *oneLayout = new QVBoxLayout(); - auto content = new QLabel(this); - content->setWordWrap(true); + m_content = new QLabel(this); + m_content->setWordWrap(true); + //int textWidth = (this->width() - 40 - 40 - 24) * 3; //QString elidedString = qApp->fontMetrics().elidedText(error.errorStr, Qt::ElideMiddle, textWidth); - content->setText(labelText); + m_content->setText(m_labelText); // QHBoxLayout *labelLayout = new QHBoxLayout(this); auto labelIcon = new QLabel(this); - labelIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24, 24)); + labelIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16, 16)); // labelIcon->setGeometry(0, content->y(), labelIcon->size().width(), labelIcon->size().height()); - labelIcon->setAlignment(Qt::AlignTop); + //labelIcon->setAlignment(Qt::AlignTop); + labelIcon->setAlignment(Qt::AlignVCenter); + QFontMetrics fm(qApp->font()); + + if(labelIcon &&labelIcon->pixmap() && !labelIcon->pixmap()->size().isNull() && labelIcon->pixmap()->size().height()/labelIcon->devicePixelRatioF() <= fm.height()) + labelIcon->setFixedHeight(fm.height()); + QObject::connect(qApp, &QApplication::fontChanged, this, [&](const QFont &font){ + QFontMetrics fm(qApp->font()); + QString line; + line = fm.elidedText(line1, Qt::ElideMiddle, 500); + m_labelText = line + line2; + m_content->setText(m_labelText); + m_content->setFont(qApp->font()); + m_content->update(); + + if(labelIcon &&labelIcon->pixmap() && !labelIcon->pixmap()->size().isNull() && labelIcon->pixmap()->size().height()/labelIcon->devicePixelRatioF() <= fm.height()) + labelIcon->setFixedHeight(fm.height()); + QString text = m_content->text(); + int textwidth = m_content->width() - 2*m_content->contentsMargins().left(); + textwidth = qMax(textwidth, 1); + QRect textrect = fm.boundingRect(0,0,textwidth,0, m_content->alignment() | Qt::TextWordWrap, m_content->text()); + + m_iconTopLabel->setFixedHeight((m_content->height() - textrect.height()) / 2); + }, Qt::UniqueConnection); + + // labelLayout->addWidget(labelIcon); // labelLayout->addStretch(); @@ -155,13 +212,20 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) bottomLayout->addWidget(buttonBoxOne); bottomLayout->setAlignment(buttonBoxOne, Qt::AlignRight); - oneLayout->addWidget(content); + oneLayout->addWidget(m_content); oneLayout->addLayout(centerLayout); oneLayout->addWidget(specificationLabel); oneLayout->addLayout(bottomLayout); QHBoxLayout *mainLayout = new QHBoxLayout(); - mainLayout->addWidget(labelIcon); + QVBoxLayout *iconLayout = new QVBoxLayout(); + m_iconTopLabel = new QLabel(); + iconLayout->setSpacing(0); + iconLayout->addWidget(m_iconTopLabel); + iconLayout->addWidget(labelIcon); + iconLayout->addStretch(); + mainLayout->addLayout(iconLayout); +// mainLayout->addWidget(labelIcon); mainLayout->addLayout(oneLayout); pageOne->setLayout(mainLayout); @@ -361,7 +425,7 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) QGSettings *settings = new QGSettings("org.ukui.style", QByteArray(), this); connect(settings, &QGSettings::changed, this, [=](const QString &key) { if("iconThemeName" == key){ - labelIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24, 24)); + labelIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16, 16)); //renameIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24, 24)); } else if ("systemFont" == key || "systemFontSize" == key) { if (0 != stack->currentIndex()) { @@ -385,7 +449,7 @@ void KyFileDialogRename::handle(Peony::FileOperationError &error) // line = qApp->fontMetrics().elidedText(line3, Qt::ElideMiddle, 500); // messages.append(line); // auto labelText = messages.join('\n'); - content->setText(labelText); + m_content->setText(m_labelText); this->repaint(); } }); diff --git a/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.h b/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.h index 009f287..ba89bcd 100644 --- a/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.h +++ b/qt5-ukui-filedialog/file-operation-dialog/kyfiledialogrename.h @@ -24,6 +24,7 @@ #define KYFILEDIALOGRENAME_H #include +#include #include "file-operation-error-handler.h" #include "kyfileoperationdialog.h" namespace UKUIFileDialog { @@ -59,6 +60,9 @@ public: void setCurrentUri(QString uri); QString currentUri(); void setMaxLength(int maxLength); + protected: + void showEvent(QShowEvent *event) override; + Q_SIGNALS: void changeFileName(QString name); @@ -69,6 +73,9 @@ private: QString m_truncateFileName; QString m_currentUri; int m_maxLength = 255; + QLabel *m_content = nullptr; + QLabel *m_iconTopLabel = nullptr; + QString m_labelText; }; } #endif // KYFILEDIALOGRENAME_H diff --git a/qt5-ukui-filedialog/filedialogplugin.cpp b/qt5-ukui-filedialog/filedialogplugin.cpp index ca2ca61..95cb431 100644 --- a/qt5-ukui-filedialog/filedialogplugin.cpp +++ b/qt5-ukui-filedialog/filedialogplugin.cpp @@ -1,3 +1,25 @@ +/* + * KWin Style UKUI + * + * Copyright (C) 2023, 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: Jing Tan + * + */ + #include "filedialogplugin.h" #include "kyfiledialog.h" #if QT_VERSION < 0x050000 diff --git a/qt5-ukui-filedialog/filedialogplugin.h b/qt5-ukui-filedialog/filedialogplugin.h index e139d7c..8d57f45 100644 --- a/qt5-ukui-filedialog/filedialogplugin.h +++ b/qt5-ukui-filedialog/filedialogplugin.h @@ -20,7 +20,6 @@ * */ - #ifndef MYPLUGIN_H #define MYPLUGIN_H #include diff --git a/qt5-ukui-filedialog/kyfiledialog.cpp b/qt5-ukui-filedialog/kyfiledialog.cpp index b337772..a0eb898 100644 --- a/qt5-ukui-filedialog/kyfiledialog.cpp +++ b/qt5-ukui-filedialog/kyfiledialog.cpp @@ -1,3 +1,27 @@ +/* + * KWin Style UKUI + * + * Copyright (C) 2023, 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: Jing Tan + * + */ + +#include "debug.h" +#include "kyfiledialog.h" #include #include #include @@ -16,6 +40,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -32,7 +60,6 @@ #include #include #include -#include "ukuiwindowhelper.h" //#include "ukuistylehelper/ukuistylehelper.h" #include "debug.h" #include "uikyfiledialog.h" @@ -46,6 +73,8 @@ #define PERSONALSIE_SCHEMA "org.ukui.control-center.personalise" #define PERSONALSIE_TRAN_KEY "transparency" +#define FILEDIALOG_VIEW_MODE "filedialogViewMode" + using namespace UKUIFileDialog; bool isFuseFileSystem(QString path) @@ -69,6 +98,11 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) : QDialog(parent), d_ptr(new KyNativeFileDialogPrivate) { + if(qApp && qApp->style() && qApp->style()->objectName() != "ukui") + { + this->setStyle(QStyleFactory::create("ukui")); + } + QString locale = QLocale::system().name(); if(qApp->property("Language").isValid()) @@ -84,6 +118,13 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) connect(d_ptr.get()->m_timer, &QTimer::timeout, this, [&](){ // pDebug << "timeout isActive:..........." << d_ptr.get()->m_timer->isActive(); + if(containerView()->viewId() == "List View") + { + this->getCurrentPage()->setZoomLevelRequest(24); + } + else if(containerView()->viewId() == "Icon View"){ + this->getCurrentPage()->setZoomLevelRequest(25); + } this->show(); if(d_ptr.get()->m_timer->isActive()){ pDebug << "timer stop...."; @@ -109,11 +150,19 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) else goToUri(uri, addToHistory, forceUpdate); }); + connect(this, &KyNativeFileDialog::updateSideModel, mKyFileDialogUi->m_sider, &FileDialogSideBar::updateModel); connect(getCurrentPage(), &Peony::DirectoryViewContainer::signal_responseUnmounted, this, &KyNativeFileDialog::slot_responseUnmounted); connect(getCurrentPage(), &Peony::DirectoryViewContainer::directoryChanged, this, &KyNativeFileDialog::updateWindowState); connect(getCurrentPage(), &Peony::DirectoryViewContainer::directoryChanged, this, [=](){ + if(!getCurrentUri().startsWith("search://")){ + m_lastSearchPath = getCurrentUri(); + } + searchButtonClicked(getCurrentUri().startsWith("search://")); + updateAcceptButtonState(); + + pDebug << "directoryChanged........" << getCurrentUri(); mKyFileDialogUi->m_pathbarWidget->updatePath(getCurrentUri()); @@ -287,14 +336,14 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) mKyFileDialogUi->m_toParentButton->setEnabled(false); connect(mKyFileDialogUi->m_toParentButton, &QToolButton::clicked, this, &KyNativeFileDialog::goToParent); - mKyFileDialogUi->m_searchBtn->setIcon(QIcon::fromTheme("edit-find-symbolic")); - mKyFileDialogUi->m_searchBtn->setToolTip(tr("Search")); - mKyFileDialogUi->m_searchBtn->setIconSize(QSize(16, 16)); - mKyFileDialogUi->m_searchBtn->setAutoRaise(true); + // mKyFileDialogUi->m_searchBtn->setIcon(QIcon::fromTheme("edit-find-symbolic")); + // mKyFileDialogUi->m_searchBtn->setToolTip(tr("Search")); + // mKyFileDialogUi->m_searchBtn->setIconSize(QSize(16, 16)); + // mKyFileDialogUi->m_searchBtn->setAutoRaise(true); - mKyFileDialogUi->m_searchBtn->setProperty("useIconHighlightEffect", true); - mKyFileDialogUi->m_searchBtn->setProperty("iconHighlightEffectMode", 1); - connect(mKyFileDialogUi->m_searchBtn, &QToolButton::clicked, this, &KyNativeFileDialog::searchButtonClicked); + // mKyFileDialogUi->m_searchBtn->setProperty("useIconHighlightEffect", true); + // mKyFileDialogUi->m_searchBtn->setProperty("iconHighlightEffectMode", 1); + // connect(mKyFileDialogUi->m_searchBtn, &QToolButton::clicked, this, &KyNativeFileDialog::searchButtonClicked); mKyFileDialogUi->m_modeButton->setToolTip(tr("View Type")); mKyFileDialogUi->m_modeButton->setIcon(QIcon::fromTheme("view-grid-symbolic")); @@ -333,9 +382,9 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) connect(mKyFileDialogUi->m_modeMenu, &QMenu::triggered, this, [=](QAction *action) { if (action == mKyFileDialogUi->m_listModeAction) { - this->getCurrentPage()->switchViewType("List View"); + setViewMode(ViewMode::List); } else { - this->getCurrentPage()->switchViewType("Icon View"); + setViewMode(ViewMode::Icon); } }); @@ -418,18 +467,17 @@ KyNativeFileDialog::KyNativeFileDialog(QWidget *parent) //transparency - QRegion region(this->geometry()); - UkuiWindowHelper *windowHelper = new UkuiWindowHelper(this); - windowHelper->setBlurEffect(region); + m_windowHelper = new UkuiWindowHelper(this); + m_windowHelper->setBlurEffect(QRegion()); QGSettings *settings = nullptr; if (QGSettings::isSchemaInstalled(PERSONALSIE_SCHEMA)) { settings = new QGSettings(PERSONALSIE_SCHEMA, QByteArray(), this); - m_transparency = settings->get(PERSONALSIE_TRAN_KEY).toDouble() * 255; + m_transparency = settings->get(PERSONALSIE_TRAN_KEY).toDouble(); connect(settings,&QGSettings::changed,this,[=](QString changedKey) { if (changedKey == PERSONALSIE_TRAN_KEY) { - m_transparency = settings->get(PERSONALSIE_TRAN_KEY).toDouble() * 255; + m_transparency = settings->get(PERSONALSIE_TRAN_KEY).toDouble(); this->update(); } @@ -669,7 +717,12 @@ void KyNativeFileDialog::beginSwitchView(const QString &viewId) if (getCurrentPage()->getView()->viewId() == viewId) return; - getCurrentPage()->switchViewType(viewId); +// getCurrentPage()->switchViewType(viewId); + if(viewId == "List View"){ + setViewMode(ViewMode::List); + } else if(viewId == "Icon View") { + setViewMode(ViewMode::Icon); + } // change default view id auto factoryManager = Peony::DirectoryViewFactoryManager2::getInstance(); @@ -713,7 +766,7 @@ QDir KyNativeFileDialog::directory() const if (uri.startsWith("trash://") || uri.startsWith("recent://") || uri.startsWith("computer://") || uri.startsWith("favorite://") || - uri.startsWith("filesafe://")){ + uri.startsWith("filesafe://") || uri.startsWith("idm://")){ uri = convertSpecialPath(uri); pDebug << "directory uri 00000000..:" << uri; } @@ -723,10 +776,9 @@ QDir KyNativeFileDialog::directory() const uri = getCurrentPage()->getCurrentUri();//特殊路径不能先编码转换 可能会造成结果不准 uri = convertSpecialPath(uri); - } - else if(!uri.isEmpty()) - uri = directoryUrl().toLocalFile(); - else{ + } else if (!uri.isEmpty()){ + return QDir(uri); + } else { QDir dir; dir.setPath(uri); return dir; @@ -769,6 +821,8 @@ void KyNativeFileDialog::goToUri(const QString &uri, bool addToHistory, bool for } QString gUri = uri; + QUrl url(uri); + pDebug << "goto uri00000........" << gUri; if ((gUri == "file:///data" || gUri == "file:///data/") && Peony::FileUtils::isFileExsit("file:///data/usershare")){ bool isDBlockHasUserFile = isDataBlockHasUserFile(); @@ -777,6 +831,22 @@ void KyNativeFileDialog::goToUri(const QString &uri, bool addToHistory, bool for gUri = "file:///data/usershare"; } } + else if (gUri == "computer:///ukui-data-volume") { + gUri = "file:///data"; + } + if (url.scheme().isEmpty() && ! uri.startsWith("mtp://") && ! uri.startsWith("gphoto2://")) { + pDebug << "transform special uri:"<isShow()) addToHistory = false; pDebug << "getCurrentUri....,,,,:" << m_fileDialogHelper->isShow() << getCurrentUri(); - pDebug << "gotouri123123:" << uri << addToHistory << forceUpdate; + pDebug << "gotouri123123:" << gUri << "1123:" << uri << addToHistory << forceUpdate; Q_EMIT locationChangeStart(); m_isLoading = true; mKyFileDialogUi->m_pathbarWidget->updatePath(gUri); + pDebug << "gotouri456654:" << gUri; + if(gUri.startsWith("search:///search_uris=")) getCurrentPage()->goToUri(gUri, addToHistory, forceUpdate); else @@ -903,7 +975,7 @@ QList KyNativeFileDialog::selectedUrls() const !uri.startsWith("filesafe://") && !uri.startsWith("mult://") && !uri.startsWith("smb://") && !uri.startsWith("ftp://") && !uri.startsWith("sftp://") &&!uri.startsWith("mtp://") && - !uri.startsWith("gphoto2://")){ + !uri.startsWith("gphoto2://") && !uri.startsWith("idm://")){ if(uri.startsWith("file:///")) uri = uri.remove(0,7); @@ -1181,12 +1253,26 @@ void KyNativeFileDialog::setViewMode(ViewMode mode) { if(containerView()){ pDebug << "setViewMode...." << mode << containerView()->viewId(); - if(mode == ViewMode::List && containerView()->viewId() != "List View") + if(mode == ViewMode::List) { - this->getCurrentPage()->switchViewType("List View"); + if(containerView()->viewId() != "List View") + this->getCurrentPage()->switchViewType("List View"); + containerView()->setCurrentZoomLevel(24); + auto settings = UKUIStyleSettings::globalInstance(); + if(settings->keys().contains(FILEDIALOG_VIEW_MODE) && settings->get(FILEDIALOG_VIEW_MODE).toString() != "listview") + settings->set(FILEDIALOG_VIEW_MODE, "listview"); + + } + else if(mode == ViewMode::Icon){ + if(containerView()->viewId() != "Icon View") + this->getCurrentPage()->switchViewType("Icon View"); + containerView()->setCurrentZoomLevel(25); + auto settings = UKUIStyleSettings::globalInstance(); + if(settings->keys().contains(FILEDIALOG_VIEW_MODE) && settings->get(FILEDIALOG_VIEW_MODE).toString() != "iconview") + settings->set(FILEDIALOG_VIEW_MODE, "iconview"); + } - else if(mode == ViewMode::Icon && containerView()->viewId() != "Icon View") - this->getCurrentPage()->switchViewType("Icon View"); + onSwitchView(); } } @@ -1353,7 +1439,7 @@ void KyNativeFileDialog::onAcceptButtonClicked() bool KyNativeFileDialog::saveMessageBox(QString name) { m_RecodPath = ""; - if(QMessageBox::warning(this, tr("Warning"), name + " " + tr("exist, are you sure replace?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) + if(QMessageBox::warning(this, tr("Warning"), name + " " + tr("exist, are you sure replace?"), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { return true; } @@ -1366,7 +1452,8 @@ bool KyNativeFileDialog::checkSaveFileExsits(QString path, QString fileName) QString directoryPath = directoryUrl().toString(); if (directoryPath.startsWith("trash://") || directoryPath.startsWith("recent://") - || directoryPath.startsWith("computer://") || directoryPath.startsWith("favorite://")){ + || directoryPath.startsWith("computer://") || directoryPath.startsWith("favorite://") || + directoryPath.startsWith("idm://")){ QStringList urlStrList = getCurrentPage()->getCurrentSelections(); QStringList pathList; for (auto uri : urlStrList) { @@ -1617,7 +1704,7 @@ bool KyNativeFileDialog::doOpen(QStringList sFiles) !uri.startsWith("filesafe://") && !uri.startsWith("mult://") && !uri.startsWith("smb://") && !uri.startsWith("ftp://") && !uri.startsWith("sftp://") && !uri.startsWith("mtp://") && - !uri.startsWith("gphoto2://")){ + !uri.startsWith("gphoto2://") && !uri.startsWith("idm://")){ if(uri.startsWith("file:///")) uri = uri.remove(0,7); @@ -1733,11 +1820,12 @@ void KyNativeFileDialog::updateWindowState() //mKyFileDialogUi->m_fileNameEdit->setText(""); pDebug << "updateWindowState m_searchMode.............." <getAllFileUris(); @@ -1861,6 +1949,8 @@ void KyNativeFileDialog::updateStatusBar() void KyNativeFileDialog::containerMenuRequest(const QPoint &pos) { + Q_D(const KyNativeFileDialog); + pDebug << "menuRequest....00000" << pos << QCursor::pos() << (this->getCurrentPage() == nullptr); if(this->getCurrentPage()) pDebug << "menuRequest....1111111" << (this->getCurrentPage()->getView() == nullptr); @@ -1868,6 +1958,21 @@ void KyNativeFileDialog::containerMenuRequest(const QPoint &pos) QStringList hideActionsName; hideActionsName.append(OPEN_IN_NEW_WINDOW_ACTION); hideActionsName.append(OPEN_IN_NEW_TAB_ACTION); + if(d->fileMode == QFileDialog::ExistingFile || d->fileMode == QFileDialog::AnyFile || d->fileMode == QFileDialog::DirectoryOnly){ + hideActionsName.append(SELECT_ALL_ACTION); + hideActionsName.append(REVERSE_SELECT_ACTION); + } + QStringList selectUri = getCurrentSelections(); + for(int i = 0; i < selectUri.count(); i++){ + if(isSymbolLinkAndTargetDataPath(selectUri.at(i))){ + hideActionsName.append(RENAME_ACTION); + hideActionsName.append(COPY_ACTION); + hideActionsName.append(CUT_ACTION); + hideActionsName.append(RENAME_ACTION); + break; + } + } + pDebug << "hideActionsName...." << hideActionsName; menu.setHiddenActionsByObjectName(hideActionsName); pDebug << "menuRequest....11111"; @@ -1893,60 +1998,58 @@ void KyNativeFileDialog::discardDelayedShow() void KyNativeFileDialog::resizeEvent(QResizeEvent *e) { - pDebug << "resizeEvent....." << this->width() << mKyFileDialogUi->m_siderWidget->width() << mKyFileDialogUi->m_container->width(); QDialog::resizeEvent(e); } void KyNativeFileDialog::paintEvent(QPaintEvent *e) { QColor color = this->palette().base().color(); - QColor colorBase = QColor(this->palette().base().color()); + QColor siderColor = this->palette().window().color(); +// QColor colorBase = QColor(this->palette().base().color()); - int R1 = color.red(); - int G1 = color.green(); - int B1 = color.blue(); - qreal a1 = 0.3; +// int R1 = color.red(); +// int G1 = color.green(); +// int B1 = color.blue(); +// qreal a1 = 0.3; - int R2 = colorBase.red(); - int G2 = colorBase.green(); - int B2 = colorBase.blue(); - qreal a2 = 1; +// int R2 = colorBase.red(); +// int G2 = colorBase.green(); +// int B2 = colorBase.blue(); +// qreal a2 = 1; - qreal a = 1 - (1 - a1)*(1 - a2); +// qreal a = 1 - (1 - a1)*(1 - a2); - qreal R = (a1*R1 + (1 - a1)*a2*R2) / a; - qreal G = (a1*G1 + (1 - a1)*a2*G2) / a; - qreal B = (a1*B1 + (1 - a1)*a2*B2) / a; +// qreal R = (a1*R1 + (1 - a1)*a2*R2) / a; +// qreal G = (a1*G1 + (1 - a1)*a2*G2) / a; +// qreal B = (a1*B1 + (1 - a1)*a2*B2) / a; - colorBase.setRed(R); - colorBase.setGreen(G); - colorBase.setBlue(B); +// colorBase.setRed(R); +// colorBase.setGreen(G); +// colorBase.setBlue(B); auto sidebarOpacity = Peony::GlobalSettings::getInstance()->getValue(SIDEBAR_BG_OPACITY).toInt(); - if(sidebarOpacity != 100) + if(m_transparency != 1.0){ mKyFileDialogUi->m_sider->viewport()->setAttribute(Qt::WA_TranslucentBackground); + mKyFileDialogUi->m_sider->setAttribute(Qt::WA_TranslucentBackground); + } - colorBase.setAlphaF(sidebarOpacity/100.0); + siderColor.setAlphaF(this->isActiveWindow() ? m_transparency : 1.0); QPainterPath sidebarPath; QRect sideBarRect = QRect(mKyFileDialogUi->m_sider->mapTo(this, QPoint()), mKyFileDialogUi->m_sider->size()); auto adjustedRect = sideBarRect.adjusted(0, 0, 0, 0); - int radius = 6; - if (QGSettings::isSchemaInstalled("org.ukui.style")) { - auto *settings = new QGSettings("org.ukui.style"); - QString r = settings->get("window-radius").toString(); - radius = r.split(",").value(0).toInt(); - } - sidebarPath.addRoundedRect(adjustedRect, radius, radius); -// sidebarPath.addRect(adjustedRect.adjusted(0, 0, 0, -6)); -// sidebarPath.addRect(adjustedRect.adjusted(6, 0, 0, 0)); + sidebarPath.addRoundedRect(adjustedRect, 0, 0); + QPainter p(this); QPainterPath contentPath; - contentPath.addRoundedRect(this->rect(), 8, 8); + contentPath.addRoundedRect(this->rect(), 0, 0); auto bgPath = contentPath - sidebarPath; + sidebarPath.setFillRule(Qt::FillRule::WindingFill); + + p.fillPath(sidebarPath, siderColor); + p.fillPath(bgPath, color); - p.fillPath(sidebarPath, colorBase); QDialog::paintEvent(e); } @@ -1965,6 +2068,14 @@ void KyNativeFileDialog::keyPressEvent(QKeyEvent *e) return QDialog::keyPressEvent(e); } +bool KyNativeFileDialog::event(QEvent *e) +{ + if(e->type() == QEvent::ActivationChange){ + m_windowHelper->setBlurEffect(QRegion(), 0, this->isActiveWindow()); + } + return QDialog::event(e); +} + Peony::DirectoryViewContainer *KyNativeFileDialog::getCurrentPage() { @@ -2025,7 +2136,7 @@ void KyNativeFileDialog::updateAcceptButtonState() !parentPath.startsWith("filesafe://") && !parentPath.startsWith("mult://") && !parentPath.startsWith("smb://") && !parentPath.startsWith("ftp://") && !parentPath.startsWith("sftp://") && !parentPath.startsWith("mtp://") && - !parentPath.startsWith("gphoto2://")){ + !parentPath.startsWith("gphoto2://") && !parentPath.startsWith("idm://")){ QString targetPath = Peony::FileUtils::urlDecode(parentPath + "/" + str); pDebug << "targetPath11111 uri....." << targetPath << Peony::FileUtils::isFileExsit(targetPath); @@ -2041,7 +2152,7 @@ void KyNativeFileDialog::updateAcceptButtonState() else { QString targetPath = convertSpecialPath(getCurrentSelections()[0]); - if(Peony::FileUtils::isFileExsit(targetPath)) + if(Peony::FileUtils::isFileExsit(targetPath) && !targetPath.isEmpty()) { isSelectFile = true; pDebug << "isSelectFileeeeeeee3333333333333...." << isSelectFile; @@ -2129,15 +2240,26 @@ void KyNativeFileDialog::updateAcceptButtonState() pDebug << "isSelectFile...." << isSelectFile; QString path = directoryUrl().toString(); - if(path.startsWith("mult://") || path.startsWith("smb://") || - path.startsWith("ftp://") || path.startsWith("sftp://") || - path.startsWith("mtp://") || path.startsWith("gphoto2://")){ + + if (!path.startsWith("trash://") && !path.startsWith("recent://") && + !path.startsWith("computer://") && !path.startsWith("favorite://") && + !path.startsWith("filesafe://") && !path.startsWith("mult://") && + !path.startsWith("smb://") && !path.startsWith("ftp://") && + !path.startsWith("sftp://") && !path.startsWith("mtp://") && + !path.startsWith("gphoto2://") && !path.startsWith("idm://")){ g_autofree char* gPath = nullptr; gPath = g_file_get_path(const_cast(g_file_new_for_uri(getCurrentUri().toLocal8Bit()))); pDebug << "updateAcceptButtonState open....gpath.....:" << (gPath == nullptr) << gPath; if(gPath == nullptr) isSelectFile = false; } + else if(copyEditText().isEmpty()){ + QString p = convertSpecialPath(path); + if(p.isEmpty()){ + isSelectFile = false; + } + + } mKyFileDialogUi->m_acceptButton->setEnabled(isSelectFile); } @@ -2149,13 +2271,26 @@ void KyNativeFileDialog::updateAcceptButtonState() QString path = directoryUrl().toString(); pDebug << "updateAcceptButtonState....path:" << path; - if ((path == "trash:///" || path == "recent:///" - || path == "computer:///" || path == "favorite:///")){ + if (path.startsWith("trash:///") || path.startsWith("recent:///") + || path.startsWith("computer:///") || path.startsWith("favorite:///") + || path.startsWith("idm:///")){ mKyFileDialogUi->m_newFolderButton->setEnabled(false); if(getCurrentSelectionsList().isEmpty()){ mKyFileDialogUi->m_acceptButton->setEnabled(false); return; } + else{ + if(getCurrentSelectionsList().length() != 0){ + mKyFileDialogUi->m_acceptButton->setEnabled(true); + return; + } + if(copyEditText() == "") + mKyFileDialogUi->m_acceptButton->setEnabled(false); + else + mKyFileDialogUi->m_acceptButton->setEnabled(true); + return; + + } } else if(path.startsWith("mult://") || path.startsWith("smb://") || path.startsWith("ftp://") || path.startsWith("sftp://") || @@ -2230,7 +2365,21 @@ void KyNativeFileDialog::onCurrentInputNameChanged() void KyNativeFileDialog::onNewFolder() { Peony::CreateTemplateOperation op(getCurrentUri(), Peony::CreateTemplateOperation::EmptyFolder); + connect(&op, &Peony::FileOperation::errored, [&](Peony::FileOperationError& error){ + if(QMessageBox::warning(this, "error", error.errorStr, QMessageBox::Ok)) + { + return; + } + }); op.run(); + auto targetUri = op.target(); + + QTimer::singleShot(500, this, [=]() { + if(containerView()) + containerView()->scrollToSelection(targetUri); + this->editUri(targetUri); + }); + return; QDir dir = directory(); pDebug << "onNewFolder getCurrentUri:" << getCurrentUri() << directory() << directoryUrl(); @@ -2249,13 +2398,13 @@ void KyNativeFileDialog::setSortType() { if(getCurrentPage()->getSortOrder() == Qt::AscendingOrder) { - mKyFileDialogUi->m_sortButton->setIcon(QIcon::fromTheme("view-sort-descending-symbolic")); - mKyFileDialogUi->m_descending->setChecked(true); + mKyFileDialogUi->m_sortButton->setIcon(QIcon::fromTheme("view-sort-ascending-symbolic"));//升序,使用向下箭头;降序,使用向上箭头 + mKyFileDialogUi->m_descending->setChecked(true);//降序 mKyFileDialogUi->m_ascending->setChecked(false); } else { - mKyFileDialogUi->m_sortButton->setIcon(QIcon::fromTheme("view-sort-ascending-symbolic")); + mKyFileDialogUi->m_sortButton->setIcon(QIcon::fromTheme("view-sort-descending-symbolic")); mKyFileDialogUi->m_ascending->setChecked(true); mKyFileDialogUi->m_descending->setChecked(false); } @@ -2299,21 +2448,22 @@ void KyNativeFileDialog::refreshCompleter() pDebug << "updateWindowState 2222222222222"; } -void KyNativeFileDialog::searchButtonClicked() +void KyNativeFileDialog::searchButtonClicked(bool search) { - m_searchMode = ! m_searchMode; + m_searchMode = search; if(m_searchMode) { mKyFileDialogUi->m_fileNameEdit->setText(""); mKyFileDialogUi->m_fileNameEdit->setReadOnly(true); + mKyFileDialogUi->m_newFolderButton->setEnabled(false); setCurrentSelections(QStringList()); - m_lastSearchPath = getCurrentUri(); pDebug << "m_lastSearchPath....." << m_lastSearchPath << getCurrentUri() << getCurrentPage()->getCurrentUri(); } else { mKyFileDialogUi->m_fileNameEdit->setReadOnly(false); + mKyFileDialogUi->m_newFolderButton->setEnabled(true); } pDebug << "searchButtonClicked searchButtonClicked" <updateSearchRequest(m_search_mode); @@ -2322,10 +2472,10 @@ void KyNativeFileDialog::searchButtonClicked() void KyNativeFileDialog::setSearchMode(bool mode) { - mKyFileDialogUi->m_searchBtn->setCheckable(mode); - mKyFileDialogUi->m_searchBtn->setChecked(mode); - mKyFileDialogUi->m_searchBtn->setDown(mode); - mKyFileDialogUi->m_pathbar->switchEditMode(mode); + // mKyFileDialogUi->m_searchBtn->setCheckable(mode); + // mKyFileDialogUi->m_searchBtn->setChecked(mode); + // mKyFileDialogUi->m_searchBtn->setDown(mode); + // mKyFileDialogUi->m_pathbar->switchEditMode(mode); } void KyNativeFileDialog::lineEditTextChange(QString text) @@ -2356,7 +2506,8 @@ void KyNativeFileDialog::lineEditTextChange(QString text) || parentPath.startsWith("filesafe://") || parentPath.startsWith("mult://") || parentPath.startsWith("smb://") || parentPath.startsWith("ftp://") || parentPath.startsWith("sftp://") || parentPath.startsWith("mtp://") - || parentPath.startsWith("gphoto2://")) && getCurrentSelections().length() > 0) + || parentPath.startsWith("gphoto2://") || parentPath.startsWith("idm://")) + && getCurrentSelections().length() > 0) { for(int i = 0; i < getCurrentSelections().length(); i++) { @@ -2467,7 +2618,7 @@ void KyNativeFileDialog::lineEditTextChange(QString text) || parentPath.startsWith("filesafe://") || parentPath.startsWith("mult://") || parentPath.startsWith("smb://") || parentPath.startsWith("ftp://") || parentPath.startsWith("sftp://") || parentPath.startsWith("mtp://") - || parentPath.startsWith("gphoto2://")) + || parentPath.startsWith("gphoto2://") || parentPath.startsWith("idm://")) { QStringList list = text.split("\""); pDebug << "listttt1111............" << list; @@ -2640,6 +2791,10 @@ void KyNativeFileDialog::setShortCuts() auto uris = this->getCurrentSelections(); + for(int i =0; i < uris.count(); i++){ + if(isSymbolLinkAndTargetDataPath(uris.at(i))) + return; + } QString desktopPath = "file://" + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString desktopUri = Peony::FileUtils::getEncodedUri(desktopPath); QString homeUri = "file://" + QStandardPaths::writableLocation(QStandardPaths::HomeLocation); @@ -2671,6 +2826,10 @@ void KyNativeFileDialog::setShortCuts() auto uris = this->getCurrentSelections(); + for(int i =0; i < uris.count(); i++){ + if(isSymbolLinkAndTargetDataPath(uris.at(i))) + return; + } QString desktopPath = "file://" + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString documentPath = Peony::FileUtils::getEncodedUri("file://" + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); QString musicPath = Peony::FileUtils::getEncodedUri("file://" + QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); @@ -2688,7 +2847,7 @@ void KyNativeFileDialog::setShortCuts() auto searchAction = new QAction(this); searchAction->setShortcuts(QList()<getCurrentSelections().first().startsWith("favorite://", Qt::CaseInsensitive)) { return ; } + auto uris = this->getCurrentSelections(); + + for(int i =0; i < uris.count(); i++){ + if(isSymbolLinkAndTargetDataPath(uris.at(i))) + return; + } } else return; @@ -2815,7 +2980,7 @@ void KyNativeFileDialog::setShortCuts() auto currentUri = getCurrentUri(); if (currentUri.startsWith("trash://") || currentUri.startsWith("recent://") || currentUri.startsWith("computer://") || currentUri.startsWith("favorite://") - || currentUri.startsWith("search://") || currentUri == "filesafe:///") + || currentUri.startsWith("search://") || currentUri == "filesafe:///" || currentUri == "idm://") { /* Add hint information,link to bug#107640. */ QMessageBox::warning(this, tr("warn"), tr("This operation is not supported.")); @@ -2853,6 +3018,12 @@ void KyNativeFileDialog::setShortCuts() if (this->getCurrentSelections().first().startsWith("favorite://", Qt::CaseInsensitive)) { return ; } + auto uris = this->getCurrentSelections(); + + for(int i =0; i < uris.count(); i++){ + if(isSymbolLinkAndTargetDataPath(uris.at(i))) + return; + } auto currentUri = getCurrentUri(); if (currentUri.startsWith("search://")) @@ -2870,6 +3041,25 @@ void KyNativeFileDialog::setShortCuts() }); addAction(cutAction); + //show selected item's properties + auto propertiesWindowAction = new QAction(this); + propertiesWindowAction->setShortcuts(QList()< 0) + { + this->showProperties(currentSelections); + } + else + { + this->showProperties(getCurrentUri()); + } + + }); + addAction(propertiesWindowAction); m_shortcutsSet = true; } } @@ -3158,7 +3348,8 @@ void KyNativeFileDialog::selectionChanged() QString KyNativeFileDialog::convertSpecialPath(QString uri) const { if (uri.startsWith("trash://") || uri.startsWith("recent://") - || uri.startsWith("computer://") || uri.startsWith("favorite://")){ + || uri.startsWith("computer://") || uri.startsWith("favorite://") || + uri.startsWith("idm://")){ pDebug << "convertSpecialPath directory............" << uri; return Peony::FileUtils::getTargetUri(uri); @@ -3236,6 +3427,94 @@ void KyNativeFileDialog::slot_responseUnmounted(const QString &destUri, const QS } +void KyNativeFileDialog::showProperties(const QString &uri) +{ + //qDebug() << "showProperties uri:" <= QT_VERSION_CHECK(5, 10, 0) + p.setProgram("/usr/bin/peony"); + p.setArguments(QStringList()<<"--show-properties"< 1) { + args.removeAt(args.indexOf("trash:///")); + QtConcurrent::run([=]() { + QProcess p; +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + p.setProgram("/usr/bin/peony"); + p.setArguments(QStringList() << "--show-properties" << "trash:///"); + p.startDetached(); +#else + p.startDetached("/usr/bin/peony", QStringList()<<"--show-properties"<= QT_VERSION_CHECK(5, 10, 0) + p.setProgram("/usr/bin/peony"); + p.setArguments(QStringList() << "--show-properties" << args); + p.startDetached(); +#else + p.startDetached("/usr/bin/peony", QStringList()<<"--show-properties"<= QT_VERSION_CHECK(5, 10, 0)) + p.startDetached(); +#else + p.startDetached("/usr/bin/ukui-control-center", QStringList()<<"-m" << "About"); +#endif + p.waitForFinished(-1); +} + +bool KyNativeFileDialog::isSymbolLinkAndTargetDataPath(const QString &uri) +{ + bool isTargetData = false; + if (Peony::FileUtils::getFileIsSymbolicLink(uri)) { + QString targetPath = Peony::FileUtils::getSymbolicTarget(uri); + if (targetPath == "/data/usershare") { + isTargetData = true; + } + } + return isTargetData; +} + /* GAsyncReadyCallback KyNativeFileDialog::async_query_permisson_callback(GObject *obj, GAsyncResult *res, Peony::PermissionsPropertiesPage *p_this) { @@ -3252,7 +3531,7 @@ GAsyncReadyCallback KyNativeFileDialog::async_query_permisson_callback(GObject * auto owner_writeable = mode & S_IWUSR; auto owner_executable = mode & S_IXUSR; - qDebug() << "owner_writeable......" << owner_writeable; + pDebug << "owner_writeable......" << owner_writeable; } g_object_unref(info); @@ -3266,15 +3545,15 @@ KyFileDialogHelper::KyFileDialogHelper() : QPlatformFileDialogHelper(), mKyFileD mKyFileDialog->setHelper(this); pDebug << "KyFileDialogHelper........." << (options() == nullptr); - connect(mKyFileDialog, &KyNativeFileDialog::currentChanged, this, &KyFileDialogHelper::currentChanged); - connect(mKyFileDialog, &KyNativeFileDialog::directoryEntered, this, &KyFileDialogHelper::directoryEntered); + connect(mKyFileDialog.data(), &KyNativeFileDialog::currentChanged, this, &KyFileDialogHelper::currentChanged); + connect(mKyFileDialog.data(), &KyNativeFileDialog::directoryEntered, this, &KyFileDialogHelper::directoryEntered); //QFileDialog::accept()里_q_emitUrlSelected会发送fileSelected信号 这里会导致发两次fileSelected的信号 // connect(mKyFileDialog, &KyNativeFileDialog::fileSelected, this, &KyFileDialogHelper::fileSelected); //QFileDialog::accept()里_q_emitUrlsSelected会发送filesSelected信号 这里会导致发两次filesSelected的信号 // connect(mKyFileDialog, &KyNativeFileDialog::filesSelected, this, &KyFileDialogHelper::filesSelected); - connect(mKyFileDialog, &KyNativeFileDialog::filterSelected, this, &KyFileDialogHelper::filterSelected); - connect(mKyFileDialog, &QDialog::accepted, this, &KyFileDialogHelper::accept); - connect(mKyFileDialog, &QDialog::rejected, this, &KyFileDialogHelper::reject); + connect(mKyFileDialog.data(), &KyNativeFileDialog::filterSelected, this, &KyFileDialogHelper::filterSelected); + connect(mKyFileDialog.data(), &QDialog::accepted, this, &KyFileDialogHelper::accept); + connect(mKyFileDialog.data(), &QDialog::rejected, this, &KyFileDialogHelper::reject); } @@ -3304,6 +3583,8 @@ void KyFileDialogHelper::hide() bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) { + Q_EMIT mKyFileDialog->updateSideModel(); + if(m_isShow){ mKyFileDialog->delayShow(); return true; @@ -3334,7 +3615,7 @@ bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi ///设置parent是QFiledialog 之前设置的是p 会有问题 showevent里有时候会找不到对应name的 /// 必须是p 否则设置的模态有问题 只对parent模态 在parent里去遍历找子对象 mKyFileDialog->setParent(p, windowFlags); - UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mKyFileDialog); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mKyFileDialog.data()); windowHelper->setSkipSwitcher(true); } pDebug << "filediaog directory000...." << fd->directory(); @@ -3347,7 +3628,14 @@ bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi pDebug <<"dirrrrr..." << dir.path(); mKyFileDialog->mKyFileDialogUi->m_pathbarWidget->updatePath(QUrl::fromLocalFile(dir.absolutePath()).toString()); mKyFileDialog->setDirectory(dir); - } else if(fd->directory().exists() || Peony::FileUtils::isFileExsit(fd->directory().path())){ + } + else if(!m_initialDirectory.toString().isEmpty() && Peony::FileUtils::isFileExsit(m_initialDirectory.toString())){ + QDir dir(m_initialDirectory.toString()); + pDebug <<"m_initialDirectory dirrrrr..." << dir.path(); + mKyFileDialog->mKyFileDialogUi->m_pathbarWidget->updatePath(QUrl::fromLocalFile(dir.absolutePath()).toString()); + mKyFileDialog->setDirectory(m_initialDirectory.toString()); + } + else if(fd->directory().exists() || Peony::FileUtils::isFileExsit(fd->directory().path())){ pDebug << "directory exsits...." << fd->directory().path(); mKyFileDialog->mKyFileDialogUi->m_pathbarWidget->updatePath(QUrl::fromLocalFile(fd->directory().absolutePath()).toString()); @@ -3393,6 +3681,12 @@ bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi mKyFileDialog->setDirectory(dir); } + else if(!m_initialDirectory.toString().isEmpty() && Peony::FileUtils::isFileExsit(m_initialDirectory.toString())){ + QDir dir(m_initialDirectory.toString()); + pDebug <<"m_initialDirectory dirrrrr..." << dir.path(); + mKyFileDialog->mKyFileDialogUi->m_pathbarWidget->updatePath(QUrl::fromLocalFile(dir.absolutePath()).toString()); + mKyFileDialog->setDirectory(m_initialDirectory.toString()); + } else if(fd->directory().exists() || Peony::FileUtils::isFileExsit(fd->directory().path())){ pDebug << "updatePath........." << fd->directory(); mKyFileDialog->mKyFileDialogUi->m_pathbarWidget->updatePath(QUrl::fromLocalFile(fd->directory().absolutePath()).toString()); @@ -3410,12 +3704,31 @@ bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi } } } + QString viewmode = "listview"; + if (QGSettings::isSchemaInstalled("org.ukui.style")) { + auto settings = UKUIStyleSettings::globalInstance(); + if(settings->keys().contains(FILEDIALOG_VIEW_MODE)) + viewmode = settings->get(FILEDIALOG_VIEW_MODE).toString(); + } + pDebug << "options viewmode..." << options()->viewMode() << mKyFileDialog->viewMode() << viewmode; + + if((options()->viewMode() == QFileDialog::List || viewmode == "iconview")){ + if( mKyFileDialog->viewMode() != KyNativeFileDialog::Icon){ + mKyFileDialog->setViewMode(KyNativeFileDialog::Icon); + } + auto settings = UKUIStyleSettings::globalInstance(); + if(viewmode != "iconview" && settings->keys().contains(FILEDIALOG_VIEW_MODE)) + settings->set(FILEDIALOG_VIEW_MODE, "iconview"); + } + else{ + if(mKyFileDialog->viewMode() != KyNativeFileDialog::List) + mKyFileDialog->setViewMode(KyNativeFileDialog::List); + auto settings = UKUIStyleSettings::globalInstance(); + if(viewmode != "listview" && settings->keys().contains(FILEDIALOG_VIEW_MODE)) + settings->set(FILEDIALOG_VIEW_MODE, "listview"); + } + - pDebug << "options viewmode..." << options()->viewMode() << mKyFileDialog->viewMode(); - if(options()->viewMode() == QFileDialog::List && mKyFileDialog->viewMode() != KyNativeFileDialog::Icon) - mKyFileDialog->setViewMode(KyNativeFileDialog::Icon); - else if(options()->viewMode() == QFileDialog::Detail && mKyFileDialog->viewMode() != KyNativeFileDialog::List) - mKyFileDialog->setViewMode(KyNativeFileDialog::List); //remove windows header // QString platform = QGuiApplication::platformName(); @@ -3429,7 +3742,7 @@ bool KyFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wi // hints.decorations = MWM_DECOR_BORDER; // XAtomHelper::getInstance()->setWindowMotifHint(mKyFileDialog->winId(), hints); // } - UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mKyFileDialog); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mKyFileDialog.data()); windowHelper->removeTitleBar(); @@ -3525,6 +3838,11 @@ void KyFileDialogHelper::viewInitialFinished() pDebug << "initiallySelectedFiles:" << selectedFiles; for(const auto& selectedFile: selectedFiles) { + // fix bug#445139 + if (options()->acceptMode() == QFileDialog::AcceptOpen && !Peony::FileUtils::isFileExsit(selectedFile.toString())) + { + continue; + } auto info = Peony::FileInfo::fromUri(selectedFile.path()); // if (!info->isDir() && !info->isVolume()) // { @@ -3655,7 +3973,7 @@ QList KyFileDialogHelper::selectedFiles() const !uri.startsWith("filesafe://") && !uri.startsWith("mult://") && !uri.startsWith("smb://") && !uri.startsWith("ftp://") && !uri.startsWith("sftp://") && !uri.startsWith("mtp://") && - !uri.startsWith("gphoto2://")){ + !uri.startsWith("gphoto2://") && !uri.startsWith("idm://")){ if(uri.startsWith("file:///")) uri = uri.remove(0,7); @@ -3696,7 +4014,7 @@ QList KyFileDialogHelper::selectedFiles() const directoryPath.startsWith("filesafe://") || directoryPath.startsWith("mult://") || directoryPath.startsWith("smb://") || directoryPath.startsWith("ftp://") || directoryPath.startsWith("sftp://") || directoryPath.startsWith("mtp://") || - directoryPath.startsWith("gphoto2://")){ + directoryPath.startsWith("gphoto2://") || directoryPath.startsWith("idm://")){ QStringList urlStrList = mKyFileDialog->getCurrentPage()->getCurrentSelections(); QStringList pathList; QString fileName = mKyFileDialog->copyEditText(); diff --git a/qt5-ukui-filedialog/kyfiledialog.h b/qt5-ukui-filedialog/kyfiledialog.h index 012ee6a..dacff69 100644 --- a/qt5-ukui-filedialog/kyfiledialog.h +++ b/qt5-ukui-filedialog/kyfiledialog.h @@ -33,6 +33,7 @@ #include "qpa/qplatformdialoghelper.h" #include #include +#include "ukuiwindowhelper.h" #define OPEN_ACTIONS_SEPARATOR "open-actions-seperator" #define CREATE_ACTIONS_SEPARATOR "create-actions-seperator" @@ -326,6 +327,9 @@ public: */ QString convertSpecialPath(QString path) const; + bool isSymbolLinkAndTargetDataPath(const QString &uri); + + Q_SIGNALS: void switchViewRequest(const QString &viewId); @@ -337,6 +341,7 @@ Q_SIGNALS: void filterSelected(const QString &filter); void locationChangeEnd(); void locationChangeStart(); + void updateSideModel(); public Q_SLOTS: void goToUri(const QString &uri, bool addToHistory = true, bool forceUpdate = false); @@ -349,7 +354,7 @@ public Q_SLOTS: void updateStatusBar(); void onNewFolder(); void setSortType(); - void searchButtonClicked(); + void searchButtonClicked(bool search = false); void setSearchMode(bool mode); void lineEditTextChange(QString text); void containerMenuRequest(const QPoint &pos); @@ -357,11 +362,15 @@ public Q_SLOTS: void selectionChanged(); bool isDataBlockHasUserFile(); void slot_responseUnmounted(const QString &destUri, const QString &sourceUri); + void showProperties(const QString &uri); + void showProperties(const QStringList &uris); + void gotoAboutComputer(); protected: void resizeEvent(QResizeEvent *e); void paintEvent(QPaintEvent *e); void keyPressEvent(QKeyEvent *e); + bool event(QEvent *e); private: Ui_KyFileDialog *mKyFileDialogUi = nullptr; @@ -403,7 +412,8 @@ private: QString m_longSavePath; //保存长文件的目录 int m_maxLenth = LONG_NAME_LIMIT;//文件名的最长长度 QString m_RecodPath;//记录的最后一个非长文件名目录 - int m_transparency = 0; + double m_transparency = 0.0; + UkuiWindowHelper *m_windowHelper = nullptr; QTranslator *m_translator = nullptr; QTranslator *m_translator0 = nullptr; @@ -455,7 +465,7 @@ Q_SIGNALS: private: - KyNativeFileDialog* mKyFileDialog = nullptr; + QScopedPointer mKyFileDialog; QUrl m_selectedFiles; bool m_viewInitialFinished = false; bool m_isShow = false; diff --git a/qt5-ukui-filedialog/menutoolbutoon.cpp b/qt5-ukui-filedialog/menutoolbutoon.cpp index 8c51857..6cca867 100644 --- a/qt5-ukui-filedialog/menutoolbutoon.cpp +++ b/qt5-ukui-filedialog/menutoolbutoon.cpp @@ -32,10 +32,10 @@ MenuToolButton::MenuToolButton(QWidget *parent) : QToolButton(parent) { setStyle(ToolButtonStyle::getStyle()); - QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); - } +// QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); +// } } void MenuToolButton::tableModeChanged(bool isTableMode) diff --git a/qt5-ukui-filedialog/pathbar.cpp b/qt5-ukui-filedialog/pathbar.cpp index a14488f..2b8fed0 100644 --- a/qt5-ukui-filedialog/pathbar.cpp +++ b/qt5-ukui-filedialog/pathbar.cpp @@ -16,27 +16,27 @@ FileDialogPathBar::FileDialogPathBar(QWidget *parent) : QWidget(parent)//Peony:: setContentsMargins(0,0,0,0); m_pathBar = new Peony::AdvancedLocationBar(this); - QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(updateTableModel(bool))); - } +// QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(updateTableModel(bool))); +// } - QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - "get_current_tabletmode"); - QDBusMessage ret = QDBusConnection::sessionBus().call(message); - if (ret.type() != QDBusMessage::ReplyMessage) - { - //从返回参数获取返回值 - pDebug << "complex type failed!"; - updateTableModel(false); - } - else - { - updateTableModel(ret.arguments()[0].value()); - } +// QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", +// "/", +// "com.kylin.statusmanager.interface", +// "get_current_tabletmode"); +// QDBusMessage ret = QDBusConnection::sessionBus().call(message); +// if (ret.type() != QDBusMessage::ReplyMessage) +// { +// //从返回参数获取返回值 +// pDebug << "complex type failed!"; +// updateTableModel(false); +// } +// else +// { +// updateTableModel(ret.arguments()[0].value()); +// } } FileDialogPathBar::~FileDialogPathBar() @@ -47,8 +47,12 @@ FileDialogPathBar::~FileDialogPathBar() void FileDialogPathBar::updatePath(const QString &uri) { -// qDebug() << "m_pathBar........ updatePath:" << uri << Peony::FileUtils::getEncodedUri(uri); - m_pathBar->updateLocation(Peony::FileUtils::urlEncode(uri)); + pDebug << "m_pathBar........ updatePath:" << uri << Peony::FileUtils::getEncodedUri(uri) << Peony::FileUtils::urlEncode(uri); + if(!uri.startsWith("search://")) + m_pathBar->updateLocation(Peony::FileUtils::urlEncode(uri)); + else + m_pathBar->updateLocation(uri); + // setText(uri); // clearFocus(); } @@ -56,6 +60,7 @@ void FileDialogPathBar::updatePath(const QString &uri) void FileDialogPathBar::resizeEvent(QResizeEvent *e) { m_pathBar->setFixedWidth(this->width()); + m_pathBar->setFixedHeight(36); m_pathBar->setGeometry(0, (this->height() - m_pathBar->height()) / 2, this->width(), m_pathBar->height()); } diff --git a/qt5-ukui-filedialog/sidebar.cpp b/qt5-ukui-filedialog/sidebar.cpp index a87d240..60feaad 100644 --- a/qt5-ukui-filedialog/sidebar.cpp +++ b/qt5-ukui-filedialog/sidebar.cpp @@ -43,10 +43,10 @@ FileDialogComboBox::FileDialogComboBox(QWidget *parent):QComboBox(parent) pDebug << "setStyleChanged m_styleChanged:" << change; m_styleChanged = change; }); - QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); - } +// QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); +// } m_minSize = this->minimumSize(); pDebug << "combobox minsize...." << m_minSize; } @@ -66,7 +66,8 @@ QSize FileDialogComboBox::minimumSizeHint() const } QSize size = QComboBox::minimumSizeHint(); - return size; + //fixbug#480595 + return QSize(size.width() > 160 ? 160 : size.width(), size.height()); } @@ -92,6 +93,9 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent) setProperty("doNotBlur", true); viewport()->setProperty("doNotBlur", true); setContextMenuPolicy(Qt::CustomContextMenu); + setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_Disabled, false); setExpandsOnDoubleClick(false); setMouseTracking(true);//追踪鼠标 @@ -235,10 +239,29 @@ FileDialogSideBar::FileDialogSideBar(QWidget *parent) : QTreeView(parent) } }); - QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); - } + connect(Peony::GlobalSettings::getInstance(), &GlobalSettings::valueChanged, this, [=](const QString& key){ + if (SHOW_NETWORK == key) { + for (int i = 0; i < m_proxyModel->rowCount(); ++i) { + auto index = m_proxyModel->index(i, 0); + auto item = m_proxyModel->itemFromIndex(index); + bool isShowNetwork = Peony::GlobalSettings::getInstance()->isExist(SHOW_NETWORK) ? + Peony::GlobalSettings::getInstance()->getValue(SHOW_NETWORK).toBool() : true; + if (item->type() == SideBarAbstractItem::NetWorkItem) { + this->setRowHidden(index.row(), index.parent(), !isShowNetwork); + if (!isShowNetwork) { + item->findChildrenAsync(); + } + return; + } + } + this->viewport()->update(); + } + }); + +// QDBusInterface *interFace = new QDBusInterface(SERVICE, PATH, INTERFACE, QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); +// } // if (QGSettings::isSchemaInstalled("org.ukui.style")) { // auto settings = UKUIStyleSettings::globalInstance(); @@ -315,13 +338,43 @@ void FileDialogSideBar::menuRequest(const QPoint &pos) void FileDialogSideBar::paintEvent(QPaintEvent *event) { - QPalette palette = qApp->palette(); - palette.setColor(QPalette::Base, QColor(Qt::transparent));//window AlternateBase Base NoRole - this->setPalette(palette); + setViewportMargins(8, 4, 4, 4); + QPalette pal = qApp->palette(); + pal.setColor(QPalette::Base, QColor(Qt::transparent)); + setPalette(pal); + viewport()->setPalette(pal); QTreeView::paintEvent(event); } +void FileDialogSideBar::updateModel() +{ + Peony::GlobalSettings::getInstance()->forceSync(); + QMap remoteServer = Peony::GlobalSettings::getInstance()->getValue(REMOTE_SERVER_REMOTE_IP).toMap (); + + for (const QString& remoteServer : remoteServer.keys()) { + if (!remoteServer.isEmpty()) { + for (int i = 0; i < m_proxyModel->rowCount(); ++i) { + auto index = m_proxyModel->index(i, 0); + auto item = m_proxyModel->itemFromIndex(index); + bool isShowNetwork = Peony::GlobalSettings::getInstance()->isExist(SHOW_NETWORK) ? + Peony::GlobalSettings::getInstance()->getValue(SHOW_NETWORK).toBool() : true; + if (item->type() == SideBarAbstractItem::NetWorkItem) { + this->setRowHidden(index.row(), index.parent(), !isShowNetwork); + if (!isShowNetwork) { + item->findChildrenAsync(); + } + if(this->isExpanded(index)) + { + this->collapse(index); + this->expand(index); + } + } + } + this->viewport()->update(); + } + } +} //void FileDialogSideBar::paintEvent(QPaintEvent *e) //{ // QColor color = this->palette().window().color(); diff --git a/qt5-ukui-filedialog/sidebar.h b/qt5-ukui-filedialog/sidebar.h index d7731da..74e436c 100644 --- a/qt5-ukui-filedialog/sidebar.h +++ b/qt5-ukui-filedialog/sidebar.h @@ -83,6 +83,7 @@ public: public Q_SLOTS: void menuRequest(const QPoint &pos); void tableModeChanged(bool isTableMode); + void updateModel(); private: Peony::SideBarProxyFilterSortModel *m_proxyModel = nullptr; diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_bo_CN.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_bo_CN.ts index cd2450d..a43ee98 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_bo_CN.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_bo_CN.ts @@ -11,12 +11,12 @@ Save File - ཉར་ཚགས། + ཡིག་ཆ་ཉར་ཚགས་བྱེད་པ All Files (*) - ཡོད་ཚད་(*) + ཡིག་ཆ་ཡོད་ཚད་(*) @@ -43,7 +43,7 @@ Saving "%1" - "%1"ཉར་ཚགས་བྱེད་བཞིན་ཡོད། + 正在保存 “%1” @@ -52,7 +52,7 @@ Filename too long - ཡིག་ཆའི་མིང་རིང་དྲགས་པ། + 文件名过长 @@ -61,31 +61,31 @@ Copying "%1" - "བརྒྱ་ཆ་1"འདྲ་བཟོ་བྱེད་བཞིན་ཡོད། + 正在复制 "%1" To "%1" - "བརྒྱ་ཆ་1"ལ་སླེབས་པར་བྱ་དགོས། + 到 "%1" Copying failed, the reason is: %1 - འདྲ་བཟོ་བྱས་པར་ཕམ་ཉེས་བྱུང་བའི་རྒྱུ་མཚན་ནི། བརྒྱ་ཆ་1ཡིན། + 复制失败, 原因: %1 Moving "%1" - "བརྒྱ་ཆ་1"སྤོ་བཞིན་ཡོད། + 正在移动 "%1" Moving failed, the reason is: %1 - སྤོ་འགུལ་ཕམ་ཉེས་བྱུང་བའི་རྒྱུ་མཚན་གཤམ་གསལ། + 移动失败, 原因: %1 File operation error: - ཡིག་ཆ་བཀོལ་སྤྱོད་ཀྱི་ནོར་འཁྲུལ་ནི། + 文件操作错误: The reason is: %1 - རྒྱུ་མཚན་ནི་བརྒྱ་ཆ་1ཡོད་ + 原因: %1 @@ -100,7 +100,7 @@ Rename - མིང་བསྐྱར་བཏགས་པ། + མིང་བསྒྱུར་བ། @@ -133,15 +133,15 @@ Cancel - ཕྱིར་འཐེན། + མེད་པར་བཟོ་དགོས Apply - ཉེར་སྤྱོད། + 应用 Save - གྲོན་ཆུང་བྱེད་དགོས། + 保存 @@ -158,13 +158,17 @@ OK - གཏན་འཁེལ། + འགྲིགས། File "%1" ཡིག་ཆ་"%1" + + Filename too long. + 文件名过长。 + Please choose the following processing method: @@ -182,7 +186,11 @@ Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - དེའི་ཐོག་ནས་སྤྱོད་མཁན་གྱིས་ཡིག་ཆའི་མིང་བསྐྱར་དུ་བཏགས་ཏེ་བརྒྱ་ཆ་12ནང་ཚུན་དུ་འགན་ལེན་བྱ་དགོས་པ་དང་། + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ @@ -191,7 +199,11 @@ Description: Save the file to "%1/扩展". - གསལ་བཤད་བྱས་དོན། ཡིག་ཆ་དེ་"བརྒྱ་ཆ་1/1བར་དུ་ཉར་ཚགས་བྱེད་དགོས་"ཞེས་གསལ་བཤད་བྱས་ཡོད། + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 @@ -204,12 +216,12 @@ Go Forward - མདུན་སྐྱོད། + མདུན་དུ་སྐྱོད། Cd Up - གོང་མ། + གོང་ཕྱོགས། @@ -224,18 +236,18 @@ Sort Type - གོ་རིམ་རིགས། + རིམ་སྒྲིག་གི་རིགས། Maximize - ཆེས་ཆེ་བསྒྱུར། + ཆེས་ཆེ་ཤོས། Close - ཁ་རྒྱག་པ། + སྒོ་རྒྱག་པ་ @@ -245,7 +257,7 @@ Name - ཡིག་ཆའི་མིང་། + མིང་། @@ -257,23 +269,23 @@ Cancel - ཕྱིར་འཐེན། + མེད་པར་བཟོ་དགོས Save as - གཞན་དུ་ཉར་ཚགས། + གཞན་གཉེར། New Folder - ཡིག་ཁུག་གསར་འཛུགས། + གསར་འཛུགས་ཡིག་ཁུག Save - ཉར་ཚག། + གྲོན་ཆུང་བྱེད་དགོས། @@ -289,32 +301,32 @@ Warning - ཐ་ཚིག། + ཐ་ཚིག་སྒྲོག་པ། exist, are you sure replace? - ཡོད་ཟིན། བརྗེ་དགོས་སམ། + གནས་ཡོད་པས། ཁྱོད་ཀྱིས་དངོས་གནས་ཚབ་བྱེད་ཐུབ་བམ། NewFolder - དཀར་ཆག་གསར་འཛུགས། + ཡིག་སྒམ། Undo - ཕྱིར་འཐེན། + ཕྱིར་འཐེན་བྱེད་པ། Redo - ཡང་བསྐྱར་བྱེད་པ། + ཡང་བསྐྱར་ཐེངས་གཅིག་ལ་བསྐྱར warn - ཐ་ཚིག། + ཉེན་བརྡ། @@ -330,40 +342,15 @@ ཡིག་ཆ་ཉར་ཚགས་བྱེད་ཐུབ་མ་སོང། - - MessageBox - - Close - ཁ་རྒྱག་པ། - - - - QApplication - - Executable '%1' requires Qt %2, found Qt %3. - ལག་བསྟར་བྱེད་ཆོག་པའི་'%1'ལ་Qt %2,Qt%3རྙེད་པ་རེད། - - - Incompatible Qt Library Error - ཕན་ཚུན་མཐུན་ཐབས་མེད་པའི་Qt དཔེ་མཛོད་ཁང་གི་ནོར་འཁྲུལ། - - - - QDialogButtonBox - - OK - འགྲིགས། - - QMessageBox Show Details... - ཞིབ་ཕྲའི་གནས་ཚུལ་གསལ་བཤད་བྱ་དགོས། + 显示细节…… Hide Details... - གནས་ཚུལ་ཞིབ་ཕྲ་སྦས་སྐུང་བྱེད་ + 隐藏细节…… @@ -376,7 +363,7 @@ Modified Date - དུས་འགྱུར་བ། + བཅོས་པའི་ཚེས་གྲངས། @@ -391,43 +378,32 @@ Original Path - དང་ཐོག་མའི་ལམ། + གདོད་མའི་ཐབས་ལམ། Descending - མར་འབབ་པ། + རིམ་ཕབ། Ascending - འཕར། + རིམ་འཕར། - Use global sorting - ཁྱོན་ཡོངས་་གོ་རིམ་སྒྲིག་པ། + Use current sorting for all folders + ཡིག་ཆ་ཚང་མས་མིག་སྔའི་གོ་རིམ་བཀོལ་སྤྱོད་བྱས་ཡོད། List View - མཐོང་རིས་རེའུ་མིག + མིང་ཐོའི་ལྟ་ཚུལ། Icon View - མཚོན་རྟགས་ལྟ་རིས། - - - - UKUI::TabWidget::DefaultSlideAnimatorFactory - - Default Slide - ཁ་ཆད་བཞག་པའི་སྒྲོན་བརྙན - - - Let tab widget switch with a slide animation. - སྒྲོན་བརྙན་གྱི་འགུལ་རིས་ལ་བརྟེན་ནས་ཤོག་བྱང་ཆུང་ཆུང་བརྗེ་རེས་བྱེད་དུ་འཇུག་དགོས། + 图标视图 diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_cs.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_cs.ts index c714a9d..5df6d65 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_cs.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_cs.ts @@ -317,7 +317,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_de.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_de.ts index bc94a1b..3964b07 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_de.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_de.ts @@ -184,8 +184,8 @@ - Use global sorting - Globale Sortierung verwenden + Use current sorting for all folders + Aktuelle Sortierung für alle Ordner verwenden diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_en_US.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_en_US.ts index 6c25374..c5399e4 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_en_US.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_en_US.ts @@ -373,8 +373,8 @@ - Use global sorting - Use global sorting + Use current sorting for all folders + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_es.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_es.ts index 39a9a5a..5a0a29e 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_es.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_es.ts @@ -184,7 +184,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fa.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fa.ts index c95d7e8..58dc38e 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fa.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fa.ts @@ -317,7 +317,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fr.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fr.ts index 66ddb05..7ac2781 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fr.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_fr.ts @@ -317,7 +317,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_kk.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_kk.ts index 7791cb3..9c6506b 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_kk.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_kk.ts @@ -1,22 +1,22 @@ - + UKUIFileDialog::KyFileDialogHelper Open File - + حۇجاتتى ٸشٸۋ Save File - + حۇجاتتى ساقتاۋ All Files (*) - + بارلٸق حۇجاتتار (*) @@ -24,211 +24,275 @@ bytes - + بايت Bytes - + بايت character - + حارەكتەرى Character - + كەيپكەر + + + Saving "%1" + 正在保存 “%1” Saving failed, the reason is: %1 - + ساقتاۋ جەڭىلىپ قالدى، وبالى: %1 - - Please choose the following processing method: - + Filename too long + 文件名过长 + + + + Description: Save long file names to " + تۇسٸندٸرۋشٸ: ۇزىن حۇجات اتاقتارىن " عا ساقتاۋ + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 Truncation - + كەسۋ Save to long file name directory - + ۇزىن حۇجات مى مازمۇنعا ساقتاۋ Rename - + ەسىمىن وزگەرتۋ modify the name - - - - - Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - - - - - Description: Save long file names to " - - - - - ". - + ەسىمىن وزگەرتۋ . - + . Explanation: When renaming a file name, ensure it is within %1 %2 and - + تۇسىندىرۋ: حۇجات اتاعىن وزگەرتكەندە، حۇجات اتاعىنڭ %1 %2 ساباعىندا بولۋٸنا كەپىلدىك ىستەڭ ۋا All applications - - - - - File "%1" - + بارلٸق قولدانعىش پٸروگٸراممالار The file name is too long. - + حۇجات مى وتە ۇزىن ەكەن. Cancel - + كۇشىنەن قالدىرۋ + + + Apply + 应用 + + + Save + 保存 Front truncation - + الدى قىسقارتۋ Post truncation - + كەسۋ جازباسى OK - + ماقۇل + + + + File "%1" + حۇجات "%1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + تومەندەگٸ بٸر جاق ەتۋ تاسٸلدٸ تالدا: truncate interval + قىسقارتۋ ارالققا + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + تۇسىندىرۋ: %1 %2 دان ٸشٸپ كەتكەن حۇجات اتاعىن قىسقارتىپ تالدا. + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + UKUIFileDialog::KyNativeFileDialog Go Back - + ارتىنا قايتۋ Go Forward - + ىلگەرلەۋ Cd Up - + Cd دان جوعارعى Search - + ىزدە View Type - + كورۋ تيپى Sort Type - + تۇرگە ايىرۋ تيپى Maximize - + ۇلكەندىگى Close - + تاقاۋ Restore - + قالپىنا كەلتىرىلگەن Name - + مى Open - + ٸشٸۋ Cancel - + كۇشىنەن قالدىرۋ Save as - + ورىنداپ ساقتاۋ New Folder - + جاڭا حۇجات قىسقىش Save - + ساقتاۋ Directories - + باس مازمۇن @@ -237,37 +301,37 @@ Warning - + ەسكەرتۋ exist, are you sure replace? - + ساقتالعان، الماستٸرۋدٸ تۇراقتاستىراسىزبا؟ NewFolder - + جاڭا قاتتاعىش Undo - + قايتىپ الۋ Redo - + قايتىلا warn - + ەسكەرتۋ This operation is not supported. - + نۇ جوبالاۋ قولدامايدى. @@ -275,7 +339,18 @@ File save failed! - + حۇجات ساقتاۋ جەڭىلىپ قالدى! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… @@ -283,211 +358,52 @@ File Name - + قولحات مى Modified Date - + وزگەرتىلگەن ۋاقىتى File Type - + حۇجات تۇرى File Size - + حۇجات ۇلكەندىگى Original Path - + وڭ جول Descending - + تومەندەۋ Ascending - + ورلەۋ جاعٸ - Use global sorting - ئومومىيلىق مەنەن تىزۋدى ٸستەتۋ + Use current sorting for all folders + بارلٸق حۇجات قىسقىشقا قارتا كەزەكتەگى رەتتەۋدى ٸستەتڭٸز. List View - + تٸزٸمدٸك كورىنۋى Icon View - پىشىن كورىنۋى - - - Close - 关闭 - - - - UKUI::TabWidget::DefaultSlideAnimatorFactory - - - Default Slide - الدىن بەكٸتٸلگەن slide - - - - Let tab widget switch with a slide animation. - تالدانبا كارتونىن كشكەنە زاپشاستارىن پٸروبيكسيا كارتون فىلىمىگە سايكەستىرۋ - - - - UKUIFileDialog::KyFileDialogHelper - - - Open File - حۇجاتتى ٸشٸۋ - - - - Save File - حۇجاتتى ساقتاۋ - - - - All Files (*) - بارلٸق حۇجاتتار (*) - - - - UKUIFileDialog::KyNativeFileDialog - - - Go Back - قايتۋ - - - - Go Forward - ىلگەرلەۋ - - - - Cd Up - Cd نىڭ ٷستٸندە - - - - Search - ٸزدەۋ - - - - View Type - كورىنۋ تيپى - - - - Sort Type - رەتتەلگەن تيپ - - - - - Maximize - ۇلكەيتۋ - - - - Close - تاقاۋ - - - - Restore - قالپىنا كەلتىرىلگەن - - - - Name - ات-فاميليا - - - - - Open - ٸشٸۋ - - - - - Cancel - كۇشىنەن قالدىرۋ - - - - Save as - تەجەۋ - - - - New Folder - جاڭا حۇجات قىسقىش - - - - - Save - ساقتاۋ - - - - - - Directories - مازمۇندار - - - - Warning - ەسكەرتۋ - - - - exist, are you sure replace? - ساقتالعان، الماستٸرۋدٸ تۇراقتاستىراسىزبا؟ - - - - NewFolder - جاڭا قاتتاعىش - - - - Undo - Undo - - - - Redo - قاتە-قاتە - - - - warn - ەسكەرتۋ - - - - This operation is not supported. - نۇ جوبالاۋدى قولدامايدى. + گرافيىكتى كورۋ diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ky.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ky.ts index 0e2da26..02452f5 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ky.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ky.ts @@ -1,22 +1,22 @@ - + UKUIFileDialog::KyFileDialogHelper Open File - + ۅجۅتۉن اچۇۇ Save File - + ۅجۅت ساقتوو All Files (*) - + باردىق ۅجۅتتۅر (*) @@ -24,211 +24,275 @@ bytes - + بايت Bytes - + بايت character - + خاراكتېرى Character - + جەكە + + + Saving "%1" + 正在保存 “%1” Saving failed, the reason is: %1 - + ساقتوو جەڭىلۉۉ بولدۇ ، سەبەبى : %1 - - Please choose the following processing method: - + Filename too long + 文件名过长 + + + + Description: Save long file names to " + تۉشۉندۉرۉسۉ: ۇزۇن ۅجۅت ناامدارىن " عا ساقتوو + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 Truncation - + قىيىش Save to long file name directory - + ۇزۇن ۅجۅت ناامى مازمۇۇنۇنا ساقتوو Rename - + قايرا ات تەك ات جاسوو ،اتقارۇۇ modify the name - - - - - Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - - - - - Description: Save long file names to " - - - - - ". - + اتتى ۅزگۅرتۉش . - + Explanation: When renaming a file name, ensure it is within %1 %2 and - + تۉشۅندۉرۉش : ۅجۅت اتاعىن ۅزگۅرتكۅندۅ، ۅجۅت اتاعىنڭ %1 %2 چۅلكۅمۉندۅ بولۇشۇنا ەەبولۇۇ قىلىڭ جانا All applications - - - - - File "%1" - + باردىق قولدونۇشچان پراگراممالار The file name is too long. - + ۅجۅت ناامى ۅتۅ ۇزۇن ەكەن . Cancel - + ارعادان قالتىرىش + + + Apply + 应用 + + + Save + 保存 Front truncation - + الدى بۅلۅگۉ كېسىۋېتىلگەن. Post truncation - + قىيىش يازمىسى OK - + بەكىتۉۉ + + + + File "%1" + ۅجۅت "%1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + تۅمۅندۅكۉ بىر تاراپ جاسوو ،اتقارۇۇ ىڭعايىن تانداڭ: truncate interval + قىسقارتۇۇ ارالىعى + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + تۉشۅندۉرۉش : %1 %2 نان اشىپ كەتكەن ،قوروعون ۅجۅت اتاعىن قىسقارتىپ تانداڭ. + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + UKUIFileDialog::KyNativeFileDialog Go Back - + ارتىنا يېنىش Go Forward - + ىلگەرلۅۅ Cd Up - + Cd نان جوعورۇ Search - + ىزدۅۅ View Type - + كۅرۉۉ تۉرۉ Sort Type - + ترتىپلەش تۉرۉ Maximize - + چوڭدۇعۇ Close - + بەكىتىش Restore - + العاچىنا كەتىرىش Name - + ات-تەك اتى Open - + اچۇۇ Cancel - + ارعادان قالتىرىش Save as - + جاساپ ساقتوو New Folder - + جاڭى ۅجۅت قىپچىعىچ Save - + ساقلا Directories - + تىزىمدىك @@ -237,37 +301,37 @@ Warning - + ەسكەرتۉۉ exist, are you sure replace? - + باربولۇۇسۇ ، الماشتىرۇۇنۇ تۇراقتاندىرا الاسىزبى؟ NewFolder - + جاڭى قاتتاعىچ Undo - + يېنىۋېلىش Redo - + قايرا ىشتۅۅ warn - + ەسكەرتۉۉ This operation is not supported. - + بۇل ماشقۇلدانۇۇ قولدوبويت. @@ -275,7 +339,18 @@ File save failed! - + ۅجۅت ساقتوو جەڭىلۉۉ بولدۇ ! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… @@ -283,211 +358,52 @@ File Name - + ۅجۅت ناامى Modified Date - + ۅزگۅرتۉلگۅن ۇباقتى File Type - + ۅجۅت تۉرۉ File Size - + ۅجۅت چوڭدۇعۇ Original Path - + العاچى جول Descending - + چوڭدىن كىچىككە قاراتىپ تىزۉۉ Ascending - + كىچىكتەن چوڭعو قاراتىپ تىزۉۉ - Use global sorting - ئومومىيلىق مەنەن تىزۉۉنۉ ىشتەتىش + Use current sorting for all folders + باردىق ۅجۅت قىسقىچقا قاراتا گەزەكتەكى ىرەتتۅۅنۉ ىشتەتىڭ. List View - + تىزىمدىك گۅرۉنۉشۉ Icon View - تۉر گۅرۉنۉشۉ - - - Close - 关闭 - - - - UKUI::TabWidget::DefaultSlideAnimatorFactory - - - Default Slide - الدىن بەكىتىلگەن slide - - - - Let tab widget switch with a slide animation. - تاندالما كارتاداقى كىچىك شايمانداردى پرويەكسىيە كارتون فىلىمىگە الماشتىرۇۇ - - - - UKUIFileDialog::KyFileDialogHelper - - - Open File - ۅجۅتۉن اچۇۇ - - - - Save File - ۅجۅتۉن ساقتوو - - - - All Files (*) - باردىق ۅجۅتتۅر (*) - - - - UKUIFileDialog::KyNativeFileDialog - - - Go Back - قايتۇۇ - - - - Go Forward - ىلگەرلۅۅ - - - - Cd Up - Cd نىڭ ۉستۉندۆ - - - - Search - ىزدۅۅ - - - - View Type - كۅرۉنۉش تۉرۉ - - - - Sort Type - ىرەتتەلگەن تىپ - - - - - Maximize - چوڭويتۇش - - - - Close - بەكىتىش - - - - Restore - العاچىنا كەلتىرۉۉ - - - - Name - ات-تەك اتى - - - - - Open - اچۇۇ - - - - - Cancel - ارعادان قالتىرىش - - - - Save as - تەجۅۅ - - - - New Folder - جاڭى ۅجۅت قىپچىعىچ - - - - - Save - ساقتوو - - - - - - Directories - مازمۇۇندار - - - - Warning - ەسكەرتۉۉ - - - - exist, are you sure replace? - باربولۇۇسۇ ، الماشتىرۇۇنۇ تۇراقتاندىرا الاسىزبى؟ - - - - NewFolder - جاڭى قاتتاعىچ - - - - Undo - Undo - - - - Redo - قايرا-قايرا - - - - warn - ەسكەرتۉۉ - - - - This operation is not supported. - بۇل ماشقۇلدانۇۇنۇ قولدوبويت. + شارتتۇۇ بەلگىنى كۅرۉۉ diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_mn.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_mn.ts index a3eeeb5..d13397e 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_mn.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_mn.ts @@ -1,6 +1,6 @@ - + UKUIFileDialog::KyFileDialogHelper @@ -24,109 +24,109 @@ bytes - ᠪᠸᠲ᠋ᠠ + ᠪᠠᠰ Bytes - ᠪᠸᠲ᠋ᠠ + ᠪᠠᠰ character - ᠦᠰᠦᠭ ᠦᠨ ᠲᠡᠮᠲᠡᠭ ᠃ + ᠦᠰᠦᠭ ᠳᠡᠮᠳᠡᠭ Character - ᠦᠰᠦᠭ ᠦᠨ ᠲᠡᠮᠲᠡᠭ ᠃ + ᠦᠰᠦᠭ ᠳᠡᠮᠳᠡᠭ Saving "%1" - ᠬᠠᠳᠠᠭᠠᠯᠠᠵᠤ ᠪᠠᠢᠨ᠎ᠠ "%1" + 正在保存 “%1” Saving failed, the reason is: %1 - ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ ᠳᠤ ᠢᠯᠠᠭᠳᠠᠯ ᠢ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ ᠶᠢᠨ ᠰᠢᠯᠲᠠᠭᠠᠨ ᠨᠢ ᠄%1 + ᠬᠠᠳᠠᠭᠠᠯᠠᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ᠂ ᠰᠢᠯᠳᠠᠭᠠᠨ ᠨᠢ: %1 Filename too long - ᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠬᠡᠲᠦᠷᠬᠡᠢ ᠤᠷ + 文件名过长 Description: Save long file names to " - ᠳᠦᠷᠰᠦᠯᠡᠭᠰᠡᠨ ᠨᠢ  ᠤᠷᠲᠤ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠸᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠶᠢ ᠬᠠᠲᠠᠭᠠᠯᠠᠶ᠎ᠠ  ᠭᠡᠵᠡᠢ + ᠳᠤᠳᠤᠷᠬᠠᠢᠯᠠᠯᠳᠠ᠄ ᠤᠷᠳᠤ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ ᠵᠢᠨ ᠹᠠᠢᠯ ᠢ᠋ " ᠲᠤ᠌\ ᠳ᠋ᠤ᠌ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ Copying "%1" - %1"᠎ᠶ᠋ᠢ ᠺᠤᠫᠢᠳᠠᠵᠤ ᠪᠣᠢ + 正在复制 "%1" To "%1" - "%1" ᠪᠣᠯᠬᠤ ᠳᠤ ᠬᠦᠷᠲᠡᠯ᠎ᠡ + 到 "%1" Copying failed, the reason is: %1 - ᠪᠠᠭᠤᠯᠭᠠᠬᠤ ᠳᠤ ᠢᠯᠠᠭᠳᠠᠯ ᠳᠤ ᠢᠯᠠᠭᠳᠠᠭᠰᠠᠨ ᠰᠢᠯᠲᠠᠭᠠᠨ᠄ 1᠃ + 复制失败, 原因: %1 Moving "%1" - ᠶᠢᠡᠨ %1"᠎ᠶ᠋ᠢ ᠰᠢᠯᠵᠢᠭᠦᠯᠵᠦ ᠪᠣᠢ + 正在移动 "%1" Moving failed, the reason is: %1 - ᠰᠢᠯᠵᠢᠮᠡᠯ ᠢᠯᠠᠭᠳᠠᠭᠰᠠᠨ ᠤ ᠰᠢᠯᠲᠠᠭᠠᠨ ᠄ 1 ᠃ + 移动失败, 原因: %1 File operation error: - ᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠠᠵᠢᠯᠯᠠᠭᠤᠯᠬᠤ ᠪᠤᠷᠤᠭᠤ + 文件操作错误: The reason is: %1 - ᠰᠢᠯᠲᠠᠭᠠᠨ ᠄ 1 ᠃ + 原因: %1 Truncation - ᠲᠠᠰᠤᠯᠤᠨ᠎ᠠ ᠃ + ᠳᠠᠰᠤᠯᠬᠤ Save to long file name directory - ᠤᠷᠲᠤ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷᠡᠰ ᠦᠨ ᠭᠠᠷᠴᠠᠭ ᠲᠤ ᠬᠠᠳᠠᠭᠠᠯᠠᠨ᠎ᠠ ᠃ + ᠤᠷᠳᠤ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ ᠵᠢᠨ ᠭᠠᠷᠴᠠᠭ ᠲᠤ᠌ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ Rename - ᠬᠦᠨᠳᠦ ᠨᠡᠷᠡᠶᠢᠳᠦᠨ᠎ᠡ ᠃ + ᠳᠠᠬᠢᠵᠤ ᠨᠡᠷᠡᠯᠡᠬᠦ modify the name - ᠨᠡᠷᠡᠶᠢᠳᠬᠦ ᠶᠢ ᠵᠠᠰᠠᠨ᠎ᠠ ᠃ + ᠨᠡᠷᠡᠢᠳᠦᠯ ᠢ᠋ ᠵᠠᠰᠠᠬᠤ . - . + Explanation: When renaming a file name, ensure it is within %1 %2 and - ᠲᠠᠶᠢᠯᠪᠤᠷᠢᠯᠠᠯᠲᠠ ᠄ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠨᠡᠷᠡᠶᠢᠳᠦᠭᠰᠡᠨ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠶᠢ ᠬᠦᠨᠳᠦᠷᠡᠭᠦᠯᠵᠦ ᠂ %1%2 ᠶᠢᠨ ᠳᠣᠲᠣᠷ᠎ᠠ ᠂ ᠣᠴᠢᠬᠤ ᠶᠢ ᠪᠠᠲᠤᠯᠠᠨ᠎ᠠ ᠃ + ᠳᠤᠳᠤᠷᠬᠠᠢᠯᠠᠯᠳᠠ᠄ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ ᠵᠢ ᠳᠠᠬᠢᠨ ᠨᠡᠷᠡᠢᠳᠬᠦ᠂%1 %2 ᠤ᠋ᠨ\ ᠵᠢᠨ ᠳᠤᠳᠤᠷ᠎ᠠ ᠪᠠᠢᠬᠤ ᠵᠢ ᠪᠠᠳᠤᠯᠠᠬᠤ All applications - ᠪᠦᠬᠦᠨ ᠢ ᠬᠡᠷᠡᠭᠯᠡᠨ᠎ᠡ᠃ + ᠪᠦᠬᠦ ᠬᠡᠷᠡᠭᠯᠡᠭᠡ The file name is too long. - ᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠬᠡᠲᠦᠷᠬᠡᠢ ᠤᠷ + ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ ᠬᠡᠳᠦ ᠤᠷᠳᠤ᠃ @@ -137,61 +137,73 @@ Apply - ᠬᠡᠷᠡᠭᠯᠡᠨ᠎ᠡ᠃ + 应用 Save - ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ + 保存 Front truncation - ᠡᠮᠦᠨ᠎ᠡ ᠲᠠᠰᠤᠯᠤᠨ᠎ᠠ ᠃ + ᠡᠮᠦᠨᠡᠬᠢ ᠵᠢ ᠳᠠᠰᠤᠯᠬᠤ Post truncation - ᠬᠣᠢ᠌ᠨ᠎ᠠ ᠠᠴᠠ ᠲᠠᠰᠤᠷᠠᠪᠠ ᠃ + ᠬᠤᠢᠨᠠᠬᠢ ᠵᠢ ᠳᠠᠰᠤᠯᠬᠤ OK - ᠪᠠᠰᠠ ᠪᠣᠯᠣᠨ᠎ᠠ ᠃ + ᠪᠠᠳᠤᠯᠠᠬᠤ File "%1" - ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ %1 + ᠹᠠᠢᠯ"%1" + + + Filename too long. + 文件名过长。 Please choose the following processing method: - ᠳᠣᠣᠷᠠᠬᠢ ᠮᠡᠲᠦ ᠰᠢᠢᠳᠪᠦᠷᠢᠯᠡᠬᠦ ᠠᠷᠭ᠎ᠠ ᠶᠢ ᠰᠣᠩᠭᠣᠭᠠᠷᠠᠢ᠄ + ᠰᠢᠢᠳᠪᠦᠷᠢᠯᠡᠬᠦ ᠠᠷᠭ᠎ᠠ ᠵᠢ ᠰᠣᠩᠭᠣᠭᠠᠷᠠᠢ: truncate interval - ᠣᠷᠣᠨ ᠵᠠᠢ ᠶᠢ ᠲᠠᠰᠤᠯᠤᠨ᠎ᠠ ᠃ + ᠳᠠᠰᠤᠯᠬᠤ ᠬᠡᠰᠡᠭ Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - ᠲᠠᠶᠢᠯᠪᠤᠷᠢᠯᠠᠯᠲᠠ ᠄ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠨᠡᠷᠡᠶᠢᠳᠦᠭᠰᠡᠨ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠶᠢ ᠬᠦᠨᠳᠦᠷᠡᠭᠦᠯᠵᠦ ᠂%1 %2 ᠶᠢᠨ ᠳᠣᠲᠣᠷ᠎ᠠ ᠂ ᠣᠴᠢᠬᠤ ᠶᠢ ᠪᠠᠲᠤᠯᠠᠨ᠎ᠠ ᠃ + ᠳᠤᠳᠤᠷᠬᠠᠢᠯᠠᠯᠳᠠ᠄ ᠳᠠᠰᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ ᠵᠢᠨ ᠬᠡᠳᠦᠷᠦᠭᠰᠡᠨ %1 %2 ᠬᠡᠰᠡᠭ ᠢ᠋ ᠣᠴᠢᠵᠤ ᠰᠣᠩᠭᠣᠬᠤ Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - ᠲᠠᠶᠢᠯᠪᠤᠷᠢᠯᠠᠯᠲᠠ ᠄ ᠬᠡᠷᠡᠭᠯᠡᠭᠴᠢ ᠨᠡᠷᠡᠶᠢᠳᠦᠭᠰᠡᠨ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠤᠨ ᠨᠡᠷ᠎ᠡ ᠶᠢ ᠬᠦᠨᠳᠦᠷᠡᠭᠦᠯᠵᠦ ᠂ 1% 2 ᠶᠢᠨ ᠳᠣᠲᠣᠷ᠎ᠠ ᠂ ᠣᠴᠢᠬᠤ ᠶᠢ ᠪᠠᠲᠤᠯᠠᠨ᠎ᠠ ᠃ + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ ". - ". + "᠃ Description: Save the file to "%1/扩展". - ᠲᠠᠶᠢᠯᠪᠤᠷᠢᠯᠠᠯᠲᠠ ᠄ ᠪᠢᠴᠢᠭ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠢ 《 1/ᠥᠷᠭᠡᠳᠬᠡᠬᠦ 》 ᠪᠣᠯᠭᠠᠨ ᠬᠠᠳᠠᠭᠠᠯᠠᠨ᠎ᠠ ᠃ + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 @@ -224,7 +236,7 @@ Sort Type - ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ + ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ @@ -240,7 +252,7 @@ Restore - ᠡᠬᠡᠬᠦᠯᠬᠦ + ᠰᠡᠷᠭᠦᠭᠡᠬᠦ @@ -262,12 +274,12 @@ Save as - ᠦᠭᠡᠷ᠎ᠡ ᠭᠠᠵᠠᠷ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ + ᠦᠬᠡᠷ᠎ᠡ ᠭᠠᠵᠠᠷ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ New Folder - ᠰᠢᠨ᠎ᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ + ᠰᠢᠨ᠎ᠡ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ ᠪᠠᠢᠭᠤᠯᠬᠤ @@ -289,7 +301,7 @@ Warning - ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠦᠯ + ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠬᠦ᠌ @@ -299,7 +311,7 @@ NewFolder - ᠰᠢᠨ᠎ᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ + ᠰᠢᠨ᠎ᠡ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ ᠪᠠᠢᠭᠤᠯᠬᠤ @@ -319,7 +331,7 @@ This operation is not supported. - ᠳᠤᠰ ᠠᠵᠢᠯᠯᠠᠬᠤᠢ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠦᠬᠡᠢ. + ᠳᠤᠰ ᠠᠵᠢᠯᠯᠠᠬᠤᠢ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠦᠬᠡᠢ᠃ @@ -327,21 +339,18 @@ File save failed! - ᠪᠢᠴᠢᠭ᠌ ᠮᠠᠲ᠋ᠧᠷᠢᠶᠠᠯ ᠢ ᠬᠠᠳᠠᠭᠠᠯᠠᠵᠤ ᠢᠯᠠᠭᠳᠠᠵᠠᠢ ! + ᠹᠠᠢᠯ ᠢ᠋ ᠬᠠᠳᠠᠭᠠᠯᠠᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ! - QApplication + QMessageBox - Executable '%1' requires Qt %2, found Qt %3. - ᠭᠦᠢᠴᠡᠳᠬᠡᠵᠦ ᠪᠣᠯᠬᠤ ᠹᠠᠢᠯ '%1' Qt% 2 ᠬᠡᠷᠡᠭᠰᠡᠵᠦ ᠂ Qt% 3 ᠢ᠋/ ᠵᠢ ᠡᠷᠢᠵᠦ ᠣᠯᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ . + Show Details... + 显示细节…… - - - QDialogButtonBox - OK - OK + Hide Details... + 隐藏细节…… @@ -354,7 +363,7 @@ Modified Date - ᠵᠠᠰᠠᠭᠰᠠᠨ ᠡᠳᠦᠷ ᠰᠠᠷ᠎ᠠ + ᠡᠳᠦᠷ ᠰᠠᠷ᠎ᠠ ᠵᠢ ᠵᠠᠰᠠᠬᠤ @@ -369,7 +378,7 @@ Original Path - ᠤᠭ ᠤ᠋ᠨ ᠵᠠᠮ ᠱᠤᠭᠤᠮ + ᠤᠭ ᠤ᠋ᠨ ᠵᠢᠮ @@ -383,8 +392,8 @@ - Use global sorting - ᠪᠦᠬᠦ ᠪᠠᠢᠳᠠᠯ ᠤ᠋ᠨ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ + Use current sorting for all folders + ᠪᠦᠬᠦ ᠭᠠᠷᠴᠠᠭ ᠣᠳᠣᠬᠢ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ᠎ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ @@ -394,7 +403,7 @@ Icon View - ᠰᠢᠪᠠᠭ᠎ᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ + ᠢᠺᠦᠨ ᠵᠢᠷᠤᠭ ᠤ᠋ᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ms.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ms.ts new file mode 100644 index 0000000..13da9f7 --- /dev/null +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ms.ts @@ -0,0 +1,409 @@ + + + + + UKUIFileDialog::KyFileDialogHelper + + + Open File + Buka Fail + + + + Save File + Simpan Fail + + + + All Files (*) + Semua Fail (*) + + + + UKUIFileDialog::KyFileDialogRename + + + bytes + Bait + + + + Bytes + Bait + + + + character + Aksara + + + + Character + Aksara + + + Saving "%1" + 正在保存 “%1” + + + + Saving failed, the reason is: %1 + Menyimpan gagal, alasannya adalah: %1 + + + Filename too long + 文件名过长 + + + + Description: Save long file names to " + Keterangan: Simpan nama fail panjang ke " + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 + + + + Truncation + Pemotongan + + + + Save to long file name directory + Simpan ke direktori nama fail panjang + + + + Rename + Namakan Semula + + + + modify the name + ubah suai nama + + + + + . + . + + + + Explanation: When renaming a file name, ensure it is within %1 %2 and + Penjelasan: Semua menamakan semula nama fail, pastikan dalam %1 %2 dan + + + + All applications + Semua Aplikasi + + + + The file name is too long. + Nama fail terlalu panjang. + + + + + + Cancel + Batal + + + Apply + 应用 + + + Save + 保存 + + + + Front truncation + Pemotongan Depan + + + + Post truncation + Pemotongan Belakang + + + + + + OK + OK + + + + File "%1" + Fail "%1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + Sila pilih kaedah pemprosesan berikut: + + + + truncate interval + selang pemotongan + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + Penjelasan: Potong bahagian nama fail yang melebihi %1 %2 dan pilih + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + ". + + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + + UKUIFileDialog::KyNativeFileDialog + + + Go Back + Kembali + + + + Go Forward + Teruskan + + + + Cd Up + Cd Atas + + + + Search + Cari + + + + View Type + Jenis Paparan + + + + Sort Type + Jenis Isihan + + + + + Maximize + Maksimumkan + + + + Close + Tutup + + + + Restore + Pulihkan + + + + Name + Nama + + + + + Open + Buka + + + + + Cancel + Batal + + + + Save as + Simpan sebagai + + + + New Folder + Folder Baru + + + + + Save + Simpan + + + + + + Directories + Direktori + + + + + + + + Warning + Amaran + + + + exist, are you sure replace? + sudah wujud, adakah anda pasti untuk gantikan? + + + + NewFolder + FolderBaru + + + + Undo + Batal + + + + Redo + Buat Semula + + + + warn + amaran + + + + This operation is not supported. + Operasi ini tidak disokong. + + + + + + + File save failed! + Simpan fail gagal! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… + + + + QObject + + + File Name + Nama Fail + + + + Modified Date + Tarikh Diubah + + + + File Type + Jenis Fail + + + + File Size + Saiz Fail + + + + Original Path + Laluan Asal + + + + Descending + Menurun + + + + Ascending + Menaik + + + + Use current sorting for all folders + Guna pengisihan semasa untuk semua folder + + + + List View + Paparan Senarai + + + + Icon View + Paparan Ikon + + + diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_th.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_th.ts new file mode 100644 index 0000000..1ada8bd --- /dev/null +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_th.ts @@ -0,0 +1,409 @@ + + + + + UKUIFileDialog::KyFileDialogHelper + + + Open File + เปิดไฟล์ + + + + Save File + บันทึกไฟล์ + + + + All Files (*) + ไฟล์ทั้งหมด + + + + UKUIFileDialog::KyFileDialogRename + + + bytes + ไบต์ + + + + Bytes + ไบต์ + + + + character + อักขระ + + + + Character + อักขระ + + + Saving "%1" + 正在保存 “%1” + + + + Saving failed, the reason is: %1 + การบันทึกล้มเหลว สาเหตุคือ: %1 + + + Filename too long + 文件名过长 + + + + Description: Save long file names to " + คำอธิบาย: บันทึกชื่อไฟล์ที่ยาวลงใน + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 + + + + Truncation + การตัดสั้น + + + + Save to long file name directory + บันทึกไปยังไดเร็กทอรีที่มีชื่อไฟล์ที่ยาว + + + + Rename + ตั้งชื่อใหม่ + + + + modify the name + แก้ไขชื่อ + + + + + . + + + + + Explanation: When renaming a file name, ensure it is within %1 %2 and + คำอธิบาย: เมื่อเปลี่ยนชื่อไฟล์ ให้แน่ใจว่าไฟล์นั้นอยู่ในขอบเขต %1 %2 และ + + + + All applications + แอปพลิเคชันทั้งหมด + + + + The file name is too long. + ชื่อไฟล์ยาวเกินไป + + + + + + Cancel + ยกเลิก + + + Apply + 应用 + + + Save + 保存 + + + + Front truncation + การตัดสั้นด้านหน้า + + + + Post truncation + การตัดสั้นด้านหลัง + + + + + + OK + โอเค + + + + File "%1" + ไฟล์ "%1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + กรุณาเลือกวิธีการประมวลผลด้านล่างนี้: + + + + truncate interval + ช่วงเวลาการตัดสั้น + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + คำอธิบาย: ตัดส่วนของชื่อไฟล์ที่เกิน %1 %2 และเลือก + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + ". + + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + + UKUIFileDialog::KyNativeFileDialog + + + Go Back + กลับมา + + + + Go Forward + ไปข้างหน้า + + + + Cd Up + cd ขึ้นไป + + + + Search + คันหา + + + + View Type + ประเภทวิว + + + + Sort Type + ประเภทการเรียงลำดับ + + + + + Maximize + ขยายใหญ่สุด + + + + Close + ปิด + + + + Restore + เรียกคืน + + + + Name + ชื่อ + + + + + Open + เปิด + + + + + Cancel + ยกเลิก + + + + Save as + บันทึกเป็น + + + + New Folder + โฟลเดอร์ใหม่ + + + + + Save + บันทึก + + + + + + Directories + ไดเร็กทอรี + + + + + + + + Warning + เดือน + + + + exist, are you sure replace? + มีอยู่แล้ว คุณแน่ใจที่จะทับแทนหรือไม่? + + + + NewFolder + โฟลเดอร์ใหม่ + + + + Undo + ยกเลิก + + + + Redo + ทําใหม่ + + + + warn + เตือน + + + + This operation is not supported. + การดำเนินการนี้ไม่ได้รับการสนับสนุน + + + + + + + File save failed! + การบันทึกไฟล์ล้มเหลว! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… + + + + QObject + + + File Name + ชื่อไฟล์ + + + + Modified Date + วันที่แก้ไข + + + + File Type + ประเภทไฟล์ + + + + File Size + ขนาดไฟล์ + + + + Original Path + เส้นทางเดิม + + + + Descending + จากมากไปน้อย + + + + Ascending + จากน้อยไปมาก + + + + Use current sorting for all folders + ใช้ลำดับเรียงปัจจุบันสำหรับโฟลเดอร์ทั้งหมด + + + + List View + วิวรายการ + + + + Icon View + วิวไอคอน + + + diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_tr.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_tr.ts index 9ea69cd..c94e2a5 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_tr.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_tr.ts @@ -317,7 +317,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ug.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ug.ts index a5b2a3f..5270764 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ug.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_ug.ts @@ -1,22 +1,22 @@ - + UKUIFileDialog::KyFileDialogHelper Open File - + ھۆججەتنى ئېچىش Save File - + ھۆججەتنى ساقلاش All Files (*) - + بارلىق ھۆججەتلەر (*) @@ -24,122 +24,186 @@ bytes - + بايت Bytes - + بايت character - + شەخىس Character - + شەخىس + + + Saving "%1" + 正在保存 “%1” Saving failed, the reason is: %1 - + ساقلاش مەغلۇپ بولدى، سەۋەبى: ٪1 - - Please choose the following processing method: - + Filename too long + 文件名过长 + + + + Description: Save long file names to " + چۈشەندۈرۈشى: ئۇزۇن ھۆججەت ناملىرىنى " غا ساقلاش + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 Truncation - + كىسىش Save to long file name directory - + ئۇزۇن ھۆججەت نامى مۇندەرىجىسىگە ساقلاش Rename - + قايتا ئىسىم فامىلە قىلىش modify the name - - - - - Explanation: Truncate the portion of the file name that exceeds %1 %2 and select - - - - - Description: Save long file names to " - - - - - ". - + نامىنى ئۆزگەرتىش . - + . Explanation: When renaming a file name, ensure it is within %1 %2 and - + چۈشەندۈرۈش: ھۆججەت نامىنى ئۆزگەرتكەندە، ھۆججەت نامىنىڭ ٪1 ٪2 دائىرىسىدە بولۇشىغا كاپالەتلىك قىلىڭ ۋە All applications - - - - - File "%1" - + بارلىق قوللىنىشچان پروگراممىلار The file name is too long. - + ھۆججەت نامى بەك ئۇزۇن ئىكەن. Cancel - + ئەمەلدىن قالدۇرۇش + + + Apply + 应用 + + + Save + 保存 Front truncation - + ئالدى قىسمى كېسىۋېتىلگەن. Post truncation - + كېسىۋەتكەندىن كېيىن. OK - + جەزملەشتۈرۈش + + + + File "%1" + ھۆججەت "٪1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + تۆۋەندىكى بىر تەرەپ قىلىش ئۇسۇلىنى تاللاڭ: truncate interval - + كەسمە ئارىلىق + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + چۈشەندۈرۈش: ٪1 ٪2 دىن ئېشىپ كەتكەن ھۆججەت نامىنى قىسقارتىپ تاللاڭ. + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + ". + + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 @@ -147,88 +211,88 @@ Go Back - + كەينىگە يېنىش Go Forward - + ئىلگىرىلەش Cd Up - + Cd دىن يۇقىرى Search - + ئىزدە View Type - + كۆرۈش تۈرى Sort Type - + ترتىپلەش تىپى Maximize - + چوڭايتىش Close - + تاقاش Restore - + ئەسلىگە قايتۇرۇش Name - + نامى Open - + ئېچىش Cancel - + ئەمەلدىن قالدۇرۇش Save as - + قىلىپ ساقلاش New Folder - + يېڭى ھۆججەت قىسقۇچ Save - + ساقلاش Directories - + مۇندەرىجە @@ -237,37 +301,37 @@ Warning - + ئاگاھلانددۇرۇش exist, are you sure replace? - + مەۋجۇت، ئالماشتۇرۇشنى جەزىملەشتۈرەلەمسىز؟ NewFolder - + يېڭى قاتلىغۇچ Undo - + ئەمەلدىن قالدۇرۇش Redo - + قايتا قىلىش warn - + ئاگاھلاندۇرۇش This operation is not supported. - + بۇ مەشغۇلاتنى قوللىمايدۇ. @@ -275,7 +339,18 @@ File save failed! - + ھۆججەت ساقلاش مەغلۇپ بولدى! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… @@ -283,211 +358,52 @@ File Name - + ھۆججەت نامى Modified Date - + ئۆزگەرتىلگەن ۋاقتى File Type - + ھۆججەت تۈرى File Size - + ھۆججەت چوڭلۇقى Original Path - + ئەسلى يول Descending - + چوڭدىن كىچىككە قارىتىپ تىزىش Ascending - + كىچىكتىن چوڭغا قارىتىپ تىزىش - Use global sorting - ئومومىيلىق بىلەن تىزىشنى ئىشلىتىش + Use current sorting for all folders + بارلىق ھۆججەت قىسقۇچقا قارىتا نۆۋەتتىكى رەتلەشنى ئىشلىتىڭ. List View - + تىزىملىك كۆرۈنۈشى Icon View - شەكىل كۆرۈنۈشى - - - Close - 关闭 - - - - UKUI::TabWidget::DefaultSlideAnimatorFactory - - - Default Slide - ئالدىن بىكىتىلگەن slide - - - - Let tab widget switch with a slide animation. - تاللانما كارتىدىكى كىچىك زاپچاسلارنى پرويېكسىيە كارتون فىلىمىگە ئالماشتۇرۇش - - - - UKUIFileDialog::KyFileDialogHelper - - - Open File - ھۆججەتنى ئېچىش - - - - Save File - ھۆججەتنى ساقلاش - - - - All Files (*) - بارلىق ھۆججەتلەر (*) - - - - UKUIFileDialog::KyNativeFileDialog - - - Go Back - قايت - - - - Go Forward - ئالدىغا ماڭ - - - - Cd Up - Cd نىڭ ئۈستىدە - - - - Search - ئىزدە - - - - View Type - كۆرۈنۈش تىپى - - - - Sort Type - رەتلەنگەن تىپ - - - - - Maximize - چوڭايتىش - - - - Close - تاقاش - - - - Restore - ئەسلىگە كەلتۈرۈش - - - - Name - ئىسىم-فامىلىسى - - - - - Open - ئېچىش - - - - - Cancel - ئەمەلدىن قالدۇرۇش - - - - Save as - تېجەش - - - - New Folder - يېڭى ھۆججەت قىسقۇچ - - - - - Save - ساقلاش - - - - - - Directories - مۇندەرىجىلەر - - - - Warning - ئاگاھلاندۇرۇش - - - - exist, are you sure replace? - مەۋجۇت، ئالماشتۇرۇشنى جەزىملەشتۈرەلەمسىز؟ - - - - NewFolder - يېڭى قاتلىغۇچ - - - - Undo - Undo - - - - Redo - قايتا-قايتا - - - - warn - ئاگاھلاندۇرۇش - - - - This operation is not supported. - بۇ مەشغۇلاتنى قوللىمايدۇ. + سىنبەلگىنى كۆرۈش diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_vi.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_vi.ts new file mode 100644 index 0000000..373f2a6 --- /dev/null +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_vi.ts @@ -0,0 +1,409 @@ + + + + + UKUIFileDialog::KyFileDialogHelper + + + Open File + Mở + + + + Save File + Lưu + + + + All Files (*) + Tất cả (*) + + + + UKUIFileDialog::KyFileDialogRename + + + bytes + Byte + + + + Bytes + Byte + + + + character + Ký tự + + + + Character + Ký tự + + + Saving "%1" + 正在保存 “%1” + + + + Saving failed, the reason is: %1 + Lưu thất bại, lý do: %1 + + + Filename too long + 文件名过长 + + + + Description: Save long file names to " + Lưu ý: Lưu tệp tin có tên dài vào " + + + Copying "%1" + 正在复制 "%1" + + + To "%1" + 到 "%1" + + + Copying failed, the reason is: %1 + 复制失败, 原因: %1 + + + Moving "%1" + 正在移动 "%1" + + + Moving failed, the reason is: %1 + 移动失败, 原因: %1 + + + File operation error: + 文件操作错误: + + + The reason is: %1 + 原因: %1 + + + + Truncation + Chặt cụt + + + + Save to long file name directory + Lưu vào thư mục có tên tệp dài + + + + Rename + Đổi tên Bluetooth + + + + modify the name + Sửa tên + + + + + . + . + + + + Explanation: When renaming a file name, ensure it is within %1 %2 and + Hướng dẫn:Khi người dùng đổi tên tệp, đảm bảo trong khoảng %1 đến %2, và + + + + All applications + Tất cả các ứng dụng + + + + The file name is too long. + Tên tệp quá dài. + + + + + + Cancel + Hủy + + + Apply + 应用 + + + Save + 保存 + + + + Front truncation + Cắt xén phía trước + + + + Post truncation + Cắt xén phía sau + + + + + + OK + Chắc chắc + + + + File "%1" + Tệp "%1" + + + Filename too long. + 文件名过长。 + + + + Please choose the following processing method: + Vui lòng chọn cách xử lý: + + + + truncate interval + Khoảng bị cắt xén + + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + Lưu ý:Cắt bỏ phần vượt quá %1 %2 của tên tệp, và đi chọn + + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 + + + Description: Save the file to " + 说明:将文件保存至“ + + + + ". + ". + + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + + UKUIFileDialog::KyNativeFileDialog + + + Go Back + Quay lại + + + + Go Forward + Tiến lên + + + + Cd Up + Đi lên + + + + Search + Tìm kiếm ứng dụng + + + + View Type + Loại chế độ xem + + + + Sort Type + Loại hình sắp xếp + + + + + Maximize + Phóng lớn + + + + Close + Thoát + + + + Restore + Mở + + + + Name + Tên card âm thanh + + + + + Open + Bật + + + + + Cancel + Hủy + + + + Save as + Lưu thành + + + + New Folder + Thư mục + + + + + Save + Lưu + + + + + + Directories + Thư mục + + + + + + + + Warning + Sao lưu và phục hồi + + + + exist, are you sure replace? + Đã tồn tại, có thay thế không? + + + + NewFolder + Tạo thư mục mới + + + + Undo + Hoàn tác + + + + Redo + Làm lại + + + + warn + Cảnh báo + + + + This operation is not supported. + Không hỗ trợ thao tác này. + + + + + + + File save failed! + Lưu tệp thất bại! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… + + + + QObject + + + File Name + Tên tập tin + + + + Modified Date + Ngày sửa đổi + + + + File Type + Loại tệp + + + + File Size + Kích thước tệp + + + + Original Path + Đường dẫn gốc + + + + Descending + Giảm dần + + + + Ascending + Tăng dần + + + + Use current sorting for all folders + Tất cả các thư mục sắp xếp theo thứ tự hiện tại + + + + List View + Dạng xem danh sách + + + + Icon View + Chế độ xem biểu tượng + + + diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_CN.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_CN.ts index 678cd56..275a14c 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_CN.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_CN.ts @@ -392,8 +392,8 @@ - Use global sorting - 使用全局排序 + Use current sorting for all folders + 所有目录使用当前排序 diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_HK.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_HK.ts index 4fddd62..be10268 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_HK.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_HK.ts @@ -388,8 +388,8 @@ - Use global sorting - 使用全域排序 + Use current sorting for all folders + 所有資料夾套用目前排序方式 diff --git a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_Hant.ts b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_Hant.ts index b7aa645..1f2bcc1 100644 --- a/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_Hant.ts +++ b/qt5-ukui-filedialog/translations/qt5-ukui-filedialog_zh_Hant.ts @@ -1,386 +1,409 @@ - + - MainWindow + UKUIFileDialog::KyFileDialogHelper - - - - - - - - - MainWindow - + + Open File + 打開檔 - - - test open - + + Save File + 保存檔案 - - - directory - + + All Files (*) + 所有檔案 (*) + + + UKUIFileDialog::KyFileDialogRename - - - selected uri - + + bytes + 位元組 - - - test show - + + Bytes + 位元組 - - - test exec - + + character + 字元 - - - test save - + + Character + 字元 - - - test static open - + Saving "%1" + 正在保存 “%1” - - - - - PushButton - + + Saving failed, the reason is: %1 + 儲存失敗,原因是: %1 - - - use auto highlight icon - + Filename too long + 文件名过长 - - - - - ... - + + Description: Save long file names to " + 描述:將長檔名保存到” - - - highlightOnly - + Copying "%1" + 正在复制 "%1" - - - bothDefaultAndHighlight - + To "%1" + 到 "%1" - - - RadioButton - + Copying failed, the reason is: %1 + 复制失败, 原因: %1 - - - style - + Moving "%1" + 正在移动 "%1" - - - icon - + Moving failed, the reason is: %1 + 移动失败, 原因: %1 - - - menu opacity - + File operation error: + 文件操作错误: - - - font - + The reason is: %1 + 原因: %1 - - - MessageBox - - Close - 關閉 + + Truncation + 截斷 - - - QApplication - - Executable '%1' requires Qt %2, found Qt %3. - 可執行檔「%1」 需要數量%2,找到數量%3。 + + Save to long file name directory + 保存到長檔名目錄 - - Incompatible Qt Library Error - 不相容的Qt庫錯誤 + + Rename + 重新命名 - - - QDialogButtonBox - - - OK - 確認 + + modify the name + 修改名稱 - - - QMessageBox - - - - Show Details... - 顯示細節...... + + + . + . - - - Hide Details... - 隱藏細節...... + + Explanation: When renaming a file name, ensure it is within %1 %2 and + 說明:重新命名檔名時,請確保它在 %1 %2 範圍內,並且 - - - QObject - - File Name - 檔名稱 + + All applications + 所有應用 - - Modified Date - 修改日期 + + The file name is too long. + 檔名太長。 - - File Type - 檔案類型 + + + + Cancel + 取消 - - File Size - 檔大小 + Apply + 应用 - - Original Path - 原始路徑 + Save + 保存 - - Descending - 降序 + + Front truncation + 前截斷 - - Ascending - 升序 + + Post truncation + 後截斷 - - Use global sorting - 使用全域排序 + + + + OK + 確認 - - List View - 清單檢視 + + File "%1" + 檔%1 - - Icon View - 圖示檢視 + Filename too long. + 文件名过长。 - - Close - 關閉 + + Please choose the following processing method: + 請選擇以下處理方法: - - - UKUI::TabWidget::DefaultSlideAnimatorFactory - - - Default Slide - 默認slide + + truncate interval + 截斷間隔 - - - Let tab widget switch with a slide animation. - 讓選項卡小部件切換為幻燈片動畫。 + + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 說明:截斷檔名中超過 %1 %2 的部分,然後選擇 - - - UKUIFileDialog::KyFileDialogHelper - - Open File - 打開 + Explanation: Truncate the portion of the file name that exceeds %1 %2 and select + 说明:截断文件名的超过 %1 %2的部分,去选择 - - Save File - 保存 + Description: Save the file to " + 说明:将文件保存至“ - - All Files (*) - 所有(*) + + ". + ". + + + Description: Save the file to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 + + + Description: By default, save to "%1/扩展". + 说明:将文件保存至“%1/扩展”。 UKUIFileDialog::KyNativeFileDialog - + Go Back - 後退 + 回去 - + Go Forward 前進 - + Cd Up - 向上 + CD 向上 - + Search 搜索 - + View Type 視圖類型 - + Sort Type 排序類型 - - + + Maximize 最大化 - + Close 關閉 - + Restore - 還原 + 恢復 - + Name - 檔名 + 名字 - - + + Open 打開 - - + + Cancel 取消 - + Save as 另存為 - + New Folder 新建資料夾 - - + + Save - 保存 + - - - + + + Directories 目錄 - + + + + + Warning 警告 - + exist, are you sure replace? - 已存在,是否替換? + 存在,你確定替換嗎? - + NewFolder 新建資料夾 - + Undo - 撤銷 + 恢復 - + Redo 重做 - + warn 警告 - + This operation is not supported. - 不支援此操作。 + 不支援此作。 + + + + + + + File save failed! + 檔案儲存失敗! + + + + QMessageBox + + Show Details... + 显示细节…… + + + Hide Details... + 隐藏细节…… + + + + QObject + + + File Name + 檔名 + + + + Modified Date + 修改日期 + + + + File Type + 檔案類型 + + + + File Size + 檔大小 + + + + Original Path + 原始路徑 + + + + Descending + + + + + Ascending + 上升 + + + + Use current sorting for all folders + 所有目錄使用當前排序 + + + + List View + 清單檢視 + + + + Icon View + 圖示檢視 diff --git a/qt5-ukui-filedialog/uikyfiledialog.cpp b/qt5-ukui-filedialog/uikyfiledialog.cpp index 22f2c82..1260a35 100644 --- a/qt5-ukui-filedialog/uikyfiledialog.cpp +++ b/qt5-ukui-filedialog/uikyfiledialog.cpp @@ -271,13 +271,14 @@ void Ui_KyFileDialog::initSortMenu(QDialog *mKyFileDialog) m_sortMenu->addSeparator(); - m_useGlobalSortAction = m_sortMenu->addAction(QObject::tr("Use global sorting")); + // m_useGlobalSortAction = m_sortMenu->addAction(QObject::tr("Use global sorting")); + m_useGlobalSortAction = m_sortMenu->addAction(QObject::tr("Use current sorting for all folders")); m_useGlobalSortAction->setCheckable(true); m_sortButton->setMenu(m_sortMenu); m_sortButton->setPopupMode(QToolButton::InstantPopup); m_sortButton->setAutoRaise(true); - m_sortButton->setFixedSize(QSize(57, 40)); + m_sortButton->setFixedSize(QSize(57, 36)); m_sortButton->setIconSize(QSize(16, 16)); } @@ -287,7 +288,7 @@ void Ui_KyFileDialog::initModeMenu(QDialog *mKyFileDialog) m_modeButton = new MenuToolButton(this); m_modeButton->setPopupMode(QToolButton::InstantPopup); m_modeButton->setAutoRaise(true); - m_modeButton->setFixedSize(QSize(57, 40)); + m_modeButton->setFixedSize(QSize(57, 36)); m_modeButton->setIconSize(QSize(16, 16)); m_modeMenu = new QMenu(m_modeButton); @@ -301,6 +302,7 @@ void Ui_KyFileDialog::initModeMenu(QDialog *mKyFileDialog) void Ui_KyFileDialog::initSiderBar(QDialog *mKyFileDialog) { m_siderWidget = new QWidget(this); + m_siderWidget->setAttribute(Qt::WA_TranslucentBackground); m_siderLayout = new QVBoxLayout(); m_siderLayout->setContentsMargins(0,0,0,0); @@ -325,7 +327,7 @@ void Ui_KyFileDialog::initHeaderBar(QDialog *mKyFileDialog) m_pathbar->setMinimumWidth(250); m_pathbar->setFocusPolicy(Qt::FocusPolicy(m_pathbar->focusPolicy() & ~Qt::TabFocus)); - m_searchBtn = new QToolButton(this); + // m_searchBtn = new QToolButton(this); m_maximizeAndRestore = new QToolButton(this); @@ -336,7 +338,7 @@ void Ui_KyFileDialog::initHeaderBar(QDialog *mKyFileDialog) m_hHeaderLayout->addWidget(m_forwardButton); m_hHeaderLayout->addWidget(m_toParentButton); m_hHeaderLayout->addWidget(m_pathbarWidget); - m_hHeaderLayout->addWidget(m_searchBtn); + // m_hHeaderLayout->addWidget(m_searchBtn); m_hHeaderLayout->addWidget(m_modeButton); m_hHeaderLayout->addWidget(m_sortButton); m_hHeaderLayout->addWidget(m_maximizeAndRestore); @@ -369,6 +371,7 @@ void Ui_KyFileDialog::initLineEditLayout(QDialog *mKyFileDialog) pDebug << "44444444444444444"; m_fileTypeCombo = new FileDialogComboBox(this); + m_fileTypeCombo->setProperty("needShowToolTip", true); QSizePolicy sizePolicy4(QSizePolicy::Expanding, QSizePolicy::Fixed); sizePolicy4.setHorizontalStretch(0); sizePolicy4.setVerticalStretch(0); @@ -429,6 +432,7 @@ void Ui_KyFileDialog::setupUi(QDialog *mKyFileDialog) m_gridLayout->setObjectName(QString::fromUtf8("gridLayout")); m_container = new Peony::DirectoryViewContainer(this); + m_container->setProperty("KFileDialog", QVariant::fromValue(mKyFileDialog)); m_frame = new QFrame(this); vboxLayout = new QVBoxLayout(this); diff --git a/qt5-ukui-filedialog/uikyfiledialog.h b/qt5-ukui-filedialog/uikyfiledialog.h index 86719b5..baf5ea3 100644 --- a/qt5-ukui-filedialog/uikyfiledialog.h +++ b/qt5-ukui-filedialog/uikyfiledialog.h @@ -67,7 +67,7 @@ class Ui_KyFileDialog: public QWidget QHBoxLayout *m_hBtnLayout = nullptr; FileDialogPathBar *m_pathbarWidget = nullptr; Peony::AdvancedLocationBar *m_pathbar = nullptr; - QToolButton *m_searchBtn = nullptr; + // QToolButton *m_searchBtn = nullptr; //QWidget *m_pathbar = nullptr; QToolButton *m_backButton = nullptr; QToolButton *m_forwardButton = nullptr; diff --git a/qt5-ukui-platformtheme/CMakeLists.txt b/qt5-ukui-platformtheme/CMakeLists.txt index f69ccda..f56f71e 100644 --- a/qt5-ukui-platformtheme/CMakeLists.txt +++ b/qt5-ukui-platformtheme/CMakeLists.txt @@ -97,7 +97,14 @@ endif() #message(${FREETYPE2_INCLUDE_DIRS}) include_directories(../libqt5-ukui-style/) +include_directories(../ukui-styles/) +file(GLOB_RECURSE ConfigSources + ../ukui-styles/readconfig.cpp + ) +file(GLOB_RECURSE ConfigHeaders + ../ukui-styles/readconfig.h + ) file(GLOB_RECURSE sources "*.h" "*.hpp" "*.cpp" "*.c" "*.ui") file(GLOB_RECURSE Json "*.json") @@ -106,6 +113,10 @@ message("jsonfiles path:${Json}") # To create a new ts file: lupdate -recursive . -target-language en_US -ts translations/en_US.ts -no-ui-lines file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") +# foreach(TS_FILE ${TS_FILES}) +# message(STATUS "主题找到翻译文件vi ms th:${TS_FILE}") +# endforeach() + source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sources} ${Json} ${TS_FILES}) # i18n @@ -128,7 +139,7 @@ MESSAGE("QM_FILES PATH: ${QM_FILES}") add_custom_target(themetranslations ALL DEPENDS ${QM_FILES}) -add_library(qt5-ukui-platformtheme MODULE ${sources} ${Json} ${TS_FILES}) +add_library(qt5-ukui-platformtheme MODULE ${sources} ${Json} ${TS_FILES} ${ConfigSources} ${ConfigHeaders}) get_filename_component(PARENT_PATH "${PARENT_PATH}" PATH) get_filename_component(PARENT_PATH "${PARENT_PATH}" PATH) @@ -164,7 +175,6 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE UKUIPLATFORMTHEME_DIR="${UKUI message("DUKUIPLATFORMTHEME_DIR path: ${UKUIPLATFORMTHEME_DIR}") if(UNIX) - MESSAGE("libqt5-ukui-platformtheme TARGET_PATH: ${TARGET_PATH}") install(TARGETS ${PROJECT_NAME} DESTINATION ${TARGET_PATH}/platformthemes/) diff --git a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp index 6a2aefa..dd08d01 100644 --- a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp +++ b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp @@ -25,6 +25,7 @@ #include "qt5-ukui-platform-theme.h" #include "settings/ukui-style-settings.h" #include "effects/highlight-effect.h" +#include "settings/black-list.h" #include #include @@ -61,7 +62,12 @@ static bool isDBusTrayAvailable() { static bool dbusTrayAvailableKnown = false; if (!dbusTrayAvailableKnown) { QDBusMenuConnection conn; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 19)) + + if (conn.isWatcherRegistered()) +#else if (conn.isStatusNotifierHostRegistered()) +#endif dbusTrayAvailable = true; dbusTrayAvailableKnown = true; } @@ -77,8 +83,10 @@ void Qt5UKUIPlatformTheme::slotChangeStyle(const QString& key) QIcon::setThemeName(icontheme); - QIcon icon = qApp->windowIcon(); - qApp->setWindowIcon(QIcon::fromTheme(icon.name())); + if(qApp){ + QIcon icon = qApp->windowIcon(); + qApp->setWindowIcon(QIcon::fromTheme(icon.name())); + } // update all widgets for repaint new themed icons. for (auto widget : QApplication::allWidgets()) { widget->update(); @@ -116,7 +124,7 @@ void Qt5UKUIPlatformTheme::slotChangeStyle(const QString& key) if (key == "systemFontSize" || key == "system-font-size") { //Skip QGuiApplication avoid it crash when we setfont auto *app = qobject_cast(qApp); - if(app == nullptr) + if(app == nullptr || qApp == nullptr) return; if (qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool()) @@ -142,7 +150,7 @@ Qt5UKUIPlatformTheme::Qt5UKUIPlatformTheme(const QStringList &args) //set font auto fontName = settings->get("systemFont").toString(); auto fontSize = settings->get("systemFontSize").toString().toDouble(); - if (qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool()) + if (qApp && qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool()) fontSize = 11; m_system_font.setFamily(fontName); m_system_font.setPointSizeF(fontSize); @@ -178,7 +186,7 @@ Qt5UKUIPlatformTheme::Qt5UKUIPlatformTheme(const QStringList &args) // if (QFile::exists(QString("%1/kf5/kirigami/org.kylin.style.so").arg(QT_PLUGIN_INSTALL_DIRS))) { // QQuickStyle::setStyle("org.kylin.style"); // } - if((qApp->inherits("QApplication") == true || qApp->inherits("QGuiApplication") == true) && qAppName() != "cura") { + if(qApp && (qApp->inherits("QApplication") == true || qApp->inherits("QGuiApplication") == true) && qAppName() != "cura") { QQuickStyle::setStyle("org.ukui.style"); } @@ -217,6 +225,10 @@ Qt5UKUIPlatformTheme::Qt5UKUIPlatformTheme(const QStringList &args) watcher->deleteLater(); }); + + m_dtConfig = new GlobalDTConfig(); + m_palette = new QPalette(m_dtConfig->appPalette()); + } Qt5UKUIPlatformTheme::~Qt5UKUIPlatformTheme() @@ -226,11 +238,22 @@ Qt5UKUIPlatformTheme::~Qt5UKUIPlatformTheme() delete m_loader; m_loader = nullptr; } + if(m_dtConfig){ + delete m_dtConfig; + m_dtConfig = nullptr; + } + if(m_palette){ + delete m_palette; + m_palette = nullptr; + } } const QPalette *Qt5UKUIPlatformTheme::palette(Palette type) const { //FIXME: + if (type == QPlatformTheme::SystemPalette && m_palette) { + return m_palette; + } return QPlatformTheme::palette(type); } @@ -298,14 +321,16 @@ QVariant Qt5UKUIPlatformTheme::themeHint(ThemeHint hint) const QStringList Qt5UKUIPlatformTheme::xdgIconThemePaths() const { QStringList paths; + // Add home directory first in search path const QFileInfo homeIconDir(QDir::homePath() + QLatin1String("/.icons")); if (homeIconDir.isDir()) paths.prepend(homeIconDir.absoluteFilePath()); paths.append(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, - QStringLiteral("icons"), - QStandardPaths::LocateDirectory)); + QStringLiteral("icons"), + QStandardPaths::LocateDirectory)); + return paths; } @@ -332,12 +357,15 @@ bool Qt5UKUIPlatformTheme::usePlatformNativeDialog(DialogType type) const { switch (type) { case QPlatformTheme::FileDialog: - return true; + if (ukuiFiledialogBlackList().contains(qAppName())) + return false; + else + return true; case QPlatformTheme::FontDialog: case QPlatformTheme::ColorDialog: return false; case QPlatformTheme::MessageDialog: - if(qApp->inherits("QApplication")) + if(qApp && qApp->inherits("QApplication")) return true; // if (qAppName() == "ukui-control-center") // return false; @@ -352,13 +380,13 @@ QPlatformDialogHelper *Qt5UKUIPlatformTheme::createPlatformDialogHelper(DialogTy { switch (type) { case QPlatformTheme::FileDialog: - if (qApp->inherits("QApplication") && (m_loader && m_loader->instance())) { - return qobject_cast(m_loader->instance())->create(); + if (!ukuiFiledialogBlackList().contains(qAppName())) { + if (qApp && qApp->inherits("QApplication") && (m_loader && m_loader->instance())) { + return qobject_cast(m_loader->instance())->create(); + } else if (qApp && qApp->inherits("QGuiApplication") && m_portalVersion >= 3) { + return new XdgDesktopPortalFileDialog; + } } - else if (qApp->inherits("QGuiApplication") && m_portalVersion >= 3) - return new XdgDesktopPortalFileDialog; - - //return new KyFileDialogHelper; case QPlatformTheme::FontDialog: case QPlatformTheme::ColorDialog: return QPlatformTheme::createPlatformDialogHelper(type); diff --git a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h index 8114540..b72236d 100644 --- a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h +++ b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h @@ -28,7 +28,8 @@ #include #include #include - +#include "../ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h" +#include "../ukui-styles/readconfig.h" #if !defined(QT_NO_DBUS) && defined(QT_DBUS_LIB) #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) && !defined(QT_NO_SYSTEMTRAYICON) @@ -50,6 +51,8 @@ class QPlatformSystemTrayIcon; class QPlatformMenuBar; #endif +using namespace UKUIConfigStyleSpace; +using namespace UKUIGlobalDTConfig; /*! * \brief The Qt5UKUIPlatformTheme class * \details @@ -98,6 +101,9 @@ private: QFont m_fixed_font; QPluginLoader *m_loader = nullptr; int m_portalVersion = 0; + GlobalDTConfig *m_dtConfig = nullptr; + + QPalette *m_palette = nullptr; }; #endif // QT5UKUIPLATFORMTHEME_H diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts index 90264f6..5f62a0d 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts @@ -6,7 +6,7 @@ Close - ཁ་རྒྱག་པ། + སྒོ་རྒྱག་པ་ @@ -14,12 +14,12 @@ Executable '%1' requires Qt %2, found Qt %3. - ལག་བསྟར་བྱེད་ཆོག་པའི་'%1'ལ་Qt %2,Qt%3རྙེད་པ་རེད། + ལག་བསྟར་བྱེད་ཆོག་པའི་ཡིག་ཆ་'%1'དགོས་ཆེད་གྲངས་འབོར%2,འཚོལ་ཟིན་པ%3 Incompatible Qt Library Error - ཕན་ཚུན་མཐུན་ཐབས་མེད་པའི་Qt དཔེ་མཛོད་ཁང་གི་ནོར་འཁྲུལ། + ཕན་ཚུན་མཐུན་ཐབས་མེད་པའི་Qt ནོར་འཁྲུལ། @@ -38,61 +38,61 @@ Show Details... - ཞིབ་ཕྲའི་གནས་ཚུལ་གསལ་བཤད་བྱ་དགོས། + ཞིབ་ཕྲ་ངོན་པ། Hide Details... - གནས་ཚུལ་ཞིབ་ཕྲ་སྦས་སྐུང་བྱེད་ + ཞིབ་ཕྲ་སྦས་སྐུང་བྱེད་པ། QObject File Name - ཡིག་ཆའི་མིང་། + 文件名称 Modified Date - བཟོ་བཅོས་བརྒྱབ་པའི་དུས་ཚོད། + 修改日期 File Type - ཡིག་ཆའི་རིགས་གྲས། + 文件类型 File Size - ཡིག་ཆའི་ཆེ་ཆུང་། + 文件大小 Original Path - ཐོག་མའི་འགྲོ་ལམ། + 原始路径 Descending - མར་འབབ་པ། + 降序 Ascending - རིམ་པ་ཇེ་མང་དུ་འགྲོ་བཞིན། + 升序 - Use global sorting - ཁྱོན་ཡོངས་ཀྱི་གོ་རིམ་བེད་སྤྱོད། + Use current sorting for all folders + ཡིག་ཆ་ཚང་མས་མིག་སྔའི་གོ་རིམ་བཀོལ་སྤྱོད་བྱས་ཡོད། List View - མཐོང་རིས་རེའུ་མིག + 列表视图 Icon View - མཚོན་རྟགས་ལྟ་ཚུལ། + 图标视图 Close - ཁ་རྒྱག་པ། + ཁ་རྒྱག @@ -100,122 +100,122 @@ Default Slide - ཁ་ཆད་བཞག་པའི་སྒྲོན་བརྙན + སྤྱིའི་Slide Let tab widget switch with a slide animation. - སྒྲོན་བརྙན་གྱི་འགུལ་རིས་ལ་བརྟེན་ནས་ཤོག་བྱང་ཆུང་ཆུང་བརྗེ་རེས་བྱེད་དུ་འཇུག་དགོས། + གདམ་གསེས་བྱང་བུའི་ལྷུ་ལག་ཆུང་ཆུང་དེ་དང་སྒྲོན་བརྙན་པར་ཤེལ་འགུལ་རིས་གཉིས་བརྗེ། UKUIFileDialog::KyFileDialogHelper Open File - ཁ་ཕྱེ་བའི་ཡིག་ཆ། + 打开 Save File - ཡིག་ཆ་ཉར་ཚགས་བྱེད་པ། + 保存 All Files (*) - ཡིག་ཆ་ཡོད་ཚད་(*) + 所有(*) UKUIFileDialog::KyNativeFileDialog Go Back - ཕྱིར་ལོག + 后退 Go Forward - མདུན་སྐྱོད། + 前进 Cd Up - གོང་ཕྱོགས། + 向上 Search - འཚོལ་ཞིབ། + 搜索 View Type - མཐོང་རིས་ཀྱི་རིགས། + 视图类型 Sort Type - གོ་རིམ་གྱི་རིགས། + 排序类型 Maximize - ཆེས་ཆེ་བསྒྱུར། + 最大化 Close - ཁ་རྒྱག་པ། + 关闭 Restore - སླར་གསོ་བྱེད་པ། + 还原 Name - ཡིག་ཆའི་མིང་། + 文件名 Open - སྒོ་ཕྱེ་བ། + 打开 Cancel - ཕྱིར་འཐེན། + 取消 Save as - ཉར་ཚགས་གཞན། + 另存为 New Folder - ཡིག་ཁུག་གསར་འཛུགས། + 新建文件夹 Save - གྲོན་ཆུང་བྱེད་དགོས། + 保存 Directories - དཀར་ཆག + 目录 Warning - ཐ་ཚིག་སྒྲོག་པ། + 警告 exist, are you sure replace? - གནས་ཡོད་པས། ཁྱོད་ཀྱིས་དངོས་གནས་ཚབ་བྱེད་ཐུབ་བམ། + 已存在,是否替换? NewFolder - དཀར་ཆག་གསར་བ། + 新建文件夹 Undo - ཁ་ཕྱིར་འཐེན་བྱ་དགོས། + 撤销 Redo - ཡང་བསྐྱར་ལས། + 重做 warn - ཉེན་བརྡ་བཏང་བ། + 警告 This operation is not supported. - བཀོལ་སྤྱོད་འདི་ལ་རྒྱབ་སྐྱོར་མི་བྱེད། + 不支持此操作。 diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts index 4a62991..a8bf9a4 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts @@ -184,7 +184,7 @@ - Use global sorting + Use current sorting for all folders Globale Sortierung verwenden diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts index 84b60c3..6a5862c 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts @@ -78,8 +78,8 @@ Ascending - Use global sorting - Use global sorting + Use current sorting for all folders + Use current sorting for all folders List View diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts index 33a8685..16ebe59 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts @@ -184,7 +184,7 @@ - Use global sorting + Use current sorting for all folders diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts index 627da2b..630ff59 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts @@ -78,7 +78,7 @@ Ascendant - Use global sorting + Use current sorting for all folders Utiliser le tri global diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts index fb6fa10..c5d91df 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts @@ -6,7 +6,7 @@ Close - تاقاۋ + جابۋ @@ -14,7 +14,7 @@ Executable '%1' requires Qt %2, found Qt %3. - اتقار ىستەۋگە بولاتٸن حۇجات 1، مۇقتاجدىق ارگومەنتتٸ 2، ٸزدەپ تاپقان ارگومەنتتٸ 3 + اتقار ىستەۋگە بولاتٸن حۇجات 1، سەزگٸرلٸگٸنە ارگومەنتتٸ 2، ٸزدەپ تاپقان ارگومەنتتٸ 3 @@ -28,7 +28,7 @@ OK - ماقۇل + تۇراقتاندىرۋ @@ -78,8 +78,8 @@ 升序 - Use global sorting - 使用全局排序 + Use current sorting for all folders + بارلٸق حۇجات قىسقىشقا قارتا كەزەكتەگى رەتتەۋدى ٸستەتڭٸز. List View @@ -92,7 +92,7 @@ Close - تاقاۋ + جابۋ @@ -100,12 +100,12 @@ Default Slide - الدىن بەكٸتٸلگەن slide + الدىن بەكىتىلگەن slide Let tab widget switch with a slide animation. - تالدانبا كارتونىن كشكەنە زاپشاستارىن پٸروبيكسيا كارتون فىلىمىگە سايكەستىرۋ + تالدانبا كارتونىن كشكەنە زاپشاستارىن پىروكسيا كارتون فىلىمىگە سايكەستىرۋ diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts index 78600c4..6c76f9e 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts @@ -6,7 +6,7 @@ Close - بەكىتىش + جابۇۇ @@ -14,7 +14,7 @@ Executable '%1' requires Qt %2, found Qt %3. - اتقارماق جاسووعو بولوتۇرعان ۅجۅت 1، كەرەكتۉۉ سان 2، ىزدەپ تاپقان سان 3 + اتقارماق جاسووعو بولوتۇرعان ۅجۅت 1، ەتىياجدۇۇ سان 2، ىزدەپ تاپقان سان 3 @@ -28,7 +28,7 @@ OK - ماقۇل + بەكىتۉۉ @@ -78,8 +78,8 @@ 升序 - Use global sorting - 使用全局排序 + Use current sorting for all folders + باردىق ۅجۅت قىسقىچقا قاراتا گەزەكتەكى ىرەتتۅۅنۉ ىشتەتىڭ. List View @@ -92,7 +92,7 @@ Close - بەكىتىش + جابۇۇ @@ -105,7 +105,7 @@ Let tab widget switch with a slide animation. - تاندالما كارتاداقى كىچىك شايمانداردى پرويەكسىيە كارتون فىلىمىگە الماشتىرۇۇ + تاندالما كارتاداقى كىچىك شايمانداردى پىرويېكسىيە كارتون فىلىمىگە الماشتىرۇۇ diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts index e63a9a7..a83d80b 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts @@ -1,6 +1,6 @@ - + MessageBox @@ -14,12 +14,12 @@ Executable '%1' requires Qt %2, found Qt %3. - ᠭᠦᠢᠴᠡᠳᠬᠡᠵᠦ ᠪᠣᠯᠬᠤ ᠹᠠᠢᠯ '%1' Qt% 2 ᠬᠡᠷᠡᠭᠰᠡᠵᠦ ᠂ Qt% 3 ᠢ᠋/ ᠵᠢ ᠡᠷᠢᠵᠦ ᠣᠯᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ . + ᠭᠦᠢᠴᠡᠳᠬᠡᠵᠦ ᠪᠣᠯᠬᠤ ᠹᠠᠢᠯ '%1' Qt% 2 ᠬᠡᠷᠡᠭᠰᠡᠵᠦ ᠂ Qt% 3 ᠢ᠋/ ᠵᠢ ᠡᠷᠢᠵᠦ ᠣᠯᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ᠃ Incompatible Qt Library Error - + ᠦᠯᠦ ᠵᠤᠬᠢᠴᠠᠬᠤ Qt ᠬᠦᠮᠦᠷᠭᠡ ᠪᠤᠷᠤᠭᠤᠳᠠᠪᠠ @@ -28,7 +28,7 @@ OK - OK + ᠪᠠᠳᠤᠯᠠᠬᠤ @@ -38,56 +38,56 @@ Show Details... - + ᠨᠠᠷᠢᠨ ᠪᠠᠢᠳᠠᠯ ᠢ᠋ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ··· Hide Details... - + ᠨᠠᠷᠢᠨ ᠪᠠᠢᠳᠠᠯ ᠢ᠋ ᠨᠢᠭᠤᠴᠠᠯᠠᠬᠤ··· QObject File Name - ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷᠡᠢᠳᠦᠯ + 文件名称 Modified Date - ᠵᠠᠰᠠᠭᠰᠠᠨ ᠡᠳᠦᠷ ᠰᠠᠷ᠎ᠠ + 修改日期 File Type - ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ + 文件类型 File Size - ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠶᠡᠬᠡ ᠪᠠᠭ᠎ᠠ + 文件大小 Original Path - ᠤᠭ ᠤ᠋ᠨ ᠵᠠᠮ ᠱᠤᠭᠤᠮ + 原始路径 Descending - ᠪᠠᠭᠠᠰᠬᠠᠬᠤ + 降序 Ascending - ᠶᠡᠬᠡᠰᠬᠡᠬᠦ + 升序 - Use global sorting - ᠪᠦᠬᠦ ᠪᠠᠢᠳᠠᠯ ᠤ᠋ᠨ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ + Use current sorting for all folders + ᠪᠦᠬᠦ ᠭᠠᠷᠴᠠᠭ ᠣᠳᠣᠬᠢ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ᠎ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ List View - ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ + 列表视图 Icon View - ᠰᠢᠪᠠᠭ᠎ᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ + 图标视图 @@ -100,122 +100,122 @@ Default Slide - Default Slide + ᠠᠶᠠᠳᠠᠯ Slide Let tab widget switch with a slide animation. - + ᠰᠤᠩᠭᠤᠭᠳᠠᠬᠤᠨ ᠤ᠋ ᠵᠢᠵᠢᠭ ᠲᠣᠨᠣᠭᠯᠠᠯ ᠢ᠋ ᠬᠤᠸᠠᠨᠳᠧᠩ ᠤ᠋ᠨ ᠺᠠᠷᠲ᠋ᠣᠨ ᠵᠢᠡᠷ ᠰᠣᠯᠢᠬᠤ UKUIFileDialog::KyFileDialogHelper Open File - ᠨᠡᠬᠡᠬᠡᠬᠦ + 打开 Save File - ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ + 保存 All Files (*) - ᠪᠦᠬᠦᠢᠯᠡ (*) + 所有(*) UKUIFileDialog::KyNativeFileDialog Go Back - ᠤᠬᠤᠷᠢᠬᠤ + 后退 Go Forward - ᠤᠷᠤᠭᠰᠢᠯᠠᠬᠤ + 前进 Cd Up - ᠳᠡᠭᠡᠭᠰᠢ + 向上 Search - ᠬᠠᠢᠯᠳᠠ + 搜索 View Type - ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ + 视图类型 Sort Type - ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ + 排序类型 Maximize - ᠬᠠᠮᠤᠭ ᠤ᠋ᠨ ᠶᠡᠬᠡᠴᠢᠯᠡᠯ + 最大化 Close - ᠬᠠᠭᠠᠬᠤ + 关闭 Restore - ᠡᠬᠡᠬᠦᠯᠬᠦ + 还原 Name - ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷ᠎ᠡ + 文件名 Open - ᠨᠡᠬᠡᠬᠡᠬᠦ + 打开 Cancel - ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ + 取消 Save as - ᠦᠭᠡᠷ᠎ᠡ ᠭᠠᠵᠠᠷ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ + 另存为 New Folder - ᠰᠢᠨ᠎ᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ + 新建文件夹 Save - ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ + 保存 Directories - ᠭᠠᠷᠴᠠᠭ + 目录 Warning - ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠦᠯ + 警告 exist, are you sure replace? - ᠪᠠᠢᠨ᠎ᠠ᠂ ᠰᠤᠯᠢᠬᠤ ᠤᠤ? + 已存在,是否替换? NewFolder - ᠰᠢᠨ᠎ᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ + 新建文件夹 Undo - ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ + 撤销 Redo - ᠳᠠᠬᠢᠵᠤ ᠬᠢᠬᠦ + 重做 warn - ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠬᠦ + 警告 This operation is not supported. - ᠳᠤᠰ ᠠᠵᠢᠯᠯᠠᠬᠤᠢ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠦᠬᠡᠢ. + 不支持此操作。 diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ms.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ms.ts new file mode 100644 index 0000000..d03293a --- /dev/null +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ms.ts @@ -0,0 +1,221 @@ + + + + + MessageBox + + + Close + Tutup + + + + QApplication + + + Executable '%1' requires Qt %2, found Qt %3. + Boleh laku '%1' memerlukan Qt %2, didapati Qt %3. + + + + Incompatible Qt Library Error + Ralat Perpustakaan Qt tidak serasi + + + + QDialogButtonBox + + + + OK + OK + + + + QMessageBox + + + + + Show Details... + Tunjukkan Butiran... + + + + + Hide Details... + Sembunyikan Butiran... + + + + QObject + + File Name + 文件名称 + + + Modified Date + 修改日期 + + + File Type + 文件类型 + + + File Size + 文件大小 + + + Original Path + 原始路径 + + + Descending + 降序 + + + Ascending + 升序 + + + Use current sorting for all folders + Guna pengisihan semasa untuk semua folder + + + List View + 列表视图 + + + Icon View + 图标视图 + + + + Close + Tutup + + + + UKUI::TabWidget::DefaultSlideAnimatorFactory + + + Default Slide + Slaid Lalai + + + + Let tab widget switch with a slide animation. + Tukar widget tab kepada animasi slaid. + + + + UKUIFileDialog::KyFileDialogHelper + + Open File + 打开 + + + Save File + 保存 + + + All Files (*) + 所有(*) + + + + UKUIFileDialog::KyNativeFileDialog + + Go Back + 后退 + + + Go Forward + 前进 + + + Cd Up + 向上 + + + Search + 搜索 + + + View Type + 视图类型 + + + Sort Type + 排序类型 + + + Maximize + 最大化 + + + Close + 关闭 + + + Restore + 还原 + + + Name + 文件名 + + + Open + 打开 + + + Cancel + 取消 + + + Save as + 另存为 + + + New Folder + 新建文件夹 + + + Save + 保存 + + + Directories + 目录 + + + Warning + 警告 + + + exist, are you sure replace? + 已存在,是否替换? + + + NewFolder + 新建文件夹 + + + Undo + 撤销 + + + Redo + 重做 + + + warn + 警告 + + + This operation is not supported. + 不支持此操作。 + + + diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_th.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_th.ts new file mode 100644 index 0000000..5c3101d --- /dev/null +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_th.ts @@ -0,0 +1,221 @@ + + + + + MessageBox + + + Close + ปิด + + + + QApplication + + + Executable '%1' requires Qt %2, found Qt %3. + โปรแกรมปฏิบัติการ '%1' ต้องใช้ Qt %2 แต่พบ Qt %3 + + + + Incompatible Qt Library Error + ข้อผิดพลาดไลบรารี Qt ที่เข้ากันไม่ได้ + + + + QDialogButtonBox + + + + OK + OK + + + + QMessageBox + + + + + Show Details... + แสดงรายละเอียด... + + + + + Hide Details... + ซ่อนรายละเอียด... + + + + QObject + + File Name + 文件名称 + + + Modified Date + 修改日期 + + + File Type + 文件类型 + + + File Size + 文件大小 + + + Original Path + 原始路径 + + + Descending + 降序 + + + Ascending + 升序 + + + Use current sorting for all folders + ใช้ลำดับเรียงปัจจุบันสำหรับโฟลเดอร์ทั้งหมด + + + List View + 列表视图 + + + Icon View + 图标视图 + + + + Close + ปิด + + + + UKUI::TabWidget::DefaultSlideAnimatorFactory + + + Default Slide + สไลด์เริ่มต้น + + + + Let tab widget switch with a slide animation. + ให้แท็บวิดเจ็ตสลับไปมาด้วยแอนิเมชั่นสไลด์ + + + + UKUIFileDialog::KyFileDialogHelper + + Open File + 打开 + + + Save File + 保存 + + + All Files (*) + 所有(*) + + + + UKUIFileDialog::KyNativeFileDialog + + Go Back + 后退 + + + Go Forward + 前进 + + + Cd Up + 向上 + + + Search + 搜索 + + + View Type + 视图类型 + + + Sort Type + 排序类型 + + + Maximize + 最大化 + + + Close + 关闭 + + + Restore + 还原 + + + Name + 文件名 + + + Open + 打开 + + + Cancel + 取消 + + + Save as + 另存为 + + + New Folder + 新建文件夹 + + + Save + 保存 + + + Directories + 目录 + + + Warning + 警告 + + + exist, are you sure replace? + 已存在,是否替换? + + + NewFolder + 新建文件夹 + + + Undo + 撤销 + + + Redo + 重做 + + + warn + 警告 + + + This operation is not supported. + 不支持此操作。 + + + diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts index 66652c0..820eafe 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts @@ -14,12 +14,12 @@ Executable '%1' requires Qt %2, found Qt %3. - ئىجرا قىلىشقا بولىدىغان ھۆججەت 1، ئىھتىياجلىق سان 2، ئىزدەپ تاپقان سان 3 + ئىجرا قىلىنىدىغان '٪1' ئۈچۈن Qt ٪2 تەلەپ قىلىنىدۇ، Qt ٪3 تېپىلدى. Incompatible Qt Library Error - سىغىشمىغانQT ئامبىرىدا خاتالىق كۆرۈلدى + ماس كەلمەيدىغان Qt ئامبىرىدا خاتالىق كۆرۈلدى @@ -28,7 +28,7 @@ OK - ماقۇل + جەزملەشتۈرۈش @@ -38,13 +38,13 @@ Show Details... - تەپسىلاتىنى كۆرسىتىش + تەپسىلاتىنى كۆرسىتىش... Hide Details... - تەپسىلاتىنى يوشۇرۇش + تەپسىلاتلارنى يوشۇرۇش... @@ -78,8 +78,8 @@ 升序 - Use global sorting - 使用全局排序 + Use current sorting for all folders + بارلىق ھۆججەت قىسقۇچقا قارىتا نۆۋەتتىكى رەتلەشنى ئىشلىتىڭ. List View @@ -92,7 +92,7 @@ Close - تاقاش + ياپ diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_vi.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_vi.ts new file mode 100644 index 0000000..6816e86 --- /dev/null +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_vi.ts @@ -0,0 +1,221 @@ + + + + + MessageBox + + + Close + Tắt + + + + QApplication + + + Executable '%1' requires Qt %2, found Qt %3. + File thực thi "%1" yêu cầu số lượng %2, tìm thấy số lượng %3. + + + + Incompatible Qt Library Error + Lỗi thư viện Qt không tương thích + + + + QDialogButtonBox + + + + OK + Xác định + + + + QMessageBox + + + + + Show Details... + Hiển thị chi tiết... + + + + + Hide Details... + Ẩn chi tiết... + + + + QObject + + File Name + 文件名称 + + + Modified Date + 修改日期 + + + File Type + 文件类型 + + + File Size + 文件大小 + + + Original Path + 原始路径 + + + Descending + 降序 + + + Ascending + 升序 + + + Use current sorting for all folders + Tất cả các thư mục sắp xếp theo thứ tự hiện tại + + + List View + 列表视图 + + + Icon View + 图标视图 + + + + Close + Tắt + + + + UKUI::TabWidget::DefaultSlideAnimatorFactory + + + Default Slide + Slide mặc định + + + + Let tab widget switch with a slide animation. + Chuyển đổi tab widget thành hoạt ảnh trình chiếu. + + + + UKUIFileDialog::KyFileDialogHelper + + Open File + 打开 + + + Save File + 保存 + + + All Files (*) + 所有(*) + + + + UKUIFileDialog::KyNativeFileDialog + + Go Back + 后退 + + + Go Forward + 前进 + + + Cd Up + 向上 + + + Search + 搜索 + + + View Type + 视图类型 + + + Sort Type + 排序类型 + + + Maximize + 最大化 + + + Close + 关闭 + + + Restore + 还原 + + + Name + 文件名 + + + Open + 打开 + + + Cancel + 取消 + + + Save as + 另存为 + + + New Folder + 新建文件夹 + + + Save + 保存 + + + Directories + 目录 + + + Warning + 警告 + + + exist, are you sure replace? + 已存在,是否替换? + + + NewFolder + 新建文件夹 + + + Undo + 撤销 + + + Redo + 重做 + + + warn + 警告 + + + This operation is not supported. + 不支持此操作。 + + + diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts index 74010b5..85e4145 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts @@ -78,8 +78,8 @@ 升序 - Use global sorting - 使用全局排序 + Use current sorting for all folders + 所有目录使用当前排序 List View diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts index 584a449..a7110e6 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts @@ -78,8 +78,8 @@ 升序 - Use global sorting - 使用全域排序 + Use current sorting for all folders + 所有資料夾套用目前排序方式 List View diff --git a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts index 39df820..3a45d04 100644 --- a/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts +++ b/qt5-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts @@ -1,127 +1,6 @@ - - - MainWindow - - - - - - - - - - MainWindow - - - - - - test open - - - - - - directory - - - - - - selected uri - - - - - - test show - - - - - - test exec - - - - - - test save - - - - - - test static open - - - - - - - - PushButton - - - - - - use auto highlight icon - - - - - - - - ... - - - - - - highlightOnly - - - - - - bothDefaultAndHighlight - - - - - - RadioButton - - - - - - style - - - - - - icon - - - - - - menu opacity - - - - - - font - - - + MessageBox @@ -135,12 +14,12 @@ Executable '%1' requires Qt %2, found Qt %3. - 可執行檔「%1」 需要數量%2,找到數量%3。 + 可執行檔案%1 需要 Qt %2,找到 Qt %3。 Incompatible Qt Library Error - 不相容的Qt庫錯誤 + 不相容的 Qt 庫錯誤 @@ -159,228 +38,184 @@ Show Details... - 顯示細節...... + 顯示詳細資訊... Hide Details... - 隱藏細節...... + 隱藏詳細資訊... QObject - File Name - 檔名稱 + 文件名称 - Modified Date - 修改日期 + 修改日期 - File Type - 檔案類型 + 文件类型 - File Size - 檔大小 + 文件大小 - Original Path - 原始路徑 + 原始路径 - Descending - 降序 + 降序 - Ascending - 升序 + 升序 - - Use global sorting - 使用全域排序 + Use current sorting for all folders + 所有目錄使用當前排序 - List View - 清單檢視 + 列表视图 - Icon View - 圖示檢視 + 图标视图 Close - 關閉 + 關閉 UKUI::TabWidget::DefaultSlideAnimatorFactory - Default Slide - 默認slide + 默認幻燈片 - Let tab widget switch with a slide animation. - 讓選項卡小部件切換為幻燈片動畫。 + 讓選項卡小部件使用滑動動畫進行切換。 UKUIFileDialog::KyFileDialogHelper - Open File - 打開 + 打开 - Save File - 保存 + 保存 - All Files (*) - 所有(*) + 所有(*) UKUIFileDialog::KyNativeFileDialog - Go Back - 後退 + 后退 - Go Forward - 前進 + 前进 - Cd Up - 向上 + 向上 - Search - 搜索 + 搜索 - View Type - 視圖類型 + 视图类型 - Sort Type - 排序類型 + 排序类型 - - Maximize - 最大化 + 最大化 - Close - 關閉 + 关闭 - Restore - 還原 + 还原 - Name - 檔名 + 文件名 - - Open - 打開 + 打开 - - Cancel - 取消 + 取消 - Save as - 另存為 + 另存为 - New Folder - 新建資料夾 + 新建文件夹 - - Save - 保存 + 保存 - - - Directories - 目錄 + 目录 - Warning - 警告 + 警告 - exist, are you sure replace? - 已存在,是否替換? + 已存在,是否替换? - NewFolder - 新建資料夾 + 新建文件夹 - Undo - 撤銷 + 撤销 - Redo - 重做 + 重做 - warn - 警告 + 警告 - This operation is not supported. - 不支援此操作。 + 不支持此操作。 diff --git a/qt5-ukui-platformtheme/widget/messagebox/message-box.cpp b/qt5-ukui-platformtheme/widget/messagebox/message-box.cpp index 636d12b..41a5d40 100644 --- a/qt5-ukui-platformtheme/widget/messagebox/message-box.cpp +++ b/qt5-ukui-platformtheme/widget/messagebox/message-box.cpp @@ -34,7 +34,6 @@ #include #include "private/qlabel_p.h" #include "private/qdialog_p.h" -#include "ukuiwindowhelper.h" #include #include @@ -98,18 +97,25 @@ MessageBox::MessageBox(QWidget *parent) : QDialog(*new MessageBoxPrivate, parent setContentsMargins(0, 0, 0, 0); setAttribute(Qt::WA_TranslucentBackground); - QDBusInterface *interFace = new QDBusInterface("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(d->tableModeChanged(bool))); - } + m_windowHelper = new UkuiWindowHelper(this); + m_windowHelper->removeTitleBar(); + m_windowHelper->setSkipTaskBar(true); + m_windowHelper->setSkipSwitcher(true); +// QDBusInterface *interFace = new QDBusInterface("com.kylin.statusmanager.interface", +// "/", +// "com.kylin.statusmanager.interface", +// QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(d->tableModeChanged(bool))); +// } } MessageBox::~MessageBox() { - + if (m_windowHelper) { + delete m_windowHelper; + m_windowHelper = nullptr; + } } void MessageBox::setCheckBox(QCheckBox *cb) @@ -148,8 +154,8 @@ void MessageBox::setIconPixmap(const QPixmap &pixmap) { Q_D(MessageBox); if (!pixmap.isNull()){ - d->mIconLabel->setAlignment(Qt::AlignVCenter); d->mIconLabel->setPixmap(pixmap); + d->mIconLabel->setAlignment(Qt::AlignVCenter); } d->mIcon = QMessageBox::NoIcon; } @@ -425,7 +431,8 @@ void MessageBox::setDetailedText(const QString &text) void MessageBox::setWindowTitle(const QString &title) { Q_D(MessageBox); - d->mTitleText->setText(title); +// d->mTitleText->setText(title); + d->mTitleText->setText(""); QDialog::setWindowTitle(title); } @@ -451,7 +458,7 @@ QPixmap MessageBox::standardIcon(QMessageBox::Icon icon) void MessageBox::setWindowIcon(const QIcon &icon) { Q_D(MessageBox); - d->mTitleIcon->setPixmap(icon.pixmap(QSize(22, 22))); +// d->mTitleIcon->setPixmap(icon.pixmap(QSize(22, 22))); QDialog::setWindowIcon(icon); } @@ -696,28 +703,28 @@ void MessageBoxPrivate::init(const QString &title, const QString &text) mIconLabel = new QLabel; mIconLabel->setObjectName(QLatin1String("ukui_msgbox_icon_label")); mIconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - mIconLabel->setContentsMargins(0, 0, 0, 0); +// mIconLabel->setContentsMargins(0, 0, 0, 0); mButtonBox = new QDialogButtonBox; mButtonBox->setObjectName(QLatin1String("ukui_msgbox_buttonbox")); mButtonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q)); QObject::connect(mButtonBox, SIGNAL(clicked(QAbstractButton*)), q, SLOT(_q_buttonClicked(QAbstractButton*))); - bool isTableMode = false; - QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - "get_current_tabletmode"); - QDBusMessage ret = QDBusConnection::sessionBus().call(message); - if (ret.type() != QDBusMessage::ReplyMessage) - { - //从返回参数获取返回值 - qDebug() << "complex type failed!"; - } - else - { - isTableMode = ret.arguments()[0].value(); - } +// bool isTableMode = false; +// QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", +// "/", +// "com.kylin.statusmanager.interface", +// "get_current_tabletmode"); +// QDBusMessage ret = QDBusConnection::sessionBus().call(message); +// if (ret.type() != QDBusMessage::ReplyMessage) +// { +// //从返回参数获取返回值 +// qDebug() << "complex type failed!"; +// } +// else +// { +// isTableMode = ret.arguments()[0].value(); +// } mCloseButtton = new QPushButton(); @@ -727,9 +734,9 @@ void MessageBoxPrivate::init(const QString &title, const QString &text) mCloseButtton->setIcon(QIcon::fromTheme("window-close-symbolic")); mCloseButtton->setIconSize(QSize(16, 16)); mCloseButtton->setToolTip(QObject::tr("Close")); - if(isTableMode)//styleName == "ukui-dark"){// - mCloseButtton->setFixedSize(48, 48); - else +// if(isTableMode)//styleName == "ukui-dark"){// +// mCloseButtton->setFixedSize(48, 48); +// else mCloseButtton->setFixedSize(32, 32); QObject::connect(mCloseButtton, &QPushButton::clicked, q, [=]() { @@ -737,10 +744,11 @@ void MessageBoxPrivate::init(const QString &title, const QString &text) }); mTitleText = new QLabel(); - mTitleText->setText(title); - mTitleIcon = new QLabel(); +// mTitleText->setText(title); + mTitleText->setText(""); +// mTitleIcon = new QLabel(); // mTitleIcon->setPixmap(QIcon(qApp->windowIcon()).pixmap(QSize(22, 22))); - mTitleIcon->setFixedSize(22, 22); + //mTitleIcon->setFixedSize(22, 22); q->setModal(true); mIcon = QMessageBox::NoIcon; @@ -755,6 +763,19 @@ void MessageBoxPrivate::setupLayout() bool hasIcon = mIconLabel->pixmap() && !mIconLabel->pixmap()->isNull(); + if(hasIcon){ + QFontMetrics fm(qApp->font()); + if(!mIconLabel->pixmap()->size().isNull() && mIconLabel->pixmap()->size().height()/mIconLabel->devicePixelRatioF() <= fm.height()) + { + mIconLabel->setFixedHeight(fm.height()); + } + QObject::connect(qApp, &QApplication::fontChanged, q, [&](const QFont &font){ + QFontMetrics fm(qApp->font()); + if(!mIconLabel->pixmap()->size().isNull() && mIconLabel->pixmap()->size().height()/mIconLabel->devicePixelRatioF() <= fm.height()) + mIconLabel->setFixedHeight(fm.height()); + }, Qt::UniqueConnection); + } + QGridLayout *gridLayout = new QGridLayout; gridLayout->setContentsMargins(0, 0, 0, 32); gridLayout->setHorizontalSpacing(8); @@ -778,7 +799,7 @@ void MessageBoxPrivate::setupLayout() buttonLayout->addWidget(mCheckbox, 0, Qt::AlignLeft | Qt::AlignVCenter); } if (mButtonBox->layout()) { - mButtonBox->layout()->setSpacing(10); + mButtonBox->layout()->setSpacing(8); } buttonLayout->addWidget(mButtonBox, 0, Qt::AlignRight | Qt::AlignVCenter); @@ -793,12 +814,7 @@ void MessageBoxPrivate::setupLayout() } QHBoxLayout *titleLayout = new QHBoxLayout; - titleLayout->setContentsMargins(6,0,0,0); -// //ukui should remove title icon -// if (mTitleIcon->pixmap() && !mTitleIcon->pixmap()->isNull()) { -// titleLayout->addWidget(mTitleIcon, Qt::AlignLeft | Qt::AlignVCenter); -// titleLayout->addSpacing(5); -// } + titleLayout->setContentsMargins(20,0,0,0); titleLayout->addWidget(mTitleText, Qt::AlignLeft | Qt::AlignVCenter); titleLayout->addWidget(mCloseButtton, Qt::AlignRight | Qt::AlignVCenter); @@ -862,6 +878,8 @@ void MessageBoxPrivate::updateSize() : q->layout()->totalMinimumSize().height()), minSize.height())); q->setFixedSize(size); + Q_EMIT q->sizeChanged(size); + QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest); } @@ -1323,6 +1341,16 @@ bool MessageBoxHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wind { if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text() && mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) { + qMessageBox = mb; + connect(mMessageBox, &MessageBox::sizeChanged, this, [&](QSize size){ + if(qMessageBox){ + qMessageBox->setFixedSize(size); + if(mMessageBox && ((qMessageBox->x() != 0 && qMessageBox->x() != mMessageBox->x()) || (qMessageBox->y() != 0 && qMessageBox->y() != mMessageBox->y()))) + mMessageBox->setGeometry(qMessageBox->x(), qMessageBox->y(), mMessageBox->width(), mMessageBox->height()); + } + }, Qt::UniqueConnection); + if(mb->x() != 0 || mb->y() != 0) + mMessageBox->setGeometry(mb->x(), mb->y(), mMessageBox->width(), mMessageBox->height()); if(!mb->windowIcon().isNull()){ mMessageBox->setWindowIcon(mb->windowIcon()); break; @@ -1398,9 +1426,27 @@ bool MessageBoxHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wind if(QMessageBox *mb = qobject_cast(w)) { if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text() && mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) { + qMessageBox = mb; + connect(mMessageBox, &MessageBox::sizeChanged, this, [&](QSize size){ + if(qMessageBox){ + qMessageBox->setFixedSize(size); + if(mMessageBox && ((qMessageBox->x() != 0 && qMessageBox->x() != mMessageBox->x()) || (qMessageBox->y() != 0 && qMessageBox->y() != mMessageBox->y()))) + mMessageBox->setGeometry(qMessageBox->x(), qMessageBox->y(), mMessageBox->width(), mMessageBox->height()); + } + }, Qt::UniqueConnection); if(mb->escapeButton() && mMessageBox->escapeButton() != mb->escapeButton()) mMessageBox->setEscapeButton(mb->escapeButton()); + if (QCheckBox *cb = mb->findChild()) { + if (mb->layout() && (mb->layout()->indexOf(cb) != -1)) { + mMessageBox->setCheckBox(cb); + } + } + + if(mb->x() != 0 || mb->y() != 0) + mMessageBox->setGeometry(mb->x(), mb->y(), mMessageBox->width(), mMessageBox->height()); + + if(mb->defaultButton() == nullptr) break; QString btnText = mb->defaultButton()->text(); @@ -1482,9 +1528,9 @@ bool MessageBoxHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality wind // hints.decorations = MWM_DECOR_BORDER; // XAtomHelper::getInstance()->setWindowMotifHint(mMessageBox->winId(), hints); // } - UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mMessageBox); - windowHelper->removeTitleBar(); - + // UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mMessageBox); + // windowHelper->removeTitleBar(); + // windowHelper->setSkipTaskBar(true); foreach (QAbstractButton *ab, mMessageBox->buttons()) { if (QPushButton *pb = qobject_cast(ab)) { diff --git a/qt5-ukui-platformtheme/widget/messagebox/message-box.h b/qt5-ukui-platformtheme/widget/messagebox/message-box.h index 0c9810c..1df6473 100644 --- a/qt5-ukui-platformtheme/widget/messagebox/message-box.h +++ b/qt5-ukui-platformtheme/widget/messagebox/message-box.h @@ -34,6 +34,7 @@ #include #include "private/qdialog_p.h" #include +#include "ukuiwindowhelper.h" class QLabel; class QAbstractButton; @@ -135,6 +136,7 @@ public slots: Q_SIGNALS: void buttonClicked(QAbstractButton* button); + void sizeChanged(QSize size); private: Q_DISABLE_COPY(MessageBox) @@ -142,6 +144,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton*)) Q_PRIVATE_SLOT(d_func(), void _q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)) + UkuiWindowHelper *m_windowHelper; }; class MessageBoxHelper : public QPlatformMessageDialogHelper @@ -163,6 +166,7 @@ private: private: MessageBox* mMessageBox = nullptr; + QMessageBox* qMessageBox = nullptr; }; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt old mode 100644 new mode 100755 index c659fa4..01223de --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,9 +1,14 @@ project(test) -add_subdirectory(custom-shadow) -add_subdirectory(filedialog) -add_subdirectory(highlighted-icon-button) -add_subdirectory(messagebox) -add_subdirectory(region-blur) -add_subdirectory(system-settings) -add_subdirectory(tabwidget) -add_subdirectory(mps-style-application) +# add_subdirectory(custom-shadow) +# add_subdirectory(filedialog) +# add_subdirectory(highlighted-icon-button) +# add_subdirectory(messagebox) +# add_subdirectory(region-blur) +# add_subdirectory(system-settings) +# add_subdirectory(tabwidget) +# add_subdirectory(mps-style-application) +# add_subdirectory(auto-test) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") +enable_testing() diff --git a/test/auto-test/CMakeLists.txt b/test/auto-test/CMakeLists.txt new file mode 100755 index 0000000..29e76ea --- /dev/null +++ b/test/auto-test/CMakeLists.txt @@ -0,0 +1,216 @@ +set(CMAKE_AUTOMOC on) +set(CMAKE_AUTOMOC on) +set(CMAKE_AUTOMOC on) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(QT_MIN_VERSION "5.12.0") +set(KF5_MIN_VERSION "5.66.0") + +#set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_CURRENT_SOURCE_DIR}/cmake/kde-modules ${CMAKE_MODULE_PATH}) + +# 查找Qt组件 +find_package(QT NAMES Qt6 Qt5 COMPONENTS Gui Test DBus Qml Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Test DBus Qml Widgets REQUIRED) + +# 查找PkgConfig工具 +find_package(PkgConfig REQUIRED) + +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS + DBus + Widgets + X11Extras +) + +find_package(gsettings-qt) +find_package(X11) + +include_directories(${Qt5Widgets_PRIVATE_INCLUDE_DIRS}) +include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + +find_package(KF5WindowSystem ${KF5_MIN_VERSION} CONFIG REQUIRED COMPONENTS) + +find_package(KF5Wayland CONFIG REQUIRED COMPONENTS) +pkg_check_modules(Qsettings REQUIRED gsettings-qt) +pkg_check_modules(KYSDKCONF2 REQUIRED kysdk-conf2) +pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0 ) +pkg_check_modules(PEONY REQUIRED peony) +find_package(Qt5LinguistTools) + +find_package(KF5WindowSystem ${KF5_MIN_VERSION} CONFIG REQUIRED COMPONENTS) +find_package(KF5Wayland CONFIG REQUIRED COMPONENTS) + +find_package(X11) + +find_package(PkgConfig) +pkg_check_modules(QGSETTINGS REQUIRED gsettings-qt) +pkg_check_modules(PEONY REQUIRED peony) +pkg_check_modules(REQUIRED kysdk-waylandhelper) +pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0 ) +pkg_check_modules(KYSDKWAYLANDHELPER REQUIRED kysdk-waylandhelper) +pkg_check_modules(KYSDKCONF2 REQUIRED kysdk-conf2) + + +message(${imported_location}) +set(LIB_PATH ${imported_location}) +get_filename_component(PARENT_PATH "${LIB_PATH}" PATH) +get_filename_component(PARENT_PATH "${PARENT_PATH}" PATH) +message("qt5-ukui-filedialog PARENT_PATH: ${PARENT_PATH}") +set(TARGET_PATH ${PARENT_PATH}) + +include_directories("/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes") +include_directories(${QGSETTINGS_INCLUDE_DIRS}) +include_directories(${GLIB2_INCLUDE_DIRS}) + +if (PEONY_FOUND) + include_directories(${PEONY_INCLUDE_DIRS}) + link_directories(${PEONY_LIBRARY_DIRS}) +endif() +if (KYSDKWAYLANDHELPER_FOUND) + include_directories(${KYSDKWAYLANDHELPER_INCLUDE_DIRS}) + link_directories(${KYSDKWAYLANDHELPER_LIBRARY_DIRS}) +endif() +if (QGSETTINGS_FOUND) + include_directories(${QGSETTINGS_INCLUDE_DIRS}) + link_directories(${QGSETTINGS_LIBRARY_DIRS}) +endif() + +if (KYSDKCONF2_FOUND) + include_directories(${KYSDKCONF2_INCLUDE_DIRS}) + link_directories(${KYSDKCONF2_LIBRARY_DIRS}) +endif() + +include_directories(${Qsettings_INCLUDE_DIRS}) +# 设置库文件名变量 +include_directories(../../libqt5-ukui-style) +include_directories(../../qt5-ukui-filedialog) +include_directories(../../ukui-styles) + +# 将库文件路径添加到库搜索路径中 +link_directories(${LIBRARY_DIR}) + +file(GLOB_RECURSE test_settings_sources + test-settings.cpp + ../../libqt5-ukui-style/effects/highlight-effect.h + ../../libqt5-ukui-style/effects/highlight-effect.cpp + ../../libqt5-ukui-style/settings/application-style-settings.h + ../../libqt5-ukui-style/settings/application-style-settings.cpp + ../../libqt5-ukui-style/settings/ukui-style-conf-settings.h + ../../libqt5-ukui-style/settings/ukui-style-conf-settings.cpp + ../../libqt5-ukui-style/settings/ukui-style-settings.h + ../../libqt5-ukui-style/settings/ukui-style-settings.cpp + ../../libqt5-ukui-style/settings/black-list.h + + ../../libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-animator.h + ../../libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-animator.cpp + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-iface.h + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-plugin-iface.h + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-factory.h + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.h + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.cpp + ../../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-factory.cpp + ../../libqt5-ukui-style/gestures/ukui-two-finger-slide-gesture.h + ../../libqt5-ukui-style/gestures/ukui-two-finger-zoom-gesture.h + ../../libqt5-ukui-style/gestures/ukui-two-finger-slide-gesture.cpp + ../../libqt5-ukui-style/gestures/ukui-two-finger-zoom-gesture.cpp + ../../ukui-styles/qt5-config-style-ukui/ukui-config-style-parameter.cpp + ../../ukui-styles/qt5-config-style-ukui/ukui-config-style-parameter.h + ../../ukui-styles/**/*.cpp + ../../ukui-styles/blur-helper.h + ../../ukui-styles/blur-helper.cpp + ../../ukui-styles/gesture-helper.h + ../../ukui-styles/gesture-helper.cpp + ../../ukui-styles/window-manager.h + ../../ukui-styles/window-manager.cpp +# ../../ukui-styles/ukui-style-plugin.h +# ../../ukui-styles/ukui-style-plugin.cpp + ../../ukui-styles/readconfig.h + ../../ukui-styles/readconfig.cpp + ../../ukui-styles/themeinformation.h + + ../../qt5-ukui-filedialog/pathbar.h + ../../qt5-ukui-filedialog/sidebar.h + ../../qt5-ukui-filedialog/debug.h + ../../qt5-ukui-filedialog/kyfiledialog.h + ../../qt5-ukui-filedialog/uikyfiledialog.h + ../../qt5-ukui-filedialog/filedialoginterface.h + ../../qt5-ukui-filedialog/filedialogplugin_global.h + ../../qt5-ukui-filedialog/filedialogplugin.h + ../../qt5-ukui-filedialog/kyfiledialog.h + ../../qt5-ukui-filedialog/kyfiledialogprivate.h + ../../qt5-ukui-filedialog/menutoolbutoon.h + ../../qt5-ukui-filedialog/uikyfiledialog.h + + ../../qt5-ukui-filedialog/filedialogplugin.cpp + ../../qt5-ukui-filedialog/kyfiledialog.cpp + ../../qt5-ukui-filedialog/kyfiledialogprivate.cpp + ../../qt5-ukui-filedialog/menutoolbutoon.cpp + ../../qt5-ukui-filedialog/pathbar.cpp + ../../qt5-ukui-filedialog/sidebar.cpp + ../../qt5-ukui-filedialog/uikyfiledialog.cpp +) + +add_executable(test-settings ${test-settings_SRCS} ${test_settings_sources} ) + +set(PLUGIN_INSTALL_FILES /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/peony-extensions/libpeony-computer-view-plugin.so) +target_compile_definitions(test-settings PRIVATE PLUGIN_INSTALL_FILES="${PLUGIN_INSTALL_FILES}") + +file(GLOB_RECURSE test_settings_headers ../../ukui-styles/**/*.h) + +set(test-settings_SRCS ${test_settings_headers}) + +target_link_libraries(test-settings PRIVATE Qt${QT_VERSION_MAJOR}::Test + Qt5::Widgets + Qt5::DBus + Qt5::Gui + Qt5::X11Extras + KF5::WaylandClient + KF5::WindowSystem + ${QGSETTINGS_LIBRARIES} + ${KYSDKWAYLANDHELPER_LIBRARIES} + xcb + glib-2.0 + ${PEONY_LIBRARIES} + ${XCB_LIBS} + gsettings-qt + qt5-ukui-style + ${KYSDKCONF2_LIBRARIES}) + +set(test_libs + Qt5::Widgets + glib-2.0 + peony + ) + +SET(_code " + #include + #include + + int main() + { + Peony::SearchVFSUriParser::addSearchKey(\"\", true); + return 0; + }") +SET(_file ${CMAKE_CURRENT_BINARY_DIR}/DetermineHavePeonyInterface.cpp) +FILE(WRITE "${_file}" "${_code}") +TRY_COMPILE(HAVE_PEONY_INTERFACE + "${CMAKE_CURRENT_BINARY_DIR}" + "${_file}" + LINK_LIBRARIES ${test_libs} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${GLIB2_INCLUDE_DIRS} ${PEONY_INCLUDE_DIRS}" + OUTPUT_VARIABLE OUTPUT) +MESSAGE("Build output: ${OUTPUT} HAVE_PEONY_INTERFACE: ${HAVE_PEONY_INTERFACE}") + +if(HAVE_PEONY_INTERFACE) + add_definitions(-DHAVE_PEONY_INTERFACE=1) +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") + +# 添加测试用例 +add_test(NAME test-settings COMMAND test-settings) +add_definitions(-DQT5UKUIPLATFORMTHEME_LIBRARY) +add_definitions(-DQT_DEPRECATED_WARNINGS) +add_definitions(-DQT_MESSAGELOGCONTEXT) diff --git a/test/auto-test/test-settings.cpp b/test/auto-test/test-settings.cpp new file mode 100755 index 0000000..08ce6e2 --- /dev/null +++ b/test/auto-test/test-settings.cpp @@ -0,0 +1,3365 @@ +/* + * * Copyright (C) 2024, 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: like + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../libqt5-ukui-style/effects/highlight-effect.h" +#include "../libqt5-ukui-style/settings/application-style-settings.h" +#include "../libqt5-ukui-style/settings/ukui-style-conf-settings.h" +#include "../libqt5-ukui-style/settings/ukui-style-settings.h" +#include "../libqt5-ukui-style/settings/black-list.h" + +#include "../libqt5-ukui-style/animations/scrollbar/ukui-scrollbar-default-interaction-animator.h" +#include "../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-iface.h" +#include "../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-animator-plugin-iface.h" +#include "../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator-factory.h" +#include "../libqt5-ukui-style/animations/tabwidget/ukui-tabwidget-default-slide-animator.h" +#include "../libqt5-ukui-style/gestures/ukui-two-finger-slide-gesture.h" +#include "../libqt5-ukui-style/gestures/ukui-two-finger-zoom-gesture.h" +#include "../ukui-styles/readconfig.h" +#include "../ukui-styles/qt5-config-style-ukui/ukui-config-style.h" +#include "../ukui-styles/blur-helper.h" +#include "../ukui-styles/gesture-helper.h" +#include "../ukui-styles/window-manager.h" +#include "../ukui-styles/ukui-style-plugin.h" +#include "../ukui-styles/qt5-config-style-ukui/config-shadow-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/config-style-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-box-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-box-animator.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-button-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-button-animator.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-checkbox-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-checkbox-animator.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-scrollbar-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-slider-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-tab-widget-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-tree-animation-helper.h" +#include "../ukui-styles/qt5-config-style-ukui/animations/config-tree-animator.h" +#include "../ukui-styles/themeinformation.h" + + +#include "../qt5-ukui-filedialog/debug.h" +#include "../qt5-ukui-filedialog/filedialogplugin.h" +#include "../qt5-ukui-filedialog/kyfiledialogprivate.h" +#include "../qt5-ukui-filedialog/menutoolbutoon.h" +#include "../qt5-ukui-filedialog/pathbar.h" +#include "../qt5-ukui-filedialog/sidebar.h" +#include "../qt5-ukui-filedialog/uikyfiledialog.h" +#include "../qt5-ukui-filedialog/kyfiledialog.h" + +// 定义函数指针类型,与库中函数的签名匹配 +typedef void (*FunctionInLibType)(void); + +// 测试用例类,继承自QObject +class LibFunctionTest : public QObject +{ + Q_OBJECT +public: + +private Q_SLOTS: + + // 测试调用库中函数的功能 + void testFunctionInLib() + { + QWidget *w = new QWidget ; + + HighLightEffect::setSkipEffect(w, true); + w->show(); + + const QPixmap pixmap(QSize(100, 100)); + // 创建pixmap的一个可修改副本,用于后续绘制操作 + QPixmap modifiablePixmap = pixmap; + // 使用QPainter在可修改的副本上进行绘制 + QPainter painter(&modifiablePixmap); + painter.setBrush(Qt::red); + painter.drawRect(10, 10, 80, 80); + painter.end(); + + bool isPixmapPureColor = HighLightEffect::isPixmapPureColor(pixmap); + bool isSymbolicColor = HighLightEffect::isSymbolicColor(pixmap); + + QMenu *menu = new QMenu(); + bool setMenuIconHighlightEffect = HighLightEffect::setMenuIconHighlightEffect(menu, HighLightEffect::skipHighlight, HighLightEffect::HighlightOnly); + +// QListView *view = new QListView(); +// bool setViewItemIconHighlightEffect = HighLightEffect::setViewItemIconHighlightEffect(view, HighLightEffect::skipHighlight, HighLightEffect::HighlightOnly); + + HighLightEffect::HighLightMode mode = HighLightEffect::isWidgetIconUseHighlightEffect(w); + + const QColor &color = QColor(255, 0, 0); + HighLightEffect::setSymoblicColor(color); + HighLightEffect::setWidgetIconFillSymbolicColor(w, true); + + const QColor getCurrentSymbolicColor = HighLightEffect::getCurrentSymbolicColor(); + + // 通过静态方法获取实例指针 + ApplicationStyleSettings *settingsPtr = ApplicationStyleSettings::getInstance(); + + // 测试setColorStretagy方法 + ApplicationStyleSettings::ColorStretagy colorStretagy = ApplicationStyleSettings::Bright; + settingsPtr->setColorStretagy(colorStretagy); + + + // 测试setStyleStretagy方法 + ApplicationStyleSettings::StyleStretagy styleStretagy = ApplicationStyleSettings::Default; + settingsPtr->setStyleStretagy(styleStretagy); + + + // 测试setCustomStyle方法 + QString customStyle = "MyCustomStyle"; + settingsPtr->setCustomStyle(customStyle); + + + // 测试setColor方法 + QPalette::ColorRole role = QPalette::Window; + QColor setcolor(Qt::red); + QPalette::ColorGroup group = QPalette::Active; + settingsPtr->setColor(role, setcolor, group); + + // 获取设置后的颜色并验证 + QColor retrievedColor = settingsPtr->getColor(role, group); + + // 例如,连接colorStretageChanged信号到一个槽函数(这里使用lambda表达式模拟槽函数) + bool colorStretageChangedReceived = false; + + // 更改颜色策略,触发信号发射 + ApplicationStyleSettings::ColorStretagy newColorStretagy = ApplicationStyleSettings::System; + settingsPtr->setColorStretagy(newColorStretagy); + + QByteArray schemaId("test_schema"); + ukuiStyleConfSettings* confinstance = new ukuiStyleConfSettings(schemaId); + delete confinstance; + + + UKUIStyleSettings *ukuisettingsPtr = UKUIStyleSettings::globalInstance(); +// delete ukuisettingsPtr; + } + + void testAllHighLightEffectMethods() + { + // 测试 setSkipEffect 方法 + qDebug() << "Testing setSkipEffect..."; + QWidget widget; + HighLightEffect::setSkipEffect(&widget, true); + qDebug() << "skipHighlightIconEffect property after set to true:" << widget.property("skipHighlightIconEffect").toBool(); + HighLightEffect::setSkipEffect(&widget, false); + qDebug() << "skipHighlightIconEffect property after set to false:" << widget.property("skipHighlightIconEffect").toBool(); + + + // 测试 isPixmapPureColor 方法 + qDebug() << "Testing isPixmapPureColor..."; + QPixmap purePixmap(10, 10); + purePixmap.fill(QColor(38, 38, 38)); + qDebug() << "isPixmapPureColor for pure pixmap:" << HighLightEffect::isPixmapPureColor(purePixmap); + QPixmap impurePixmap(10, 10); + impurePixmap.fill(QColor(38, 38, 39)); + qDebug() << "isPixmapPureColor for impure pixmap:" << HighLightEffect::isPixmapPureColor(impurePixmap); + QPixmap nullPixmap; + qDebug() << "isPixmapPureColor for null pixmap:" << HighLightEffect::isPixmapPureColor(nullPixmap); + + + // 测试 isSymbolicColor 方法 + qDebug() << "Testing isSymbolicColor..."; + QPixmap symbolicPixmap(10, 10); + symbolicPixmap.fill(QColor(38, 38, 38)); + qDebug() << "isSymbolicColor for symbolic pixmap:" << HighLightEffect::isSymbolicColor(symbolicPixmap); + QPixmap nonSymbolicPixmap(10, 10); + nonSymbolicPixmap.fill(QColor(38, 38, 39)); + qDebug() << "isSymbolicColor for non-symbolic pixmap:" << HighLightEffect::isSymbolicColor(nonSymbolicPixmap); + qDebug() << "isSymbolicColor for null pixmap:" << HighLightEffect::isSymbolicColor(nullPixmap); + + + // 测试 setMenuIconHighlightEffect 方法 + qDebug() << "Testing setMenuIconHighlightEffect..."; + QMenu menu; + HighLightEffect::setMenuIconHighlightEffect(&menu, HighLightEffect::HighlightEffect, HighLightEffect::BothDefaultAndHighlit); + qDebug() << "useIconHighlightEffect property after setMenuIconHighlightEffect:" << menu.property("useIconHighlightEffect").toInt(); + qDebug() << "iconHighlightEffectMode property after setMenuIconHighlightEffect:" << menu.property("iconHighlightEffectMode").toInt(); + + + // 测试 setViewItemIconHighlightEffect 方法 + qDebug() << "Testing setViewItemIconHighlightEffect..."; + QTreeView view; + HighLightEffect::setViewItemIconHighlightEffect(&view, HighLightEffect::HighlightEffect, HighLightEffect::BothDefaultAndHighlit); + qDebug() << "useIconHighlightEffect property of viewport after setViewItemIconHighlightEffect:" << view.viewport()->property("useIconHighlightEffect").toInt(); + qDebug() << "iconHighlightEffectMode property of viewport after setViewItemIconHighlightEffect:" << view.viewport()->property("iconHighlightEffectMode").toInt(); + + // 测试 isWidgetIconUseHighlightEffect 方法 + qDebug() << "Testing isWidgetIconUseHighlightEffect..."; + HighLightEffect::setSkipEffect(&menu, true); + qDebug() << "isWidgetIconUseHighlightEffect when skipHighlight is set:" << HighLightEffect::isWidgetIconUseHighlightEffect(&menu); + HighLightEffect::setMenuIconHighlightEffect(&menu, HighLightEffect::HighlightEffect, HighLightEffect::BothDefaultAndHighlit); + qDebug() << "isWidgetIconUseHighlightEffect after setMenuIconHighlightEffect:" << HighLightEffect::isWidgetIconUseHighlightEffect(&menu); + + + // 测试 setSymoblicColor 方法 + qDebug() << "Testing setSymoblicColor..."; + QColor newColor(50, 50, 50); + HighLightEffect::setSymoblicColor(newColor); + qDebug() << "symbolic_color after setSymoblicColor:" << HighLightEffect::symbolic_color; + + + // 测试 setWidgetIconFillSymbolicColor 方法 + qDebug() << "Testing setWidgetIconFillSymbolicColor..."; + HighLightEffect::setWidgetIconFillSymbolicColor(&widget, true); + qDebug() << "fillIconSymbolicColor property after set to true:" << widget.property("fillIconSymbolicColor").toBool(); + HighLightEffect::setWidgetIconFillSymbolicColor(&widget, false); + qDebug() << "fillIconSymbolicColor property after set to false:" << widget.property("fillIconSymbolicColor").toBool(); + + + // 测试 getCurrentSymbolicColor 方法 + qDebug() << "Testing getCurrentSymbolicColor..."; + QColor originalSymbolicColor = HighLightEffect::symbolic_color; + QColor newSymbolicColor = HighLightEffect::getCurrentSymbolicColor(); + qDebug() << "getCurrentSymbolicColor result:" << newSymbolicColor; + qDebug() << "symbolic_color after getCurrentSymbolicColor:" << HighLightEffect::symbolic_color; + + + // 测试 defaultStyleDark 方法 + qDebug() << "Testing defaultStyleDark..."; + QStyleOption option; + QColor darkColor = HighLightEffect::defaultStyleDark(&option); + qDebug() << "defaultStyleDark result:" << darkColor; + + + // 测试 generatePixmap 方法 + qDebug() << "Testing generatePixmap..."; + QPixmap pixmap(10, 10); + pixmap.fill(QColor(38, 38, 38)); + QStyleOption option2; + QWidget widget2; + + // 测试 force 为 true 的情况 + qDebug() << "generatePixmap with force true:"; + QPixmap result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, true); + qDebug() << "generatePixmap result (force true):" << result; + + // 测试各种 HighLightMode 和 EffectMode 组合 + widget2.setProperty("skipHighlightIconEffect", false); + widget2.setProperty("iconHighlightEffectMode", HighLightEffect::BothDefaultAndHighlit); + qDebug() << "generatePixmap with skipHighlightIconEffect false and iconHighlightEffectMode set:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (skipHighlightIconEffect false and iconHighlightEffectMode set):" << result; + + widget2.setProperty("useIconHighlightEffect", HighLightEffect::HighlightEffect); + qDebug() << "generatePixmap with useIconHighlightEffect set to HighlightEffect:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (useIconHighlightEffect set to HighlightEffect):" << result; + + widget2.setProperty("useIconHighlightEffect", HighLightEffect::ordinaryHighLight); + qDebug() << "generatePixmap with useIconHighlightEffect set to ordinaryHighLight:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (useIconHighlightEffect set to ordinaryHighLight):" << result; + + widget2.setProperty("useIconHighlightEffect", HighLightEffect::hoverHighLight); + qDebug() << "generatePixmap with useIconHighlightEffect set to hoverHighLight:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (useIconHighlightEffect set to hoverHighLight):" << result; + + widget2.setProperty("useIconHighlightEffect", HighLightEffect::defaultHighLight); + qDebug() << "generatePixmap with useIconHighlightEffect set to defaultHighLight:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (useIconHighlightEffect set to defaultHighLight):" << result; + + widget2.setProperty("useIconHighlightEffect", HighLightEffect::filledSymbolicColorHighLight); + qDebug() << "generatePixmap with useIconHighlightEffect set to filledSymbolicColorHighLight:"; + result = HighLightEffect::generatePixmap(pixmap, &option2, &widget2, false); + qDebug() << "generatePixmap result (useIconHighlightEffect set to filledSymbolicColorHighLight):" << result; + + + // 测试 ordinaryGeneratePixmap 方法 + qDebug() << "Testing ordinaryGeneratePixmap..."; + QPixmap pixmap2(10, 10); + pixmap2.fill(QColor(38, 38, 38)); + QStyleOption option3; + QWidget widget3; + qDebug() << "ordinaryGeneratePixmap result:" << HighLightEffect::ordinaryGeneratePixmap(pixmap2, &option3, &widget3, HighLightEffect::BothDefaultAndHighlit); + + + // 测试 hoverGeneratePixmap 方法 + qDebug() << "Testing hoverGeneratePixmap..."; + QPixmap pixmap3(10, 10); + pixmap3.fill(QColor(38, 38, 38)); + QStyleOption option4; + QWidget widget4; + qDebug() << "hoverGeneratePixmap result:" << HighLightEffect::hoverGeneratePixmap(pixmap3, &option4, &widget4, HighLightEffect::BothDefaultAndHighlit); + + QPixmap pixmap3_1(10, 10); + pixmap3_1 = QIcon::fromTheme("user-home-symbolic").pixmap(10,10); + QStyleOption option3_1; + QWidget widget3_1; + qDebug() << "hoverGeneratePixmap result:" << HighLightEffect::filledSymbolicColoredGeneratePixmap(pixmap3_1, &option3_1, &widget3_1, HighLightEffect::BothDefaultAndHighlit); + + // 测试 bothOrdinaryAndHoverGeneratePixmap 方法 + qDebug() << "Testing bothOrdinaryAndHoverGeneratePixmap..."; + QPixmap pixmap4(10, 10); + pixmap4.fill(QColor(38, 38, 38)); + QStyleOption option5; + QWidget widget5; + qDebug() << "bothOrdinaryAndHoverGeneratePixmap result:" << HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap4, &option5, &widget5, HighLightEffect::BothDefaultAndHighlit); + + + // 测试 filledSymbolicColoredGeneratePixmap 方法 + qDebug() << "Testing filledSymbolicColoredGeneratePixmap..."; + QPixmap pixmap5(10, 10); + pixmap5.fill(QColor(38, 38, 38)); + QStyleOption option6; + QWidget widget6; +// qDebug() << "filledSymbolicColoredGeneratePixmap result:" << HighLightEffect::filledSymbolicColoredGeneratePixmap(pixmap5, &option6, &widget6, HighLightEffect::SymbolicColor); + } + void testicontions() + { + // 创建 UKUIConfigStyle 实例 + UKUIConfigStyle configStyle("IconStyle"); + + // 测试 generatedIconPixmap 函数 + // 测试 QIcon::Disabled 模式 + QPixmap originalPixmap(100, 100); + originalPixmap.fill(Qt::red); + QStyleOption option; + configStyle.generatedIconPixmap(QIcon::Disabled, originalPixmap, &option); + + // 测试另一种情况,当原始 pixmap 为不同颜色 + QPixmap anotherPixmap(100, 100); + anotherPixmap.fill(Qt::blue); + configStyle.generatedIconPixmap(QIcon::Disabled, anotherPixmap, &option); + + // 测试当 pixmap 是纯色的情况 + configStyle.generatedIconPixmap(QIcon::Disabled, originalPixmap, &option); + + // 测试当 option 有不同的 palette 时 + QPalette palette; + palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::green); + option.palette = palette; + configStyle.generatedIconPixmap(QIcon::Disabled, originalPixmap, &option); + + // 测试其他 QIcon::Mode 的情况,这里只是简单调用,你可以根据实际情况添加更多逻辑 + configStyle.generatedIconPixmap(QIcon::Normal, originalPixmap, &option); + + + // 测试 testGeneratedSVGPixmap 函数 + // 测试 testGeneratedSVGPixmap 函数 + configStyle.testGeneratedSVGPixmap(originalPixmap); + + // 测试当原始 pixmap 为不同颜色 + configStyle.testGeneratedSVGPixmap(anotherPixmap); + + // 测试当原始 pixmap 为透明时 + QPixmap transparentPixmap(100, 100); + transparentPixmap.fill(Qt::transparent); + configStyle.testGeneratedSVGPixmap(transparentPixmap); + } + void UKUIStyleConfSettingsTest(){ +// // 测试 qtify_name 函数 +// const char* testName1 = "hello-world"; +// QString result1 = qtify_name(testName1); +// qDebug() << "qtify_name result: " << result1; + +// // 测试 unqtify_name 函数 +// QString testName2 = "HelloWorld"; +// char* result2 = unqtify_name(testName2); +// qDebug() << "unqtify_name result: " << result2; +// g_free(result2); + +// 测试 ukuiStyleConfSettings 的构造函数和析构函数 + ukuiStyleConfSettings settings("test_schema"); +// qDebug() << "ukuiStyleConfSettings constructed."; + + // 测试 settingChanged 函数 + // 由于该函数是静态函数,并且依赖于 KSettings 的信号连接,这里无法直接调用测试, + // 可通过后续的操作间接验证其是否正常工作 + + +// // 测试 types_to_qvariant 函数 +// ukuiStyleConfSettings testSettings("test_schema"); +// const char* testKey = "test_key"; +// const char* testValue = "123"; +// QVariant variant = testSettings.types_to_qvariant(testKey, testValue); +// qDebug() << "types_to_qvariant result: " << variant; + +//// // 测试 get 函数 +// QString getKey = "test_get_key"; +// QVariant getValue = testSettings.get(getKey); +// qDebug() << "get result: " << getValue; + + +// // 测试 set 函数 +// QString setKey = "test_set_key"; +// QVariant setValue = QVariant("test_set_value"); +// testSettings.set(setKey, setValue); +// qDebug() << "set function called."; + + +// // 测试 trySet 函数 +// QString trySetKey = "test_try_set_key"; +// QVariant trySetValue = QVariant("test_try_set_value"); +// bool trySetResult = testSettings.trySet(trySetKey, trySetValue); +// qDebug() << "trySet result: " << trySetResult; + + +// // 测试 keys 函数 +// QStringList keyList = testSettings.keys(); +// qDebug() << "keys result: " << keyList; + + +// // 测试 reset 函数 +// QString resetKey = "test_reset_key"; +// testSettings.reset(resetKey); +// qDebug() << "reset function called."; + + +// // 测试 isSettingsAvailable 函数 +// QString schemaId = "test_schema_available"; +// bool available = ukuiStyleConfSettings::isSettingsAvailable(schemaId); +// qDebug() << "isSettingsAvailable result: " << available; + + +// // 额外的测试,确保不传入 0x0 作为 value 给 types_to_qvariant 函数 +// const char* validKey = "valid_key"; +// const char* validValue = "valid_value"; +// QVariant validVariant = testSettings.types_to_qvariant(validKey, validValue); +// qDebug() << "types_to_qvariant with valid value result: " << validVariant; + + +// // 可以添加更多测试用例,确保各种情况都能正确处理 +// // 例如,测试不同的数据类型转换 +// const char* boolValue = "true"; +// QVariant boolVariant = testSettings.types_to_qvariant("bool_key", boolValue); +// qDebug() << "types_to_qvariant with boolean value result: " << boolVariant; + + +// const char* intValue = "42"; +// QVariant intVariant = testSettings.types_to_qvariant("int_key", intValue); +// qDebug() << "types_to_qvariant with integer value result: " << intVariant; + + +// const char* doubleValue = "3.14"; +// QVariant doubleVariant = testSettings.types_to_qvariant("double_key", doubleValue); +// qDebug() << "types_to_qvariant with double value result: " << doubleVariant; + + +// const char* arrayValue = "['item1', 'item2']"; + } + + void testScrollBarAnimator(){ + + QWidget parentWidget; + UKUI::ScrollBar::DefaultInteractionAnimator animator(&parentWidget); + + // 测试bindWidget函数 + QScrollBar scrollBar; + animator.bindWidget(&scrollBar); + + // 测试unboundWidget函数 + animator.unboundWidget(); + + // 重新绑定测试,再次调用bindWidget + animator.bindWidget(&scrollBar); + + // 测试value函数 + animator.value("groove_width"); + animator.value("slider_opacity"); + animator.value("additional_opacity"); + animator.value("move_position"); + animator.value("bg_width"); + + // 测试setAnimatorStartValue和setAnimatorEndValue函数 + animator.setAnimatorStartValue("groove_width", 0.2); + animator.setAnimatorEndValue("groove_width", 0.8); + animator.setAnimatorStartValue("slider_opacity", 0.3); + animator.setAnimatorEndValue("slider_opacity", 0.7); + animator.setAnimatorStartValue("additional_opacity", 0.1); + animator.setAnimatorEndValue("additional_opacity", 0.5); + animator.setAnimatorStartValue("move_position", 0.0); + animator.setAnimatorEndValue("move_position", 1.0); + animator.setAnimatorStartValue("bg_width", 0.0); + animator.setAnimatorEndValue("bg_width", 1.0); + + // 测试setAnimatorDuration函数 + animator.setAnimatorDuration("groove_width", 300); + animator.setAnimatorDuration("slider_opacity", 250); + animator.setAnimatorDuration("additional_opacity", 200); + animator.setAnimatorDuration("move_position", 350); + animator.setAnimatorDuration("bg_width", 280); + + // 测试setAnimatorDirectionForward函数 + animator.setAnimatorDirectionForward("groove_width", true); + animator.setAnimatorDirectionForward("slider_opacity", false); + animator.setAnimatorDirectionForward("additional_opacity", true); + animator.setAnimatorDirectionForward("move_position", false); + animator.setAnimatorDirectionForward("bg_width", true); + + // 测试isRunning函数 + animator.isRunning("groove_width"); + animator.isRunning("slider_opacity"); + animator.isRunning("additional_opacity"); + animator.isRunning("move_position"); + animator.isRunning("bg_width"); + + // 测试startAnimator和stopAnimator函数 + animator.startAnimator("groove_width"); + animator.stopAnimator("groove_width"); + animator.startAnimator("slider_opacity"); + animator.stopAnimator("slider_opacity"); + animator.startAnimator("additional_opacity"); + animator.stopAnimator("additional_opacity"); + animator.startAnimator("move_position"); + animator.stopAnimator("move_position"); + animator.startAnimator("bg_width"); + animator.stopAnimator("bg_width"); + + // 测试currentAnimatorTime和setAnimatorCurrentTime函数 + animator.startAnimator("groove_width"); + animator.setAnimatorCurrentTime("groove_width", 100); + animator.currentAnimatorTime("groove_width"); + animator.startAnimator("slider_opacity"); + animator.setAnimatorCurrentTime("slider_opacity", 80); + animator.currentAnimatorTime("slider_opacity"); + animator.startAnimator("additional_opacity"); + animator.setAnimatorCurrentTime("additional_opacity", 50); + animator.currentAnimatorTime("additional_opacity"); + animator.startAnimator("move_position"); + animator.setAnimatorCurrentTime("move_position", 120); + animator.currentAnimatorTime("move_position"); + animator.startAnimator("bg_width"); + animator.setAnimatorCurrentTime("bg_width", 90); + animator.currentAnimatorTime("bg_width"); + + // 测试setExtraProperty和getExtraProperty函数 + animator.setExtraProperty("end_position", 10); + animator.setExtraProperty("start_position", 5); + animator.setExtraProperty("addValue", true); + animator.getExtraProperty("end_position"); + animator.getExtraProperty("start_position"); + animator.getExtraProperty("addValue"); + + // 析构函数测试(通过对象生命周期结束自动调用析构函数来间接验证资源释放) + { + QWidget parentWidgetForDelete; + UKUI::ScrollBar::DefaultInteractionAnimator* animatorOnHeap = new UKUI::ScrollBar::DefaultInteractionAnimator(&parentWidgetForDelete); + animatorOnHeap->bindWidget(&scrollBar); + delete animatorOnHeap; + } + + } + void testTabWidgetAnimator(){ + // 测试构造函数 + QWidget *parentWidget = new QWidget(); + UKUI::TabWidget::DefaultSlideAnimator animator(parentWidget); + + QTabWidget *tabWidget = new QTabWidget(); + tabWidget->addTab(new QWidget, "Tab 1"); + tabWidget->addTab(new QWidget, "Tab 2"); + QWidget parentWidgetForDelete; + UKUI::TabWidget::DefaultSlideAnimator* animatorOnHeap = new UKUI::TabWidget::DefaultSlideAnimator(&parentWidgetForDelete); + animatorOnHeap->bindTabWidget(tabWidget); + delete animatorOnHeap; + // 模拟触发currentChanged信号来执行相关逻辑(简单触发,未细致验证逻辑结果) + QObject::connect(tabWidget, &QTabWidget::currentChanged, [](int) {}); + + // 测试unboundTabWidget函数 + animator.unboundTabWidget(); + + // 重新绑定进行多次操作测试 + animator.bindTabWidget(tabWidget); + + QEvent event(QEvent::None); + animator.eventFilter(tabWidget, &event); + animator.eventFilter(tabWidget->widget(0), &event); + animator.eventFilter(tabWidget->widget(1), &event); + + +// 析构函数测试(通过对象生命周期结束自动调用析构函数来间接验证资源释放) + { + QWidget parentWidgetForDelete; + UKUI::TabWidget::DefaultSlideAnimator* animatorOnHeap = new UKUI::TabWidget::DefaultSlideAnimator(&parentWidgetForDelete); + animatorOnHeap->bindTabWidget(tabWidget); + delete animatorOnHeap; + } + } + + void testUnpolish() + { + UKUIConfigStyle style("testUnpolish Style");; + QWidget widget; + style.unpolish(&widget); + // 这里可以添加对初始状态的验证,例如检查某些属性是否已被正确设置或移除 + + // 测试普通 QWidget 的 unpolish 操作 + QWidget testWidget; + style.unpolish(&testWidget); +// 验证一些属性是否被正确移除或修改,例如事件过滤器是否已移除 +// QVERIFY(!testWidget.eventFilter(nullptr, nullptr)); + + // 测试不同类型的部件 + QLabel label; + style.unpolish(&label); +// QVERIFY(!label.wordWrap()); + + QMenu menu; + style.unpolish(&menu); + // 可以根据具体的实现添加更多的验证逻辑 + + QTabWidget tabWidget; + style.unpolish(&tabWidget); + // 验证 tabWidget 相关的动画助手是否正确注销 + // 这里假设你有相应的方法来检查 m_tab_animation_helper 是否注销 + // 例如,通过检查内部状态或调用某些辅助函数来确认 + + QScrollBar scrollBar; + style.unpolish(&scrollBar); + // 验证 scrollBar 相关的动画助手是否正确注销 + + QListView itemView; + style.unpolish(&itemView); + // 验证 itemView 的视口属性是否已正确设置 +// QVERIFY(itemView.viewport()->testAttribute(Qt::WA_Hover)); + + QToolButton toolButton; + style.unpolish(&toolButton); + // 验证 toolButton 相关的动画助手是否正确注销 + + QPushButton pushButton; + style.unpolish(&pushButton); + // 验证 pushButton 相关的动画助手是否正确注销 + + QComboBox comboBox; + style.unpolish(&comboBox); + // 验证 comboBox 相关的动画助手是否正确注销 + + QSpinBox spinBox; + style.unpolish(&spinBox); + // 验证 spinBox 相关的动画助手是否正确注销 + + QDoubleSpinBox doubleSpinBox; + style.unpolish(&doubleSpinBox); + // 验证 doubleSpinBox 相关的动画助手是否正确注销 + + QRadioButton radioButton; + style.unpolish(&radioButton); + // 验证 radioButton 相关的动画助手是否正确注销 + + QCheckBox checkBox; + style.unpolish(&checkBox); + // 验证 checkBox 相关的动画助手是否正确注销 + + QSlider slider; + style.unpolish(&slider); + // 验证 slider 相关的动画助手是否正确注销 + + QLineEdit lineEdit; + style.unpolish(&lineEdit); + // 验证 lineEdit 的属性是否已正确设置 +// QVERIFY(!lineEdit.testAttribute(Qt::WA_Hover)); + + QTreeView treeView; + style.unpolish(&treeView); + // 验证 treeView 相关的动画助手是否正确注销 + + // 测试窗口部件的各种属性组合 + QWidget windowWidget; + windowWidget.setWindowFlags(Qt::Window); + windowWidget.setProperty("useStyleWindowManager", true); + style.unpolish(&windowWidget); + // 验证窗口部件的窗口管理器是否正确注销 + + QWidget translucentWidget; + translucentWidget.setWindowFlags(Qt::Window); + translucentWidget.setAttribute(Qt::WA_TranslucentBackground, true); + style.unpolish(&translucentWidget); + // 验证具有半透明背景的窗口部件的处理是否正确 + + // 测试 QTipLabel 相关逻辑 + QWidget tipLabel; + style.unpolish(&tipLabel); + // 可以根据具体的实现添加相应的验证 + + // 测试属性 "useStyleWindowManager" 不同情况的处理 + QWidget customWidget; + customWidget.setWindowFlags(Qt::Window); + customWidget.setProperty("useStyleWindowManager", false); + style.unpolish(&customWidget); + // 验证不同属性值下的处理是否正确 + + // 测试各种部件的继承关系 + QWidget derivedWidget; + derivedWidget.setWindowFlags(Qt::Window); + derivedWidget.inherits("QPushButton"); + style.unpolish(&derivedWidget); + // 验证继承关系的处理是否正确 + + // 测试不同应用名称下的逻辑 + qApp->setApplicationName("ukui-menu"); + QWidget menuWidget; + style.unpolish(&menuWidget); + // 验证 ukui-menu 应用名称下的处理是否正确 + + + qApp->setApplicationName("other-app"); + QWidget otherWidget; + style.unpolish(&otherWidget); + // 验证其他应用名称下的处理是否正确 + + } + void testGestureHelper() + { + // 创建 GestureHelper 实例 + GestureHelper gestureHelper; + // 创建 QWidget 实例 + QWidget widget; + // 测试 registerWidget 函数 + gestureHelper.registerWidget(&widget); + + + // 测试 ActivationChange 事件 + QEvent activationChangeEvent(QEvent::ActivationChange); + gestureHelper.eventFilter(&widget, &activationChangeEvent); + + + // 测试 TouchBegin 事件 + QTouchEvent touchBeginEvent(QEvent::TouchBegin); + gestureHelper.eventFilter(&widget, &touchBeginEvent); + + + // 模拟 TouchBegin 事件中的一些操作 + QList touchPoints; + QTouchEvent::TouchPoint touchPoint1; + touchPoint1.setPos(QPointF(10, 10)); + touchPoints.append(touchPoint1); + auto teBegin = static_cast(&touchBeginEvent); + teBegin->setTouchPoints(touchPoints); + + + // 测试 TouchUpdate 事件 + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate); + gestureHelper.eventFilter(&widget, &touchUpdateEvent); + + + // 模拟 TouchUpdate 事件中的一些操作 + QTouchEvent::TouchPoint touchPoint2; + touchPoint2.setPos(QPointF(20, 20)); + touchPoints.append(touchPoint2); + auto teUpdate = static_cast(&touchUpdateEvent); + teUpdate->setTouchPoints(touchPoints); + + + // 测试 TouchCancel 事件 + QTouchEvent touchCancelEvent(QEvent::TouchCancel); + gestureHelper.eventFilter(&widget, &touchCancelEvent); + + + // 测试 TouchEnd 事件 + QTouchEvent touchEndEvent(QEvent::TouchEnd); + gestureHelper.eventFilter(&widget, &touchEndEvent); + + +// // 测试 Gesture 事件 +// QGestureEvent gestureEvent(QEvent::Gesture); + + +// // 模拟 TwoFingerSlideGesture + UKUI::TwoFingerSlideGesture twoFingerSlideGesture; +// gestureEvent.addGesture(&twoFingerSlideGesture); + + +// // 模拟 TwoFingerSlideGesture 的更新状态 +// twoFingerSlideGesture.setState(Qt::GestureUpdated); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// // 模拟没有 Scroller 的情况 +// QWidget widgetWithoutScroller; +// gestureHelper.eventFilter(&widgetWithoutScroller, &gestureEvent); + + +// // 模拟 TwoFingerZoomGesture + UKUI::TwoFingerZoomGesture twoFingerZoomGesture; +// gestureEvent.addGesture(&twoFingerZoomGesture); + + +// // 模拟 TwoFingerZoomGesture 的不同缩放方向 +// twoFingerZoomGesture.setZoomDirection(UKUI::TwoFingerZoomGesture::ZoomIn); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// twoFingerZoomGesture.setZoomDirection(UKUI::TwoFingerZoomGesture::ZoomOut); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// // 模拟 TapGesture + QTapGesture tapGesture; +// gestureEvent.addGesture(&tapGesture); + + +// // 模拟 TapGesture 的不同状态 +// tapGesture.setState(Qt::GestureStarted); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// tapGesture.setState(Qt::GestureCanceled); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// tapGesture.setState(Qt::GestureFinished); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// // 模拟 TapAndHoldGesture + QTapAndHoldGesture tapAndHoldGesture; +// gestureEvent.addGesture(&tapAndHoldGesture); + + +// // 模拟 TapAndHoldGesture 的不同状态 +// tapAndHoldGesture.setState(Qt::GestureStarted); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// tapAndHoldGesture.setState(Qt::GestureCanceled); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// tapAndHoldGesture.setState(Qt::GestureFinished); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// // 模拟 SwipeGesture + QSwipeGesture swipeGesture; +// gestureEvent.addGesture(&swipeGesture); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// // 模拟 PanGesture + QPanGesture panGesture; +// gestureEvent.addGesture(&panGesture); + + +// // 模拟 PanGesture 的不同状态 +// panGesture.setState(Qt::GestureStarted); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// panGesture.setState(Qt::GestureCanceled); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + +// panGesture.setState(Qt::GestureFinished); +// gestureHelper.eventFilter(&widget, &gestureEvent); + + + // 测试 MouseMove 事件 + QMouseEvent mouseMoveEvent(QEvent::MouseMove, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + gestureHelper.eventFilter(&widget, &mouseMoveEvent); + + + // 测试 MouseButtonPress 事件 + QMouseEvent mouseButtonPressEvent(QEvent::MouseButtonPress, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + gestureHelper.eventFilter(&widget, &mouseButtonPressEvent); + + + // 测试 MouseButtonRelease 事件 + QMouseEvent mouseButtonReleaseEvent(QEvent::MouseButtonRelease, QPoint(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + gestureHelper.eventFilter(&widget, &mouseButtonReleaseEvent); + + + // 测试 DragEnter 和 DragMove 事件 + QEvent dragEnterEvent(QEvent::DragEnter); + gestureHelper.eventFilter(&widget, &dragEnterEvent); + + + QEvent dragMoveEvent(QEvent::DragMove); + gestureHelper.eventFilter(&widget, &dragMoveEvent); + + + // 测试 unregisterWidget 函数 + gestureHelper.unregisterWidget(&widget); + } + void testPushButton(){ + QWidget *w = new QWidget(); + QVBoxLayout *layout = new QVBoxLayout(); + QPushButton *pushbutton = new QPushButton(); + QToolButton *tb = new QToolButton(); + QCheckBox *box = new QCheckBox(); + QScrollBar *scrollbar1 = new QScrollBar(Qt::Vertical); + scrollbar1->setObjectName("scrollbar1111"); + scrollbar1->setContextMenuPolicy(Qt::NoContextMenu); + qDebug() << "scrollbar1..." << scrollbar1->minimum() << scrollbar1->maximum(); + scrollbar1->setProperty("drawScrollBarGroove", false); + scrollbar1->setProperty("needTranslucent", true); + + QScrollBar *scrollbar2 = new QScrollBar(Qt::Horizontal); + scrollbar2->setProperty("needTranslucent", false); + scrollbar2->setObjectName("scrollbar22222"); + scrollbar2->setPageStep(1); + scrollbar2->setMaximum(100); + scrollbar2->setMinimum(0); + + QSlider *slider2 = new QSlider(Qt::Horizontal); + slider2->setObjectName("slider2"); + + slider2->setMaximum(100); + slider2->setMinimum(0); + // slider2->setSingleStep(1); + slider2->setPageStep(10); + slider2->setTickPosition(QSlider::TicksBelow); + slider2->setProperty("needTranslucent", true); + + + layout->addWidget(pushbutton); + layout->addWidget(tb); + layout->addWidget(scrollbar1); + layout->addWidget(scrollbar2); + layout->addWidget(slider2); + + w->setLayout(layout); + w->show(); + } + void ConfigSliderAnimatorTests() + { + QSlider widget; + UKUIConfigStyleSpace::ConfigSliderAnimator animator; + + // 测试 bindWidget 函数 + animator.bindWidget(&widget); + + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("slider_opacity", 0.0); + animator.setAnimatorStartValue("additional_opacity", 0.0); + animator.setAnimatorStartValue("move_position", 0.0); + animator.setAnimatorStartValue("bg_width", 0.0); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("slider_opacity", 1.0); + animator.setAnimatorEndValue("additional_opacity", 0.1); + animator.setAnimatorEndValue("move_position", 1.0); + animator.setAnimatorEndValue("bg_width", 1.0); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("slider_opacity", 200); + animator.setAnimatorDuration("additional_opacity", 150); + animator.setAnimatorDuration("move_position", 150); + animator.setAnimatorDuration("bg_width", 200); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("slider_opacity", true); + animator.setAnimatorDirectionForward("additional_opacity", false); + animator.setAnimatorDirectionForward("move_position", true); + animator.setAnimatorDirectionForward("bg_width", false); + + // 测试 startAnimator 函数 + animator.startAnimator("slider_opacity"); + animator.startAnimator("additional_opacity"); + animator.startAnimator("move_position"); + animator.startAnimator("bg_width"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(250); + + // 测试 value 函数 + qDebug() << "slider_opacity value: " << animator.value("slider_opacity"); + qDebug() << "additional_opacity value: " << animator.value("additional_opacity"); + qDebug() << "move_position value: " << animator.value("move_position"); + qDebug() << "bg_width value: " << animator.value("bg_width"); + + // 测试 animatorStartValue 函数 + qDebug() << "slider_opacity start value: " << animator.animatorStartValue("slider_opacity"); + qDebug() << "additional_opacity start value: " << animator.animatorStartValue("additional_opacity"); + qDebug() << "move_position start value: " << animator.animatorStartValue("move_position"); + qDebug() << "bg_width start value: " << animator.animatorStartValue("bg_width"); + + // 测试 animatorEndValue 函数 + qDebug() << "slider_opacity end value: " << animator.animatorEndValue("slider_opacity"); + qDebug() << "additional_opacity end value: " << animator.animatorEndValue("additional_opacity"); + qDebug() << "move_position end value: " << animator.animatorEndValue("move_position"); + qDebug() << "bg_width end value: " << animator.animatorEndValue("bg_width"); + + // 测试 isRunning 函数 + qDebug() << "slider_opacity is running: " << animator.isRunning("slider_opacity"); + qDebug() << "additional_opacity is running: " << animator.isRunning("additional_opacity"); + qDebug() << "move_position is running: " << animator.isRunning("move_position"); + qDebug() << "bg_width is running: " << animator.isRunning("bg_width"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "slider_opacity current time: " << animator.currentAnimatorTime("slider_opacity"); + qDebug() << "additional_opacity current time: " << animator.currentAnimatorTime("additional_opacity"); + qDebug() << "move_position current time: " << animator.currentAnimatorTime("move_position"); + qDebug() << "bg_width current time: " << animator.currentAnimatorTime("bg_width"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "slider_opacity total duration: " << animator.totalAnimationDuration("slider_opacity"); + qDebug() << "additional_opacity total duration: " << animator.totalAnimationDuration("additional_opacity"); + qDebug() << "move_position total duration: " << animator.totalAnimationDuration("move_position"); + qDebug() << "bg_width total duration: " << animator.totalAnimationDuration("bg_width"); + + // 测试 setExtraProperty 函数 + animator.setExtraProperty("end_position", 100); + animator.setExtraProperty("start_position", 50); + animator.setExtraProperty("addValue", true); + + // 测试 getExtraProperty 函数 + qDebug() << "end_position: " << animator.getExtraProperty("end_position"); + qDebug() << "start_position: " << animator.getExtraProperty("start_position"); + qDebug() << "addValue: " << animator.getExtraProperty("addValue"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("slider_opacity"); + animator.stopAnimator("additional_opacity"); + animator.stopAnimator("move_position"); + animator.stopAnimator("bg_width"); + + // 测试 unboundWidget 函数 + animator.unboundWidget(); + } + + void runConfigBoxAnimatorTests() + { + QComboBox comboBox; + UKUIConfigStyleSpace::ConfigBoxAnimator animator; + + // 测试 bindWidget 函数 + bool bindResult = animator.bindWidget(&comboBox); + qDebug() << "bindWidget result: " << bindResult; + if (bindResult) { + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("MouseOver", 0.2); + animator.setAnimatorStartValue("SunKen", 0.3); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("MouseOver", 0.8); + animator.setAnimatorEndValue("SunKen", 0.7); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("MouseOver", 150); + animator.setAnimatorDuration("SunKen", 120); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("MouseOver", true); + animator.setAnimatorDirectionForward("SunKen", false); + + // 测试 startAnimator 函数 + animator.startAnimator("MouseOver"); + animator.startAnimator("SunKen"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(100); + + // 测试 value 函数 + qDebug() << "MouseOver value: " << animator.value("MouseOver"); + qDebug() << "SunKen value: " << animator.value("SunKen"); + + // 测试 isRunning 函数 + qDebug() << "MouseOver is running: " << animator.isRunning("MouseOver"); + qDebug() << "SunKen is running: " << animator.isRunning("SunKen"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "MouseOver current time: " << animator.currentAnimatorTime("MouseOver"); + qDebug() << "SunKen current time: " << animator.currentAnimatorTime("SunKen"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "MouseOver total duration: " << animator.totalAnimationDuration("MouseOver"); + qDebug() << "SunKen total duration: " << animator.totalAnimationDuration("SunKen"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("MouseOver"); + animator.stopAnimator("SunKen"); + } + + // 测试 unboundWidget 函数 + bool unboundResult = animator.unboundWidget(); + qDebug() << "unboundWidget result: " << unboundResult; + } + void runConfigButtonAnimatorTests() + { + // 创建各种可能的按钮类型 + QToolButton toolButton; + QPushButton pushButton; + QComboBox comboBox; + QSpinBox spinBox; + QDoubleSpinBox doubleSpinBox; + + UKUIConfigStyleSpace::ConfigButtonAnimator animator; + + // 测试 bindWidget 函数 + bool bindResult; + + // 测试 QToolButton + bindResult = animator.bindWidget(&toolButton); + qDebug() << "bindWidget for QToolButton result: " << bindResult; + if (bindResult) { + // 调用各种函数进行测试 + testAnimatorFunctions(animator); + animator.unboundWidget(); + } + + // 测试 QPushButton + bindResult = animator.bindWidget(&pushButton); + qDebug() << "bindWidget for QPushButton result: " << bindResult; + if (bindResult) { + testAnimatorFunctions(animator); + animator.unboundWidget(); + } + + // 测试 QComboBox + bindResult = animator.bindWidget(&comboBox); + qDebug() << "bindWidget for QComboBox result: " << bindResult; + if (bindResult) { + testAnimatorFunctions(animator); + animator.unboundWidget(); + } + + // 测试 QSpinBox + bindResult = animator.bindWidget(&spinBox); + qDebug() << "bindWidget for QSpinBox result: " << bindResult; + if (bindResult) { + testAnimatorFunctions(animator); + animator.unboundWidget(); + } + + // 测试 QDoubleSpinBox + bindResult = animator.bindWidget(&doubleSpinBox); + qDebug() << "bindWidget for QDoubleSpinBox result: " << bindResult; + if (bindResult) { + testAnimatorFunctions(animator); + animator.unboundWidget(); + } + } + + // 封装一个测试动画器各种函数的函数 + void testAnimatorFunctions(UKUIConfigStyleSpace::ConfigButtonAnimator& animator) { + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("MouseOver", 0.2); + animator.setAnimatorStartValue("SunKen", 0.3); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("MouseOver", 0.8); + animator.setAnimatorEndValue("SunKen", 0.7); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("MouseOver", 150); + animator.setAnimatorDuration("SunKen", 120); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("MouseOver", true); + animator.setAnimatorDirectionForward("SunKen", false); + + // 测试 startAnimator 函数 + animator.startAnimator("MouseOver"); + animator.startAnimator("SunKen"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(100); + + // 测试 value 函数 + qDebug() << "MouseOver value: " << animator.value("MouseOver"); + qDebug() << "SunKen value: " << animator.value("SunKen"); + + // 测试 isRunning 函数 + qDebug() << "MouseOver is running: " << animator.isRunning("MouseOver"); + qDebug() << "SunKen is running: " << animator.isRunning("SunKen"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "MouseOver current time: " << animator.currentAnimatorTime("MouseOver"); + qDebug() << "SunKen current time: " << animator.currentAnimatorTime("SunKen"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "MouseOver total duration: " << animator.totalAnimationDuration("MouseOver"); + qDebug() << "SunKen total duration: " << animator.totalAnimationDuration("SunKen"); + + // 测试 endValue 函数 + qDebug() << "MouseOver end value: " << animator.endValue("MouseOver"); + qDebug() << "SunKen end value: " << animator.endValue("SunKen"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("MouseOver"); + animator.stopAnimator("SunKen"); + } + + void runConfigCheckBoxAnimatorTests() + { + QCheckBox checkBox; + UKUIConfigStyleSpace::ConfigCheckBoxAnimator animator; + + // 测试 bindWidget 函数 + bool bindResult = animator.bindWidget(&checkBox); + qDebug() << "bindWidget result: " << bindResult; + if (bindResult) { + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("OnScale", 0.2); + animator.setAnimatorStartValue("OnOpacity", 0.3); + animator.setAnimatorStartValue("OnBase", 0.4); + animator.setAnimatorStartValue("Off", 0.5); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("OnScale", 0.8); + animator.setAnimatorEndValue("OnOpacity", 0.7); + animator.setAnimatorEndValue("OnBase", 0.6); + animator.setAnimatorEndValue("Off", 0.5); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("OnScale", 300); + animator.setAnimatorDuration("OnOpacity", 200); + animator.setAnimatorDuration("OnBase", 250); + animator.setAnimatorDuration("Off", 150); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("OnScale", true); + animator.setAnimatorDirectionForward("OnOpacity", false); + animator.setAnimatorDirectionForward("OnBase", true); + animator.setAnimatorDirectionForward("Off", false); + + // 测试 startAnimator 函数 + animator.startAnimator("OnScale"); + animator.startAnimator("OnOpacity"); + animator.startAnimator("OnBase"); + animator.startAnimator("Off"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(200); + + // 测试 value 函数 + qDebug() << "OnScale value: " << animator.value("OnScale"); + qDebug() << "OnOpacity value: " << animator.value("OnOpacity"); + qDebug() << "OnBase value: " << animator.value("OnBase"); + qDebug() << "Off value: " << animator.value("Off"); + + // 测试 isRunning 函数 + qDebug() << "OnScale is running: " << animator.isRunning("OnScale"); + qDebug() << "OnOpacity is running: " << animator.isRunning("OnOpacity"); + qDebug() << "OnBase is running: " << animator.isRunning("OnBase"); + qDebug() << "Off is running: " << animator.isRunning("Off"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "OnScale current time: " << animator.currentAnimatorTime("OnScale"); + qDebug() << "OnOpacity current time: " << animator.currentAnimatorTime("OnOpacity"); + qDebug() << "OnBase current time: " << animator.currentAnimatorTime("OnBase"); + qDebug() << "Off current time: " << animator.currentAnimatorTime("Off"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "OnScale total duration: " << animator.totalAnimationDuration("OnScale"); + qDebug() << "OnOpacity total duration: " << animator.totalAnimationDuration("OnOpacity"); + qDebug() << "OnBase total duration: " << animator.totalAnimationDuration("OnBase"); + qDebug() << "Off total duration: " << animator.totalAnimationDuration("Off"); + + // 测试 setExtraProperty 函数 + animator.setExtraProperty("nochange", true); + qDebug() << "nochange value: " << animator.getExtraProperty("nochange"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("OnScale"); + animator.stopAnimator("OnOpacity"); + animator.stopAnimator("OnBase"); + animator.stopAnimator("Off"); + } + + // 测试 unboundWidget 函数 + bool unboundResult = animator.unboundWidget(); + qDebug() << "unboundWidget result: " << unboundResult; + } + void runConfigProgressBarAnimationTests() + { + QProgressBar progressBar; + UKUIConfigStyleSpace::ConfigProgressBarAnimation animator(&progressBar); + + // 测试 init 函数 + qDebug() << "Duration: " << animator.duration(); + qDebug() << "Start value: " << animator.startValue(); + qDebug() << "End value: " << animator.endValue(); + qDebug() << "Direction: " << animator.direction(); + qDebug() << "Easing curve: " << animator.easingCurve(); + + + // 测试 target 函数 + QWidget *targetWidget = animator.target(); + qDebug() << "Target widget: " << targetWidget; + + + // 测试 valueChanged 和 finished 信号连接 + animator.start(); + QApplication::processEvents(); + QThread::msleep(500); + + + // 测试修改动画参数 + animator.setStartValue(0.2); + animator.setEndValue(0.8); + animator.setDuration(3000); + animator.setDirection(QAbstractAnimation::Backward); + animator.setEasingCurve(QEasingCurve::OutCubic); + + + // 再次测试参数是否修改成功 + qDebug() << "Modified Duration: " << animator.duration(); + qDebug() << "Modified Start value: " << animator.startValue(); + qDebug() << "Modified End value: " << animator.endValue(); + qDebug() << "Modified Direction: " << animator.direction(); + qDebug() << "Modified Easing curve: " << animator.easingCurve(); + + + // 重新启动动画以查看修改后的效果 + animator.start(); + QApplication::processEvents(); + QThread::msleep(500); + + + // 测试暂停和恢复动画 +// animator.pause(); +// qDebug() << "Is paused: " << animator.state() == QAbstractAnimation::Paused; +// animator.resume(); +// qDebug() << "Is resumed: " << animator.state() == QAbstractAnimation::Running; + + +// // 测试停止动画 +// animator.stop(); +// qDebug() << "Is stopped: " << animator.state() == QAbstractAnimation::Stopped; + + + // 测试当前时间和总时长 + qDebug() << "Current time: " << animator.currentTime(); + qDebug() << "Total duration: " << animator.totalDuration(); + } + void runConfigRadioButtonAnimatorTests() + { + QRadioButton radioButton; + UKUIConfigStyleSpace::ConfigRadioButtonAnimator animator; + + // 测试 bindWidget 函数 + bool bindResult = animator.bindWidget(&radioButton); + qDebug() << "bindWidget result: " << bindResult; + if (bindResult) { + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("SunKenOn", 0.2); + animator.setAnimatorStartValue("Off", 0.8); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("SunKenOn", 0.8); + animator.setAnimatorEndValue("Off", 0.2); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("SunKenOn", 300); + animator.setAnimatorDuration("Off", 150); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("SunKenOn", true); + animator.setAnimatorDirectionForward("Off", false); + + // 测试 startAnimator 函数 + animator.startAnimator("SunKenOn"); + animator.startAnimator("Off"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(200); + + // 测试 value 函数 + qDebug() << "SunKenOn value: " << animator.value("SunKenOn"); + qDebug() << "Off value: " << animator.value("Off"); + + // 测试 isRunning 函数 + qDebug() << "SunKenOn is running: " << animator.isRunning("SunKenOn"); + qDebug() << "Off is running: " << animator.isRunning("Off"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "SunKenOn current time: " << animator.currentAnimatorTime("SunKenOn"); + qDebug() << "Off current time: " << animator.currentAnimatorTime("Off"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "SunKenOn total duration: " << animator.totalAnimationDuration("SunKenOn"); + qDebug() << "Off total duration: " << animator.totalAnimationDuration("Off"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("SunKenOn"); + animator.stopAnimator("Off"); + } + + // 测试 unboundWidget 函数 + bool unboundResult = animator.unboundWidget(); + qDebug() << "unboundWidget result: " << unboundResult; + } + void runConfigTreeAnimatorTests() + { + QTreeView treeView; + UKUIConfigStyleSpace::ConfigTreeAnimator animator; + + // 测试 bindWidget 函数 + bool bindResult = animator.bindWidget(&treeView); + qDebug() << "bindWidget result: " << bindResult; + if (bindResult) { + // 测试 setAnimatorStartValue 函数 + animator.setAnimatorStartValue("expand", 0.2); + animator.setAnimatorStartValue("collaps", 0.3); + + // 测试 setAnimatorEndValue 函数 + animator.setAnimatorEndValue("expand", 0.8); + animator.setAnimatorEndValue("collaps", 0.7); + + // 测试 setAnimatorDuration 函数 + animator.setAnimatorDuration("expand", 300); + animator.setAnimatorDuration("collaps", 250); + + // 测试 setAnimatorDirectionForward 函数 + animator.setAnimatorDirectionForward("expand", true); + animator.setAnimatorDirectionForward("collaps", false); + + // 测试 startAnimator 函数 + animator.startAnimator("expand"); + animator.startAnimator("collaps"); + + // 等待一段时间让动画运行 + QApplication::processEvents(); + QThread::msleep(200); + + // 测试 value 函数 + qDebug() << "expand value: " << animator.value("expand"); + qDebug() << "collaps value: " << animator.value("collaps"); + + // 测试 isRunning 函数 + qDebug() << "expand is running: " << animator.isRunning("expand"); + qDebug() << "collaps is running: " << animator.isRunning("collaps"); + + // 测试 currentAnimatorTime 函数 + qDebug() << "expand current time: " << animator.currentAnimatorTime("expand"); + qDebug() << "collaps current time: " << animator.currentAnimatorTime("collaps"); + + // 测试 totalAnimationDuration 函数 + qDebug() << "expand total duration: " << animator.totalAnimationDuration("expand"); + qDebug() << "collaps total duration: " << animator.totalAnimationDuration("collaps"); + + // 测试 animatorStartValue 函数 + qDebug() << "expand start value: " << animator.animatorStartValue("expand"); + qDebug() << "collaps start value: " << animator.animatorStartValue("collaps"); + + // 测试 animatorEndValue 函数 + qDebug() << "expand end value: " << animator.animatorEndValue("expand"); + qDebug() << "collaps end value: " << animator.animatorEndValue("collaps"); + + // 测试 stopAnimator 函数 + animator.stopAnimator("expand"); + animator.stopAnimator("collaps"); + + // 测试 setExtraProperty 函数 + QModelIndex index1, index2; + animator.setExtraProperty("expandItem", index1); + animator.setExtraProperty("collapsItem", index2); + + // 测试 getExtraProperty 函数 + qDebug() << "expandItem: " << animator.getExtraProperty("expandItem"); + qDebug() << "collapsItem: " << animator.getExtraProperty("collapsItem"); + } + + // 测试 unboundWidget 函数 + bool unboundResult = animator.unboundWidget(); + qDebug() << "unboundWidget result: " << unboundResult; + } + + + void runUKUIConfigStyleDrawControlTests() + { + QWidget widget; + UKUIConfigStyle style("testDrawControlStyle"); + + // 获取系统自带图标 + QIcon systemIcon = QIcon::fromTheme("application-x-desktop"); + QPixmap icon = systemIcon.pixmap(QSize(16, 16)); // 可以根据需要调整图标的大小 + + + // 测试 CE_PushButton + { + QStyleOptionButton buttonOption; + buttonOption.state = QStyle::State_Enabled | QStyle::State_Raised; + buttonOption.text = "Test Button"; + buttonOption.icon = systemIcon; + QImage image(200, 50, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_PushButton, &buttonOption, &imagePainter, &widget); + } + + + // 测试 CE_ScrollBarAddLine + { + QStyleOptionSlider sliderOption; + sliderOption.orientation = Qt::Horizontal; + sliderOption.state = QStyle::State_Enabled | QStyle::State_MouseOver; + sliderOption.minimum = 0; + sliderOption.maximum = 100; +// sliderOption.icon = systemIcon; + QImage image(200, 20, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ScrollBarAddLine, &sliderOption, &imagePainter, &widget); + } + + + // 测试 CE_ScrollBarSubLine + { + QStyleOptionSlider sliderOption; + sliderOption.orientation = Qt::Horizontal; + sliderOption.state = QStyle::State_Enabled | QStyle::State_MouseOver; + sliderOption.minimum = 0; + sliderOption.maximum = 100; +// sliderOption.icon = systemIcon; + QImage image(200, 20, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ScrollBarSubLine, &sliderOption, &imagePainter, &widget); + } + + + // 测试 CE_ScrollBarSlider + { + QStyleOptionSlider sliderOption; + sliderOption.orientation = Qt::Horizontal; + sliderOption.state = QStyle::State_Enabled | QStyle::State_MouseOver; + sliderOption.minimum = 0; + sliderOption.maximum = 100; + sliderOption.sliderPosition = 50; +// sliderOption.icon = systemIcon; + QImage image(200, 20, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ScrollBarSlider, &sliderOption, &imagePainter, &widget); + } + + + // 测试 CE_TabBarTabShape + { + QStyleOptionTab tabOption; + tabOption.state = QStyle::State_Selected; + tabOption.text = "Tab 1"; + tabOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + + widget.setProperty("setRadius", 1); + widget.setProperty("setWidgetBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarFocusPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarHoverPen", QPen(QColor(Qt::red))); + + style.drawControl(QStyle::CE_TabBarTabShape, &tabOption, &imagePainter, &widget); + } + + + // 测试 CE_TabBarTabLabel + { + QStyleOptionTab tabOption; + tabOption.state = QStyle::State_Selected; + tabOption.text = "Tab 1"; + tabOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_TabBarTabLabel, &tabOption, &imagePainter, &widget); + } + + + // 测试 CE_TabBarTab + { + QStyleOptionTab tabOption; + tabOption.state = QStyle::State_Selected; + tabOption.text = "Tab 1"; + tabOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_TabBarTab, &tabOption, &imagePainter, &widget); + } + + + // 测试 CE_CheckBox + { + QStyleOptionButton checkBoxOption; + checkBoxOption.state = QStyle::State_Enabled | QStyle::State_Selected; + checkBoxOption.text = "Check Box"; + checkBoxOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_CheckBox, &checkBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_CheckBoxLabel + { + QStyleOptionButton checkBoxOption; + checkBoxOption.state = QStyle::State_Enabled | QStyle::State_Selected; + checkBoxOption.text = "Check Box Label"; + checkBoxOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_CheckBoxLabel, &checkBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_MenuBarItem + { + QStyleOptionMenuItem menuItemOption; + menuItemOption.state = QStyle::State_Enabled | QStyle::State_Selected; + menuItemOption.text = "Menu Bar Item"; + menuItemOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_MenuBarItem, &menuItemOption, &imagePainter, &widget); + } + + + // 测试 CE_ToolBoxTabShape + { + QStyleOptionToolBox toolBoxOption; + toolBoxOption.state = QStyle::State_Enabled | QStyle::State_Selected; + toolBoxOption.text = "Tool Box Tab Shape"; + toolBoxOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ToolBoxTabShape, &toolBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_ToolBoxTabLabel + { + QStyleOptionToolBox toolBoxOption; + toolBoxOption.state = QStyle::State_Enabled | QStyle::State_Selected; + toolBoxOption.text = "Tool Box Tab Label"; + toolBoxOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ToolBoxTabLabel, &toolBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_ToolBoxTab + { + QStyleOptionToolBox toolBoxOption; + toolBoxOption.state = QStyle::State_Enabled | QStyle::State_Selected; + toolBoxOption.text = "Tool Box Tab"; + toolBoxOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ToolBoxTab, &toolBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_ProgressBarGroove + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = 50; + progressBarOption.textVisible = true; + progressBarOption.text = "50%"; +// progressBarOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ProgressBarGroove, &progressBarOption, &imagePainter, &widget); + } + + + // 测试 CE_ProgressBarContent + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = 50; + progressBarOption.textVisible = true; + progressBarOption.text = "50%"; +// progressBarOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ProgressBarContents, &progressBarOption, &imagePainter, &widget); + } + + + // 测试 CE_ProgressBarLabel + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = 50; + progressBarOption.textVisible = true; + progressBarOption.text = "50%"; +// progressBarOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ProgressBarLabel, &progressBarOption, &imagePainter, &widget); + } + + + // 测试 CE_ProgressBar + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = 50; + progressBarOption.textVisible = true; + progressBarOption.text = "50%"; +// progressBarOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ProgressBar, &progressBarOption, &imagePainter, &widget); + } + + + // 测试 CE_HeaderSection + { + QStyleOptionHeader headerOption; + headerOption.state = QStyle::State_Enabled; + headerOption.text = "Header Section"; + headerOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_HeaderSection, &headerOption, &imagePainter, &widget); + } + + + // 测试 CE_HeaderLabel + { + QStyleOptionHeader headerOption; + headerOption.state = QStyle::State_Enabled; + headerOption.text = "Header Label"; + headerOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_HeaderLabel, &headerOption, &imagePainter, &widget); + } + + + // 测试 CE_HeaderEmptyArea + { + QStyleOptionHeader headerOption; + headerOption.state = QStyle::State_Enabled; + headerOption.text = "Header Empty Area"; + headerOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_HeaderEmptyArea, &headerOption, &imagePainter, &widget); + } + + + // 测试 CE_Header + { + QStyleOptionHeader headerOption; + headerOption.state = QStyle::State_Enabled; + headerOption.text = "Header"; + headerOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_Header, &headerOption, &imagePainter, &widget); + } + + + // 测试 CE_ItemViewItem + { + QStyleOptionViewItem itemOption; + itemOption.text = "Item 1"; + itemOption.state = QStyle::State_Selected; + itemOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ItemViewItem, &itemOption, &imagePainter, &widget); + } + + + // 测试 CE_ShapedFrame + { + QStyleOptionFrame frameOption; + frameOption.frameShape = QFrame::Box; + frameOption.state = QStyle::State_Raised; +// frameOption.icon = systemIcon; + QImage image(200, 200, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ShapedFrame, &frameOption, &imagePainter, &widget); + } + + + // 测试 CE_ComboBox + { + QStyleOptionComboBox comboBoxOption; + comboBoxOption.state = QStyle::State_Enabled; + comboBoxOption.currentText = "Select Option"; +// comboBoxOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_ComboBoxLabel, &comboBoxOption, &imagePainter, &widget); + } + + + // 测试 CE_MenuItem + { + QStyleOptionMenuItem menuItemOption; + menuItemOption.state = QStyle::State_Enabled | QStyle::State_Selected; + menuItemOption.text = "Menu Item"; + menuItemOption.icon = systemIcon; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + + widget.setProperty("setFrameradius", 2); + widget.setProperty("setItemradius", 2); + widget.setProperty("setMenuBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setMenuBackgroundPen", QPen(QColor(Qt::red))); + widget.setProperty("setItemSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setMenuHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setItemFocusPen", QPen(QColor(Qt::red))); + + style.drawControl(QStyle::CE_MenuItem, &menuItemOption, &imagePainter, &widget); + } + + + // 测试 CE_ToolButton + { + QStyleOptionToolButton toolButtonOption; + toolButtonOption.state = QStyle::State_Enabled | QStyle::State_MouseOver; + toolButtonOption.text = "Tool Button"; + toolButtonOption.icon = systemIcon; + QImage image(100, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + + widget.setProperty("setIconHighlight", true); + widget.setProperty("setTextHighlight", true); + widget.setProperty("setTextDefaultColor", QColor(Qt::red)); + widget.setProperty("setTextHoverColor", QColor(Qt::red)); + widget.setProperty("setTextDisableColor", QColor(Qt::red)); + + style.drawControl(QStyle::CE_ToolButtonLabel, &toolButtonOption, &imagePainter, &widget); + } + + + // 测试 CE_RadioButton + { + QStyleOptionButton radioButtonOption; + radioButtonOption.state = QStyle::State_Enabled | QStyle::State_Selected; + radioButtonOption.text = "Radio Button"; + radioButtonOption.icon = systemIcon; + QImage image(150, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter imagePainter(&image); + style.drawControl(QStyle::CE_RadioButton, &radioButtonOption, &imagePainter, &widget); + } + + + // 测试布局方向 + { + QStyleOptionButton buttonOption; + buttonOption.state = QStyle::State_Enabled; + buttonOption.text = "Test Button"; + buttonOption.icon = systemIcon; + QImage leftToRightImage(200, 50, QImage::Format_ARGB32); + QImage rightToLeftImage(200, 50, QImage::Format_ARGB32); + leftToRightImage.fill(Qt::transparent); + rightToLeftImage.fill(Qt::transparent); + QPainter leftToRightPainter(&leftToRightImage); + QPainter rightToLeftPainter(&rightToLeftImage); + QGuiApplication::setLayoutDirection(Qt::LeftToRight); + style.drawControl(QStyle::CE_PushButton, &buttonOption, &leftToRightPainter, &widget); + QGuiApplication::setLayoutDirection(Qt::RightToLeft); + style.drawControl(QStyle::CE_PushButton, &buttonOption, &rightToLeftPainter, &widget); + } + } + void testSizeFromContents() + { + UKUIConfigStyle style("testSizeFromContentsStyle"); + + // 测试 CT_MenuItem + { + QStyleOptionMenuItem menuItem; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_MenuItem, &menuItem, size, &widget); + } + + // 测试 CT_LineEdit + { + QStyleOptionFrame frameOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_LineEdit, &frameOption, size, &widget); + } + + // 测试 CT_TabBarTab + { + QStyleOptionTab tabOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_TabBarTab, &tabOption, size, &widget); + } + + // 测试 CT_RadioButton + { + QStyleOptionButton radioButtonOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_RadioButton, &radioButtonOption, size, &widget); + } + + // 测试 CT_CheckBox + { + QStyleOptionButton checkBoxOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_CheckBox, &checkBoxOption, size, &widget); + } + + // 测试 CT_ToolButton + { + QStyleOptionToolButton toolButtonOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_ToolButton, &toolButtonOption, size, &widget); + } + + // 测试 CT_PushButton + { + QStyleOptionButton pushButtonOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_PushButton, &pushButtonOption, size, &widget); + } + + // 测试 CT_ComboBox + { + QStyleOptionComboBox comboBoxOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_ComboBox, &comboBoxOption, size, &widget); + } + + // 测试 CT_SpinBox + { + QStyleOptionSpinBox spinBoxOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_SpinBox, &spinBoxOption, size, &widget); + } + + // 测试 CT_ProgressBar + { + QStyleOptionProgressBar progressBarOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_ProgressBar, &progressBarOption, size, &widget); + } + + // 测试 CT_Slider + { + QStyleOptionSlider sliderOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_Slider, &sliderOption, size, &widget); + } + + // 测试 CT_HeaderSection + { + QStyleOptionHeader headerOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_HeaderSection, &headerOption, size, &widget); + } + + // 测试 CT_ItemViewItem + { + QStyleOptionViewItem viewItemOption; + QWidget widget; + QSize size(100, 20); + style.sizeFromContents(UKUIConfigStyle::CT_ItemViewItem, &viewItemOption, size, &widget); + } + } + void testDrawComplexControl() + { + UKUIConfigStyle style("DrawComplexControlStyle"); + // 测试 CC_ScrollBar + { + QStyleOptionSlider sliderOption; + sliderOption.orientation = Qt::Horizontal; + sliderOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(200, 20, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + + widget.setProperty("setRadius", 1); + widget.setProperty("setGrooveDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveInactiveBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setSliderDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setSliderHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setSliderClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setSliderDisableBrush", QBrush(QColor(Qt::red))); + + style.drawComplexControl(QStyle::CC_ScrollBar, &sliderOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_Slider + { + QStyleOptionSlider sliderOption; + sliderOption.orientation = Qt::Horizontal; + sliderOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(200, 20, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + + widget.setProperty("setRadius", 1); + widget.setProperty("setGrooveRadius", QBrush(QColor(Qt::red))); + widget.setProperty("setHandleDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHandleHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHandleClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHandleDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveValueDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveValueHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveValueDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveUnvalueDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveUnvalueHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setGrooveUnvalueDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHandleDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setHandleHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setHandleClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setHandleDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setSliderGroovePen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + + style.drawComplexControl(QStyle::CC_Slider, &sliderOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_ComboBox + { + QStyleOptionComboBox comboBoxOption; + comboBoxOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setEditBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setOnPen", QPen(QColor(Qt::red))); + widget.setProperty("setEditPen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + + style.drawComplexControl(QStyle::CC_ComboBox, &comboBoxOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_SpinBox + { + QStyleOptionSpinBox spinBoxOption; + spinBoxOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(200, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setFocusBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + widget.setProperty("setUpDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setUpFocusHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setUpClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setUpHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDownDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDownHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDownFocusHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDownClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setUpDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setUpHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setUpFocusHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setUpClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setUpDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setDownDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setDownHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDownFocusHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDownClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setDownDisablePen", QPen(QColor(Qt::red))); + + style.drawComplexControl(QStyle::CC_SpinBox, &spinBoxOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_Dial + { + QStyleOptionSlider dialOption; + dialOption.orientation = Qt::Horizontal; + dialOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(200, 200, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + style.drawComplexControl(QStyle::CC_Dial, &dialOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_ToolButton + { + QStyleOptionToolButton toolButtonOption; + toolButtonOption.state = QStyle::State_Enabled; + QWidget widget; + QImage image(100, 30, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + style.drawComplexControl(QStyle::CC_ToolButton, &toolButtonOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + + // 测试 CC_GroupBox + { + QStyleOptionGroupBox groupBoxOption; + groupBoxOption.state = QStyle::State_Enabled; + groupBoxOption.text = "Group Box"; + QWidget widget; + QImage image(200, 200, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + style.drawComplexControl(QStyle::CC_GroupBox, &groupBoxOption, &painter, &widget); + // 可添加更具体的断言,例如检查绘制的颜色、矩形位置和大小等 + } + } + void testSubElementRect() + { + UKUIConfigStyle style("SubElementRectstyle"); + QWidget widget; + + // 测试 SE_TabBarScrollLeftButton + { + QStyleOptionTab tabOption; + tabOption.direction = Qt::LeftToRight; + tabOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabBarScrollLeftButton, &tabOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabBarScrollLeftButton result: " << result; + } + + // 测试 SE_TabBarScrollRightButton + { + QStyleOptionTab tabOption; + tabOption.direction = Qt::LeftToRight; + tabOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabBarScrollRightButton, &tabOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabBarScrollRightButton result: " << result; + } + + // 测试 SE_TabBarTabLeftButton + { + QStyleOptionTab tabOption; + tabOption.direction = Qt::LeftToRight; + tabOption.rect = QRect(0, 0, 100, 30); + tabOption.shape = QTabBar::RoundedNorth; + tabOption.leftButtonSize = QSize(10, 10); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabBarTabLeftButton, &tabOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabBarTabLeftButton result: " << result; + } + + // 测试 SE_TabBarTabRightButton + { + QStyleOptionTab tabOption; + tabOption.direction = Qt::LeftToRight; + tabOption.rect = QRect(0, 0, 100, 30); + tabOption.shape = QTabBar::RoundedNorth; + tabOption.rightButtonSize = QSize(10, 10); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabBarTabRightButton, &tabOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabBarTabRightButton result: " << result; + } + + // 测试 SE_TabBarTabText + { + QStyleOptionTab tabOption; + tabOption.direction = Qt::LeftToRight; + tabOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabBarTabText, &tabOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabBarTabText result: " << result; + } + + // 测试 SE_TabWidgetTabPane + { + QStyleOptionTabWidgetFrame tabWidgetFrameOption; + tabWidgetFrameOption.direction = Qt::LeftToRight; + tabWidgetFrameOption.rect = QRect(0, 0, 100, 100); + tabWidgetFrameOption.tabBarSize = QSize(80, 30); + tabWidgetFrameOption.lineWidth = 2; + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabWidgetTabPane, &tabWidgetFrameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabWidgetTabPane result: " << result; + } + + // 测试 SE_TabWidgetTabContents + { + QStyleOptionTabWidgetFrame tabWidgetFrameOption; + tabWidgetFrameOption.direction = Qt::LeftToRight; + tabWidgetFrameOption.rect = QRect(0, 0, 100, 100); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabWidgetTabContents, &tabWidgetFrameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabWidgetTabContents result: " << result; + } + + // 测试 SE_TabWidgetTabBar + { + QStyleOptionTabWidgetFrame tabWidgetFrameFrameOption; + tabWidgetFrameFrameOption.direction = Qt::LeftToRight; + tabWidgetFrameFrameOption.rect = QRect(0, 0, 100, 100); + tabWidgetFrameFrameOption.tabBarSize = QSize(80, 30); + tabWidgetFrameFrameOption.shape = QTabBar::RoundedNorth; + tabWidgetFrameFrameOption.leftCornerWidgetSize = QSize(10, 10); + tabWidgetFrameFrameOption.rightCornerWidgetSize = QSize(10, 10); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabWidgetTabBar, &tabWidgetFrameFrameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabWidgetTabBar result: " << result; + } + + // 测试 SE_TabWidgetLeftCorner + { + QStyleOptionTabWidgetFrame tabWidgetFrameOption; + tabWidgetFrameOption.direction = Qt::LeftToRight; + tabWidgetFrameOption.rect = QRect(0, 0, 100, 100); + tabWidgetFrameOption.shape = QTabBar::RoundedNorth; + tabWidgetFrameOption.leftCornerWidgetSize = QSize(10, 10); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabWidgetLeftCorner, &tabWidgetFrameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabWidgetLeftCorner result: " << result; + } + + // 测试 SE_TabWidgetRightCorner + { + QStyleOptionTabWidgetFrame tabWidgetFrameOption; + tabWidgetFrameOption.direction = Qt::LeftToRight; + tabWidgetFrameOption.rect = QRect(0, 0, 100, 100); + tabWidgetFrameOption.shape = QTabBar::RoundedNorth; + tabWidgetFrameOption.rightCornerWidgetSize = QSize(10, 10); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TabWidgetRightCorner, &tabWidgetFrameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TabWidgetRightCorner result: " << result; + } + + // 测试 SE_RadioButtonIndicator + { + QStyleOptionButton buttonOption; + buttonOption.direction = Qt::LeftToRight; + buttonOption.rect = QRect(0, 0, 50, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_RadioButtonIndicator, &buttonOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_RadioButtonIndicator result: " << result; + } + + // 测试 SE_RadioButtonContents + { + QStyleOptionButton buttonOption; + buttonOption.direction = Qt::LeftToRight; + buttonOption.rect = QRect(0, 0, 50, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_RadioButtonContents, &buttonOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_RadioButtonContents result: " << result; + } + + // 测试 SE_CheckBoxIndicator + { + QStyleOptionButton buttonOption; + buttonOption.direction = Qt::LeftToRight; + buttonOption.rect = QRect(0, 0, 50, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_CheckBoxIndicator, &buttonOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_CheckBoxIndicator result: " << result; + } + + // 测试 SE_CheckBoxContents + { + QStyleOptionButton buttonOption; + buttonOption.direction = Qt::LeftToRight; + buttonOption.rect = QRect(0, 0, 50, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_CheckBoxContents, &buttonOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_CheckBoxContents result: " << result; + } + + // 测试 SE_PushButtonContents + { + QStyleOptionButton buttonOption; + buttonOption.direction = Qt::LeftToRight; + buttonOption.rect = QRect(0, 0, 50, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_PushButtonContents, &buttonOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_PushButtonContents result: " << result; + } + + // 测试 SE_LineEditContents + { + QStyleOptionFrame frameOption; + frameOption.direction = Qt::LeftToRight; + frameOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_LineEditContents, &frameOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_LineEditContents result: " << result; + } + + // 测试 SE_ProgressBarGroove + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.direction = Qt::LeftToRight; + progressBarOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ProgressBarGroove, &progressBarOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ProgressBarGroove result: " << result; + } + + // 测试 SE_ProgressBarLabel + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.direction = Qt::LeftToRight; + progressBarOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ProgressBarLabel, &progressBarOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ProgressBarLabel result: " << result; + } + + // 测试 SE_ProgressBarContents + { + QStyleOptionProgressBar progressBarOption; + progressBarOption.direction = Qt::LeftToRight; + progressBarOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ProgressBarContents, &progressBarOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ProgressBarContents result: " << result; + } + + // 测试 SE_HeaderLabel + { + QStyleOptionHeader headerOption; + headerOption.direction = Qt::LeftToRight; + headerOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_HeaderLabel, &headerOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_HeaderLabel result: " << result; + } + + // 测试 SE_HeaderArrow + { + QStyleOptionHeader headerOption; + headerOption.direction = Qt::LeftToRight; + headerOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_HeaderArrow, &headerOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_HeaderArrow result: " << result; + } + + // 测试 SE_ItemViewItemCheckIndicator + { + QStyleOptionViewItem viewItemOption; + viewItemOption.direction = Qt::LeftToRight; + viewItemOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ItemViewItemCheckIndicator, &viewItemOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ItemViewItemCheckIndicator result: " << result; + } + + // 测试 SE_ItemViewItemDecoration + { + QStyleOptionViewItem viewItemOption; + viewItemOption.direction = Qt::LeftToRight; + viewItemOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ItemViewItemDecoration, &viewItemOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ItemViewItemDecoration result: " << result; + } + + // 测试 SE_ItemViewItemText + { + QStyleOptionViewItem viewItemOption; + viewItemOption.direction = Qt::LeftToRight; + viewItemOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ItemViewItemText, &viewItemOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ItemViewItemText result: " << result; + } + + // 测试 SE_ItemViewItemFocusRect + { + QStyleOptionViewItem viewItemOption; + viewItemOption.direction = Qt::LeftToRight; + viewItemOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_ItemViewItemFocusRect, &viewItemOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_ItemViewItemFocusRect result: " << result; + } + + // 测试 SE_TreeViewDisclosureItem + { + QStyleOptionViewItem viewItemOption; + viewItemOption.direction = Qt::LeftToRight; + viewItemOption.rect = QRect(0, 0, 100, 30); + QRect result = style.subElementRect(UKUIConfigStyle::SE_TreeViewDisclosureItem, &viewItemOption, &widget); + // 这里可以输出结果,以便手动检查 + qDebug() << "SE_TreeViewDisclosureItem result: " << result; + } + } + void testDrawPrimitive() + { + UKUIConfigStyle style("DrawPrimitiveStyle"); + QWidget widget; + QPainter painter; + + // 测试 PE_PanelMenu + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + widget.setProperty("setFrameradius", 1); + widget.setProperty("setItemradius", 1); + widget.setProperty("setMenuBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setMenuBackgroundPen", QPen(QColor(Qt::red))); + widget.setProperty("setItemSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setMenuHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setItemFocusPen", QPen(QColor(Qt::red))); + + style.drawPrimitive(QStyle::PE_PanelMenu, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameMenu + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_FrameMenu, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameFocusRect + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setBranchDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setBranchHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setBranchSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setBranchDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTextHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setTextSelectPen", QPen(QColor(Qt::red))); + widget.setProperty("setTextDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setSelectPen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + + style.drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_Frame + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_Frame, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_PanelButtonCommand + { + QStyleOptionButton buttonOption; + buttonOption.rect = QRect(0, 0, 100, 100); + buttonOption.state = QStyle::State_None; + buttonOption.palette = widget.palette(); + buttonOption.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_PanelButtonCommand, &buttonOption, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_PanelTipLabel + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + widget.setProperty("setRadius", 1); + widget.setProperty("setBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setBackgroundPen", QPen(QColor(Qt::red))); + style.drawPrimitive(QStyle::PE_PanelTipLabel, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameStatusBar + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_FrameStatusBar, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorButtonDropDown + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorButtonDropDown, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_PanelButtonTool + { + QStyleOptionButton buttonOption; + buttonOption.rect = QRect(0, 0, 100, 100); + buttonOption.state = QStyle::State_None; + buttonOption.palette = widget.palette(); + buttonOption.direction = Qt::LeftToRight; + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setCheckBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setCheckHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setCheckClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setCheckDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setCheckPen", QPen(QColor(Qt::red))); + widget.setProperty("setCheckHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setCheckClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setCheckDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + style.drawPrimitive(QStyle::PE_PanelButtonTool, &buttonOption, &painter, &widget); + + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorTabClose + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameTabBarBase + { + QStyleOptionTabBarBase tabBarBaseOption; + tabBarBaseOption.tabBarRect = QRect(0, 0, 100, 100); + tabBarBaseOption.state = QStyle::State_None; + tabBarBaseOption.palette = widget.palette(); + tabBarBaseOption.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_FrameTabBarBase, &tabBarBaseOption, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameTabWidget + { + QStyleOptionTabWidgetFrame tabWidgetFrameOption; + tabWidgetFrameOption.rect = QRect(0, 0, 100, 100); + tabWidgetFrameOption.state = QStyle::State_None; + tabWidgetFrameOption.palette = widget.palette(); + tabWidgetFrameOption.direction = Qt::LeftToRight; + widget.setProperty("setRadius", 1); + widget.setProperty("setWidgetBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarBackgroundBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarSelectBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setTabBarDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarFocusPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setTabBarHoverPen", QPen(QColor(Qt::red))); + style.drawPrimitive(QStyle::PE_FrameTabWidget, &tabWidgetFrameOption, &painter, &widget); + + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_FrameGroupBox + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_FrameGroupBox, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_PanelLineEdit + { + QStyleOptionFrame frameOption; + frameOption.rect = QRect(0, 0, 100, 100); + frameOption.state = QStyle::State_None; + frameOption.palette = widget.palette(); + frameOption.direction = Qt::LeftToRight; + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setFocusBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setFocusPen", QPen(QColor(Qt::red))); + style.drawPrimitive(QStyle::PE_PanelLineEdit, &frameOption, &painter, &widget); + + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorArrowUp + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorArrowUp, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorArrowDown + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorArrowDown, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorArrowRight + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorArrowRight, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorArrowLeft + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorArrowLeft, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorRadioButton + { + QStyleOptionButton radioButtonOption; + radioButtonOption.rect = QRect(0, 0, 100, 100); + radioButtonOption.state = QStyle::State_None; + radioButtonOption.palette = widget.palette(); + radioButtonOption.direction = Qt::LeftToRight; + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setChildrenOnDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setChildrenOnHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setChildrenOnClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setChildrenOnDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnClickPen", QPen(QColor(Qt::red))); + style.drawPrimitive(QStyle::PE_IndicatorRadioButton, &radioButtonOption, &painter, &widget); + + + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorCheckBox + { + QStyleOptionButton checkBoxOption; + checkBoxOption.rect = QRect(0, 0, 100, 100); + checkBoxOption.state = QStyle::State_None; + checkBoxOption.palette = widget.palette(); + checkBoxOption.direction = Qt::LeftToRight; + + widget.setProperty("setRadius", 1); + widget.setProperty("setDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnDefaultBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnHoverBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setOnClickBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setPathDisableBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setPathBrush", QBrush(QColor(Qt::red))); + widget.setProperty("setContentPen", QPen(QColor(Qt::red))); + widget.setProperty("setDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setDisablePen", QPen(QColor(Qt::red))); + widget.setProperty("setHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnDefaultPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnHoverPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnClickPen", QPen(QColor(Qt::red))); + widget.setProperty("setOnHoverBrushIslinearGradient", true); + + style.drawPrimitive(QStyle::PE_IndicatorCheckBox, &checkBoxOption, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorTabTearLeft + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_IndicatorTabTearRight + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_IndicatorTabTearRight, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + + // 测试 PE_PanelScrollAreaCorner + { + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = widget.palette(); + option.direction = Qt::LeftToRight; + style.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &painter, &widget); + // 可以添加检查绘制结果的逻辑,例如使用 QImage 捕获绘制结果,检查颜色、形状等 + } + } + void testmenustyle() + { + // 创建 UKUIConfigStyle 实例 + UKUIConfigStyle configStyle("Menustyle"); + // 创建 QPainter 实例,这里使用 QImage 作为绘图设备 + QImage image(200, 200, QImage::Format_ARGB32); + QPainter painter(&image); + // 创建 QStyleOption 实例 + QStyleOption option; + // 创建 QWidget 实例 + QWidget widget; + // 测试 QStyle::PE_PanelMenu 情况 + configStyle.drawPrimitive(QStyle::PE_PanelMenu, &option, &painter, &widget); + // 测试 QStyle::PE_FrameMenu 情况 + configStyle.drawPrimitive(QStyle::PE_FrameMenu, &option, &painter, &widget); + // 测试 sp->initConfigMenuParameters + UKUIConfigStyleSpace::UKUIConfigStyleParameters *sp = new UKUIConfigStyleSpace::UKUIConfigStyleParameters(nullptr, true, "testCfg"); + + sp->updateParameters(true); + sp->colorIsSame(Qt::red, Qt::blue); +// configStyle.sp = sp; + // 测试保存和恢复 painter 状态 + painter.save(); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + painter.setBrush(Qt::red); + painter.setPen(Qt::blue); + painter.drawRoundedRect(widget.rect(), 10, 10); + painter.restore(); + + + // 测试 Menu_Right_Bottom_Corner 为 true 的情况 + sp->Menu_Right_Bottom_Corner = true; + + + QRect drawRect; + drawRect = option.rect.adjusted(0, 0, 1, 1); + QPainterPath drawRightBottomPath; + drawRightBottomPath.moveTo(drawRect.right(), drawRect.bottom() - 28); + drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * 20, drawRect.bottom() - 2 * 28, 2 * 20, 2 * 28), 0, -90); + drawRightBottomPath.lineTo(drawRect.right() - 10, drawRect.bottom()); + drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * 10, drawRect.bottom() - 2 * 10, 2 * 10, 2 * 10), -90, 90); + drawRightBottomPath.lineTo(drawRect.right(), drawRect.bottom() - 28); + + + QColor startColor = option.palette.color(QPalette::Active, QPalette::Base).lighter(300); + QColor endColor = option.palette.color(QPalette::Active, QPalette::Base).lighter(300); + QLinearGradient linearGradient; + + + painter.save(); + linearGradient.setColorAt(0, startColor); + linearGradient.setColorAt(1, endColor); + linearGradient.setStart(drawRect.right(), drawRect.bottom() - 28); + linearGradient.setFinalStop(drawRect.right(), drawRect.bottom()); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + painter.setPen(Qt::transparent); + painter.setBrush(linearGradient); + painter.drawPath(drawRightBottomPath); + painter.restore(); + + + // 清理资源 + delete sp; + } + void testEventFilter() + { + UKUIConfigStyle style("EventFilterstyle"); + QObject obj; + QEvent event(QEvent::None); +// QApplication app(argc, argv); // 假设你已经在 main 函数中定义了 argc 和 argv + + // 测试 QEvent::StyleAnimationUpdate 事件的处理 + { + QEvent styleAnimationUpdateEvent(QEvent::StyleAnimationUpdate); + bool result = style.eventFilter(&obj, &styleAnimationUpdateEvent); + // 可以添加检查 result 的逻辑,例如 QVERIFY(result == true); + } + + // 测试 QPushButton 和 QToolButton 的 QEvent::Hide 事件处理 + { + QPushButton pushButton; + QToolButton toolButton; + QEvent hideEvent(QEvent::Hide); + // 对于 QPushButton + bool pushButtonResult = style.eventFilter(&pushButton, &hideEvent); + // 对于 QToolButton + bool toolButtonResult = style.eventFilter(&toolButton, &hideEvent); + // 可以添加检查 pushButtonResult 和 toolButtonResult 的逻辑,例如 QVERIFY(pushButtonResult == false); + } + + // 测试 QTipLabel 的事件处理 + { + QLabel tipLabel; + tipLabel.setAlignment(Qt::AlignLeft); + QEvent someEvent(QEvent::None); + style.eventFilter(&tipLabel, &someEvent); + // 可以添加检查 tipLabel 的对齐方式是否被修改的逻辑,例如 QVERIFY(tipLabel.alignment() == Qt::AlignVCenter); + } + + // 测试 QSlider 的 QEvent::Wheel 事件处理 + { + QSlider slider(Qt::Horizontal); + QWheelEvent wheelEvent(QPoint(0, 0), 0, Qt::NoButton, Qt::NoModifier); + bool wheelEventResult = style.eventFilter(&slider, &wheelEvent); + // 可以添加检查 wheelEventResult 的逻辑,例如 QVERIFY(wheelEventResult == false); + } + + // 测试 QSlider 的 QEvent::MouseButtonPress 事件处理 + { + QSlider slider(Qt::Horizontal); + QMouseEvent mousePressEvent(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + bool mousePressEventResult = style.eventFilter(&slider, &mousePressEvent); + // 可以添加检查 mousePressEventResult 的逻辑,例如 QVERIFY(mousePressEventResult == false); + } + + // 测试 QScrollBar 的事件处理 + { + QScrollBar scrollBar(Qt::Horizontal); + QMouseEvent mousePressEvent(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + bool scrollBarMouseEventResult = style.eventFilter(&scrollBar, &mousePressEvent); + // 可以添加检查 scrollBarMouseEventResult 的逻辑,例如 QVERIFY(scrollBarMouseEventResult == false); + } + + // 测试 QMenu 的 QEvent::Show 事件处理 + { + QMenu menu; + QEvent showEvent(QEvent::Show); + bool menuShowEventResult = style.eventFilter(&menu, &showEvent); + // 可以添加检查 menuShowEventResult 的逻辑,例如 QVERIFY(menuShowEventResult == false); + } + } + void testShadowHelper(){ + // 创建 ConfigShadowHelper 对象 + UKUIConfigStyleSpace::ConfigShadowHelper shadowHelper(nullptr); + + + // 测试 isWidgetNeedDecoShadow 函数 + QWidget* testWidget1 = new QWidget(); + bool needShadow1 = shadowHelper.isWidgetNeedDecoShadow(testWidget1); + qDebug() << "isWidgetNeedDecoShadow result for default QWidget: " << needShadow1; + + + // 测试 registerWidget 函数 + shadowHelper.registerWidget(testWidget1); + qDebug() << "registerWidget called for default QWidget."; + + + // 测试 getShadowPixmap 函数 + QColor testColor(255, 0, 0); + int shadowBorder = 5; + qreal darkness = 0.8; + QWidget* testWidget2 = new QWidget(); + int borderRadiusTopLeft = 10; + int borderRadiusTopRight = 10; + int borderRadiusBottomLeft = 10; + int borderRadiusBottomRight = 10; + QPixmap pixmap = shadowHelper.getShadowPixmap(testColor, shadowBorder, darkness, testWidget2, borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomLeft, borderRadiusBottomRight); + qDebug() << "getShadowPixmap result size: " << pixmap.size(); + + + // 测试 caculateRelativePainterPath 函数 + QPainterPath path = shadowHelper.caculateRelativePainterPath(testWidget2, borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomLeft, borderRadiusBottomRight); + qDebug() << "caculateRelativePainterPath result containsElement: " << path.contains(QPointF(0, 0)); + + + // 测试 getShadow 函数 + KWindowShadow* shadow = shadowHelper.getShadow(testColor, shadowBorder, darkness, testWidget2, borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomLeft, borderRadiusBottomRight); + qDebug() << "getShadow function called."; + + + // 测试 eventFilter 函数 + QEvent* showEvent = new QEvent(QEvent::Show); + bool filterResult = shadowHelper.eventFilter(testWidget1, showEvent); + qDebug() << "eventFilter result for Show event: " << filterResult; + + + // 测试 unregisterWidget 函数 + shadowHelper.unregisterWidget(testWidget1); + qDebug() << "unregisterWidget called for default QWidget."; + + + // 额外测试,使用具有特定属性的 QWidget 进行测试 + QWidget* customWidget = new QWidget(); + customWidget->setProperty("useCustomShadow", true); + customWidget->setProperty("customShadowWidth", 8); + customWidget->setProperty("customShadowDarkness", 0.6); + QVector4D radius(12, 12, 12, 12); + customWidget->setProperty("customShadowRadius", radius); + QVector4D margins(5, 5, 5, 5); + customWidget->setProperty("customShadowMargins", margins); + + + // 重新测试 registerWidget 函数 + shadowHelper.registerWidget(customWidget); + qDebug() << "registerWidget called for custom QWidget."; + + + // 重新测试 isWidgetNeedDecoShadow 函数 + bool needShadow2 = shadowHelper.isWidgetNeedDecoShadow(customWidget); + qDebug() << "isWidgetNeedDecoShadow result for custom QWidget: " << needShadow2; + + + // 重新测试 eventFilter 函数 + QEvent* customShowEvent = new QEvent(QEvent::Show); + filterResult = shadowHelper.eventFilter(customWidget, customShowEvent); + qDebug() << "eventFilter result for custom QWidget Show event: " << filterResult; + + + // 重新测试 unregisterWidget 函数 + shadowHelper.unregisterWidget(customWidget); + qDebug() << "unregisterWidget called for custom QWidget."; + + + // 清理内存 + delete testWidget1; + delete testWidget2; + delete customWidget; + delete showEvent; + delete customShowEvent; + if (shadow) { + shadow->destroy(); + delete shadow; + } + } + void testConfigP() { + + ReadConfig readcf("/usr/share/qt5-ukui-platformtheme/themeconfig/fashion.json"); + readcf.load("/usr/share/qt5-ukui-platformtheme/themeconfig/fashion.json"); + QBrush b; + readcf.getColorValue(b, "LightTheme", "PushButton", "DefaultPushButton", "DefaultBrush", ""); + + readcf.getColorValue(b, "LightTheme", "Palette", "WindowText_at", "", ""); + readcf.getColorValue(b, "LightTheme", "PushButton", "", "", ""); + readcf.getColorValue(b, "LightTheme", "PushButton", "DefaultPushButton", "", ""); + readcf.getColorValue(b, "LightTheme", "PushButton", "DefaultPushButton", "DefaultBrush", ""); + + readcf.setValue("PushButton", "DefaultPushButton"); + ReadThemeConfig themecf("/usr/share/qt5-ukui-platformtheme/themeconfig/fashion.json"); + themecf.setRadius("2123", 1); + + + QList l; + readcf.getGradientValue(l, "LightTheme", "PushButton", "WindowCloseButton", "HoverBrush", ""); + + readcf.stringToPaletteColor("WindowText_at" ); + readcf.stringToPaletteColor("WindowText_iat" ); + readcf.stringToPaletteColor("WindowText_dis" ); + readcf.stringToPaletteColor("Button_at" ); + readcf.stringToPaletteColor("Button_iat" ); + readcf.stringToPaletteColor("Button_dis" ); + readcf.stringToPaletteColor("Light_at" ); + readcf.stringToPaletteColor("Light_iat" ); + readcf.stringToPaletteColor("Light_dis" ); + readcf.stringToPaletteColor("Midlight_at" ); + readcf.stringToPaletteColor("Midlight_iat" ); + readcf.stringToPaletteColor("Midlight_dis" ); + + + readcf.stringToPaletteColor("Dark_at" ); + readcf.stringToPaletteColor("Dark_iat" ); + readcf.stringToPaletteColor("Dark_dis" ); + readcf.stringToPaletteColor("Mid_at" ); + readcf.stringToPaletteColor("Mid_iat" ); + readcf.stringToPaletteColor("Mid_dis" ); + readcf.stringToPaletteColor("Text_at" ); + readcf.stringToPaletteColor("Text_iat" ); + readcf.stringToPaletteColor("Text_dis" ); + readcf.stringToPaletteColor("BrightText_at" ); + readcf.stringToPaletteColor("BrightText_iat" ); + readcf.stringToPaletteColor("BrightText_dis" ); + + + readcf.stringToPaletteColor("ButtonText_at" ); + readcf.stringToPaletteColor("ButtonText_iat" ); + readcf.stringToPaletteColor("ButtonText_dis" ); + readcf.stringToPaletteColor("Base_at" ); + readcf.stringToPaletteColor("Base_iat" ); + readcf.stringToPaletteColor("Base_dis" ); + readcf.stringToPaletteColor("Window_at" ); + readcf.stringToPaletteColor("Window_iat" ); + readcf.stringToPaletteColor("Window_dis" ); + readcf.stringToPaletteColor("Shadow_at" ); + readcf.stringToPaletteColor("Shadow_iat" ); + readcf.stringToPaletteColor("Shadow_dis" ); + + readcf.stringToPaletteColor("HighLight_at" ); + readcf.stringToPaletteColor("HighLight_iat" ); + readcf.stringToPaletteColor("HighLight_dis" ); + readcf.stringToPaletteColor("HighLightText_at" ); + readcf.stringToPaletteColor("HighLightText_iat" ); + readcf.stringToPaletteColor("HighLightText_dis" ); + readcf.stringToPaletteColor("Link_at" ); + readcf.stringToPaletteColor("Link_iat" ); + readcf.stringToPaletteColor("Link_dis" ); + readcf.stringToPaletteColor("LinkVisited_at" ); + readcf.stringToPaletteColor("LinkVisited_iat" ); + readcf.stringToPaletteColor("LinkVisited_dis" ); + + + readcf.stringToPaletteColor("AlternateBase_at" ); + readcf.stringToPaletteColor("AlternateBase_iat" ); + readcf.stringToPaletteColor("AlternateBase_dis" ); + readcf.stringToPaletteColor("NoRole_at" ); + readcf.stringToPaletteColor("NoRole_iat" ); + readcf.stringToPaletteColor("NoRole_dis" ); + readcf.stringToPaletteColor("ToolTipBase_at" ); + readcf.stringToPaletteColor("ToolTipBase_iat" ); + readcf.stringToPaletteColor("ToolTipBase_dis" ); + readcf.stringToPaletteColor("ToolTipText_at" ); + readcf.stringToPaletteColor("ToolTipText_iat" ); + readcf.stringToPaletteColor("ToolTipText_dis" ); + + + readcf.stringToPaletteColor("PlaceholderText_at"); + readcf.stringToPaletteColor("PlaceholderText_iat" ); + readcf.stringToPaletteColor("PlaceholderText_dis" ); + + + // 创建 UKUIConfigStyleParameters 对象 + UKUIConfigStyleSpace::UKUIConfigStyleParameters params(nullptr, true, "testCfg"); + // 测试 lanhuHSLToQtHsl 函数 + QColor result1 = params.lanhuHSLToQtHsl(120, 50, 70, 200); + qDebug() << "lanhuHSLToQtHsl result: " << result1; + // 测试 adjustColor 函数 + QColor color1(255, 0, 0); // 红色 + QColor result2 = params.adjustColor(color1, 10, 20, 30, 40); + qDebug() << "adjustColor result: " << result2; + // 测试 adjustH 函数 + QColor result3 = params.adjustH(color1, 50); + qDebug() << "adjustH result: " << result3; + // 测试 adjustS 函数 + QColor result4 = params.adjustS(color1, 30); + qDebug() << "adjustS result: " << result4; + // 测试 adjustL 函数 + QColor result5 = params.adjustL(color1, 40); + qDebug() << "adjustL result: " << result5; + // 测试 adjustA 函数 + QColor result6 = params.adjustA(color1, 25); + qDebug() << "adjustA result: " << result6; + // 测试 highlightClick 函数 + QPalette palette; + QColor result7 = params.highlightClick(true, palette); + qDebug() << "highlightClick (isDark = true) result: " << result7; + QColor result8 = params.highlightClick(false, palette); + qDebug() << "highlightClick (isDark = false) result: " << result8; + // 测试 highlightHover 函数 + QColor result9 = params.highlightHover(true, palette); + qDebug() << "highlightHover (isDark = true) result: " << result9; + QColor result10 = params.highlightHover(false, palette); + qDebug() << "highlightHover (isDark = false) result: " << result10; + // 测试 buttonDarkClick 函数 + QColor result11 = params.buttonDarkClick(true, palette); + qDebug() << "buttonDarkClick (isDark = true) result: " << result11; + QColor result12 = params.buttonDarkClick(false, palette); + qDebug() << "buttonDarkClick (isDark = false) result: " << result12; + // 测试 normalButtonColor 函数 + QPen defaultPen, hoverPen, clickPen, disablePen; + QBrush defaultBrush, hoverBrush, clickBrush, disableBrush; + params.normalButtonColor(true, palette, defaultPen, defaultBrush, hoverPen, hoverBrush, clickPen, clickBrush, disablePen, disableBrush); + qDebug() << "normalButtonColor (isDark = true) executed"; + params.normalButtonColor(false, palette, defaultPen, defaultBrush, hoverPen, hoverBrush, clickPen, clickBrush, disablePen, disableBrush); + qDebug() << "normalButtonColor (isDark = false) executed"; + } + + void testBlackList(){ + QStringList blackApp = blackAppList(); + qDebug() << "blackAppList:"; + for (const QString& app : blackApp) { + qDebug() << app; + } + // 测试 blackAppListWithBlurHelper 函数 + QStringList blackAppBlur = blackAppListWithBlurHelper(); + qDebug() << "blackAppListWithBlurHelper:"; + for (const QString& app : blackAppBlur) { + qDebug() << app; + } + // 测试 useDarkPaletteList 函数 + QStringList darkPalette = useDarkPaletteList(); + qDebug() << "useDarkPaletteList:"; + for (const QString& app : darkPalette) { + qDebug() << app; + } + // 测试 useDefaultPaletteList 函数 + QStringList defaultPalette = useDefaultPaletteList(); + qDebug() << "useDefaultPaletteList:"; + for (const QString& app : defaultPalette) { + qDebug() << app; + } + // 测试 useTransparentButtonList 函数 + QStringList transparentButton = useTransparentButtonList(); + qDebug() << "useTransparentButtonList:"; + for (const QString& app : transparentButton) { + qDebug() << app; + } + // 测试 focusStateActiveList 函数 + QStringList focusState = focusStateActiveList(); + qDebug() << "focusStateActiveList:"; + for (const QString& app : focusState) { + qDebug() << app; + } + // 测试 windowManageBlackList 函数 + QStringList windowManage = windowManageBlackList(); + qDebug() << "windowManageBlackList:"; + for (const QString& app : windowManage) { + qDebug() << app; + } + } + + + void testFileDialog(){ + + UKUIFileDialog::KyNativeFileDialog kf; + kf.getCurrentAllFileUris(); + kf.getCurrentSelectionFileInfos(); + kf.setCurrentSortOrder(Qt::AscendingOrder); + kf.setCurrentSortColumn(0); + kf.editUri("11"); + kf.editUris(QStringList("1111")); + kf.selectNameFilterIndex(); + kf.setLabelText(QFileDialog::Accept, "ok"); + kf.labelText(QFileDialog::Accept); + kf.setOptions(QFileDialog::HideNameFilterDetails); + kf.setOption(QFileDialog::HideNameFilterDetails, true); + kf.options(); + kf.setCurrentInputName(""); + + UKUIFileDialog::FileDialogSideBar bar; + UKUIFileDialog::SideBarStyle *style = UKUIFileDialog::SideBarStyle::getStyle(); + bar.setStyle(style); + { + QWidget widget; + widget.setProperty("normalRadius", 8); + QPainter painter; + QStyleOption option; + option.rect = QRect(0, 0, 100, 100); + option.state = QStyle::State_None; + option.palette = qApp->style()->standardPalette(); + option.direction = Qt::LeftToRight; + style->drawPrimitive(QStyle::PE_PanelMenu, &option, &painter, &widget); + style->drawPrimitive(QStyle::PE_IndicatorItemViewItemDrop, &option, &painter, &widget); + QStyleOptionViewItem iOption; + iOption.rect = QRect(0, 0, 100, 100); + iOption.state = QStyle::State_None; + iOption.palette = qApp->style()->standardPalette(); + iOption.direction = Qt::LeftToRight; + style->drawPrimitive(QStyle::PE_IndicatorBranch, &iOption, &painter, &widget); + style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, &painter, &widget); + style->drawControl(QStyle::CE_ItemViewItem, &iOption, &painter, &widget); + + } + bar.tableModeChanged(""); + bar.menuRequest(QPoint(0,0)); +// QWindow *w1 = new QWindow(); + UKUIFileDialog::KyFileDialogHelper*help = new UKUIFileDialog::KyFileDialogHelper(); + help->defaultNameFilterDisables(); + help->setDirectory(QUrl("/usr/share/qt5-ukui-platformtheme/themeconfig")); + QString list; + list.append("桌面文件(*.desktop)"); + help->selectNameFilter(list); + help->selectMimeTypeFilter("application/icon"); + help->selectedMimeTypeFilter(); +// bool ishow = help->isShow(); +// help->show(Qt::Widget,Qt::ApplicationModal,w1); + QWidget *w1 = new QWidget(); +// QFileDialog *a = new QFileDialog(w1); +// UKUIFileDialog::KyNativeFileDialog *a = new UKUIFileDialog::KyNativeFileDialog(w1); +//// a->setDirectory(QString("file://%1").arg(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); +// a->setViewMode(UKUIFileDialog::KyNativeFileDialog::List); +// a->setAcceptMode(QFileDialog::AcceptSave); +// a->setCurrentInputName("test"); +// a->setLabelText(QFileDialog::FileName, "test"); + +//// QStringList nameFilters; +//// nameFilters << "txt"; +//// nameFilters << "*"; +//// a->setNameFilters(nameFilters); + +// a->show(); + + QStringList mimeTypeFilters({"image/jpeg", // will show "JPEG image (*.jpeg *.jpg *.jpe) + "image/png", // will show "PNG image (*.png)" + "application/octet-stream" // will show "All files (*)" + }); + + QWidget *w = new QWidget(); + QFileDialog *dialog00 = new QFileDialog(w); + dialog00->setMimeTypeFilters(mimeTypeFilters); + dialog00->show(); + qApp->setProperty("Language", "zh_CN"); + + QFileDialog *dialog01 = new QFileDialog(); + dialog01->setDirectoryUrl(QUrl("file://home/tanjing/work")); + QString filters = tr("Image(*.png) ;; Image(*.jpg)"); + + dialog01->setNameFilter(filters); + dialog01->setViewMode(QFileDialog::Detail); +// dialog01->show(); +//dialog01->close(); + QFileDialog *dialog02 = new QFileDialog(); + dialog02->setAcceptMode(QFileDialog::AcceptSave); + + dialog02->setNameFilter(filters); + dialog02->setViewMode(QFileDialog::Detail); +// dialog02->show(); +//dialog02->close(); + QFileDialog::getOpenFileName(nullptr, tr("getOpenFileName"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation), tr("Image Files (*.png *.jpg *.bmp);;Text files(*.txt);;XML files(*.xml)")); + QFileDialog::getOpenFileNames(nullptr, QStandardPaths::writableLocation(QStandardPaths::HomeLocation), tr("getOpenFileNames")); + QFileDialog::getSaveFileName(nullptr, tr("getSaveFileName"), "/home", tr("Image Files (*.png *.jpg *.bmp);;Text files(*.txt);;XML files(*.xml)")); + QFileDialog::getSaveFileUrl(nullptr, tr("getSaveFileUrl"),QUrl(), tr("Image Files (*.png *.jpg *.bmp)")); + QFileDialog::getExistingDirectory(nullptr, tr("getExistingDirectory")); + QFileDialog::getExistingDirectoryUrl(nullptr, tr("getExistingDirectoryUrl")); + + } + + +}; + +// 定义测试用例入口点setSkipEffect +QTEST_MAIN(LibFunctionTest) + +#include "test-settings.moc" + diff --git a/ukui-qml-style-helper/CMakeLists.txt b/ukui-qml-style-helper/CMakeLists.txt index 2b29ead..aa79a2d 100644 --- a/ukui-qml-style-helper/CMakeLists.txt +++ b/ukui-qml-style-helper/CMakeLists.txt @@ -77,6 +77,8 @@ file(GLOB_RECURSE HEADER_FILES "styleparameter/ukuitextfiled.h" "styleparameter/ukuicombobox.h" "styleparameter/ukuislider.h" + "styleparameter/ukuitextarea.h" + "styleparameter/ukuiheaderview.h" ) file(GLOB_RECURSE SRC_FILES "KyIcon.cpp" @@ -112,6 +114,8 @@ file(GLOB_RECURSE SRC_FILES "styleparameter/ukuipopupwindowhandle.cpp" "styleparameter/ukuispinbox.cpp" "styleparameter/ukuitooltip.cpp" + "styleparameter/ukuitextarea.cpp" + "styleparameter/ukuiheaderview.cpp" ) file(GLOB_RECURSE OTHER_FILES qmldir) diff --git a/ukui-qml-style-helper/KyIcon.cpp b/ukui-qml-style-helper/KyIcon.cpp index 037fd51..71aa721 100644 --- a/ukui-qml-style-helper/KyIcon.cpp +++ b/ukui-qml-style-helper/KyIcon.cpp @@ -27,7 +27,6 @@ #include #include "effects/highlight-effect.h" #include - QStyle *KyIcon::style() { return qApp->style(); @@ -80,7 +79,7 @@ void KyIcon::setIconName(const QString &iconName) m_iconName = iconName; if(!QIcon::hasThemeIcon(m_iconName)) { - m_icon = QIcon(); + m_icon = m_iconHelper.loadIcon(iconName); qWarning() << "未找到名为 " << m_iconName << " 的图标!"; return; } diff --git a/ukui-qml-style-helper/KyIcon.h b/ukui-qml-style-helper/KyIcon.h index de004e5..69c16c4 100644 --- a/ukui-qml-style-helper/KyIcon.h +++ b/ukui-qml-style-helper/KyIcon.h @@ -26,6 +26,7 @@ #include #include #include +#include "styleparameter/imageprovider.h" class QStyle; class KyIcon : public QQuickPaintedItem @@ -42,6 +43,7 @@ class KyIcon : public QQuickPaintedItem Q_PROPERTY( QString icontype READ icontype WRITE seticontype NOTIFY icontypeChanged) + public: KyIcon(QQuickPaintedItem *parent = nullptr); @@ -108,6 +110,7 @@ protected: private: QIcon m_icon; QString m_iconName; + UKUIQQC2Style::IconHelper m_iconHelper; }; diff --git a/ukui-qml-style-helper/qqc2styleplugin.cpp b/ukui-qml-style-helper/qqc2styleplugin.cpp index aa01947..287e0e3 100644 --- a/ukui-qml-style-helper/qqc2styleplugin.cpp +++ b/ukui-qml-style-helper/qqc2styleplugin.cpp @@ -49,6 +49,8 @@ #include "styleparameter/parsecolorinterface.h" #include "styleparameter/ukuiswitch.h" #include "styleparameter/ukuipopupwindowhandle.h" +#include "styleparameter/ukuitextarea.h" +#include "styleparameter/ukuiheaderview.h" using namespace UKUIQQC2Style; @@ -97,6 +99,8 @@ void Qqc2StylePlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "UKUISpinBox"); qmlRegisterType(uri, 1, 0, "UKUITabBar"); qmlRegisterType(uri, 1, 0, "UKUISwitch"); + qmlRegisterType(uri, 1, 0, "UKUITextArea"); + qmlRegisterType(uri, 1, 0, "UKUIHeaderView"); qmlRegisterType(uri, 1, 0, "ParseColorInterface"); qmlRegisterType(uri, 1, 0, "PopupHandle"); diff --git a/ukui-qml-style-helper/styleparameter/appparameter.cpp b/ukui-qml-style-helper/styleparameter/appparameter.cpp index b80e853..8e00873 100644 --- a/ukui-qml-style-helper/styleparameter/appparameter.cpp +++ b/ukui-qml-style-helper/styleparameter/appparameter.cpp @@ -6,6 +6,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "settings/ukui-style-settings.h" #include "../../qt5-ukui-platformtheme/platform-theme-fontdata.h" @@ -15,8 +20,8 @@ APPParameter::APPParameter(QQuickItem *parent) : QQuickItem(parent) { if(!qApp) return; - m_font = QApplication::font(); - m_palette = QApplication::palette(); + m_font =qApp->font(); + m_palette = qApp->palette(); if (QGSettings::isSchemaInstalled("org.ukui.style")) { @@ -62,26 +67,38 @@ APPParameter::APPParameter(QQuickItem *parent) : QQuickItem(parent) } connect(settings, &QGSettings::changed, this, [&](const QString& key){ - slotChangeStyle(key); - setPalette(QApplication::palette()); - emit parametryChanged(); - }, Qt::QueuedConnection); + slotChangeStyle(key); + TokenParameter * token = qApp->property("qqc2-globaltoken").value(); + if(token){ + setPalette(token->getInstance()->appPalette()); + } + else + setPalette(qApp->palette()); + emit parametryChanged(); + }, Qt::UniqueConnection); + connect(settings, &QGSettings::changed, this, [&](const QString& key){ + if(key == "iconThemeName" || key == "icon-theme-name"){ + emit iconThemeChanged(); + } + }, Qt::UniqueConnection); } - connect(qApp, &QApplication::paletteChanged, this, [&](const QPalette &pal){ + connect(qApp, &QGuiApplication::paletteChanged, this, [&](const QPalette &pal){ setPalette(pal); emit parametryChanged(); - }, Qt::QueuedConnection); + }, Qt::UniqueConnection); if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - setWindowColor(token->getInstance()->windowActive()); - connect(token->getInstance(), &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token){ setWindowColor(token->getInstance()->windowActive()); - emit parametryChanged(); - }, Qt::QueuedConnection); - + connect(token->getInstance(), &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + setPalette(token->getInstance()->appPalette()); + setWindowColor(token->getInstance()->windowActive()); + emit parametryChanged(); + }, Qt::UniqueConnection); + } } APPParameter::~APPParameter() @@ -142,8 +159,7 @@ void APPParameter::slotChangeStyle(const QString& key) if (key == "systemFont" || key == "system-font") { //Skip QGuiApplication avoid it crash when we setfont - auto *app = qobject_cast(qApp); - if(app == nullptr) + if(!qApp) return; QString font = settings->get("system-font").toString(); @@ -167,15 +183,15 @@ void APPParameter::slotChangeStyle(const QString& key) } if (key == "systemFontSize" || key == "system-font-size") { //Skip QGuiApplication avoid it crash when we setfont - auto *app = qobject_cast(qApp); - if(app == nullptr) + // auto *app = qobject_cast(qApp); + if(!qApp) return; if (qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool()) return; double fontSize = settings->get("system-font-size").toString().toDouble(); if (fontSize > 0) { - QFont oldFont = QApplication::font(); + QFont oldFont = qApp->font(); QFont tempFont = m_font; tempFont.setPointSize(fontSize); @@ -228,3 +244,58 @@ bool APPParameter::themeHasIcon(QString iconName) { return QIcon::hasThemeIcon(iconName); } + +bool APPParameter::focusEnable() const +{ + return m_focusEnable; +} + +void APPParameter::setFocusEnable(bool newFocusEnable) +{ + if (m_focusEnable == newFocusEnable) + return; + m_focusEnable = newFocusEnable; + emit focusEnableChanged(); +} + +bool APPParameter::showToolTipWindow() +{ + if(qAppName() == "kylin-aiassistant") + return false; + return true; +} + +QPoint APPParameter::posByCursor(int width, int height) +{ + QPoint p = QCursor::pos(); + qDebug() << "cursor pos:" << p; + const QScreen *screen =QGuiApplication::screenAt(QCursor::pos()); + if (const QPlatformScreen *platformScreen = screen ? screen->handle() : nullptr) { + QPlatformCursor *cursor = platformScreen->cursor(); + const QSize nativeSize = cursor ? cursor->size() : QSize(16, 16); + const QSize cursorSize = QHighDpi::fromNativePixels(nativeSize, platformScreen); + QPoint offset(2, cursorSize.height()); + if (cursorSize.height() > 2 * height) { + offset = QPoint(cursorSize.width() / 2, 0); + } + p += offset; + + QRect screenRect = screen->availableGeometry(); + if (p.x() + width > screenRect.x() + screenRect.width()) + p.rx() -= 4 + width; + if (p.y() + height > screenRect.y() + screenRect.height()) + p.ry() -= 24 + height; + if (p.y() < screenRect.y()) + p.setY(screenRect.y()); + if (p.x() + width > screenRect.x() + screenRect.width()) + p.setX(screenRect.x() + screenRect.width() - width); + if (p.x() < screenRect.x()) + p.setX(screenRect.x()); + if (p.y() + height > screenRect.y() + screenRect.height()) + p.setY(screenRect.y() + screenRect.height() - height); + } + qDebug() << "cursor pos1:" << p; + + return p; +} + diff --git a/ukui-qml-style-helper/styleparameter/appparameter.h b/ukui-qml-style-helper/styleparameter/appparameter.h index 02b2777..f51c1ca 100644 --- a/ukui-qml-style-helper/styleparameter/appparameter.h +++ b/ukui-qml-style-helper/styleparameter/appparameter.h @@ -42,6 +42,7 @@ class APPParameter : public QQuickItem Q_PROPERTY(bool isDark READ isDark WRITE setIsDark NOTIFY isDarkChanged) Q_PROPERTY(double menuTransparency READ menuTransparency WRITE setMenuTransparency NOTIFY menuTransparencyChanged) Q_PROPERTY(QBrush windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged) + Q_PROPERTY(bool focusEnable READ focusEnable WRITE setFocusEnable NOTIFY focusEnableChanged) public: @@ -73,6 +74,14 @@ public: Q_INVOKABLE bool themeHasIcon(QString iconName); + Q_INVOKABLE bool showToolTipWindow(); + + Q_INVOKABLE QPoint posByCursor(int width, int height); + + bool focusEnable() const; + + void setFocusEnable(bool newFocusEnable); + public slots: void slotChangeStyle(const QString& key); @@ -94,6 +103,10 @@ signals: void windowColorChanged(); + void focusEnableChanged(); + + void iconThemeChanged(); + private: QFont m_font; QPalette m_palette; @@ -102,6 +115,7 @@ private: bool m_isDark = false; double m_menuTransparency; QBrush m_windowColor; + bool m_focusEnable = false; }; inline int APPParameter::iconWidth() const diff --git a/ukui-qml-style-helper/styleparameter/icon.h b/ukui-qml-style-helper/styleparameter/icon.h index 58faa00..86bce2d 100644 --- a/ukui-qml-style-helper/styleparameter/icon.h +++ b/ukui-qml-style-helper/styleparameter/icon.h @@ -39,7 +39,7 @@ class Icon : public QObject public: explicit Icon(QObject *parent = nullptr); - enum Mode { Normal, Disabled, Hovered, Selected, Highlight }; + enum Mode { Normal, Disabled, Hovered, Selected, Highlight, HighDisabled }; }; } diff --git a/ukui-qml-style-helper/styleparameter/imageprovider.cpp b/ukui-qml-style-helper/styleparameter/imageprovider.cpp index ddb09cd..4108c38 100644 --- a/ukui-qml-style-helper/styleparameter/imageprovider.cpp +++ b/ukui-qml-style-helper/styleparameter/imageprovider.cpp @@ -37,10 +37,10 @@ QIcon IconHelper::loadIcon(const QString &id) //qDebug() << "path......" << id << path; if (!path.isEmpty()) { QPixmap pixmap; - isOk = loadPixmap(path, pixmap); - if (isOk) { - icon.addPixmap(pixmap); - } + isOk = initIcon(path, icon); +// if (isOk) { +// icon.addPixmap(pixmap); +// } } //qDebug() << "isOk..." << isOk; @@ -60,35 +60,29 @@ QIcon IconHelper::loadIcon(const QString &id) return icon; } -bool IconHelper::loadPixmap(const QString &path, QPixmap &pixmap) +bool IconHelper::initIcon(const QString &path, QIcon &icon) { if (!QFile::exists(path)) { - qWarning() << "Error: loadPixmap, File dose not exists." << path; + //qWarning() << "Error: initIcon, File dose not exists." << path; return false; } - return pixmap.load(path); + icon.addFile(path); + return true; } bool IconHelper::loadThemeIcon(const QString &name, QIcon &icon) { - //qDebug() << "loadThemeIcon....." << QIcon::hasThemeIcon(name); - if (!QIcon::hasThemeIcon(name)) { - return false; - } - //qDebug() << "loadThemeIcon 1111....." << QIcon::hasThemeIcon(name); - icon = QIcon::fromTheme(name); + if(icon.isNull()) + return false; return true; } void IconHelper::loadDefaultIcon(QIcon &icon) { if (!loadThemeIcon("application-x-desktop", icon)) { - QPixmap pixmap; - if (loadPixmap(":/res/icon/application-x-desktop.png", pixmap)) { - icon.addPixmap(pixmap); - } + initIcon(":/res/icon/application-x-desktop.png", icon); } } @@ -134,7 +128,10 @@ bool IconHelper::isRemoteServerFile(const QUrl &url) bool IconHelper::isThemeIcon(const QString &name) { - return QIcon::hasThemeIcon(name); + QIcon icon = QIcon::fromTheme(name); + if(icon.isNull()) + return false; + return true; } bool IconHelper::isLocalFile(const QUrl &url) @@ -154,15 +151,16 @@ QPixmap IconHelper::generatePixMap(const QString &id, Icon::Mode mode, const QSi ////qDebug() << "not isSymbolicColor..." << HighLightEffect::isPixmapPureColor(pixmap) << HighLightEffect::isSymbolicColor(pixmap); return pixmap; } - if(mode == Icon::Disabled){ -// Icon *icon = new Icon(); - pixmap = generatedDisablePixmap(pixmap); - } - else if(mode == Icon::Highlight){ + if(mode == Icon::Highlight || mode == Icon::HighDisabled){ ////qDebug() << "hightlight mode......."; pixmap = generatedHightlightPixmap(pixmap); } + if(mode == Icon::Disabled || mode == Icon::HighDisabled){ + // Icon *icon = new Icon(); + pixmap = generatedDisablePixmap(pixmap); + } + return pixmap; } @@ -173,6 +171,16 @@ QPixmap IconHelper::generatedDisablePixmap(QPixmap pixmap) // //Fix me:QT original code QImage im = target.toImage().convertToFormat(QImage::Format_ARGB32); + for (int y = 0; y < im.height(); y++) { + QRgb* scanLine = reinterpret_cast(im.scanLine(y)); + for (int x = 0; x < im.width(); x++) { + QRgb pixel = scanLine[x];//当前像素点 (r,g,b,a) + int curAlpha = qAlpha(pixel);//0-255整数值 + scanLine[x] = qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel), int(curAlpha * 0.45));//给当前像素点赋新值 + } + } + return QPixmap::fromImage(im); + /* // Create a colortable based on the background (black -> bg -> white) QColor bg = qApp->palette().color(QPalette::Disabled, QPalette::ButtonText); int red = bg.red(); @@ -242,6 +250,7 @@ QPixmap IconHelper::generatedDisablePixmap(QPixmap pixmap) // p.end(); // return target; + */ } @@ -270,7 +279,7 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize iconID = id.left(lastIndex); model = id.right(id.length() - lastIndex - 1); } - if(model != "normal" && model != "disenable" && model != "clicked" && model != "hover" && model != "highlight"){ + if(model != "normal" && model != "disenable" && model != "clicked" && model != "hover" && model != "highlight" && model != "highDisbale"){ iconID = id; model = ""; } @@ -286,9 +295,16 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize im = Icon::Hovered; else if(model == "highlight") im = Icon::Highlight; + else if(model == "highDisbale") + im = Icon::HighDisabled; QPixmap pixmap = IconHelper::generatePixMap(iconID, im, requestedSize, defaultSize); + if(!requestedSize.isEmpty() && pixmap.size() != requestedSize) + pixmap = pixmap.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + else if(requestedSize.isEmpty()) + pixmap = pixmap.scaled(defaultSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + if (size) { QSize pixmapSize = pixmap.size(); size->setWidth(pixmapSize.width()); diff --git a/ukui-qml-style-helper/styleparameter/imageprovider.h b/ukui-qml-style-helper/styleparameter/imageprovider.h index 42a7ce8..0b6b5e4 100644 --- a/ukui-qml-style-helper/styleparameter/imageprovider.h +++ b/ukui-qml-style-helper/styleparameter/imageprovider.h @@ -55,7 +55,7 @@ public: // 图标相关 // 从某个路径加载图标,并存入引用中,返回加载是否成功 - static bool loadPixmap(const QString &path, QPixmap &pixmap); + static bool initIcon(const QString &path, QIcon &icon); // 从路径或者主题加载图标 static QIcon loadIcon(const QString &id); diff --git a/ukui-qml-style-helper/styleparameter/parsecolorinterface.cpp b/ukui-qml-style-helper/styleparameter/parsecolorinterface.cpp index 3925658..77dad52 100644 --- a/ukui-qml-style-helper/styleparameter/parsecolorinterface.cpp +++ b/ukui-qml-style-helper/styleparameter/parsecolorinterface.cpp @@ -76,3 +76,14 @@ QString ParseColorInterface::endString(QString s, QString lastS) } return returnS; } + +QColor ParseColorInterface::getDtColor(QVariant dtColorkey) +{ + QString key = dtColorkey.toString(); + const char* c= key.toLocal8Bit().constData(); + if (!key.isEmpty() && qApp && qApp->property(c).isValid()){ + QBrush b = qApp->property(c).value(); + return b.color(); + } + return QColor(); +} diff --git a/ukui-qml-style-helper/styleparameter/parsecolorinterface.h b/ukui-qml-style-helper/styleparameter/parsecolorinterface.h index 6fc073f..c253fb7 100644 --- a/ukui-qml-style-helper/styleparameter/parsecolorinterface.h +++ b/ukui-qml-style-helper/styleparameter/parsecolorinterface.h @@ -54,6 +54,7 @@ public: Q_INVOKABLE QString endString(QString s, QString lasts); + Q_INVOKABLE QColor getDtColor(QVariant dtColorkey); }; } diff --git a/ukui-qml-style-helper/styleparameter/ukuibutton.cpp b/ukui-qml-style-helper/styleparameter/ukuibutton.cpp index e40bd32..a678e55 100644 --- a/ukui-qml-style-helper/styleparameter/ukuibutton.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuibutton.cpp @@ -22,15 +22,17 @@ UKUIButton::UKUIButton(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); - connect(qApp, &QApplication::paletteChanged, this, [=](const QPalette &pal){ - initParam(m_instance); - }, Qt::QueuedConnection); + connect(qApp, &QApplication::paletteChanged, this, [=](const QPalette &pal){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIButton::~UKUIButton() @@ -46,10 +48,10 @@ UKUIButton* UKUIButton::qmlAttachedProperties(QObject* parent) void UKUIButton::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setNormalBC(instance->buttonActive()); + setNormalBC(instance->kComponentNormal()); setClickedBC(instance->kComponentClick()); setHoveredBC(instance->kComponentHover()); - setDisableBC(instance->buttonDisable()); + setDisableBC(instance->kComponentDisable()); // qDebug() << "kComponentHover...." << instance->kComponentHover().gradient(); // if(instance->kComponentHover().gradient() && instance->kComponentHover().gradient()->stops().length() >= 2){ @@ -57,27 +59,27 @@ void UKUIButton::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) // qDebug() << "second1" << instance->kComponentHover().gradient()->stops().at(1).second; // } - setNormalHBC(instance->highLightActive()); + setNormalHBC(instance->kBrandNormal()); setHoveredHBC(instance->kBrandHover()); setClickedHBC(instance->kBrandClick()); - setDisableHBC(instance->highLightDisable()); + setDisableHBC(instance->kBrandDisable()); - setNormalTextColor(instance->buttonTextActive()); - setDisableTextColor(instance->buttonTextDisable()); - setHighlightTextColor(instance->highLightedTextActive()); - setHighlightTextDisableColor(instance->highLightedTextDisable()); + setNormalTextColor(instance->kFontPrimary()); + setDisableTextColor(instance->kFontPrimaryDisable()); + setHighlightTextColor(instance->kFontWhite()); + setHighlightTextDisableColor(instance->kFontWhiteDisable()); setBorderWidth(1); - setFocusBorderWidth(instance->focusline()); + setFocusBorderWidth(1);//instance->focusline()); setNormalBorderColor(instance->kLineComponentNormal()); setClickBorderColor(instance->kLineComponentClick()); setHoverBorderColor(instance->kLineComponentHover()); setDisableBorderColor(instance->kLineComponentDisable()); - setNormalBorderHColor(instance->kLineBrandNormal()); - setClickBorderHColor(instance->kLineBrandClick()); - setHoverBorderHColor(instance->kLineBrandHover()); - setDisableBorderHColor(instance->kLineBrandDisable()); + setNormalBorderHColor(instance->kLineComponentNormal()); + setClickBorderHColor(instance->kLineComponentClick()); + setHoverBorderHColor(instance->kLineComponentHover()); + setDisableBorderHColor(instance->kLineComponentDisable()); setFocusBorderColor(instance->kBrandFocus()); setRadius(instance->kradiusNormal()); @@ -86,19 +88,37 @@ void UKUIButton::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setClickedCloseBC(instance->kErrorClick()); setHoveredClosedBC(instance->kErrorHover()); setDisableCloseBC(instance->kGrayAlpha0()); - setNormalBorderCloseColor(instance->kLineComponentNormal()); - setHoverBorderCloseColor(instance->kLineComponentHover()); - setClickBorderCloseColor(instance->kLineComponentClick()); - setDisableBorderCloseColor(instance->kLineComponentDisable()); + setNormalBorderCloseColor(QBrush(QColor(0,0,0,0))); + setHoverBorderCloseColor(QBrush(QColor(0,0,0,0))); + setClickBorderCloseColor(QBrush(QColor(0,0,0,0))); + setDisableBorderCloseColor(QBrush(QColor(0,0,0,0))); setNormalWindowBC(instance->kGrayAlpha0()); - setClickedWindowBC(instance->kComponentAlphaClick()); - setHoveredWindowdBC(instance->kComponentAlphaHover()); + setClickedWindowBC(instance->kComponentClick()); + setHoveredWindowBC(instance->kComponentHover()); setDisableWindowBC(instance->kGrayAlpha0()); - setNormalBorderWindowColor(instance->kLineComponentNormal()); - setHoverBorderWindowColor(instance->kLineComponentHover()); - setClickBorderWindowColor(instance->kLineComponentClick()); - setDisableBorderWindowColor(instance->kLineComponentDisable()); + setNormalBorderWindowColor(QBrush(QColor(0,0,0,0))); + setHoverBorderWindowColor(QBrush(QColor(0,0,0,0))); + setClickBorderWindowColor(QBrush(QColor(0,0,0,0))); + setDisableBorderWindowColor(QBrush(QColor(0,0,0,0))); + + setNormalTransparentBC(instance->kComponentAlphaNormal()); + setHoveredTransparentBC(instance->kComponentAlphaHover()); + setClickedTransparentBC(instance->kComponentAlphaClick()); + setDisableTransparentBC(instance->kComponentAlphaDisable()); + setNormalBorderTransparentBC(instance->kLineComponentNormal()); + setHoveredBorderTransparentBC(instance->kLineComponentHover()); + setClickedBorderTransparentBC(instance->kLineComponentClick()); + setDisableBorderTransparentBC(instance->kLineComponentDisable()); + + setNormalWindowTransparentBC(instance->kGrayAlpha0()); + setClickedWindowTransparentBC(instance->kComponentAlphaClick()); + setHoveredWindowTransparentBC(instance->kComponentAlphaHover()); + setDisableWindowTransparentBC(instance->kGrayAlpha0()); + setNormalBorderWindowTransparentColor(QBrush(QColor(0,0,0,0))); + setHoveredBorderWindowTransparentColor(QBrush(QColor(0,0,0,0))); + setClickedBorderWindowTransparentColor(QBrush(QColor(0,0,0,0))); + setDisableBorderWindowTransparentColor(QBrush(QColor(0,0,0,0))); emit parametryChanged(); // qDebug() << "instance->highLightActive()..." << m_normalHBC.red() << m_normalHBC.green() << m_normalHBC.blue(); // qDebug() << "instance->setHoveredHBC()..." << m_hoveredHBC.red() << m_hoveredHBC.green() << m_hoveredHBC.blue(); @@ -618,7 +638,7 @@ const QBrush &UKUIButton::hoveredWindowBC() const return m_hoveredWindowBC; } -void UKUIButton::setHoveredWindowdBC(const QBrush &newHoveredWindowBC) +void UKUIButton::setHoveredWindowBC(const QBrush &newHoveredWindowBC) { if (m_hoveredWindowBC == newHoveredWindowBC) return; @@ -690,3 +710,211 @@ void UKUIButton::setDisableBorderWindowColor(const QBrush &newDisableBorderWindo m_disableBorderWindowColor = newDisableBorderWindowColor; emit disableBorderWindowColorChanged(); } + +const QBrush &UKUIButton::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUIButton::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUIButton::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUIButton::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUIButton::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUIButton::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUIButton::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUIButton::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} + +const QBrush &UKUIButton::normalBorderTransparentBC() const +{ + return m_normalBorderTransparentBC; +} + +void UKUIButton::setNormalBorderTransparentBC(const QBrush &newNormalBorderTransparentBC) +{ + if (m_normalBorderTransparentBC == newNormalBorderTransparentBC) + return; + m_normalBorderTransparentBC = newNormalBorderTransparentBC; + emit normalBorderTransparentBCChanged(); +} + +const QBrush &UKUIButton::clickedBorderTransparentBC() const +{ + return m_clickedBorderTransparentBC; +} + +void UKUIButton::setClickedBorderTransparentBC(const QBrush &newClickedBorderTransparentBC) +{ + if (m_clickedBorderTransparentBC == newClickedBorderTransparentBC) + return; + m_clickedBorderTransparentBC = newClickedBorderTransparentBC; + emit clickedBorderTransparentBCChanged(); +} + +const QBrush &UKUIButton::hoveredBorderTransparentBC() const +{ + return m_hoveredBorderTransparentBC; +} + +void UKUIButton::setHoveredBorderTransparentBC(const QBrush &newHoveredBorderTransparentBC) +{ + if (m_hoveredBorderTransparentBC == newHoveredBorderTransparentBC) + return; + m_hoveredBorderTransparentBC = newHoveredBorderTransparentBC; + emit hoveredBorderTransparentBCChanged(); +} + +const QBrush &UKUIButton::disableBorderTransparentBC() const +{ + return m_disableBorderTransparentBC; +} + +void UKUIButton::setDisableBorderTransparentBC(const QBrush &newDisableBorderTransparentBC) +{ + if (m_disableBorderTransparentBC == newDisableBorderTransparentBC) + return; + m_disableBorderTransparentBC = newDisableBorderTransparentBC; + emit disableBorderTransparentBCChanged(); +} + +const QBrush &UKUIButton::normalWindowTransparentBC() const +{ + return m_normalWindowTransparentBC; +} + +void UKUIButton::setNormalWindowTransparentBC(const QBrush &newNormalWindowTransparentBC) +{ + if (m_normalWindowTransparentBC == newNormalWindowTransparentBC) + return; + m_normalWindowTransparentBC = newNormalWindowTransparentBC; + emit normalWindowTransparentBCChanged(); +} + +const QBrush &UKUIButton::clickedWindowTransparentBC() const +{ + return m_clickedWindowTransparentBC; +} + +void UKUIButton::setClickedWindowTransparentBC(const QBrush &newClickedWindowTransparentBC) +{ + if (m_clickedWindowTransparentBC == newClickedWindowTransparentBC) + return; + m_clickedWindowTransparentBC = newClickedWindowTransparentBC; + emit clickedWindowTransparentBCChanged(); +} + +const QBrush &UKUIButton::hoveredWindowTransparentBC() const +{ + return m_hoveredWindowTransparentBC; +} + +void UKUIButton::setHoveredWindowTransparentBC(const QBrush &newHoveredWindowTransparentBC) +{ + if (m_hoveredWindowTransparentBC == newHoveredWindowTransparentBC) + return; + m_hoveredWindowTransparentBC = newHoveredWindowTransparentBC; + emit hoveredWindowTransparentBCChanged(); +} + +const QBrush &UKUIButton::disableWindowTransparentBC() const +{ + return m_disableWindowTransparentBC; +} + +void UKUIButton::setDisableWindowTransparentBC(const QBrush &newDisableWindowTransparentBC) +{ + if (m_disableWindowTransparentBC == newDisableWindowTransparentBC) + return; + m_disableWindowTransparentBC = newDisableWindowTransparentBC; + emit disableWindowTransparentBCChanged(); +} + +const QBrush &UKUIButton::normalBorderWindowTransparentColor() const +{ + return m_normalBorderWindowTransparentColor; +} + +void UKUIButton::setNormalBorderWindowTransparentColor(const QBrush &newNormalBorderWindowTransparentColor) +{ + if (m_normalBorderWindowTransparentColor == newNormalBorderWindowTransparentColor) + return; + m_normalBorderWindowTransparentColor = newNormalBorderWindowTransparentColor; + emit normalBorderWindowTransparentColorChanged(); +} + +const QBrush &UKUIButton::hoveredBorderWindowTransparentColor() const +{ + return m_hoveredBorderWindowTransparentColor; +} + +void UKUIButton::setHoveredBorderWindowTransparentColor(const QBrush &newHoveredBorderWindowTransparentColor) +{ + if (m_hoveredBorderWindowTransparentColor == newHoveredBorderWindowTransparentColor) + return; + m_hoveredBorderWindowTransparentColor = newHoveredBorderWindowTransparentColor; + emit hoveredBorderWindowTransparentColorChanged(); +} + +const QBrush &UKUIButton::clickedBorderWindowTransparentColor() const +{ + return m_clickedBorderWindowTransparentColor; +} + +void UKUIButton::setClickedBorderWindowTransparentColor(const QBrush &newClickedBorderWindowTransparentColor) +{ + if (m_clickedBorderWindowTransparentColor == newClickedBorderWindowTransparentColor) + return; + m_clickedBorderWindowTransparentColor = newClickedBorderWindowTransparentColor; + emit clickedBorderWindowTransparentColorChanged(); +} + +const QBrush &UKUIButton::disableBorderWindowTransparentColor() const +{ + return m_disableBorderWindowTransparentColor; +} + +void UKUIButton::setDisableBorderWindowTransparentColor(const QBrush &newDisableBorderWindowTransparentColor) +{ + if (m_disableBorderWindowTransparentColor == newDisableBorderWindowTransparentColor) + return; + m_disableBorderWindowTransparentColor = newDisableBorderWindowTransparentColor; + emit disableBorderWindowTransparentColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuibutton.h b/ukui-qml-style-helper/styleparameter/ukuibutton.h index 46742b2..5e57af9 100644 --- a/ukui-qml-style-helper/styleparameter/ukuibutton.h +++ b/ukui-qml-style-helper/styleparameter/ukuibutton.h @@ -84,13 +84,32 @@ class UKUIButton : public QQuickItem Q_PROPERTY(QBrush normalWindowBC READ normalWindowBC WRITE setNormalWindowBC NOTIFY normalWindowBCChanged) Q_PROPERTY(QBrush clickedWindowBC READ clickedWindowBC WRITE setClickedWindowBC NOTIFY clickedWindowBCChanged) - Q_PROPERTY(QBrush hoveredWindowBC READ hoveredWindowBC WRITE setHoveredWindowdBC NOTIFY hoveredWindowBCChanged) + Q_PROPERTY(QBrush hoveredWindowBC READ hoveredWindowBC WRITE setHoveredWindowBC NOTIFY hoveredWindowBCChanged) Q_PROPERTY(QBrush disableWindowBC READ disableWindowBC WRITE setDisableWindowBC NOTIFY disableWindowBCChanged) Q_PROPERTY(QBrush normalBorderWindowColor READ normalBorderWindowColor WRITE setNormalBorderWindowColor NOTIFY normalBorderWindowColorChanged) Q_PROPERTY(QBrush hoverBorderWindowColor READ hoverBorderWindowColor WRITE setHoverBorderWindowColor NOTIFY hoverBorderWindowColorChanged) Q_PROPERTY(QBrush clickBorderWindowColor READ clickBorderWindowColor WRITE setClickBorderWindowColor NOTIFY clickBorderWindowColorChanged) Q_PROPERTY(QBrush disableBorderWindowColor READ disableBorderWindowColor WRITE setDisableBorderWindowColor NOTIFY disableBorderWindowColorChanged) + + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + Q_PROPERTY(QBrush normalBorderTransparentBC READ normalBorderTransparentBC WRITE setNormalBorderTransparentBC NOTIFY normalBorderTransparentBCChanged) + Q_PROPERTY(QBrush clickedBorderTransparentBC READ clickedBorderTransparentBC WRITE setClickedBorderTransparentBC NOTIFY clickedBorderTransparentBCChanged) + Q_PROPERTY(QBrush hoveredBorderTransparentBC READ hoveredBorderTransparentBC WRITE setHoveredBorderTransparentBC NOTIFY hoveredBorderTransparentBCChanged) + Q_PROPERTY(QBrush disableBorderTransparentBC READ disableBorderTransparentBC WRITE setDisableBorderTransparentBC NOTIFY disableBorderTransparentBCChanged) + + Q_PROPERTY(QBrush normalWindowTransparentBC READ normalWindowTransparentBC WRITE setNormalWindowTransparentBC NOTIFY normalWindowTransparentBCChanged) + Q_PROPERTY(QBrush clickedWindowTransparentBC READ clickedWindowTransparentBC WRITE setClickedWindowTransparentBC NOTIFY clickedWindowTransparentBCChanged) + Q_PROPERTY(QBrush hoveredWindowTransparentBC READ hoveredWindowTransparentBC WRITE setHoveredWindowTransparentBC NOTIFY hoveredWindowTransparentBCChanged) + Q_PROPERTY(QBrush disableWindowTransparentBC READ disableWindowTransparentBC WRITE setDisableWindowTransparentBC NOTIFY disableWindowTransparentBCChanged) + Q_PROPERTY(QBrush normalBorderWindowTransparentColor READ normalBorderWindowTransparentColor WRITE setNormalBorderWindowTransparentColor NOTIFY normalBorderWindowTransparentColorChanged) + Q_PROPERTY(QBrush hoveredBorderWindowTransparentColor READ hoveredBorderWindowTransparentColor WRITE setHoveredBorderWindowTransparentColor NOTIFY hoveredBorderWindowTransparentColorChanged) + Q_PROPERTY(QBrush clickedBorderWindowTransparentColor READ clickedBorderWindowTransparentColor WRITE setClickedBorderWindowTransparentColor NOTIFY clickedBorderWindowTransparentColorChanged) + Q_PROPERTY(QBrush disableBorderWindowTransparentColor READ disableBorderWindowTransparentColor WRITE setDisableBorderWindowTransparentColor NOTIFY disableBorderWindowTransparentColorChanged) + public: explicit UKUIButton(QQuickItem *parent = nullptr); ~UKUIButton(); @@ -216,7 +235,7 @@ public: void setClickedWindowBC(const QBrush &newClickedWindowBC); const QBrush &hoveredWindowBC() const; - void setHoveredWindowdBC(const QBrush &newHoveredWindowBC); + void setHoveredWindowBC(const QBrush &newHoveredWindowBC); const QBrush &disableWindowBC() const; void setDisableWindowBC(const QBrush &newDisableWindowBC); @@ -233,6 +252,54 @@ public: const QBrush &disableBorderWindowColor() const; void setDisableBorderWindowColor(const QBrush &newDisableBorderWindowColor); + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + + const QBrush &normalBorderTransparentBC() const; + void setNormalBorderTransparentBC(const QBrush &newNormalBorderTransparentBC); + + const QBrush &clickedBorderTransparentBC() const; + void setClickedBorderTransparentBC(const QBrush &newClickedBorderTransparentBC); + + const QBrush &hoveredBorderTransparentBC() const; + void setHoveredBorderTransparentBC(const QBrush &newHoveredBorderTransparentBC); + + const QBrush &disableBorderTransparentBC() const; + void setDisableBorderTransparentBC(const QBrush &newDisableBorderTransparentBC); + + const QBrush &normalWindowTransparentBC() const; + void setNormalWindowTransparentBC(const QBrush &newNormalWindowTransparentBC); + + const QBrush &clickedWindowTransparentBC() const; + void setClickedWindowTransparentBC(const QBrush &newClickedWindowTransparentBC); + + const QBrush &hoveredWindowTransparentBC() const; + void setHoveredWindowTransparentBC(const QBrush &newHoveredWindowTransparentBC); + + const QBrush &disableWindowTransparentBC() const; + void setDisableWindowTransparentBC(const QBrush &newDisableWindowTransparentBC); + + const QBrush &normalBorderWindowTransparentColor() const; + void setNormalBorderWindowTransparentColor(const QBrush &newNormalBorderWindowTransparentColor); + + const QBrush &hoveredBorderWindowTransparentColor() const; + void setHoveredBorderWindowTransparentColor(const QBrush &newHoveredBorderWindowTransparentColor); + + const QBrush &clickedBorderWindowTransparentColor() const; + void setClickedBorderWindowTransparentColor(const QBrush &newClickedBorderWindowTransparentColor); + + const QBrush &disableBorderWindowTransparentColor() const; + void setDisableBorderWindowTransparentColor(const QBrush &newDisableBorderWindowTransparentColor); + signals: void radiusChanged(); @@ -326,9 +393,41 @@ signals: void disableBorderWindowColorChanged(); + void normalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + + void normalBorderTransparentBCChanged(); + + void clickedBorderTransparentBCChanged(); + + void hoveredBorderTransparentBCChanged(); + + void disableBorderTransparentBCChanged(); + + void normalWindowTransparentBCChanged(); + + void clickedWindowTransparentBCChanged(); + + void hoveredWindowTransparentBCChanged(); + + void disableWindowTransparentBCChanged(); + + void normalBorderWindowTransparentColorChanged(); + + void hoveredBorderWindowTransparentColorChanged(); + + void clickedBorderWindowTransparentColorChanged(); + + void disableBorderWindowTransparentColorChanged(); + private: double m_radius = 6.0; - double m_leftRightMargin = 4.0; + double m_leftRightMargin = 8.0; double m_upDownMargin = 4.0; double m_space = 4.0; int m_normalWidth = 96; @@ -356,7 +455,7 @@ private: QBrush m_disableBorderHColor ; QBrush m_focusBorderColor ; - UKUIGlobalDTConfig::GlobalDTConfig* m_instance ; + UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; QBrush m_highlightTextColor; QBrush m_highlightTextDisableColor; QBrush m_normalCloseBC; @@ -375,6 +474,22 @@ private: QBrush m_hoverBorderWindowColor; QBrush m_clickBorderWindowColor; QBrush m_disableBorderWindowColor; + QBrush m_normalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; + QBrush m_normalBorderTransparentBC; + QBrush m_clickedBorderTransparentBC; + QBrush m_hoveredBorderTransparentBC; + QBrush m_disableBorderTransparentBC; + QBrush m_normalWindowTransparentBC; + QBrush m_clickedWindowTransparentBC; + QBrush m_hoveredWindowTransparentBC; + QBrush m_disableWindowTransparentBC; + QBrush m_normalBorderWindowTransparentColor; + QBrush m_hoveredBorderWindowTransparentColor; + QBrush m_clickedBorderWindowTransparentColor; + QBrush m_disableBorderWindowTransparentColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIButton, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuicheckbox.cpp b/ukui-qml-style-helper/styleparameter/ukuicheckbox.cpp index a3aae11..778e6ff 100644 --- a/ukui-qml-style-helper/styleparameter/ukuicheckbox.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuicheckbox.cpp @@ -8,11 +8,13 @@ UKUICheckBox::UKUICheckBox(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUICheckBox::~UKUICheckBox() @@ -30,28 +32,37 @@ void UKUICheckBox::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { setNormalTextColor(instance->kFontPrimary()); setDisableTextColor(instance->kFontPrimaryDisable()); - setNormalIndicatorColor(instance->buttonActive()); + setNormalIndicatorColor(instance->kComponentNormal()); setHoverIndicatorColor(instance->kComponentHover()); setClickIndicatorColor(instance->kComponentClick()); - setDisableIndicatorColor(instance->buttonDisable()); - setNormalIndicatorBorderColor(instance->kLineNormal()); - setHoverIndicatorBorderColor(instance->kLineNormal()); - setClickIndicatorBorderColor(instance->kLineNormal()); - setDisableIndicatorBorderColor(instance->kLineDisable()); + setDisableIndicatorColor(instance->kComponentDisable()); + setNormalIndicatorBorderColor(instance->kLineSelectboxNormal()); + setHoverIndicatorBorderColor(instance->kLineSelectboxHover()); + setClickIndicatorBorderColor(instance->kLineSelectboxClick()); + setDisableIndicatorBorderColor(instance->kLineSelectboxDisable()); - setChecked_NormalIndicatorColor(instance->highLightActive()); + setChecked_NormalIndicatorColor(instance->kBrandNormal()); setChecked_HoverIndicatorColor(instance->kBrandHover()); setChecked_ClickIndicatorColor(instance->kBrandClick()); - setChecked_DisableIndicatorColor(instance->buttonDisable()); - setChecked_NormalIndicatorBorderColor(instance->kLineNormal()); - setChecked_HoverIndicatorBorderColor(instance->kLineNormal()); - setChecked_ClickIndicatorBorderColor(instance->kLineNormal()); - setChecked_DisableIndicatorBorderColor(instance->kLineDisable()); - - setChecked_NormalChildrenColor(instance->highLightedTextActive()); - setChecked_HoverChildrenColor(instance->highLightedTextActive()); - setChecked_ClickChildrenColor(instance->highLightedTextActive()); - setChecked_DisableChildrenColor(instance->highLightedTextDisable()); + setChecked_DisableIndicatorColor(instance->kBrandDisable()); + setChecked_NormalIndicatorBorderColor(instance->kLineSelectboxNormal()); + setChecked_HoverIndicatorBorderColor(instance->kLineSelectboxHover()); + setChecked_ClickIndicatorBorderColor(instance->kLineSelectboxClick()); + setChecked_DisableIndicatorBorderColor(instance->kLineSelectboxDisable()); + + setChecked_NormalChildrenColor(instance->kFontWhite()); + setChecked_HoverChildrenColor(instance->kFontWhite()); + setChecked_ClickChildrenColor(instance->kFontWhite()); + setChecked_DisableChildrenColor(instance->kFontWhiteDisable()); + + setNormalTransparentIndicatorColor(instance->kComponentAlphaNormal()); + setHoverTransparentIndicatorColor(instance->kComponentAlphaHover()); + setClickTransparentIndicatorColor(instance->kComponentAlphaClick()); + setDisableTransparentIndicatorColor(instance->kComponentAlphaDisable()); + setNormalTransparentIndicatorBorderColor(instance->kLineSelectboxNormal()); + setHoverTransparentIndicatorBorderColor(instance->kLineSelectboxNormal()); + setClickTransparentIndicatorBorderColor(instance->kLineSelectboxNormal()); + setDisableTransparentIndicatorBorderColor(instance->kLineSelectboxDisable()); setBorderWidth(instance->normalline()); setSpace(8); @@ -497,3 +508,107 @@ void UKUICheckBox::setRadius(int newRadius) m_radius = newRadius; emit radiusChanged(); } + +const QBrush &UKUICheckBox::normalTransparentIndicatorColor() const +{ + return m_normalTransparentIndicatorColor; +} + +void UKUICheckBox::setNormalTransparentIndicatorColor(const QBrush &newNormalTransparentIndicatorColor) +{ + if (m_normalTransparentIndicatorColor == newNormalTransparentIndicatorColor) + return; + m_normalTransparentIndicatorColor = newNormalTransparentIndicatorColor; + emit normalTransparentIndicatorColorChanged(); +} + +const QBrush &UKUICheckBox::hoverTransparentIndicatorColor() const +{ + return m_hoverTransparentIndicatorColor; +} + +void UKUICheckBox::setHoverTransparentIndicatorColor(const QBrush &newHoverTransparentIndicatorColor) +{ + if (m_hoverTransparentIndicatorColor == newHoverTransparentIndicatorColor) + return; + m_hoverTransparentIndicatorColor = newHoverTransparentIndicatorColor; + emit hoverTransparentIndicatorColorChanged(); +} + +const QBrush &UKUICheckBox::clickTransparentIndicatorColor() const +{ + return m_clickTransparentIndicatorColor; +} + +void UKUICheckBox::setClickTransparentIndicatorColor(const QBrush &newClickTransparentIndicatorColor) +{ + if (m_clickTransparentIndicatorColor == newClickTransparentIndicatorColor) + return; + m_clickTransparentIndicatorColor = newClickTransparentIndicatorColor; + emit clickTransparentIndicatorColorChanged(); +} + +const QBrush &UKUICheckBox::disableTransparentIndicatorColor() const +{ + return m_disableTransparentIndicatorColor; +} + +void UKUICheckBox::setDisableTransparentIndicatorColor(const QBrush &newDisableTransparentIndicatorColor) +{ + if (m_disableTransparentIndicatorColor == newDisableTransparentIndicatorColor) + return; + m_disableTransparentIndicatorColor = newDisableTransparentIndicatorColor; + emit disableTransparentIndicatorColorChanged(); +} + +const QBrush &UKUICheckBox::normalTransparentIndicatorBorderColor() const +{ + return m_normalTransparentIndicatorBorderColor; +} + +void UKUICheckBox::setNormalTransparentIndicatorBorderColor(const QBrush &newNormalTransparentIndicatorBorderColor) +{ + if (m_normalTransparentIndicatorBorderColor == newNormalTransparentIndicatorBorderColor) + return; + m_normalTransparentIndicatorBorderColor = newNormalTransparentIndicatorBorderColor; + emit normalTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUICheckBox::hoverTransparentIndicatorBorderColor() const +{ + return m_hoverTransparentIndicatorBorderColor; +} + +void UKUICheckBox::setHoverTransparentIndicatorBorderColor(const QBrush &newHoverTransparentIndicatorBorderColor) +{ + if (m_hoverTransparentIndicatorBorderColor == newHoverTransparentIndicatorBorderColor) + return; + m_hoverTransparentIndicatorBorderColor = newHoverTransparentIndicatorBorderColor; + emit hoverTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUICheckBox::clickTransparentIndicatorBorderColor() const +{ + return m_clickTransparentIndicatorBorderColor; +} + +void UKUICheckBox::setClickTransparentIndicatorBorderColor(const QBrush &newClickTransparentIndicatorBorderColor) +{ + if (m_clickTransparentIndicatorBorderColor == newClickTransparentIndicatorBorderColor) + return; + m_clickTransparentIndicatorBorderColor = newClickTransparentIndicatorBorderColor; + emit clickTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUICheckBox::disableTransparentIndicatorBorderColor() const +{ + return m_disableTransparentIndicatorBorderColor; +} + +void UKUICheckBox::setDisableTransparentIndicatorBorderColor(const QBrush &newDisableTransparentIndicatorBorderColor) +{ + if (m_disableTransparentIndicatorBorderColor == newDisableTransparentIndicatorBorderColor) + return; + m_disableTransparentIndicatorBorderColor = newDisableTransparentIndicatorBorderColor; + emit disableTransparentIndicatorBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuicheckbox.h b/ukui-qml-style-helper/styleparameter/ukuicheckbox.h index ee68c3b..a3c0580 100644 --- a/ukui-qml-style-helper/styleparameter/ukuicheckbox.h +++ b/ukui-qml-style-helper/styleparameter/ukuicheckbox.h @@ -71,6 +71,17 @@ class UKUICheckBox : public QQuickItem Q_PROPERTY(QBrush checked_clickChildrenBorderColor READ checked_clickChildrenBorderColor WRITE setChecked_ClickChildrenBorderColor NOTIFY checked_clickChildrenBorderColorChanged) Q_PROPERTY(QBrush checked_disableChildrenBorderColor READ checked_disableChildrenBorderColor WRITE setChecked_DisableChildrenBorderColor NOTIFY checked_disableChildrenBorderColorChanged) + + Q_PROPERTY(QBrush normalTransparentIndicatorColor READ normalTransparentIndicatorColor WRITE setNormalTransparentIndicatorColor NOTIFY normalTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush hoverTransparentIndicatorColor READ hoverTransparentIndicatorColor WRITE setHoverTransparentIndicatorColor NOTIFY hoverTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush clickTransparentIndicatorColor READ clickTransparentIndicatorColor WRITE setClickTransparentIndicatorColor NOTIFY clickTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush disableTransparentIndicatorColor READ disableTransparentIndicatorColor WRITE setDisableTransparentIndicatorColor NOTIFY disableTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush normalTransparentIndicatorBorderColor READ normalTransparentIndicatorBorderColor WRITE setNormalTransparentIndicatorBorderColor NOTIFY normalTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush hoverTransparentIndicatorBorderColor READ hoverTransparentIndicatorBorderColor WRITE setHoverTransparentIndicatorBorderColor NOTIFY hoverTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush clickTransparentIndicatorBorderColor READ clickTransparentIndicatorBorderColor WRITE setClickTransparentIndicatorBorderColor NOTIFY clickTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentIndicatorBorderColor READ disableTransparentIndicatorBorderColor WRITE setDisableTransparentIndicatorBorderColor NOTIFY disableTransparentIndicatorBorderColorChanged) + + Q_PROPERTY(int indicatorWidth READ indicatorWidth WRITE setIndicatorWidth NOTIFY indicatorWidthChanged) Q_PROPERTY(int childrenWidth READ childrenWidth WRITE setChildrenWidth NOTIFY childrenWidthChanged) Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged) @@ -182,6 +193,30 @@ public: int radius() const; void setRadius(int newRadius); + const QBrush &normalTransparentIndicatorColor() const; + void setNormalTransparentIndicatorColor(const QBrush &newNormalTransparentIndicatorColor); + + const QBrush &hoverTransparentIndicatorColor() const; + void setHoverTransparentIndicatorColor(const QBrush &newHoverTransparentIndicatorColor); + + const QBrush &clickTransparentIndicatorColor() const; + void setClickTransparentIndicatorColor(const QBrush &newClickTransparentIndicatorColor); + + const QBrush &disableTransparentIndicatorColor() const; + void setDisableTransparentIndicatorColor(const QBrush &newDisableTransparentIndicatorColor); + + const QBrush &normalTransparentIndicatorBorderColor() const; + void setNormalTransparentIndicatorBorderColor(const QBrush &newNormalTransparentIndicatorBorderColor); + + const QBrush &hoverTransparentIndicatorBorderColor() const; + void setHoverTransparentIndicatorBorderColor(const QBrush &newHoverTransparentIndicatorBorderColor); + + const QBrush &clickTransparentIndicatorBorderColor() const; + void setClickTransparentIndicatorBorderColor(const QBrush &newClickTransparentIndicatorBorderColor); + + const QBrush &disableTransparentIndicatorBorderColor() const; + void setDisableTransparentIndicatorBorderColor(const QBrush &newDisableTransparentIndicatorBorderColor); + signals: void leftRightMarginChanged(); @@ -252,6 +287,22 @@ signals: void parametryChanged(); + void normalTransparentIndicatorColorChanged(); + + void hoverTransparentIndicatorColorChanged(); + + void clickTransparentIndicatorColorChanged(); + + void disableTransparentIndicatorColorChanged(); + + void normalTransparentIndicatorBorderColorChanged(); + + void hoverTransparentIndicatorBorderColorChanged(); + + void clickTransparentIndicatorBorderColorChanged(); + + void disableTransparentIndicatorBorderColorChanged(); + private: double m_leftRightMargin; double m_upDownMargin; @@ -287,8 +338,16 @@ private: int m_childrenWidth; int m_radius; - UKUIGlobalDTConfig::GlobalDTConfig* m_instance ; + UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_normalTransparentIndicatorColor; + QBrush m_hoverTransparentIndicatorColor; + QBrush m_clickTransparentIndicatorColor; + QBrush m_disableTransparentIndicatorColor; + QBrush m_normalTransparentIndicatorBorderColor; + QBrush m_hoverTransparentIndicatorBorderColor; + QBrush m_clickTransparentIndicatorBorderColor; + QBrush m_disableTransparentIndicatorBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUICheckBox, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuicombobox.cpp b/ukui-qml-style-helper/styleparameter/ukuicombobox.cpp index 5d90fbd..ce41b19 100644 --- a/ukui-qml-style-helper/styleparameter/ukuicombobox.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuicombobox.cpp @@ -8,11 +8,13 @@ UKUIComboBox::UKUIComboBox(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIComboBox::~UKUIComboBox() @@ -28,7 +30,7 @@ UKUIComboBox* UKUIComboBox::qmlAttachedProperties(QObject* parent) void UKUIComboBox::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setLeftRightPadding(instance->tokenGap8()); + setLeftRightPadding(8); setRadius(instance->kradiusNormal()); setBorderWidth(instance->normalline()); setFocusBorderWidth(instance->focusline()); @@ -36,13 +38,26 @@ void UKUIComboBox::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setNormalHeight(36); setUpDownMargin(6); setLeftRightPadding(6); - setNormalBC(instance->buttonActive()); + setNormalBC(instance->kComponentNormal()); + setHoveredBC(instance->kComponentHover()); + setClickedBC(instance->kComponentClick()); + setDisableBC(instance->kComponentDisable()); setNormalBorderColor(instance->kLineComponentNormal()); + setHoveredBorderColor(instance->kLineComponentHover()); + setClickBorderColor(instance->kLineComponentClick()); setDisableBorderColor(instance->kLineComponentDisable()); setFocusBorderColor(instance->kBrandFocus()); setNormalTextColor(instance->buttonTextActive()); setDisableTextColor(instance->buttonTextDisable()); + setNormalTransparentBC(instance->kComponentAlphaNormal()); + setClickedTransparentBC(instance->kComponentAlphaClick()); + setHoveredTransparentBC(instance->kComponentAlphaHover()); + setDisableTransparentBC(instance->kComponentAlphaDisable()); + setNormalTransparentBorderColor(instance->kLineComponentNormal()); + setClickedTransparentBorderColor(instance->kLineComponentNormal()); + setHoveredTransparentBorderColor(instance->kLineComponentNormal()); + setDisableTransparentBorderColor(instance->kLineComponentDisable()); emit parametryChanged(); } @@ -280,3 +295,120 @@ void UKUIComboBox::setFocusBorderColor(QBrush newFocusBorderColor) emit focusBorderColorChanged(); } } + +const QBrush &UKUIComboBox::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUIComboBox::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUIComboBox::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUIComboBox::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUIComboBox::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUIComboBox::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUIComboBox::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUIComboBox::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} + +const QBrush &UKUIComboBox::hoveredBorderColor() const +{ + return m_hoveredBorderColor; +} + +void UKUIComboBox::setHoveredBorderColor(const QBrush &newHoveredBorderColor) +{ + if (m_hoveredBorderColor == newHoveredBorderColor) + return; + m_hoveredBorderColor = newHoveredBorderColor; + emit hoveredBorderColorChanged(); +} + +const QBrush &UKUIComboBox::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUIComboBox::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} + +const QBrush &UKUIComboBox::clickedTransparentBorderColor() const +{ + return m_clickedTransparentBorderColor; +} + +void UKUIComboBox::setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor) +{ + if (m_clickedTransparentBorderColor == newClickedTransparentBorderColor) + return; + m_clickedTransparentBorderColor = newClickedTransparentBorderColor; + emit clickedTransparentBorderColorChanged(); +} + +const QBrush &UKUIComboBox::hoveredTransparentBorderColor() const +{ + return m_hoveredTransparentBorderColor; +} + +void UKUIComboBox::setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor) +{ + if (m_hoveredTransparentBorderColor == newHoveredTransparentBorderColor) + return; + m_hoveredTransparentBorderColor = newHoveredTransparentBorderColor; + emit hoveredTransparentBorderColorChanged(); +} + +const QBrush &UKUIComboBox::disableTransparentBorderColor() const +{ + return m_disableTransparentBorderColor; +} + +void UKUIComboBox::setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor) +{ + if (m_disableTransparentBorderColor == newDisableTransparentBorderColor) + return; + m_disableTransparentBorderColor = newDisableTransparentBorderColor; + emit disableTransparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuicombobox.h b/ukui-qml-style-helper/styleparameter/ukuicombobox.h index 95e6881..9d030f1 100644 --- a/ukui-qml-style-helper/styleparameter/ukuicombobox.h +++ b/ukui-qml-style-helper/styleparameter/ukuicombobox.h @@ -52,10 +52,21 @@ class UKUIComboBox : public QQuickItem Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) Q_PROPERTY(int focusBorderWidth READ focusBorderWidth WRITE setFocusBorderWidth NOTIFY focusBorderWidthChanged) Q_PROPERTY(QBrush normalBorderColor READ normalBorderColor WRITE setNormalBorderColor NOTIFY normalBorderColorChanged) + Q_PROPERTY(QBrush hoveredBorderColor READ hoveredBorderColor WRITE setHoveredBorderColor NOTIFY hoveredBorderColorChanged) Q_PROPERTY(QBrush clickBorderColor READ clickBorderColor WRITE setClickBorderColor NOTIFY clickBorderColorChanged) Q_PROPERTY(QBrush disableBorderColor READ disableBorderColor WRITE setDisableBorderColor NOTIFY disableBorderColorChanged) Q_PROPERTY(QBrush focusBorderColor READ focusBorderColor WRITE setFocusBorderColor NOTIFY focusBorderColorChanged) + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickedTransparentBorderColor READ clickedTransparentBorderColor WRITE setClickedTransparentBorderColor NOTIFY clickedTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoveredTransparentBorderColor READ hoveredTransparentBorderColor WRITE setHoveredTransparentBorderColor NOTIFY hoveredTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentBorderColor READ disableTransparentBorderColor WRITE setDisableTransparentBorderColor NOTIFY disableTransparentBorderColorChanged) + public: explicit UKUIComboBox(QQuickItem *parent = nullptr); @@ -120,6 +131,33 @@ public: Q_INVOKABLE QBrush focusBorderColor() const; void setFocusBorderColor(QBrush newFocusBorderColor); + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + + const QBrush &hoveredBorderColor() const; + void setHoveredBorderColor(const QBrush &newHoveredBorderColor); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + + const QBrush &clickedTransparentBorderColor() const; + void setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor); + + const QBrush &hoveredTransparentBorderColor() const; + void setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor); + + const QBrush &disableTransparentBorderColor() const; + void setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor); + signals: void radiusChanged(); @@ -160,6 +198,24 @@ signals: void parametryChanged(); + void normalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + + void hoveredBorderColorChanged(); + + void normalTransparentBorderColorChanged(); + + void clickedTransparentBorderColorChanged(); + + void hoveredTransparentBorderColorChanged(); + + void disableTransparentBorderColorChanged(); + private: double m_radius; @@ -182,8 +238,17 @@ private: Q_INVOKABLE QBrush m_disableBorderColor ; Q_INVOKABLE QBrush m_focusBorderColor ; - UKUIGlobalDTConfig::GlobalDTConfig* m_instance ; - + UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + + QBrush m_normalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; + QBrush m_hoveredBorderColor; + QBrush m_normalTransparentBorderColor; + QBrush m_clickedTransparentBorderColor; + QBrush m_hoveredTransparentBorderColor; + QBrush m_disableTransparentBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIComboBox, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuiheaderview.cpp b/ukui-qml-style-helper/styleparameter/ukuiheaderview.cpp new file mode 100644 index 0000000..f4df86f --- /dev/null +++ b/ukui-qml-style-helper/styleparameter/ukuiheaderview.cpp @@ -0,0 +1,92 @@ +#include +#include "ukuiheaderview.h" +#include "qdebug.h" +using namespace UKUIQQC2Style; + +UKUIHeaderView::UKUIHeaderView(QQuickItem *parent) : QQuickItem(parent) +{ + if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) + return; + TokenParameter * token = qApp->property("qqc2-globaltoken").value(); + if(token && token->getInstance()){ + m_instance = token->getInstance(); + initParam(m_instance); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } +} + +UKUIHeaderView::~UKUIHeaderView() +{ + +} + +UKUIHeaderView* UKUIHeaderView::qmlAttachedProperties(QObject* parent) +{ + auto p = qobject_cast(parent); + return new UKUIHeaderView(p); +} + +void UKUIHeaderView::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) +{ + setNormalTextColor(m_instance->kFontPrimary()); + setLineColor(m_instance->kLineInputNormal()); + setLineWidth(1); + setnormalHeight(36); + emit parametryChanged(); +} + + +const QBrush &UKUIHeaderView::normalTextColor() const +{ + return m_normalTextColor; +} + +void UKUIHeaderView::setNormalTextColor(const QBrush &newNormalTextColor) +{ + if (m_normalTextColor == newNormalTextColor) + return; + m_normalTextColor = newNormalTextColor; + emit normalTextColorChanged(); +} + +const QBrush &UKUIHeaderView::lineColor() const +{ + return m_lineColor; +} + +void UKUIHeaderView::setLineColor(const QBrush &newLineColor) +{ + if (m_lineColor == newLineColor) + return; + m_lineColor = newLineColor; + emit lineColorChanged(); +} + + +int UKUIHeaderView::lineWidth() const +{ + return m_lineWidth; +} + +void UKUIHeaderView::setLineWidth(int newLineWidth) +{ + if (m_lineWidth == newLineWidth) + return; + m_lineWidth = newLineWidth; + emit lineWidthChanged(); +} + +int UKUIHeaderView::normalHeight() const +{ + return m_normalHeight; +} + +void UKUIHeaderView::setnormalHeight(int newNormalHeight) +{ + if (m_normalHeight == newNormalHeight) + return; + m_normalHeight = newNormalHeight; + emit lineWidthChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiheaderview.h b/ukui-qml-style-helper/styleparameter/ukuiheaderview.h new file mode 100644 index 0000000..a3ce75b --- /dev/null +++ b/ukui-qml-style-helper/styleparameter/ukuiheaderview.h @@ -0,0 +1,86 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +#ifndef UKUIHeaderView_H +#define UKUIHeaderView_H + +#include +#include +#include +#include +#include "tokenparameter.h" + +namespace UKUIQQC2Style { + +class UKUIHeaderView : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(QBrush normalTextColor READ normalTextColor WRITE setNormalTextColor NOTIFY normalTextColorChanged) + Q_PROPERTY(QBrush lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged) + Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged) + Q_PROPERTY(int normalHeight READ normalHeight WRITE setnormalHeight NOTIFY lineWidthChanged) + + +public: + explicit UKUIHeaderView(QQuickItem *parent = nullptr); + ~UKUIHeaderView(); + + static UKUIHeaderView* qmlAttachedProperties(QObject* parent); + + void initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance); + + const QBrush &normalTextColor() const; + void setNormalTextColor(const QBrush &newNormalTextColor); + + const QBrush &lineColor() const; + void setLineColor(const QBrush &newLineColor); + + int lineWidth() const; + void setLineWidth(int newLineWidth); + + int normalHeight() const; + void setnormalHeight(int newNormalHeight); + +signals: + + void parametryChanged(); + + void normalTextColorChanged(); + + void lineColorChanged(); + + void lineWidthChanged(); + +private: + + UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + + QBrush m_normalTextColor; + QBrush m_lineColor; + int m_lineWidth; + int m_normalHeight; +}; +} +QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIHeaderView, QML_HAS_ATTACHED_PROPERTIES) + +#endif // UKUIHeaderView_H diff --git a/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.cpp b/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.cpp index f12bbe8..9ff1be1 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.cpp @@ -8,11 +8,13 @@ UKUIItemDelegate::UKUIItemDelegate(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIItemDelegate::~UKUIItemDelegate() @@ -24,8 +26,10 @@ void UKUIItemDelegate::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { setPadding(12); setRadius(instance->kradiusNormal()); - setNormalTextColor(instance->textActive()); - setDisableTextColor(instance->textDisable()); + setNormalTextColor(instance->kFontPrimary()); + setDisableTextColor(instance->kFontPrimaryDisable()); + setNormalHTextColor(instance->kFontWhite()); + setDisableHTextColor(instance->kFontWhiteDisable()); setNormalBC(QBrush(QColor(0,0,0,0))); setClickedBC(instance->kContainClick()); @@ -33,24 +37,56 @@ void UKUIItemDelegate::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setDisableBC(QBrush(QColor(0,0,0,0))); setBorderWidth(1); - setNormalBorderColor(instance->kLineComponentNormal()); - setClickBorderColor(instance->kLineComponentClick()); - setHoverBorderColor(instance->kLineComponentHover()); - setDisableBorderColor(instance->kLineComponentDisable()); + setNormalBorderColor(QBrush(QColor(0,0,0,0))); + setClickBorderColor(QBrush(QColor(0,0,0,0))); + setHoverBorderColor(QBrush(QColor(0,0,0,0))); + setDisableBorderColor(QBrush(QColor(0,0,0,0))); - setNormalHBC(instance->highLightActive()); + setNormalHBC(instance->kBrandNormal()); setNormalBorderHColor(instance->kLineBrandNormal()); setHoveredHBC(instance->kBrandHover()); setHoverBorderHColor(instance->kLineBrandHover()); setClickedHBC(instance->kBrandClick()); setClickBorderHColor(instance->kLineBrandClick()); + setDisableHBC(instance->kBrandDisable()); + setDisableBorderHColor(QBrush(QColor(0,0,0,0))); + + setNormalCheckedBC(instance->kComponentSelectedNormal()); + setNormalBorderCheckedColor(QBrush(QColor(0,0,0,0))); + setHoveredCheckedBC(instance->kComponentSelectedHover()); + setHoverBorderCheckedColor(QBrush(QColor(0,0,0,0))); + setClickedCheckedBC(instance->kComponentSelectedClick()); + setClickBorderCheckedColor(QBrush(QColor(0,0,0,0))); + setDisableCheckedBC(instance->kComponentSelectedDisable()); + setDisableBorderCheckedColor(QBrush(QColor(0,0,0,0))); + + setNormalTransparentBC(QBrush(QColor(0,0,0,0))); + setHoveredTransparentBC(instance->kContainAlphaHover()); + setClickedTransparentBC(instance->kContainAlphaClick()); + setDisableTransparentBC(QBrush(QColor(0,0,0,0))); + setNormalTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setHoveredTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setClickedTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setDisableTransparentBorderColor(QBrush(QColor(0,0,0,0))); + + setNormalCheckedTransparentBC(instance->kComponentSelectedAlphaNormal()); + setHoveredCheckedTransparentBC(instance->kComponentSelectedAlphaHover()); + setClickedCheckedTransparentBC(instance->kComponentSelectedAlphaClick()); + setDisableCheckedTransparentBC(instance->kComponentSelectedAlphaDisable()); + setNormalCheckedTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setHoveredCheckedTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setClickedCheckedTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setDisableCheckedTransparentBorderColor(QBrush(QColor(0,0,0,0))); + + setNormalAlternateBC(instance->kContainSecondaryNormal()); + setClickedAlternateBC(instance->kContainClick()); + setHoveredAlternateBC(instance->kContainHover()); + setDisableAlternateBC(instance->kContainSecondaryNormal()); + setNormalAlternateTransparentBC(instance->kContainSecondaryAlphaNormal()); + setClickedAlternateTransparentBC(instance->kContainAlphaClick()); + setHoveredAlternateTransparentBC(instance->kContainAlphaHover()); + setDisableAlternateTransparentBC(instance->kContainSecondaryAlphaNormal()); - setNormalCheckedBC(instance->buttonActive()); - setNormalBorderCheckedColor(instance->kLineComponentNormal()); - setHoveredCheckedBC(instance->kComponentHover()); - setHoverBorderCheckedColor(instance->kLineComponentNormal()); - setClickedCheckedBC(instance->kComponentClick()); - setClickBorderCheckedColor(instance->kLineComponentNormal()); emit parametryChanged(); } @@ -399,3 +435,393 @@ void UKUIItemDelegate::setPadding(int newPadding) m_padding = newPadding; emit paddingChanged(); } + +const QBrush &UKUIItemDelegate::normalHTextColor() const +{ + return m_normalHTextColor; +} + +void UKUIItemDelegate::setNormalHTextColor(const QBrush &newNormalHTextColor) +{ + if (m_normalHTextColor == newNormalHTextColor) + return; + m_normalHTextColor = newNormalHTextColor; + emit normalHTextColorChanged(); +} + +const QBrush &UKUIItemDelegate::disableHTextColor() const +{ + return m_disableHTextColor; +} + +void UKUIItemDelegate::setDisableHTextColor(const QBrush &newDisableHTextColor) +{ + if (m_disableHTextColor == newDisableHTextColor) + return; + m_disableHTextColor = newDisableHTextColor; + emit disableHTextColorChanged(); +} + +const QBrush &UKUIItemDelegate::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUIItemDelegate::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUIItemDelegate::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUIItemDelegate::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUIItemDelegate::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUIItemDelegate::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::clickedTransparentBorderColor() const +{ + return m_clickedTransparentBorderColor; +} + +void UKUIItemDelegate::setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor) +{ + if (m_clickedTransparentBorderColor == newClickedTransparentBorderColor) + return; + m_clickedTransparentBorderColor = newClickedTransparentBorderColor; + emit clickedTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::hoveredTransparentBorderColor() const +{ + return m_hoveredTransparentBorderColor; +} + +void UKUIItemDelegate::setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor) +{ + if (m_hoveredTransparentBorderColor == newHoveredTransparentBorderColor) + return; + m_hoveredTransparentBorderColor = newHoveredTransparentBorderColor; + emit hoveredTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::disableTransparentBorderColor() const +{ + return m_disableTransparentBorderColor; +} + +void UKUIItemDelegate::setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor) +{ + if (m_disableTransparentBorderColor == newDisableTransparentBorderColor) + return; + m_disableTransparentBorderColor = newDisableTransparentBorderColor; + emit disableTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::disableHBC() const +{ + return m_disableHBC; +} + +void UKUIItemDelegate::setDisableHBC(const QBrush &newDisableHBC) +{ + if (m_disableHBC == newDisableHBC) + return; + m_disableHBC = newDisableHBC; + emit disabledHBCChanged(); +} + +const QBrush &UKUIItemDelegate::disableBorderHColor() const +{ + return m_disableBorderHColor; +} + +void UKUIItemDelegate::setDisableBorderHColor(const QBrush &newDisableBorderHColor) +{ + if (m_disableBorderHColor == newDisableBorderHColor) + return; + m_disableBorderHColor = newDisableBorderHColor; + emit disabledBorderHColorChanged(); +} + +const QBrush &UKUIItemDelegate::disableCheckedBC() const +{ + return m_disableCheckedBC; +} + +void UKUIItemDelegate::setDisableCheckedBC(const QBrush &newDisableCheckedBC) +{ + if (m_disableCheckedBC == newDisableCheckedBC) + return; + m_disableCheckedBC = newDisableCheckedBC; + emit disableCheckedBCChanged(); +} + +const QBrush &UKUIItemDelegate::disableBorderCheckedColor() const +{ + return m_disableBorderCheckedColor; +} + +void UKUIItemDelegate::setDisableBorderCheckedColor(const QBrush &newDisableBorderCheckedColor) +{ + if (m_disableBorderCheckedColor == newDisableBorderCheckedColor) + return; + m_disableBorderCheckedColor = newDisableBorderCheckedColor; + emit disableBorderCheckedColorChanged(); +} + +const QBrush &UKUIItemDelegate::normalCheckedTransparentBC() const +{ + return m_normalCheckedTransparentBC; +} + +void UKUIItemDelegate::setNormalCheckedTransparentBC(const QBrush &newNormalCheckedTransparentBC) +{ + if (m_normalCheckedTransparentBC == newNormalCheckedTransparentBC) + return; + m_normalCheckedTransparentBC = newNormalCheckedTransparentBC; + emit normalCheckedTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::clickedCheckedTransparentBC() const +{ + return m_clickedCheckedTransparentBC; +} + +void UKUIItemDelegate::setClickedCheckedTransparentBC(const QBrush &newClickedCheckedTransparentBC) +{ + if (m_clickedCheckedTransparentBC == newClickedCheckedTransparentBC) + return; + m_clickedCheckedTransparentBC = newClickedCheckedTransparentBC; + emit clickedCheckedTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::hoveredCheckedTransparentBC() const +{ + return m_hoveredCheckedTransparentBC; +} + +void UKUIItemDelegate::setHoveredCheckedTransparentBC(const QBrush &newHoveredCheckedTransparentBC) +{ + if (m_hoveredCheckedTransparentBC == newHoveredCheckedTransparentBC) + return; + m_hoveredCheckedTransparentBC = newHoveredCheckedTransparentBC; + emit hoveredCheckedTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::disableCheckedTransparentBC() const +{ + return m_disableCheckedTransparentBC; +} + +void UKUIItemDelegate::setDisableCheckedTransparentBC(const QBrush &newDisableCheckedTransparentBC) +{ + if (m_disableCheckedTransparentBC == newDisableCheckedTransparentBC) + return; + m_disableCheckedTransparentBC = newDisableCheckedTransparentBC; + emit disableCheckedTransparentBCChanged(); +} + +const QBrush &UKUIItemDelegate::normalCheckedTransparentBorderColor() const +{ + return m_normalCheckedTransparentBorderColor; +} + +void UKUIItemDelegate::setNormalCheckedTransparentBorderColor(const QBrush &newNormalCheckedTransparentBorderColor) +{ + if (m_normalCheckedTransparentBorderColor == newNormalCheckedTransparentBorderColor) + return; + m_normalCheckedTransparentBorderColor = newNormalCheckedTransparentBorderColor; + emit normalCheckedTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::clickedCheckedTransparentBorderColor() const +{ + return m_clickedCheckedTransparentBorderColor; +} + +void UKUIItemDelegate::setClickedCheckedTransparentBorderColor(const QBrush &newClickedCheckedTransparentBorderColor) +{ + if (m_clickedCheckedTransparentBorderColor == newClickedCheckedTransparentBorderColor) + return; + m_clickedCheckedTransparentBorderColor = newClickedCheckedTransparentBorderColor; + emit clickedCheckedTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::hoveredCheckedTransparentBorderColor() const +{ + return m_hoveredCheckedTransparentBorderColor; +} + +void UKUIItemDelegate::setHoveredCheckedTransparentBorderColor(const QBrush &newHoveredCheckedTransparentBorderColor) +{ + if (m_hoveredCheckedTransparentBorderColor == newHoveredCheckedTransparentBorderColor) + return; + m_hoveredCheckedTransparentBorderColor = newHoveredCheckedTransparentBorderColor; + emit hoveredCheckedTransparentBorderColorChanged(); +} + +const QBrush &UKUIItemDelegate::disableCheckedTransparentBorderColor() const +{ + return m_disableCheckedTransparentBorderColor; +} + +void UKUIItemDelegate::setDisableCheckedTransparentBorderColor(const QBrush &newDisableCheckedTransparentBorderColor) +{ + if (m_disableCheckedTransparentBorderColor == newDisableCheckedTransparentBorderColor) + return; + m_disableCheckedTransparentBorderColor = newDisableCheckedTransparentBorderColor; + emit disableCheckedTransparentBorderColorChanged(); +} + +QBrush UKUIItemDelegate::normalAlternateBC() const +{ + return m_normalAlternateBC; +} + +void UKUIItemDelegate::setNormalAlternateBC(const QBrush &newNormalAlternateBC) +{ + if (m_normalAlternateBC == newNormalAlternateBC) + return; + m_normalAlternateBC = newNormalAlternateBC; + emit normalAlternateBCChanged(); +} + +QBrush UKUIItemDelegate::clickedAlternateBC() const +{ + return m_clickedAlternatedBC; +} + +void UKUIItemDelegate::setClickedAlternateBC(const QBrush &newClickedAlternatedBC) +{ + if (m_clickedAlternatedBC == newClickedAlternatedBC) + return; + m_clickedAlternatedBC = newClickedAlternatedBC; + emit clickedAlternateBCChanged(); +} + +QBrush UKUIItemDelegate::hoveredAlternateBC() const +{ + return m_hoveredAlternatedBC; +} + +void UKUIItemDelegate::setHoveredAlternateBC(const QBrush &newHoveredAlternatedBC) +{ + if (m_hoveredAlternatedBC == newHoveredAlternatedBC) + return; + m_hoveredAlternatedBC = newHoveredAlternatedBC; + emit hoveredAlternateBCChanged(); +} + +QBrush UKUIItemDelegate::disableAlternateBC() const +{ + return m_disableAlternateBC; +} + +void UKUIItemDelegate::setDisableAlternateBC(const QBrush &newDisableAlternateBC) +{ + if (m_disableAlternateBC == newDisableAlternateBC) + return; + m_disableAlternateBC = newDisableAlternateBC; + emit disableAlternateBCChanged(); +} + +QBrush UKUIItemDelegate::normalAlternateTransparentBC() const +{ + return m_normalAlternateTransparentBC; +} + +void UKUIItemDelegate::setNormalAlternateTransparentBC(const QBrush &newNormalAlternateTransparentBC) +{ + if (m_normalAlternateTransparentBC == newNormalAlternateTransparentBC) + return; + m_normalAlternateTransparentBC = newNormalAlternateTransparentBC; + emit normalAlternateTransparentBCChanged(); +} + +QBrush UKUIItemDelegate::clickedAlternateTransparentBC() const +{ + return m_clickedAlternateTransparentBC; +} + +void UKUIItemDelegate::setClickedAlternateTransparentBC(const QBrush &newClickedAlternateTransparentBC) +{ + if (m_clickedAlternateTransparentBC == newClickedAlternateTransparentBC) + return; + m_clickedAlternateTransparentBC = newClickedAlternateTransparentBC; + emit clickedAlternateTransparentBCChanged(); +} + +QBrush UKUIItemDelegate::hoveredAlternateTransparentBC() const +{ + return m_hoveredAlternateTransparentBC; +} + +void UKUIItemDelegate::setHoveredAlternateTransparentBC(const QBrush &newHoveredAlternateTransparentBC) +{ + if (m_hoveredAlternateTransparentBC == newHoveredAlternateTransparentBC) + return; + m_hoveredAlternateTransparentBC = newHoveredAlternateTransparentBC; + emit hoveredAlternateTransparentBCChanged(); +} + +QBrush UKUIItemDelegate::disableAlternateTransparentBC() const +{ + return m_disableAlternateTransparentBC; +} + +void UKUIItemDelegate::setDisableAlternateTransparentBC(const QBrush &newDisableAlternateTransparentBC) +{ + if (m_disableAlternateTransparentBC == newDisableAlternateTransparentBC) + return; + m_disableAlternateTransparentBC = newDisableAlternateTransparentBC; + emit disableAlternateTransparentBCChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.h b/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.h index 01816e2..f36361b 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.h +++ b/ukui-qml-style-helper/styleparameter/ukuiitemdelegate.h @@ -54,21 +54,56 @@ class UKUIItemDelegate : public QQuickItem Q_PROPERTY(QBrush clickBorderColor READ clickBorderColor WRITE setClickBorderColor NOTIFY clickBorderColorChanged) Q_PROPERTY(QBrush disableBorderColor READ disableBorderColor WRITE setDisableBorderColor NOTIFY disableBorderColorChanged) + Q_PROPERTY(QBrush normalHTextColor READ normalHTextColor WRITE setNormalHTextColor NOTIFY normalHTextColorChanged) + Q_PROPERTY(QBrush disableHTextColor READ disableHTextColor WRITE setDisableHTextColor NOTIFY disableHTextColorChanged) Q_PROPERTY(QBrush normalHBC READ normalHBC WRITE setNormalHBC NOTIFY normalHBCChanged) Q_PROPERTY(QBrush clickedHBC READ clickedHBC WRITE setClickedHBC NOTIFY clickedHBCChanged) Q_PROPERTY(QBrush hoveredHBC READ hoveredHBC WRITE setHoveredHBC NOTIFY hoveredHBCChanged) + Q_PROPERTY(QBrush disableHBC READ disableHBC WRITE setDisableHBC NOTIFY disabledHBCChanged) Q_PROPERTY(QBrush normalBorderHColor READ normalBorderHColor WRITE setNormalBorderHColor NOTIFY normalBorderHColorChanged) Q_PROPERTY(QBrush hoverBorderHColor READ hoverBorderHColor WRITE setHoverBorderHColor NOTIFY hoverBorderHColorChanged) Q_PROPERTY(QBrush clickBorderHColor READ clickBorderHColor WRITE setClickBorderHColor NOTIFY clickBorderHColorChanged) + Q_PROPERTY(QBrush disableBorderHColor READ disableBorderHColor WRITE setDisableBorderHColor NOTIFY disabledBorderHColorChanged) Q_PROPERTY(QBrush normalCheckedBC READ normalCheckedBC WRITE setNormalCheckedBC NOTIFY normalCheckedBCChanged) Q_PROPERTY(QBrush clickedCheckedBC READ clickedCheckedBC WRITE setClickedCheckedBC NOTIFY clickedCheckedBCChanged) Q_PROPERTY(QBrush hoveredCheckedBC READ hoveredCheckedBC WRITE setHoveredCheckedBC NOTIFY hoveredCheckedBCChanged) + Q_PROPERTY(QBrush disableCheckedBC READ disableCheckedBC WRITE setDisableCheckedBC NOTIFY disableCheckedBCChanged) Q_PROPERTY(QBrush normalBorderCheckedColor READ normalBorderCheckedColor WRITE setNormalBorderCheckedColor NOTIFY normalBorderCheckedColorChanged) Q_PROPERTY(QBrush hoverBorderCheckedColor READ hoverBorderCheckedColor WRITE setHoverBorderCheckedColor NOTIFY hoverBorderCheckedColorChanged) Q_PROPERTY(QBrush clickBorderCheckedColor READ clickBorderCheckedColor WRITE setClickBorderCheckedColor NOTIFY clickBorderCheckedColorChanged) + Q_PROPERTY(QBrush disableBorderCheckedColor READ disableBorderCheckedColor WRITE setDisableBorderCheckedColor NOTIFY disableBorderCheckedColorChanged) Q_PROPERTY(int implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged) + + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickedTransparentBorderColor READ clickedTransparentBorderColor WRITE setClickedTransparentBorderColor NOTIFY clickedTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoveredTransparentBorderColor READ hoveredTransparentBorderColor WRITE setHoveredTransparentBorderColor NOTIFY hoveredTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentBorderColor READ disableTransparentBorderColor WRITE setDisableTransparentBorderColor NOTIFY disableTransparentBorderColorChanged) + + Q_PROPERTY(QBrush normalCheckedTransparentBC READ normalCheckedTransparentBC WRITE setNormalCheckedTransparentBC NOTIFY normalCheckedTransparentBCChanged) + Q_PROPERTY(QBrush clickedCheckedTransparentBC READ clickedCheckedTransparentBC WRITE setClickedCheckedTransparentBC NOTIFY clickedCheckedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredCheckedTransparentBC READ hoveredCheckedTransparentBC WRITE setHoveredCheckedTransparentBC NOTIFY hoveredCheckedTransparentBCChanged) + Q_PROPERTY(QBrush disableCheckedTransparentBC READ disableCheckedTransparentBC WRITE setDisableCheckedTransparentBC NOTIFY disableCheckedTransparentBCChanged) + Q_PROPERTY(QBrush normalCheckedTransparentBorderColor READ normalCheckedTransparentBorderColor WRITE setNormalCheckedTransparentBorderColor NOTIFY normalCheckedTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickedCheckedTransparentBorderColor READ clickedCheckedTransparentBorderColor WRITE setClickedCheckedTransparentBorderColor NOTIFY clickedCheckedTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoveredCheckedTransparentBorderColor READ hoveredCheckedTransparentBorderColor WRITE setHoveredCheckedTransparentBorderColor NOTIFY hoveredCheckedTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableCheckedTransparentBorderColor READ disableCheckedTransparentBorderColor WRITE setDisableCheckedTransparentBorderColor NOTIFY disableCheckedTransparentBorderColorChanged) + + + Q_PROPERTY(QBrush normalAlternateBC READ normalAlternateBC WRITE setNormalAlternateBC NOTIFY normalAlternateBCChanged) + Q_PROPERTY(QBrush clickedAlternatedBC READ clickedAlternateBC WRITE setClickedAlternateBC NOTIFY clickedAlternateBCChanged) + Q_PROPERTY(QBrush hoveredAlternatedBC READ hoveredAlternateBC WRITE setHoveredAlternateBC NOTIFY hoveredAlternateBCChanged) + Q_PROPERTY(QBrush disableAlternateBC READ disableAlternateBC WRITE setDisableAlternateBC NOTIFY disableAlternateBCChanged) + Q_PROPERTY(QBrush normalAlternateTransparentBC READ normalAlternateTransparentBC WRITE setNormalAlternateTransparentBC NOTIFY normalAlternateTransparentBCChanged) + Q_PROPERTY(QBrush clickedAlternateTransparentBC READ clickedAlternateTransparentBC WRITE setClickedAlternateTransparentBC NOTIFY clickedAlternateTransparentBCChanged) + Q_PROPERTY(QBrush hoveredAlternateTransparentBC READ hoveredAlternateTransparentBC WRITE setHoveredAlternateTransparentBC NOTIFY hoveredAlternateTransparentBCChanged) + Q_PROPERTY(QBrush disableAlternateTransparentBC READ disableAlternateTransparentBC WRITE setDisableAlternateTransparentBC NOTIFY disableAlternateTransparentBCChanged) + public: explicit UKUIItemDelegate(QQuickItem *parent = nullptr); ~UKUIItemDelegate(); @@ -156,6 +191,96 @@ public: int padding() const; void setPadding(int newPadding); + const QBrush &normalHTextColor() const; + void setNormalHTextColor(const QBrush &newNormalHTextColor); + + const QBrush &disableHTextColor() const; + void setDisableHTextColor(const QBrush &newDisableHTextColor); + + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + + const QBrush &clickedTransparentBorderColor() const; + void setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor); + + const QBrush &hoveredTransparentBorderColor() const; + void setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor); + + const QBrush &disableTransparentBorderColor() const; + void setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor); + + const QBrush &disableHBC() const; + void setDisableHBC(const QBrush &newDisableHBC); + + const QBrush &disableBorderHColor() const; + void setDisableBorderHColor(const QBrush &newDisableBorderHColor); + + const QBrush &disableCheckedBC() const; + void setDisableCheckedBC(const QBrush &newDisableCheckedBC); + + const QBrush &disableBorderCheckedColor() const; + void setDisableBorderCheckedColor(const QBrush &newDisableBorderCheckedColor); + + const QBrush &normalCheckedTransparentBC() const; + void setNormalCheckedTransparentBC(const QBrush &newNormalCheckedTransparentBC); + + const QBrush &clickedCheckedTransparentBC() const; + void setClickedCheckedTransparentBC(const QBrush &newClickedCheckedTransparentBC); + + const QBrush &hoveredCheckedTransparentBC() const; + void setHoveredCheckedTransparentBC(const QBrush &newHoveredCheckedTransparentBC); + + const QBrush &disableCheckedTransparentBC() const; + void setDisableCheckedTransparentBC(const QBrush &newDisableCheckedTransparentBC); + + const QBrush &normalCheckedTransparentBorderColor() const; + void setNormalCheckedTransparentBorderColor(const QBrush &newNormalCheckedTransparentBorderColor); + + const QBrush &clickedCheckedTransparentBorderColor() const; + void setClickedCheckedTransparentBorderColor(const QBrush &newClickedCheckedTransparentBorderColor); + + const QBrush &hoveredCheckedTransparentBorderColor() const; + void setHoveredCheckedTransparentBorderColor(const QBrush &newHoveredCheckedTransparentBorderColor); + + const QBrush &disableCheckedTransparentBorderColor() const; + void setDisableCheckedTransparentBorderColor(const QBrush &newDisableCheckedTransparentBorderColor); + + QBrush normalAlternateBC() const; + void setNormalAlternateBC(const QBrush &newNormalAlternateBC); + + QBrush clickedAlternateBC() const; + void setClickedAlternateBC(const QBrush &newClickeAlternatedBC); + + QBrush hoveredAlternateBC() const; + void setHoveredAlternateBC(const QBrush &newHovereAlternatedBC); + + QBrush disableAlternateBC() const; + void setDisableAlternateBC(const QBrush &newDisableAlternateBC); + + QBrush normalAlternateTransparentBC() const; + void setNormalAlternateTransparentBC(const QBrush &newNormalAlternateTransparentBC); + + QBrush clickedAlternateTransparentBC() const; + void setClickedAlternateTransparentBC(const QBrush &newClickedAlternateTransparentBC); + + QBrush hoveredAlternateTransparentBC() const; + void setHoveredAlternateTransparentBC(const QBrush &newHoveredAlternateTransparentBC); + + QBrush disableAlternateTransparentBC() const; + void setDisableAlternateTransparentBC(const QBrush &newDisableAlternateTransparentBC); + signals: void normalTextColorChanged(); @@ -212,6 +337,66 @@ signals: void paddingChanged(); + void normalHTextColorChanged(); + + void disableHTextColorChanged(); + + void normalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + + void normalTransparentBorderColorChanged(); + + void clickedTransparentBorderColorChanged(); + + void hoveredTransparentBorderColorChanged(); + + void disableTransparentBorderColorChanged(); + + void disabledHBCChanged(); + + void disabledBorderHColorChanged(); + + void disableCheckedBCChanged(); + + void disableBorderCheckedColorChanged(); + + void normalCheckedTransparentBCChanged(); + + void clickedCheckedTransparentBCChanged(); + + void hoveredCheckedTransparentBCChanged(); + + void disableCheckedTransparentBCChanged(); + + void normalCheckedTransparentBorderColorChanged(); + + void clickedCheckedTransparentBorderColorChanged(); + + void hoveredCheckedTransparentBorderColorChanged(); + + void disableCheckedTransparentBorderColorChanged(); + + void normalAlternateBCChanged(); + + void clickedAlternateBCChanged(); + + void hoveredAlternateBCChanged(); + + void disableAlternateBCChanged(); + + void normalAlternateTransparentBCChanged(); + + void clickedAlternateTransparentBCChanged(); + + void hoveredAlternateTransparentBCChanged(); + + void disableAlternateTransparentBCChanged(); + private: Q_INVOKABLE QBrush m_normalTextColor ; Q_INVOKABLE QBrush m_disableTextColor ; @@ -242,6 +427,36 @@ private: QBrush m_clickBorderCheckedColor; int m_implicitHeight = 36; int m_padding; + QBrush m_normalHTextColor; + QBrush m_disableHTextColor; + QBrush m_normalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; + QBrush m_normalTransparentBorderColor; + QBrush m_clickedTransparentBorderColor; + QBrush m_hoveredTransparentBorderColor; + QBrush m_disableTransparentBorderColor; + QBrush m_disableHBC; + QBrush m_disableBorderHColor; + QBrush m_disableCheckedBC; + QBrush m_disableBorderCheckedColor; + QBrush m_normalCheckedTransparentBC; + QBrush m_clickedCheckedTransparentBC; + QBrush m_hoveredCheckedTransparentBC; + QBrush m_disableCheckedTransparentBC; + QBrush m_normalCheckedTransparentBorderColor; + QBrush m_clickedCheckedTransparentBorderColor; + QBrush m_hoveredCheckedTransparentBorderColor; + QBrush m_disableCheckedTransparentBorderColor; + QBrush m_normalAlternateBC; + QBrush m_clickedAlternatedBC; + QBrush m_hoveredAlternatedBC; + QBrush m_disableAlternateBC; + QBrush m_normalAlternateTransparentBC; + QBrush m_clickedAlternateTransparentBC; + QBrush m_hoveredAlternateTransparentBC; + QBrush m_disableAlternateTransparentBC; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIItemDelegate, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuilabel.cpp b/ukui-qml-style-helper/styleparameter/ukuilabel.cpp index a7deabd..4a97182 100644 --- a/ukui-qml-style-helper/styleparameter/ukuilabel.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuilabel.cpp @@ -8,11 +8,13 @@ UKUILabel::UKUILabel(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUILabel::~UKUILabel() diff --git a/ukui-qml-style-helper/styleparameter/ukuimenu.cpp b/ukui-qml-style-helper/styleparameter/ukuimenu.cpp index de3c31b..8997528 100644 --- a/ukui-qml-style-helper/styleparameter/ukuimenu.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuimenu.cpp @@ -9,17 +9,19 @@ UKUIMenu::UKUIMenu(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); - if (QGSettings::isSchemaInstalled("org.ukui.style")) { - auto settings = UKUIStyleSettings::globalInstance(); - connect(settings, &QGSettings::changed, this, [&](const QString& key){ - if(key == "menuTransparency" || key == "menu-transparency") - initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + if (QGSettings::isSchemaInstalled("org.ukui.style")) { + auto settings = UKUIStyleSettings::globalInstance(); + connect(settings, &QGSettings::changed, this, [&](const QString& key){ + if(key == "menuTransparency" || key == "menu-transparency") + initParam(m_instance); + }, Qt::UniqueConnection); + } } } @@ -41,7 +43,9 @@ void UKUIMenu::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) c.setAlphaF(opacity); setBcColorAlpha(opacity); } - setNormalBC(c); + setNormalBC(instance->kContainGeneralNormal()); + setNormalTransparentBC(c); + setNormalTransparentBorderColor(instance->kLineWindowActive()); emit parametryChanged(); @@ -171,3 +175,24 @@ void UKUIMenu::setBcColorAlpha(double newBcColorAlpha) m_bcColorAlpha = newBcColorAlpha; emit bcColorAlphaChanged(); } + +void UKUIMenu::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUIMenu::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUIMenu::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuimenu.h b/ukui-qml-style-helper/styleparameter/ukuimenu.h index 16b83e5..1d6a3ea 100644 --- a/ukui-qml-style-helper/styleparameter/ukuimenu.h +++ b/ukui-qml-style-helper/styleparameter/ukuimenu.h @@ -47,6 +47,9 @@ class UKUIMenu : public QQuickItem Q_PROPERTY(QBrush normalBorderColor READ normalBorderColor WRITE setNormalBorderColor NOTIFY normalBorderColorChanged) Q_PROPERTY(double bcColorAlpha READ bcColorAlpha WRITE setBcColorAlpha NOTIFY bcColorAlphaChanged) + Q_PROPERTY(QBrush normalTransparentBC READ normalBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + public: explicit UKUIMenu(QQuickItem *parent = nullptr); ~UKUIMenu(); @@ -81,6 +84,11 @@ public: double bcColorAlpha() const; void setBcColorAlpha(double newBcColorAlpha); + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + signals: void leftRightPaddingChanged(); @@ -102,9 +110,13 @@ signals: void bcColorAlphaChanged(); + void normalTransparentBCChanged(); + + void normalTransparentBorderColorChanged(); + private: int m_leftRightPadding = 8; - int m_topBottomPadding = 6; + int m_topBottomPadding = 8; int m_radius = 8; Q_INVOKABLE QBrush m_shadowNormalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.3)); Q_INVOKABLE QBrush m_shadowDisableColor; @@ -115,6 +127,8 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; double m_bcColorAlpha; + QBrush m_normalTransparentBC; + QBrush m_normalTransparentBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIMenu, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuimenuitem.cpp b/ukui-qml-style-helper/styleparameter/ukuimenuitem.cpp index 2b19f68..8b1aad3 100644 --- a/ukui-qml-style-helper/styleparameter/ukuimenuitem.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuimenuitem.cpp @@ -8,11 +8,13 @@ UKUIMenuItem::UKUIMenuItem(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIMenuItem::~UKUIMenuItem() @@ -34,6 +36,47 @@ void UKUIMenuItem::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setNormalTextColor(instance->kFontPrimary()); setDisableTextColor(instance->kFontPrimaryDisable()); + setNormalTransparentBC(QBrush(QColor(0,0,0,0))); + setHoveredTransparentBC(instance->kComponentAlphaHover()); + setClickedTransparentBC(instance->kComponentAlphaClick()); + setDisableTransparentBC(QBrush(QColor(0,0,0,0))); + setNormalTransparentBorderColor(QBrush(QColor(0,0,0,0))); + setHoverTransparentBorderColor(instance->kLineComponentHover()); + setClickTransparentBorderColor(instance->kLineComponentClick()); + setDisableTransparentBorderColor(QBrush(QColor(0,0,0,0))); + + setNormalCheckedBC(instance->kComponentSelectedNormal()); + setNormalBorderCheckedColor(instance->kLineComponentNormal()); + setHoveredCheckedBC(instance->kComponentSelectedHover()); + setHoverBorderCheckedColor(instance->kLineComponentHover()); + setClickedCheckedBC(instance->kComponentSelectedClick()); + setClickBorderCheckedColor(instance->kLineComponentClick()); + setDisableCheckedBC(instance->kComponentSelectedDisable()); + setDisableBorderCheckedColor(instance->kLineComponentDisable()); + + setNormalCheckedTransparentBC(instance->kComponentSelectedAlphaNormal()); + setNormalBorderCheckedTransparentColor(instance->kLineComponentNormal()); + setHoveredCheckedTransparentBC(instance->kComponentSelectedAlphaHover()); + setHoverBorderCheckedTransparentColor(instance->kLineComponentHover()); + setClickedCheckedTransparentBC(instance->kComponentSelectedAlphaClick()); + setClickBorderCheckedTransparentColor(instance->kLineComponentClick()); + setDisableCheckedTransparentBC(instance->kComponentSelectedAlphaDisable()); + setDisableBorderCheckedTransparentColor(instance->kLineComponentDisable()); + + setNormalHTextColor(instance->kFontWhite()); + setDisableHTextColor(instance->kFontWhiteDisable()); + setNormalCheckedHBC(instance->kBrandNormal()); + setHoveredCheckedHBC(instance->kBrandHover()); + setClickedCheckedHBC(instance->kBrandClick()); + setDisableCheckedHBC(instance->kBrandDisable()); + setNormalCheckedHBorderColor(instance->kLineBrandNormal()); + setHoveredCheckedHBorderColor(instance->kLineBrandHover()); + setClickedCheckedHBorderColor(instance->kLineBrandClick()); + setDisableCheckedHBorderColor(instance->kLineBrandDisable()); + + setMenuSeparatorColor(instance->kLineNormal()); + + emit parametryChanged(); } @@ -265,3 +308,458 @@ void UKUIMenuItem::setDisableBorderColor(const QBrush &newDisableBorderColor) m_disableBorderColor = newDisableBorderColor; emit disableBorderColorChanged(); } + +const QBrush &UKUIMenuItem::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUIMenuItem::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUIMenuItem::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUIMenuItem::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUIMenuItem::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUIMenuItem::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::hoverTransparentBorderColor() const +{ + return m_hoverTransparentBorderColor; +} + +void UKUIMenuItem::setHoverTransparentBorderColor(const QBrush &newHoverTransparentBorderColor) +{ + if (m_hoverTransparentBorderColor == newHoverTransparentBorderColor) + return; + m_hoverTransparentBorderColor = newHoverTransparentBorderColor; + emit hoverTransparentBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::clickTransparentBorderColor() const +{ + return m_clickTransparentBorderColor; +} + +void UKUIMenuItem::setClickTransparentBorderColor(const QBrush &newClickTransparentBorderColor) +{ + if (m_clickTransparentBorderColor == newClickTransparentBorderColor) + return; + m_clickTransparentBorderColor = newClickTransparentBorderColor; + emit clickTransparentBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::disableTransparentBorderColor() const +{ + return m_disableTransparentBorderColor; +} + +void UKUIMenuItem::setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor) +{ + if (m_disableTransparentBorderColor == newDisableTransparentBorderColor) + return; + m_disableTransparentBorderColor = newDisableTransparentBorderColor; + emit disableTransparentBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::normalCheckedBC() const +{ + return m_normalCheckedBC; +} + +void UKUIMenuItem::setNormalCheckedBC(const QBrush &newNormalCheckedBC) +{ + if (m_normalCheckedBC == newNormalCheckedBC) + return; + m_normalCheckedBC = newNormalCheckedBC; + emit normalCheckedBCChanged(); +} + +const QBrush &UKUIMenuItem::clickedCheckedBC() const +{ + return m_clickedCheckedBC; +} + +void UKUIMenuItem::setClickedCheckedBC(const QBrush &newClickedCheckedBC) +{ + if (m_clickedCheckedBC == newClickedCheckedBC) + return; + m_clickedCheckedBC = newClickedCheckedBC; + emit clickedCheckedBCChanged(); +} + +const QBrush &UKUIMenuItem::hoveredCheckedBC() const +{ + return m_hoveredCheckedBC; +} + +void UKUIMenuItem::setHoveredCheckedBC(const QBrush &newHoveredCheckedBC) +{ + if (m_hoveredCheckedBC == newHoveredCheckedBC) + return; + m_hoveredCheckedBC = newHoveredCheckedBC; + emit hoveredCheckedBCChanged(); +} + +const QBrush &UKUIMenuItem::disableCheckedBC() const +{ + return m_disableCheckedBC; +} + +void UKUIMenuItem::setDisableCheckedBC(const QBrush &newDisableCheckedBC) +{ + if (m_disableCheckedBC == newDisableCheckedBC) + return; + m_disableCheckedBC = newDisableCheckedBC; + emit disableCheckedBCChanged(); +} + +const QBrush &UKUIMenuItem::normalBorderCheckedColor() const +{ + return m_normalBorderCheckedColor; +} + +void UKUIMenuItem::setNormalBorderCheckedColor(const QBrush &newNormalBorderCheckedColor) +{ + if (m_normalBorderCheckedColor == newNormalBorderCheckedColor) + return; + m_normalBorderCheckedColor = newNormalBorderCheckedColor; + emit normalBorderCheckedColorChanged(); +} + +const QBrush &UKUIMenuItem::hoverBorderCheckedColor() const +{ + return m_hoverBorderCheckedColor; +} + +void UKUIMenuItem::setHoverBorderCheckedColor(const QBrush &newHoverBorderCheckedColor) +{ + if (m_hoverBorderCheckedColor == newHoverBorderCheckedColor) + return; + m_hoverBorderCheckedColor = newHoverBorderCheckedColor; + emit hoverBorderCheckedColorChanged(); +} + +const QBrush &UKUIMenuItem::clickBorderCheckedColor() const +{ + return m_clickBorderCheckedColor; +} + +void UKUIMenuItem::setClickBorderCheckedColor(const QBrush &newClickBorderCheckedColor) +{ + if (m_clickBorderCheckedColor == newClickBorderCheckedColor) + return; + m_clickBorderCheckedColor = newClickBorderCheckedColor; + emit clickBorderCheckedColorChanged(); +} + +const QBrush &UKUIMenuItem::disableBorderCheckedColor() const +{ + return m_disableBorderCheckedColor; +} + +void UKUIMenuItem::setDisableBorderCheckedColor(const QBrush &newDisableBorderCheckedColor) +{ + if (m_disableBorderCheckedColor == newDisableBorderCheckedColor) + return; + m_disableBorderCheckedColor = newDisableBorderCheckedColor; + emit disableBorderCheckedColorChanged(); +} + +const QBrush &UKUIMenuItem::normalHTextColor() const +{ + return m_normalHTextColor; +} + +void UKUIMenuItem::setNormalHTextColor(const QBrush &newNormalHTextColor) +{ + if (m_normalHTextColor == newNormalHTextColor) + return; + m_normalHTextColor = newNormalHTextColor; + emit normalHTextColorChanged(); +} + +const QBrush &UKUIMenuItem::disableHTextColor() const +{ + return m_disableHTextColor; +} + +void UKUIMenuItem::setDisableHTextColor(const QBrush &newDisableHTextColor) +{ + if (m_disableHTextColor == newDisableHTextColor) + return; + m_disableHTextColor = newDisableHTextColor; + emit disableHTextColorChanged(); +} + +const QBrush &UKUIMenuItem::normalCheckedHBC() const +{ + return m_normalCheckedHBC; +} + +void UKUIMenuItem::setNormalCheckedHBC(const QBrush &newNormalCheckedHBC) +{ + if (m_normalCheckedHBC == newNormalCheckedHBC) + return; + m_normalCheckedHBC = newNormalCheckedHBC; + emit normalCheckedHBCChanged(); +} + +const QBrush &UKUIMenuItem::clickedCheckedHBC() const +{ + return m_clickedCheckedHBC; +} + +void UKUIMenuItem::setClickedCheckedHBC(const QBrush &newClickedCheckedHBC) +{ + if (m_clickedCheckedHBC == newClickedCheckedHBC) + return; + m_clickedCheckedHBC = newClickedCheckedHBC; + emit clickedCheckedHBCChanged(); +} + +const QBrush &UKUIMenuItem::hoveredCheckedHBC() const +{ + return m_hoveredCheckedHBC; +} + +void UKUIMenuItem::setHoveredCheckedHBC(const QBrush &newHoveredCheckedHBC) +{ + if (m_hoveredCheckedHBC == newHoveredCheckedHBC) + return; + m_hoveredCheckedHBC = newHoveredCheckedHBC; + emit hoveredCheckedHBCChanged(); +} + +const QBrush &UKUIMenuItem::disableCheckedHBC() const +{ + return m_disableCheckedHBC; +} + +void UKUIMenuItem::setDisableCheckedHBC(const QBrush &newDisableCheckedHBC) +{ + if (m_disableCheckedHBC == newDisableCheckedHBC) + return; + m_disableCheckedHBC = newDisableCheckedHBC; + emit disableCheckedHBCChanged(); +} + +const QBrush &UKUIMenuItem::normalCheckedHBorderColor() const +{ + return m_normalCheckedHBorderColor; +} + +void UKUIMenuItem::setNormalCheckedHBorderColor(const QBrush &newNormalCheckedHBorderColor) +{ + if (m_normalCheckedHBorderColor == newNormalCheckedHBorderColor) + return; + m_normalCheckedHBorderColor = newNormalCheckedHBorderColor; + emit normalCheckedHBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::clickedCheckedHBorderColor() const +{ + return m_clickedCheckedHBorderColor; +} + +void UKUIMenuItem::setClickedCheckedHBorderColor(const QBrush &newClickedCheckedHBorderColor) +{ + if (m_clickedCheckedHBorderColor == newClickedCheckedHBorderColor) + return; + m_clickedCheckedHBorderColor = newClickedCheckedHBorderColor; + emit clickedCheckedHBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::hoveredCheckedHBorderColor() const +{ + return m_hoveredCheckedHBorderColor; +} + +void UKUIMenuItem::setHoveredCheckedHBorderColor(const QBrush &newHoveredCheckedHBorderColor) +{ + if (m_hoveredCheckedHBorderColor == newHoveredCheckedHBorderColor) + return; + m_hoveredCheckedHBorderColor = newHoveredCheckedHBorderColor; + emit hoveredCheckedHBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::disableCheckedHBorderColor() const +{ + return m_disableCheckedHBorderColor; +} + +void UKUIMenuItem::setDisableCheckedHBorderColor(const QBrush &newDisableCheckedHBorderColor) +{ + if (m_disableCheckedHBorderColor == newDisableCheckedHBorderColor) + return; + m_disableCheckedHBorderColor = newDisableCheckedHBorderColor; + emit disableCheckedHBorderColorChanged(); +} + +const QBrush &UKUIMenuItem::normalCheckedTransparentBC() const +{ + return m_normalCheckedTransparentBC; +} + +void UKUIMenuItem::setNormalCheckedTransparentBC(const QBrush &newNormalCheckedTransparentBC) +{ + if (m_normalCheckedTransparentBC == newNormalCheckedTransparentBC) + return; + m_normalCheckedTransparentBC = newNormalCheckedTransparentBC; + emit normalCheckedTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::clickedCheckedTransparentBC() const +{ + return m_clickedCheckedTransparentBC; +} + +void UKUIMenuItem::setClickedCheckedTransparentBC(const QBrush &newClickedCheckedTransparentBC) +{ + if (m_clickedCheckedTransparentBC == newClickedCheckedTransparentBC) + return; + m_clickedCheckedTransparentBC = newClickedCheckedTransparentBC; + emit clickedCheckedTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::hoveredCheckedTransparentBC() const +{ + return m_hoveredCheckedTransparentBC; +} + +void UKUIMenuItem::setHoveredCheckedTransparentBC(const QBrush &newHoveredCheckedTransparentBC) +{ + if (m_hoveredCheckedTransparentBC == newHoveredCheckedTransparentBC) + return; + m_hoveredCheckedTransparentBC = newHoveredCheckedTransparentBC; + emit hoveredCheckedTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::disableCheckedTransparentBC() const +{ + return m_disableCheckedTransparentBC; +} + +void UKUIMenuItem::setDisableCheckedTransparentBC(const QBrush &newDisableCheckedTransparentBC) +{ + if (m_disableCheckedTransparentBC == newDisableCheckedTransparentBC) + return; + m_disableCheckedTransparentBC = newDisableCheckedTransparentBC; + emit disableCheckedTransparentBCChanged(); +} + +const QBrush &UKUIMenuItem::normalBorderCheckedTransparentColor() const +{ + return m_normalBorderCheckedTransparentColor; +} + +void UKUIMenuItem::setNormalBorderCheckedTransparentColor(const QBrush &newNormalBorderCheckedTransparentColor) +{ + if (m_normalBorderCheckedTransparentColor == newNormalBorderCheckedTransparentColor) + return; + m_normalBorderCheckedTransparentColor = newNormalBorderCheckedTransparentColor; + emit normalBorderCheckedColorTransparentChanged(); +} + +const QBrush &UKUIMenuItem::hoverBorderCheckedTransparentColor() const +{ + return m_hoverBorderCheckedTransparentColor; +} + +void UKUIMenuItem::setHoverBorderCheckedTransparentColor(const QBrush &newHoverBorderCheckedTransparentColor) +{ + if (m_hoverBorderCheckedTransparentColor == newHoverBorderCheckedTransparentColor) + return; + m_hoverBorderCheckedTransparentColor = newHoverBorderCheckedTransparentColor; + emit hoverBorderCheckedColorTransparentChanged(); +} + +const QBrush &UKUIMenuItem::clickBorderCheckedTransparentColor() const +{ + return m_clickBorderCheckedTransparentColor; +} + +void UKUIMenuItem::setClickBorderCheckedTransparentColor(const QBrush &newClickBorderCheckedTransparentColor) +{ + if (m_clickBorderCheckedTransparentColor == newClickBorderCheckedTransparentColor) + return; + m_clickBorderCheckedTransparentColor = newClickBorderCheckedTransparentColor; + emit clickBorderCheckedColorTransparentChanged(); +} + +const QBrush &UKUIMenuItem::disableBorderCheckedTransparentColor() const +{ + return m_disableBorderCheckedTransparentColor; +} + +void UKUIMenuItem::setDisableBorderCheckedTransparentColor(const QBrush &newDisableBorderCheckedTransparentColor) +{ + if (m_disableBorderCheckedTransparentColor == newDisableBorderCheckedTransparentColor) + return; + m_disableBorderCheckedTransparentColor = newDisableBorderCheckedTransparentColor; + emit disableBorderCheckedColorTransparentChanged(); +} + +const QBrush &UKUIMenuItem::menuSeparatorColor() const +{ + return m_menuSeparatorColor; +} + +void UKUIMenuItem::setMenuSeparatorColor(const QBrush &newMenuSeparatorColor) +{ + if (m_menuSeparatorColor == newMenuSeparatorColor) + return; + m_menuSeparatorColor = newMenuSeparatorColor; + emit menuSeparatorColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuimenuitem.h b/ukui-qml-style-helper/styleparameter/ukuimenuitem.h index 3f139f0..d4356af 100644 --- a/ukui-qml-style-helper/styleparameter/ukuimenuitem.h +++ b/ukui-qml-style-helper/styleparameter/ukuimenuitem.h @@ -57,6 +57,46 @@ class UKUIMenuItem : public QQuickItem Q_PROPERTY(QBrush clickBorderColor READ clickBorderColor WRITE setClickBorderColor NOTIFY clickBorderColorChanged) Q_PROPERTY(QBrush disableBorderColor READ disableBorderColor WRITE setDisableBorderColor NOTIFY disableBorderColorChanged) + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoverTransparentBorderColor READ hoverTransparentBorderColor WRITE setHoverTransparentBorderColor NOTIFY hoverTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickTransparentBorderColor READ clickTransparentBorderColor WRITE setClickTransparentBorderColor NOTIFY clickTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentBorderColor READ disableTransparentBorderColor WRITE setDisableTransparentBorderColor NOTIFY disableTransparentBorderColorChanged) + + Q_PROPERTY(QBrush normalCheckedBC READ normalCheckedBC WRITE setNormalCheckedBC NOTIFY normalCheckedBCChanged) + Q_PROPERTY(QBrush clickedCheckedBC READ clickedCheckedBC WRITE setClickedCheckedBC NOTIFY clickedCheckedBCChanged) + Q_PROPERTY(QBrush hoveredCheckedBC READ hoveredCheckedBC WRITE setHoveredCheckedBC NOTIFY hoveredCheckedBCChanged) + Q_PROPERTY(QBrush disableCheckedBC READ disableCheckedBC WRITE setDisableCheckedBC NOTIFY disableCheckedBCChanged) + Q_PROPERTY(QBrush normalBorderCheckedColor READ normalBorderCheckedColor WRITE setNormalBorderCheckedColor NOTIFY normalBorderCheckedColorChanged) + Q_PROPERTY(QBrush hoverBorderCheckedColor READ hoverBorderCheckedColor WRITE setHoverBorderCheckedColor NOTIFY hoverBorderCheckedColorChanged) + Q_PROPERTY(QBrush clickBorderCheckedColor READ clickBorderCheckedColor WRITE setClickBorderCheckedColor NOTIFY clickBorderCheckedColorChanged) + Q_PROPERTY(QBrush disableBorderCheckedColor READ disableBorderCheckedColor WRITE setDisableBorderCheckedColor NOTIFY disableBorderCheckedColorChanged) + + Q_PROPERTY(QBrush normalCheckedTransparentBC READ normalCheckedTransparentBC WRITE setNormalCheckedTransparentBC NOTIFY normalCheckedTransparentBCChanged) + Q_PROPERTY(QBrush clickedCheckedTransparentBC READ clickedCheckedTransparentBC WRITE setClickedCheckedTransparentBC NOTIFY clickedCheckedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredCheckedTransparentBC READ hoveredCheckedTransparentBC WRITE setHoveredCheckedTransparentBC NOTIFY hoveredCheckedTransparentBCChanged) + Q_PROPERTY(QBrush disableCheckedTransparentBC READ disableCheckedTransparentBC WRITE setDisableCheckedTransparentBC NOTIFY disableCheckedTransparentBCChanged) + Q_PROPERTY(QBrush normalBorderCheckedTransparentColor READ normalBorderCheckedTransparentColor WRITE setNormalBorderCheckedTransparentColor NOTIFY normalBorderCheckedColorTransparentChanged) + Q_PROPERTY(QBrush hoverBorderCheckedTransparentColor READ hoverBorderCheckedTransparentColor WRITE setHoverBorderCheckedTransparentColor NOTIFY hoverBorderCheckedColorTransparentChanged) + Q_PROPERTY(QBrush clickBorderCheckedTransparentColor READ clickBorderCheckedTransparentColor WRITE setClickBorderCheckedTransparentColor NOTIFY clickBorderCheckedColorTransparentChanged) + Q_PROPERTY(QBrush disableBorderCheckedTransparentColor READ disableBorderCheckedTransparentColor WRITE setDisableBorderCheckedTransparentColor NOTIFY disableBorderCheckedColorTransparentChanged) + + Q_PROPERTY(QBrush normalHTextColor READ normalHTextColor WRITE setNormalHTextColor NOTIFY normalHTextColorChanged) + Q_PROPERTY(QBrush disableHTextColor READ disableHTextColor WRITE setDisableHTextColor NOTIFY disableHTextColorChanged) + Q_PROPERTY(QBrush normalCheckedHBC READ normalCheckedHBC WRITE setNormalCheckedHBC NOTIFY normalCheckedHBCChanged) + Q_PROPERTY(QBrush clickedCheckedHBC READ clickedCheckedHBC WRITE setClickedCheckedHBC NOTIFY clickedCheckedHBCChanged) + Q_PROPERTY(QBrush hoveredCheckedHBC READ hoveredCheckedHBC WRITE setHoveredCheckedHBC NOTIFY hoveredCheckedHBCChanged) + Q_PROPERTY(QBrush disableCheckedHBC READ disableCheckedHBC WRITE setDisableCheckedHBC NOTIFY disableCheckedHBCChanged) + Q_PROPERTY(QBrush normalCheckedHBorderColor READ normalCheckedHBorderColor WRITE setNormalCheckedHBorderColor NOTIFY normalCheckedHBorderColorChanged) + Q_PROPERTY(QBrush clickedCheckedHBorderColor READ clickedCheckedHBorderColor WRITE setClickedCheckedHBorderColor NOTIFY clickedCheckedHBorderColorChanged) + Q_PROPERTY(QBrush hoveredCheckedHBorderColor READ hoveredCheckedHBorderColor WRITE setHoveredCheckedHBorderColor NOTIFY hoveredCheckedHBorderColorChanged) + Q_PROPERTY(QBrush disableCheckedHBorderColor READ disableCheckedHBorderColor WRITE setDisableCheckedHBorderColor NOTIFY disableCheckedHBorderColorChanged) + + Q_PROPERTY(QBrush menuSeparatorColor READ menuSeparatorColor WRITE setMenuSeparatorColor NOTIFY menuSeparatorColorChanged) + public: explicit UKUIMenuItem(QQuickItem *parent = nullptr); ~UKUIMenuItem(); @@ -116,6 +156,111 @@ public: const QBrush &disableBorderColor() const; void setDisableBorderColor(const QBrush &newDisableBorderColor); + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + + const QBrush &hoverTransparentBorderColor() const; + void setHoverTransparentBorderColor(const QBrush &newHoverTransparentBorderColor); + + const QBrush &clickTransparentBorderColor() const; + void setClickTransparentBorderColor(const QBrush &newClickTransparentBorderColor); + + const QBrush &disableTransparentBorderColor() const; + void setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor); + + const QBrush &normalCheckedBC() const; + void setNormalCheckedBC(const QBrush &newNormalCheckedBC); + + const QBrush &clickedCheckedBC() const; + void setClickedCheckedBC(const QBrush &newClickedCheckedBC); + + const QBrush &hoveredCheckedBC() const; + void setHoveredCheckedBC(const QBrush &newHoveredCheckedBC); + + const QBrush &disableCheckedBC() const; + void setDisableCheckedBC(const QBrush &newDisableCheckedBC); + + const QBrush &normalBorderCheckedColor() const; + void setNormalBorderCheckedColor(const QBrush &newNormalBorderCheckedColor); + + const QBrush &hoverBorderCheckedColor() const; + void setHoverBorderCheckedColor(const QBrush &newHoverBorderCheckedColor); + + const QBrush &clickBorderCheckedColor() const; + void setClickBorderCheckedColor(const QBrush &newClickBorderCheckedColor); + + const QBrush &disableBorderCheckedColor() const; + void setDisableBorderCheckedColor(const QBrush &newDisableBorderCheckedColor); + + const QBrush &normalHTextColor() const; + void setNormalHTextColor(const QBrush &newNormalHTextColor); + + const QBrush &disableHTextColor() const; + void setDisableHTextColor(const QBrush &newDisableHTextColor); + + const QBrush &normalCheckedHBC() const; + void setNormalCheckedHBC(const QBrush &newNormalCheckedHBC); + + const QBrush &clickedCheckedHBC() const; + void setClickedCheckedHBC(const QBrush &newClickedCheckedHBC); + + const QBrush &hoveredCheckedHBC() const; + void setHoveredCheckedHBC(const QBrush &newHoveredCheckedHBC); + + const QBrush &disableCheckedHBC() const; + void setDisableCheckedHBC(const QBrush &newDisableCheckedHBC); + + const QBrush &normalCheckedHBorderColor() const; + void setNormalCheckedHBorderColor(const QBrush &newNormalCheckedHBorderColor); + + const QBrush &clickedCheckedHBorderColor() const; + void setClickedCheckedHBorderColor(const QBrush &newClickedCheckedHBorderColor); + + const QBrush &hoveredCheckedHBorderColor() const; + void setHoveredCheckedHBorderColor(const QBrush &newHoveredCheckedHBorderColor); + + const QBrush &disableCheckedHBorderColor() const; + void setDisableCheckedHBorderColor(const QBrush &newDisableCheckedHBorderColor); + + const QBrush &normalCheckedTransparentBC() const; + void setNormalCheckedTransparentBC(const QBrush &newNormalCheckedTransparentBC); + + const QBrush &clickedCheckedTransparentBC() const; + void setClickedCheckedTransparentBC(const QBrush &newClickedCheckedTransparentBC); + + const QBrush &hoveredCheckedTransparentBC() const; + void setHoveredCheckedTransparentBC(const QBrush &newHoveredCheckedTransparentBC); + + const QBrush &disableCheckedTransparentBC() const; + void setDisableCheckedTransparentBC(const QBrush &newDisableCheckedTransparentBC); + + const QBrush &normalBorderCheckedTransparentColor() const; + void setNormalBorderCheckedTransparentColor(const QBrush &newNormalBorderCheckedTransparentColor); + + const QBrush &hoverBorderCheckedTransparentColor() const; + void setHoverBorderCheckedTransparentColor(const QBrush &newHoverBorderCheckedTransparentColor); + + const QBrush &clickBorderCheckedTransparentColor() const; + void setClickBorderCheckedTransparentColor(const QBrush &newClickBorderCheckedTransparentColor); + + const QBrush &disableBorderCheckedTransparentColor() const; + void setDisableBorderCheckedTransparentColor(const QBrush &newDisableBorderCheckedTransparentColor); + + const QBrush &menuSeparatorColor() const; + void setMenuSeparatorColor(const QBrush &newMenuSeparatorColor); + signals: void leftRightPaddingChanged(); @@ -151,13 +296,83 @@ signals: void parametryChanged(); + void normalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + + void normalTransparentBorderColorChanged(); + + void hoverTransparentBorderColorChanged(); + + void clickTransparentBorderColorChanged(); + + void disableTransparentBorderColorChanged(); + + void normalCheckedBCChanged(); + + void clickedCheckedBCChanged(); + + void hoveredCheckedBCChanged(); + + void disableCheckedBCChanged(); + + void normalBorderCheckedColorChanged(); + + void hoverBorderCheckedColorChanged(); + + void clickBorderCheckedColorChanged(); + + void disableBorderCheckedColorChanged(); + + void normalHTextColorChanged(); + + void disableHTextColorChanged(); + + void normalCheckedHBCChanged(); + + void clickedCheckedHBCChanged(); + + void hoveredCheckedHBCChanged(); + + void disableCheckedHBCChanged(); + + void normalCheckedHBorderColorChanged(); + + void clickedCheckedHBorderColorChanged(); + + void hoveredCheckedHBorderColorChanged(); + + void disableCheckedHBorderColorChanged(); + + void normalCheckedTransparentBCChanged(); + + void clickedCheckedTransparentBCChanged(); + + void hoveredCheckedTransparentBCChanged(); + + void disableCheckedTransparentBCChanged(); + + void normalBorderCheckedColorTransparentChanged(); + + void hoverBorderCheckedColorTransparentChanged(); + + void clickBorderCheckedColorTransparentChanged(); + + void disableBorderCheckedColorTransparentChanged(); + + void menuSeparatorColorChanged(); + private: int m_leftRightPadding = 8; int m_topBottomPadding = 6; int m_imageWidth = 16; int m_imageSpace = 4; int m_normalHeight = 36; - int m_radius = 8; + int m_radius = 6; Q_INVOKABLE QBrush m_normalBC; Q_INVOKABLE QBrush m_clickedBC; Q_INVOKABLE QBrush m_hoveredBC; @@ -172,6 +387,41 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_normalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; + QBrush m_normalTransparentBorderColor; + QBrush m_hoverTransparentBorderColor; + QBrush m_clickTransparentBorderColor; + QBrush m_disableTransparentBorderColor; + QBrush m_normalCheckedBC; + QBrush m_clickedCheckedBC; + QBrush m_hoveredCheckedBC; + QBrush m_disableCheckedBC; + QBrush m_normalBorderCheckedColor; + QBrush m_hoverBorderCheckedColor; + QBrush m_clickBorderCheckedColor; + QBrush m_disableBorderCheckedColor; + QBrush m_normalHTextColor; + QBrush m_disableHTextColor; + QBrush m_normalCheckedHBC; + QBrush m_clickedCheckedHBC; + QBrush m_hoveredCheckedHBC; + QBrush m_disableCheckedHBC; + QBrush m_normalCheckedHBorderColor; + QBrush m_clickedCheckedHBorderColor; + QBrush m_hoveredCheckedHBorderColor; + QBrush m_disableCheckedHBorderColor; + QBrush m_normalCheckedTransparentBC; + QBrush m_clickedCheckedTransparentBC; + QBrush m_hoveredCheckedTransparentBC; + QBrush m_disableCheckedTransparentBC; + QBrush m_normalBorderCheckedTransparentColor; + QBrush m_hoverBorderCheckedTransparentColor; + QBrush m_clickBorderCheckedTransparentColor; + QBrush m_disableBorderCheckedTransparentColor; + QBrush m_menuSeparatorColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIMenuItem, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuipopup.cpp b/ukui-qml-style-helper/styleparameter/ukuipopup.cpp index 0b09f69..3104a42 100644 --- a/ukui-qml-style-helper/styleparameter/ukuipopup.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuipopup.cpp @@ -9,11 +9,13 @@ UKUIPopup::UKUIPopup(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIPopup::~UKUIPopup() @@ -23,10 +25,17 @@ UKUIPopup::~UKUIPopup() void UKUIPopup::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setBackColor(instance->baseActive()); + setBackColor(instance->kContainSecondaryNormal()); setBackBorderColor(instance->kLineWindowActive()); setRadius(instance->kradiusMenu()); setShadowColor(instance->shadowActive()); + QColor c = instance->windowActive().color(); + if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { + auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; + c.setAlphaF(opacity); + } + setTransparentBC(c); + setTransparentBorderColor(QBrush(QColor(0,0,0,0))); emit parametryChanged(); } @@ -115,3 +124,29 @@ void UKUIPopup::setRadius(int newRadius) m_radius = newRadius; emit radiusChanged(); } + +const QBrush &UKUIPopup::transparentBC() const +{ + return m_transparentBC; +} + +void UKUIPopup::setTransparentBC(const QBrush &newTransparentBC) +{ + if (m_transparentBC == newTransparentBC) + return; + m_transparentBC = newTransparentBC; + emit transparentBCChanged(); +} + +const QBrush &UKUIPopup::transparentBorderColor() const +{ + return m_transparentBorderColor; +} + +void UKUIPopup::setTransparentBorderColor(const QBrush &newTransparentBorderColor) +{ + if (m_transparentBorderColor == newTransparentBorderColor) + return; + m_transparentBorderColor = newTransparentBorderColor; + emit transparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuipopup.h b/ukui-qml-style-helper/styleparameter/ukuipopup.h index 4977e19..1af8886 100644 --- a/ukui-qml-style-helper/styleparameter/ukuipopup.h +++ b/ukui-qml-style-helper/styleparameter/ukuipopup.h @@ -45,6 +45,8 @@ class UKUIPopup : public QQuickItem Q_PROPERTY(QBrush backColor READ backColor WRITE setBackColor NOTIFY backColorChanged) Q_PROPERTY(QBrush backBorderColor READ backBorderColor WRITE setBackBorderColor NOTIFY backBorderColorChanged) Q_PROPERTY(QBrush shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged) + Q_PROPERTY(QBrush transparentBC READ transparentBC WRITE setTransparentBC NOTIFY transparentBCChanged) + Q_PROPERTY(QBrush transparentBorderColor READ transparentBorderColor WRITE setTransparentBorderColor NOTIFY transparentBorderColorChanged) public: explicit UKUIPopup(QQuickItem *parent = nullptr); @@ -72,6 +74,12 @@ public: int radius() const; void setRadius(int newRadius); + const QBrush &transparentBC() const; + void setTransparentBC(const QBrush &newTransparentBC); + + const QBrush &transparentBorderColor() const; + void setTransparentBorderColor(const QBrush &newTransparentBorderColor); + signals: void normalColorChanged(); @@ -87,6 +95,10 @@ signals: void parametryChanged(); + void transparentBCChanged(); + + void transparentBorderColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); @@ -98,6 +110,8 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_transparentBC; + QBrush m_transparentBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIPopup, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.cpp b/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.cpp index 11194e5..2fb5b9f 100644 --- a/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -35,253 +37,166 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran //} using namespace UKUIQQC2Style; -UKUIPopupWindowHandle::UKUIPopupWindowHandle(QObject *parent) - : QObject (parent) +UKUIPopupWindowHandle::UKUIPopupWindowHandle(QQuickItem *parent) + : QQuickItem (parent) { -} + setFlag(ItemHasContents, false); // 不显示任何内容 + setAcceptHoverEvents(false); // 不接受鼠标悬停事件 + setAcceptTouchEvents(false); // 不接受触摸事件 + setAcceptedMouseButtons(Qt::NoButton); // 不接受鼠标点击事件 -UKUIPopupWindowHandle::~UKUIPopupWindowHandle() -{ + QByteArray envValue = qgetenv("QT_QPA_PLATFORM"); -} + if (!envValue.isEmpty()) { + QString value = QString::fromUtf8(envValue); + if(value == "xcb") + { + m_isXCB = true; -UKUIPopupWindowHandle *UKUIPopupWindowHandle::qmlAttachedProperties(QObject *object) -{ + // qDebug() << "xcbxbcxcbxcb....." << m_isXCB; - if (!object || !object->inherits("QQuickPopup")) - return nullptr; + } + } + connect(this, &QQuickItem::windowChanged, this, [this](QQuickWindow *window) { + if (window) { + if(m_windowStaysOnTopHint) + window->setFlags(Qt::FramelessWindowHint | Qt::Window | Qt::ToolTip | Qt::WindowStaysOnTopHint); + else{ +//task 576023 menu.qml设置popup属性后,虚拟键盘菜单异常 + if(QQmlEngine::contextForObject(this) && QQmlEngine::contextForObject(this)->engine()){ + QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine(); + if(engine->property("flags").isValid() && engine->property("flags").canConvert() && + engine->property("flags").value() == "WindowDoesNotAcceptFocus"){ + window->setFlags(Qt::ToolTip); + } + else + window->setFlags(Qt::Popup); + } + else + window->setFlags(Qt::Popup); + } + + if(!m_isXCB){ + m_windowHelper = new UkuiWindowHelper(window); + if (!m_titlebarVisible) + m_windowHelper->removeTitleBar(); + m_windowHelper->setSkipSwitcher(true); + m_windowHelper->setSkipTaskBar(true); +// QPainterPath path; +// path.addRoundedRect(x(), y(), width(), height(), m_radius, m_radius); +// QRegion effectRegion(path.toFillPolygon().toPolygon()); + m_windowHelper->setDecorationCompoents(UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::Shadow) | + UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::Border) | + UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::RoundCorner)); + + if(m_blurEnabled) + m_windowHelper->setBlurEffect(QRegion()); + } + } + }, Qt::UniqueConnection); +} - return new UKUIPopupWindowHandle(object); +UKUIPopupWindowHandle::~UKUIPopupWindowHandle() +{ + if(m_windowHelper){ + m_windowHelper->deleteLater(); + m_windowHelper = nullptr; + } } -QQmlComponent *UKUIPopupWindowHandle::delegate() const +void UKUIPopupWindowHandle::setBlurStrength(int strength) { - return m_delegate; + m_blurStrength = strength; } -void UKUIPopupWindowHandle::setDelegate(QQmlComponent *delegate) +void UKUIPopupWindowHandle::setBlurEnabled(int enabled) { - m_delegate = delegate; + m_blurEnabled = enabled; } -void UKUIPopupWindowHandle::open() +void UKUIPopupWindowHandle::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - if(!m_window) - createHandle(); + QQuickItem::geometryChanged(newGeometry, oldGeometry); + if (m_windowHelper && m_blurEnabled && !m_isXCB) { +// QPainterPath path; +// path.addRoundedRect(x(), y(), width(), height(), m_radius, m_radius); +// QRegion effectRegion(path.toFillPolygon().toPolygon()); -// qDebug() << "open show 000...." << m_window << m_window->isVisible(); - if(m_window && !m_window->isVisible()){ - updateWindow(); -// qDebug() << "open show 1111...." << m_window << m_window->isVisible(); + m_windowHelper->setBlurEffect(QRegion()); - m_window->show(); } -// qDebug() << "open show 2222...." << m_window << m_window->isVisible(); } -void UKUIPopupWindowHandle::close() +void UKUIPopupWindowHandle::setTitlebarVisible(bool visible) { - if(m_window && m_window->isVisible()){ -// qDebug() << "close hide 000...." << m_window << m_window->isVisible(); - - m_window->hide(); -// qDebug() << "close hide 111...." << m_window << m_window->isVisible(); - } + m_titlebarVisible = visible; } -void UKUIPopupWindowHandle::updateWindow() + + +QSize UKUIPopupWindowHandle::getScreenSize() { // 获取鼠标所在屏幕,如果没有特别指定,这里通常会是主屏幕 const QScreen *screen =QGuiApplication::screenAt(QCursor::pos()); Q_ASSERT(screen); if(!screen) - return; + return QSize(); // 获取屏幕尺寸 - QRect screenGeometry = screen->geometry(); + QRect screenGeometry = screen->availableGeometry(); int screenWidth = screenGeometry.width(); int screenHeight = screenGeometry.height(); + return QSize(screenWidth, screenHeight); - if(m_y + m_height > screenGeometry.y() + screenHeight) - { - m_height = screenGeometry.y() + screenHeight - m_y; - setOutScreen(true); - } - else - setOutScreen(false); - emit sizeChanged(m_width, m_height); - - if(m_x + m_width > screenGeometry.x() + screenWidth)//超出屏幕 - { - //todo 调整位置 - } - - if(m_window){ - if(m_width <= 0) - m_width = 1; - if(m_height <= 0) - m_height = 1; - m_window->setX(m_x); - m_window->setY(m_y); -// qDebug() << "UKUIPopupWindowHandle..." << m_width; - m_window->setWidth(m_width); - m_window->setHeight(m_height); - - m_window->update(); - } } -void UKUIPopupWindowHandle::setSize(int width, int height) +QPoint UKUIPopupWindowHandle::getScreenPoint() { -// qDebug() << "setsize..." << width << height; - m_width = width; - m_height = height; - if(m_window){ - updateWindow(); - } -} - -void UKUIPopupWindowHandle::setPosion(int x, int y) -{ -// qDebug() << "setPosion..." << x << y; - if(!posFollwMouse()){ - m_x = x; - m_y = y; - } - else{ - QPoint p = posByCursor(); - m_x = p.x(); - m_y = p.y(); - } -// qDebug() << "posFollwMouse..." << posFollwMouse() << m_x << m_y; - if(m_window){ - updateWindow(); - } -} - -void UKUIPopupWindowHandle::createHandle() -{ -// qDebug() << "createHandle m_delegate...." << m_delegate; - - if(m_delegate){ - -// qDebug() << "createHandle...." << m_delegate << m_delegate->creationContext() << m_delegate->creationContext()->children(); - auto window = qobject_cast(m_delegate->create(m_delegate->creationContext())); - Q_ASSERT(window); - QColor c = Qt::transparent; -// if(m_backColor.canConvert()){ -// QBrush b = m_backColor.value(); -// c = b.color(); -// c.setAlphaF(0.65); -// } -// qDebug() << "create window...." << window << c << c.red() << c.green() << c.blue() << c.alphaF(); - window->setColor(c); - window->setFlags(Qt::Popup | Qt::FramelessWindowHint); - m_window = window; - - QPainterPath path; - int radius = 8; - if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { - auto settings = UKUIStyleSettings::globalInstance(); - if(settings->keys().contains("windowRadius")) - radius = settings->get("windowRadius").toInt(); - } - path.addRoundedRect(m_x, m_y, m_width, m_height, radius, radius);//设置这个path 没有毛玻璃效果 - UkuiWindowHelper *windowHelper = new UkuiWindowHelper(m_window); - windowHelper->removeTitleBar(); - windowHelper->setBlurEffect(path.toFillPolygon().toPolygon()); - - - connect(m_window, &QQuickWindow::visibleChanged, this, [=](bool arg){ -// qDebug() << "m_window visible changed..." << arg << m_window->isVisible(); - emit visibleChanged(arg); - }, Qt::QueuedConnection); - } -} - -void UKUIPopupWindowHandle::createWindow(QObject *obj) -{ -// qDebug() << "createWindow...." << obj << qobject_cast(obj); - auto window = qobject_cast(obj); - Q_ASSERT(window); - QColor c = Qt::transparent; -// if(m_backColor.canConvert()){ -// QBrush b = m_backColor.value(); -// c = b.color(); -// c.setAlphaF(0.65); -// } -// qDebug() << "create window...." << window << c << c.red() << c.green() << c.blue() << c.alphaF(); - window->setColor(c); - window->setFlags(Qt::Popup | Qt::ToolTip); - m_window = window; - - - QPainterPath path; - int radius = 8; - if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { - auto settings = UKUIStyleSettings::globalInstance(); - if(settings->keys().contains("windowRadius")) - radius = settings->get("windowRadius").toInt(); - } - path.addRoundedRect(m_x, m_y, m_width, m_height, radius, radius);//设置这个path 没有毛玻璃效果 - m_window->setProperty("ukui_surface_no_titlebar", true); - QPair p; - p.first = path.toFillPolygon().toPolygon(); - m_window->setProperty("ukui_surface_blur", QVariant::fromValue(p)); - - connect(m_window, &QQuickWindow::visibleChanged, this, [=](bool arg){ - -// qDebug() << "m_window visible changed..." << arg << m_window->isVisible(); - emit visibleChanged(arg); - }, Qt::QueuedConnection); + // 获取鼠标所在屏幕,如果没有特别指定,这里通常会是主屏幕 + const QScreen *screen =QGuiApplication::screenAt(QCursor::pos()); + Q_ASSERT(screen); + if(!screen) + return QPoint(); + // 获取屏幕尺寸 + QRect screenGeometry = screen->availableGeometry(); + return QPoint(screenGeometry.x(), screenGeometry.y()); } -bool UKUIPopupWindowHandle::outScreen() -{ - return m_outScreen; -} -void UKUIPopupWindowHandle::setOutScreen(bool newOutScreen) -{ -// qDebug() << "setOutScreen....." << newOutScreen; - if (m_outScreen == newOutScreen) - return; - m_outScreen = newOutScreen; - emit outScreenChanged(m_outScreen); -} -QPoint UKUIPopupWindowHandle::posByCursor() +QPoint UKUIPopupWindowHandle::posByCursor(int width, int height) { QPoint p = QCursor::pos(); - if(!m_window) - return p; + // qDebug() << "cursor pos:" << p; const QScreen *screen =QGuiApplication::screenAt(QCursor::pos()); if (const QPlatformScreen *platformScreen = screen ? screen->handle() : nullptr) { QPlatformCursor *cursor = platformScreen->cursor(); const QSize nativeSize = cursor ? cursor->size() : QSize(16, 16); const QSize cursorSize = QHighDpi::fromNativePixels(nativeSize, platformScreen); QPoint offset(2, cursorSize.height()); - if (cursorSize.height() > 2 * m_window->height()) { + if (cursorSize.height() > 2 * height) { offset = QPoint(cursorSize.width() / 2, 0); } p += offset; - QRect screenRect = screen->geometry(); - if (p.x() + m_window->width() > screenRect.x() + screenRect.width()) - p.rx() -= 4 + m_window->width(); - if (p.y() + m_window->height() > screenRect.y() + screenRect.height()) - p.ry() -= 24 + m_window->height(); + QRect screenRect = screen->availableGeometry(); + if (p.x() + width > screenRect.x() + screenRect.width()) + p.rx() -= 4 + width; + if (p.y() + height > screenRect.y() + screenRect.height()) + p.ry() -= 24 + height; if (p.y() < screenRect.y()) p.setY(screenRect.y()); - if (p.x() + m_window->width() > screenRect.x() + screenRect.width()) - p.setX(screenRect.x() + screenRect.width() - m_window->width()); + if (p.x() + width > screenRect.x() + screenRect.width()) + p.setX(screenRect.x() + screenRect.width() - width); if (p.x() < screenRect.x()) p.setX(screenRect.x()); - if (p.y() + m_window->height() > screenRect.y() + screenRect.height()) - p.setY(screenRect.y() + screenRect.height() - m_window->height()); + if (p.y() + height > screenRect.y() + screenRect.height()) + p.setY(screenRect.y() + screenRect.height() - height); } + // qDebug() << "cursor pos1:" << p; + return p; } @@ -295,300 +210,12 @@ void UKUIPopupWindowHandle::setPosFollwMouse(bool newPosFollwMouse) m_posFollwMouse = newPosFollwMouse; } -const QVariant &UKUIPopupWindowHandle::backColor() const -{ - return m_backColor; -} - -void UKUIPopupWindowHandle::setBackColor(const QVariant &newBackColor) -{ - m_backColor = newBackColor; -} - - -const QVariant &UKUIPopupWindowHandle::shadowColor() const -{ - return m_shadowColor; -} - -void UKUIPopupWindowHandle::setShadowColor(const QVariant &newShadowColor) -{ - m_shadowColor = newShadowColor; -} - -/* -void UKUIPopupWindowHandle::createShadow() +void UKUIPopupWindowHandle::setRadius(int newRadius) { - QColor c = Qt::transparent; - if(m_shadowColor.canConvert()){ - QBrush b = m_shadowColor.value(); - c = b.color(); - } - auto shadowColor = QColor(Qt::red); - - int shadowBorder = 20; - bool ok = false; - qreal darkness = 1.0; - if (!ok) { - darkness = 1.0; - } - QVector4D radius = QVector4D(1, 1, 1, 1); - QVector4D margins = QVector4D(20, 20, 20, 20); - - m_windowShadow = getShadow(shadowColor, shadowBorder, darkness, radius.x(), radius.y(), radius.z(), radius.w()); - - m_windowShadow->setPadding(QMargins(margins.x(), margins.y(), margins.z(), margins.w())); - m_windowShadow->setWindow(m_window); -// qDebug() << "m_windowShadow create..." << m_windowShadow->create(); + m_radius = newRadius; } -void UKUIPopupWindowHandle::destoryShadow() +void UKUIPopupWindowHandle::setWindowStaysOnTopHint(bool newWindowStaysOnTopHint) { - if(m_windowShadow){ - m_windowShadow->destroy(); - m_windowShadow->deleteLater(); - m_windowShadow = nullptr; - } - -} - - -KWindowShadow *UKUIPopupWindowHandle::getShadow(QColor color, int shadow_border, qreal darkness, int borderRadiusTopLeft, int borderRadiusTopRight, int borderRadiusBottomLeft, int borderRadiusBottomRight) -{ - QPixmap shadowPixmap = getShadowPixmap(color, shadow_border, darkness, borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomLeft, borderRadiusBottomRight); - qreal maxTopRadius = qMax(borderRadiusTopLeft, borderRadiusTopRight); - qreal maxBottomRadius = qMax(borderRadiusBottomLeft, borderRadiusBottomRight); - int maxRadius = qMax(maxTopRadius, maxBottomRadius); - maxRadius = qMax(12, maxRadius); - - QPixmap topLeftPixmap = shadowPixmap.copy(0, 0, maxRadius + shadow_border, maxRadius + shadow_border); - QPixmap topPixmap = shadowPixmap.copy(maxRadius + shadow_border, 0, INNERRECT_WIDTH, maxRadius + shadow_border); - QPixmap topRightPixmap = shadowPixmap.copy(maxRadius + shadow_border + INNERRECT_WIDTH, 0, maxRadius + shadow_border, maxRadius + shadow_border); - QPixmap leftPixmap = shadowPixmap.copy(0, maxRadius + shadow_border, maxRadius + shadow_border, INNERRECT_WIDTH); - QPixmap rightPixmap = shadowPixmap.copy(maxRadius + shadow_border + INNERRECT_WIDTH, maxRadius + shadow_border, maxRadius + shadow_border, INNERRECT_WIDTH); - QPixmap bottomLeftPixmap = shadowPixmap.copy(0, maxRadius + shadow_border + INNERRECT_WIDTH, maxRadius + shadow_border, maxRadius + shadow_border); - QPixmap bottomPixmap = shadowPixmap.copy(maxRadius + shadow_border, maxRadius + shadow_border + INNERRECT_WIDTH, INNERRECT_WIDTH, maxRadius + shadow_border); - QPixmap bottomRightPixmap = shadowPixmap.copy(maxRadius + shadow_border + INNERRECT_WIDTH, maxRadius + shadow_border + INNERRECT_WIDTH, maxRadius + shadow_border, maxRadius + shadow_border); - - 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; -} - - -QPixmap UKUIPopupWindowHandle::getShadowPixmap(QColor color, int shadow_border, qreal darkness, int borderRadiusTopLeft, int borderRadiusTopRight, int borderRadiusBottomLeft, int borderRadiusBottomRight) -{ - int maxTopRadius = qMax(borderRadiusTopLeft, borderRadiusTopRight); - int maxBottomRadius = qMax(borderRadiusBottomLeft, borderRadiusBottomRight); - int maxRadius = qMax(maxTopRadius, maxBottomRadius); - maxRadius = qMax(12, maxRadius); - QPixmap pix(QSize(2 * maxRadius + 2 * shadow_border + INNERRECT_WIDTH, 2 * maxRadius + 2 * shadow_border + INNERRECT_WIDTH)); - pix.fill(Qt::transparent); - - int squareWidth = 2 * maxRadius + INNERRECT_WIDTH; - - QPainterPath windowRelativePath; - windowRelativePath.setFillRule(Qt::WindingFill); - QPoint currentPos; - - int qAppMaxradius = maxRadius; - auto settings = UKUIStyleSettings::globalInstance(); - if(settings && settings->keys().contains("windowRadius")) - qAppMaxradius = settings->get("windowRadius").toInt(); - // move to top left arc start point - windowRelativePath.moveTo(borderRadiusTopLeft, 0); - // top left arc - auto topLeftBorderRadiusRect = QRect(0, 0, 2 * borderRadiusTopLeft, 2 * borderRadiusTopLeft); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(topLeftBorderRadiusRect, 90, 90); - else - windowRelativePath.addRect(topLeftBorderRadiusRect); - // move to bottom left arc start point - currentPos = QPoint(0, maxRadius + INNERRECT_WIDTH + maxRadius - borderRadiusBottomLeft); - //windowRelativePath.moveTo(currentPos); - // bottom left arc - auto bottomLeftRect = QRect(0, currentPos.y() - borderRadiusBottomLeft, 2 * borderRadiusBottomLeft, 2 * borderRadiusBottomLeft); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(bottomLeftRect, 180, 90); - else - windowRelativePath.addRect(bottomLeftRect); - - // move to bottom right arc start point - currentPos = QPoint(2 * maxRadius + INNERRECT_WIDTH - borderRadiusBottomRight, 2 * maxRadius + INNERRECT_WIDTH); - //windowRelativePath.moveTo(currentPos); - // bottom right arc - auto bottomRightRect = QRect(currentPos.x() - borderRadiusBottomRight, currentPos.y() - 2 * borderRadiusBottomRight, 2 * borderRadiusBottomRight, 2 * borderRadiusBottomRight); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(bottomRightRect, 270, 90); - else - windowRelativePath.addRect(bottomRightRect); - - // move to top right arc start point - currentPos = QPoint(2 * maxRadius + INNERRECT_WIDTH, borderRadiusTopRight); - //windowRelativePath.moveTo(currentPos); - // top right arc - auto topRightRect = QRect(squareWidth - 2 * borderRadiusTopRight, 0, 2 * borderRadiusTopRight, 2 * borderRadiusTopRight); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(topRightRect, 0, 90); - else - windowRelativePath.addRect(topRightRect); - - QPainter painter(&pix); - painter.save(); - painter.translate(shadow_border, shadow_border); - painter.fillPath(windowRelativePath, QColor(26,26,26)); - painter.restore(); - - QImage rawImg = pix.toImage(); - qt_blurImage(rawImg, shadow_border, true, true); - - QPixmap target = QPixmap::fromImage(rawImg); - QPainter painter2(&target); - painter2.save(); - painter2.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - painter2.translate(shadow_border, shadow_border); - painter2.setCompositionMode(QPainter::CompositionMode_Clear); - painter2.fillPath(windowRelativePath, Qt::transparent); - painter2.restore(); - painter2.end(); - - // handle darkness - QImage newImg = target.toImage(); - for (int x = 0; x < newImg.width(); x++) { - for (int y = 0; y < newImg.height(); y++) { - auto color = newImg.pixelColor(x, y); - if (color.alpha() == 0) - continue; - color.setAlphaF(darkness * color.alphaF()); - newImg.setPixelColor(x, y, color); - } - } - - QPixmap darkerTarget = QPixmap::fromImage(newImg); - painter2.begin(&darkerTarget); - - auto borderPath = caculateRelativePainterPath(borderRadiusTopLeft + 0.5, borderRadiusTopRight + 0.5, borderRadiusBottomLeft + 0.5, borderRadiusBottomRight + 0.5); - painter2.setCompositionMode(QPainter::CompositionMode_DestinationOver); - painter2.setRenderHint(QPainter::HighQualityAntialiasing); - QColor borderColor = color; - borderColor.setAlphaF(0.05); - painter2.setPen(borderColor); - painter2.setBrush(Qt::NoBrush); - painter2.translate(shadow_border, shadow_border); - painter2.translate(-0.5, -0.5); -// painter2.drawPath(borderPath); - - return darkerTarget; -} - - -QPainterPath UKUIPopupWindowHandle::caculateRelativePainterPath(qreal borderRadiusTopLeft, qreal borderRadiusTopRight, qreal borderRadiusBottomLeft, qreal borderRadiusBottomRight) -{ - qreal maxTopRadius = qMax(borderRadiusTopLeft, borderRadiusTopRight); - qreal maxBottomRadius = qMax(borderRadiusBottomLeft, borderRadiusBottomRight); - qreal maxRadius = qMax(maxTopRadius, maxBottomRadius); - maxRadius = qMax(12.0, maxRadius); - - qreal squareWidth = 2 * maxRadius + INNERRECT_WIDTH; - - QPainterPath windowRelativePath; - windowRelativePath.setFillRule(Qt::WindingFill); - QPointF currentPos; - - int qAppMaxradius = maxRadius; - auto settings = UKUIStyleSettings::globalInstance(); - if(settings && settings->keys().contains("windowRadius")) - qAppMaxradius = settings->get("windowRadius").toInt(); - - // move to top left arc start point - windowRelativePath.moveTo(borderRadiusTopLeft, 0); - // top left arc - auto topLeftBorderRadiusRect = QRectF(0, 0, 2 * borderRadiusTopLeft, 2 * borderRadiusTopLeft); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(topLeftBorderRadiusRect, 90, 90); - else - windowRelativePath.addRect(topLeftBorderRadiusRect); - - // move to bottom left arc start point - currentPos = QPointF(0, maxRadius + INNERRECT_WIDTH + maxRadius - borderRadiusBottomLeft); - //windowRelativePath.moveTo(currentPos); - // bottom left arc - auto bottomLeftRect = QRectF(0, currentPos.y() - borderRadiusBottomLeft, 2 * borderRadiusBottomLeft, 2 * borderRadiusBottomLeft); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(bottomLeftRect, 180, 90); - else - windowRelativePath.addRect(bottomLeftRect); - - // move to bottom right arc start point - currentPos = QPointF(2 * maxRadius + INNERRECT_WIDTH - borderRadiusBottomRight, 2 * maxRadius + INNERRECT_WIDTH); - //windowRelativePath.moveTo(currentPos); - // bottom right arc - auto bottomRightRect = QRectF(currentPos.x() - borderRadiusBottomRight, currentPos.y() - 2 * borderRadiusBottomRight, 2 * borderRadiusBottomRight, 2 * borderRadiusBottomRight); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(bottomRightRect, 270, 90); - else - windowRelativePath.addRect(bottomRightRect); - - // move to top right arc start point - currentPos = QPointF(2 * maxRadius + INNERRECT_WIDTH, borderRadiusTopRight); - //windowRelativePath.moveTo(currentPos); - // top right arc - auto topRightRect = QRectF(squareWidth - 2 * borderRadiusTopRight, 0, 2 * borderRadiusTopRight, 2 * borderRadiusTopRight); - if(qAppMaxradius > 0) - windowRelativePath.arcTo(topRightRect, 0, 90); - else - windowRelativePath.addRect(topRightRect); - - return windowRelativePath; -} -*/ - -bool UKUIPopupWindowHandle::visible() -{ -// qDebug() << "handle visible..." << m_visible; - if(m_window) - m_visible = m_window->isVisible(); - return m_visible; -} - -void UKUIPopupWindowHandle::setVisible(bool newVisible) -{ -// qDebug() << "handle setVisible..." << newVisible << m_visible; - - if (m_visible == newVisible) - return; - m_visible = newVisible; - if(m_window){ - if(m_visible) - updateWindow(); - m_window->setVisible(m_visible); - } - else{ - createHandle(); - m_window->setVisible(m_visible); - } + m_windowStaysOnTopHint = newWindowStaysOnTopHint; } diff --git a/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.h b/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.h index 231440e..e06f310 100644 --- a/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.h +++ b/ukui-qml-style-helper/styleparameter/ukuipopupwindowhandle.h @@ -31,86 +31,72 @@ #include //#include //#include +#include "ukuiwindowhelper.h" #include "tokenparameter.h" namespace UKUIQQC2Style { -class UKUIPopupWindowHandle : public QObject +class UKUIPopupWindowHandle : public QQuickItem { Q_OBJECT - Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate) - Q_PROPERTY(bool outScreen READ outScreen WRITE setOutScreen NOTIFY outScreenChanged) Q_PROPERTY(bool posFollwMouse READ posFollwMouse WRITE setPosFollwMouse) - Q_PROPERTY(QVariant backColor READ backColor WRITE setBackColor) - Q_PROPERTY(QVariant shadowColor READ shadowColor WRITE setShadowColor) - Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged) + /** + * The enabled state of the window blur effect + */ + Q_PROPERTY(bool blur WRITE setBlurEnabled) - QML_NAMED_ELEMENT(PopupHandle) - QML_ATTACHED(UKUIPopupWindowHandle) + /** + * The strength of the window blur effect + */ + Q_PROPERTY(int blurStrength WRITE setBlurStrength) -public: - explicit UKUIPopupWindowHandle(QObject *parent = nullptr); - ~UKUIPopupWindowHandle() override; - - UKUIPopupWindowHandle* qmlAttachedProperties(QObject *object); - - Q_INVOKABLE void open(); - Q_INVOKABLE void close(); - Q_INVOKABLE void setSize(int width, int height); - Q_INVOKABLE void setPosion(int x, int y); - Q_INVOKABLE QPoint posByCursor(); - Q_INVOKABLE void createWindow(QObject *obj); - bool outScreen(); + /** + * The visible of server-side titlebar + */ + Q_PROPERTY(bool titlebarVisible WRITE setTitlebarVisible) - void updateWindow(); - QQmlComponent *delegate() const; - void setDelegate(QQmlComponent *newDelegate); + Q_PROPERTY(int radius WRITE setRadius) - void setOutScreen(bool newOutScreen); - - bool posFollwMouse() const; - void setPosFollwMouse(bool newPosFollwMouse); + Q_PROPERTY(bool windowStaysOnTopHint WRITE setWindowStaysOnTopHint) - const QVariant &backColor() const; - void setBackColor(const QVariant &newBackColor); - const QVariant &shadowColor() const; - void setShadowColor(const QVariant &newShadowColor); +// QML_NAMED_ELEMENT(PopupHandle) +// QML_ATTACHED(UKUIPopupWindowHandle) +public: + explicit UKUIPopupWindowHandle(QQuickItem *parent = nullptr); + ~UKUIPopupWindowHandle() override; -// void createShadow(); -// void destoryShadow(); + Q_INVOKABLE QPoint posByCursor(int width, int height); + Q_INVOKABLE QSize getScreenSize(); + Q_INVOKABLE QPoint getScreenPoint(); -// QPainterPath caculateRelativePainterPath(qreal borderRadiusTopLeft, qreal borderRadiusTopRight, qreal borderRadiusBottomLeft, qreal borderRadiusBottomRight); -// KWindowShadow *getShadow(QColor color, int shadow_border, qreal darkness, int borderRadiusTopLeft, int borderRadiusTopRight, int borderRadiusBottomLeft, int borderRadiusBottomRight); -// QPixmap getShadowPixmap(QColor color, /*ConfigShadowHelper::State state,*/ int shadow_border, qreal darkness, int borderRadiusTopLeft, int borderRadiusTopRight, int borderRadiusBottomLeft, int borderRadiusBottomRight); - bool visible(); - void setVisible(bool newVisible); + bool posFollwMouse() const; + void setPosFollwMouse(bool newPosFollwMouse); + void setBlurStrength(int strength); + void setBlurEnabled(int enabled); + void setTitlebarVisible(bool visible); + void setRadius(int newRadius); -Q_SIGNALS: - void visibleChanged(bool visible); - void sizeChanged(int width, int height); - void outScreenChanged(bool outScreen); + void setWindowStaysOnTopHint(bool newWindowStaysOnTopHint); -private Q_SLOTS: - void createHandle(); +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; private: - QQmlComponent *m_delegate = nullptr; - QQuickWindow *m_window = nullptr; - int m_width = 0; - int m_height = 0; - int m_x = 0; - int m_y = 0; - bool m_outScreen = false; bool m_posFollwMouse = false; - QVariant m_backColor; - QVariant m_shadowColor; -// KWindowShadow *m_windowShadow = nullptr; - bool m_visible = false; + int m_blurStrength = 0; + bool m_blurEnabled = false; + bool m_titlebarVisible = true; + bool m_isXCB = false; + + UkuiWindowHelper *m_windowHelper = nullptr; + + int m_radius = 0; + bool m_windowStaysOnTopHint = false; }; } diff --git a/ukui-qml-style-helper/styleparameter/ukuiprogressbar.cpp b/ukui-qml-style-helper/styleparameter/ukuiprogressbar.cpp index 53da116..f728f3f 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiprogressbar.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuiprogressbar.cpp @@ -8,11 +8,13 @@ UKUIProgressBar::UKUIProgressBar(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIProgressBar::~UKUIProgressBar() @@ -24,13 +26,36 @@ void UKUIProgressBar::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { setRadius(instance->kradiusNormal()); setNormalColor(instance->kComponentNormal()); - setChildrenColor(instance->highLightActive()); + setChildrenColor(instance->kBrandNormal()); setNormalWidth(243); - setNormalHeight(30); - setIndeterminateChildrenWidth(56); + setNormalHeight(24); + setIndeterminateChildrenWidth(48); setBorderWidth(1); setBorderColor(instance->kLineComponentNormal()); - setHightlightTextColor(instance->highLightedTextActive()); + setHightlightTextColor(instance->kFontWhite()); + setNormalTransparentColor(instance->kComponentAlphaNormal()); + setTransparentBorderColor(instance->kLineComponentNormal()); + + + QColor baseColor = instance->kBrandNormal().color(); + // 获取颜色分量 + int r = baseColor.red(); + int g = baseColor.green(); + int b = baseColor.blue(); + + r = calculateHighColor(r); + g = calculateHighColor(g); + b = calculateHighColor(b); + + QColor color; + color.setRed(r); + color.setGreen(g); + color.setBlue(b); + + QLinearGradient linearGradient; + linearGradient.setColorAt(1, baseColor); + linearGradient.setColorAt(0, color); + setIndeterminateColor(QBrush(linearGradient)); emit parametryChanged(); @@ -185,3 +210,49 @@ void UKUIProgressBar::setHightlightTextColor(const QBrush &newHightlightTextColo m_hightlightTextColor = newHightlightTextColor; emit hightlightTextColorChanged(); } + +const QBrush &UKUIProgressBar::normalTransparentColor() const +{ + return m_normalTransparentColor; +} + +void UKUIProgressBar::setNormalTransparentColor(const QBrush &newNormalTransparentColor) +{ + if (m_normalTransparentColor == newNormalTransparentColor) + return; + m_normalTransparentColor = newNormalTransparentColor; + emit normalTransparentColorChanged(); +} + +const QBrush &UKUIProgressBar::transparentborderColor() const +{ + return m_transparentborderColor; +} + +void UKUIProgressBar::setTransparentBorderColor(const QBrush &newTransparentborderColor) +{ + if (m_transparentborderColor == newTransparentborderColor) + return; + m_transparentborderColor = newTransparentborderColor; + emit transparentBorderColorChanged(); +} + +const QBrush &UKUIProgressBar::indeterminateColor() const +{ + return m_indeterminateColor; +} + +void UKUIProgressBar::setIndeterminateColor(const QBrush &newIndeterminateColor) +{ + m_indeterminateColor = newIndeterminateColor; + emit indeterminateColorChanged(); + +} + +int UKUIProgressBar::calculateHighColor(int c) +{ + if(c > 128) + return 255 - (255 - c) * (255 - 255) * 1.0 / 128.0; + else + return c * 255 * 1.0 / 128 * 1.0; +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiprogressbar.h b/ukui-qml-style-helper/styleparameter/ukuiprogressbar.h index 414a022..c03807b 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiprogressbar.h +++ b/ukui-qml-style-helper/styleparameter/ukuiprogressbar.h @@ -52,6 +52,10 @@ class UKUIProgressBar : public QQuickItem Q_PROPERTY(QBrush hightlightTextColor READ hightlightTextColor WRITE setHightlightTextColor NOTIFY hightlightTextColorChanged) + Q_PROPERTY(QBrush normalTransparentColor READ normalTransparentColor WRITE setNormalTransparentColor NOTIFY normalTransparentColorChanged) + Q_PROPERTY(QBrush transparentborderColor READ transparentborderColor WRITE setTransparentBorderColor NOTIFY transparentBorderColorChanged) + + Q_PROPERTY(QBrush indeterminateColor READ indeterminateColor WRITE setIndeterminateColor NOTIFY indeterminateColorChanged) public: explicit UKUIProgressBar(QQuickItem *parent = nullptr); ~UKUIProgressBar(); @@ -93,6 +97,17 @@ public: const QBrush &hightlightTextColor() const; void setHightlightTextColor(const QBrush &newHightlightTextColor); + const QBrush &normalTransparentColor() const; + void setNormalTransparentColor(const QBrush &newNormalTransparentColor); + + const QBrush &transparentborderColor() const; + void setTransparentBorderColor(const QBrush &newTransparentborderColor); + + const QBrush &indeterminateColor() const; + void setIndeterminateColor(const QBrush &newIndeterminateColor); + + int calculateHighColor(int c); + signals: void normalColorChanged(); @@ -118,6 +133,12 @@ signals: void hightlightTextColorChanged(); + void normalTransparentColorChanged(); + + void transparentBorderColorChanged(); + + void indeterminateColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); @@ -134,6 +155,9 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; QBrush m_hightlightTextColor; + QBrush m_normalTransparentColor; + QBrush m_transparentborderColor; + QBrush m_indeterminateColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIProgressBar, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuiradiobutton.cpp b/ukui-qml-style-helper/styleparameter/ukuiradiobutton.cpp index 3983456..c8d8bf6 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiradiobutton.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuiradiobutton.cpp @@ -8,11 +8,13 @@ UKUIRadioButton::UKUIRadioButton(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIRadioButton::~UKUIRadioButton() @@ -30,33 +32,42 @@ void UKUIRadioButton::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { setNormalTextColor(instance->kFontPrimary()); setDisableTextColor(instance->kFontPrimaryDisable()); - setNormalIndicatorColor(instance->buttonActive()); + setNormalIndicatorColor(instance->kComponentNormal()); setHoverIndicatorColor(instance->kComponentHover()); setClickIndicatorColor(instance->kComponentClick()); - setDisableIndicatorColor(instance->buttonDisable()); - setNormalIndicatorBorderColor(instance->kLineNormal()); - setHoverIndicatorBorderColor(instance->kLineNormal()); - setClickIndicatorBorderColor(instance->kLineNormal()); - setDisableIndicatorBorderColor(instance->kLineDisable()); + setDisableIndicatorColor(instance->kComponentDisable()); + setNormalIndicatorBorderColor(instance->kLineSelectboxNormal()); + setHoverIndicatorBorderColor(instance->kLineSelectboxHover()); + setClickIndicatorBorderColor(instance->kLineSelectboxClick()); + setDisableIndicatorBorderColor(instance->kLineSelectboxDisable()); - setChecked_NormalIndicatorColor(instance->highLightActive()); + setChecked_NormalIndicatorColor(instance->kBrandNormal()); setChecked_HoverIndicatorColor(instance->kBrandHover()); setChecked_ClickIndicatorColor(instance->kBrandClick()); - setChecked_DisableIndicatorColor(instance->buttonDisable()); - setChecked_NormalIndicatorBorderColor(instance->kLineNormal()); - setChecked_HoverIndicatorBorderColor(instance->kLineNormal()); - setChecked_ClickIndicatorBorderColor(instance->kLineNormal()); - setChecked_DisableIndicatorBorderColor(instance->kLineDisable()); - - setChecked_NormalChildrenColor(instance->highLightedTextActive()); - setChecked_HoverChildrenColor(instance->highLightedTextActive()); - setChecked_ClickChildrenColor(instance->highLightedTextActive()); - setChecked_DisableChildrenColor(instance->highLightedTextDisable()); + setChecked_DisableIndicatorColor(instance->kBrandDisable()); + setChecked_NormalIndicatorBorderColor(instance->kLineSelectboxNormal()); + setChecked_HoverIndicatorBorderColor(instance->kLineSelectboxHover()); + setChecked_ClickIndicatorBorderColor(instance->kLineSelectboxClick()); + setChecked_DisableIndicatorBorderColor(instance->kLineSelectboxDisable()); + + setChecked_NormalChildrenColor(instance->kFontWhite()); + setChecked_HoverChildrenColor(instance->kFontWhite()); + setChecked_ClickChildrenColor(instance->kFontWhite()); + setChecked_DisableChildrenColor(instance->kFontWhiteDisable()); + + setNormalTransparentIndicatorColor(instance->kComponentAlphaNormal()); + setHoverTransparentIndicatorColor(instance->kComponentAlphaHover()); + setClickTransparentIndicatorColor(instance->kComponentAlphaClick()); + setDisableTransparentIndicatorColor(instance->kComponentAlphaDisable()); + setNormalTransparentIndicatorBorderColor(instance->kLineSelectboxNormal()); + setHoverTransparentIndicatorBorderColor(instance->kLineSelectboxHover()); + setClickTransparentIndicatorBorderColor(instance->kLineSelectboxClick()); + setDisableTransparentIndicatorBorderColor(instance->kLineSelectboxDisable()); setBorderWidth(instance->normalline()); setSpace(8); setIndicatorWidth(16); - setChildrenWidth(8); + setChildrenWidth(6); emit parametryChanged(); @@ -482,3 +493,107 @@ void UKUIRadioButton::setChildrenWidth(int newChildrenWidth) m_childrenWidth = newChildrenWidth; emit childrenWidthChanged(); } + +const QBrush &UKUIRadioButton::normalTransparentIndicatorColor() const +{ + return m_normalTransparentIndicatorColor; +} + +void UKUIRadioButton::setNormalTransparentIndicatorColor(const QBrush &newNormalTransparentIndicatorColor) +{ + if (m_normalTransparentIndicatorColor == newNormalTransparentIndicatorColor) + return; + m_normalTransparentIndicatorColor = newNormalTransparentIndicatorColor; + emit normalTransparentIndicatorColorChanged(); +} + +const QBrush &UKUIRadioButton::hoverTransparentIndicatorColor() const +{ + return m_hoverTransparentIndicatorColor; +} + +void UKUIRadioButton::setHoverTransparentIndicatorColor(const QBrush &newHoverTransparentIndicatorColor) +{ + if (m_hoverTransparentIndicatorColor == newHoverTransparentIndicatorColor) + return; + m_hoverTransparentIndicatorColor = newHoverTransparentIndicatorColor; + emit hoverTransparentIndicatorColorChanged(); +} + +const QBrush &UKUIRadioButton::clickTransparentIndicatorColor() const +{ + return m_clickTransparentIndicatorColor; +} + +void UKUIRadioButton::setClickTransparentIndicatorColor(const QBrush &newClickTransparentIndicatorColor) +{ + if (m_clickTransparentIndicatorColor == newClickTransparentIndicatorColor) + return; + m_clickTransparentIndicatorColor = newClickTransparentIndicatorColor; + emit clickTransparentIndicatorColorChanged(); +} + +const QBrush &UKUIRadioButton::disableTransparentIndicatorColor() const +{ + return m_disableTransparentIndicatorColor; +} + +void UKUIRadioButton::setDisableTransparentIndicatorColor(const QBrush &newDisableTransparentIndicatorColor) +{ + if (m_disableTransparentIndicatorColor == newDisableTransparentIndicatorColor) + return; + m_disableTransparentIndicatorColor = newDisableTransparentIndicatorColor; + emit disableTransparentIndicatorColorChanged(); +} + +const QBrush &UKUIRadioButton::normalTransparentIndicatorBorderColor() const +{ + return m_normalTransparentIndicatorBorderColor; +} + +void UKUIRadioButton::setNormalTransparentIndicatorBorderColor(const QBrush &newNormalTransparentIndicatorBorderColor) +{ + if (m_normalTransparentIndicatorBorderColor == newNormalTransparentIndicatorBorderColor) + return; + m_normalTransparentIndicatorBorderColor = newNormalTransparentIndicatorBorderColor; + emit normalTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUIRadioButton::hoverTransparentIndicatorBorderColor() const +{ + return m_hoverTransparentIndicatorBorderColor; +} + +void UKUIRadioButton::setHoverTransparentIndicatorBorderColor(const QBrush &newHoverTransparentIndicatorBorderColor) +{ + if (m_hoverTransparentIndicatorBorderColor == newHoverTransparentIndicatorBorderColor) + return; + m_hoverTransparentIndicatorBorderColor = newHoverTransparentIndicatorBorderColor; + emit hoverTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUIRadioButton::clickTransparentIndicatorBorderColor() const +{ + return m_clickTransparentIndicatorBorderColor; +} + +void UKUIRadioButton::setClickTransparentIndicatorBorderColor(const QBrush &newClickTransparentIndicatorBorderColor) +{ + if (m_clickTransparentIndicatorBorderColor == newClickTransparentIndicatorBorderColor) + return; + m_clickTransparentIndicatorBorderColor = newClickTransparentIndicatorBorderColor; + emit clickTransparentIndicatorBorderColorChanged(); +} + +const QBrush &UKUIRadioButton::disableTransparentIndicatorBorderColor() const +{ + return m_disableTransparentIndicatorBorderColor; +} + +void UKUIRadioButton::setDisableTransparentIndicatorBorderColor(const QBrush &newDisableTransparentIndicatorBorderColor) +{ + if (m_disableTransparentIndicatorBorderColor == newDisableTransparentIndicatorBorderColor) + return; + m_disableTransparentIndicatorBorderColor = newDisableTransparentIndicatorBorderColor; + emit disableTransparentIndicatorBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiradiobutton.h b/ukui-qml-style-helper/styleparameter/ukuiradiobutton.h index 29b6b70..c537d4d 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiradiobutton.h +++ b/ukui-qml-style-helper/styleparameter/ukuiradiobutton.h @@ -71,6 +71,16 @@ class UKUIRadioButton : public QQuickItem Q_PROPERTY(QBrush checked_clickChildrenBorderColor READ checked_clickChildrenBorderColor WRITE setChecked_ClickChildrenBorderColor NOTIFY checked_clickChildrenBorderColorChanged) Q_PROPERTY(QBrush checked_disableChildrenBorderColor READ checked_disableChildrenBorderColor WRITE setChecked_DisableChildrenBorderColor NOTIFY checked_disableChildrenBorderColorChanged) + Q_PROPERTY(QBrush normalTransparentIndicatorColor READ normalTransparentIndicatorColor WRITE setNormalTransparentIndicatorColor NOTIFY normalTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush hoverTransparentIndicatorColor READ hoverTransparentIndicatorColor WRITE setHoverTransparentIndicatorColor NOTIFY hoverTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush clickTransparentIndicatorColor READ clickTransparentIndicatorColor WRITE setClickTransparentIndicatorColor NOTIFY clickTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush disableTransparentIndicatorColor READ disableTransparentIndicatorColor WRITE setDisableTransparentIndicatorColor NOTIFY disableTransparentIndicatorColorChanged) + Q_PROPERTY(QBrush normalTransparentIndicatorBorderColor READ normalTransparentIndicatorBorderColor WRITE setNormalTransparentIndicatorBorderColor NOTIFY normalTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush hoverTransparentIndicatorBorderColor READ hoverTransparentIndicatorBorderColor WRITE setHoverTransparentIndicatorBorderColor NOTIFY hoverTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush clickTransparentIndicatorBorderColor READ clickTransparentIndicatorBorderColor WRITE setClickTransparentIndicatorBorderColor NOTIFY clickTransparentIndicatorBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentIndicatorBorderColor READ disableTransparentIndicatorBorderColor WRITE setDisableTransparentIndicatorBorderColor NOTIFY disableTransparentIndicatorBorderColorChanged) + + Q_PROPERTY(int indicatorWidth READ indicatorWidth WRITE setIndicatorWidth NOTIFY indicatorWidthChanged) Q_PROPERTY(int childrenWidth READ childrenWidth WRITE setChildrenWidth NOTIFY childrenWidthChanged) @@ -178,6 +188,30 @@ public: int childrenWidth() const; void setChildrenWidth(int newChildrenWidth); + const QBrush &normalTransparentIndicatorColor() const; + void setNormalTransparentIndicatorColor(const QBrush &newNormalTransparentIndicatorColor); + + const QBrush &hoverTransparentIndicatorColor() const; + void setHoverTransparentIndicatorColor(const QBrush &newHoverTransparentIndicatorColor); + + const QBrush &clickTransparentIndicatorColor() const; + void setClickTransparentIndicatorColor(const QBrush &newClickTransparentIndicatorColor); + + const QBrush &disableTransparentIndicatorColor() const; + void setDisableTransparentIndicatorColor(const QBrush &newDisableTransparentIndicatorColor); + + const QBrush &normalTransparentIndicatorBorderColor() const; + void setNormalTransparentIndicatorBorderColor(const QBrush &newNormalTransparentIndicatorBorderColor); + + const QBrush &hoverTransparentIndicatorBorderColor() const; + void setHoverTransparentIndicatorBorderColor(const QBrush &newHoverTransparentIndicatorBorderColor); + + const QBrush &clickTransparentIndicatorBorderColor() const; + void setClickTransparentIndicatorBorderColor(const QBrush &newClickTransparentIndicatorBorderColor); + + const QBrush &disableTransparentIndicatorBorderColor() const; + void setDisableTransparentIndicatorBorderColor(const QBrush &newDisableTransparentIndicatorBorderColor); + signals: void leftRightMarginChanged(); @@ -246,6 +280,22 @@ signals: void parametryChanged(); + void normalTransparentIndicatorColorChanged(); + + void hoverTransparentIndicatorColorChanged(); + + void clickTransparentIndicatorColorChanged(); + + void disableTransparentIndicatorColorChanged(); + + void normalTransparentIndicatorBorderColorChanged(); + + void hoverTransparentIndicatorBorderColorChanged(); + + void clickTransparentIndicatorBorderColorChanged(); + + void disableTransparentIndicatorBorderColorChanged(); + private: double m_leftRightMargin; double m_upDownMargin; @@ -282,6 +332,14 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_normalTransparentIndicatorColor; + QBrush m_hoverTransparentIndicatorColor; + QBrush m_clickTransparentIndicatorColor; + QBrush m_disableTransparentIndicatorColor; + QBrush m_normalTransparentIndicatorBorderColor; + QBrush m_hoverTransparentIndicatorBorderColor; + QBrush m_clickTransparentIndicatorBorderColor; + QBrush m_disableTransparentIndicatorBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIRadioButton, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuiscrollbar.cpp b/ukui-qml-style-helper/styleparameter/ukuiscrollbar.cpp index 64da7a4..a5bd0ca 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiscrollbar.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuiscrollbar.cpp @@ -8,12 +8,13 @@ UKUIScrollBar::UKUIScrollBar(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); - + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUIScrollBar::~UKUIScrollBar() @@ -23,10 +24,14 @@ UKUIScrollBar::~UKUIScrollBar() void UKUIScrollBar::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setNormalColor(instance->kGray6()); - setHoverColor(instance->kComponentHover()); - setClickColor(instance->kComponentClick()); - setDisableColor(instance->kGray3()); + setNormalColor(instance->kGray12()); + setHoverColor(instance->kGray13()); + setClickColor(instance->kGray14()); + setDisableColor(instance->kGray8()); + setNormalTransparentColor(instance->kGrayAlpha10()); + setHoverTransparentColor(instance->kGrayAlpha13()); + setClickTransparentColor(instance->kGrayAlpha11()); + setDisableTransparentColor(instance->kGrayAlpha5()); emit parametryChanged(); @@ -103,3 +108,55 @@ void UKUIScrollBar::setDisableColor(const QBrush &newDisableColor) m_disableColor = newDisableColor; emit disableColorChanged(); } + +const QBrush &UKUIScrollBar::normalTransparentColor() const +{ + return m_normalTransparentColor; +} + +void UKUIScrollBar::setNormalTransparentColor(const QBrush &newNormalTransparentColor) +{ + if (m_normalTransparentColor == newNormalTransparentColor) + return; + m_normalTransparentColor = newNormalTransparentColor; + emit normalTransparentColorChanged(); +} + +const QBrush &UKUIScrollBar::hoverTransparentColor() const +{ + return m_hoverTransparentColor; +} + +void UKUIScrollBar::setHoverTransparentColor(const QBrush &newHoverTransparentColor) +{ + if (m_hoverTransparentColor == newHoverTransparentColor) + return; + m_hoverTransparentColor = newHoverTransparentColor; + emit hoverTransparentColorChanged(); +} + +const QBrush &UKUIScrollBar::clickTransparentColor() const +{ + return m_clickTransparentColor; +} + +void UKUIScrollBar::setClickTransparentColor(const QBrush &newClickTransparentColor) +{ + if (m_clickTransparentColor == newClickTransparentColor) + return; + m_clickTransparentColor = newClickTransparentColor; + emit clickTransparentColorChanged(); +} + +const QBrush &UKUIScrollBar::disableTransparentColor() const +{ + return m_disableTransparentColor; +} + +void UKUIScrollBar::setDisableTransparentColor(const QBrush &newDisableTransparentColor) +{ + if (m_disableTransparentColor == newDisableTransparentColor) + return; + m_disableTransparentColor = newDisableTransparentColor; + emit disableTransparentColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiscrollbar.h b/ukui-qml-style-helper/styleparameter/ukuiscrollbar.h index bbb6ddf..2132712 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiscrollbar.h +++ b/ukui-qml-style-helper/styleparameter/ukuiscrollbar.h @@ -43,6 +43,11 @@ class UKUIScrollBar : public QQuickItem Q_PROPERTY(QBrush clickColor READ clickColor WRITE setClickColor NOTIFY clickColorChanged) Q_PROPERTY(QBrush disableColor READ disableColor WRITE setDisableColor NOTIFY disableColorChanged) + Q_PROPERTY(QBrush normalTransparentColor READ normalTransparentColor WRITE setNormalTransparentColor NOTIFY normalTransparentColorChanged) + Q_PROPERTY(QBrush hoverTransparentColor READ hoverTransparentColor WRITE setHoverTransparentColor NOTIFY hoverTransparentColorChanged) + Q_PROPERTY(QBrush clickTransparentColor READ clickTransparentColor WRITE setClickTransparentColor NOTIFY clickTransparentColorChanged) + Q_PROPERTY(QBrush disableTransparentColor READ disableTransparentColor WRITE setDisableTransparentColor NOTIFY disableTransparentColorChanged) + Q_PROPERTY(int padding READ padding WRITE setPadding NOTIFY paddingChanged) public: @@ -68,6 +73,19 @@ public: const QBrush &disableColor() const; void setDisableColor(const QBrush &newDisableColor); + const QBrush &normalTransparentColor() const; + void setNormalTransparentColor(const QBrush &newNormalTransparentColor); + + const QBrush &hoverTransparentColor() const; + void setHoverTransparentColor(const QBrush &newHoverTransparentColor); + + const QBrush &clickTransparentColor() const; + void setClickTransparentColor(const QBrush &newClickTransparentColor); + + const QBrush &disableTransparentColor() const; + + void setDisableTransparentColor(const QBrush &newDisableTransparentColor); + signals: void normalColorChanged(); @@ -81,6 +99,14 @@ signals: void parametryChanged(); + void normalTransparentColorChanged(); + + void hoverTransparentColorChanged(); + + void clickTransparentColorChanged(); + + void disableTransparentColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); @@ -91,6 +117,10 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_normalTransparentColor; + QBrush m_hoverTransparentColor; + QBrush m_clickTransparentColor; + QBrush m_disableTransparentColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIScrollBar, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuislider.cpp b/ukui-qml-style-helper/styleparameter/ukuislider.cpp index 503bc74..c0866c5 100644 --- a/ukui-qml-style-helper/styleparameter/ukuislider.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuislider.cpp @@ -8,11 +8,13 @@ UKUISlider::UKUISlider(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUISlider::~UKUISlider() @@ -28,10 +30,11 @@ void UKUISlider::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) instance = token->getInstance(); } } - setNormalWidth(243); + setNormalWidth(240); setNormalHeight(24); setGrooveHeight(4); - setHandleHeight(20); + setHandleHeight(16); + setHandleHoverHeight(20); setTouchNormalWidth(240); setTouchNormalHeight(16); @@ -44,27 +47,33 @@ void UKUISlider::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setFocusBorderColor(instance->kBrandFocus()); - setNormalGrooveColor(instance->kBrandClick()); - setDisableGrooveColor(instance->kGray12()); - setNormalGrooveBorderColor(instance->kLineBrandClick()); - setDisableGrooveBorderColor(instance->kLineBrandDisable()); - setGrooveBorderWidth(1); - - setNormalUnGrooveColor(instance->buttonActive()); - setDisableUnGrooveColor(instance->buttonDisable()); - setNormalUnGrooveBorderColor(instance->kLineComponentNormal()); - setDisableUnGrooveBorderColor(instance->kLineComponentDisable()); - - - setNormalHandleColor(instance->highLightActive()); - setHoverHandleColor(instance->kBrandHover()); - setClickHandleColor(instance->kBrandClick()); - setDisableHandleColor(instance->kGray11()); - setNormalHandleBorderColor(instance->kLineBrandNormal()); - setHoverHandleBorderColor(instance->kLineBrandNormal()); - setClickHandleBorderColor(instance->kLineBrandNormal()); - setDisableHandleBorderColor(instance->kLineBrandDisable()); - setHandleBorderWidth(1); + setNormalGrooveColor(instance->kBrandNormal()); + setDisableGrooveColor(instance->kBrandNormal()); + setNormalGrooveBorderColor(QBrush(QColor(0,0,0,0))); + setDisableGrooveBorderColor(QBrush(QColor(0,0,0,0))); + setGrooveBorderWidth(0); + + setNormalUnGrooveColor(instance->kComponentNormal()); + setDisableUnGrooveColor(instance->kComponentNormal()); + setNormalUnGrooveBorderColor(QBrush(QColor(0,0,0,0))); + setDisableUnGrooveBorderColor(QBrush(QColor(0,0,0,0))); + + setNormalTransparentUnGrooveColor(instance->kComponentAlphaNormal()); + setDisableTransparentUnGrooveColor(instance->kComponentAlphaNormal()); + setNormalTransparentUnGrooveBorderColor(QBrush(QColor(0,0,0,0))); + setDisableTransparentUnGrooveBorderColor(QBrush(QColor(0,0,0,0))); + + + setNormalHandleColor(instance->kFontWhite()); + setHoverHandleColor(instance->kFontWhite()); + setClickHandleColor(instance->kFontWhite()); + setDisableHandleColor(instance->kFontWhite()); + setNormalHandleBorderColor(instance->kBrandNormal()); + setHoverHandleBorderColor(instance->kBrandNormal()); + setClickHandleBorderColor(instance->kBrandNormal()); + setDisableHandleBorderColor(instance->kBrandNormal()); + setTouchHandleBaseColor(instance->baseActive()); + setHandleBorderWidth(3); setPadding(0); emit parametryChanged(); @@ -481,3 +490,81 @@ void UKUISlider::setTouchHandleColor(const QBrush &newTouchHandleColor) m_touchHandleColor = newTouchHandleColor; emit touchHandleColorChanged(); } + +const QBrush &UKUISlider::normalTransparentUnGrooveColor() const +{ + return m_normalTransparentUnGrooveColor; +} + +void UKUISlider::setNormalTransparentUnGrooveColor(const QBrush &newNormalTransparentUnGrooveColor) +{ + if (m_normalTransparentUnGrooveColor == newNormalTransparentUnGrooveColor) + return; + m_normalTransparentUnGrooveColor = newNormalTransparentUnGrooveColor; + emit normalTransparentUnGrooveColorChanged(); +} + +const QBrush &UKUISlider::disableTransparentUnGrooveColor() const +{ + return m_disableTransparentUnGrooveColor; +} + +void UKUISlider::setDisableTransparentUnGrooveColor(const QBrush &newDisableTransparentUnGrooveColor) +{ + if (m_disableTransparentUnGrooveColor == newDisableTransparentUnGrooveColor) + return; + m_disableTransparentUnGrooveColor = newDisableTransparentUnGrooveColor; + emit disableTransparentUnGrooveColorChanged(); +} + +const QBrush &UKUISlider::normalTransparentUnGrooveBorderColor() const +{ + return m_normalTransparentUnGrooveBorderColor; +} + +void UKUISlider::setNormalTransparentUnGrooveBorderColor(const QBrush &newNormalTransparentUnGrooveBorderColor) +{ + if (m_normalTransparentUnGrooveBorderColor == newNormalTransparentUnGrooveBorderColor) + return; + m_normalTransparentUnGrooveBorderColor = newNormalTransparentUnGrooveBorderColor; + emit normalTransparentUnGrooveBorderColorChanged(); +} + +const QBrush &UKUISlider::disableTransparentUnGrooveBorderColor() const +{ + return m_disableTransparentUnGrooveBorderColor; +} + +void UKUISlider::setDisableTransparentUnGrooveBorderColor(const QBrush &newDisableTransparentUnGrooveBorderColor) +{ + if (m_disableTransparentUnGrooveBorderColor == newDisableTransparentUnGrooveBorderColor) + return; + m_disableTransparentUnGrooveBorderColor = newDisableTransparentUnGrooveBorderColor; + emit disableTransparentUnGrooveBorderColorChanged(); +} + +int UKUISlider::handleHoverHeight() const +{ + return m_handleHoverHeight; +} + +void UKUISlider::setHandleHoverHeight(int newHandleHoverHeight) +{ + if (m_handleHoverHeight == newHandleHoverHeight) + return; + m_handleHoverHeight = newHandleHoverHeight; + emit handleHoverHeightChanged(); +} + +const QBrush &UKUISlider::touchHandleBaseColor() const +{ + return m_touchHandleBaseColor; +} + +void UKUISlider::setTouchHandleBaseColor(const QBrush &newTouchHandleBaseColor) +{ + if (m_touchHandleBaseColor == newTouchHandleBaseColor) + return; + m_touchHandleBaseColor = newTouchHandleBaseColor; + emit touchHandleBaseColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuislider.h b/ukui-qml-style-helper/styleparameter/ukuislider.h index 04b2587..4387209 100644 --- a/ukui-qml-style-helper/styleparameter/ukuislider.h +++ b/ukui-qml-style-helper/styleparameter/ukuislider.h @@ -42,6 +42,8 @@ class UKUISlider : public QQuickItem Q_PROPERTY(int normalHeight READ normalHeight WRITE setNormalHeight NOTIFY normalHeightChanged) Q_PROPERTY(int grooveHeight READ grooveHeight WRITE setGrooveHeight NOTIFY grooveHeightChanged) Q_PROPERTY(int handleHeight READ handleHeight WRITE setHandleHeight NOTIFY handleHeightChanged) + Q_PROPERTY(int handleHoverHeight READ handleHoverHeight WRITE setHandleHoverHeight NOTIFY handleHoverHeightChanged) + Q_PROPERTY(int focusBorderWidth READ focusBorderWidth WRITE setFocusBorderWidth NOTIFY focusBorderWidthChanged) Q_PROPERTY(QBrush focusBorderColor READ focusBorderColor WRITE setFocusBorderColor NOTIFY focusBorderColorChanged) @@ -75,6 +77,13 @@ class UKUISlider : public QQuickItem Q_PROPERTY(int touchHandleWidth READ touchHandleWidth WRITE setTouchHandleWidth NOTIFY touchHandleWidthChanged) Q_PROPERTY(QBrush touchHandleColor READ touchHandleColor WRITE setTouchHandleColor NOTIFY touchHandleColorChanged) + Q_PROPERTY(QBrush normalTransparentUnGrooveColor READ normalTransparentUnGrooveColor WRITE setNormalTransparentUnGrooveColor NOTIFY normalTransparentUnGrooveColorChanged) + Q_PROPERTY(QBrush disableTransparentUnGrooveColor READ disableTransparentUnGrooveColor WRITE setDisableTransparentUnGrooveColor NOTIFY disableTransparentUnGrooveColorChanged) + Q_PROPERTY(QBrush normalTransparentUnGrooveBorderColor READ normalTransparentUnGrooveBorderColor WRITE setNormalTransparentUnGrooveBorderColor NOTIFY normalTransparentUnGrooveBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentUnGrooveBorderColor READ disableTransparentUnGrooveBorderColor WRITE setDisableTransparentUnGrooveBorderColor NOTIFY disableTransparentUnGrooveBorderColorChanged) + + Q_PROPERTY(QBrush touchHandleBaseColor READ touchHandleBaseColor WRITE setTouchHandleBaseColor NOTIFY touchHandleBaseColorChanged) + public: explicit UKUISlider(QQuickItem *parent = nullptr); @@ -177,6 +186,24 @@ public: const QBrush &touchHandleColor() const; void setTouchHandleColor(const QBrush &newTouchHandleColor); + const QBrush &normalTransparentUnGrooveColor() const; + void setNormalTransparentUnGrooveColor(const QBrush &newNormalTransparentUnGrooveColor); + + const QBrush &disableTransparentUnGrooveColor() const; + void setDisableTransparentUnGrooveColor(const QBrush &newDisableTransparentUnGrooveColor); + + const QBrush &normalTransparentUnGrooveBorderColor() const; + void setNormalTransparentUnGrooveBorderColor(const QBrush &newNormalTransparentUnGrooveBorderColor); + + const QBrush &disableTransparentUnGrooveBorderColor() const; + void setDisableTransparentUnGrooveBorderColor(const QBrush &newDisableTransparentUnGrooveBorderColor); + + int handleHoverHeight() const; + void setHandleHoverHeight(int newHandleHoverHeight); + + const QBrush &touchHandleBaseColor() const; + void setTouchHandleBaseColor(const QBrush &newTouchHandleBaseColor); + signals: void normalWidthChanged(); @@ -242,6 +269,18 @@ signals: void touchHandleColorChanged(); + void normalTransparentUnGrooveColorChanged(); + + void disableTransparentUnGrooveColorChanged(); + + void normalTransparentUnGrooveBorderColorChanged(); + + void disableTransparentUnGrooveBorderColorChanged(); + + void handleHoverHeightChanged(); + + void touchHandleBaseColorChanged(); + private: int m_normalWidth; int m_normalHeight; @@ -277,6 +316,12 @@ private: int m_touchHandleHeight; int m_touchHandleWidth; QBrush m_touchHandleColor; + QBrush m_normalTransparentUnGrooveColor; + QBrush m_disableTransparentUnGrooveColor; + QBrush m_normalTransparentUnGrooveBorderColor; + QBrush m_disableTransparentUnGrooveBorderColor; + int m_handleHoverHeight; + QBrush m_touchHandleBaseColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUISlider, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuispinbox.cpp b/ukui-qml-style-helper/styleparameter/ukuispinbox.cpp index fd4933b..dc2acb9 100644 --- a/ukui-qml-style-helper/styleparameter/ukuispinbox.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuispinbox.cpp @@ -8,11 +8,13 @@ UKUISpinBox::UKUISpinBox(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUISpinBox::~UKUISpinBox() @@ -22,27 +24,45 @@ UKUISpinBox::~UKUISpinBox() void UKUISpinBox::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setNormalColor(instance->buttonActive()); + setNormalColor(instance->kComponentNormal()); setHoverColor(instance->kComponentHover()); - setClickColor(instance->kComponentClick()); - setDisableColor(instance->buttonDisable()); + setClickColor(instance->kComponentInput()); + setDisableColor(instance->kComponentDisable()); setNormalTextColor(instance->buttonTextActive()); setDisableTextColor(instance->buttonTextDisable()); setNormalBorderColor(instance->kLineComponentNormal()); setHoverBorderColor(instance->kLineComponentHover()); - setClickBorderColor(instance->kLineComponentClick()); + setClickBorderColor(instance->kBrandNormal()); setDisableBorderColor(instance->kLineComponentDisable()); - setFocusBorderColor(instance->highLightActive()); + setFocusBorderColor(instance->kBrandFocus()); setFocusColor(instance->kContainGeneralNormal()); - setBtnNormalColor(instance->buttonActive()); + setBtnNormalColor(QBrush(QColor(0,0,0,0))); setBtnHoverColor(instance->kComponentHover()); setBtnClickColor(instance->kComponentClick()); - setBtnDisableColor(instance->kComponentDisable()); - setBtnNormalBorderColor(instance->kLineComponentNormal()); - setBtnHoverBorderColor(instance->kLineComponentHover()); - setBtnClickBorderColor(instance->kLineComponentClick()); - setBtnDisableBorderColor(instance->kLineComponentDisable()); + setBtnDisableColor(QBrush(QColor(0,0,0,0))); +// setBtnNormalBorderColor(instance->kLineComponentNormal()); +// setBtnHoverBorderColor(instance->kLineComponentHover()); +// setBtnClickBorderColor(instance->kLineComponentClick()); +// setBtnDisableBorderColor(instance->kLineComponentDisable()); + + setNormalTransparentBC(instance->kComponentAlphaNormal()); + setClickedTransparentBC(instance->kComponentInputAlpha()); + setHoveredTransparentBC(instance->kComponentAlphaHover()); + setDisableTransparentBC(instance->kComponentAlphaDisable()); + setNormalTransparentBorderColor(instance->kLineComponentNormal()); + setClickedTransparentBorderColor(instance->kBrandNormal()); + setHoveredTransparentBorderColor(instance->kLineComponentHover()); + setDisableTransparentBorderColor(instance->kLineComponentDisable()); + + setBtnNormalTransparentColor(QBrush(QColor(0,0,0,0))); + setBtnHoverTransparentColor(instance->kComponentAlphaHover()); + setBtnClickTransparentColor(instance->kComponentAlphaClick()); + setBtnDisableTransparentColor(QBrush(QColor(0,0,0,0))); +// setBtnNormalTransparentBorderColor(instance->kLineComponentNormal()); +// setBtnHoverTransparentBorderColor(instance->kLineComponentHover()); +// setBtnClickTransparentBorderColor(instance->kLineComponentClick()); +// setBtnDisableTransparentBorderColor(instance->kLineComponentDisable()); setNormalWidth(160); setNormalHeight(36); @@ -51,7 +71,7 @@ void UKUISpinBox::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setRadius(instance->kradiusNormal()); setNormalBorderWidth(instance->normalline()); setFocusBorderWidth(instance->focusline()); - setPadding(instance->tokenGap8()); + setPadding(8); setBtnBorderWidth(instance->normalline()); emit parametryChanged(); @@ -466,3 +486,211 @@ void UKUISpinBox::setBtnBorderWidth(int newBtnBorderWidth) m_btnBorderWidth = newBtnBorderWidth; emit btnBorderWidthChanged(); } + +const QBrush &UKUISpinBox::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUISpinBox::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUISpinBox::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUISpinBox::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUISpinBox::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUISpinBox::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUISpinBox::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUISpinBox::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} + +const QBrush &UKUISpinBox::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUISpinBox::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::clickedTransparentBorderColor() const +{ + return m_clickedTransparentBorderColor; +} + +void UKUISpinBox::setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor) +{ + if (m_clickedTransparentBorderColor == newClickedTransparentBorderColor) + return; + m_clickedTransparentBorderColor = newClickedTransparentBorderColor; + emit clickedTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::hoveredTransparentBorderColor() const +{ + return m_hoveredTransparentBorderColor; +} + +void UKUISpinBox::setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor) +{ + if (m_hoveredTransparentBorderColor == newHoveredTransparentBorderColor) + return; + m_hoveredTransparentBorderColor = newHoveredTransparentBorderColor; + emit hoveredTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::disableTransparentBorderColor() const +{ + return m_disableTransparentBorderColor; +} + +void UKUISpinBox::setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor) +{ + if (m_disableTransparentBorderColor == newDisableTransparentBorderColor) + return; + m_disableTransparentBorderColor = newDisableTransparentBorderColor; + emit disableTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::btnNormalTransparentColor() const +{ + return m_btnNormalTransparentColor; +} + +void UKUISpinBox::setBtnNormalTransparentColor(const QBrush &newBtnNormalTransparentColor) +{ + if (m_btnNormalTransparentColor == newBtnNormalTransparentColor) + return; + m_btnNormalTransparentColor = newBtnNormalTransparentColor; + emit btnNormalTransparentColorChanged(); +} + +const QBrush &UKUISpinBox::btnHoverTransparentColor() const +{ + return m_btnHoverTransparentColor; +} + +void UKUISpinBox::setBtnHoverTransparentColor(const QBrush &newBtnHoverTransparentColor) +{ + if (m_btnHoverTransparentColor == newBtnHoverTransparentColor) + return; + m_btnHoverTransparentColor = newBtnHoverTransparentColor; + emit btnHoverTransparentColorChanged(); +} + +const QBrush &UKUISpinBox::btnClickTransparentColor() const +{ + return m_btnClickTransparentColor; +} + +void UKUISpinBox::setBtnClickTransparentColor(const QBrush &newBtnClickTransparentColor) +{ + if (m_btnClickTransparentColor == newBtnClickTransparentColor) + return; + m_btnClickTransparentColor = newBtnClickTransparentColor; + emit btnClickTransparentColorChanged(); +} + +const QBrush &UKUISpinBox::btnDisableTransparentColor() const +{ + return m_btnDisableTransparentColor; +} + +void UKUISpinBox::setBtnDisableTransparentColor(const QBrush &newBtnDisableTransparentColor) +{ + if (m_btnDisableTransparentColor == newBtnDisableTransparentColor) + return; + m_btnDisableTransparentColor = newBtnDisableTransparentColor; + emit btnDisableTransparentColorChanged(); +} + +const QBrush &UKUISpinBox::btnNormalTransparentBorderColor() const +{ + return m_btnNormalTransparentBorderColor; +} + +void UKUISpinBox::setBtnNormalTransparentBorderColor(const QBrush &newBtnNormalTransparentBorderColor) +{ + if (m_btnNormalTransparentBorderColor == newBtnNormalTransparentBorderColor) + return; + m_btnNormalTransparentBorderColor = newBtnNormalTransparentBorderColor; + emit btnNormalTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::btnHoverTransparentBorderColor() const +{ + return m_btnHoverTransparentBorderColor; +} + +void UKUISpinBox::setBtnHoverTransparentBorderColor(const QBrush &newBtnHoverTransparentBorderColor) +{ + if (m_btnHoverTransparentBorderColor == newBtnHoverTransparentBorderColor) + return; + m_btnHoverTransparentBorderColor = newBtnHoverTransparentBorderColor; + emit btnHoverTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::btnClickTransparentBorderColor() const +{ + return m_btnClickTransparentBorderColor; +} + +void UKUISpinBox::setBtnClickTransparentBorderColor(const QBrush &newBtnClickTransparentBorderColor) +{ + if (m_btnClickTransparentBorderColor == newBtnClickTransparentBorderColor) + return; + m_btnClickTransparentBorderColor = newBtnClickTransparentBorderColor; + emit btnClickTransparentBorderColorChanged(); +} + +const QBrush &UKUISpinBox::btnDisableTransparentBorderColor() const +{ + return m_btnDisableTransparentBorderColor; +} + +void UKUISpinBox::setBtnDisableTransparentBorderColor(const QBrush &newBtnDisableTransparentBorderColor) +{ + if (m_btnDisableTransparentBorderColor == newBtnDisableTransparentBorderColor) + return; + m_btnDisableTransparentBorderColor = newBtnDisableTransparentBorderColor; + emit btnDisableTransparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuispinbox.h b/ukui-qml-style-helper/styleparameter/ukuispinbox.h index 6002d7f..f9d7de0 100644 --- a/ukui-qml-style-helper/styleparameter/ukuispinbox.h +++ b/ukui-qml-style-helper/styleparameter/ukuispinbox.h @@ -65,6 +65,25 @@ class UKUISpinBox : public QQuickItem Q_PROPERTY(QBrush btnDisableBorderColor READ btnDisableBorderColor WRITE setBtnDisableBorderColor NOTIFY btnDisableBorderColorChanged) Q_PROPERTY(QBrush btnFocusBorderColor READ btnFocusBorderColor WRITE setBtnFocusBorderColor NOTIFY btnFocusBorderColorChanged) + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickedTransparentBorderColor READ clickedTransparentBorderColor WRITE setClickedTransparentBorderColor NOTIFY clickedTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoveredTransparentBorderColor READ hoveredTransparentBorderColor WRITE setHoveredTransparentBorderColor NOTIFY hoveredTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentBorderColor READ disableTransparentBorderColor WRITE setDisableTransparentBorderColor NOTIFY disableTransparentBorderColorChanged) + + Q_PROPERTY(QBrush btnNormalTransparentColor READ btnNormalTransparentColor WRITE setBtnNormalTransparentColor NOTIFY btnNormalTransparentColorChanged) + Q_PROPERTY(QBrush btnHoverTransparentColor READ btnHoverTransparentColor WRITE setBtnHoverTransparentColor NOTIFY btnHoverTransparentColorChanged) + Q_PROPERTY(QBrush btnClickTransparentColor READ btnClickTransparentColor WRITE setBtnClickTransparentColor NOTIFY btnClickTransparentColorChanged) + Q_PROPERTY(QBrush btnDisableTransparentColor READ btnDisableTransparentColor WRITE setBtnDisableTransparentColor NOTIFY btnDisableTransparentColorChanged) + + Q_PROPERTY(QBrush btnNormalTransparentBorderColor READ btnNormalTransparentBorderColor WRITE setBtnNormalTransparentBorderColor NOTIFY btnNormalTransparentBorderColorChanged) + Q_PROPERTY(QBrush btnHoverTransparentBorderColor READ btnHoverTransparentBorderColor WRITE setBtnHoverTransparentBorderColor NOTIFY btnHoverTransparentBorderColorChanged) + Q_PROPERTY(QBrush btnClickTransparentBorderColor READ btnClickTransparentBorderColor WRITE setBtnClickTransparentBorderColor NOTIFY btnClickTransparentBorderColorChanged) + Q_PROPERTY(QBrush btnDisableTransparentBorderColor READ btnDisableTransparentBorderColor WRITE setBtnDisableTransparentBorderColor NOTIFY btnDisableTransparentBorderColorChanged) Q_PROPERTY(int normalWidth READ normalWidth WRITE setNormalWidth NOTIFY normalWidthChanged) Q_PROPERTY(int normalHeight READ normalHeight WRITE setNormalHeight NOTIFY normalHeightChanged) @@ -179,6 +198,54 @@ public: int btnBorderWidth() const; void setBtnBorderWidth(int newBtnBorderWidth); + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + + const QBrush &clickedTransparentBorderColor() const; + void setClickedTransparentBorderColor(const QBrush &newClickedTransparentBorderColor); + + const QBrush &hoveredTransparentBorderColor() const; + void setHoveredTransparentBorderColor(const QBrush &newHoveredTransparentBorderColor); + + const QBrush &disableTransparentBorderColor() const; + void setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor); + + const QBrush &btnNormalTransparentColor() const; + void setBtnNormalTransparentColor(const QBrush &newBtnNormalTransparentColor); + + const QBrush &btnHoverTransparentColor() const; + void setBtnHoverTransparentColor(const QBrush &newBtnHoverTransparentColor); + + const QBrush &btnClickTransparentColor() const; + void setBtnClickTransparentColor(const QBrush &newBtnClickTransparentColor); + + const QBrush &btnDisableTransparentColor() const; + void setBtnDisableTransparentColor(const QBrush &newBtnDisableTransparentColor); + + const QBrush &btnNormalTransparentBorderColor() const; + void setBtnNormalTransparentBorderColor(const QBrush &newBtnNormalTransparentBorderColor); + + const QBrush &btnHoverTransparentBorderColor() const; + void setBtnHoverTransparentBorderColor(const QBrush &newBtnHoverTransparentBorderColor); + + const QBrush &btnClickTransparentBorderColor() const; + void setBtnClickTransparentBorderColor(const QBrush &newBtnClickTransparentBorderColor); + + const QBrush &btnDisableTransparentBorderColor() const; + void setBtnDisableTransparentBorderColor(const QBrush &newBtnDisableTransparentBorderColor); + signals: void normalColorChanged(); @@ -246,6 +313,38 @@ signals: void parametryChanged(); + void normalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + + void normalTransparentBorderColorChanged(); + + void clickedTransparentBorderColorChanged(); + + void hoveredTransparentBorderColorChanged(); + + void disableTransparentBorderColorChanged(); + + void btnNormalTransparentColorChanged(); + + void btnHoverTransparentColorChanged(); + + void btnClickTransparentColorChanged(); + + void btnDisableTransparentColorChanged(); + + void btnNormalTransparentBorderColorChanged(); + + void btnHoverTransparentBorderColorChanged(); + + void btnClickTransparentBorderColorChanged(); + + void btnDisableTransparentBorderColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); Q_INVOKABLE QBrush m_disableColor; @@ -281,6 +380,22 @@ private: Q_INVOKABLE QBrush m_btnDisableBorderColor; Q_INVOKABLE QBrush m_btnFocusBorderColor; int m_btnBorderWidth; + QBrush m_normalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; + QBrush m_normalTransparentBorderColor; + QBrush m_clickedTransparentBorderColor; + QBrush m_hoveredTransparentBorderColor; + QBrush m_disableTransparentBorderColor; + QBrush m_btnNormalTransparentColor; + QBrush m_btnHoverTransparentColor; + QBrush m_btnClickTransparentColor; + QBrush m_btnDisableTransparentColor; + QBrush m_btnNormalTransparentBorderColor; + QBrush m_btnHoverTransparentBorderColor; + QBrush m_btnClickTransparentBorderColor; + QBrush m_btnDisableTransparentBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUISpinBox, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuiswitch.cpp b/ukui-qml-style-helper/styleparameter/ukuiswitch.cpp index 6eb19ac..831b8d3 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiswitch.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuiswitch.cpp @@ -8,12 +8,13 @@ UKUISwitch::UKUISwitch(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); - + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUISwitch::~UKUISwitch() @@ -23,29 +24,38 @@ UKUISwitch::~UKUISwitch() void UKUISwitch::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setNormalColor(instance->buttonActive()); + setNormalColor(instance->kComponentNormal()); setHoverColor(instance->kComponentHover()); setClickColor(instance->kComponentClick()); - setDisableColor(instance->buttonDisable()); + setDisableColor(instance->kComponentDisable()); setNormalBorderColor(instance->kLineComponentNormal()); setHoverBorderColor(instance->kLineComponentHover()); setClickBorderColor(instance->kLineComponentClick()); setDisableBorderColor(instance->kLineComponentDisable()); - setCheckedNormalColor(instance->highLightActive()); + setCheckedNormalColor(instance->kBrandNormal()); setCheckedHoverColor(instance->kBrandHover()); setCheckedClickColor(instance->kBrandClick()); - setCheckedDisableColor(instance->highLightDisable()); - setCheckedNormalBorderColor(instance->kLineBrandNormal()); - setCheckedHoverBorderColor(instance->kLineBrandHover()); - setCheckedClickBorderColor(instance->kLineBrandClick()); - setCheckedDisableBorderColor(instance->kLineBrandDisable()); - - setNormalIndicatorColor(instance->highLightedTextActive()); - setDisableIndicatorColor(instance->buttonTextDisable()); - - setRecWidth(50); - setRecHeight(24); + setCheckedDisableColor(instance->kBrandDisable()); + setCheckedNormalBorderColor(instance->kLineComponentNormal()); + setCheckedHoverBorderColor(instance->kLineComponentHover()); + setCheckedClickBorderColor(instance->kLineComponentClick()); + setCheckedDisableBorderColor(instance->kLineComponentDisable()); + + setNormalIndicatorColor(instance->kFontWhite()); + setDisableIndicatorColor(instance->kFontWhiteDisable()); + + setNormalTransparentColor(instance->kComponentAlphaNormal()); + setHoverTransparentColor(instance->kComponentAlphaHover()); + setClickTransparentColor(instance->kComponentAlphaClick()); + setDisableTransparentColor(instance->kComponentAlphaDisable()); + setNormalTransparentBorderColor(instance->kLineComponentNormal()); + setHoverTransparentBorderColor(instance->kLineComponentHover()); + setClickTransparentBorderColor(instance->kLineComponentClick()); + setDisableTransparentBorderColor(instance->kLineComponentDisable()); + + setRecWidth(44); + setRecHeight(22); setIndicatorWidth(16); setPadding(4); setBorderWidth(instance->normalline()); @@ -372,3 +382,107 @@ void UKUISwitch::setIndicatorLeftRightPadding(int newIndicatorLeftRightPadding) m_indicatorLeftRightPadding = newIndicatorLeftRightPadding; emit indicatorLeftRightPaddingChanged(); } + +const QBrush &UKUISwitch::normalTransparentColor() const +{ + return m_normalTransparentColor; +} + +void UKUISwitch::setNormalTransparentColor(const QBrush &newNormalTransparentColor) +{ + if (m_normalTransparentColor == newNormalTransparentColor) + return; + m_normalTransparentColor = newNormalTransparentColor; + emit normalTransparentColorChanged(); +} + +const QBrush &UKUISwitch::hoverTransparentColor() const +{ + return m_hoverTransparentColor; +} + +void UKUISwitch::setHoverTransparentColor(const QBrush &newHoverTransparentColor) +{ + if (m_hoverTransparentColor == newHoverTransparentColor) + return; + m_hoverTransparentColor = newHoverTransparentColor; + emit hoverTransparentColorChanged(); +} + +const QBrush &UKUISwitch::clickTransparentColor() const +{ + return m_clickTransparentColor; +} + +void UKUISwitch::setClickTransparentColor(const QBrush &newClickTransparentColor) +{ + if (m_clickTransparentColor == newClickTransparentColor) + return; + m_clickTransparentColor = newClickTransparentColor; + emit clickTransparentColorChanged(); +} + +const QBrush &UKUISwitch::disableTransparentColor() const +{ + return m_disableTransparentColor; +} + +void UKUISwitch::setDisableTransparentColor(const QBrush &newDisableTransparentColor) +{ + if (m_disableTransparentColor == newDisableTransparentColor) + return; + m_disableTransparentColor = newDisableTransparentColor; + emit disableTransparentColorChanged(); +} + +const QBrush &UKUISwitch::normalTransparentBorderColor() const +{ + return m_normalTransparentBorderColor; +} + +void UKUISwitch::setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor) +{ + if (m_normalTransparentBorderColor == newNormalTransparentBorderColor) + return; + m_normalTransparentBorderColor = newNormalTransparentBorderColor; + emit normalTransparentBorderColorChanged(); +} + +const QBrush &UKUISwitch::hoverTransparentBorderColor() const +{ + return m_hoverTransparentBorderColor; +} + +void UKUISwitch::setHoverTransparentBorderColor(const QBrush &newHoverTransparentBorderColor) +{ + if (m_hoverTransparentBorderColor == newHoverTransparentBorderColor) + return; + m_hoverTransparentBorderColor = newHoverTransparentBorderColor; + emit hoverTransparentBorderColorChanged(); +} + +const QBrush &UKUISwitch::clickTransparentBorderColor() const +{ + return m_clickTransparentBorderColor; +} + +void UKUISwitch::setClickTransparentBorderColor(const QBrush &newClickTransparentBorderColor) +{ + if (m_clickTransparentBorderColor == newClickTransparentBorderColor) + return; + m_clickTransparentBorderColor = newClickTransparentBorderColor; + emit clickTransparentBorderColorChanged(); +} + +const QBrush &UKUISwitch::disableTransparentBorderColor() const +{ + return m_disableTransparentBorderColor; +} + +void UKUISwitch::setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor) +{ + if (m_disableTransparentBorderColor == newDisableTransparentBorderColor) + return; + m_disableTransparentBorderColor = newDisableTransparentBorderColor; + emit disableTransparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuiswitch.h b/ukui-qml-style-helper/styleparameter/ukuiswitch.h index 97142be..9a34e06 100644 --- a/ukui-qml-style-helper/styleparameter/ukuiswitch.h +++ b/ukui-qml-style-helper/styleparameter/ukuiswitch.h @@ -61,6 +61,15 @@ class UKUISwitch : public QQuickItem Q_PROPERTY(QBrush normalIndicatorColor READ normalIndicatorColor WRITE setNormalIndicatorColor NOTIFY normalIndicatorColorChanged) Q_PROPERTY(QBrush disableIndicatorColor READ disableIndicatorColor WRITE setDisableIndicatorColor NOTIFY disableIndicatorColorChanged) + Q_PROPERTY(QBrush normalTransparentColor READ normalTransparentColor WRITE setNormalTransparentColor NOTIFY normalTransparentColorChanged) + Q_PROPERTY(QBrush hoverTransparentColor READ hoverTransparentColor WRITE setHoverTransparentColor NOTIFY hoverTransparentColorChanged) + Q_PROPERTY(QBrush clickTransparentColor READ clickTransparentColor WRITE setClickTransparentColor NOTIFY clickTransparentColorChanged) + Q_PROPERTY(QBrush disableTransparentColor READ disableTransparentColor WRITE setDisableTransparentColor NOTIFY disableTransparentColorChanged) + Q_PROPERTY(QBrush normalTransparentBorderColor READ normalTransparentBorderColor WRITE setNormalTransparentBorderColor NOTIFY normalTransparentBorderColorChanged) + Q_PROPERTY(QBrush hoverTransparentBorderColor READ hoverTransparentBorderColor WRITE setHoverTransparentBorderColor NOTIFY hoverTransparentBorderColorChanged) + Q_PROPERTY(QBrush clickTransparentBorderColor READ clickTransparentBorderColor WRITE setClickTransparentBorderColor NOTIFY clickTransparentBorderColorChanged) + Q_PROPERTY(QBrush disableTransparentBorderColor READ disableTransparentBorderColor WRITE setDisableTransparentBorderColor NOTIFY disableTransparentBorderColorChanged) + Q_PROPERTY(int padding READ padding WRITE setPadding NOTIFY paddingChanged) Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) Q_PROPERTY(int recWidth READ recWidth WRITE setRecWidth NOTIFY recWidthHChanged) @@ -148,6 +157,30 @@ public: int indicatorLeftRightPadding() const; void setIndicatorLeftRightPadding(int newIndicatorLeftRightPadding); + const QBrush &normalTransparentColor() const; + void setNormalTransparentColor(const QBrush &newNormalTransparentColor); + + const QBrush &hoverTransparentColor() const; + void setHoverTransparentColor(const QBrush &newHoverTransparentColor); + + const QBrush &clickTransparentColor() const; + void setClickTransparentColor(const QBrush &newClickTransparentColor); + + const QBrush &disableTransparentColor() const; + void setDisableTransparentColor(const QBrush &newDisableTransparentColor); + + const QBrush &normalTransparentBorderColor() const; + void setNormalTransparentBorderColor(const QBrush &newNormalTransparentBorderColor); + + const QBrush &hoverTransparentBorderColor() const; + void setHoverTransparentBorderColor(const QBrush &newHoverTransparentBorderColor); + + const QBrush &clickTransparentBorderColor() const; + void setClickTransparentBorderColor(const QBrush &newClickTransparentBorderColor); + + const QBrush &disableTransparentBorderColor() const; + void setDisableTransparentBorderColor(const QBrush &newDisableTransparentBorderColor); + signals: void normalColorChanged(); @@ -199,6 +232,22 @@ signals: void indicatorLeftRightPaddingChanged(); + void normalTransparentColorChanged(); + + void hoverTransparentColorChanged(); + + void clickTransparentColorChanged(); + + void disableTransparentColorChanged(); + + void normalTransparentBorderColorChanged(); + + void hoverTransparentBorderColorChanged(); + + void clickTransparentBorderColorChanged(); + + void disableTransparentBorderColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); @@ -228,6 +277,14 @@ private: int m_recWidth; int m_recHeight; int m_indicatorLeftRightPadding; + QBrush m_normalTransparentColor; + QBrush m_hoverTransparentColor; + QBrush m_clickTransparentColor; + QBrush m_disableTransparentColor; + QBrush m_normalTransparentBorderColor; + QBrush m_hoverTransparentBorderColor; + QBrush m_clickTransparentBorderColor; + QBrush m_disableTransparentBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUISwitch, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuitabbar.cpp b/ukui-qml-style-helper/styleparameter/ukuitabbar.cpp index 53052b5..166315c 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitabbar.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuitabbar.cpp @@ -8,11 +8,13 @@ UKUITabBar::UKUITabBar(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUITabBar::~UKUITabBar() diff --git a/ukui-qml-style-helper/styleparameter/ukuitabbutton.cpp b/ukui-qml-style-helper/styleparameter/ukuitabbutton.cpp index e0f5c4b..7c613b9 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitabbutton.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuitabbutton.cpp @@ -8,11 +8,13 @@ UKUITabButton::UKUITabButton(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUITabButton::~UKUITabButton() @@ -33,6 +35,12 @@ void UKUITabButton::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) setCheckedBorderColor(instance->kLineComponentNormal()); setNormalTextColor(instance->kFontPrimary()); + setNormalTransparentColor(QBrush(QColor(0,0,0,0))); + setHoverTransparentColor(instance->kContainAlphaHover()); + setClickedTransparentColor(instance->kContainAlphaClick()); + setCheckedTransparentColor(instance->kContainGeneralNormal()); + + setFocusBorderColor(instance->kBrandFocus()); emit parametryChanged(); } @@ -172,3 +180,68 @@ void UKUITabButton::setNormalTextColor(const QBrush &newNormalTextColor) m_normalTextColor = newNormalTextColor; emit disableTextColorChanged(); } + +const QBrush &UKUITabButton::normalTransparentColor() const +{ + return m_normalTransparentColor; +} + +void UKUITabButton::setNormalTransparentColor(const QBrush &newNormalTransparentColor) +{ + if (m_normalTransparentColor == newNormalTransparentColor) + return; + m_normalTransparentColor = newNormalTransparentColor; + emit normalTransparentColorChanged(); +} + +const QBrush &UKUITabButton::hoverTransparentColor() const +{ + return m_hoverTransparentColor; +} + +void UKUITabButton::setHoverTransparentColor(const QBrush &newHoverTransparentColor) +{ + if (m_hoverTransparentColor == newHoverTransparentColor) + return; + m_hoverTransparentColor = newHoverTransparentColor; + emit hoverTransparentColorChanged(); +} + +const QBrush &UKUITabButton::checkedTransparentColor() const +{ + return m_checkedTransparentColor; +} + +void UKUITabButton::setCheckedTransparentColor(const QBrush &newCheckedTransparentColor) +{ + if (m_checkedTransparentColor == newCheckedTransparentColor) + return; + m_checkedTransparentColor = newCheckedTransparentColor; + emit checkedTransparentColorChanged(); +} + +const QBrush &UKUITabButton::clickedTransparentColor() const +{ + return m_clickedTransparentColor; +} + +void UKUITabButton::setClickedTransparentColor(const QBrush &newClickedTransparentColor) +{ + if (m_clickedTransparentColor == newClickedTransparentColor) + return; + m_clickedTransparentColor = newClickedTransparentColor; + emit clickedTransparentColorChanged(); +} + +const QBrush &UKUITabButton::focusBorderColor() const +{ + return m_focusBorderColor; +} + +void UKUITabButton::setFocusBorderColor(const QBrush &newFocusBorderColor) +{ + if (m_focusBorderColor == newFocusBorderColor) + return; + m_focusBorderColor = newFocusBorderColor; + emit focusBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuitabbutton.h b/ukui-qml-style-helper/styleparameter/ukuitabbutton.h index c93184e..4373c03 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitabbutton.h +++ b/ukui-qml-style-helper/styleparameter/ukuitabbutton.h @@ -42,7 +42,6 @@ class UKUITabButton : public QQuickItem Q_PROPERTY(QBrush hoverColor READ hoverColor WRITE setHoverColor NOTIFY hoverColorChanged) Q_PROPERTY(QBrush checkedColor READ checkedColor WRITE setCheckedColor NOTIFY checkedColorChanged) Q_PROPERTY(QBrush clickedColor READ clickedColor WRITE setClickedColor NOTIFY clickedColorChanged) - Q_PROPERTY(QBrush checkedColor READ checkedColor WRITE setCheckedColor NOTIFY checkedColorColorChanged) Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) Q_PROPERTY(QBrush normalBorderColor READ normalBorderColor WRITE setNormalBorderColor NOTIFY normalBorderColorChanged) @@ -52,6 +51,12 @@ class UKUITabButton : public QQuickItem Q_PROPERTY(QBrush normalTextColor READ normalTextColor WRITE setNormalTextColor NOTIFY disableTextColorChanged) + Q_PROPERTY(QBrush normalTransparentColor READ normalTransparentColor WRITE setNormalTransparentColor NOTIFY normalTransparentColorChanged) + Q_PROPERTY(QBrush hoverTransparentColor READ hoverTransparentColor WRITE setHoverTransparentColor NOTIFY hoverTransparentColorChanged) + Q_PROPERTY(QBrush checkedTransparentColor READ checkedTransparentColor WRITE setCheckedTransparentColor NOTIFY checkedTransparentColorChanged) + Q_PROPERTY(QBrush clickedTransparentColor READ clickedTransparentColor WRITE setClickedTransparentColor NOTIFY clickedTransparentColorChanged) + Q_PROPERTY(QBrush focusBorderColor READ focusBorderColor WRITE setFocusBorderColor NOTIFY focusBorderColorChanged) + public: explicit UKUITabButton(QQuickItem *parent = nullptr); ~UKUITabButton(); @@ -90,6 +95,21 @@ public: const QBrush &normalTextColor() const; void setNormalTextColor(const QBrush &newNormalTextColor); + const QBrush &normalTransparentColor() const; + void setNormalTransparentColor(const QBrush &newNormalTransparentColor); + + const QBrush &hoverTransparentColor() const; + void setHoverTransparentColor(const QBrush &newHoverTransparentColor); + + const QBrush &checkedTransparentColor() const; + void setCheckedTransparentColor(const QBrush &newCheckedTransparentColor); + + const QBrush &clickedTransparentColor() const; + void setClickedTransparentColor(const QBrush &newClickedTransparentColor); + + const QBrush &focusBorderColor() const; + void setFocusBorderColor(const QBrush &newFocusBorderColor); + signals: void normalColorChanged(); @@ -99,8 +119,6 @@ signals: void clickedColorChanged(); - void checkedColorColorChanged(); - void borderWidthChanged(); void normalBorderColorChanged(); @@ -115,6 +133,16 @@ signals: void parametryChanged(); + void normalTransparentColorChanged(); + + void hoverTransparentColorChanged(); + + void checkedTransparentColorChanged(); + + void clickedTransparentColorChanged(); + + void focusBorderColorChanged(); + private: Q_INVOKABLE QBrush m_normalColor = QBrush("#FFFFFF"); Q_INVOKABLE QBrush m_hoverColor = QBrush("#F2F2F2"); @@ -129,6 +157,11 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_normalTransparentColor; + QBrush m_hoverTransparentColor; + QBrush m_checkedTransparentColor; + QBrush m_clickedTransparentColor; + QBrush m_focusBorderColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUITabButton, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuitextarea.cpp b/ukui-qml-style-helper/styleparameter/ukuitextarea.cpp new file mode 100644 index 0000000..9356e61 --- /dev/null +++ b/ukui-qml-style-helper/styleparameter/ukuitextarea.cpp @@ -0,0 +1,415 @@ +#include +#include "ukuitextarea.h" +#include "qdebug.h" +using namespace UKUIQQC2Style; + +UKUITextArea::UKUITextArea(QQuickItem *parent) : QQuickItem(parent) +{ + if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) + return; + TokenParameter * token = qApp->property("qqc2-globaltoken").value(); + if(token && token->getInstance()){ + m_instance = token->getInstance(); + initParam(m_instance); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } +} + +UKUITextArea::~UKUITextArea() +{ + +} + +UKUITextArea* UKUITextArea::qmlAttachedProperties(QObject* parent) +{ + auto p = qobject_cast(parent); + return new UKUITextArea(p); +} + +void UKUITextArea::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) +{ + setLeftRightPadding(16); + setRadius(instance->kradiusNormal()); + setBorderWidth(instance->normalline()); + setFocusBorderWidth(instance->focusline()); + setNormalWidth(180); + setNormalHeight(36); + + setInputNormalBC(instance->kComponentInput()); + setNormalBC(instance->kContainSecondaryNormal()); + setHoveredBC(instance->kContainSecondaryNormal()); + setClickedBC(instance->kContainSecondaryNormal()); + setDisableBC(instance->kContainSecondaryNormal()); + + setNormalBorderColor(instance->kLineNormal()); + setHoverBorderColor(instance->kLineNormal()); + setDisableBorderColor(instance->kLineDisable()); + setFocusBorderColor(instance->kBrandNormal()); + + setPlaceHolderNormalTextColor(instance->kFontPlaceholdertext()); + setPlaceHolderDisableTextColor(instance->kFontPlaceholdertextDisable()); + setNormalTextColor(instance->kFontPrimary()); + setDisableTextColor(instance->kFontPlaceholdertextDisable()); + + setInputNormalTransparentBC(instance->kComponentInputAlpha()); + setNormalTransparentBC(instance->kContainSecondaryAlphaNormal()); + setHoveredTransparentBC(instance->kContainSecondaryAlphaNormal()); + setClickedTransparentBC(instance->kContainSecondaryAlphaNormal()); + setDisableTransparentBC(instance->kContainSecondaryAlphaNormal()); + + emit parametryChanged(); + +} + +double UKUITextArea::radius() const +{ + return m_radius; +} + +void UKUITextArea::setRadius(double newRadius) +{ + if (qFuzzyCompare(m_radius, newRadius)) + return; + m_radius = newRadius; + emit radiusChanged(); +} + +double UKUITextArea::leftRightPadding() const +{ + return m_leftRightPadding; +} + +void UKUITextArea::setLeftRightPadding(double newLeftRightPadding) +{ + if (qFuzzyCompare(m_leftRightPadding, newLeftRightPadding)) + return; + m_leftRightPadding = newLeftRightPadding; + emit leftRightPaddingChanged(); +} + +double UKUITextArea::upDownMargin() const +{ + return m_upDownMargin; +} + +void UKUITextArea::setUpDownMargin(double newUpDownMargin) +{ + if (qFuzzyCompare(m_upDownMargin, newUpDownMargin)) + return; + m_upDownMargin = newUpDownMargin; + emit upDownMarginChanged(); +} + +double UKUITextArea::space() const +{ + return m_space; +} + +void UKUITextArea::setSpace(double newSpace) +{ + if (qFuzzyCompare(m_space, newSpace)) + return; + m_space = newSpace; + emit spaceChange(); +} + +int UKUITextArea::normalWidth() const +{ + return m_normalWidth; +} + +void UKUITextArea::setNormalWidth(int newNormalWidth) +{ + if (m_normalWidth == newNormalWidth) + return; + m_normalWidth = newNormalWidth; + emit normalWidthChanged(); +} + +int UKUITextArea::normalHeight() const +{ + return m_normalHeight; +} + +void UKUITextArea::setNormalHeight(int newNormalHeight) +{ + if (m_normalHeight == newNormalHeight) + return; + m_normalHeight = newNormalHeight; + emit normalHeightChanged(); +} + +const QBrush &UKUITextArea::normalBC() const +{ + return m_normalBC; +} + +void UKUITextArea::setNormalBC(const QBrush &newNormalBC) +{ + if (m_normalBC == newNormalBC) + return; + m_normalBC = newNormalBC; + emit normalBCChanged(); +} + +const QBrush &UKUITextArea::clickedBC() const +{ + return m_clickedBC; +} + +void UKUITextArea::setClickedBC(const QBrush &newClickedBC) +{ + if (m_clickedBC == newClickedBC) + return; + m_clickedBC = newClickedBC; + emit clickedBCChanged(); +} + +const QBrush &UKUITextArea::hoveredBC() const +{ + return m_hoveredBC; +} + +void UKUITextArea::setHoveredBC(const QBrush &newHoveredBC) +{ + if (m_hoveredBC == newHoveredBC) + return; + m_hoveredBC = newHoveredBC; + emit hoveredBCChanged(); +} + +const QBrush &UKUITextArea::disableBC() const +{ + return m_disableBC; +} + +void UKUITextArea::setDisableBC(const QBrush &newDisableBC) +{ + if (m_disableBC == newDisableBC) + return; + m_disableBC = newDisableBC; + emit disableBCChanged(); +} + +const QBrush &UKUITextArea::disableTextColor() const +{ + return m_disableTextColor; +} + +void UKUITextArea::setDisableTextColor(const QBrush &newDisableTextColor) +{ + if (m_disableTextColor == newDisableTextColor) + return; + m_disableTextColor = newDisableTextColor; + emit disableTextColorChanged(); +} + +const QBrush &UKUITextArea::normalTextColor() const +{ + return m_normalTextColor; +} + +void UKUITextArea::setNormalTextColor(const QBrush &newNormalTextColor) +{ + if (m_normalTextColor == newNormalTextColor) + return; + m_normalTextColor = newNormalTextColor; + emit normalTextColorChanged(); +} + +int UKUITextArea::borderWidth() const +{ + return m_borderWidth; +} + +void UKUITextArea::setBorderWidth(int newBorderWidth) +{ + if (m_borderWidth == newBorderWidth) + return; + m_borderWidth = newBorderWidth; + emit borderWidthChanged(); +} + +int UKUITextArea::focusBorderWidth() const +{ + return m_focusBorderWidth; +} + +void UKUITextArea::setFocusBorderWidth(int newFocusBorderWidth) +{ + if (m_focusBorderWidth == newFocusBorderWidth) + return; + m_focusBorderWidth = newFocusBorderWidth; + emit focusBorderWidthChanged(); +} + +const QBrush &UKUITextArea::normalBorderColor() const +{ + return m_normalBorderColor; +} + +void UKUITextArea::setNormalBorderColor(const QBrush &newNormalBorderColor) +{ + if (m_normalBorderColor == newNormalBorderColor) + return; + m_normalBorderColor = newNormalBorderColor; + emit normalBorderColorChanged(); +} + +const QBrush &UKUITextArea::clickBorderColor() const +{ + return m_clickBorderColor; +} + +void UKUITextArea::setClickBorderColor(const QBrush &newClickBorderColor) +{ + if (m_clickBorderColor == newClickBorderColor) + return; + m_clickBorderColor = newClickBorderColor; + emit clickBorderColorChanged(); +} + +const QBrush &UKUITextArea::disableBorderColor() const +{ + return m_disableBorderColor; +} + +void UKUITextArea::setDisableBorderColor(const QBrush &newDisableBorderColor) +{ + if (m_disableBorderColor == newDisableBorderColor) + return; + m_disableBorderColor = newDisableBorderColor; + emit disableBorderColorChanged(); +} + +const QBrush &UKUITextArea::focusBorderColor() const +{ + return m_focusBorderColor; +} + +void UKUITextArea::setFocusBorderColor(const QBrush &newFocusBorderColor) +{ + if (m_focusBorderColor == newFocusBorderColor) + return; + m_focusBorderColor = newFocusBorderColor; + emit focusBorderColorChanged(); +} + +const QBrush &UKUITextArea::hoverBorderColor() const +{ + return m_hoverBorderColor; +} + +void UKUITextArea::setHoverBorderColor(const QBrush &newHoverBorderColor) +{ + if (m_hoverBorderColor == newHoverBorderColor) + return; + m_hoverBorderColor = newHoverBorderColor; + emit hoverBorderColorChanged(); +} + +const QBrush &UKUITextArea::placeHolderNormalTextColor() const +{ + return m_placeHolderNormalTextColor; +} + +void UKUITextArea::setPlaceHolderNormalTextColor(const QBrush &newPlaceHolderNormalTextColor) +{ + if (m_placeHolderNormalTextColor == newPlaceHolderNormalTextColor) + return; + m_placeHolderNormalTextColor = newPlaceHolderNormalTextColor; + emit placeHolderNormalTextColorChanged(); +} + +const QBrush &UKUITextArea::placeHolderDisableTextColor() const +{ + return m_placeHolderDisableTextColor; +} + +void UKUITextArea::setPlaceHolderDisableTextColor(const QBrush &newPlaceHolderDisableTextColor) +{ + if (m_placeHolderDisableTextColor == newPlaceHolderDisableTextColor) + return; + m_placeHolderDisableTextColor = newPlaceHolderDisableTextColor; + emit placeHolderDisableTextColorChanged(); +} + +const QBrush &UKUITextArea::inputNormalBC() const +{ + return m_inputNormalBC; +} + +void UKUITextArea::setInputNormalBC(const QBrush &newInputNormalBC) +{ + if (m_inputNormalBC == newInputNormalBC) + return; + m_inputNormalBC = newInputNormalBC; + emit inputNormalBCChanged(); +} + +const QBrush &UKUITextArea::normalTransparentBC() const +{ + return m_normalTransparentBC; +} + +void UKUITextArea::setNormalTransparentBC(const QBrush &newNormalTransparentBC) +{ + if (m_normalTransparentBC == newNormalTransparentBC) + return; + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); +} + +const QBrush &UKUITextArea::inputNormalTransparentBC() const +{ + return m_inputNormalTransparentBC; +} + +void UKUITextArea::setInputNormalTransparentBC(const QBrush &newInputNormalTransparentBC) +{ + if (m_inputNormalTransparentBC == newInputNormalTransparentBC) + return; + m_inputNormalTransparentBC = newInputNormalTransparentBC; + emit inputNormalTransparentBCChanged(); +} + +const QBrush &UKUITextArea::clickedTransparentBC() const +{ + return m_clickedTransparentBC; +} + +void UKUITextArea::setClickedTransparentBC(const QBrush &newClickedTransparentBC) +{ + if (m_clickedTransparentBC == newClickedTransparentBC) + return; + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); +} + +const QBrush &UKUITextArea::hoveredTransparentBC() const +{ + return m_hoveredTransparentBC; +} + +void UKUITextArea::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) +{ + if (m_hoveredTransparentBC == newHoveredTransparentBC) + return; + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUITextArea::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUITextArea::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuitextarea.h b/ukui-qml-style-helper/styleparameter/ukuitextarea.h new file mode 100644 index 0000000..7e3d81a --- /dev/null +++ b/ukui-qml-style-helper/styleparameter/ukuitextarea.h @@ -0,0 +1,256 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +#ifndef UKUITEXTAREA_H +#define UKUITEXTAREA_H + +#include +#include +#include +#include +#include "tokenparameter.h" + +namespace UKUIQQC2Style { + +class UKUITextArea : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(double radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(double leftRightPadding READ leftRightPadding WRITE setLeftRightPadding NOTIFY leftRightPaddingChanged) + Q_PROPERTY(double upDownMargin READ upDownMargin WRITE setUpDownMargin NOTIFY upDownMarginChanged) + Q_PROPERTY(double space READ space WRITE setSpace NOTIFY spaceChange) + + Q_PROPERTY(int normalWidth READ normalWidth WRITE setNormalWidth NOTIFY normalWidthChanged) + Q_PROPERTY(int normalHeight READ normalHeight WRITE setNormalHeight NOTIFY normalHeightChanged) + Q_PROPERTY(QBrush normalBC READ normalBC WRITE setNormalBC NOTIFY normalBCChanged) + Q_PROPERTY(QBrush inputNormalBC READ inputNormalBC WRITE setInputNormalBC NOTIFY inputNormalBCChanged) + + Q_PROPERTY(QBrush clickedBC READ clickedBC WRITE setClickedBC NOTIFY clickedBCChanged) + Q_PROPERTY(QBrush hoveredBC READ hoveredBC WRITE setHoveredBC NOTIFY hoveredBCChanged) + Q_PROPERTY(QBrush disableBC READ disableBC WRITE setDisableBC NOTIFY disableBCChanged) + + Q_PROPERTY(QBrush placeHolderNormalTextColor READ placeHolderNormalTextColor WRITE setPlaceHolderNormalTextColor NOTIFY placeHolderNormalTextColorChanged) + Q_PROPERTY(QBrush placeHolderDisableTextColor READ placeHolderDisableTextColor WRITE setPlaceHolderDisableTextColor NOTIFY placeHolderDisableTextColorChanged) + Q_PROPERTY(QBrush disableTextColor READ disableTextColor WRITE setDisableTextColor NOTIFY disableTextColorChanged) + Q_PROPERTY(QBrush normalTextColor READ normalTextColor WRITE setNormalTextColor NOTIFY normalTextColorChanged) + + Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) + Q_PROPERTY(int focusBorderWidth READ focusBorderWidth WRITE setFocusBorderWidth NOTIFY focusBorderWidthChanged) + Q_PROPERTY(QBrush normalBorderColor READ normalBorderColor WRITE setNormalBorderColor NOTIFY normalBorderColorChanged) + Q_PROPERTY(QBrush hoverBorderColor READ hoverBorderColor WRITE setHoverBorderColor NOTIFY hoverBorderColorChanged) + + Q_PROPERTY(QBrush clickBorderColor READ clickBorderColor WRITE setClickBorderColor NOTIFY clickBorderColorChanged) + Q_PROPERTY(QBrush disableBorderColor READ disableBorderColor WRITE setDisableBorderColor NOTIFY disableBorderColorChanged) + Q_PROPERTY(QBrush focusBorderColor READ focusBorderColor WRITE setFocusBorderColor NOTIFY focusBorderColorChanged) + + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush inputNormalTransparentBC READ inputNormalTransparentBC WRITE setInputNormalTransparentBC NOTIFY inputNormalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + +public: + explicit UKUITextArea(QQuickItem *parent = nullptr); + ~UKUITextArea(); + + static UKUITextArea* qmlAttachedProperties(QObject* parent); + + void initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance); + + + double radius() const; + void setRadius(double newRadius); + + double leftRightPadding() const; + void setLeftRightPadding(double newLeftRightPadding); + + double upDownMargin() const; + void setUpDownMargin(double newUpDownMargin); + + double space() const; + void setSpace(double newSpace); + + int normalWidth() const; + void setNormalWidth(int newNormalWidth); + + int normalHeight() const; + void setNormalHeight(int newNormalHeight); + + const QBrush &normalBC() const; + void setNormalBC(const QBrush &newNormalBC); + + const QBrush &clickedBC() const; + void setClickedBC(const QBrush &newClickedBC); + + const QBrush &hoveredBC() const; + void setHoveredBC(const QBrush &newHoveredBC); + + const QBrush &disableBC() const; + void setDisableBC(const QBrush &newDisableBC); + + const QBrush &disableTextColor() const; + void setDisableTextColor(const QBrush &newDisableTextColor); + + const QBrush &normalTextColor() const; + void setNormalTextColor(const QBrush &newNormalTextColor); + + int borderWidth() const; + void setBorderWidth(int newBorderWidth); + + int focusBorderWidth() const; + void setFocusBorderWidth(int newFocusBorderWidth); + + const QBrush &normalBorderColor() const; + void setNormalBorderColor(const QBrush &newNormalBorderColor); + + const QBrush &clickBorderColor() const; + void setClickBorderColor(const QBrush &newClickBorderColor); + + const QBrush &disableBorderColor() const; + void setDisableBorderColor(const QBrush &newDisableBorderColor); + + const QBrush &focusBorderColor() const; + void setFocusBorderColor(const QBrush &newFocusBorderColor); + + const QBrush &hoverBorderColor() const; + void setHoverBorderColor(const QBrush &newHoverBorderColor); + + const QBrush &placeHolderNormalTextColor() const; + void setPlaceHolderNormalTextColor(const QBrush &newPlaceHolderNormalTextColor); + + const QBrush &placeHolderDisableTextColor() const; + void setPlaceHolderDisableTextColor(const QBrush &newPlaceHolderDisableTextColor); + + const QBrush &inputNormalBC() const; + void setInputNormalBC(const QBrush &newInputNormalBC); + + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &inputNormalTransparentBC() const; + void setInputNormalTransparentBC(const QBrush &newInputNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + +signals: + + void radiusChanged(); + + void leftRightPaddingChanged(); + + void upDownMarginChanged(); + + void spaceChange(); + + void normalWidthChanged(); + + void normalHeightChanged(); + + void normalBCChanged(); + + void clickedBCChanged(); + + void hoveredBCChanged(); + + void disableBCChanged(); + + void disableTextColorChanged(); + + void normalTextColorChanged(); + + void borderWidthChanged(); + + void focusBorderWidthChanged(); + + void normalBorderColorChanged(); + + void clickBorderColorChanged(); + + void disableBorderColorChanged(); + + void focusBorderColorChanged(); + + void hoverBorderColorChanged(); + + void placeHolderNormalTextColorChanged(); + + void placeHolderDisableTextColorChanged(); + + void inputNormalBCChanged(); + + void parametryChanged(); + + void normalTransparentBCChanged(); + + void inputNormalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + +private: + + double m_radius; + double m_leftRightPadding; + double m_upDownMargin; + double m_space; + int m_normalWidth; + int m_normalHeight; + Q_INVOKABLE QBrush m_normalBC; + Q_INVOKABLE QBrush m_clickedBC; + Q_INVOKABLE QBrush m_hoveredBC; + Q_INVOKABLE QBrush m_disableBC; + Q_INVOKABLE QBrush m_disableTextColor; + Q_INVOKABLE QBrush m_normalTextColor; + int m_borderWidth; + int m_focusBorderWidth; + Q_INVOKABLE QBrush m_normalBorderColor; + Q_INVOKABLE QBrush m_clickBorderColor; + Q_INVOKABLE QBrush m_disableBorderColor; + Q_INVOKABLE QBrush m_focusBorderColor; + Q_INVOKABLE QBrush m_hoverBorderColor; + Q_INVOKABLE QBrush m_placeHolderNormalTextColor; + Q_INVOKABLE QBrush m_placeHolderDisableTextColor; + Q_INVOKABLE QBrush m_inputNormalBC; + + UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + + QBrush m_normalTransparentBC; + QBrush m_inputNormalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; +}; +} +QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUITextArea, QML_HAS_ATTACHED_PROPERTIES) + +#endif // UKUITEXTAREA_H diff --git a/ukui-qml-style-helper/styleparameter/ukuitextfiled.cpp b/ukui-qml-style-helper/styleparameter/ukuitextfiled.cpp index 3eeb90b..04bc146 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitextfiled.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuitextfiled.cpp @@ -8,11 +8,13 @@ UKUITextFiled::UKUITextFiled(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + } } UKUITextFiled::~UKUITextFiled() @@ -28,28 +30,34 @@ UKUITextFiled* UKUITextFiled::qmlAttachedProperties(QObject* parent) void UKUITextFiled::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setLeftRightPadding(instance->tokenGap8()); + setLeftRightPadding(8); setRadius(instance->kradiusNormal()); setBorderWidth(instance->normalline()); setFocusBorderWidth(instance->focusline()); setNormalWidth(180); setNormalHeight(36); + setInputNormalBC(instance->kComponentInput()); setNormalBC(instance->kComponentNormal()); - setInputNormalBC(instance->kContainGeneralNormal()); - setPlaceHolderNormalBC(instance->buttonActive()); - setPlaceHolderHoveredBC(instance->kComponentHover()); - setPlaceHolderClickedBC(instance->kComponentClick()); - setPlaceHolderDisableBC(instance->buttonDisable()); + setHoveredBC(instance->kComponentHover()); + setClickedBC(instance->kComponentClick()); + setDisableBC(instance->kComponentDisable()); + setNormalBorderColor(instance->kLineComponentNormal()); setHoverBorderColor(instance->kLineComponentHover()); setDisableBorderColor(instance->kLineComponentDisable()); - setFocusBorderColor(instance->kBrandFocus()); + setFocusBorderColor(instance->kBrandNormal()); + + setPlaceHolderNormalTextColor(instance->kFontPlaceholdertext()); + setPlaceHolderDisableTextColor(instance->kFontPlaceholdertextDisable()); + setNormalTextColor(instance->kFontPrimary()); + setDisableTextColor(instance->kFontPlaceholdertextDisable()); - setPlaceHolderNormalTextColor(instance->placeholderTextActive()); - setPlaceHolderDisableTextColor(instance->placeholderTextDisable()); - setNormalTextColor(instance->buttonTextActive()); - setDisableTextColor(instance->placeholderTextDisable()); + setInputNormalTransparentBC(instance->kComponentInputAlpha()); + setNormalTransparentBC(instance->kComponentAlphaNormal()); + setHoveredTransparentBC(instance->kComponentAlphaHover()); + setClickedTransparentBC(instance->kComponentAlphaClick()); + setDisableTransparentBC(instance->kComponentAlphaDisable()); emit parametryChanged(); @@ -328,67 +336,80 @@ void UKUITextFiled::setPlaceHolderDisableTextColor(const QBrush &newPlaceHolderD emit placeHolderDisableTextColorChanged(); } -const QBrush &UKUITextFiled::placeHolderNormalBC() const +const QBrush &UKUITextFiled::inputNormalBC() const { - return m_placeHolderNormalBC; + return m_inputNormalBC; } -void UKUITextFiled::setPlaceHolderNormalBC(const QBrush &newPlaceHolderNormalBC) +void UKUITextFiled::setInputNormalBC(const QBrush &newInputNormalBC) { - if (m_placeHolderNormalBC == newPlaceHolderNormalBC) + if (m_inputNormalBC == newInputNormalBC) return; - m_placeHolderNormalBC = newPlaceHolderNormalBC; - emit placeHolderNormalBCChanged(); + m_inputNormalBC = newInputNormalBC; + emit inputNormalBCChanged(); } -const QBrush &UKUITextFiled::placeHolderClickedBC() const +const QBrush &UKUITextFiled::normalTransparentBC() const { - return m_placeHolderClickedBC; + return m_normalTransparentBC; } -void UKUITextFiled::setPlaceHolderClickedBC(const QBrush &newPlaceHolderClickedBC) +void UKUITextFiled::setNormalTransparentBC(const QBrush &newNormalTransparentBC) { - if (m_placeHolderClickedBC == newPlaceHolderClickedBC) + if (m_normalTransparentBC == newNormalTransparentBC) return; - m_placeHolderClickedBC = newPlaceHolderClickedBC; - emit placeHolderClickedBCChanged(); + m_normalTransparentBC = newNormalTransparentBC; + emit normalTransparentBCChanged(); } -const QBrush &UKUITextFiled::placeHolderHoveredBC() const +const QBrush &UKUITextFiled::inputNormalTransparentBC() const { - return m_placeHolderHoveredBC; + return m_inputNormalTransparentBC; } -void UKUITextFiled::setPlaceHolderHoveredBC(const QBrush &newPlaceHolderHoveredBC) +void UKUITextFiled::setInputNormalTransparentBC(const QBrush &newInputNormalTransparentBC) { - if (m_placeHolderHoveredBC == newPlaceHolderHoveredBC) + if (m_inputNormalTransparentBC == newInputNormalTransparentBC) return; - m_placeHolderHoveredBC = newPlaceHolderHoveredBC; - emit placeHolderHoveredBCChanged(); + m_inputNormalTransparentBC = newInputNormalTransparentBC; + emit inputNormalTransparentBCChanged(); } -const QBrush &UKUITextFiled::placeHolderDisableBC() const +const QBrush &UKUITextFiled::clickedTransparentBC() const { - return m_placeHolderDisableBC; + return m_clickedTransparentBC; } -void UKUITextFiled::setPlaceHolderDisableBC(const QBrush &newPlaceHolderDisableBC) +void UKUITextFiled::setClickedTransparentBC(const QBrush &newClickedTransparentBC) { - if (m_placeHolderDisableBC == newPlaceHolderDisableBC) + if (m_clickedTransparentBC == newClickedTransparentBC) return; - m_placeHolderDisableBC = newPlaceHolderDisableBC; - emit placeHolderDisableBCChanged(); + m_clickedTransparentBC = newClickedTransparentBC; + emit clickedTransparentBCChanged(); } -const QBrush &UKUITextFiled::inputNormalBC() const +const QBrush &UKUITextFiled::hoveredTransparentBC() const { - return m_inputNormalBC; + return m_hoveredTransparentBC; } -void UKUITextFiled::setInputNormalBC(const QBrush &newInputNormalBC) +void UKUITextFiled::setHoveredTransparentBC(const QBrush &newHoveredTransparentBC) { - if (m_inputNormalBC == newInputNormalBC) + if (m_hoveredTransparentBC == newHoveredTransparentBC) return; - m_inputNormalBC = newInputNormalBC; - emit inputNormalBCChanged(); + m_hoveredTransparentBC = newHoveredTransparentBC; + emit hoveredTransparentBCChanged(); +} + +const QBrush &UKUITextFiled::disableTransparentBC() const +{ + return m_disableTransparentBC; +} + +void UKUITextFiled::setDisableTransparentBC(const QBrush &newDisableTransparentBC) +{ + if (m_disableTransparentBC == newDisableTransparentBC) + return; + m_disableTransparentBC = newDisableTransparentBC; + emit disableTransparentBCChanged(); } diff --git a/ukui-qml-style-helper/styleparameter/ukuitextfiled.h b/ukui-qml-style-helper/styleparameter/ukuitextfiled.h index 0d44f30..e90a0f5 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitextfiled.h +++ b/ukui-qml-style-helper/styleparameter/ukuitextfiled.h @@ -49,11 +49,6 @@ class UKUITextFiled : public QQuickItem Q_PROPERTY(QBrush hoveredBC READ hoveredBC WRITE setHoveredBC NOTIFY hoveredBCChanged) Q_PROPERTY(QBrush disableBC READ disableBC WRITE setDisableBC NOTIFY disableBCChanged) - Q_PROPERTY(QBrush placeHolderNormalBC READ placeHolderNormalBC WRITE setPlaceHolderNormalBC NOTIFY placeHolderNormalBCChanged) - Q_PROPERTY(QBrush placeHolderClickedBC READ placeHolderClickedBC WRITE setPlaceHolderClickedBC NOTIFY placeHolderClickedBCChanged) - Q_PROPERTY(QBrush placeHolderHoveredBC READ placeHolderHoveredBC WRITE setPlaceHolderHoveredBC NOTIFY placeHolderHoveredBCChanged) - Q_PROPERTY(QBrush placeHolderDisableBC READ placeHolderDisableBC WRITE setPlaceHolderDisableBC NOTIFY placeHolderDisableBCChanged) - Q_PROPERTY(QBrush placeHolderNormalTextColor READ placeHolderNormalTextColor WRITE setPlaceHolderNormalTextColor NOTIFY placeHolderNormalTextColorChanged) Q_PROPERTY(QBrush placeHolderDisableTextColor READ placeHolderDisableTextColor WRITE setPlaceHolderDisableTextColor NOTIFY placeHolderDisableTextColorChanged) Q_PROPERTY(QBrush disableTextColor READ disableTextColor WRITE setDisableTextColor NOTIFY disableTextColorChanged) @@ -68,7 +63,12 @@ class UKUITextFiled : public QQuickItem Q_PROPERTY(QBrush disableBorderColor READ disableBorderColor WRITE setDisableBorderColor NOTIFY disableBorderColorChanged) Q_PROPERTY(QBrush focusBorderColor READ focusBorderColor WRITE setFocusBorderColor NOTIFY focusBorderColorChanged) - + Q_PROPERTY(QBrush normalTransparentBC READ normalTransparentBC WRITE setNormalTransparentBC NOTIFY normalTransparentBCChanged) + Q_PROPERTY(QBrush inputNormalTransparentBC READ inputNormalTransparentBC WRITE setInputNormalTransparentBC NOTIFY inputNormalTransparentBCChanged) + Q_PROPERTY(QBrush clickedTransparentBC READ clickedTransparentBC WRITE setClickedTransparentBC NOTIFY clickedTransparentBCChanged) + Q_PROPERTY(QBrush hoveredTransparentBC READ hoveredTransparentBC WRITE setHoveredTransparentBC NOTIFY hoveredTransparentBCChanged) + Q_PROPERTY(QBrush disableTransparentBC READ disableTransparentBC WRITE setDisableTransparentBC NOTIFY disableTransparentBCChanged) + public: explicit UKUITextFiled(QQuickItem *parent = nullptr); ~UKUITextFiled(); @@ -141,21 +141,24 @@ public: const QBrush &placeHolderDisableTextColor() const; void setPlaceHolderDisableTextColor(const QBrush &newPlaceHolderDisableTextColor); - const QBrush &placeHolderNormalBC() const; - void setPlaceHolderNormalBC(const QBrush &newPlaceHolderNormalBC); - - const QBrush &placeHolderClickedBC() const; - void setPlaceHolderClickedBC(const QBrush &newPlaceHolderClickedBC); - - const QBrush &placeHolderHoveredBC() const; - void setPlaceHolderHoveredBC(const QBrush &newPlaceHolderHoveredBC); - - const QBrush &placeHolderDisableBC() const; - void setPlaceHolderDisableBC(const QBrush &newPlaceHolderDisableBC); - const QBrush &inputNormalBC() const; void setInputNormalBC(const QBrush &newInputNormalBC); - + + const QBrush &normalTransparentBC() const; + void setNormalTransparentBC(const QBrush &newNormalTransparentBC); + + const QBrush &inputNormalTransparentBC() const; + void setInputNormalTransparentBC(const QBrush &newInputNormalTransparentBC); + + const QBrush &clickedTransparentBC() const; + void setClickedTransparentBC(const QBrush &newClickedTransparentBC); + + const QBrush &hoveredTransparentBC() const; + void setHoveredTransparentBC(const QBrush &newHoveredTransparentBC); + + const QBrush &disableTransparentBC() const; + void setDisableTransparentBC(const QBrush &newDisableTransparentBC); + signals: void radiusChanged(); @@ -200,18 +203,20 @@ signals: void placeHolderDisableTextColorChanged(); - void placeHolderNormalBCChanged(); - - void placeHolderClickedBCChanged(); - - void placeHolderHoveredBCChanged(); - - void placeHolderDisableBCChanged(); - void inputNormalBCChanged(); void parametryChanged(); - + + void normalTransparentBCChanged(); + + void inputNormalTransparentBCChanged(); + + void clickedTransparentBCChanged(); + + void hoveredTransparentBCChanged(); + + void disableTransparentBCChanged(); + private: double m_radius; @@ -235,14 +240,15 @@ private: Q_INVOKABLE QBrush m_hoverBorderColor; Q_INVOKABLE QBrush m_placeHolderNormalTextColor; Q_INVOKABLE QBrush m_placeHolderDisableTextColor; - Q_INVOKABLE QBrush m_placeHolderNormalBC; - Q_INVOKABLE QBrush m_placeHolderClickedBC; - Q_INVOKABLE QBrush m_placeHolderHoveredBC; - Q_INVOKABLE QBrush m_placeHolderDisableBC; Q_INVOKABLE QBrush m_inputNormalBC; UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; - + + QBrush m_normalTransparentBC; + QBrush m_inputNormalTransparentBC; + QBrush m_clickedTransparentBC; + QBrush m_hoveredTransparentBC; + QBrush m_disableTransparentBC; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUITextFiled, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qml-style-helper/styleparameter/ukuitooltip.cpp b/ukui-qml-style-helper/styleparameter/ukuitooltip.cpp index 295d046..3403c7f 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitooltip.cpp +++ b/ukui-qml-style-helper/styleparameter/ukuitooltip.cpp @@ -9,20 +9,22 @@ UKUIToolTip::UKUIToolTip(QQuickItem *parent) : QQuickItem(parent) if(!qApp || !qApp->property("qqc2-globaltoken").isValid()) return; TokenParameter * token = qApp->property("qqc2-globaltoken").value(); - m_instance = token->getInstance(); - initParam(m_instance); - connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + if(token && token->getInstance()){ + m_instance = token->getInstance(); initParam(m_instance); - }, Qt::QueuedConnection); - if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { - auto settings = UKUIStyleSettings::globalInstance(); - connect(settings, &UKUIStyleSettings::changed, this, [=](const QString &key) { - if (key == "menuTransparency" || key == "menu-transparency") { - initParam(m_instance); - return; - } - }, Qt::QueuedConnection - ); + connect(m_instance, &UKUIGlobalDTConfig::GlobalDTConfig::tokenChanged, this, [=](){ + initParam(m_instance); + }, Qt::UniqueConnection); + if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { + auto settings = UKUIStyleSettings::globalInstance(); + connect(settings, &UKUIStyleSettings::changed, this, [=](const QString &key) { + if (key == "menuTransparency" || key == "menu-transparency") { + initParam(m_instance); + return; + } + }, Qt::UniqueConnection + ); + } } } @@ -33,19 +35,20 @@ UKUIToolTip::~UKUIToolTip() void UKUIToolTip::initParam(UKUIGlobalDTConfig::GlobalDTConfig* instance) { - setPadding(12); - setBackBorderColor(instance->kLineWindowActive()); + setPadding(8); + setBackBorderColor(instance->kLineWindowInactive()); + setBackColor(instance->kContainGeneralNormal()); //setShadowColor(instance->kShadowMin()); setTextColor(instance->windowTextActive()); - setRadius(instance->kradiusNormal()); + setRadius(instance->kradiusMenu()); QColor c = instance->baseActive().color(); if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; c.setAlphaF(opacity); } - setBackColor(c); - + setBackTransparentColor(c); + setBackTransparentBorderColor(instance->kLineWindowInactive()); emit parametryChanged(); } @@ -146,3 +149,29 @@ void UKUIToolTip::setMargins(int newMargins) m_margins = newMargins; emit marginsChanged(); } + +const QBrush &UKUIToolTip::backTransparentColor() const +{ + return m_backTransparentColor; +} + +void UKUIToolTip::setBackTransparentColor(const QBrush &newBackTransparentColor) +{ + if (m_backTransparentColor == newBackTransparentColor) + return; + m_backTransparentColor = newBackTransparentColor; + emit backTransparentColorChanged(); +} + +const QBrush &UKUIToolTip::backTransparentBorderColor() const +{ + return m_backBorderTransparentColor; +} + +void UKUIToolTip::setBackTransparentBorderColor(const QBrush &newBackBorderTransparentColor) +{ + if (m_backBorderTransparentColor == newBackBorderTransparentColor) + return; + m_backBorderTransparentColor = newBackBorderTransparentColor; + emit backTransparentBorderColorChanged(); +} diff --git a/ukui-qml-style-helper/styleparameter/ukuitooltip.h b/ukui-qml-style-helper/styleparameter/ukuitooltip.h index d8fcc04..87d3613 100644 --- a/ukui-qml-style-helper/styleparameter/ukuitooltip.h +++ b/ukui-qml-style-helper/styleparameter/ukuitooltip.h @@ -45,6 +45,8 @@ class UKUIToolTip : public QQuickItem Q_PROPERTY(QBrush textColor READ textColor WRITE setTextColor NOTIFY textColorChanged) Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(int margins READ margins WRITE setMargins NOTIFY marginsChanged) + Q_PROPERTY(QBrush backTransparentColor READ backTransparentColor WRITE setBackTransparentColor NOTIFY backTransparentColorChanged) + Q_PROPERTY(QBrush backBorderTransparentColor READ backTransparentBorderColor WRITE setBackTransparentBorderColor NOTIFY backTransparentBorderColorChanged) public: explicit UKUIToolTip(QQuickItem *parent = nullptr); @@ -75,6 +77,12 @@ public: int margins() const; void setMargins(int newMargins); + const QBrush &backTransparentColor() const; + void setBackTransparentColor(const QBrush &newBackTransparentColor); + + const QBrush &backTransparentBorderColor() const; + void setBackTransparentBorderColor(const QBrush &newBackBorderTransparentColor); + signals: void paddingChanged(); @@ -92,6 +100,10 @@ signals: void parametryChanged(); + void backTransparentColorChanged(); + + void backTransparentBorderColorChanged(); + private: int m_padding = 12; Q_INVOKABLE QBrush m_backColor = QBrush(QColor::fromRgbF(0, 0, 0, 0.85)); @@ -103,6 +115,8 @@ private: UKUIGlobalDTConfig::GlobalDTConfig* m_instance = nullptr; + QBrush m_backTransparentColor; + QBrush m_backBorderTransparentColor; }; } QML_DECLARE_TYPEINFO(UKUIQQC2Style::UKUIToolTip, QML_HAS_ATTACHED_PROPERTIES) diff --git a/ukui-qqc2-style/org.ukui.style/BusyIndicator.qml b/ukui-qqc2-style/org.ukui.style/BusyIndicator.qml index e35ee0e..ef54c7c 100644 --- a/ukui-qqc2-style/org.ukui.style/BusyIndicator.qml +++ b/ukui-qqc2-style/org.ukui.style/BusyIndicator.qml @@ -28,6 +28,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Controls.impl 2.12 import QtQuick.Templates 2.12 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate T.BusyIndicator { id: controlRoot @@ -37,6 +38,15 @@ T.BusyIndicator { hoverEnabled: true property var index: 0 + property var iconWidth: controlRoot.width > 0 ? controlRoot.width : 16 + property var iconHeight: controlRoot.height > 0 ? controlRoot.height : 16 + + onIndexChanged: { + image.source = iconSource() + controlRoot.update(); + + // console.log("index changeddd", index) + } NumberAnimation{ id: animation target: controlRoot @@ -50,10 +60,26 @@ T.BusyIndicator { contentItem: Image { id: image - source: "image://imageProvider/ukui-loading-" + Math.round(index).toString() + "-symbolic" + source: iconSource() + sourceSize.width: iconWidth + sourceSize.height: iconHeight opacity: controlRoot.running ? 1 : 0 smooth: true anchors.fill: controlRoot } + + StylePrivate.APPParameter{ + id: app + // onParametryChanged:{ + // image.source = iconSource() + // controlRoot.update(); + // } + } + function iconSource(){ + if(app.isDark) + return "image://imageProvider/ukui-loading-" + Math.round(index).toString() + "-symbolic/highlight" + else + return "image://imageProvider/ukui-loading-" + Math.round(index).toString() + "-symbolic" + } } diff --git a/ukui-qqc2-style/org.ukui.style/Button.qml b/ukui-qqc2-style/org.ukui.style/Button.qml index 463abec..271d8fb 100644 --- a/ukui-qqc2-style/org.ukui.style/Button.qml +++ b/ukui-qqc2-style/org.ukui.style/Button.qml @@ -20,6 +20,13 @@ * */ +import QtQuick.Controls 1.4 + +import QtQuick 2.15 +import QtQuick.Window 2.12 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.15 +import QtGraphicalEffects 1.14 import QtQuick 2.6 import QtQuick.Templates 2.5 as T import org.ukui.qqc2style.private 1.0 as StylePrivate @@ -28,43 +35,71 @@ import org.ukui.qqc2style.private 1.0 as StylePrivate T.Button { id: controlRoot implicitWidth: { - var contentwidth = implicitContentWidth + leftPadding + rightPadding + if(controlRoot.hasOwnProperty("maxWidth")) + return controlRoot.maxWidth + var contentwidth = implicitContentWidth + leftPadding + rightPadding return Math.max(implicitBackgroundWidth + leftInset + rightInset, contentwidth, btn.normalWidth) } implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, btn.normalHeight) - leftPadding: StylePrivate.UKUIButton.margin - rightPadding: StylePrivate.UKUIButton.margin + leftPadding: StylePrivate.UKUIButton.leftRightMargin + rightPadding: StylePrivate.UKUIButton.leftRightMargin hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? + property var _menuToolButton:{ + if(controlRoot.hasOwnProperty("hasMenu")) + return controlRoot.hasMenu + else + return false + } + property var _maxWidth: { + if(controlRoot.hasOwnProperty("maxWidth")){ + console.log("maxWidthhhhhhh", controlRoot.maxWidth) + return controlRoot.maxWidth + } + else + return -1 + } - font: StylePrivate.APPParameter.font + font: app.font + palette: app.palette + + onEnabledChanged: { + content.updateImage() + back.changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) + } + onPressedChanged: content.updateImage() + property bool hasWindowActive: Qt.application.active + onHasWindowActiveChanged:{ + content.updateImage() + } StylePrivate.UKUIButton{ id: btn // Component.onCompleted: console.log("UKUIButton 1122333", btn.normalHBC) } -// StylePrivate.APPParameter{ -// id: appP + StylePrivate.APPParameter{ + id: app + + } -// Component.onCompleted: console.log("APPParameter 1122333") -// } contentItem: ButtonIconLabelContent { + id:content controlRoot: controlRoot anchors.centerIn: controlRoot //onWidthChanged: console.log(controlRoot.text, width) } background: BackGroundRectangle{ - implicitWidth: btn.normalWidth - implicitHeight: btn.normalHeight + id: back + implicitHeight: controlRoot.implicitHeight + implicitWidth: controlRoot.implicitWidth controlRoot: controlRoot _radius: btn.radius //Component.onCompleted: console.log("BackGroundRectangle radius", StylePrivate.UKUIButton.radius, StylePrivate.UKUIButton.normalBC) - } -// Component.onCompleted: console.log("Button radius", btn.radius) - + } } diff --git a/ukui-qqc2-style/org.ukui.style/CheckBox.qml b/ukui-qqc2-style/org.ukui.style/CheckBox.qml index c4d6829..8d35856 100644 --- a/ukui-qqc2-style/org.ukui.style/CheckBox.qml +++ b/ukui-qqc2-style/org.ukui.style/CheckBox.qml @@ -37,20 +37,49 @@ T.CheckBox { padding: 6 spacing: checkbox.space hoverEnabled: true + palette: app.palette + font: app.font + property var normalColor:checkbox.normalIndicatorColor + property var tansparentNormalColor: checkbox.normalTransparentIndicatorColor + property var tansparentNormalCheckColor: checkbox.checked_normalIndicatorColor + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + + // 新增:判断是否有动画正在运行(涵盖所有相关动画) + property bool isAnimating: scaleAnim.running || opacityAnim.running + || uncheckScaleAnim.running || uncheckOpacityAnim.running + || tansparentColorReturnAnim.running || tansparentColorAnim.running + || normalColorAnim.running || normalColorReturnAnim.running + + property var borderColor: control.checked || (control.tristate == true && control.checkState === Qt.PartiallyChecked)? + (!control.enabled ? checkbox.checked_disableIndicatorBorderColor : + control.pressed ? checkbox.checked_clickIndicatorBorderColor : + (!isAnimating && control.hovered) ? checkbox.checked_hoverIndicatorBorderColor : + checkbox.checked_normalIndicatorBorderColor) : + (!control.enabled ? checkbox.disableIndicatorBorderColor : + control.pressed ? checkbox.clickIndicatorBorderColor : + (!isAnimating && control.hovered) ? checkbox.hoverIndicatorBorderColor : + checkbox.normalIndicatorBorderColor) + + property var checkBoxColor: control.checked || (control.tristate == true && control.checkState === Qt.PartiallyChecked) ? + (!control.enabled ? checkbox.checked_disableIndicatorColor : + control.pressed ? checkbox.checked_clickIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.checked_hoverIndicatorColor : + tansparentNormalCheckColor) : + isTransaprent ? + (!control.enabled ? checkbox.disableTransparentIndicatorColor : + control.pressed ? checkbox.clickTransparentIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.hoverTransparentIndicatorColor : + tansparentNormalColor) : + (!control.enabled ? checkbox.disableIndicatorColor : + control.pressed ? checkbox.clickIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.hoverIndicatorColor : + normalColor) - property var borderColor: control.checked ? (!control.enabled ? checkbox.checked_disableIndicatorBorderColor : - control.pressed ? checkbox.checked_clickIndicatorBorderColor : control.hovered ? - checkbox.checked_hoverIndicatorBorderColor : checkbox.checked_normalIndicatorBorderColor) : - (!control.enabled ? checkbox.disableIndicatorBorderColor : control.pressed ? - checkbox.clickIndicatorBorderColor : control.hovered ? - checkbox.hoverIndicatorBorderColor : checkbox.normalIndicatorBorderColor) - - property var checkBoxColor: control.checked ? (!control.enabled ? checkbox.checked_disableIndicatorColor : - control.pressed ? checkbox.checked_clickIndicatorColor : control.hovered ? - checkbox.checked_hoverIndicatorColor : checkbox.checked_normalIndicatorColor) : - (!control.enabled ? checkbox.disableIndicatorColor : control.pressed ? - checkbox.clickIndicatorColor : control.hovered ? - checkbox.hoverIndicatorColor : checkbox.normalIndicatorColor) ParseInterface{ id: parseInterface } @@ -64,83 +93,278 @@ T.CheckBox { return parseInterface.pEndColor(dtcolor) } - // keep in sync with CheckDelegate.qml (shared CheckIndicator.qml was removed for performance reasons) - indicator: Rectangle { + indicator: Item{ implicitWidth: checkbox.indicatorWidth implicitHeight: checkbox.indicatorWidth - x: control.text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 - radius: checkbox.radius - - border.width: checkbox.borderWidth - border.color: getStartColor(control.visualFocus ? (control.checked ? borderColor : checkbox.checked_normalIndicatorColor) : control.borderColor) - color: gradientRec.visible ? "transparent" : getStartColor(checkBoxColor) - Rectangle{ - id: gradientRec + Rectangle { anchors.fill: parent - radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color - gradient: Gradient { - id:gradient - GradientStop { position: 0.0; color: getStartColor(checkBoxColor) } - - GradientStop { position: 1.0; color: getEndColor(checkBoxColor)} + radius: checkbox.radius + + color: gradientRec.visible ? "transparent" : getStartColor(checkBoxColor) + + Rectangle{ + id: gradientRec + anchors.fill: parent + radius: parent.radius + gradient: Gradient { + id:gradient + GradientStop { position: 0.0; color: getStartColor(checkBoxColor) } + GradientStop { position: 1.0; color: getEndColor(checkBoxColor)} + } + visible: !parseInterface.isSolidPattern(checkBoxColor) + } + + Rectangle{ + anchors.fill: parent + radius: checkbox.radius + border.width: checkbox.borderWidth + border.color: getStartColor(borderColor) + color: "transparent" } - visible: !parseInterface.isSolidPattern(checkBoxColor) } Image { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: 14 - height: 12 -// defaultColor: "#353637" -// color: control.palette.text - source: { - var model = !control.enabled ? "disenable" : control.checked ? "highlight" : "normal" - var icon = "object-select-symbolic"; - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg" - return "image://imageProvider/" + icon + "/" + model; + id: image + anchors.centerIn: parent + sourceSize.width: 16 + sourceSize.height: 16 + source: iconSource() + visible: control.checkState === Qt.Checked || (control.checkState === Qt.Unchecked && uncheckScaleAnim.running) + cache: false + scale: 0.2 + opacity: 0.0 + transformOrigin: Item.Center + } - } - visible: control.checkState === Qt.Checked + NumberAnimation { + id: scaleAnim + target: image + property: "scale" + from: 0.2 + to: 1.0 + duration: 240 + easing.type: Easing.InOutCirc + onRunningChanged: if (!running) control.update() + } + + PropertyAnimation { + id: opacityAnim + target: image + property: "opacity" + from: 0.0 + to: 1.0 + duration: 100 + easing.type: Easing.InOutQuart + onRunningChanged: if (!running) control.update() + } + + NumberAnimation { + id: uncheckScaleAnim + target: image + property: "scale" + from: 1.0 + to: 0.2 + duration: 240 + easing.type: Easing.InOutCirc + onRunningChanged: if (!running) control.update() + } + + PropertyAnimation { + id: uncheckOpacityAnim + target: image + property: "opacity" + from: 1.0 + to: 0.0 + duration: 100 + easing.type: Easing.InOutQuint + onRunningChanged: if (!running) control.update() } Rectangle { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 + anchors.centerIn: parent width: 9 height: 1 color: { getStartColor(!control.enabled ? checkbox.checked_disableChildrenColor : - control.pressed ? checkbox.checked_clickChildrenColor: - control.hovered ? checkbox.checked_hoverChildrenColor: - checkbox.checked_normalChildrenColor) + control.pressed ? checkbox.checked_clickChildrenColor: + // 部分选中状态处理hover与动画的关系 + (!isAnimating && control.hovered) ? checkbox.checked_hoverChildrenColor: + checkbox.checked_normalChildrenColor) } visible: control.checkState === Qt.PartiallyChecked } } - contentItem: Label { + contentItem: Text { leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 - text: control.text - font: app.font + font: control.font color: getStartColor(control.enabled ? checkbox.normalTextColor : checkbox.disableTextColor) } StylePrivate.APPParameter{ id: app onParametryChanged:{ + image.source = iconSource() control.update(); } + onIconThemeChanged: { + image.source = "" + image.source = iconSource() + } } StylePrivate.UKUICheckBox{ id: checkbox } + + ColorAnimation { + id: tansparentColorAnim + target: control + property: "tansparentNormalCheckColor" + from:checkbox.normalTransparentIndicatorColor + to: checkbox.checked_normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + + ColorAnimation { + id: tansparentColorReturnAnim + target: control + property: "tansparentNormalColor" + from: checkbox.checked_normalIndicatorColor + to: checkbox.normalTransparentIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + ColorAnimation { + id: normalColorAnim + target: control + property: "tansparentNormalCheckColor" + from:checkbox.normalIndicatorColor + to: checkbox.checked_normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + ColorAnimation { + id: normalColorReturnAnim + target: control + property: "normalColor" + from: checkbox.checked_normalIndicatorColor + to: checkbox.normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + + + + onEnabledChanged: { + image.source = iconSource(); + control.update(); + } + + property int prevCheckState: Qt.Unchecked + + Component.onCompleted: { + prevCheckState = control.checkState; + } + + onCheckStateChanged: { + // console.log("状态转换:", prevCheckState, "→", control.checkState) + if (prevCheckState === Qt.Unchecked && control.checkState === Qt.PartiallyChecked) { + + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.start(); + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.start(); + } + + scaleAnim.start(); + opacityAnim.start(); + } + else if (prevCheckState === Qt.PartiallyChecked && control.checkState === Qt.Checked) { + + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.stop(); + tansparentNormalCheckColor = checkbox.checked_normalIndicatorColor; + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.stop(); + normalColor = checkbox.checked_normalIndicatorColor; + } + scaleAnim.start(); + opacityAnim.start(); + } + else if (prevCheckState === Qt.Checked && control.checkState === Qt.Unchecked) { + if(isTransaprent){ + tansparentColorAnim.stop(); + tansparentColorReturnAnim.start(); + }else{ + normalColorAnim.stop(); + normalColorReturnAnim.start(); + } + uncheckScaleAnim.start(); + uncheckOpacityAnim.start(); + } + else if (prevCheckState === Qt.Unchecked && control.checkState === Qt.Checked) { + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.start(); + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.start(); + } + scaleAnim.start(); + opacityAnim.start(); + } + + prevCheckState = control.checkState; + control.update(); + } + + onCheckedChanged: { + if (!control.tristate) { + if (control.checked) { + if(isTransaprent) + tansparentColorAnim.start(); + else + normalColorAnim.start(); + scaleAnim.start(); + opacityAnim.start(); + } else { + if(isTransaprent) + tansparentColorReturnAnim.start(); + else + normalColorReturnAnim.start(); + uncheckScaleAnim.start(); + uncheckOpacityAnim.start(); + } + } + image.source = iconSource(); + } + + function iconSource(){ + // var model = (!control.enabled && control.checked) ? "highDisbale" : + // !control.enabled ? "disenable" : + // control.checked ? "highlight" : "normal" + var model = "highlight" + var icon = "object-select-symbolic"; + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model; + } } diff --git a/ukui-qqc2-style/org.ukui.style/CheckDelegate.qml b/ukui-qqc2-style/org.ukui.style/CheckDelegate.qml index 962e96f..0e5afaf 100644 --- a/ukui-qqc2-style/org.ukui.style/CheckDelegate.qml +++ b/ukui-qqc2-style/org.ukui.style/CheckDelegate.qml @@ -30,33 +30,62 @@ T.CheckDelegate { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - implicitContentWidth + spacing + leftPadding + rightPadding) + implicitContentWidth + implicitIndicatorWidth + spacing + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, implicitIndicatorHeight + topPadding + bottomPadding) - padding: checkbox.upDownMargin - spacing: checkbox.space - leftPadding: checkbox.leftRightMargin + padding: 6//checkbox.upDownMargin + leftPadding: 6//checkbox.leftRightMargin icon.width: app.iconWidth icon.height: app.iconWidth icon.color: control.palette.text hoverEnabled: true + font: app.font + spacing: checkbox.space + palette: app.palette + property var normalColor:checkbox.normalIndicatorColor + property var tansparentNormalColor: checkbox.normalTransparentIndicatorColor + property var tansparentNormalCheckColor: checkbox.checked_normalIndicatorColor + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + + // 新增:判断是否有动画正在运行(涵盖所有相关动画) + property bool isAnimating: scaleAnim.running || opacityAnim.running + || uncheckScaleAnim.running || uncheckOpacityAnim.running + || tansparentColorReturnAnim.running || tansparentColorAnim.running + || normalColorAnim.running || normalColorReturnAnim.running + + property var borderColor: control.checked || (control.tristate == true && control.checkState === Qt.PartiallyChecked)? + (!control.enabled ? checkbox.checked_disableIndicatorBorderColor : + control.pressed ? checkbox.checked_clickIndicatorBorderColor : + (!isAnimating && control.hovered) ? checkbox.checked_hoverIndicatorBorderColor : + checkbox.checked_normalIndicatorBorderColor) : + (!control.enabled ? checkbox.disableIndicatorBorderColor : + control.pressed ? checkbox.clickIndicatorBorderColor : + (!isAnimating && control.hovered) ? checkbox.hoverIndicatorBorderColor : + checkbox.normalIndicatorBorderColor) + + property var checkBoxColor: control.checked || (control.tristate == true && control.checkState === Qt.PartiallyChecked) ? + (!control.enabled ? checkbox.checked_disableIndicatorColor : + control.pressed ? checkbox.checked_clickIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.checked_hoverIndicatorColor : + tansparentNormalCheckColor) : + isTransaprent ? + (!control.enabled ? checkbox.disableTransparentIndicatorColor : + control.pressed ? checkbox.clickTransparentIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.hoverTransparentIndicatorColor : + tansparentNormalColor) : + (!control.enabled ? checkbox.disableIndicatorColor : + control.pressed ? checkbox.clickIndicatorColor : + (!isAnimating && control.hovered) ? checkbox.hoverIndicatorColor : + normalColor) - property var borderColor: control.checked ? (!control.enabled ? checkbox.checked_disableIndicatorBorderColor : - control.pressed ? checkbox.checked_clickIndicatorBorderColor : control.hovered ? - checkbox.checked_hoverIndicatorBorderColor : checkbox.checked_normalIndicatorBorderColor) : - (!control.enabled ? checkbox.disableIndicatorBorderColor : control.pressed ? - checkbox.clickIndicatorBorderColor : control.hovered ? - checkbox.hoverIndicatorBorderColor : checkbox.normalIndicatorBorderColor) - - property var checkBoxColor: control.checked ? (!control.enabled ? checkbox.checked_disableIndicatorColor : - control.pressed ? checkbox.checked_clickIndicatorColor : control.hovered ? - checkbox.checked_hoverIndicatorColor : checkbox.checked_normalIndicatorColor) : - (!control.enabled ? checkbox.disableIndicatorColor : control.pressed ? - checkbox.clickIndicatorColor : control.hovered ? - checkbox.hoverIndicatorColor : checkbox.normalIndicatorColor) ParseInterface{ id: parseInterface } @@ -74,6 +103,10 @@ T.CheckDelegate { onParametryChanged:{ control.update(); } + onIconThemeChanged: { + image.source = "" + image.source = iconSource() + } } StylePrivate.UKUICheckBox{ id: checkbox @@ -109,72 +142,272 @@ T.CheckDelegate { id: iconLabel controlRoot: control anchors.left: control.left - leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.right: control.right + anchors.leftMargin: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.rightMargin: !control.mirrored ? control.indicator.width + control.spacing : control.rightPadding + //leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding //x: 0// control.text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 //anchors.centerIn: control - implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) + indicator.implicitWidth + control.spacing + implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) } // keep in sync with CheckDelegate.qml (shared CheckIndicator.qml was removed for performance reasons) - indicator: Rectangle { + indicator: Item{ implicitWidth: checkbox.indicatorWidth implicitHeight: checkbox.indicatorWidth - - x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + x: control.text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : 0 y: control.topPadding + (control.availableHeight - height) / 2 - radius: checkbox.radius - - border.width: checkbox.borderWidth - border.color: getStartColor(control.visualFocus ? (control.checked ? borderColor : checkbox.checked_normalIndicatorColor) : borderColor) - color: gradientRec.visible ? "transparent" : getStartColor(checkBoxColor) - Rectangle{ - id: gradientRec + Rectangle { anchors.fill: parent - radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color - gradient: Gradient { - id:gradient - GradientStop { position: 0.0; color: getStartColor(checkBoxColor) } - - GradientStop { position: 1.0; color: getEndColor(checkBoxColor)} + radius: checkbox.radius + + color: gradientRec.visible ? "transparent" : getStartColor(checkBoxColor) + + Rectangle{ + id: gradientRec + anchors.fill: parent + radius: parent.radius + gradient: Gradient { + id:gradient + GradientStop { position: 0.0; color: getStartColor(checkBoxColor) } + + GradientStop { position: 1.0; color: getEndColor(checkBoxColor)} + } + visible: !parseInterface.isSolidPattern(checkBoxColor) } - visible: !parseInterface.isSolidPattern(checkBoxColor) - } - Image { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: 14 - height: 12 -// defaultColor: "#353637" -// color: control.palette.text - source: { - var model = !control.enabled ? "disenable" : control.checked ? "highlight" : "normal" - return "image://imageProvider/" + "object-select-symbolic" + "/" + model; + Rectangle{ + anchors.fill: parent + radius: checkbox.radius + + border.width: checkbox.borderWidth + border.color: getStartColor(borderColor) + color: "transparent" } - visible: control.checkState === Qt.Checked + } + Image { + id: image + anchors.centerIn: parent + sourceSize.width: 16 + sourceSize.height: 16 + source: iconSource() + visible: control.checkState === Qt.Checked || (control.checkState === Qt.Unchecked && uncheckScaleAnim.running) + cache: false + scale: 0.2 + opacity: 0.0 + transformOrigin: Item.Center + } + + NumberAnimation { + id: scaleAnim + target: image + property: "scale" + from: 0.2 + to: 1.0 + duration: 240 + easing.type: Easing.InOutCirc + onRunningChanged: if (!running) control.update() + } + + PropertyAnimation { + id: opacityAnim + target: image + property: "opacity" + from: 0.0 + to: 1.0 + duration: 100 + easing.type: Easing.InOutQuart + onRunningChanged: if (!running) control.update() + } + + NumberAnimation { + id: uncheckScaleAnim + target: image + property: "scale" + from: 1.0 + to: 0.2 + duration: 240 + easing.type: Easing.InOutCirc + onRunningChanged: if (!running) control.update() + } + + PropertyAnimation { + id: uncheckOpacityAnim + target: image + property: "opacity" + from: 1.0 + to: 0.0 + duration: 100 + easing.type: Easing.InOutQuint + onRunningChanged: if (!running) control.update() } Rectangle { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 + anchors.centerIn: parent width: 9 height: 1 color: { getStartColor(!control.enabled ? checkbox.checked_disableChildrenColor : - control.pressed ? checkbox.checked_clickChildrenColor: - control.hovered ? checkbox.checked_hoverChildrenColor: - checkbox.checked_normalChildrenColor) + control.pressed ? checkbox.checked_clickChildrenColor: + // 部分选中状态处理hover与动画的关系 + (!isAnimating && control.hovered) ? checkbox.checked_hoverChildrenColor: + checkbox.checked_normalChildrenColor) } visible: control.checkState === Qt.PartiallyChecked } } - background: Rectangle { - implicitWidth: parent.implicitWidth - implicitHeight: 36 - visible: control.down || control.highlighted - color: control.down ? control.palette.midlight : control.palette.light + background: Item { + anchors.fill: parent + // visible: control.down || control.highlighted + // color: control.down ? control.palette.midlight : control.palette.light + } + ColorAnimation { + id: tansparentColorAnim + target: control + property: "tansparentNormalCheckColor" + from:checkbox.normalTransparentIndicatorColor + to: checkbox.checked_normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + + ColorAnimation { + id: tansparentColorReturnAnim + target: control + property: "tansparentNormalColor" + from: checkbox.checked_normalIndicatorColor + to: checkbox.normalTransparentIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + + ColorAnimation { + id: normalColorAnim + target: control + property: "normalColor" + from:checkbox.normalIndicatorColor + to: checkbox.checked_normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() } + + ColorAnimation { + id: normalColorReturnAnim + target: control + property: "normalColor" + from: checkbox.checked_normalIndicatorColor + to: checkbox.normalIndicatorColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: if (!running) control.update() + } + + onEnabledChanged: { + image.source = iconSource(); + control.update(); + } + + property int prevCheckState: Qt.Unchecked + + Component.onCompleted: { + prevCheckState = control.checkState; + } + + onCheckStateChanged: { + // console.log("状态转换:", prevCheckState, "→", control.checkState) + if (prevCheckState === Qt.Unchecked && control.checkState === Qt.PartiallyChecked) { + + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.start(); + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.start(); + } + + scaleAnim.start(); + opacityAnim.start(); + } + else if (prevCheckState === Qt.PartiallyChecked && control.checkState === Qt.Checked) { + + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.stop(); + tansparentNormalCheckColor = checkbox.checked_normalIndicatorColor; + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.stop(); + normalColor = checkbox.checked_normalIndicatorColor; + } + scaleAnim.start(); + opacityAnim.start(); + } + else if (prevCheckState === Qt.Checked && control.checkState === Qt.Unchecked) { + if(isTransaprent){ + tansparentColorAnim.stop(); + tansparentColorReturnAnim.start(); + }else{ + normalColorAnim.stop(); + normalColorReturnAnim.start(); + } + uncheckScaleAnim.start(); + uncheckOpacityAnim.start(); + } + else if (prevCheckState === Qt.Unchecked && control.checkState === Qt.Checked) { + if(isTransaprent){ + tansparentColorReturnAnim.stop(); + tansparentColorAnim.start(); + }else{ + normalColorReturnAnim.stop(); + normalColorAnim.start(); + } + scaleAnim.start(); + opacityAnim.start(); + } + + prevCheckState = control.checkState; + control.update(); + } + + onCheckedChanged: { + if (!control.tristate) { + if (control.checked) { + if(isTransaprent) + tansparentColorAnim.start(); + else + normalColorAnim.start(); + scaleAnim.start(); + opacityAnim.start(); + } else { + if(isTransaprent) + tansparentColorReturnAnim.start(); + else + normalColorReturnAnim.start(); + uncheckScaleAnim.start(); + uncheckOpacityAnim.start(); + } + } + image.source = iconSource(); + } + + function iconSource(){ + // var model = (!control.enabled && control.checked) ? "highDisbale" : + // !control.enabled ? "disenable" : + // control.checked ? "highlight" : "normal" + var model = "highlight" + var icon = "object-select-symbolic"; + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model; + } + + } diff --git a/ukui-qqc2-style/org.ukui.style/ComboBox.qml b/ukui-qqc2-style/org.ukui.style/ComboBox.qml index 0ea1855..70f7343 100644 --- a/ukui-qqc2-style/org.ukui.style/ComboBox.qml +++ b/ukui-qqc2-style/org.ukui.style/ComboBox.qml @@ -41,6 +41,10 @@ T.ComboBox { rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) hoverEnabled: true + palette: app.palette + font: app.font + property bool firstShow: false; + ParseInterface{ id: parseInterface } @@ -53,11 +57,29 @@ T.ComboBox { { return parseInterface.pEndColor(dtcolor) } - + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } property var scrollbarWidth : 0 + + property var backColor: !isTransaprent ? (!control.enabled ? combobox.disableBC : ((control.pressed || pop.visible) ? combobox.clickedBC : + (control.hovered ? combobox.hoveredBC : combobox.normalBC))) : + (!control.enabled ? combobox.disableTransparentBC : + ((control.pressed || pop.visible)? combobox.clickedTransparentBC : (control.hovered ? combobox.hoveredTransparentBC : combobox.normalTransparentBC))) + property var borderColor: !isTransaprent ? (!control.enabled ? combobox.disableBorderColor : + ((app.focusEnable && control.focus) ? combobox.focusBorderColor : + (control.pressed ? combobox.clickBorderColor : + (control.hovered ? combobox.hoveredBorderColor : combobox.normalBorderColor)))) : + (!control.enabled ? combobox.disableTransparentBorderColor : ((app.focusEnable && control.focus) ? combobox.focusBorderColor : + (control.pressed ? combobox.clickedTransparentBorderColor : (control.hovered ? combobox.hoveredTransparentBorderColor : combobox.normalTransparentBorderColor)))) + + delegate: MenuItem { id: menuitem - implicitWidth: control.width - 2 * control.leftPadding - scrollbarWidth + width: control.width - 2 * control.leftPadding - scrollbarWidth text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData icon.name: (control.iconNameRole && model[control.iconNameRole] !== undefined) ? model[control.iconNameRole] : null highlighted: control.highlightedIndex === index @@ -65,14 +87,22 @@ T.ComboBox { autoExclusive: true checked: control.currentIndex === index Component.onCompleted: { -// console.log("delegate menuitem......", control.width, control.leftPadding, control.rightPadding, scrollbarWidth) + + // console.log("delegate menuitem......", control.width, control.leftPadding, control.rightPadding, scrollbarWidth) if(menuitem.hasOwnProperty("itemHasChecked")){ itemHasChecked = true } + if(control.currentIndex === index){ + + if(menuitem.hasOwnProperty("isKeyBorderSelect")) + menuitem.isKeyBorderSelect = true + } } + } contentItem: T.TextField { + id: textfield leftPadding: 0//!control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1 rightPadding:0// control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1 anchors.verticalCenter: control.verticalCenter @@ -86,11 +116,15 @@ T.ComboBox { validator: control.validator selectByMouse: control.selectTextByMouse - font: app.font + font: control.font color: getStartColor(!control.enabled ? combobox.disableTextColor : combobox.normalTextColor) selectionColor: control.palette.highlight selectedTextColor: control.palette.highlightedText verticalAlignment: Text.AlignVCenter + anchors.left: control.mirrored ? indicatorImage.right : control.left + anchors.leftMargin: StylePrivate.UKUITextFiled.leftRightPadding + anchors.right: control.mirrored ? control.right : indicatorImage.left + anchors.rightMargin: StylePrivate.UKUITextFiled.leftRightPadding } indicator: Image { @@ -98,143 +132,169 @@ T.ComboBox { x: control.mirrored ? control.padding : control.width - width - control.padding y: control.topPadding + (control.availableHeight - height) / 2 z: 10 - width: app.iconWidth - height: width - source: { - var icon = "ukui-down-symbolic"; - if(!pop.visible){ - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-down-symbolic.svg" - } - else{ - icon = "ukui-up-symbolic" - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-up-symbolic.svg" - } - - var model = !control.enabled ? "disenable" : "normal" - - return "image://imageProvider/" + icon + "/" + model; - - } + sourceSize.width: app.iconWidth + sourceSize.height: app.iconWidth + source: iconSource() + cache: false MouseArea{ - anchors.fill: parent - onClicked: - { -// popHandle.setPosion(parent.mapToGlobal(control.x, control.y + control.height).x, parent.mapToGlobal(control.x, control.y + control.height).y) - -// if(popHandle && !popHandle.isVisible()){ -// popHandle.open() -// } -// else if(popHandle && popHandle.isVisible()) -// popHandle.close() - pop.visible = !pop.visible; - } + anchors.fill: parent + onClicked: + { + pop.visible = !pop.visible; + control.focus = true + } } } background: Rectangle { + id: bRec implicitWidth: combobox.normalWidth implicitHeight: combobox.normalHeight radius: combobox.radius - color: gradientRec.visible ? "transparent" : getStartColor(combobox.normalBC) - border.color: getStartColor(!control.enabled ? combobox.disableBorderColor : - control.focus ? combobox.focusBorderColor : combobox.normalBorderColor) - border.width: control.focus ? combobox.focusBorderWidth : combobox.borderWidth; + color: gradientRec.visible ? "transparent" : getStartColor(backColor) Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { id:gradient - GradientStop { position: 0.0; color: getStartColor(combobox.normalBC) } + GradientStop { position: 0.0; color: getStartColor(backColor) } - GradientStop { position: 1.0; color: getEndColor(combobox.normalBC)} + GradientStop { position: 1.0; color: getEndColor(backColor)} } - visible: !parseInterface.isSolidPattern(combobox.normalBC) + visible: !parseInterface.isSolidPattern(backColor) + } + Rectangle{ + anchors.fill: parent + radius: parent.radius + color: "transparent" + border.color: getStartColor(borderColor) + border.width: (app.focusEnable && control.focus) ? combobox.focusBorderWidth : combobox.borderWidth; } } - popup: Popup { + popup: T.Popup { id: pop y: control.height width: control.width -// height: Math.min(contentItem.implicitHeight + topMargin + bottomMargin, control.Window.height - topMargin - bottomMargin) topMargin: 6 bottomMargin: 6 - background: Item{} + closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnReleaseOutsideParent onVisibleChanged: { - if(popHandle && parent) + if(visible && parent) { - popHandle.setPosion(mapToGlobal(x, y).x, mapToGlobal(x, y).y) + var p = mapToGlobal(x, y) + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.hide() + popupwindow.x = p.x + popupwindow.y = p.y + } + popupwindow.show(); + listview.model = control.delegateModel + } + else if(!visible ){ + if(popupwindow.visible) + popupwindow.hide() + listview.model = "" } - if(visible && popHandle && !popHandle.visible){ - popHandle.open() + + indicatorImage.source = "" + indicatorImage.source = iconSource() + if(popupwindow.visible != visible){ + popupwindow.visible = visible } - else if(!visible && popHandle && popHandle.visible) - popHandle.close() } onYChanged: { - if(popHandle && parent) + if(visible && parent) { - popHandle.setPosion(mapToGlobal(x, y).x, mapToGlobal(x, y).y) + var p = mapToGlobal(x, y) + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.x = p.x + popupwindow.y = p.y + } } } onXChanged: { - if(popHandle && parent) + if(visible && parent) { - popHandle.setPosion(mapToGlobal(x, y).x, mapToGlobal(x, y).y) + var p = mapToGlobal(x, y) + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.x = p.x + popupwindow.y = p.y + } } } - StylePrivate.PopupHandle{ - id: popHandle - onVisibleChanged: { - // popupwindow.visible = visible - if(pop.visible !== visible){ - pop.visible = visible - } - } - backColor: ukuiPopup.backColor - shadowColor: ukuiPopup.shadowColor + background: Item{ - delegate: Window { + Window { id: popupwindow - // width: windowLabel ? windowLabel.width : 0 - // height: windowLabel ? windowLabel.height : 0 - // blurControl: control - flags: Qt.ToolTip - + flags: Qt.Window | Qt.Popup + visible: pop.visible + color: "transparent" + width: listview.implicitWidth +scrollbarWidth + 2 * combobox.upDownMargin + height: listview.contentHeight + 2 * combobox.upDownMargin + + onHeightChanged: { + outScreen(); + + var size = popHandle.getScreenSize(); + var p = popHandle.getScreenPoint(); + + if(popupwindow.y + height >= size.height + p.y){ + var h = size.height + p.y - popupwindow.y + if(h > 0){ + height = h + listview.implicitHeight = h + } + } - Component.onCompleted: { - scrollbar.visible = popHandle.outScreen } - + onVisibleChanged: { + if(visible){ + firstShow = true + } + else + firstShow = false + if(pop.visible != visible){ + pop.visible = visible + } + } + StylePrivate.PopupHandle{ + id: popHandle + blur: true + titlebarVisible: false + anchors.fill: parent + visible: parent.visible + radius: ukuiPopup.radius + } Rectangle{ id: popRec width: parent.width height: parent.height visible: true - radius: ukuiPopup.radius - color: getStartColor(ukuiPopup.backColor) + // radius: ukuiPopup.radius + color: { + var baccolor = getStartColor(ukuiPopup.backColor) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, isTransaprent ? app.menuTransparency : 1.0) + } //border.color: StylePrivate.ParseColorInterface.startColor(ukuiPopup.backBorderColor) - opacity: app.menuTransparency - layer.enabled: true + //opacity: app.menuTransparency + // layer.enabled: true ScrollBar { id: scrollbar active: visible orientation: Qt.Vertical - visible: popHandle.outScreen + visible: false + // visible: popHandle.outScreen anchors.top: parent.top anchors.topMargin: pop.topPadding anchors.right: parent.right @@ -243,109 +303,79 @@ T.ComboBox { size: listview.visibleArea.heightRatio onPositionChanged: { - if (active && listview.visibleArea.yPosition != position) { + if (listview.visibleArea.yPosition != position || vscrollbar.position !== position) { vscrollbar.position = position; } } onVisibleChanged:{ if(visible) - scrollbarWidth = scrollbar.width - } - } - layer.effect: DropShadow { - transparentBorder: true - radius: ukuiPopup.radius - samples: 16 - horizontalOffset: 0 - verticalOffset: 0 - width: popRec.width + 8 - height: popRec.height + 8 - color: StylePrivate.ParseColorInterface.startColor(ukuiPopup.shadowColor) - } - } - + scrollbarWidth = scrollbar.width + else + scrollbarWidth = 0 +// listview.implicitWidth = listview.contentHeight + scrollbarWidth - Connections { - target: popHandle - function onVisibleChanged(visible) { - if(visible){ - listview.visible = true - popupwindow.show() - } - else{ - listview.visible = false - popupwindow.hide() } } - function onSizeChanged(width, height){ - // pop.implicitWidth = width - if(listview.implicitHeight !== height) - listview.implicitHeight = height - if(popRec.width !== width) - popRec.width = width - if(popRec.height !== height) - popRec.height = height - } - + // layer.effect: DropShadow { + // transparentBorder: true + // radius: ukuiPopup.radius + // samples: 16 + // horizontalOffset: 0 + // verticalOffset: 0 + // width: popRec.width + 8 + // height: popRec.height + 8 + // color: StylePrivate.ParseColorInterface.startColor(ukuiPopup.shadowColor) + // } } + ListView { id: listview - clip: popHandle.outScreen + // clip: popHandle.outScreen implicitHeight: contentHeight implicitWidth: control.width - 2 * control.leftPadding - scrollbarWidth - model: control.delegateModel +// model: control.delegateModel currentIndex: control.highlightedIndex highlightMoveDuration: 0 - interactive: popHandle.outScreen + highlightRangeMode: ListView.NoHighlightRange + snapMode: ListView.NoSnap + // interactive: popHandle.outScreen anchors.top: popRec.top anchors.topMargin: combobox.upDownMargin anchors.left: popRec.left anchors.leftMargin: combobox.upDownMargin + visible: parent.visible + clip: outScreen() onVisibleChanged: { if(visible){ listview.implicitHeight = listview.contentHeight - popHandle.setSize(control.width, listview.contentHeight + 2 * combobox.upDownMargin) } } - - onWidthChanged: { - // pop.height = listview.implicitHeight + 2 * combobox.upDownMargin - - popHandle.setSize(control.width, listview.contentHeight + 2 * combobox.upDownMargin) - } - onHeightChanged: { - // pop.height = listview.implicitHeight + 2 * combobox.upDownMargin - - popHandle.setSize(control.width, listview.contentHeight + 2 * combobox.upDownMargin) + onModelChanged: { + listview.implicitHeight = listview.contentHeight + popupwindow.height = listview.contentHeight + 2 * combobox.upDownMargin } - Component.onCompleted: { - // pop.height = listview.implicitHeight + 2 * combobox.upDownMargin - popHandle.setSize(control.width, listview.contentHeight + 2 * combobox.upDownMargin) - } onContentHeightChanged: { listview.implicitHeight = listview.contentHeight - popHandle.setSize(control.width, listview.contentHeight + 2 * combobox.upDownMargin) + popupwindow.height = listview.contentHeight + 2 * combobox.upDownMargin } ScrollBar.vertical: ScrollBar { id: vscrollbar active: visible - visible: popHandle ? popHandle.outScreen : false + visible: false width: 0 } - - Connections{ - target: popHandle - function onOutScreenChanged() - { - listview.interactive = popHandle.outScreen ? true : false; - listview.clip = listview.interactive; - scrollbar.visible = popHandle.outScreen; - } + onCurrentIndexChanged: { + indexSelect(); } + + } + Shortcut{ + sequence: "Escape" + onActivated: pop.visible = false } } } @@ -361,6 +391,92 @@ T.ComboBox { StylePrivate.APPParameter{ id: app + onParametryChanged:{ + indicatorImage.source = "" + indicatorImage.source = iconSource() + control.update(); + } + onIconThemeChanged: { + indicatorImage.source = "" + indicatorImage.source = iconSource() + } + } + onEnabledChanged: { + indicatorImage.source = "" + indicatorImage.source = iconSource() + } + function outScreen(){ + var size = popHandle.getScreenSize(); + var p = popHandle.getScreenPoint(); + if(popupwindow.y + popupwindow.height >= size.height + p.y){ + var h = size.height + p.y - popupwindow.y + if(h > 0){ + listview.clip = true + scrollbar.visible = true + vscrollbar.visible = true + return true + } + } + listview.clip = false + scrollbar.visible = false + vscrollbar.visible = false + + return false + + } + + function iconSource(){ + var icon = "ukui-down-symbolic"; + if(!pop.visible){ + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-down-symbolic.svg" + } + else{ + icon = "ukui-up-symbolic" + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-up-symbolic.svg" + } + + var model = "normal" + if(!control.enabled){ + if(app.isDark) + model = "highDisbale" + else + model = "disenable" + } + else if(app.isDark){ + model = "highlight" + } + + return "image://imageProvider/" + icon + "/" + model; + + } + + function indexSelect(){ + var children = listview.contentItem.children + for (var i = 0; i < control.count; i++) { + if(i === listview.currentIndex){ + var item = listview.itemAtIndex(i); + + if(item === null || item === undefined){ + item = children[i] + } + if(item !== null && item !== undefined && item.hasOwnProperty("isKeyBorderSelect") && !item.isKeyBorderSelect) + item.isKeyBorderSelect = true + } + else if(listview.itemAtIndex(i) !== undefined && listview.itemAtIndex(i) !== null){ + if(listview.itemAtIndex(i).hasOwnProperty("isKeyBorderSelect") && listview.itemAtIndex(i).isKeyBorderSelect) + listview.itemAtIndex(i).isKeyBorderSelect = false + } + } + if(firstShow && listview.currentIndex >= 0){ + var item = listview.currentItem + if(item.checkable && item.checked){ + listview.positionViewAtIndex(listview.currentIndex, ListView.Beginning) + firstShow = false + } + } + } } diff --git a/ukui-qqc2-style/org.ukui.style/HorizontalHeaderView.qml b/ukui-qqc2-style/org.ukui.style/HorizontalHeaderView.qml new file mode 100644 index 0000000..0fb46c3 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/HorizontalHeaderView.qml @@ -0,0 +1,80 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Templates 2.15 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate + +T.HorizontalHeaderView { + id: control + + implicitWidth: syncView ? syncView.width : 0 + implicitHeight: Math.max(contentHeight, headerview.normalHeight) + + delegate: Item { + // Qt6: add cellPadding (and font etc) as public API in headerview + readonly property real cellPadding: 8 + + implicitWidth: text.implicitWidth + (cellPadding * 2) + implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2)) + + Text { + id: text + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData + width: parent.width + height: parent.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: getStartColor(headerview.normalTextColor) + } + Rectangle{ + anchors.right: parent.right + width: headerview.lineWidth + anchors.verticalCenter: parent.verticalCenter + height: 14 + color: headerview.lineColor + visible: index !== control.model.count - 1 + } + } + StylePrivate.APPParameter{ + id: appP + } + + StylePrivate.UKUIHeaderView{ + id: headerview + } + ParseInterface{ + id: parseInterface + } + + function getStartColor(dtcolor) + { + return parseInterface.pStartColor(dtcolor) + } + function getEndColor(dtcolor) + { + return parseInterface.pEndColor(dtcolor) + } +} diff --git a/ukui-qqc2-style/org.ukui.style/ItemDelegate.qml b/ukui-qqc2-style/org.ukui.style/ItemDelegate.qml index 4277ddc..fa71d10 100644 --- a/ukui-qqc2-style/org.ukui.style/ItemDelegate.qml +++ b/ukui-qqc2-style/org.ukui.style/ItemDelegate.qml @@ -43,23 +43,44 @@ T.ItemDelegate { icon.height: app.iconWidth hoverEnabled: true font: app.font + palette: app.palette // icon.color: control.palette.text - - property var borderHColor: !control.enabled ? itemdelegate.disableBorderColor : control.pressed ? itemdelegate.clickBorderHColor : - control.hovered ? itemdelegate.hoverBorderHColor : itemdelegate.normalBorderHColor - property var backHColor: !control.enabled ? itemdelegate.disableBC : control.pressed ? itemdelegate.clickedHBC : - control.hovered ? itemdelegate.hoveredHBC : itemdelegate.normalHBC - - property var borderColor: !control.enabled ? itemdelegate.disableBorderColor : control.pressed ? itemdelegate.clickBorderColor : - control.hovered ? itemdelegate.hoverBorderColor : itemdelegate.normalBorderColor - property var backColor: !control.enabled ? itemdelegate.disableBC : control.pressed ? itemdelegate.clickedBC : - control.hovered ? itemdelegate.hoveredBC : itemdelegate.normalBC - - property var borderCheckedColor: !control.enabled ? itemdelegate.disableBorderColor : control.pressed ? itemdelegate.clickBorderCheckedColor : - control.hovered ? itemdelegate.hoverBorderCheckedColor : itemdelegate.normalBorderCheckedColor - property var backCheckedColor: !control.enabled ? itemdelegate.disableBC : control.pressed ? itemdelegate.clickedCheckedBC : - control.hovered ? itemdelegate.hoveredCheckedBC : itemdelegate.normalCheckedBC + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var isAlternate:{ + if(control.hasOwnProperty("alternate")){ + if(control.alternate && index%2 === 1) + return true + } + else + return false + } + property var borderHColor: !control.enabled ? itemdelegate.disableBorderHColor : /*control.pressed ? itemdelegate.clickBorderHColor : + control.hovered ? itemdelegate.hoverBorderHColor : */itemdelegate.normalBorderHColor + property var backHColor: !control.enabled ? itemdelegate.disableHBC : /*control.pressed ? itemdelegate.clickedHBC : + control.hovered ? itemdelegate.hoveredHBC :*/ itemdelegate.normalHBC + + property var borderColor: !control.enabled ? (isTransaprent ? itemdelegate.disableTransparentBorderColor : itemdelegate.disableBorderColor) : + (control.pressed) ? (isTransaprent ? itemdelegate.clickedTransparentBorderColor : itemdelegate.clickBorderColor) : + control.hovered ? (isTransaprent ? itemdelegate.hoveredTransparentBorderColor : itemdelegate.hoverBorderColor) : + (isTransaprent ? itemdelegate.normalTransparentBorderColor : itemdelegate.normalBorderColor) + property var backColor: !control.enabled ? (isTransaprent ? (isAlternate ? itemdelegate.disableAlternateTransparentBC : itemdelegate.disableTransparentBC ): (isAlternate ? itemdelegate.disableAlternateBC : itemdelegate.disableBC)) : + (control.pressed) ? (isTransaprent ? (isAlternate ? itemdelegate.clickedAlternateTransparentBC : itemdelegate.clickedTransparentBC ): (isAlternate ? itemdelegate.clickedAlternatedBC : itemdelegate.clickedBC)) : + control.hovered ? (isTransaprent ? (isAlternate ? itemdelegate.hoveredAlternateTransparentBC : itemdelegate.hoveredTransparentBC ): (isAlternate ? itemdelegate.hoveredAlternatedBC : itemdelegate.hoveredBC)) : + (isTransaprent ? (isAlternate ? itemdelegate.normalAlternateTransparentBC : itemdelegate.normalTransparentBC ): (isAlternate ? itemdelegate.normalAlternateBC : itemdelegate.normalBC)) + property var borderCheckedColor: !control.enabled ? (isTransaprent ? itemdelegate.disableCheckedTransparentBorderColor : itemdelegate.disableBorderCheckedColor) : + //control.pressed ? (isTransaprent ? itemdelegate.clickedCheckedTransparentBorderColor : itemdelegate.clickBorderCheckedColor) : + //control.hovered ? (isTransaprent ? itemdelegate.hoveredCheckedTransparentBorderColor : itemdelegate.hoverBorderCheckedColor) : + (isTransaprent ? itemdelegate.normalCheckedTransparentBorderColor : itemdelegate.normalBorderCheckedColor) + property var backCheckedColor: !control.enabled ? (isTransaprent ? itemdelegate.disableCheckedTransparentBC : itemdelegate.disableCheckedBC) : + //control.pressed ? (isTransaprent ? itemdelegate.clickedCheckedTransparentBC : itemdelegate.clickedCheckedBC) : + //control.hovered ? (isTransaprent ? itemdelegate.hoveredCheckedTransparentBC : itemdelegate.hoveredCheckedBC) : + (isTransaprent ? itemdelegate.normalCheckedTransparentBC : itemdelegate.normalCheckedBC) ParseInterface{ id: parseInterface @@ -89,9 +110,11 @@ T.ItemDelegate { contentItem: IconLabelContent { id: iconLabel controlRoot: control - anchors.left: control.left + anchors.fill: control anchors.verticalCenter: control.verticalCenter - leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + + leftSpace: control.mirrored ? control.spacing : control.leftPadding + textColor: !control.enabled ? ((control.highlighted && control.checked) ? itemdelegate.disableHTextColor : itemdelegate.disableTextColor) : (control.highlighted && control.checked) ? itemdelegate.normalHTextColor : itemdelegate.normalTextColor //x: 0// control.text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 //anchors.centerIn: control implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) + indicator.implicitWidth + control.spacing diff --git a/ukui-qqc2-style/org.ukui.style/Label.qml b/ukui-qqc2-style/org.ukui.style/Label.qml index 74e8804..f4c34d4 100644 --- a/ukui-qqc2-style/org.ukui.style/Label.qml +++ b/ukui-qqc2-style/org.ukui.style/Label.qml @@ -30,15 +30,42 @@ import org.ukui.qqc2style.private 1.0 as StylePrivate T.Label { id:control + + property var dtColor:{ + if(control.hasOwnProperty("labelDTColor")) + return control.labelDTColor + else + return "" + } + + property var _windowLabel: { + if(control.hasOwnProperty("windowLabel")) + return control.windowLabel + else + return false + } + ParseInterface{ id: parseInterface } + onDtColorChanged: { + if(dtColor !== "") + control.color = parseInterface.getDTColor(dtColor) + } - color: parseInterface.pStartColor(enabled ? label.normalColor : label.disableColor)//StylePrivate.UKUILable.normalColor + color: { + if(dtColor !== ""){ + return parseInterface.getDTColor(dtColor) + } + else + return parseInterface.pStartColor(enabled ? (_windowLabel && !Qt.application.active) ? parseInterface.getDTColor("kfont-secondary-disable") : + label.normalColor : label.disableColor) + }//StylePrivate.UKUILable.normalColor linkColor: parseInterface.pStartColor(label.linkColor) font: app.font//appP.font + palette: app.palette StylePrivate.UKUILabel{ id: label @@ -49,5 +76,9 @@ T.Label { StylePrivate.APPParameter{ id: app + onParametryChanged: { + if(control.hasOwnProperty("labelDTColor")) + control.color = parseInterface.getDTColor(dtColor) + } } } diff --git a/ukui-qqc2-style/org.ukui.style/Menu.qml b/ukui-qqc2-style/org.ukui.style/Menu.qml index e700f61..80eb554 100644 --- a/ukui-qqc2-style/org.ukui.style/Menu.qml +++ b/ukui-qqc2-style/org.ukui.style/Menu.qml @@ -31,76 +31,87 @@ import org.ukui.qqc2style.private 1.0 as StylePrivate T.Menu { id: control -// StylePrivate.APPParameter{ -// id: appP -// } -// palette: app.palette -// font: app.font - implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding margins: 0 + palette: app.palette + + + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var _opacity:{ + if(control.hasOwnProperty("backOpacity")) + return control.backOpacity + return app.menuTransparency + } property var scrollbarWidth: 0 -// leftPadding: menu.leftRightPadding -// rightPadding: menu.leftRightPadding -// topPadding: menu.topBottomPadding -// bottomPadding: menu.topBottomPadding + // leftPadding: menu.leftRightPadding + // rightPadding: menu.leftRightPadding + // topPadding: menu.topBottomPadding + // bottomPadding: menu.topBottomPadding property var maxW: 0 onVisibleChanged: { -// console.log("DTK onvisible changed...", control.contentModel.count, visible, width, height, x, y, parent, parent.x, parent.y) - if(visible && popHandle && parent) + if(visible) { -// console.log("maptoglobale...", parent.mapToGlobal(x, y)) - popHandle.setPosion(parent.mapToGlobal(x, y).x, parent.mapToGlobal(x, y).y) + if(parent){ + if( popupwindow.x !== parent.mapToGlobal(x, y).x - (control.mirrored ? popupwindow.width : 0)) + popupwindow.x = parent.mapToGlobal(x, y).x - (control.mirrored ? popupwindow.width : 0) + if( popupwindow.y !== parent.mapToGlobal(x, y).y) + popupwindow.y = parent.mapToGlobal(x, y).y + } } - if(visible && popHandle && !popHandle.visible){ - popHandle.open() + + if( popupwindow.visible !== control.visible) + popupwindow.visible = control.visible + if(visible && control.width > 0 && control.width !== popupwindow.width) + popupwindow.width = control.width + if(visible && control.height > 0 && control.height !== popupwindow.height){ + popupwindow.height = control.height } - else if(!visible && popHandle && popHandle.visible) - popHandle.close() } onYChanged: { -// console.log("menu y changedddd", y, control.contentModel.count) - if(popHandle && parent) + if(visible && parent) { -// console.log("maptoglobale...", parent.mapToGlobal(x, y)) - popHandle.setPosion(parent.mapToGlobal(x, y).x, parent.mapToGlobal(x, y).y) + // console.log("maptoglobale...", parent.mapToGlobal(x, y)) + popupwindow.y = parent.mapToGlobal(x, y).y } } onXChanged: { - if(popHandle && parent) + if(visible && parent) { -// console.log("maptoglobale...", parent.mapToGlobal(x, y)) - popHandle.setPosion(parent.mapToGlobal(x, y).x, parent.mapToGlobal(x, y).y) + // console.log("maptoglobale...", parent.mapToGlobal(x, y)) + popupwindow.x = parent.mapToGlobal(x, y).x - (control.mirrored ? popupwindow.width : 0) } } -// onCountChanged: -// { -// if(control1){ -// for(var i = 0; i < control1.contentModel.count; i++) -// { -// control1.removeItem(control1.itemAt(i)); -// } -// for(var j = 0; j < control.contentModel.count; j++) -// { -// control1.addItem(control.itemAt(j)); -// } -// } -// } - - StylePrivate.UKUIMenu{ - id: menu + onWidthChanged: { + if(visible && control.width > 0 && control.width !== popupwindow.width) + popupwindow.width = control.width + } + onHeightChanged: { + if(visible && control.height > 0 && control.height !== popupwindow.height){ + popupwindow.height = control.height + } } + Connections{ + target: popupwindow + function onWidthChanged(){ + if(parent && visible){ + if( popupwindow.x !== parent.mapToGlobal(x, y).x - (control.mirrored ? popupwindow.width : 0)) + popupwindow.x = parent.mapToGlobal(x, y).x - (control.mirrored ? popupwindow.width : 0) + } - ParseInterface{ - id: parseInterface + } } function getStartColor(dtcolor) @@ -111,58 +122,83 @@ T.Menu { { return parseInterface.pEndColor(dtcolor) } - StylePrivate.APPParameter{ - id: app - } - StylePrivate.PopupHandle{ - id: popHandle - onVisibleChanged: { -// console.log("popupHandle visible changedddd", visible, control.visible) -// popupwindow.visible = visible - if(control.visible !== visible){ - control.visible = visible - } + background: Item{ + StylePrivate.UKUIMenu{ + id: menu + } + + + ParseInterface{ + id: parseInterface } - delegate: Window { + + StylePrivate.APPParameter{ + id: app + } + + Window { id: popupwindow - width: control1 ? control1.width : 0 - height: control1 ? control1.height : 0 - // blurControl: control - flags: Qt.ToolTip - - Connections { - target: popHandle - function onVisibleChanged(visible) { -// console.log("connections pophandle visible changeddddd", visible) - if(visible) - popupwindow.show() - else - popupwindow.hide() + width: control1.implicitWidth + height: control1.implicitHeight + // blurControl: control + visible: control.visible + color: "transparent" + onWidthChanged: { + var size = popHandle.getScreenSize(); + var p = popHandle.getScreenPoint(); + if(popupwindow.x + width >= size.width + p.x){ + var _x = size.width + p.x - popupwindow.width + if(_x > 0){ + popupwindow.x = _x + } } - function onSizeChanged(width, height){ - if(control1.contentItem.implicitWidth !== width) - control1.contentItem.implicitWidth = width - if(control1.contentItem.implicitHeight !== height) - control1.contentItem.implicitHeight = height + if(control.width > 0 && control.width !== popupwindow.width){ + width = control.width + control1.implicitWidth = control.width } - } + onHeightChanged: { + outScreen(); + + var size = popHandle.getScreenSize(); + var p = popHandle.getScreenPoint(); + if(popupwindow.y + height >= size.height + p.y){ + var h = size.height + p.y - popupwindow.y + if(h > 0 && height != h && control.height <= 0){ + height = h + } + } + if(control.height > 0 && control.height !== popupwindow.height){ + height = control.height + control1.implicitHeight = control.height + } - // rootWindow: control - // visible: control.visible - //Component.onCompleted: console.log("popupwindow visible...", visible) + } + StylePrivate.PopupHandle{ + id: popHandle + blur: true + titlebarVisible: false + anchors.fill: parent + visible: parent.visible + radius: menu.radius + } onVisibleChanged: { -// console.log("popupwindow onvisiblechanged 0000", visible, control1.visible, popHandle.isVisible(), control.contentModel, control1.contentModel) - if(visible !== control1.visible) - control1.visible = visible - // if(visible && !control1.visible) -// control1.open() -// else if(!visible && control1.visible) -// control1.close() -// console.log("popupwindow onvisiblechanged 1111", visible, control1.visible, popHandle.isVisible(), control.contentModel, control1.contentModel) + if(visible){ + if(control.width > 0 && control.width !== popupwindow.width) + width = control.width + if(control.height > 0 && control.height !== popupwindow.height) + height = control.height + + if(width <= 0) + width = 1 + if(height <= 0) + height = 1 + } + control1.visible = visible + control.visible = visible } Component.onCompleted: { for(var i = 0; i < control.contentModel.count; i++) @@ -171,6 +207,15 @@ T.Menu { } } + + Connections{ + target: Qt.application + function onStateChanged(){ + if(!Qt.application.active) + control.visible = false + } + } + T.Menu { id: control1 @@ -179,11 +224,6 @@ T.Menu { palette: app.palette font: app.font -// implicitWidth: Math.max(background ? background.implicitWidth : 0, -// contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) - //Math.max(background ? background.implicitHeight : 0, - // contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding - margins: 0 leftPadding: menu.leftRightPadding @@ -191,25 +231,33 @@ T.Menu { topPadding: menu.topBottomPadding bottomPadding: menu.topBottomPadding contentData: control.contentData - onVisibleChanged: { - if(visible === false && visible !== popHandle.visible) - popHandle.close(); - implicitHeight = listview.contentHeight + topPadding + bottomPadding; - popHandle.setSize(implicitWidth, implicitHeight) - - } onImplicitWidthChanged: { - implicitHeight = listview.contentHeight + topPadding + bottomPadding; - popHandle.setSize(implicitWidth, implicitHeight) + if(control.width > 0 && control.width !== popupwindow.width){ + popupwindow.width = control.width + } + else + popupwindow.width = implicitWidth } onImplicitHeightChanged: { - implicitHeight = listview.contentHeight + topPadding + bottomPadding; - popHandle.setSize(implicitWidth, implicitHeight) + if(control.height > 0 && control.height !== listview.contentHeight + topPadding + bottomPadding) + popupwindow.height = control.height + else + popupwindow.height = listview.contentHeight + topPadding + bottomPadding; + control1.implicitHeight = popupwindow.height; + + if(background.height != implicitHeight){ + background.height = implicitHeight + } } Component.onCompleted: { implicitHeight = listview.contentHeight + topPadding + bottomPadding; - popHandle.setSize(implicitWidth, implicitHeight) + } + onVisibleChanged: { + + menuItemChange() + + popupwindow.visible = control1.visible } Connections { target: control @@ -219,6 +267,8 @@ T.Menu { { control1.addItem(control.itemAt(j)); } + listview.model = control1.contentModel + menuItemChange() } } @@ -226,162 +276,98 @@ T.Menu { delegate: MenuItem { id: menuitem -// width: listview.width - scrollbarWidth Component.onCompleted: { -// console.log("delegate menuitem......") - if(menuitem.hasOwnProperty("itemHasChecked")){ - itemHasChecked = true + if(control.hasOwnProperty("type") && menuitem.hasOwnProperty("type")){ + menuitem.type = control.type } } } + onCurrentIndexChanged: { + listview.currentIndex = currentIndex || 0 + } contentItem: ListView { id: listview implicitHeight: contentHeight model: control1.contentModel visible: parent.visible + height: control1.implicitHeight - control1.topPadding - control1.bottomPadding + onImplicitHeightChanged: { - console.log("listview implicitheight changeddd", listview.implicitHeight, control1.topPadding, control1.bottomPadding) control1.implicitHeight = listview.contentHeight + control1.topPadding + control1.bottomPadding + if(control.height > 0 && control.height < listview.contentHeight && control1.implicitHeight !== control.height){ + control1.implicitHeight = control.height + } } onVisibleChanged: { if(visible){ control1.implicitHeight = listview.contentHeight + control1.topPadding + control1.bottomPadding + if(control.height > 0 && control.height < listview.contentHeight && control1.implicitHeight !== control.height){ + control1.implicitHeight = control.height + } } } onContentHeightChanged: { implicitHeight = listview.contentHeight; control1.implicitHeight = listview.contentHeight + topPadding + bottomPadding; - popHandle.setSize(control1.implicitWidth, control1.implicitHeight) - console.log("contentheight changedddd", contentHeight) - } - - -// implicitWidth: contentWidth - /*{ - var maxWidth = 0; - for (var l in control1.contentItem.contentItem.children) { - if(!(control1.contentItem.contentItem.children[l] instanceof MenuSeparator)) - maxWidth = Math.max(maxWidth, control1.contentItem.contentItem.children[l].implicitWidth) + if(control.height > 0 && control.height < listview.contentHeight){ + listview.clip = true + scrollbar.visible = true + vscrollbar.visible = true + control1.implicitHeight = control.height + implicitHeight = control.height - topPadding - bottomPadding } + else{ + listview.clip = false + scrollbar.visible = false + vscrollbar.visible = false - if(maxW === 0) - maxW = maxWidth - - // control1.implicitWidth = Math.max(background ? background.implicitWidth : 0, - // contentItem ? maxW + control1.leftPadding + control1.rightPadding : 0) + } + } + clip: outScreen() + //Component.onCompleted: currentIndex = control1.currentIndex || 0 - return maxWidth; - }*/ //todo why ApplicationWindow.window is null - currentIndex: control1.currentIndex || 0 + //currentIndex: control1.currentIndex || 0 keyNavigationEnabled: true keyNavigationWraps: true ScrollBar.vertical: ScrollBar {//会与menuitem重叠 所以宽度设为0 单独使背景里的scrollbar,在position改变时 listview滚动到下面的时候有点奇怪 id: vscrollbar active: visible - visible: popHandle ? popHandle.outScreen : false + visible: false width: 0 } property bool hasCheckables: false property bool hasIcons: false -// onContentYChanged: { -// if (!scrollbar.active) { -// if(scrollbar.visible){ -// if(contentY/(contentHeight - height) >= 1.0) -// scrollbar.position = 1.0 -// else if(contentY/(contentHeight - height) <= 0.0) -// scrollbar.position = 0.0 -// else -// scrollbar.position = contentY/(contentHeight - height) -// } -// } -// } - -// onContentHeightChanged: { -// scrollbar.size = Math.min(height / contentHeight, 1); -// } - - - Connections{ - target: popHandle - function onOutScreenChanged() - { -// console.log("onOutScreenChanged....", popHandle.outScreen) - listview.interactive = popHandle.outScreen ? true : false; - listview.clip = listview.interactive; - scrollbar.visible = listview.interactive; - } - } } Connections { target: control1.contentItem.contentItem - function onChildrenChanged() { - var checkable = false; - var needIcon = false; - for (var i in control1.contentItem.contentItem.children) { - var child = control1.contentItem.contentItem.children[i]; - if (child.checkable) { - control1.contentItem.hasCheckables = true; - checkable = true; - } - if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.toString().length > 0)) { - control1.contentItem.hasIcons = true; - needIcon = true; - } - } - if(checkable){ - for (var k in control1.contentItem.contentItem.children) { - var childk = control1.contentItem.contentItem.children[k]; - if(childk.hasOwnProperty("itemLeftSpace")){ - childk.itemLeftSpace = 20 + childk.leftPadding; - } - } - } - if(needIcon){ - for (var j in control1.contentItem.contentItem.children) { - var childj = control1.contentItem.contentItem.children[j]; - var b = childj.icon && childj.icon.hasOwnProperty("name") && (childj.icon.name.length > 0 || childj.icon.source.toString().length > 0); - if(childj.hasOwnProperty("labelLeftSpace")) - childj.labelLeftSpace = b ? 4 : 20; - } - } - var maxWidth = 0; - for (var l in control1.contentItem.contentItem.children) { - if(!(control1.contentItem.contentItem.children[l] instanceof MenuSeparator)) - maxWidth = Math.max(maxWidth, control1.contentItem.contentItem.children[l].implicitWidth) - } - for (var m in control1.contentItem.contentItem.children) { - control1.contentItem.contentItem.children[m].implicitWidth = maxWidth; - } - - - if(maxW === 0) - maxW = maxWidth - - listview.implicitWidth = maxWidth; - control1.implicitWidth = listview.implicitWidth + scrollbarWidth + control1.leftPadding + control1.rightPadding - // control1.implicitWidth = Math.max(background ? background.implicitWidth : 0, - // contentItem ? maxW + control1.leftPadding + control1.rightPadding : 0) + function onChildrenChanged() { + menuItemChange() } } background: Rectangle { id: backRec - anchors.fill: parent - radius: menu.radius - - color: gradientRec.visible ? "transparent" : getStartColor(menu.normalBC) - opacity: menu.bcColorAlpha - border.color: getStartColor(menu.normalBorderColor) - border.width: menu.border - // layer.enabled: true -// Component.onCompleted: console.log("menu back opacity...", opacity, menu.bcColorAlpha) + radius: _opacity >= 1 ? menu.radius : 0 + implicitHeight: control1.implicitHeight + implicitWidth: control1.implicitWidth + + color: { + if(gradientRec.visible) + return "transparent" + var baccolor = getStartColor(isTransaprent ? menu.normalTransparentBC : menu.normalBC) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, _opacity) + } +// border.color: getStartColor(isTransaprent ? menu.normalTransparentBorderColor : menu.normalBorderColor) +// border.width: menu.border + // layer.enabled: true + // Component.onCompleted: console.log("menu back opacity...", opacity, menu.bcColorAlpha) ScrollBar { id: scrollbar active: visible @@ -400,38 +386,187 @@ T.Menu { } } onVisibleChanged:{ - scrollbarWidth = scrollbar.width + scrollbarWidth = scrollbar.width + if(control.width > 0 && control.width !== maxW + scrollbarWidth + control1.leftPadding + control1.rightPadding){ + control1.implicitWidth = control.width + } + else + control1.implicitWidth = maxW + scrollbarWidth + control1.leftPadding + control1.rightPadding } } Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color - opacity: menu.bcColorAlpha + // border.width: parent.border.width + // border.color: parent.border.color gradient: Gradient { id:gradient - GradientStop { position: 0.0; color: getStartColor(menu.normalBC) } + GradientStop { position: 0.0; color: { + var baccolor = getStartColor(isTransaprent ? menu.normalTransparentBC : menu.normalBC) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, _opacity) + } + } - GradientStop { position: 1.0; color: getEndColor(menu.normalBC)} + GradientStop { position: 1.0; color: { + var baccolor = getEndColor(isTransaprent ? menu.normalTransparentBC : menu.normalBC) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, _opacity) + } + } } - visible: !parseInterface.isSolidPattern(menu.normalBC) + visible: !parseInterface.isSolidPattern(isTransaprent ? menu.normalTransparentBC : menu.normalBC) } } } } - } + } delegate: MenuItem { } -// contentItem: ListView { -// implicitHeight: contentHeight -// property bool hasCheckables: false -// property bool hasIcons: false -// model: control.contentModel -// } + + + Shortcut{ + sequence: "Escape" + onActivated: control.visible = false + } + function menuItemChange() + { + var checkable = false; + var hasChecked = false; + var checkedHasImage = false + var needIcon = false; + var children = control1.contentItem.contentItem.children + for (var i in children) { + var child = control1.contentItem.contentItem.children[i]; + + if(child.checkable) + hasChecked = true + if (child.checkable && child.checked) { + control1.contentItem.hasCheckables = true; + checkable = true; + if(child.icon.source.toString().trim() !== "" || child.icon.name.toString().trim() !== "") + checkedHasImage = true + } + if ((child.icon && child.icon.name &&child.icon.name.toString().trim() !== "") || + (child.icon && child.icon.source &&child.icon.source.toString().trim() !== "")) { + control1.contentItem.hasIcons = true; + needIcon = true; + } + } + if(hasChecked){ + for (var s in children) { + if(!(children instanceof MenuSeparator)) + { + var childs = control1.contentItem.contentItem.children[s]; + + if(childs.hasOwnProperty("hasChecked")) + childs.hasChecked = true + } + } + } + + if(checkable){ + for (var k in children) { + if(!(children instanceof MenuSeparator)) + { + var childk = control1.contentItem.contentItem.children[k]; + + var hasImageStr = false + if(childk && childk.icon && childk.icon.source && childk.icon.source.toString() !== "") + hasImageStr = true + if(!hasImageStr && childk && childk.icon && childk.icon.name && childk.icon.name.toString() !== "") + hasImageStr = true + var checked = childk.checkable && childk.checked + if(childk.hasOwnProperty("itemLeftSpace")){ + if(checked) + childk.itemLeftSpace = 24 + childk.leftPadding; + else{ + if(checkedHasImage && !hasImageStr) + childk.itemLeftSpace = 48 + childk.leftPadding; + else if(checkedHasImage && hasImageStr) + childk.itemLeftSpace = 24 + childk.leftPadding; + else if(!checkedHasImage && !hasImageStr) + childk.itemLeftSpace = 24 + childk.leftPadding; + else if(!checkedHasImage && hasImageStr) + childk.itemLeftSpace = childk.leftPadding; + } + } + } + } + } + else{ + if(needIcon){ + for (var j in control1.contentItem.contentItem.children) { + var childj = control1.contentItem.contentItem.children[j]; + var b = ((childj.icon && childj.icon.name && childj.icon.name.toString().trim() !== "") || + (childj.icon && childj.icon.source && childj.icon.source.toString().trim() !== "")); + + if(childj.hasOwnProperty("itemLeftSpace")) + childj.itemLeftSpace = childj.leftPadding + (b ? 0 : 24); + + } + } + else{ + for (var m in control1.contentItem.contentItem.children) { + var childm = control1.contentItem.contentItem.children[m]; + + if(childm.hasOwnProperty("itemLeftSpace")) + childm.itemLeftSpace = 8//childm.leftPadding; + } + } + } + var maxWidth = 0; + for (var l in control1.contentItem.contentItem.children) { + if(!(control1.contentItem.contentItem.children[l] instanceof MenuSeparator)){ + // if(control1.contentItem.contentItem.children[l].text) + maxWidth = Math.max(maxWidth, control1.contentItem.contentItem.children[l].implicitWidth) + } + } + for (var nn in control1.contentItem.contentItem.children) { + if(!(control1.contentItem.contentItem.children[nn] instanceof MenuSeparator)){ + control1.contentItem.contentItem.children[nn].implicitWidth = maxWidth; + } + } + + if(maxW === 0) + maxW = maxWidth + + listview.implicitWidth = maxWidth; + if(control.width > 0 && control.width !== listview.implicitWidth + scrollbarWidth + control1.leftPadding + control1.rightPadding){ + control1.implicitWidth = control.width + + } + else + control1.implicitWidth = listview.implicitWidth + scrollbarWidth + control1.leftPadding + control1.rightPadding + // console.log("children control1..", listview.implicitWidth, control1.implicitWidth , popupwindow.width) + // control1.implicitWidth = Math.max(background ? background.implicitWidth : 0, + // contentItem ? maxW + control1.leftPadding + control1.rightPadding : 0) + + + } + + function outScreen(){ + + var size = popHandle.getScreenSize(); + var p = popHandle.getScreenPoint(); + if(popupwindow.y + popupwindow.height >= size.height + p.y){ + var h = size.height + p.y - popupwindow.y + if(h > 0){ + listview.clip = true + scrollbar.visible = true + vscrollbar.visible = true + return true + } + } + if(popupwindow.x + popupwindow.width > size.width + p.x){ + var x = size.width + p.x - popupwindow.width; + if(x > 0) + popupwindow.x = x; + } + return false + + } } diff --git a/ukui-qqc2-style/org.ukui.style/MenuItem.qml b/ukui-qqc2-style/org.ukui.style/MenuItem.qml index 36e3d66..99d760f 100644 --- a/ukui-qqc2-style/org.ukui.style/MenuItem.qml +++ b/ukui-qqc2-style/org.ukui.style/MenuItem.qml @@ -34,8 +34,8 @@ T.MenuItem { implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - image.width + label.width + labelLeftSpace + leftPadding + rightPadding + - (controlRoot.checkable ? /*arrow.implicitWidth*/menuItem.imageWidth + menuItem.imageSpace : 0) + + image.sourceSize.width + label.implicitWidth + labelLeftSpace + leftPadding + rightPadding + + (hasChecked ? /*arrow.implicitWidth*/menuItem.imageWidth + menuItem.imageSpace : 0) + (controlRoot.subMenu != null ? /*indicator.implicitWidth*/menuItem.imageWidth + menuItem.imageSpace : 0) + itemLeftSpace) implicitHeight: visible ? Math.max(implicitBackgroundHeight + topInset + bottomInset, Math.max(implicitContentHeight, @@ -45,22 +45,80 @@ T.MenuItem { padding: menuItem.topBottomPadding + onCheckedChanged: { + // console.log("checked changedddddddd", checked, controlRoot.text) +// itemHasChecked = controlRoot.checkable && controlRoot.checked; + //itemLeftSpace = (!(itemHasChecked)/* && !controlRoot.subMenu*/) ? controlRoot.leftPadding : menuItem.imageWidth + 4 + controlRoot.leftPadding + // console.log("checked changedd aaaaaaaaaaaaa", checked, controlRoot.text, itemHasChecked, itemLeftSpace, menuItem.imageWidth) + image.source = contentImageSource(); + indicatorImage.source = indicatorImageSource() + arrowImage.source = arrowImageSource() + controlRoot.update(); + + controlRoot.update() + + } + property bool itemHasChecked: controlRoot.checkable && controlRoot.checked + property bool hasChecked: false property int gridUnit: fontMetrics.height - property int labelLeftSpace: 0 - property int itemLeftSpace: (!(itemHasChecked)/* && !controlRoot.subMenu*/) ? controlRoot.leftPadding : indicatorImage.width + 4 + controlRoot.leftPadding + property int labelLeftSpace: image.visible ? 8 : 0 + property int itemLeftSpace: (!(itemHasChecked)/* && !controlRoot.subMenu*/) ? controlRoot.leftPadding : menuItem.imageWidth + 8 + controlRoot.leftPadding + + property var isTransaprent:{ + if(controlRoot.hasOwnProperty("transparent")) + return controlRoot.transparent + else + return true + } + property var isHightModel:{ + if(controlRoot.hasOwnProperty("type")){ + if(controlRoot.type === "import") + return true + } + return false + } + property var isKeyBorderSelect: hovered //键盘选中 或者hover + property var borderHColor: !controlRoot.enabled ? menuItem.disableCheckedHBorderColor : controlRoot.pressed ? menuItem.clickedCheckedHBorderColor : + isKeyBorderSelect ? menuItem.hoveredCheckedHBorderColor : menuItem.normalCheckedHBorderColor + property var backHColor: !controlRoot.enabled ? menuItem.disableCheckedHBC : controlRoot.pressed ? menuItem.clickedCheckedHBC : + isKeyBorderSelect ? menuItem.hoveredCheckedHBC : menuItem.normalCheckedHBC + + property var borderColor: !controlRoot.enabled ? (isTransaprent ? menuItem.disableTransparentBorderColor : menuItem.disableBorderColor) : + controlRoot.pressed ? (isTransaprent ? menuItem.clickTransparentBorderColor : menuItem.clickBorderColor) : + isKeyBorderSelect ? (isTransaprent ? menuItem.hoverTransparentBorderColor : menuItem.hoverBorderColor) : + (isTransaprent ? menuItem.normalTransparentBorderColor : menuItem.normalBorderColor) + property var backColor: !controlRoot.enabled ? (isTransaprent ? menuItem.disableTransparentBC : menuItem.disableBC) : + controlRoot.pressed ? (isTransaprent ? menuItem.clickedTransparentBC : menuItem.clickedBC) : + (isKeyBorderSelect || (controlRoot.subMenu && controlRoot.subMenu.visible)) ? (isTransaprent ? menuItem.hoveredTransparentBC : menuItem.hoveredBC) : + (isTransaprent ? menuItem.normalTransparentBC : menuItem.normalBC) +// property var borderCheckedColor: !controlRoot.enabled ? (isTransaprent ? menuItem.disableCheckedTransparentBorderColor : menuItem.disableBorderCheckedColor) : +// controlRoot.pressed ? (isTransaprent ? menuItem.clickedCheckedTransparentBorderColor : menuItem.clickBorderCheckedColor) : +// isKeyBorderSelect ? (isTransaprent ? menuItem.hoveredCheckedTransparentBorderColor : menuItem.hoverBorderCheckedColor) : +// (isTransaprent ? menuItem.normalCheckedTransparentBorderColor : menuItem.normalBorderCheckedColor) +// property var backCheckedColor: !controlRoot.enabled ? (isTransaprent ? menuItem.disableCheckedTransparentBC : menuItem.disableCheckedBC) : +// controlRoot.pressed ? (isTransaprent ? menuItem.clickedCheckedTransparentBC : menuItem.clickedCheckedBC) : +// isKeyBorderSelect ? (isTransaprent ? menuItem.hoveredCheckedTransparentBC : menuItem.hoveredCheckedBC) : +// (isTransaprent ? menuItem.normalCheckedTransparentBC : menuItem.normalCheckedBC) property var bacDtColor: !controlRoot.enabled ? menuItem.disableBC : controlRoot.pressed ? menuItem.clickedBC : - controlRoot.hovered ? menuItem.hoveredBC : menuItem.normalBC + isKeyBorderSelect ? menuItem.hoveredBC : menuItem.normalBC leftPadding: menuItem.leftRightPadding/* : Math.floor(gridUnit/4)*2*/ rightPadding: menuItem.leftRightPadding// Math.floor(gridUnit/4)*2 hoverEnabled: true onItemHasCheckedChanged: { - itemLeftSpace = (!(itemHasChecked)/* && !controlRoot.subMenu*/) ? controlRoot.leftPadding : indicatorImage.width + 4 + controlRoot.leftPadding + itemLeftSpace = (!(itemHasChecked)/* && !controlRoot.subMenu*/) ? controlRoot.leftPadding : menuItem.imageWidth + 8 + controlRoot.leftPadding + } + + onHasCheckedChanged: { + implicitWidth = Math.max(implicitBackgroundWidth + leftInset + rightInset, + image.sourceSize.width + label.implicitWidth + labelLeftSpace + leftPadding + rightPadding + + (hasChecked ? /*arrow.implicitWidth*/menuItem.imageWidth + menuItem.imageSpace : 0) + + (controlRoot.subMenu != null ? /*indicator.implicitWidth*/menuItem.imageWidth + menuItem.imageSpace : 0) + itemLeftSpace) } @@ -97,39 +155,38 @@ T.MenuItem { } contentItem:Item{ - x: itemLeftSpace + controlRoot.leftPadding -// anchors.left: parent.left -// anchors.leftMargin: itemLeftSpace -// anchors.right: parent.right -// anchors.rightMargin: parent.rightPadding +// x: itemLeftSpace + controlRoot.leftPadding + anchors.left: parent.left + anchors.leftMargin: controlRoot.mirrored ? controlRoot.leftPadding : itemLeftSpace + anchors.right: parent.right + anchors.rightMargin: controlRoot.mirrored ? itemLeftSpace : controlRoot.rightPadding implicitHeight: Math.max(image.height, label.height) Image { id: image - source: //controlRoot.icon.source - { - if((controlRoot.icon.source.toString() === "" && controlRoot.icon.name.toString() === "")) - return controlRoot.icon.source - - var model = !controlRoot.enabled ? "disenable" : appP.isDark ? "highlight" : /*controlRoot.pressed ? "highlight" : controlRoot.hovered ? "highlight" :*/ "normal" - - let s = controlRoot.icon.source.toString() - return "image://imageProvider/" + s + "/" + model; - } + source: contentImageSource()//controlRoot.icon.source + cache: false anchors.verticalCenter: parent.verticalCenter - width: (controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null) ? menuItem.imageWidth : 0 + sourceSize.width: (controlRoot.display !== AbstractButton.TextOnly && source !== "" ) ? menuItem.imageWidth : 0 + sourceSize.height: (controlRoot.display !== AbstractButton.TextOnly && source !== "" ) ? menuItem.imageWidth : 0 visible: controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null + anchors.left: controlRoot.mirrored ? undefined : parent.left + anchors.right: controlRoot.mirrored ? parent.right : undefined + } - Label { + Text { id:label text: controlRoot.text font:controlRoot.font - color: getStartColor(controlRoot.enabled ? menuItem.normalTextColor : menuItem.disableTextColor) + elide: Text.ElideRight + color: getStartColor(controlRoot.enabled ? (isHightModel ? menuItem.normalHTextColor : menuItem.normalTextColor) : (isHightModel ? menuItem.disableHTextColor : menuItem.disableTextColor)) visible: controlRoot.display !== AbstractButton.IconOnly && text !== "" anchors.verticalCenter: parent.verticalCenter - anchors.left: image.right - anchors.leftMargin: labelLeftSpace//(image.visible && image.status !== Image.Null) ? 4 : labelLeftSpace + anchors.left: controlRoot.mirrored ? parent.left : (image.visible ? image.right : parent.left) + anchors.leftMargin: controlRoot.mirrored ? undefined : labelLeftSpace//(image.visible && image.status !== Image.Null) ? 4 : labelLeftSpace + anchors.right: controlRoot.mirrored ? (image.visible ? image.left : parent.right) : parent.right + anchors.rightMargin: controlRoot.mirrored ? labelLeftSpace : undefined } } @@ -142,24 +199,10 @@ T.MenuItem { anchors.verticalCenter: controlRoot.verticalCenter visible: controlRoot.checked - source: { -// return "image://imageProvider/file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg/normal" - - var model = "normal" - if( appP.isDark) - model = "highlight" - var icon = "object-select-symbolic"; - if(controlRoot.checkable){ - console.log("app themehasiconnnn", app.themeHasIcon(icon)) - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg" - return "image://imageProvider/" + icon + "/" + model - } - else - return "" - } - width: menuItem.imageWidth - height: menuItem.imageWidth + source: indicatorImageSource() + sourceSize.width: menuItem.imageWidth + sourceSize.height: menuItem.imageWidth + cache: false } arrow: Image { @@ -167,22 +210,13 @@ T.MenuItem { anchors.left: controlRoot.mirrored ?controlRoot.left : controlRoot.right anchors.leftMargin: controlRoot.mirrored ? controlRoot.leftPadding : - controlRoot.rightPadding - menuItem.imageWidth anchors.verticalCenter: parent.verticalCenter - width: menuItem.imageWidth - height: menuItem.imageWidth + sourceSize.width: menuItem.imageWidth + sourceSize.height: menuItem.imageWidth visible: controlRoot.subMenu mirror: controlRoot.mirrored - source: { - var model = "normal" - if( appP.isDark) - model = "highlight" - var icon = "ukui-end-symbolic"; - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-end-symbolic.svg" - return "image://imageProvider/" + icon + "/" + model - - return "" - } + source: arrowImageSource() + cache: false } background: @@ -191,9 +225,10 @@ T.MenuItem { width: controlRoot.width height: controlRoot.height radius: menuItem.radius - //opacity: (controlRoot.highlighted || controlRoot.hovered || controlRoot.pressed || controlRoot.checked) ? 1 : 0 - border.width: 1 - color: getStartColor(bacDtColor) + //opacity: (isHightModel || isKeyBorderSelect || controlRoot.pressed || controlRoot.checked) ? 1 : 0 + border.width: menuItem.borderWidth + border.color: getStartColor(isHightModel ? borderHColor : borderColor) + color: gradientRec.visible ? "transparent" : getStartColor(isHightModel ? backHColor : backColor) Rectangle{ id: gradientRec @@ -203,11 +238,11 @@ T.MenuItem { border.color: parent.border.color gradient: Gradient { id:gradient - GradientStop { position: 0.0; color: getStartColor(bacDtColor) } + GradientStop { position: 0.0; color: getStartColor(isHightModel ? backHColor : backColor) } - GradientStop { position: 1.0; color: getEndColor(bacDtColor)} + GradientStop { position: 1.0; color: getEndColor(isHightModel ? backHColor : backColor)} } - visible: !parseInterface.isSolidPattern(bacDtColor) + visible: !parseInterface.isSolidPattern(isHightModel ? backHColor : backColor) } } @@ -219,17 +254,21 @@ T.MenuItem { } Component.onCompleted: { + itemLeftSpace = (!(itemHasChecked)) ? controlRoot.leftPadding : menuItem.imageWidth + 8 + controlRoot.leftPadding stateChange() + image.source = contentImageSource(); + indicatorImage.source = indicatorImageSource() + arrowImage.source = arrowImageSource() } function stateChange() { bacDtColor = !controlRoot.enabled ? menuItem.disableBC : controlRoot.pressed ? menuItem.clickedBC : - controlRoot.hovered ? menuItem.hoveredBC : menuItem.normalBC + isKeyBorderSelect ? menuItem.hoveredBC : menuItem.normalBC backrect.border.color = getStartColor(!controlRoot.enabled ? menuItem.disableBorderColor : controlRoot.pressed ? menuItem.clickBorderColor : - controlRoot.hovered ? menuItem.hoverBorderColor : menuItem.normalBorderColor); + isKeyBorderSelect ? menuItem.hoverBorderColor : menuItem.normalBorderColor); controlRoot.update() } property variant fontMetrics: TextMetrics { @@ -257,6 +296,90 @@ T.MenuItem { StylePrivate.APPParameter{ id: app + onParametryChanged:{ + image.source = contentImageSource(); + indicatorImage.source = indicatorImageSource() + arrowImage.source = arrowImageSource() + controlRoot.update(); + } + onIconThemeChanged: { + image.source = "" + image.source = contentImageSource() + indicatorImage.source = "" + indicatorImage.source = indicatorImageSource() + arrowImage.source = "" + arrowImage.source = arrowImageSource() + } + } + + onEnabledChanged: { + image.source = contentImageSource(); + indicatorImage.source = indicatorImageSource() + arrowImage.source = arrowImageSource() + controlRoot.update(); + } + + function contentImageSource() + { + if((controlRoot.icon.source.toString() === "" && controlRoot.icon.name.toString() === "")) + return controlRoot.icon.source + + //var model = !controlRoot.enabled ? "disenable" : (appP.isDark || isHightModel) ? "highlight" : /*controlRoot.pressed ? "highlight" : isKeyBorderSelect ? "highlight" :*/ "normal" + var model = "normal"; + if(!controlRoot.enabled){ + if(appP.isDark || isHightModel) + model = "highDisbale" + else + model = "disenable" + } + else if(appP.isDark || isHightModel){ + model = "highlight" + } + + let s = controlRoot.icon.source.toString() + if(s === "") + s = controlRoot.icon.name.toString() + return "image://imageProvider/" + s + "/" + model; + } + + function indicatorImageSource(){ + // return "image://imageProvider/file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg/normal" + + var model = "normal" + if(!controlRoot.enabled){ + if(appP.isDark || isHightModel) + model = "highDisbale" + else + model = "disenable" + } + else if(appP.isDark || isHightModel){ + model = "highlight" + } + var icon = "object-select-symbolic"; + if(controlRoot.checkable){ + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model + } + else + return "" + } + + function arrowImageSource(){ + var model = "normal" + if(!controlRoot.enabled){ + if(appP.isDark || isHightModel) + model = "highDisbale" + else + model = "disenable" + } + else if(appP.isDark || isHightModel){ + model = "highlight" + } + var icon = "ukui-end-symbolic"; + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-end-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model } } diff --git a/ukui-qqc2-style/org.ukui.style/MenuSeparator.qml b/ukui-qqc2-style/org.ukui.style/MenuSeparator.qml new file mode 100644 index 0000000..51a8128 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/MenuSeparator.qml @@ -0,0 +1,51 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Templates 2.12 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate + +T.MenuSeparator { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 2 + verticalPadding: padding + 4 + + contentItem: Rectangle { + implicitWidth: 188 + implicitHeight: 1 + color: parseInterface.pStartColor(menuItem.menuSeparatorColor) + } + StylePrivate.UKUIMenuItem{ + id: menuItem + } + ParseInterface{ + id: parseInterface + } +} diff --git a/ukui-qqc2-style/org.ukui.style/Pane.qml b/ukui-qqc2-style/org.ukui.style/Pane.qml new file mode 100644 index 0000000..b444e23 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/Pane.qml @@ -0,0 +1,70 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Templates 2.12 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate + +T.Pane { + id: control + property var dColor:{ + if(control.hasOwnProperty("dtColor")) + return control.dtColor + else + return "" + } + onDColorChanged: { + if(dColor !== "") + rec.color = parseInterface.getDTColor(dColor) + } + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + contentHeight + topPadding + bottomPadding) + + palette: appP.palette + StylePrivate.APPParameter{ + id: appP + onParametryChanged: { + if(control.hasOwnProperty("dtColor")) + rec.color = parseInterface.getDTColor(dtColor) + } + } + ParseInterface{ + id: parseInterface + } + padding: 12 + + background: Rectangle { + id: rec + color: { + if(dColor !== ""){ + return parseInterface.getDTColor(dColor) + } + else + return appP.palette.window + } + } +} diff --git a/ukui-qqc2-style/org.ukui.style/Popup.qml b/ukui-qqc2-style/org.ukui.style/Popup.qml index c314899..2bc3f6d 100644 --- a/ukui-qqc2-style/org.ukui.style/Popup.qml +++ b/ukui-qqc2-style/org.ukui.style/Popup.qml @@ -41,7 +41,12 @@ T.Popup { padding: popup.padding clip: false - + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } // StylePrivate.APPParameter{ // id: appP // } @@ -85,8 +90,8 @@ T.Popup { background: Rectangle { radius: popup.radius - color: gradientRec.visible ? "transparent" : StylePrivate.ParseColorInterface.startColor(popup.backColor) - border.color: StylePrivate.ParseColorInterface.startColor(popup.backBorderColor) + color: gradientRec.visible ? "transparent" : StylePrivate.ParseColorInterface.startColor(isTransaprent ? popup.transparentBC : popup.backColor) + border.color: StylePrivate.ParseColorInterface.startColor(isTransaprent ? popup.transparentBorderColor : popup.backBorderColor) layer.enabled: true Rectangle{ @@ -97,11 +102,11 @@ T.Popup { border.color: parent.border.color gradient: Gradient { id:gradient - GradientStop { position: 0.0; color: StylePrivate.ParseColorInterface.startColor(popup.backColor) } + GradientStop { position: 0.0; color: StylePrivate.ParseColorInterface.startColor(isTransaprent ? popup.transparentBC : popup.backColor) } - GradientStop { position: 1.0; color: StylePrivate.ParseColorInterface.endColor(popup.backColor)} + GradientStop { position: 1.0; color: StylePrivate.ParseColorInterface.endColor(isTransaprent ? popup.transparentBC : popup.backColor)} } - visible: !StylePrivate.ParseColorInterface.isSolidPattern(popup.backColor) + visible: !StylePrivate.ParseColorInterface.isSolidPattern(isTransaprent ? popup.transparentBC : popup.backColor) } diff --git a/ukui-qqc2-style/org.ukui.style/ProgressBar.qml b/ukui-qqc2-style/org.ukui.style/ProgressBar.qml index 63423bf..52445e3 100644 --- a/ukui-qqc2-style/org.ukui.style/ProgressBar.qml +++ b/ukui-qqc2-style/org.ukui.style/ProgressBar.qml @@ -25,6 +25,7 @@ import QtQuick.Templates 2.12 as T import QtQuick.Controls 2.12 import QtQuick.Controls.impl 2.12 import org.ukui.qqc2style.private 1.0 as StylePrivate +import QtGraphicalEffects 1.15 T.ProgressBar { id: control @@ -34,6 +35,8 @@ T.ProgressBar { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) + palette: app.palette + ParseInterface{ id: parseInterface } @@ -46,92 +49,166 @@ T.ProgressBar { { return parseInterface.pEndColor(dtcolor) } + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var isShowNormalProgressBarAnim:{ + if(control.hasOwnProperty("showNormalProgressBarAnim")) + return control.showNormalSliderAnim + else + return false + } + property real animationSpeed: 160 // 统一速度值(像素/秒) + property real sliderWidth: 56 // 保持滑块宽度不变 + // 用于普通模式动画的属性 + property real animationX: -sliderWidth + + // 计算进度百分比的辅助属性 + property real progressPercent: Math.min(Math.max(0, (control.value - control.from) / (control.to - control.from) * 100), 100) background: Rectangle { radius: progressbar.radius implicitWidth: progressbar.normalWidth - implicitHeight: progressbar.normalHeight + implicitHeight: control.indeterminate ? 8 : progressbar.normalHeight - height: progressbar.normalHeight + height: control.indeterminate ? 8 : progressbar.normalHeight - color: gradientRec.visible ? "transparent" : getStartColor(progressbar.normalColor) - border.width: progressbar.borderWidth - border.color: getStartColor(progressbar.borderColor) + color: gradientRec.visible ? "transparent" : getStartColor(isTransaprent ? progressbar.normalTransparentColor : progressbar.normalColor) Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { - GradientStop { position: 0.0; color: getStartColor(progressbar.normalColor) } + GradientStop { position: 0.0; color: getStartColor(isTransaprent ? progressbar.normalTransparentColor : progressbar.normalColor)} - GradientStop { position: 1.0; color: getEndColor(progressbar.normalColor)} + GradientStop { position: 1.0; color: getEndColor(isTransaprent ? progressbar.normalTransparentColor : progressbar.normalColor)} } - visible: !parseInterface.isSolidPattern(progressbar.normalColor) + visible: !parseInterface.isSolidPattern(isTransaprent ? progressbar.normalTransparentColor : progressbar.normalColor) + } + Rectangle{ + anchors.fill: parent + radius: parent.radius + color: "transparent" + border.width: progressbar.borderWidth + border.color: getStartColor(isTransaprent ? progressbar.transparentborderColor : progressbar.borderColor) } - - } contentItem: Item{ implicitHeight: background.height implicitWidth: background.width - Rectangle { + + Item { + id: staticProgress x: !control.mirrored ? 0 : (control.width * (1.0 - control.position)) - implicitHeight: progressbar.normalHeight - implicitWidth: control.width * control.position + width: control.width * control.position + height: parent.height visible: !control.indeterminate - //indeterminate: control.visible && control.indeterminate - color: gradientItem.visible ? "transparent" : getStartColor(progressbar.childrenColor) - radius: progressbar.radius - Rectangle{ - id: gradientItem + // 启用图层效果实现圆角剪裁 + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Rectangle { + width: staticProgress.width + height: staticProgress.height + radius: progressbar.radius + } + } + Rectangle { anchors.fill: parent - radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color - gradient: Gradient { - GradientStop { position: 0.0; color: getStartColor(progressbar.childrenColor) } + color: gradientItem.visible ? "transparent" : getStartColor(progressbar.childrenColor) + radius: progressbar.radius + + Rectangle{ + id: gradientItem + anchors.fill: parent + radius: parent.radius + border.width: progressbar.borderWidth + border.color: getStartColor(progressbar.childrenColor) + gradient: Gradient { + GradientStop { position: 0.0; color: getStartColor(progressbar.childrenColor) } + GradientStop { position: 1.0; color: getEndColor(progressbar.childrenColor)} + } + visible: !parseInterface.isSolidPattern(progressbar.childrenColor) + } + } + + // 普通模式下滑块效果 + Rectangle { + id: normalAnimationRec + x: animationX + width: sliderWidth + height: parent.height + visible: isShowNormalProgressBarAnim && !control.indeterminate && control.value > control.from + color: "transparent" + radius: progressbar.radius - GradientStop { position: 1.0; color: getEndColor(progressbar.childrenColor)} + // 渐变滑块效果 + Rectangle { + anchors.centerIn: parent + width: parent.width + height: parent.height + radius: parent.radius + gradient: Gradient { + orientation: Gradient.Horizontal + GradientStop { position: 0.02; color: "transparent" } + GradientStop { position: 0.4; color: Qt.rgba(1, 1, 1, 0.35) } + GradientStop { position: 0.6; color: Qt.rgba(1, 1, 1, 0.35) } + GradientStop { position: 0.98; color: "transparent" } + } } - visible: !parseInterface.isSolidPattern(progressbar.childrenColor) } } - Label{ + + Text{ visible: !control.indeterminate anchors.centerIn: parent text: (control.position * 100).toString() + "%" + font: app.font color: control.value > (control.from + (control.to - control.from) * 1.0 / 2.0 ) ? getStartColor(progressbar.hightlightTextColor) : getStartColor(StylePrivate.UKUILabel.normalColor) } + + // 不确定状态的滑块 Rectangle { id:rec - implicitHeight: progressbar.normalHeight - implicitWidth: progressbar.indeterminateChildrenWidth - visible: control.indeterminate - //indeterminate: control.visible && control.indeterminate - color: gradientInterminate.visible ? "transparent" : getStartColor(progressbar.childrenColor) - radius: progressbar.radius + implicitHeight: parent.height + implicitWidth: control.width * progressbar.indeterminateChildrenWidth / progressbar.normalWidth + visible: false + radius: height/2 - Rectangle{ - id: gradientInterminate + LinearGradient { anchors.fill: parent - radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color + start: Qt.point(0, 0) + end: Qt.point(width, 0) gradient: Gradient { - GradientStop { position: 0.0; color: getStartColor(progressbar.childrenColor) } - - GradientStop { position: 1.0; color: getEndColor(progressbar.childrenColor)} + GradientStop { position: 0.0; color: getStartColor(progressbar.indeterminateColor) } + GradientStop { position: 1.0; color: getEndColor(progressbar.indeterminateColor)} } - visible: !parseInterface.isSolidPattern(progressbar.childrenColor) } } + // 圆角矩形作为遮罩 + Rectangle { + id: mask + anchors.fill: rec + radius: rec.radius + color: "white" + visible: false + } + OpacityMask { + anchors.centerIn: parent + anchors.fill: rec + source: rec + maskSource: mask + visible: control.indeterminate + } + + // 不确定状态的动画 Timer { id: slideTimer interval: 1 @@ -150,8 +227,32 @@ T.ProgressBar { duration: 500 + control.width easing.type: Easing.InOutQuad } - } + // 普通模式的动画 - 固定大小滑块从左到右滑动 + SequentialAnimation { + id: normalAnimation + running: !control.indeterminate && control.value > control.from + loops: Animation.Infinite + + PropertyAnimation { + target: control + property: "animationX" + from: -sliderWidth + to: control.width * (progressPercent / 100) + duration: Math.abs(control.width * (progressPercent / 100) - (-sliderWidth)) * 1000 / animationSpeed + easing.type: Easing.Linear + } + + PauseAnimation { duration: 300 } + + // 直接跳回起点 + PropertyAction { + target: control + property: "animationX" + value: -sliderWidth + } + } + } StylePrivate.UKUIProgressBar{ id: progressbar diff --git a/ukui-qqc2-style/org.ukui.style/RadioButton.qml b/ukui-qqc2-style/org.ukui.style/RadioButton.qml index d4bf1b3..b6ed775 100644 --- a/ukui-qqc2-style/org.ukui.style/RadioButton.qml +++ b/ukui-qqc2-style/org.ukui.style/RadioButton.qml @@ -34,13 +34,25 @@ T.RadioButton { implicitContentHeight + topPadding + bottomPadding, implicitIndicatorHeight + topPadding + bottomPadding) hoverEnabled: true + palette: app.palette + font: app.font + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } property alias indicatorColor: indicatorRec.color property alias childrenColor: childrenRec.color + property bool isHoveredExpanded: false //记录小圆是否处于 “hover 放大到 8px” 的状态 + + property var tansparentNormalColor: radiobutton.normalTransparentIndicatorColor + property var normalColor: radiobutton.normalIndicatorColor property var borderColor: control.checked ? (!control.enabled ? radiobutton.checked_disableIndicatorBorderColor : control.pressed ? radiobutton.checked_clickIndicatorBorderColor : control.hovered ? - radiobutton.checked_hoverIndicatorBorderColor : radiobutton.checked_normalIndicatorBorderColor) : + radiobutton.checked_hoverIndicatorColor : radiobutton.checked_normalIndicatorBorderColor) : (!control.enabled ? radiobutton.disableIndicatorBorderColor : control.pressed ? radiobutton.clickIndicatorBorderColor : control.hovered ? radiobutton.hoverIndicatorBorderColor : radiobutton.normalIndicatorBorderColor) @@ -48,9 +60,12 @@ T.RadioButton { property var backColor: control.checked ? (!control.enabled ? radiobutton.checked_disableIndicatorColor : control.pressed ? radiobutton.checked_clickIndicatorColor : control.hovered ? radiobutton.checked_hoverIndicatorColor : radiobutton.checked_normalIndicatorColor) : - (!control.enabled ? radiobutton.disableIndicatorColor : control.pressed ? - radiobutton.clickIndicatorColor : control.hovered ? - radiobutton.hoverIndicatorColor : radiobutton.normalIndicatorColor) + isTransaprent ? (!control.enabled ? radiobutton.disableTransparentIndicatorColor : control.pressed ? + radiobutton.clickTransparentIndicatorColor : control.hovered ? + radiobutton.hoverTransparentIndicatorColor : tansparentNormalColor) : + (!control.enabled ? radiobutton.disableIndicatorColor : control.pressed ? + radiobutton.clickIndicatorColor : control.hovered ? + radiobutton.hoverIndicatorColor : normalColor) property var childrenDtColor: !control.enabled ? radiobutton.checked_disableChildrenColor : control.pressed ? radiobutton.checked_clickChildrenColor: @@ -82,15 +97,11 @@ T.RadioButton { y: control.topPadding + (control.availableHeight - height) / 2 radius: width / 2 - border.width: radiobutton.borderWidth - border.color: getStartColor(control.visualFocus ? (control.checked ? borderColor : radiobutton.checked_normalIndicatorColor) : borderColor) color: gradientRec.visible ? "transparent" : getStartColor(backColor) Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(backColor) } @@ -98,12 +109,22 @@ T.RadioButton { } visible: !parseInterface.isSolidPattern(backColor) } + Rectangle{ + anchors.fill: parent + radius: width / 2 + border.width: radiobutton.borderWidth + border.color: getStartColor((app.focusEnable && control.visualFocus) ? (control.checked ? borderColor : radiobutton.checked_normalIndicatorColor) : borderColor) + color: "transparent" + + } Rectangle { id:childrenRec - width: radiobutton.childrenWidth + width: 8 height: width - anchors.centerIn: parent + // anchors.centerIn: parent + anchors.horizontalCenter: parent.horizontalCenter // 水平居中 + anchors.verticalCenter: parent.verticalCenter // 垂直居中 radius: width / 2 color: gradientChildrenRec.visible ? "transparent" : getStartColor(childrenDtColor) visible: control.checked @@ -122,17 +143,164 @@ T.RadioButton { visible: !parseInterface.isSolidPattern(childrenDtColor) } } + + NumberAnimation { + id: scaleAnim + target: childrenRec + property: "scale" + from: 0.0 + to: radiobutton.childrenWidth / 8 // 关键:计算基准大小对应的缩放比例 + duration: 200 + easing.type: Easing.InOutQuint + } + NumberAnimation { + id: uncheckScaleAnim + target: childrenRec + property: "scale" + from: radiobutton.childrenWidth / 8 // 从基准大小开始 + to: 0.0 + duration: 150 + easing.type: Easing.InOutQuint + onRunningChanged: { + if (!running && !control.checked) { + childrenRec.visible = false; + control.isHoveredExpanded = false; // 重置状态 + } + } + } + ColorAnimation { + id: transparentColorAnim + target: control + property: "tansparentNormalColor" + from: radiobutton.checked_normalIndicatorColor + to: radiobutton.normalTransparentIndicatorColor + duration: 150 + easing.type: Easing.InOutQuint + running: false + } + ColorAnimation { + id: colorAnim + target: control + property: "normalColor" + from: radiobutton.checked_normalIndicatorColor + to: radiobutton.normalIndicatorColor + duration: 150 + easing.type: Easing.InOutQuint + running: false + } + NumberAnimation { + id: hoverScaleAnim + target: childrenRec + property: "scale" + duration: 100 + easing.type: Easing.InOutQuint + } + + + } - contentItem: Label { + contentItem: Text { leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 text: control.text - font: app.font + font: control.font color: getStartColor(control.enabled ? radiobutton.normalTextColor : radiobutton.disableTextColor) } + onHoveredChanged: { + if (!control.enabled || !control.checked) { + return; + } + + const baseScale = radiobutton.childrenWidth / 8; + const targetScale = 1.0; + + hoverScaleAnim.stop(); + + if (hovered) { + // 鼠标移入:从基准大小放大到8px + if (childrenRec.scale === baseScale) { // 仅当当前是基准大小时才放大 + hoverScaleAnim.from = baseScale; + hoverScaleAnim.to = targetScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = true; // 标记为“已放大到8px” + } + } else { + if (control.isHoveredExpanded) { + hoverScaleAnim.from = targetScale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } + } + + function handleChildrenScale() { + if (!control.enabled || !control.checked) { + return; + } + + const baseScale = radiobutton.childrenWidth / 8; + const expandedScale = 1.0; + + hoverScaleAnim.stop(); + + // 新增:按下状态处理 + if (control.pressed) { + // 按下时立即缩小到基准大小 + if (childrenRec.scale !== baseScale) { + hoverScaleAnim.from = childrenRec.scale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } else if (control.hovered) { + // 松开后恢复为8px + if (childrenRec.scale === baseScale) { + hoverScaleAnim.from = baseScale; + hoverScaleAnim.to = expandedScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = true; + } + } else { + // 非hover状态处理 + if (control.isHoveredExpanded) { + hoverScaleAnim.from = expandedScale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } + } + // 新增:处理按下和松开事件 + onPressedChanged: { + // 按下时强制更新小圆圈大小 + if (control.pressed && control.hovered && control.checked && control.enabled) { + handleChildrenScale(); + } + // 松开时恢复 + else if (!control.pressed && control.hovered && control.checked && control.enabled) { + handleChildrenScale(); + } + } + onCheckedChanged: { + if (checked) { + childrenRec.scale = 0.0; + childrenRec.visible = true; + scaleAnim.start(); + control.isHoveredExpanded = false; + } else { + uncheckScaleAnim.start(); + if(isTransaprent) + transparentColorAnim.start() + else + colorAnim.start(); + control.isHoveredExpanded = false; + } + } + StylePrivate.UKUIRadioButton{ id: radiobutton } diff --git a/ukui-qqc2-style/org.ukui.style/RadioDelegate.qml b/ukui-qqc2-style/org.ukui.style/RadioDelegate.qml index c8b2570..6b36b47 100644 --- a/ukui-qqc2-style/org.ukui.style/RadioDelegate.qml +++ b/ukui-qqc2-style/org.ukui.style/RadioDelegate.qml @@ -30,15 +30,26 @@ T.RadioDelegate { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - implicitContentWidth + leftPadding + rightPadding) + implicitContentWidth + implicitIndicatorWidth + spacing + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, implicitIndicatorHeight + topPadding + bottomPadding) hoverEnabled: true + font: app.font + palette: app.palette + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } property alias indicatorColor: indicatorRec.color property alias childrenColor: childrenRec.color + property bool isHoveredExpanded: false //记录小圆是否处于 “hover 放大到 8px” 的状态 + property var tansparentNormalColor: radiobutton.normalTransparentIndicatorColor + property var normalColor: radiobutton.normalIndicatorColor property var borderColor: control.checked ? (!control.enabled ? radiobutton.checked_disableIndicatorBorderColor : control.pressed ? radiobutton.checked_clickIndicatorBorderColor : control.hovered ? radiobutton.checked_hoverIndicatorBorderColor : radiobutton.checked_normalIndicatorBorderColor) : @@ -49,9 +60,12 @@ T.RadioDelegate { property var backColor: control.checked ? (!control.enabled ? radiobutton.checked_disableIndicatorColor : control.pressed ? radiobutton.checked_clickIndicatorColor : control.hovered ? radiobutton.checked_hoverIndicatorColor : radiobutton.checked_normalIndicatorColor) : - (!control.enabled ? radiobutton.disableIndicatorColor : control.pressed ? - radiobutton.clickIndicatorColor : control.hovered ? - radiobutton.hoverIndicatorColor : radiobutton.normalIndicatorColor) + isTransaprent ? (!control.enabled ? radiobutton.disableTransparentIndicatorColor : control.pressed ? + radiobutton.clickTransparentIndicatorColor : control.hovered ? + radiobutton.hoverTransparentIndicatorColor : tansparentNormalColor) : + (!control.enabled ? radiobutton.disableIndicatorColor : control.pressed ? + radiobutton.clickIndicatorColor : control.hovered ? + radiobutton.hoverIndicatorColor : normalColor) property var childrenDtColor: !control.enabled ? radiobutton.checked_disableChildrenColor : control.pressed ? radiobutton.checked_clickChildrenColor: @@ -85,10 +99,13 @@ T.RadioDelegate { id: iconLabel controlRoot: control anchors.left: control.left - leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.right: control.right + anchors.leftMargin: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.rightMargin: !control.mirrored ? control.indicator.width + control.spacing : control.rightPadding + //leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding //x: control.text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 //anchors.centerIn: control - implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) + indicator.implicitWidth + control.spacing + implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) } @@ -102,15 +119,11 @@ T.RadioDelegate { y: control.topPadding + (control.availableHeight - height) / 2 radius: width / 2 - border.width: radiobutton.borderWidth - border.color: getStartColor(control.visualFocus ? (control.checked ? borderColor : radiobutton.checked_normalIndicatorColor) : borderColor) color: gradientRec.visible ? "transparent" : getStartColor(backColor) Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(backColor) } @@ -118,12 +131,23 @@ T.RadioDelegate { } visible: !parseInterface.isSolidPattern(backColor) } + Rectangle{ + anchors.fill: parent + radius: width / 2 + border.width: radiobutton.borderWidth + border.color: getStartColor((app.focusEnable && control.visualFocus) ? (control.checked ? borderColor : radiobutton.checked_normalIndicatorColor) : borderColor) + color: "transparent" + + } Rectangle { id:childrenRec - width: radiobutton.childrenWidth + // width: control.hovered ? 8 : radiobutton.childrenWidth + width: 8 height: width - anchors.centerIn: parent + // anchors.centerIn: parent + anchors.horizontalCenter: parent.horizontalCenter // 水平居中 + anchors.verticalCenter: parent.verticalCenter // 垂直居中 radius: width / 2 color: gradientChildrenRec.visible ? "transparent" : getStartColor(childrenDtColor) visible: control.checked @@ -142,12 +166,154 @@ T.RadioDelegate { visible: !parseInterface.isSolidPattern(childrenDtColor) } } + NumberAnimation { + id: scaleAnim + target: childrenRec + property: "scale" + from: 0.0 + to: radiobutton.childrenWidth / 8 // 关键:计算基准大小对应的缩放比例 + duration: 200 + easing.type: Easing.InOutQuint + } + NumberAnimation { + id: uncheckScaleAnim + target: childrenRec + property: "scale" + from: radiobutton.childrenWidth / 8 // 从基准大小开始 + to: 0.0 + duration: 150 + easing.type: Easing.InOutQuint + onRunningChanged: { + if (!running && !control.checked) { + childrenRec.visible = false; + control.isHoveredExpanded = false; // 重置状态 + } + } + } + ColorAnimation { + id: transparentColorAnim + target: control + property: "tansparentNormalColor" + from: radiobutton.checked_normalIndicatorColor + to: radiobutton.normalTransparentIndicatorColor + duration: 150 + easing.type: Easing.InOutQuint + running: false + } + ColorAnimation { + id: colorAnim + target: control + property: "normalColor" + from: radiobutton.checked_normalIndicatorColor + to: radiobutton.normalIndicatorColor + duration: 150 + easing.type: Easing.InOutQuint + running: false + } + NumberAnimation { + id: hoverScaleAnim + target: childrenRec + property: "scale" + duration: 100 + easing.type: Easing.InOutQuint + } + } + onHoveredChanged: { + if (!control.enabled || !control.checked) { + return; + } + + const baseScale = radiobutton.childrenWidth / 8; + const targetScale = 1.0; + + hoverScaleAnim.stop(); + + if (hovered) { + // 鼠标移入:从基准大小放大到8px + if (childrenRec.scale === baseScale) { // 仅当当前是基准大小时才放大 + hoverScaleAnim.from = baseScale; + hoverScaleAnim.to = targetScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = true; // 标记为“已放大到8px” + } + } else { + if (control.isHoveredExpanded) { + hoverScaleAnim.from = targetScale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } + } + + function handleChildrenScale() { + if (!control.enabled || !control.checked) { + return; + } + + const baseScale = radiobutton.childrenWidth / 8; + const expandedScale = 1.0; + + hoverScaleAnim.stop(); + + // 新增:按下状态处理 + if (control.pressed) { + // 按下时立即缩小到基准大小 + if (childrenRec.scale !== baseScale) { + hoverScaleAnim.from = childrenRec.scale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } else if (control.hovered) { + // 松开后恢复为8px + if (childrenRec.scale === baseScale) { + hoverScaleAnim.from = baseScale; + hoverScaleAnim.to = expandedScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = true; + } + } else { + // 非hover状态处理 + if (control.isHoveredExpanded) { + hoverScaleAnim.from = expandedScale; + hoverScaleAnim.to = baseScale; + hoverScaleAnim.start(); + control.isHoveredExpanded = false; + } + } + } + // 新增:处理按下和松开事件 + onPressedChanged: { + // 按下时强制更新小圆圈大小 + if (control.pressed && control.hovered && control.checked && control.enabled) { + handleChildrenScale(); + } + // 松开时恢复 + else if (!control.pressed && control.hovered && control.checked && control.enabled) { + handleChildrenScale(); + } + } + + onCheckedChanged: { + if (checked) { + childrenRec.scale = 0.0; + childrenRec.visible = true; + scaleAnim.start(); + control.isHoveredExpanded = false; + } else { + uncheckScaleAnim.start(); + if(isTransaprent) + transparentColorAnim.start() + else + colorAnim.start(); + control.isHoveredExpanded = false; + } } - background: Rectangle { - implicitWidth: parent.implicitWidth - implicitHeight: 36 - visible: control.down || control.highlighted - color: control.down ? control.palette.midlight : control.palette.light + background: Item { + anchors.fill: parent + // visible: control.down || control.highlighted + // color: control.down ? control.palette.midlight : control.palette.light } } diff --git a/ukui-qqc2-style/org.ukui.style/RoundButton.qml b/ukui-qqc2-style/org.ukui.style/RoundButton.qml index 5544b78..6f7c8de 100644 --- a/ukui-qqc2-style/org.ukui.style/RoundButton.qml +++ b/ukui-qqc2-style/org.ukui.style/RoundButton.qml @@ -30,10 +30,10 @@ T.RoundButton { implicitWidth: { var contentwidth = implicitContentWidth + leftPadding + rightPadding return Math.max(implicitBackgroundWidth + leftInset + rightInset, - contentwidth) + contentwidth, 36) } implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - implicitContentHeight + topPadding + bottomPadding) + implicitContentHeight + topPadding + bottomPadding, 36) leftPadding: StylePrivate.UKUIButton.margin rightPadding: StylePrivate.UKUIButton.margin @@ -41,20 +41,34 @@ T.RoundButton { hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? - font: StylePrivate.APPParameter.font + font: app.font + radius: height/2 + palette: app.palette NormalControlColor{ id:ncColor } + StylePrivate.APPParameter{ + id: app + + } + onEnabledChanged: { + content.updateImage() + back.changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) + } + onPressedChanged: content.updateImage() contentItem: ButtonIconLabelContent { + id: content controlRoot: controlRoot anchors.centerIn: controlRoot // onWidthChanged: console.log(controlRoot.text, width) } background: BackGroundRectangle{ + id: back controlRoot: controlRoot - _radius: controlRoot.height/2 + _radius: controlRoot.radius anchors.fill: parent } diff --git a/ukui-qqc2-style/org.ukui.style/ScrollBar.qml b/ukui-qqc2-style/org.ukui.style/ScrollBar.qml index 2b78b46..14d6d13 100644 --- a/ukui-qqc2-style/org.ukui.style/ScrollBar.qml +++ b/ukui-qqc2-style/org.ukui.style/ScrollBar.qml @@ -20,7 +20,7 @@ * */ -import QtQuick 2.12 +import QtQuick 2.14 import QtQuick.Controls 2.12 import QtQuick.Controls.impl 2.12 import QtQuick.Templates 2.12 as T @@ -42,9 +42,16 @@ T.ScrollBar { padding: scrollbar.padding visible: control.policy !== ScrollBar.AlwaysOff - - property var itemColor: !control.enabled ? scrollbar.disableColor : control.pressed ? scrollbar.clickColor : - control.hovered ? scrollbar.hoverColor : scrollbar.normalColor + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var itemColor: !control.enabled ? (isTransaprent ? scrollbar.disableTransparentColor : scrollbar.disableColor) : + control.pressed ? (isTransaprent ? scrollbar.clickTransparentColor : scrollbar.clickColor) : + control.hovered ? (isTransaprent ? scrollbar.hoverTransparentColor : scrollbar.hoverColor) : + (isTransaprent ? scrollbar.normalTransparentColor : scrollbar.normalColor) ParseInterface{ id: parseInterface } @@ -59,18 +66,37 @@ T.ScrollBar { } contentItem: Rectangle { - implicitWidth: control.interactive ? 4 : 2 - implicitHeight: control.interactive ? 4 : 2 - - radius: width / 2 + // 区分横向/纵向:纵向改宽度,横向改高度 + implicitWidth: control.orientation === Qt.Vertical + ? (control.interactive ? (control.hovered || control.pressed ? 8 : 4) : 2) + : 0 // 横向宽度由滚动区域决定 + implicitHeight: control.orientation === Qt.Horizontal + ? (control.interactive ? (control.hovered || control.pressed ? 8 : 4) : 2) + : 0 // 纵向高度由滚动区域决定 + + radius: control.orientation === Qt.Vertical ? width / 2 : height / 2 // 圆角随动态尺寸变化 color: gradientRec.visible ? "transparent" : getStartColor(itemColor) + // 根据方向设置动画:纵向动画宽度,横向动画高度 + Behavior on implicitWidth { + NumberAnimation { + duration: 260 + easing.type: Easing.OutExpo + } + } + Behavior on implicitHeight { + NumberAnimation { + duration: 260 + easing.type: Easing.OutExpo + } + } + Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color +// border.width: parent.border.width +// border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(itemColor) } @@ -81,7 +107,7 @@ T.ScrollBar { states: State { name: "active" - when: control.policy === ScrollBar.AlwaysOn || (control.active && control.size < 1.0) + when: /*control.policy === ScrollBar.AlwaysOn || */(control.active && (control.hovered || control.pressed) && control.size < 1.0) PropertyChanges { target: control.contentItem; implicitWidth:8; implicitHeight:8} } } @@ -93,6 +119,23 @@ T.ScrollBar { StylePrivate.APPParameter{ id: app } + + WheelHandler{ + onWheel: { + var delta = event.angleDelta.y + if(control.mirrored || event.inverted){ + delta = -1 * delta; + } + + if(delta < 0){ + control.increase() + } + else if(delta > 0){ + control.decrease() + } + } + + } } diff --git a/ukui-qqc2-style/org.ukui.style/Slider.qml b/ukui-qqc2-style/org.ukui.style/Slider.qml index e4391a0..b287ba5 100644 --- a/ukui-qqc2-style/org.ukui.style/Slider.qml +++ b/ukui-qqc2-style/org.ukui.style/Slider.qml @@ -20,9 +20,10 @@ * */ -import QtQuick 2.12 +import QtQuick 2.14 import QtQuick.Controls 2.12 import QtQuick.Controls.impl 2.12 +import QtGraphicalEffects 1.14 import QtQuick.Templates 2.12 as T import org.ukui.qqc2style.private 1.0 as StylePrivate @@ -37,6 +38,9 @@ T.Slider { padding: slider.padding hoverEnabled: true + palette: app.palette + stepSize: 0.1 + property var touchSlider : control.hasOwnProperty("sliderType") ? (control.sliderType === "touchSlider" ? true : false): false @@ -60,27 +64,127 @@ T.Slider { return parseInterface.pEndColor(dtcolor) } - handle: Rectangle { - id: handleRec - x: touchSlider ? (control.leftPadding + (control.horizontal ? - control.visualPosition * (control.availableWidth - slider.touchHandleWidth) : (control.availableWidth - width) / 2)) : - (control.leftPadding + (control.horizontal ? - control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)) + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + + //opacity: control.enabled ? 1 : 0.45 + + handle: Item{ + x: { + if (control.horizontal) { + return control.leftPadding + control.visualPosition * (control.availableWidth - width) + } else { + return (control.availableWidth - width) / 2 + } + } y: touchSlider ? (control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - 15))) : (control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))) - implicitWidth: touchSlider ? (control.horizontal ? (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15) < slider.touchHandleWidth ? - (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15)) : slider.touchHandleWidth) : slider.touchHandleHeight) : slider.handleHeight - implicitHeight: touchSlider ? (control.horizontal ? slider.touchHandleHeight : - (15 + (1-control.visualPosition) * (control.availableHeight - 15) < slider.touchHandleWidth ? - (15 + (1-control.visualPosition) * (control.availableHeight - 15)) : slider.touchHandleWidth)) : slider.handleHeight + // implicitWidth: touchSlider ? (control.horizontal ? (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15) < slider.touchHandleWidth ? + // (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15)) : slider.touchHandleWidth) : slider.touchHandleHeight) : + // ((pressed || hovered) ? slider.handleHoverHeight : slider.handleHeight) + // implicitHeight: touchSlider ? (control.horizontal ? slider.touchHandleHeight : + // (15 + (1-control.visualPosition) * (control.availableHeight - 15) < slider.touchHandleWidth ? + // (15 + (1-control.visualPosition) * (control.availableHeight - 15)) : slider.touchHandleWidth)) : + // ((pressed || hovered) ? slider.handleHoverHeight : slider.handleHeight) + property real normalWidth: touchSlider ? + (control.horizontal ? + // RTL 时用 1 - visualPosition 反转尺寸变化方向 + (15 + (control.mirrored ? (1 - control.visualPosition) : control.visualPosition) * (control.availableWidth - 15) > slider.touchHandleWidth ? + slider.touchHandleWidth : (15 + (control.mirrored ? (1 - control.visualPosition) : control.visualPosition) * (control.availableWidth - 15))) : + slider.touchHandleHeight) : + slider.handleHeight + property real normalHeight: touchSlider ? + (control.horizontal ? slider.touchHandleHeight : + (15 + (1-control.visualPosition) * (control.availableHeight - 15) < slider.touchHandleWidth ? + (15 + (1-control.visualPosition) * (control.availableHeight - 15)) : slider.touchHandleWidth)) : + slider.handleHeight + + implicitWidth: normalWidth + implicitHeight: normalHeight + property bool hovered: handleRec.hovered || mouseArea.containsMouse + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + propagateComposedEvents: true + onPressed: mouse.accepted = false + } + + Rectangle{ + anchors.fill: handleRec + visible: !touchSlider && !control.enabled + color: getStartColor(slider.touchHandleBaseColor) + radius: handleRec.radius + } + Rectangle { + id: handleRec + opacity: control.enabled ? 1 : 0.45 + anchors.fill: parent + + // x: touchSlider ? (control.leftPadding + (control.horizontal ? + // control.visualPosition * (control.availableWidth - slider.touchHandleWidth) : (control.availableWidth - width) / 2)) : + // (control.leftPadding + (control.horizontal ? + // control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)) + // y: touchSlider ? (control.topPadding + (control.horizontal ? + // (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - 15))) : + // (control.topPadding + (control.horizontal ? + // (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))) + // implicitWidth: touchSlider ? (control.horizontal ? (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15) < slider.touchHandleWidth ? + // (15 + control.visualPosition * (control.availableWidth - /*slider.touchHandleWidth*/15)) : slider.touchHandleWidth) : slider.touchHandleHeight) : + // ((pressed || hovered) ? slider.handleHoverHeight : slider.handleHeight) + // implicitHeight: touchSlider ? (control.horizontal ? slider.touchHandleHeight : + // (15 + (1-control.visualPosition) * (control.availableHeight - 15) < slider.touchHandleWidth ? + // (15 + (1-control.visualPosition) * (control.availableHeight - 15)) : slider.touchHandleWidth)) : + // ((pressed || hovered) ? slider.handleHoverHeight : slider.handleHeight) radius: touchSlider ? 20 : width / 2 - color: gradientHandleRec.visible ? "transparent" : getStartColor(!control.enabled ? slider.disableHandleColor : pressed ? slider.clickHandleColor : - hovered ? slider.hoverHandleColor : slider.normalHandleColor) + color: touchSlider ? (gradientHandleRec.visible ? "transparent" : getStartColor(!control.enabled ? /*slider.disableGrooveColor*/"transparent" : slider.normalGrooveColor)) : + (gradientHandleRec.visible ? "transparent" : getStartColor(!control.enabled ? slider.disableHandleColor : pressed ? slider.clickHandleColor : + hovered ? slider.hoverHandleColor : slider.normalHandleColor)) border.width: touchSlider ? 0 : slider.handleBorderWidth border.color: getStartColor(!control.enabled ? slider.disableHandleBorderColor : pressed ? slider.clickHandleBorderColor : hovered ? slider.hoverHandleBorderColor : slider.normalHandleBorderColor) + scale: 1.0 + states: [ + State { + name: "HOVERED" + when: !touchSlider && !control.pressed && control.hovered + PropertyChanges { target: handleRec; scale: 1.125 } + }, + State { + name: "PRESSED" + when: !touchSlider && control.pressed + PropertyChanges { + target: handleRec + scale: 1.0 + border.width: slider.handleBorderWidth * 1.25 + } + } + ] + + transitions: [ + Transition { + from: "*"; to: "HOVERED" + reversible: true + ParallelAnimation { + NumberAnimation { property: "scale"; duration: 100; easing.type: Easing.InOutSine } + } + }, + Transition { + from: "*"; to: "PRESSED" + reversible: true + ParallelAnimation { + NumberAnimation { property: "scale"; duration: 100; easing.type: Easing.InOutSine } + NumberAnimation { property: "border.width"; duration: 100; easing.type: Easing.Linear } + } + } + ] Rectangle{ id: gradientHandleRec @@ -100,44 +204,50 @@ T.Slider { } Rectangle{ - anchors.right: parent.right - anchors.rightMargin: control.horizontal ? 6 : (parent.width - width) / 2 - anchors.top: parent.top - anchors.topMargin: control.horizontal ? (parent.height - height) / 2 : 6 + anchors.left: control.mirrored ? parent.left : undefined + anchors.leftMargin: control.mirrored ? 6 : undefined + anchors.right: control.mirrored ? undefined : parent.right + anchors.rightMargin: control.mirrored ? undefined : 6 + + anchors.horizontalCenter: control.horizontal ? undefined : parent.horizontalCenter + anchors.top: control.horizontal ? undefined : parent.top + anchors.topMargin: control.horizontal ? undefined : 6 + anchors.verticalCenter: control.horizontal ? parent.verticalCenter : undefined + visible: touchSlider width: control.horizontal ? 3 : 6 - height: control.horizontal ? 6: 3 + height: control.horizontal ? 6 : 3 color: slider.touchHandleColor } } +} background: Item{ id: item + implicitWidth: control.horizontal ? (slider.normalWidth /*+ (touchSlider ? 15 : 0)*/) : slider.normalHeight + implicitHeight: control.horizontal ? slider.normalHeight : (slider.normalWidth + (touchSlider ? 0 : 24)) - implicitWidth: control.horizontal ? (slider.normalWidth + (touchSlider ? 15 : handle.width)) : slider.normalHeight - implicitHeight: control.horizontal ? slider.normalHeight : (slider.normalWidth + (touchSlider ? 0 : handle.height)) Rectangle { width: item.width height: item.height - //border.color: getStartColor(slider.focusBorderColor) - //border.width: control.activeFocus ? slider.focusBorderWidth : 0 - scale: control.horizontal && control.mirrored ? -1 : 1 + anchors.centerIn: parent + // scale: control.horizontal && control.mirrored ? -1 : 1 color: "transparent" + opacity: control.enabled ? 1: 0.45 Rectangle{ id: unGroove - x: touchSlider ? (control.horizontal ? 0 : ((item.width - width) / 2)) : (control.horizontal ? handle.width / 2 : ((item.width - width) / 2)) - y: touchSlider ? (control.horizontal ? ((item.height - height) / 2) : 0) : (control.horizontal ? ((item.height - height) / 2) : handle.height / 2) - width: touchSlider ? (control.horizontal ? parent.width : slider.touchGrooveHeight) : - (control.horizontal ? (item.width - handle.width) : slider.grooveHeight) - height: touchSlider ? (control.horizontal ? slider.touchGrooveHeight : parent.height) : - (control.horizontal ? slider.grooveHeight : (item.height - handle.height)) + x: touchSlider ? (control.horizontal ? 0 : ((item.width - width) / 2)) : (control.horizontal ? 0 : (item.width - width) / 2) + y: touchSlider ? (control.horizontal ? ((item.height - height) / 2) : 0) : (control.horizontal ? ((item.height - height) / 2) : (0)) + width: touchSlider ? (control.horizontal ? parent.width : slider.touchGrooveHeight) : (control.horizontal ? parent.width : slider.grooveHeight) + height: touchSlider ? (control.horizontal ? slider.touchGrooveHeight : parent.height) : (control.horizontal ? slider.grooveHeight : parent.height) radius: touchSlider ? 20 : (control.horizontal ? height/2 : width/2) border.width: slider.grooveBorderWidth border.color: getStartColor(!control.enabled ? slider.disableUnGrooveBorderColor : slider.normalUnGrooveBorderColor) - color: gradientUNGrooveRec.visible ? "transparent" : getStartColor(!control.enabled ? slider.disableUnGrooveColor : slider.normalUnGrooveColor) + color: gradientUNGrooveRec.visible ? "transparent" : getStartColor(isTransaprent ? (!control.enabled ? slider.disableTransparentUnGrooveColor : slider.normalTransparentUnGrooveColor) : + (!control.enabled ? slider.disableUnGrooveColor : slider.normalUnGrooveColor)) Rectangle{ id: gradientUNGrooveRec @@ -147,7 +257,6 @@ T.Slider { border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(!control.enabled ? slider.disableUnGrooveColor : slider.normalUnGrooveColor) } - GradientStop { position: 1.0; color: getEndColor(!control.enabled ? slider.disableUnGrooveColor : slider.normalUnGrooveColor)} } visible: !parseInterface.isSolidPattern(!control.enabled ? slider.disableUnGrooveColor : slider.normalUnGrooveColor) @@ -156,14 +265,27 @@ T.Slider { Rectangle{ id:groove - width: touchSlider ? (control.horizontal ? (control.position * unGroove.width < slider.touchHandleWidth ? handle.width : - control.position * unGroove.width) : slider.touchGrooveHeight) : (control.horizontal ? control.position * unGroove.width : slider.grooveHeight) - height: touchSlider ? (control.horizontal ? slider.touchGrooveHeight : ((control.position * unGroove.height) < slider.touchHandleWidth ? - handle.height : (control.position * unGroove.height))) : (control.horizontal ? slider.grooveHeight : control.position * unGroove.height) + width: touchSlider ? + (control.horizontal ? + (control.mirrored ? (parent.width - handle.x) : (handle.x + handle.width)) : + slider.touchGrooveHeight) : + (control.horizontal ? + (control.mirrored ? (parent.width - handle.x) : (handle.x + handle.width)) : + slider.grooveHeight) + + height: touchSlider ? (control.horizontal ? slider.touchGrooveHeight : (parent.height - handle.y)/*((control.position * parent.height) < slider.touchHandleWidth ? + handle.height : (parent.height - handle.y))*/) : (control.horizontal ? slider.grooveHeight : (parent.height - handle.y - handle.height/2)) radius: touchSlider ? 20 : (control.horizontal ? height/2 : width/2) - anchors.left: unGroove.left - anchors.bottom: unGroove.bottom + x: touchSlider ? + (control.horizontal ? + (control.mirrored ? handle.x : 0) : + ((item.width - width) / 2)) : + (control.horizontal ? + (control.mirrored ? (parent.width - width) : 0) : + ((item.width - width) / 2)) + y: touchSlider ? (control.horizontal ? ((item.height - height) / 2) : handle.y) : (control.horizontal ? ((item.height - height) / 2) : (handle.y + handle.height/2)) + border.width: slider.grooveBorderWidth border.color: getStartColor(!control.enabled ? slider.disableGrooveBorderColor : slider.normalGrooveBorderColor) color: gradientGrooveRec.visible ? "transparent" : getStartColor(!control.enabled ? slider.disableGrooveColor : slider.normalGrooveColor) @@ -175,17 +297,21 @@ T.Slider { border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(!control.enabled ? slider.disableGrooveColor : slider.normalGrooveColor) } - GradientStop { position: 1.0; color: getEndColor(!control.enabled ? slider.disableGrooveColor : slider.normalGrooveColor)} } visible: !parseInterface.isSolidPattern(!control.enabled ? slider.disableGrooveColor : slider.normalGrooveColor) } +// Rectangle{ +// anchors.right: parent.right +// width: handle.width +// height: handle.height +// radius: handle.height/2 +// } } - // Rectangle { // id: handle // x: control.horizontal ? (control.position * control.width - width/2) : ((item.width - width) / 2) -// y: control.horizontal ? ((item.height - height) / 2) : (control.position * parent.height - height/2) +// y: control.horizontal ? ((item.height - height) / 2) : (control.visualPosition * parent.height - height/2) // width: slider.grooveHeight // height: slider.grooveHeight @@ -204,4 +330,49 @@ T.Slider { StylePrivate.APPParameter{ id: app } + + + Keys.onPressed: { + + switch(event.key){ + case Qt.Key_PageUp: + control.value = Math.min(control.value + 10 * control.stepSize, control.to) + break; + case Qt.Key_PageDown: + control.value = Math.max(control.value - 10 * control.stepSize, control.from) + break; + case Qt.Key_Down: + control.decrease() + break; + case Qt.Key_Up: + control.increase() + break; + case Qt.Key_Home: + control.value = control.from + break; + case Qt.Key_End: + control.value = control.to + break; + + } + } + + WheelHandler{ + onWheel: { + var delta = event.angleDelta.y + if(control.mirrored || event.inverted){ + delta = -1 * delta; + } + + if(delta > 0){ + //var r = Math.floor(control.value + Math.random() * 10) + control.value = Math.round(Math.min(control.value + 10 * Math.random() * delta/120, control.to)) + } + else if(delta < 0){ + control.value = Math.round(Math.max(control.value + 10 * Math.random() * delta/120, control.from)) + } + + + } + } } diff --git a/ukui-qqc2-style/org.ukui.style/SpinBox.qml b/ukui-qqc2-style/org.ukui.style/SpinBox.qml index c169d28..04b6f9c 100644 --- a/ukui-qqc2-style/org.ukui.style/SpinBox.qml +++ b/ukui-qqc2-style/org.ukui.style/SpinBox.qml @@ -42,17 +42,29 @@ T.SpinBox { rightPadding: padding + (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0)) font: app.font + palette: app.palette + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } property bool upHover: control.up.hovered property bool upClick: control.up.pressed property bool downHover: control.down.hovered property bool downClick: control.down.pressed property bool controlPress: false - property var backColor: !control.enabled ? spinbox.disableColor : !control.editable ? spinbox.normalColor : controlPress ? spinbox.clickColor : control.activeFocus ? spinbox.focusColor : - control.hovered ? spinbox.hoverColor : spinbox.normalColor - - property var backBorderColor: !control.enabled ? spinbox.disableBorderColor : control.activeFocus ? spinbox.focusBorderColor : - control.hovered ? spinbox.hoverBorderColor : spinbox.normalBorderColor + property var backColor: !isTransaprent ? (!control.enabled ? spinbox.disableColor : ((control.pressed || control.activeFocus)? spinbox.clickColor : + ((control.hovered && !control.upHover && !control.downHover) ? spinbox.hoverColor : spinbox.normalColor))) : + (!control.enabled ? spinbox.disableTransparentBC : + ((control.pressed || control.activeFocus)? spinbox.clickedTransparentBC : ((control.hovered && !control.upHover && !control.downHover) ? spinbox.hoveredTransparentBC : spinbox.normalTransparentBC))) + property var borderColor: !isTransaprent ? (!control.enabled ? spinbox.disableBorderColor : + ((control.activeFocus) ? spinbox.clickBorderColor : + (control.pressed ? spinbox.clickBorderColor : + ((control.hovered && !control.upHover && !control.downHover) ? spinbox.hoverBorderColor : spinbox.normalBorderColor)))) : + (!control.enabled ? spinbox.disableTransparentBorderColor : ((control.activeFocus) ? spinbox.clickedTransparentBorderColor : + (control.pressed ? spinbox.clickedTransparentBorderColor : ((control.hovered && !control.upHover && !control.downHover) ? spinbox.hoveredTransparentBorderColor : spinbox.normalTransparentBorderColor)))) ParseInterface{ id: parseInterface @@ -78,6 +90,16 @@ T.SpinBox { onDownClickChanged:{ downRadiusRec.canvas.requestPaint(); } + onValueChanged: { + upImage.source = upIconSource() + downImage.source = downIconSource() + control.update(); + } + onEnabledChanged: { + upImage.source = upIconSource() + downImage.source = downIconSource() + control.update(); + } validator: IntValidator { @@ -96,6 +118,8 @@ T.SpinBox { selectedTextColor: control.palette.highlightedText horizontalAlignment: Qt.AlignLeft verticalAlignment: Qt.AlignVCenter + anchors.left: control.mirrored ? upRadiusRec.right : control.left + anchors.leftMargin: StylePrivate.UKUITextFiled.leftRightPadding readOnly: !control.editable validator: control.validator @@ -107,31 +131,30 @@ T.SpinBox { z:3 implicitWidth: spinbox.btnNormalWidth //implicitHeight: control.height/2.0 - anchors.right: control.right - anchors.rightMargin: control.activeFocus ? spinbox.focusBorderWidth : spinbox.normalBorderWidth + anchors.right: control.mirrored ? undefined : control.right + anchors.rightMargin: control.mirrored ? undefined : (borderRec.border.color.a > 0 ? borderRec.border.width : 0) + anchors.left: control.mirrored ? control.left : undefined + anchors.leftMargin: control.mirrored ? (borderRec.border.color.a > 0 ? borderRec.border.width : 0) : undefined anchors.top: parent.top - anchors.topMargin: control.activeFocus ? spinbox.focusBorderWidth : spinbox.normalBorderWidth + anchors.topMargin: borderRec.border.color.a > 0 ? borderRec.border.width : 0 anchors.bottom: control.verticalCenter leftTopRadius: spinbox.radius rightTopRadius: spinbox.radius leftBottomRadius: 0 rightBottomRadius: 0 - backColor: (!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableColor : control.up.pressed ? spinbox.btnClickColor : - control.up.hovered ? spinbox.btnHoverColor : spinbox.btnNormalColor - borderColor: (!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableBorderColor : upClick ? spinbox.btnClickBorderColor : - upHover ? spinbox.btnHoverBorderColor : spinbox.btnNormalBorderColor - borderWidth: spinbox.btnBorderWidth + backColor: isTransaprent ? ((!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableTransparentColor : + control.up.pressed ? spinbox.btnClickTransparentColor : control.up.hovered ? + spinbox.btnHoverTransparentColor : spinbox.btnNormalTransparentColor) : + ((!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableColor : control.up.pressed ? spinbox.btnClickColor : + control.up.hovered ? spinbox.btnHoverColor : spinbox.btnNormalColor) Image { + id: upImage anchors.centerIn: parent - source: { - var model = (!upRadiusRec.enabled || !control.enabled) ? "disenable" : (app.isDark) ? "highlight" : "normal" - - var icon = "ukui-up-symbolic"; - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-up-symbolic.svg" - return "image://imageProvider/" + icon + "/" + model; - } + sourceSize.width: 16 + sourceSize.height: 16 + source: upIconSource() + cache: false } } @@ -142,32 +165,30 @@ T.SpinBox { //implicitHeight: control.height/2.0 anchors.top: control.verticalCenter - anchors.right: control.right - anchors.rightMargin: control.activeFocus ? spinbox.focusBorderWidth : spinbox.normalBorderWidth + anchors.right: control.mirrored ? undefined : control.right + anchors.rightMargin: control.mirrored ? undefined : (borderRec.border.color.a > 0 ? borderRec.border.width : 0) + anchors.left: control.mirrored ? control.left : undefined + anchors.leftMargin: control.mirrored ? (borderRec.border.color.a > 0 ? borderRec.border.width : 0) : undefined anchors.bottom: parent.bottom - anchors.bottomMargin: control.activeFocus ? spinbox.focusBorderWidth : spinbox.normalBorderWidth + anchors.bottomMargin: borderRec.border.color.a > 0 ? borderRec.border.width : 0 leftTopRadius: 0 rightTopRadius: 0 leftBottomRadius: spinbox.radius rightBottomRadius: spinbox.radius - backColor: (!downRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableColor : control.down.pressed ? spinbox.btnClickColor : - control.down.hovered ? spinbox.btnHoverColor : spinbox.btnNormalColor - borderColor: (!downRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableBorderColor : downClick ? spinbox.btnClickBorderColor : - downHover ? spinbox.btnHoverBorderColor : spinbox.btnNormalBorderColor - borderWidth: spinbox.btnBorderWidth - + backColor: isTransaprent ? ((!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableTransparentColor : + control.down.pressed ? spinbox.btnClickTransparentColor : control.down.hovered ? + spinbox.btnHoverTransparentColor : spinbox.btnNormalTransparentColor) : + ((!upRadiusRec.enabled || !control.enabled) ? spinbox.btnDisableColor : control.down.pressed ? spinbox.btnClickColor : + control.down.hovered ? spinbox.btnHoverColor : spinbox.btnNormalColor) Image { + id: downImage anchors.centerIn: parent - source: { - var model = (!downRadiusRec.enabled || !control.enabled) ? "disenable" : (app.isDark) ? "highlight" : "normal" - var icon = "ukui-down-symbolic"; - if(!app.themeHasIcon(icon)) - icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-down-symbolic.svg" - return "image://imageProvider/" + icon + "/" + model; - - } + sourceSize.width: 16 + sourceSize.height: 16 + source: downIconSource() + cache: false } } @@ -175,15 +196,11 @@ T.SpinBox { implicitWidth: spinbox.normalWidth implicitHeight: spinbox.normalHeight radius: spinbox.radius - border.width: control.activeFocus ? spinbox.focusBorderWidth : spinbox.normalBorderWidth color: !parseInterface.isSolidPattern(backColor) ? "transparent" : getStartColor(backColor) - border.color: getStartColor(backBorderColor) Rectangle{ id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(backColor) } @@ -191,6 +208,14 @@ T.SpinBox { } visible: !parseInterface.isSolidPattern(backColor) } + Rectangle{ + id: borderRec + anchors.fill: parent + radius: parent.radius + border.width: (control.activeFocus) ? spinbox.focusBorderWidth : spinbox.normalBorderWidth + border.color: getStartColor(borderColor) + color: "transparent" + } // MouseArea{ // id: mouseArea // anchors.fill: parent @@ -205,6 +230,34 @@ T.SpinBox { StylePrivate.APPParameter{ id: app + onParametryChanged:{ + upImage.source = upIconSource() + downImage.source = downIconSource() + control.update(); + } + onIconThemeChanged: { + upImage.source = "" + upImage.source = upIconSource() + downImage.source = "" + downImage.source = downIconSource() + } + } + + function upIconSource(){ + var model = ((!upRadiusRec.enabled || !control.enabled) && app.isDark) ? "highDisbale" : (!upRadiusRec.enabled || !control.enabled) ? "disenable" : (app.isDark) ? "highlight" : "normal" + + var icon = "ukui-up-symbolic"; + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-up-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model; + } + function downIconSource(){ + var model = ((!downRadiusRec.enabled || !control.enabled) && app.isDark) ? "highDisbale" : (!downRadiusRec.enabled || !control.enabled) ? "disenable" : (app.isDark) ? "highlight" : "normal" + var icon = "ukui-down-symbolic"; + if(!app.themeHasIcon(icon)) + icon = "file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-down-symbolic.svg" + return "image://imageProvider/" + icon + "/" + model; + } } diff --git a/ukui-qqc2-style/org.ukui.style/Switch.qml b/ukui-qqc2-style/org.ukui.style/Switch.qml index 0ed8f6a..d6073d6 100644 --- a/ukui-qqc2-style/org.ukui.style/Switch.qml +++ b/ukui-qqc2-style/org.ukui.style/Switch.qml @@ -37,9 +37,54 @@ T.Switch { padding: ukuiSwitch.padding spacing: 6 + hoverEnabled: true + palette: app.palette + font: app.font + + // 添加动画运行状态标志 + property bool animationRunning: false + + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var normalColor:ukuiSwitch.normalColor + property var tansparentNormalColor: ukuiSwitch.normalTransparentColor + property var tansparentNormalCheckColor: ukuiSwitch.checkedNormalColor + property var backColor: control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableColor : + control.pressed ? ukuiSwitch.checkedClickColor : + // 动画运行时忽略hover状态 + (animationRunning ? tansparentNormalCheckColor : + control.hovered ? ukuiSwitch.checkedHoverColor : tansparentNormalCheckColor)) + : (!control.enabled ? (isTransaprent ? ukuiSwitch.disableTransparentColor : ukuiSwitch.disableColor) : + control.pressed ? (isTransaprent ? ukuiSwitch.clickTransparentColor : ukuiSwitch.clickColor) : + // 动画运行时忽略hover状态 + (animationRunning ? (isTransaprent ? tansparentNormalColor : normalColor) : + control.hovered ? (isTransaprent ? ukuiSwitch.hoverTransparentColor : ukuiSwitch.hoverColor) : + (isTransaprent ? tansparentNormalColor : normalColor)) + ) + property var borderColor: control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableBorderColor : control.pressed ? ukuiSwitch.checkedClickBorderColor : + // 动画运行时忽略hover状态 + (animationRunning ? ukuiSwitch.checkedNormalBorderColor : + control.hovered ? ukuiSwitch.checkedHoverBorderColor : ukuiSwitch.checkedNormalBorderColor)) + : (!control.enabled ? (isTransaprent ? ukuiSwitch.disableTransparentBorderColor : ukuiSwitch.disableBorderColor) : + control.pressed ? (isTransaprent ? ukuiSwitch.clickTransparentBorderColor : ukuiSwitch.clickBorderColor) : + // 动画运行时忽略hover状态 + (animationRunning ? (isTransaprent ? ukuiSwitch.normalTransparentBorderColor : ukuiSwitch.normalBorderColor) : + control.hovered ? (isTransaprent ? ukuiSwitch.hoverTransparentBorderColor : ukuiSwitch.hoverBorderColor) : + (isTransaprent ? ukuiSwitch.normalTransparentBorderColor : ukuiSwitch.normalBorderColor)) + ) StylePrivate.UKUISwitch{ - id: ukuiSwitch + id: ukuiSwitch + } + StylePrivate.UKUILabel{ + id: label + } + StylePrivate.APPParameter{ + id: app } ParseInterface{ id: parseInterface @@ -62,39 +107,141 @@ T.Switch { y: control.topPadding + (control.availableHeight - height) / 2 radius: implicitHeight/2 -// leftPadding: 0 -// rightPadding: 0 -// padding: ukuiSwitch.padding - color: getStartColor(control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableColor : control.pressed ? ukuiSwitch.checkedClickColor : control.hovered ? ukuiSwitch.checkedHoverColor : ukuiSwitch.checkedNormalColor) - : (!control.enabled ? ukuiSwitch.disableColor : control.pressed ? ukuiSwitch.clickColor : control.hovered ? ukuiSwitch.hoverColor : ukuiSwitch.normalColor)) + color: gradientRec.visible ? "transparent" : getStartColor(backColor) - border.color: getStartColor(control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableBorderColor : control.pressed ? ukuiSwitch.checkedClickBorderColor : control.hovered ? ukuiSwitch.checkedHoverBorderColor : ukuiSwitch.checkedNormalBorderColor) - : (!control.enabled ? ukuiSwitch.disableBorderColor : control.pressed ? ukuiSwitch.clickBorderColor : control.hovered ? ukuiSwitch.hoverColor : ukuiSwitch.normalBorderColor)) + ColorAnimation { + id: tansparentColorAnim + target: control + property: "tansparentNormalCheckColor" + from:ukuiSwitch.normalTransparentColor + to: ukuiSwitch.checkedNormalColor + duration: 200 + easing.type: Easing.Linear + running: false + // 动画运行状态同步 + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } + + ColorAnimation { + id: tansparentColorReturnAnim + target: control + property: "tansparentNormalColor" + from: ukuiSwitch.checkedNormalColor + to: ukuiSwitch.normalTransparentColor + duration: 200 + easing.type: Easing.Linear + running: false + // 动画运行状态同步 + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } + ColorAnimation { + id: normalColorAnim + target: control + property: "tansparentNormalCheckColor" + from:ukuiSwitch.normalColor + to: ukuiSwitch.checkedNormalColor + duration: 200 + easing.type: Easing.Linear + running: false + // 动画运行状态同步 + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } + ColorAnimation { + id: normalColorReturnAnim + target: control + property: "normalColor" + from: ukuiSwitch.checkedNormalColor + to: ukuiSwitch.normalColor + duration: 200 + easing.type: Easing.Linear + running: false + // 动画运行状态同步 + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } - border.width: ukuiSwitch.borderWidth + Rectangle{ + id: gradientRec + anchors.fill: parent + radius: parent.radius + gradient: Gradient { + id:gradient + GradientStop { position: 0.0; color: getStartColor(backColor) } + GradientStop { position: 1.0; color: getEndColor(backColor)} + } + visible: !parseInterface.isSolidPattern(backColor) + } + Rectangle{ + anchors.fill: parent + radius: parent.radius + color: "transparent" + border.color: getStartColor(borderColor) + border.width: ukuiSwitch.borderWidth + } Rectangle { x: Math.max(ukuiSwitch.indicatorLeftRightPadding, Math.min(parent.width - width - ukuiSwitch.indicatorLeftRightPadding, control.visualPosition * parent.width - (width / 2) - ukuiSwitch.indicatorLeftRightPadding)) - y: (parent.height - height) / 2 + anchors.verticalCenter: parent.verticalCenter width: ukuiSwitch.indicatorWidth height: ukuiSwitch.indicatorWidth radius: height/2 color: getStartColor(!control.enabled ? ukuiSwitch.disableIndicatorColor : ukuiSwitch.normalIndicatorColor) -// border.width: control.visualFocus ? 2 : 1 -// border.color: control.visualFocus ? control.palette.highlight : control.enabled ? control.palette.mid : control.palette.midlight Behavior on x { enabled: !control.down - SmoothedAnimation { velocity: 200 } + NumberAnimation { + duration: 260 + easing.type: Easing.OutExpo + } } } } - contentItem: Label { + contentItem: Text { leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 text: control.text -// font: control.font + font: control.font + color: parseInterface.pStartColor(enabled ? label.normalColor : label.disableColor) + // color: control.palette.windowText + } + + onCheckedChanged: { + // 先停止所有可能正在运行的动画 + tansparentColorAnim.stop() + tansparentColorReturnAnim.stop() + normalColorAnim.stop() + normalColorReturnAnim.stop() + + // 根据开关状态和透明度属性选择对应的动画 + if (checked) { + // 开关打开状态 + if (isTransaprent) { + tansparentColorAnim.running = true + } else { + normalColorAnim.running = true + } + } else { + // 开关关闭状态 + if (isTransaprent) { + tansparentColorReturnAnim.running = true + } else { + normalColorReturnAnim.running = true + } + } + } + } diff --git a/ukui-qqc2-style/org.ukui.style/SwitchDelegate.qml b/ukui-qqc2-style/org.ukui.style/SwitchDelegate.qml index 9897ce3..bc38125 100644 --- a/ukui-qqc2-style/org.ukui.style/SwitchDelegate.qml +++ b/ukui-qqc2-style/org.ukui.style/SwitchDelegate.qml @@ -30,20 +30,66 @@ T.SwitchDelegate { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - implicitContentWidth + leftPadding + rightPadding) + implicitContentWidth + implicitIndicatorWidth + spacing + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, implicitIndicatorHeight + topPadding + bottomPadding) padding: ukuiSwitch.padding - spacing: 12 - -// icon.width: 24 -// icon.height: 24 -// icon.color: control.palette.text + spacing: 8 + hoverEnabled: true + font: app.font + palette: app.palette + + // 添加动画运行状态标志 + property bool animationRunning: false + + // 动效相关颜色属性 + property var normalColor: ukuiSwitch.normalColor + property var tansparentNormalColor: ukuiSwitch.normalTransparentColor + property var tansparentNormalCheckColor: ukuiSwitch.checkedNormalColor + + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } - StylePrivate.UKUISwitch{ - id: ukuiSwitch + property var backColor: control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableColor : + control.pressed ? ukuiSwitch.checkedClickColor : + // 动画运行时忽略hover + (animationRunning ? tansparentNormalCheckColor : + control.hovered ? ukuiSwitch.checkedHoverColor : tansparentNormalCheckColor)) + : (!control.enabled ? (isTransaprent ? ukuiSwitch.disableTransparentColor : ukuiSwitch.disableColor) : + control.pressed ? (isTransaprent ? ukuiSwitch.clickTransparentColor : ukuiSwitch.clickColor) : + // 动画运行时忽略hover + (animationRunning ? (isTransaprent ? tansparentNormalColor : normalColor) : + control.hovered ? (isTransaprent ? ukuiSwitch.hoverTransparentColor : ukuiSwitch.hoverColor) : + (isTransaprent ? tansparentNormalColor : normalColor)) + ) + + property var borderColor: control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableBorderColor : + control.pressed ? ukuiSwitch.checkedClickBorderColor : + // 动画运行时忽略hover + (animationRunning ? ukuiSwitch.checkedNormalBorderColor : + control.hovered ? ukuiSwitch.checkedHoverBorderColor : ukuiSwitch.checkedNormalBorderColor)) + : (!control.enabled ? (isTransaprent ? ukuiSwitch.disableTransparentBorderColor : ukuiSwitch.disableBorderColor) : + control.pressed ? (isTransaprent ? ukuiSwitch.clickTransparentBorderColor : ukuiSwitch.clickBorderColor) : + // 动画运行时忽略hover + (animationRunning ? (isTransaprent ? ukuiSwitch.normalTransparentBorderColor : ukuiSwitch.normalBorderColor) : + control.hovered ? (isTransaprent ? ukuiSwitch.hoverTransparentBorderColor : ukuiSwitch.hoverBorderColor) : + (isTransaprent ? ukuiSwitch.normalTransparentBorderColor : ukuiSwitch.normalBorderColor)) + ) + + StylePrivate.UKUISwitch { + id: ukuiSwitch + } + StylePrivate.UKUILabel { + id: label + } + StylePrivate.APPParameter{ + id: app } ParseInterface{ id: parseInterface @@ -58,6 +104,7 @@ T.SwitchDelegate { return parseInterface.pEndColor(dtcolor) } + indicator: Rectangle { implicitWidth: ukuiSwitch.recWidth implicitHeight: ukuiSwitch.recHeight @@ -66,48 +113,127 @@ T.SwitchDelegate { y: control.topPadding + (control.availableHeight - height) / 2 radius: implicitHeight/2 -// leftPadding: 0 -// rightPadding: 0 -// padding: (height - 16) / 2 - color: getStartColor(control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableColor : control.pressed ? ukuiSwitch.checkedClickColor : control.hovered ? ukuiSwitch.checkedHoverColor : ukuiSwitch.checkedNormalColor) - : (!control.enabled ? ukuiSwitch.disableColor : control.pressed ? ukuiSwitch.clickColor : control.hovered ? ukuiSwitch.hoverColor : ukuiSwitch.normalColor)) + color: gradientRec.visible ? "transparent" : getStartColor(backColor) + + ColorAnimation { + id: tansparentColorAnim + target: control + property: "tansparentNormalCheckColor" + from: ukuiSwitch.normalTransparentColor + to: ukuiSwitch.checkedNormalColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } + + ColorAnimation { + id: tansparentColorReturnAnim + target: control + property: "tansparentNormalColor" + from: ukuiSwitch.checkedNormalColor + to: ukuiSwitch.normalTransparentColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } + + ColorAnimation { + id: normalColorAnim + target: control + property: "tansparentNormalCheckColor" + from: ukuiSwitch.normalColor + to: ukuiSwitch.checkedNormalColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } - border.color: getStartColor(control.checked ? (!control.enabled ? ukuiSwitch.checkedDisableBorderColor : control.pressed ? ukuiSwitch.checkedClickBorderColor : control.hovered ? ukuiSwitch.checkedHoverBorderColor : ukuiSwitch.checkedNormalBorderColor) - : (!control.enabled ? ukuiSwitch.disableBorderColor : control.pressed ? ukuiSwitch.clickBorderColor : control.hovered ? ukuiSwitch.hoverColor : ukuiSwitch.normalBorderColor)) + ColorAnimation { + id: normalColorReturnAnim + target: control + property: "normalColor" + from: ukuiSwitch.checkedNormalColor + to: ukuiSwitch.normalColor + duration: 200 + easing.type: Easing.Linear + running: false + onRunningChanged: { + control.animationRunning = running; + if (!running) control.update() + } + } - border.width: ukuiSwitch.borderWidth + Rectangle { + id: gradientRec + anchors.fill: parent + radius: parent.radius + gradient: Gradient { + GradientStop { position: 0.0; color: getStartColor(backColor) } + GradientStop { position: 1.0; color: getEndColor(backColor) } + } + visible: !parseInterface.isSolidPattern(backColor) + } + Rectangle{ + anchors.fill: parent + radius: parent.radius + color: "transparent" + border.color: getStartColor(borderColor) + border.width: ukuiSwitch.borderWidth + } Rectangle { x: Math.max(ukuiSwitch.indicatorLeftRightPadding, Math.min(parent.width - width - ukuiSwitch.indicatorLeftRightPadding, control.visualPosition * parent.width - (width / 2) - ukuiSwitch.indicatorLeftRightPadding)) - y: (parent.height - height) / 2 + anchors.verticalCenter: parent.verticalCenter width: ukuiSwitch.indicatorWidth height: ukuiSwitch.indicatorWidth radius: height/2 color: getStartColor(!control.enabled ? ukuiSwitch.disableIndicatorColor : ukuiSwitch.normalIndicatorColor) -// border.width: control.visualFocus ? 2 : 1 -// border.color: control.visualFocus ? control.palette.highlight : control.enabled ? control.palette.mid : control.palette.midlight Behavior on x { enabled: !control.down - SmoothedAnimation { velocity: 200 } + NumberAnimation { + duration: 260 + easing.type: Easing.OutExpo + } } } } contentItem: IconLabelContent { id: iconLabel - - controlRoot: control - anchors.left: control.left - leftSpace: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.right: control.right + anchors.leftMargin: control.mirrored ? control.indicator.width + control.spacing : control.leftPadding + anchors.rightMargin: !control.mirrored ? control.indicator.width + control.spacing : control.rightPadding + controlRoot: control + implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) + } - implicitWidth: iconLabel.adjustWidth(control.leftPadding + control.rightPadding) + indicator.implicitWidth + control.spacing + background: Item { + anchors.fill: parent } - background: Rectangle { - implicitWidth: parent.implicitWidth - implicitHeight: parent.implicitHeight - visible: control.down || control.highlighted - color: control.down ? control.palette.midlight : control.palette.light + onCheckedChanged: { + tansparentColorAnim.stop() + tansparentColorReturnAnim.stop() + normalColorAnim.stop() + normalColorReturnAnim.stop() + + if (checked) { + isTransaprent ? tansparentColorAnim.start() : normalColorAnim.start() + } else { + isTransaprent ? tansparentColorReturnAnim.start() : normalColorReturnAnim.start() + } } } diff --git a/ukui-qqc2-style/org.ukui.style/TabBar.qml b/ukui-qqc2-style/org.ukui.style/TabBar.qml index e430ad7..a191dc4 100644 --- a/ukui-qqc2-style/org.ukui.style/TabBar.qml +++ b/ukui-qqc2-style/org.ukui.style/TabBar.qml @@ -33,6 +33,7 @@ T.TabBar { contentHeight + topPadding + bottomPadding) spacing: 1 + palette: app.palette ParseInterface{ id: parseInterface } @@ -64,20 +65,7 @@ T.TabBar { background: Rectangle { id: back anchors.fill: control - color: gradientRec.visible ? "transparent" : getStartColor(tabbar.normalColor) - Rectangle{ - id: gradientRec - anchors.fill: parent - radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color - gradient: Gradient { - GradientStop { position: 0.0; color: getStartColor(tabbar.normalColor)} - - GradientStop { position: 1.0; color: getEndColor(tabbar.normalColor)} - } - visible: !parseInterface.isSolidPattern(tabbar.normalColor) - } + color: "transparent" } StylePrivate.UKUITabBar{ diff --git a/ukui-qqc2-style/org.ukui.style/TabButton.qml b/ukui-qqc2-style/org.ukui.style/TabButton.qml index 4005e32..8424542 100644 --- a/ukui-qqc2-style/org.ukui.style/TabButton.qml +++ b/ukui-qqc2-style/org.ukui.style/TabButton.qml @@ -44,14 +44,18 @@ T.TabButton { font: app.font + palette: app.palette - property var borderColor: controlRoot.checked ? tabbutton.checkedBorderColor : controlRoot.pressed ? - tabbutton.clickBorderColor : controlRoot.hovered ? - tabbutton.hoverBorderColor : tabbutton.normalBorderColor - - property var backColor: controlRoot.checked ? tabbutton.checkedColor : controlRoot.pressed ? - tabbutton.clickedColor : controlRoot.hovered ? - tabbutton.hoverColor : tabbutton.normalColor + property var isTransaprent:{ + if(controlRoot.hasOwnProperty("transparent")) + return controlRoot.transparent + else + return true + } + property var backColor: controlRoot.checked ? (isTransaprent ? tabbutton.checkedTransparentColor : tabbutton.checkedColor) : controlRoot.pressed ? + (isTransaprent ? tabbutton.clickedTransparentColor : tabbutton.clickedColor) : controlRoot.hovered ? + (isTransaprent ? tabbutton.hoverTransparentColor : tabbutton.hoverColor) : + (isTransaprent ? tabbutton.normalTransparentColor : tabbutton.normalColor) // property var backcolor: checked ? "blue" : pressed ? "green" : hovered ? "red" : "yellow" ParseInterface{ @@ -81,7 +85,7 @@ T.TabButton { id: canvas anchors.fill: parent onPaint: { - var radius = controlRoot.checked ? 8 : 0; + var radius = 12; var ctx = getContext("2d"); ctx.reset(); // 重置画布状态 var gradient = ctx.createLinearGradient(canvas.x, canvas.y, canvas.width, canvas.height) @@ -91,7 +95,7 @@ T.TabButton { ctx.fillStyle = gradient; ctx.beginPath(); - if(controlRoot.checked || controlRoot.pressed){ + // if(controlRoot.checked || controlRoot.pressed){ // 绘制第一段圆弧路径 ctx.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2); // 绘制第一段直线路径 @@ -104,17 +108,17 @@ T.TabButton { ctx.lineTo(x, height + y); // 绘制第四段直线路径 ctx.lineTo(x, y + radius); - } - else{ + // } + // else{ // // 绘制第一段圆弧路径 // ctx.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2); // 绘制第一段直线路径 - ctx.moveTo(x, y); + // ctx.moveTo(x, y); // 绘制第二段直线路径 - ctx.lineTo(x + width, y); - ctx.lineTo(x + width, y + height); - ctx.lineTo(x, y + height); - ctx.lineTo(x, y); + // ctx.lineTo(x + width, y); + // ctx.lineTo(x + width, y + height); + // ctx.lineTo(x, y + height); + // ctx.lineTo(x, y); // // 绘制第二段圆弧路径 // ctx.arc(width - radius + x, radius + y, radius, Math.PI * 3 / 2, Math.PI * 2); @@ -124,14 +128,14 @@ T.TabButton { // ctx.lineTo(width + x - radius, y); - } + // } ctx.closePath(); ctx.fill(); - if(getStartColor(borderColor).alpha >= 0.0){ + if(getStartColor(tabbutton.focusBorderColor).alpha >= 0.0 && app.focusEnable){ ctx.lineWidth = tabbutton.borderWidth; - ctx.strokenStyle = getStartColor(borderColor); + ctx.strokenStyle = getStartColor(tabbutton.focusBorderColor); ctx.stroke(); } @@ -154,5 +158,6 @@ T.TabButton { StylePrivate.APPParameter{ id: app + onParametryChanged: canvas.requestPaint() } } diff --git a/ukui-qqc2-style/org.ukui.style/TextArea.qml b/ukui-qqc2-style/org.ukui.style/TextArea.qml new file mode 100644 index 0000000..6c97a04 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/TextArea.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Layouts 1.3 +import QtQuick.Templates 2.12 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate + +T.TextArea { + id: control + + implicitWidth: Math.max(contentWidth + leftPadding + rightPadding, + implicitBackgroundWidth + leftInset + rightInset, + placeholder.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(contentHeight + topPadding + bottomPadding, + implicitBackgroundHeight + topInset + bottomInset, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: textfield.leftRightPadding + leftPadding: padding + + color: getStartColor(!control.enabled ? textfield.disableTextColor : textfield.normalTextColor) + selectionColor: getStartColor(textfield.focusBorderColor) + selectedTextColor: control.palette.highlightedText + placeholderTextColor: getStartColor(!control.enabled ? textfield.placeHolderDisableTextColor : textfield.placeHolderNormalTextColor) + font: app.font + hoverEnabled: true + selectByMouse: true + wrapMode: TextArea.Wrap + Layout.fillWidth: true + Layout.fillHeight: true + palette: app.palette + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var backColor: !control.enabled ? (isTransaprent ? textfield.disableTransparentBC : textfield.disableBC) : + (control.activeFocus) ? (isTransaprent ? textfield.inputNormalTransparentBC : textfield.inputNormalBC) : + click ? (isTransaprent ? textfield.inputNormalTransparentBC : textfield.inputNormalBC) : + control.hovered ? (isTransaprent ? textfield.hoveredTransparentBC : textfield.hoveredBC) : + (isTransaprent ? textfield.normalTransparentBC : textfield.normalBC) + property var backBorderColor: !control.enabled ? textfield.disableBorderColor : (control.activeFocus) ? textfield.focusBorderColor : + control.hovered ? textfield.hoverBorderColor : textfield.normalBorderColor + +// property bool hover: false + property bool click: false + ParseInterface{ + id: parseInterface + } + + function getStartColor(dtcolor) + { + return parseInterface.pStartColor(dtcolor) + } + function getEndColor(dtcolor) + { + return parseInterface.pEndColor(dtcolor) + } + + background: Rectangle { + id: backrec + radius: textfield.radius + implicitWidth: textfield.normalWidth + implicitHeight: textfield.normalHeight + color: gradientRec.visible ? "transparent" : getStartColor(backColor) + + Rectangle{ + id: gradientRec + anchors.fill: parent + radius: parent.radius + gradient: Gradient { + GradientStop { position: 0.0; color: getStartColor(backColor) } + + GradientStop { position: 1.0; color: getEndColor(backColor)} + } + visible: !parseInterface.isSolidPattern(backColor) + } + Rectangle{ + anchors.fill: parent + radius: textfield.radius + color: "transparent" + border.color: getStartColor(backBorderColor) + border.width: (control.activeFocus) ? textfield.focusBorderWidth : textfield.borderWidth + + } +// Component.onCompleted: console.log("123321....", verticalScrollBar.visible) + + //没办法内置滚动条 滚动条没办法跟内容联动 +// ScrollBar.vertical: ScrollBar { + +// id: verticalScrollBar + +// parent: backrec + +// anchors.right: backrec.right + +// anchors.top: backrec.top + +// anchors.bottom: backrec.bottom + +// visible: control.contentHeight > control.height + +// orientation: Qt.Vertical + +// size: control.height * 1.0/ control.contentHeight*1.0 //control.flickableItem.visibleArea.heightRatio + +// //position: 0.5//control.flickableItem.visibleArea.yPosition + +// active: visible//control.flickableItem.moving || control.flickableItem.dragging + +// onPositionChanged: { +// var newY = position * (control.contentHeight - control.height) +// control.flickableItem.contentY = newY + +// // control.flickable.contentY = position * control.contentHeight +// } + + +// // policy: (verticalScrollBarAlwaysVisible || control.flickableItem.contentHeight > control.height) ? ScrollBar.AlwaysOn : ScrollBar.AsNeeded + +// // orientation: Qt.Vertical + +// // size: control.flickableItem.visibleArea.heightRatio + +// // position: control.flickableItem.visibleArea.yPosition + +// // active: control.flickableItem.moving || control.flickableItem.dragging + +// } + + } + + + PlaceholderText { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + text: control.placeholderText + font: app.font + color: getStartColor(!control.enabled ? textfield.placeHolderDisableTextColor : textfield.placeHolderNormalTextColor) + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + renderType: control.renderType + } + + StylePrivate.UKUITextArea{ + id: textfield + } + + StylePrivate.APPParameter{ + id: app + } + onPressed: { + click = true; + } + onReleased: click = false + +} diff --git a/ukui-qqc2-style/org.ukui.style/TextField.qml b/ukui-qqc2-style/org.ukui.style/TextField.qml index 26406be..4e50f41 100644 --- a/ukui-qqc2-style/org.ukui.style/TextField.qml +++ b/ukui-qqc2-style/org.ukui.style/TextField.qml @@ -35,26 +35,74 @@ T.TextField { contentHeight + topPadding + bottomPadding, placeholder.implicitHeight + topPadding + bottomPadding) - padding: textfield.leftRightPadding - leftPadding: padding + 4 + // mirrored 属性,qml自动切换 + property bool mirrored: Qt.application.layoutDirection === Qt.RightToLeft + +// padding: textfield.leftRightPadding + + // leftPadding: padding + 4 + // rightPadding: (cleanBtn.visible && eyeBtn.visible ? cleanBtn.width + eyeBtn.width + 8 : + // cleanBtn.visible ? cleanBtn.width + 8 : eyeBtn.visible ? eyeBtn.width + 8 : textfield.leftRightPadding) + + + leftPadding: control.mirrored ? + (cleanBtn.visible && eyeBtn.visible ? cleanBtn.width + eyeBtn.width + 8 : + cleanBtn.visible ? cleanBtn.width + 8 : + eyeBtn.visible ? eyeBtn.width + 8 : textfield.leftRightPadding) : + (textfield.leftRightPadding + 4) + rightPadding: control.mirrored ? + (textfield.leftRightPadding + 4) : + (cleanBtn.visible && eyeBtn.visible ? cleanBtn.width + eyeBtn.width + 8 : + cleanBtn.visible ? cleanBtn.width + 8 : eyeBtn.visible ? eyeBtn.width + 8 : textfield.leftRightPadding) + color: getStartColor(!control.enabled ? textfield.disableTextColor : textfield.normalTextColor) - selectionColor: control.palette.highlight + selectionColor: getStartColor(textfield.focusBorderColor) selectedTextColor: control.palette.highlightedText placeholderTextColor: getStartColor(!control.enabled ? textfield.placeHolderDisableTextColor : textfield.placeHolderNormalTextColor) verticalAlignment: TextInput.AlignVCenter + + // 让placeholder 文本, 镜像模式下右对齐 + horizontalAlignment: control.mirrored ? TextInput.AlignRight : TextInput.AlignLeft + font: app.font hoverEnabled: true selectByMouse: true - - property var backColor: !control.enabled ? textfield.placeHolderDisableBC : control.activeFocus ? textfield.inputNormalBC : - click ? textfield.placeHolderClickedBC : - control.hovered ? textfield.placeHolderHoveredBC : textfield.normalBC - property var backBorderColor: !control.enabled ? textfield.disableBorderColor : control.activeFocus ? textfield.focusBorderColor : + palette: app.palette + property var isPassMode:{ + if(control.hasOwnProperty("passMode")) + return control.passMode + else + return false + } + property var isTransaprent:{ + if(control.hasOwnProperty("transparent")) + return control.transparent + else + return true + } + property var backColor: !control.enabled ? (isTransaprent ? textfield.disableTransparentBC : textfield.disableBC) : + (control.activeFocus) ? (isTransaprent ? textfield.inputNormalTransparentBC : textfield.inputNormalBC) : + click ? (isTransaprent ? textfield.clickedTransparentBC : textfield.clickedBC) : + control.hovered ? (isTransaprent ? textfield.hoveredTransparentBC : textfield.hoveredBC) : + (isTransaprent ? textfield.normalTransparentBC : textfield.normalBC) + property var backBorderColor: !control.enabled ? textfield.disableBorderColor : (control.activeFocus) ? textfield.focusBorderColor : control.hovered ? textfield.hoverBorderColor : textfield.normalBorderColor // property bool hover: false property bool click: false + property bool cleanVisible: false + + Component.onCompleted: { + if(isPassMode) + control.echoMode = TextInput.Password + imageSource() + // console.log("===> TextField: mirrored = ", mirrored, ", control.mirrored = ",control.mirrored, ",leftPadding = ",leftPadding,",rightPadding = ",rightPadding,",placeholder.width = ",placeholder.width) + } + onEchoModeChanged: { +// console.log("echomode changedee", control.echoMode) + imageSource() + } ParseInterface{ id: parseInterface @@ -68,9 +116,11 @@ T.TextField { { return parseInterface.pEndColor(dtcolor) } + PlaceholderText { id: placeholder - x: control.leftPadding + //x: control.leftPadding + x: control.mirrored ? control.width - control.rightPadding - width : control.leftPadding y: control.topPadding width: control.width - (control.leftPadding + control.rightPadding) height: control.height - (control.topPadding + control.bottomPadding) @@ -80,25 +130,24 @@ T.TextField { color: getStartColor(!control.enabled ? textfield.placeHolderDisableTextColor : textfield.placeHolderNormalTextColor) verticalAlignment: control.verticalAlignment visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) - elide: Text.ElideRight + + //elide: Text.ElideRight + elide: control.mirrored ? Text.ElideLeft : Text.ElideRight + renderType: control.renderType } - + //TextField background background: Rectangle { id: backrec radius: textfield.radius implicitWidth: textfield.normalWidth implicitHeight: textfield.normalHeight - border.width: control.activeFocus ? textfield.focusBorderWidth : textfield.normalWidth color: gradientRec.visible ? "transparent" : getStartColor(backColor) - border.color: getStartColor(backBorderColor) - Rectangle{ + Rectangle { id: gradientRec anchors.fill: parent radius: parent.radius - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { GradientStop { position: 0.0; color: getStartColor(backColor) } @@ -106,6 +155,68 @@ T.TextField { } visible: !parseInterface.isSolidPattern(backColor) } + Rectangle { + id: bac + anchors.fill: parent + radius: parent.radius + color: "transparent" + border.width: (control.activeFocus) ? textfield.focusBorderWidth : textfield.borderWidth + border.color: getStartColor(backBorderColor) + } + + RoundButton { + id: cleanBtn + width: height + height: control.height >= 36 ? 30 : (control.height - 6) + // anchors.right: eyeBtn.visible ? eyeBtn.left : parent.right + + anchors.right: control.mirrored ? undefined : (eyeBtn.visible ? eyeBtn.left : parent.right) + anchors.left: control.mirrored ? (eyeBtn.visible ? eyeBtn.right : parent.left) : undefined + + anchors.verticalCenter: parent.verticalCenter + //anchors.rightMargin: eyeBtn.visible ? 0 : backrec.border.width + + anchors.rightMargin: control.mirrored ? 0 : (eyeBtn.visible ? 0 : bac.border.width) + anchors.leftMargin: control.mirrored ? (eyeBtn.visible ? 0 : bac.border.width) : 0 + + flat: true + visible: !control.readOnly && control.enabled && (control.text !== "") +// icon.source: "window-close-symbolic" + + // onClicked: { + // } + onPressed: { + control.clear() + cleanVisible = false + control.focus = true + } + } + RoundButton{ + id: eyeBtn +// icon.source: "ukui-eye-hidden-symbolic" + //anchors.right: parent.right + + anchors.right: control.mirrored ? undefined : parent.right + anchors.left: control.mirrored ? parent.left : undefined + + anchors.verticalCenter: parent.verticalCenter + //anchors.rightMargin: (control.activeFocus) ? textfield.focusBorderWidth : textfield.borderWidth + + anchors.rightMargin: control.mirrored ? 0 : ((control.activeFocus) ? textfield.focusBorderWidth : textfield.borderWidth) + anchors.leftMargin: control.mirrored ? ((control.activeFocus) ? textfield.focusBorderWidth : textfield.borderWidth) : 0 + + width: height + height: control.height >= 36 ? 30 : (control.height - 6) + visible: control.enabled && isPassMode + flat: true + onPressed: { + if(control.echoMode == TextInput.Normal) + control.echoMode = TextInput.Password + else + control.echoMode = TextInput.Normal + control.focus = true + } + } } StylePrivate.UKUITextFiled{ @@ -114,10 +225,54 @@ T.TextField { StylePrivate.APPParameter{ id: app + + onParametryChanged:{ + eyeBtn.icon.source = "" + cleanBtn.icon.source = "" + imageSource(); + } + onIconThemeChanged: { + eyeBtn.icon.source = "" + cleanBtn.icon.source = "" + imageSource(); + } + } + onEnabledChanged: imageSource() + + + function imageSource(){ + // return "image://imageProvider/file:///usr/share/icons/ukui-icon-theme-default/scalable/actions/object-select-symbolic.svg/normal" + + var model = "normal" + if(!control.enabled){ + if(app.isDark) + model = "highDisbale" + else + model = "disenable" + } + else if(app.isDark){ + model = "highlight" + } + //console.log("control.echoMode...", control.echoMode === TextInput.Password) + if(isPassMode){ + if(control.echoMode === TextInput.Password) + eyeBtn.icon.source = "ukui-eye-hidden-symbolic/" + model + else + eyeBtn.icon.source = "ukui-eye-display-symbolic/" + model + + } + if(control.text !== "") + cleanBtn.icon.source = "window-close-symbolic/" + model + } onPressed: { click = true; } + onTextChanged: { + imageSource() + if(control.text !== "") + cleanVisible = true + } onReleased: click = false } diff --git a/ukui-qqc2-style/org.ukui.style/ToolButton.qml b/ukui-qqc2-style/org.ukui.style/ToolButton.qml index dc9ee7d..b812c63 100644 --- a/ukui-qqc2-style/org.ukui.style/ToolButton.qml +++ b/ukui-qqc2-style/org.ukui.style/ToolButton.qml @@ -28,21 +28,39 @@ import org.ukui.qqc2style.private 1.0 as StylePrivate T.ToolButton { id: controlRoot implicitWidth: { - var contentwidth = implicitContentWidth + leftPadding + rightPadding + if(controlRoot.hasOwnProperty("maxWidth")) + return controlRoot.maxWidth + var contentwidth = implicitContentWidth + leftPadding + rightPadding return Math.max(implicitBackgroundWidth + leftInset + rightInset, contentwidth, btn.normalWidth) } implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, btn.normalHeight) - leftPadding: btn.margin - rightPadding: btn.margin + leftPadding: btn.leftRightMargin + rightPadding: btn.leftRightMargin hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? - font.family: appP.font.family - font.pointSize: appP.font.pointSize + property var _menuToolButton:{ + if(controlRoot.hasOwnProperty("hasMenu")) + return controlRoot.hasMenu + else + return false + } + + property var _maxWidth: { + if(controlRoot.hasOwnProperty("maxWidth")){ + console.log("maxWidthhhhhhh", controlRoot.maxWidth) + return controlRoot.maxWidth + } + else + return -1 + } + + font: appP.font + palette: appP.palette NormalControlColor{ id:ncColor @@ -54,12 +72,25 @@ T.ToolButton { StylePrivate.APPParameter{ id: appP } + + onEnabledChanged: { + content.updateImage() + back.changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (appP.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) + } + property bool hasWindowActive: Qt.application.active + onHasWindowActiveChanged:{ + content.updateImage() + } + onPressedChanged: content.updateImage() contentItem: ButtonIconLabelContent { + id: content controlRoot: controlRoot anchors.centerIn: controlRoot // onWidthChanged: console.log(controlRoot.text, width) } background: BackGroundRectangle{ + id: back controlRoot: controlRoot _radius: btn.radius }} diff --git a/ukui-qqc2-style/org.ukui.style/ToolTip.qml b/ukui-qqc2-style/org.ukui.style/ToolTip.qml index 1e9bb93..4d8f182 100644 --- a/ukui-qqc2-style/org.ukui.style/ToolTip.qml +++ b/ukui-qqc2-style/org.ukui.style/ToolTip.qml @@ -41,7 +41,7 @@ T.ToolTip { // Always show the tooltip on top of everything else z: 999 -// implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitWidth: popupwindow.width // implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding margins: tooltip.margins @@ -50,10 +50,49 @@ T.ToolTip { // Timeout based on text length, from QTipLabel::restartExpireTimer timeout: 4000 - delay: 10 + delay: Qt.styleHints.mousePressAndHoldInterval + Component.onDestruction: { + if (typeof popupwindow !== "undefined" && popupwindow) { + popupwindow.visible = false//如果window还没销毁 显隐藏 + } + } + property bool loaderSuc: false + property bool showWindow: { + if(controlRoot.hasOwnProperty("backOpacity") && controlRoot.backOpacity >= 1) + return false + return true;//appP.showToolTipWindow() + } + property var internalComponent: null + property var _opacity:{ + if(controlRoot.hasOwnProperty("backOpacity")) + return controlRoot.backOpacity + return appP.menuTransparency + } + property var mode:{ + if(controlRoot.hasOwnProperty("wrapMode")){ + //console.log("mode:", controlRoot.wrapMode) + return controlRoot.wrapMode + } + return Text.NoWrap + } + property var _maxWidth:{ + if(controlRoot.hasOwnProperty("maxWidth")) + return controlRoot.maxWidth + return 0 + } + property var _textFormat:{ + if(controlRoot.hasOwnProperty("textFormat")) + return controlRoot.textFormat + return Qt.PlainText + } closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnReleaseOutsideParent - + property var isTransaprent:{ + if(controlRoot.hasOwnProperty("transparent")) + return controlRoot.transparent + else + return true + } ParseInterface{ id: parseInterface } @@ -67,18 +106,6 @@ T.ToolTip { return parseInterface.pEndColor(dtcolor) } - onVisibleChanged: { - if(popHandle && parent) - { - popHandle.setPosion(windowLabel.mapToGlobal(x, y).x, windowLabel.mapToGlobal(x, y).y) - } -// popHandle.visible = visible -// if(visible && popHandle && !popHandle.visible){ -// popHandle.open() -// } -// else if(!visible && popHandle && popHandle.visible) -// popHandle.close() - } StylePrivate.APPParameter{ id: appP @@ -87,80 +114,349 @@ T.ToolTip { StylePrivate.UKUIToolTip{ id: tooltip } + onVisibleChanged: { + if(visible){ + var p = popHandle.posByCursor(popupwindow.width, popupwindow.height) - background: Item{ - Window { - id: popupwindow - width: windowLabel ? windowLabel.width : 0 - height: windowLabel ? windowLabel.height : 0 - visible: controlRoot.visible - x: controlRoot.x - y: controlRoot.y -// blurControl: control - flags: Qt.ToolTip - // margins: tooltip.margins - //padding: tooltip.padding - - Connections { - target: popHandle - function onSizeChanged(width, height){ - rec.implicitWidth = width - rec.implicitHeight = height + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.setGeometry(Math.ceil(p.x), Math.ceil(p.y), Math.ceil(popupwindow.width), Math.ceil(popupwindow.height)) + popupwindow.visible = false + popupwindow.visible = true } - } + popupwindow.visible = controlRoot.visible + } + + // ========== 新增:文本测量相关属性和函数 ========== + // 存储行数 + property int textLineCount: 0 + // 存储每行最大宽度 + property real maxLineWidth: 0 + + + contentItem: Item{ + Window { + id: popupwindow + width: Math.max(1, (controlRoot._maxWidth != 0 && controlRoot.text != "") ? Math.min(maxLineWidth > 0 ? (maxLineWidth + 2 * tooltip.padding): controlRoot._maxWidth, + Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding) : + (Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding)) + + height: { + if (typeof popHandle !== "undefined" && popHandle) { + return Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding)) + } + return Math.max(1, Math.ceil(windowLabel.implicitHeight + 2 * tooltip.padding)) + } + visible: controlRoot.visible + color: "transparent" + flags: Qt.WindowTransparentForInput + + onWidthChanged: { + if(visible){ + var p = popHandle.posByCursor(popupwindow.width, popupwindow.height) + + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.setGeometry(Math.ceil(p.x), Math.ceil(p.y), Math.ceil(popupwindow.width), Math.ceil(popupwindow.height)) + popupwindow.requestUpdate() + } + } + } + + onHeightChanged: { + if(visible){ + var p = popHandle.posByCursor(popupwindow.width, popupwindow.height) + + if(popupwindow.x !== p.x || popupwindow.y !== p.y){ + popupwindow.setGeometry(Math.ceil(p.x), Math.ceil(p.y), Math.ceil(popupwindow.width), Math.ceil(popupwindow.height)) + popupwindow.requestUpdate() + } + } + } + onVisibleChanged: { + if(visible){ + calculateTextLines() + var w = popupwindow.width; + if(controlRoot._maxWidth !== 0) + if(maxLineWidth > 0 ) + w = maxLineWidth + 2 * tooltip.padding + else if((windowLabel.implicitWidth + + 2 * tooltip.padding) < controlRoot._maxWidth) + w = windowLabel.implicitWidth + + 2 * tooltip.padding + else{ + w = controlRoot._maxWidth + } + + var h = popupwindow.height + if (typeof popHandle !== "undefined" && popHandle) { + h = Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding)) + if(popHandle.getScreenSize().height < windowLabel.implicitHeight + 2 * tooltip.padding){ + windowLabel.elide = Qt.ElideRight + windowLabel.maximumLineCount = 100 + } + } + else + h = Math.max(1, windowLabel.implicitHeight + 2 * tooltip.padding) + + controlRoot.implicitWidth = Math.max(Math.ceil(windowLabel.implicitWidth + 2 * tooltip.padding), 1) + var p = popHandle.posByCursor(Math.ceil(w), Math.ceil(h)) - Rectangle{ - id: rec - visible: parent.visible - anchors.fill: parent - radius: tooltip.radius - color: getStartColor(tooltip.backColor) - opacity: appP.menuTransparency + if(popupwindow.x !== p.x || popupwindow.y !== p.y || popupwindow.width !== w || popupwindow.height !== h){ + popupwindow.setGeometry(p.x, p.y, Math.ceil(w), Math.ceil(h)) + popupwindow.requestUpdate() + } - Label { + } + else{ + textLineCount = 0 + maxLineWidth = 0 + } + } + + StylePrivate.PopupHandle{ + id: popHandle + blur: true + titlebarVisible: false + anchors.fill: parent + posFollwMouse: true + visible: popupwindow.visible + radius: tooltip.radius + windowStaysOnTopHint: true + } + + Rectangle{ + id: rec + visible: popupwindow.visible + anchors.fill: parent + radius: _opacity >= 1 ? tooltip.radius : 0 + color: { + var baccolor = getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, (controlRoot ? controlRoot._opacity: 1.0)) + } + // border.color: getStartColor(isTransaprent ? tooltip.backBorderTransparentColor : tooltip.backBorderColor) + // border.width: 1 + + } + Text { id: windowLabel - anchors.centerIn: parent - visible: parent.visible + anchors.fill: rec + anchors.leftMargin: tooltip.padding + anchors.rightMargin: tooltip.padding + anchors.topMargin: tooltip.padding + anchors.bottomMargin: tooltip.padding + + + anchors.centerIn: rec + visible: popupwindow.visible text: controlRoot.text - wrapMode: Text.WordWrap - font: controlRoot.font + wrapMode: controlRoot ? controlRoot.mode : Text.NoWrap + font: controlRoot ? controlRoot.font : appP.font color: getStartColor(tooltip.textColor) - onWidthChanged: { - controlRoot.implicitWidth = windowLabel.implicitWidth + 2 * controlRoot.padding - controlRoot.implicitHeight = windowLabel.implicitHeight+ 2 * controlRoot.padding - popHandle.setSize(windowLabel.implicitWidth + 2 * controlRoot.padding, windowLabel.implicitHeight+ 2 * controlRoot.padding) + textFormat: controlRoot ? controlRoot._textFormat : Qt.PlainText + + onTextChanged: { + if(controlRoot) + { + calculateTextLines() + if(controlRoot._maxWidth !== 0) + if(maxLineWidth > 0 ) + popupwindow.width = maxLineWidth + 2 * tooltip.padding + else if((Math.ceil(windowLabel.implicitWidth) + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding + else{ + popupwindow.width = controlRoot._maxWidth + } + + if (typeof popHandle !== "undefined" && popHandle) { + popupwindow.height = Math.ceil(Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding))) + if(popHandle.getScreenSize().height < windowLabel.implicitHeight + 2 * tooltip.padding){ + windowLabel.elide = Qt.ElideRight + windowLabel.maximumLineCount = 100 + } + } + else + popupwindow.height = Math.ceil(Math.max(1, windowLabel.implicitHeight + 2 * tooltip.padding)) + + + controlRoot.implicitWidth = Math.ceil(Math.max(Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding, 1)) + } + } - onHeightChanged: { - controlRoot.implicitWidth = windowLabel.implicitWidth + 2 * controlRoot.padding - controlRoot.implicitHeight = windowLabel.implicitHeight+ 2 * controlRoot.padding - popHandle.setSize(windowLabel.implicitWidth + 2 * controlRoot.padding, windowLabel.implicitHeight + 2 * controlRoot.padding) + + onContentWidthChanged: { + if(controlRoot) + { + if(controlRoot._maxWidth !== 0) + if(maxLineWidth > 0 ) + popupwindow.width = maxLineWidth + 2 * tooltip.padding + else if((windowLabel.implicitWidth + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = Math.ceil(windowLabel.implicitWidth + + 2 * tooltip.padding) + else{ + popupwindow.width = controlRoot._maxWidth + } + + if (typeof popHandle !== "undefined" && popHandle) { + popupwindow.height = Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding)) + if(popHandle.getScreenSize().height < windowLabel.implicitHeight + 2 * tooltip.padding){ + windowLabel.elide = Qt.ElideRight + windowLabel.maximumLineCount = 100 + } + } + else + popupwindow.height = Math.ceil(Math.max(1, windowLabel.implicitHeight + 2 * tooltip.padding)) + + controlRoot.implicitWidth = Math.ceil(Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1)) + } + + } + onContentHeightChanged: { + if(controlRoot) + { + if(controlRoot._maxWidth !== 0) + if(maxLineWidth > 0 ) + popupwindow.width = maxLineWidth + 2 * tooltip.padding + else if((Math.ceil(windowLabel.implicitWidth) + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = Math.ceil(windowLabel.implicitWidth) + + 2 * tooltip.padding + else{ + popupwindow.width = controlRoot._maxWidth + } + + if (typeof popHandle !== "undefined" && popHandle) { + popupwindow.height = Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding)) + if(popHandle.getScreenSize().height < windowLabel.implicitHeight + 2 * tooltip.padding){ + windowLabel.elide = Qt.ElideRight + windowLabel.maximumLineCount = 100 + } + } + else + popupwindow.height = Math.max(1, windowLabel.implicitHeight + 2 * tooltip.padding) + + controlRoot.implicitWidth = Math.max(Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding, 1) + } } Component.onCompleted: { - controlRoot.implicitWidth = windowLabel.implicitWidth + 2 * controlRoot.padding - controlRoot.implicitHeight = windowLabel.implicitHeight+ 2 * controlRoot.padding - popHandle.setSize(windowLabel.implicitWidth + 2 * controlRoot.padding, windowLabel.implicitHeight + 2 * controlRoot.padding) - } + if(controlRoot) + { + if(controlRoot._maxWidth !== 0) + if((Math.ceil(windowLabel.implicitWidth) + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = Math.ceil(windowLabel.implicitWidth) + + 2 * tooltip.padding + else{ + if(maxLineWidth > 0 ) + popupwindow.width = maxLineWidth + 2 * tooltip.padding + else + popupwindow.width = controlRoot._maxWidth + } + + if (typeof popHandle !== "undefined" && popHandle) { + popupwindow.height = Math.max(1, Math.min(popHandle.getScreenSize().height, windowLabel.implicitHeight + 2 * tooltip.padding)) + if(popHandle.getScreenSize().height < windowLabel.implicitHeight + 2 * tooltip.padding){ + windowLabel.elide = Qt.ElideRight + windowLabel.maximumLineCount = 100 + } + } + else + popupwindow.height = Math.ceil(Math.max(1, windowLabel.implicitHeight + 2 * tooltip.padding)) + + controlRoot.implicitWidth = Math.ceil(Math.max(Math.ceil(windowLabel.implicitWidth) + 2 * tooltip.padding, 1)) + } + } + + } } - } + } + // 用于测量的隐藏 Text 组件(不渲染到界面) + Text { + id: measureText + visible: false // 隐藏,仅用于测量 + font: windowLabel.font + wrapMode: Text.NoWrap // 不换行,用于测量单行宽度 + textFormat: windowLabel.textFormat + } - StylePrivate.PopupHandle{ - id: popHandle - Component.onCompleted: popHandle.createWindow(popupwindow) - posFollwMouse: true + // 计算单个字符串的宽度(Qt Quick 原生方法) + function getTextWidth(text) { + measureText.text = text + return measureText.implicitWidth } + // 计算文本行数和每行最大宽度(纯 Quick 兼容版) + function calculateTextLines() { + if(_textFormat !== Qt.PlainText || _maxWidth === 0) + return; + if (!windowLabel || windowLabel.text === "") { + controlRoot.textLineCount = 0 + controlRoot.maxLineWidth = 0 + return + } + + // 获取文本显示的实际宽度(去除padding) + const textDisplayWidth = Math.max(1, (controlRoot._maxWidth !== 0) ? + controlRoot._maxWidth - 2 * tooltip.padding : + getTextWidth(windowLabel.text)) + + // 第一步:先按显式换行符 \n 拆分原始行 + const originalLines = windowLabel.text.split('\n') + let totalLines = 0 // 最终总行数 + let maxWidth = 0 // 每行最大宽度 + + // 第二步:遍历每一行,处理自动换行并测量宽度 + for (let i = 0; i < originalLines.length; i++) { + const originalLine = originalLines[i] + // 空行:行数+1,宽度0 + if (originalLine === "") { + totalLines++ + continue + } + + // 测量当前原始行的宽度 + const originalLineWidth = getTextWidth(originalLine) + + // 情况1:不换行 或 行宽度 <= 显示宽度 → 直接作为一行 + if (windowLabel.wrapMode === Text.NoWrap /*|| originalLineWidth <= (controlRoot._maxWidth - 2 * tooltip.padding)*/) { + totalLines++ + maxWidth = Math.max(maxWidth, originalLineWidth) + continue + } + + // 情况2:需要自动换行 → 逐字符拆分(Qt Quick 原生方式) + let currentLineText = "" + let currentLineWidth = 0 - // contentItem: Controls.Label { -// text: controlRoot.text -// wrapMode: Text.WordWrap -// font: controlRoot.font -// color: getStartColor(tooltip.textColor) -// //visible: false -// } + // 逐字符处理当前行 + for (let j = 0; j < originalLine.length; j++) { + const charc = originalLine[j] + const charWidth = getTextWidth(currentLineText + charc) + // 如果添加当前字符后宽度超过限制 → 换行 + if (charWidth > (controlRoot._maxWidth - 2 * tooltip.padding)) { + // 记录当前行 + totalLines++ + maxWidth = Math.max(maxWidth, currentLineWidth) + + // 重置当前行,开始新行 + currentLineText = charc + currentLineWidth = getTextWidth(charc) + } else { + // 继续添加字符到当前行 + currentLineText += charc + currentLineWidth = charWidth + } + } + + // 处理最后一行剩余的字符 + if (currentLineText !== "") { + totalLines++ + maxWidth = Math.max(maxWidth, currentLineWidth) + } + } + + // 更新最终结果 + controlRoot.textLineCount = totalLines + controlRoot.maxLineWidth = Math.ceil(maxWidth) + + } + // ========== 修正结束 ========== } + diff --git a/ukui-qqc2-style/org.ukui.style/VerticalHeaderView.qml b/ukui-qqc2-style/org.ukui.style/VerticalHeaderView.qml new file mode 100644 index 0000000..521c55a --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/VerticalHeaderView.qml @@ -0,0 +1,81 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Templates 2.15 as T +import org.ukui.qqc2style.private 1.0 as StylePrivate + +T.VerticalHeaderView { + id: control + + implicitWidth: contentWidth + implicitHeight: syncView ? syncView.height : 0 + + delegate: Item { + // Qt6: add cellPadding (and font etc) as public API in headerview + readonly property real cellPadding: 8 + + implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) + implicitHeight: text.implicitHeight + (cellPadding * 2) + + Text { + id: text + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData + width: parent.width + height: parent.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: getStartColor(headerview.normalTextColor) + wrapMode: Text.Wrap + } + Rectangle{ + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: headerview.lineWidth + color: headerview.lineColor + } + } + + StylePrivate.APPParameter{ + id: appP + } + + StylePrivate.UKUIHeaderView{ + id: headerview + } + ParseInterface{ + id: parseInterface + } + + function getStartColor(dtcolor) + { + return parseInterface.pStartColor(dtcolor) + } + function getEndColor(dtcolor) + { + return parseInterface.pEndColor(dtcolor) + } +} diff --git a/ukui-qqc2-style/org.ukui.style/private/BackGroundRectangle.qml b/ukui-qqc2-style/org.ukui.style/private/BackGroundRectangle.qml index 7476cc0..de0cd23 100644 --- a/ukui-qqc2-style/org.ukui.style/private/BackGroundRectangle.qml +++ b/ukui-qqc2-style/org.ukui.style/private/BackGroundRectangle.qml @@ -39,18 +39,14 @@ Rectangle { property color controlEndColor property color borderColor - color: /*gradientRec.visible ? "transparent" :*/controlStartColor - opacity: (controlRoot.flat && !controlRoot.pressed && !controlRoot.hovered) ? 0 : 1 + color: gradientRec.visible ? "transparent" :controlStartColor + opacity: (controlRoot.flat && !controlRoot.pressed && !controlRoot.hovered && + (!controlRoot.checkable || (controlRoot.checkable && !controlRoot.checked))) ? 0 : 1 radius: _radius // 可选:设置圆角半径 - border.width: controlRoot.focus ? btn.focusBorderWidth : btn.borderWidth - border.color: borderColor - Rectangle { id: gradientRec anchors.fill: parent radius: _radius // 可选:设置圆角半径 - border.width: parent.border.width - border.color: parent.border.color gradient: Gradient { id:gradient @@ -61,8 +57,13 @@ Rectangle { visible: useGradient } - NormalControlColor{ - id:ncColor + Rectangle{ + anchors.fill: parent + radius: parent.radius + border.width: controlRoot.flat ? 0 : (controlRoot.focus ? btn.focusBorderWidth : btn.borderWidth) + border.color: borderColor + color: "transparent" + } ParseInterface{ @@ -71,7 +72,8 @@ Rectangle { StylePrivate.UKUIButton { id: btn onParametryChanged:{ - changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, controlRoot.focus) + changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) //root.color = "red" root.update(); } @@ -80,73 +82,95 @@ Rectangle { StylePrivate.APPParameter{ id: app onParametryChanged:{ - changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, controlRoot.focus) + changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) //root.color = "blue" root.update(); } } - function changeColor(highlighted, enable, click, hover, focus){ + function changeColor(highlighted, enable, click, hover, focus, checked){ var closeBtn = false; var windowBtn = false; var importBtn = false; + var transparent = true; if(controlRoot.hasOwnProperty("buttonType")){ - closeBtn = (controlRoot.buttonType === "closeButton"); - windowBtn = (controlRoot.buttonType === "windowButton"); + closeBtn = (controlRoot.buttonType === "closeButton" || controlRoot.buttonType === "windowTitleBarCloseButton"); + windowBtn = (controlRoot.buttonType === "windowButton" || controlRoot.buttonType === "windowTitleBarWindowButton"); importBtn = (controlRoot.buttonType === "importButton"); } + if(controlRoot.hasOwnProperty("transparent")){ + transparent = controlRoot.transparent; + } if(highlighted || importBtn){ controlStartColor = !enable ? parseInterface.pStartColor(btn.disableHBC) : - click ? parseInterface.pStartColor(btn.clickedHBC) : + click || checked ? parseInterface.pStartColor(btn.clickedHBC) : hover ? parseInterface.pStartColor(btn.hoveredHBC) : parseInterface.pStartColor(btn.normalHBC) controlEndColor = !enable ? parseInterface.pEndColor(btn.disableHBC) : - click ? parseInterface.pEndColor(btn.clickedHBC) : + click || checked ? parseInterface.pEndColor(btn.clickedHBC) : hover ? parseInterface.pEndColor(btn.hoveredHBC) : parseInterface.pEndColor(btn.normalHBC) borderColor = !enable ? parseInterface.pStartColor(btn.disableBorderHColor) : focus ? parseInterface.pStartColor(btn.focusBorderColor) : - click ? parseInterface.pStartColor(btn.clickBorderHColor) : + click || checked ? parseInterface.pStartColor(btn.clickBorderHColor) : hover ? parseInterface.pStartColor(btn.hoverBorderHColor) : parseInterface.pStartColor(btn.normalBorderHColor) } else if(closeBtn){ controlStartColor = !enable ? parseInterface.pStartColor(btn.disableCloseBC) : - click ? parseInterface.pStartColor(btn.clickedCloseBC) : + click || checked ? parseInterface.pStartColor(btn.clickedCloseBC) : hover ? parseInterface.pStartColor(btn.hoveredCloseBC) : parseInterface.pStartColor(btn.normalCloseBC) controlEndColor = !enable ? parseInterface.pEndColor(btn.disableCloseBC) : - click ? parseInterface.pEndColor(btn.clickedCloseBC) : + click || checked ? parseInterface.pEndColor(btn.clickedCloseBC) : hover ? parseInterface.pEndColor(btn.hoveredCloseBC) : parseInterface.pEndColor(btn.normalCloseBC) borderColor = !enable ? parseInterface.pStartColor(btn.disableBorderCloseColor) : - click ? parseInterface.pStartColor(btn.clickBorderCloseColor) : + click || checked ? parseInterface.pStartColor(btn.clickBorderCloseColor) : focus ? parseInterface.pStartColor(btn.focusBorderColor) : hover ? parseInterface.pStartColor(btn.hoverBorderCloseColor) : parseInterface.pStartColor(btn.normalBorderCloseColor) } - else if(windowBtn){ + else if(windowBtn && !transparent){ controlStartColor = !enable ? parseInterface.pStartColor(btn.disableWindowBC) : - click ? parseInterface.pStartColor(btn.clickedWindowBC) : + click || checked ? parseInterface.pStartColor(btn.clickedWindowBC) : hover ? parseInterface.pStartColor(btn.hoveredWindowBC) : parseInterface.pStartColor(btn.normalWindowBC) controlEndColor = !enable ? parseInterface.pEndColor(btn.disableWindowBC) : - click ? parseInterface.pEndColor(btn.clickedWindowBC) : + click || checked ? parseInterface.pEndColor(btn.clickedWindowBC) : hover ? parseInterface.pEndColor(btn.hoveredWindowBC) : parseInterface.pEndColor(btn.normalWindowBC) borderColor = !enable ? parseInterface.pStartColor(btn.disableBorderWindowColor) : - click ? parseInterface.pStartColor(btn.clickBorderWindowColor) : + click || checked ? parseInterface.pStartColor(btn.clickBorderWindowColor) : focus ? parseInterface.pStartColor(btn.focusBorderColor) : hover ? parseInterface.pStartColor(btn.hoverBorderWindowColor) : parseInterface.pStartColor(btn.normalBorderWindowColor) } + else if(windowBtn && transparent){ + controlStartColor = !enable ? parseInterface.pStartColor(btn.disableWindowTransparentBC) : + click || checked ? parseInterface.pStartColor(btn.clickedWindowTransparentBC) : + hover ? parseInterface.pStartColor(btn.hoveredWindowTransparentBC) : + parseInterface.pStartColor(btn.normalWindowTransparentBC) + + controlEndColor = !enable ? parseInterface.pEndColor(btn.disableWindowTransparentBC) : + click || checked ? parseInterface.pEndColor(btn.clickedWindowTransparentBC) : + hover ? parseInterface.pEndColor(btn.hoveredWindowTransparentBC) : + parseInterface.pEndColor(btn.normalWindowTransparentBC) + + borderColor = !enable ? parseInterface.pStartColor(btn.disableBorderWindowTransparentColor) : + click || checked ? parseInterface.pStartColor(btn.clickedBorderWindowTransparentColor) : + focus ? parseInterface.pStartColor(btn.focusBorderColor) : + hover ? parseInterface.pStartColor(btn.hoveredBorderWindowTransparentColor) : + parseInterface.pStartColor(btn.normalBorderWindowTransparentColor) + } else{ var disableStartColor = parseInterface.pStartColor(btn.disableBC); var disableEndColor = parseInterface.pEndColor(btn.disableBC); @@ -166,6 +190,26 @@ Rectangle { var hoverBorderColor = parseInterface.pStartColor(btn.hoverBorderColor ); var normalBorderColor = parseInterface.pStartColor(btn.normalBorderColor ); + if(transparent){ + disableStartColor = parseInterface.pStartColor(btn.disableTransparentBC); + disableEndColor = parseInterface.pEndColor(btn.disableTransparentBC); + + clickStartColor = parseInterface.pStartColor(btn.clickedTransparentBC); + clickEndColor = parseInterface.pEndColor(btn.clickedTransparentBC); + + normalStartColor = (controlRoot.flat ? "transparent" : parseInterface.pStartColor(btn.normalTransparentBC)); + normalEndColor = (controlRoot.flat ? "transparent" : parseInterface.pEndColor(btn.normalTransparentBC)); + + hoverStartColor = parseInterface.pStartColor(btn.hoveredTransparentBC); + hoverEndColor = parseInterface.pEndColor(btn.hoveredTransparentBC); + + disableBorderColor = parseInterface.pStartColor(btn.disableBorderTransparentBC); + focusBorderColor = parseInterface.pStartColor(btn.focusBorderColor ); + clickBorderColor = parseInterface.pStartColor(btn.clickedBorderTransparentBC ); + hoverBorderColor = parseInterface.pStartColor(btn.hoveredBorderTransparentBC ); + normalBorderColor = parseInterface.pStartColor(btn.normalBorderTransparentBC ); + } + if(controlRoot.hasOwnProperty("disableStartColor")) disableStartColor = controlRoot.disableStartColor if(controlRoot.hasOwnProperty("disableEndColor")) @@ -200,18 +244,18 @@ Rectangle { controlStartColor = !enable ? disableStartColor : - click ? clickStartColor : + click || checked ? clickStartColor : hover ? hoverStartColor : normalStartColor controlEndColor = !enable ? disableEndColor : - click ? clickEndColor : + click || checked? clickEndColor : hover ? hoverEndColor : normalEndColor borderColor = !enable ? disableBorderColor : focus ? focusBorderColor : - click ? clickBorderColor : + click || checked ? clickBorderColor : hover ? hoverBorderColor : normalBorderColor } @@ -220,23 +264,31 @@ Rectangle { Component.onCompleted: { - changeColor(controlRoot.highlighted, controlRoot.enabled, false, false, false); + changeColor(controlRoot.highlighted, controlRoot.enabled, false, false, false, (controlRoot.checkable && controlRoot.checked)); } Connections { target: controlRoot function onPressedChanged() { - changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, controlRoot.focus) + changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) } function onHoveredChanged() { // if(controlRoot.hovered) // grad.visible = true; // else // grad.visible = false; - changeColor(controlRoot.highlighted, controlRoot.enabled, false, controlRoot.hovered, controlRoot.focus) + changeColor(controlRoot.highlighted, controlRoot.enabled, false, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) } function onFocusChanged(){ - changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, controlRoot.focus) + changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) + } + function onCheckedChanged(){ + changeColor(controlRoot.highlighted, controlRoot.enabled, controlRoot.pressed, controlRoot.hovered, (app.focusEnable && controlRoot.focus), + (controlRoot.checkable && controlRoot.checked)) + } } } diff --git a/ukui-qqc2-style/org.ukui.style/private/ButtonIconLabelContent.qml b/ukui-qqc2-style/org.ukui.style/private/ButtonIconLabelContent.qml index 1fb44ed..591f201 100644 --- a/ukui-qqc2-style/org.ukui.style/private/ButtonIconLabelContent.qml +++ b/ukui-qqc2-style/org.ukui.style/private/ButtonIconLabelContent.qml @@ -30,13 +30,12 @@ Item{ id:root property T.AbstractButton controlRoot: root.parent - property int normalWidth: btn.normalWidth property int normalHeight: btn.normalHeight property string layout: "center" property int leftSpace: 0 - property int labelSpace: 0 + property int labelSpace: 4 // property var labelColor: controlRoot.enabled ? btn.normalTextColor : btn.disableTextColor @@ -47,6 +46,25 @@ Item{ return (label.text != "" && imageVisible) ? btn.space : 0 } + property var iconWidth: controlRoot.icon.width > 0 ? controlRoot.icon.width : 16 + property var iconHeight: controlRoot.icon.height > 0 ? controlRoot.icon.height : 16 + + property var menuRightSpace: 0 + property var menuLeftSpace: label.visible ? 4 : 10 + + onIconHeightChanged: { + if(controlRoot.display !== AbstractButton.TextOnly && (controlRoot.icon.source.toString() !== "" || controlRoot.icon.name.toString() !== "")) + image.sourceSize.height = iconHeight + } + onIconWidthChanged: { + if(controlRoot.display !== AbstractButton.TextOnly && (controlRoot.icon.source.toString() !== "" || controlRoot.icon.name.toString() !== "")) + image.sourceSize.width = iconWidth + } + + onImageVisibleChanged: { + adjust() + } + ParseInterface{ id: parseInterface } @@ -60,19 +78,25 @@ Item{ } function adjustWidth(margin){//margin表示边距 + if(controlRoot.hasOwnProperty("maxWidth") && controlRoot._maxWidth > 0){ + + return controlRoot._maxWidth - 2 * controlRoot.leftPadding + margin ; + } + var menuImageWidth = menuImage.visible ? (menuImage.sourceSize.width + menuRightSpace + menuLeftSpace) : 0 + if(controlRoot.display !== AbstractButton.TextUnderIcon){ var textwidth = (label.text !== "" && controlRoot.display !== AbstractButton.IconOnly) ? label.width : 0 - var imagewidth = (!imageVisible) ? 0 : image.width + var imagewidth = (!imageVisible) ? 0 : image.sourceSize.width if(controlRoot.display === AbstractButton.IconOnly || label.text === "") - return imagewidth + margin; + return imagewidth + margin + menuImageWidth; if(controlRoot.display !== AbstractButton.TextBesideIcon) - return Math.max(textwidth + margin, imagewidth + margin, normalWidth) - return Math.max(normalWidth, textwidth + imagewidth + space + margin) + return Math.max(textwidth + margin + menuImageWidth, imagewidth + margin + menuImageWidth, normalWidth) + return Math.max(normalWidth, textwidth + imagewidth + space + margin + menuImageWidth) } var textwidth1 = label1.text != "" ? label1.width : 0 - var imagewidth1 = imageVisible ? 0 : image1.width + var imagewidth1 = imageVisible ? 0 : image1.sourceSize.width - return Math.max(normalWidth, textwidth1 + imagewidth1 + space + margin) + return Math.max(normalWidth, textwidth1 + imagewidth1 + space + margin + menuImageWidth) } @@ -102,13 +126,12 @@ Item{ else if(controlRoot.hasOwnProperty("normalLabelColor") && controlRoot.enabled) return controlRoot.normalLabelColor - var closeBtn = false; var windowBtn = false; var importBtn = false; if(controlRoot.hasOwnProperty("buttonType")){ - closeBtn = (controlRoot.buttonType === "closeButton"); - windowBtn = (controlRoot.buttonType === "windowButton"); + closeBtn = (controlRoot.buttonType === "closeButton" || controlRoot.buttonType === "windowTitleBarCloseButton"); + windowBtn = (controlRoot.buttonType === "windowButton" || controlRoot.buttonType === "windowTitleBarWindowButton"); importBtn = (controlRoot.buttonType === "importButton"); } @@ -155,6 +178,14 @@ Item{ onFontChanged:{ adjust() } + onIconThemeChanged: { + image.source = "" + menuImage.source = "" + updateImage(); + } + onParametryChanged: { + updateImage() + } } anchors.centerIn: controlRoot @@ -162,14 +193,22 @@ Item{ id:item visible: controlRoot.display !== AbstractButton.TextUnderIcon implicitWidth: { + + if(controlRoot.hasOwnProperty("maxWidth") && controlRoot._maxWidth > 0){ + + return controlRoot._maxWidth - controlRoot.leftPadding * 2; + } + + var menuImageWidth = menuImage.visible ? (menuImage.sourceSize.width + menuRightSpace + menuLeftSpace) : 0 + var textwidth = (controlRoot.display !== AbstractButton.IconOnly && label.text !== "") ? label.width : 0 - var imagewidth = imageVisible ? image.width : 0 + var imagewidth = imageVisible ? image.sourceSize.width : 0 if(controlRoot.display === AbstractButton.IconOnly || label.text === "") - return imagewidth; + return imagewidth + menuImageWidth; if(controlRoot.display !== AbstractButton.TextBesideIcon) - return Math.max(textwidth, imagewidth) - return Math.max( textwidth + imagewidth + space) + return Math.max(textwidth, imagewidth) + menuImageWidth; + return Math.max( textwidth + imagewidth + space) + menuImageWidth; } implicitHeight: { @@ -183,29 +222,59 @@ Item{ return Math.max(textheight, imageheight, normalHeight) } - anchors.left: parent.left - anchors.leftMargin: - { - if(layout == "left"){ - space = leftSpace; - return leftSpace; - } - else - return (parent.width - width) / 2 - } + anchors.left: layout == "left" ? parent.left : undefined + anchors.leftMargin: layout == "left" ? leftSpace : undefined + anchors.horizontalCenter: layout !== "left" ? parent.horizontalCenter : undefined anchors.verticalCenter: parent.verticalCenter +// StylePrivate.KyIcon{ +// id: image +// iconName: parseInterface.kyIconSource(controlRoot) +// visible: controlRoot.display !== AbstractButton.TextOnly && iconName !== "" +// width: (controlRoot.display !== AbstractButton.TextOnly && iconName !== "") ? iconWidth : 0 +// height: (controlRoot.display !== AbstractButton.TextOnly && iconName !== "") ? iconHeight : 0 +// anchors.verticalCenter: parent.verticalCenter + +// Rectangle{ +// anchors.fill: parent +// color: "#30000000" +// } +// } Image { id: image source: parseInterface.iconSource(controlRoot)//controlRoot.icon.source anchors.verticalCenter: parent.verticalCenter - width: (controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null) ? 16 : 0 + + //Image 默认没有定义 anchors.left,anchors.right + + anchors.left: controlRoot.mirrored ? undefined : parent.left + anchors.right: controlRoot.mirrored ? parent.right : undefined + + anchors.leftMargin: controlRoot.mirrored ? ((image.visible) ? labelSpace : 0) : undefined + anchors.rightMargin: controlRoot.mirrored ? undefined : ((image.visible) ? labelSpace : 0) + + sourceSize.width: (controlRoot.display !== AbstractButton.TextOnly && (controlRoot.icon.source.toString() !== "" || controlRoot.icon.name.toString() !== "")) ? iconWidth : 0 + sourceSize.height: (controlRoot.display !== AbstractButton.TextOnly && (controlRoot.icon.source.toString() !== "" || controlRoot.icon.name.toString() !== "")) ? iconHeight : 0 visible: controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null + fillMode: Image.PreserveAspectFit + cache: false + onSourceChanged: { + sourceSize.width = (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconWidth : 0 + sourceSize.height = (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconHeight : 0 - onSourceChanged: adjust() + adjust() + } + onSourceSizeChanged: { + updateImage() + } + Component.onCompleted: { + if(source.toString() == "" && (controlRoot.icon.source.toString() !== "" || controlRoot.icon.name.toString() !== "")) + source = parseInterface.iconSource(controlRoot) + imageVisible = image.visible || image1.visible + } } - Label { + Text { id:label text: controlRoot.text font: controlRoot.font @@ -214,13 +283,58 @@ Item{ anchors.verticalCenter: parent.verticalCenter verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + elide: (controlRoot.hasOwnProperty("maxWidth") && controlRoot._maxWidth > 0) ? Text.ElideRight : Text.ElideNone + + // 原始默认代码 + //anchors.left: image.right + //anchors.leftMargin: (image.visible) ? labelSpace : 0 + +// anchors.left: controlRoot.mirrored ? parent.left : undefined +// anchors.right: controlRoot.mirrored ? undefined : parent.right + +// anchors.leftMargin: controlRoot.mirrored ? undefined : ((image.visible) ? labelSpace : 0) +// anchors.rightMargin: controlRoot.mirrored ? ((image.visible) ? labelSpace : 0) : undefined + + + + anchors.left: controlRoot.mirrored ? (controlRoot.hasOwnProperty("maxWidth") && controlRoot._maxWidth > 0) ? parent.left :undefined : image.right + anchors.right: controlRoot.mirrored ? image.left : (controlRoot.hasOwnProperty("maxWidth") && controlRoot._maxWidth > 0) ? parent.right :undefined + + anchors.leftMargin: controlRoot.mirrored ? undefined : ((image.visible) ? labelSpace : 0) + anchors.rightMargin: controlRoot.mirrored ? ((image.visible) ? labelSpace : 0) : undefined + - anchors.left: image.right - anchors.leftMargin: (image.visible && image.status !== Image.Null) ? labelSpace : 0 onTextChanged: { adjust() } + onFontChanged: adjust() + } + + Image { + id: menuImage + anchors.verticalCenter: parent.verticalCenter + anchors.left: controlRoot.mirrored ? undefined : (label.text != "" ? label.right : image.right) + anchors.leftMargin: controlRoot.mirrored ? undefined : menuLeftSpace + anchors.right: controlRoot.mirrored ? (label.text != "" ? label.left : image.left) : undefined + anchors.rightMargin: controlRoot.mirrored ? menuLeftSpace : undefined + + sourceSize.width: iconWidth + sourceSize.height: iconHeight + fillMode: Image.PreserveAspectFit + cache: false + source: controlRoot._menuToolButton ? parseInterface.buttonIcon(controlRoot, "ukui-down-symbolic") : "" + Component.onCompleted: { + if(controlRoot._menuToolButton) + source = parseInterface.buttonIcon(controlRoot, "ukui-down-symbolic") + } + visible: { + if(controlRoot.hasOwnProperty("_menuToolButton")) + return controlRoot._menuToolButton + else + return false + } } } @@ -228,13 +342,15 @@ Item{ id:item1 visible: controlRoot.display === AbstractButton.TextUnderIcon implicitWidth: { + var menuImageWidth = menuImage1.visible ? (menuImage1.sourceSize.width + menuRightSpace + menuLeftSpace) : 0 + var textwidth1 = label1.text != "" ? label1.width : 0 - var imagewidth1 = controlRoot.icon.source === "" ? 0 : image1.width + var imagewidth1 = controlRoot.icon.source === "" ? 0 : image1.sourceSize.width if(controlRoot.display === AbstractButton.TextUnderIcon) - return Math.max(textwidth1, imagewidth1, normalWidth); + return Math.max(textwidth1, imagewidth1, normalWidth) + menuImageWidth; if(controlRoot.display !== AbstractButton.TextBesideIcon) - return Math.max(textwidth1, imagewidth1, normalWidth) - return Math.max( textwidth1 + imagewidth1 + space, normalWidth) + return Math.max(textwidth1, imagewidth1, normalWidth) + menuImageWidth + return Math.max( textwidth1 + imagewidth1 + space, normalWidth) + menuImageWidth } implicitHeight: { var textheight1 = label1.text != "" ? label1.height : 0 @@ -247,18 +363,28 @@ Item{ anchors.centerIn: parent Image { id: image1 - source: parseInterface.iconSource(controlRoot)//controlRoot.icon.source + source: image.source//controlRoot.icon.source anchors.horizontalCenter: parent.horizontalCenter - width: visible ? 16 : 0 - height: visible ? 16 : 0 + sourceSize.width: image.sourceSize.width + sourceSize.height: image.sourceSize.height visible: controlRoot.display !== AbstractButton.TextOnly && source !== "" /*&& status != Image.Null*/ - onSourceChanged: adjust() + onSourceChanged: { + sourceSize.width = (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconWidth : 0 + sourceSize.height = (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconHeight : 0 + + adjust() + } + fillMode: Image.PreserveAspectFit + cache: false + Component.onCompleted: { + imageVisible = image.visible || image1.visible + } } - Label { + Text { id:label1 text: controlRoot.text font:controlRoot.font - color: getStartColor(labelColor()) + color: label.color visible: controlRoot.display !== AbstractButton.IconOnly && text !== "" anchors.horizontalCenter: parent.horizontalCenter @@ -268,14 +394,89 @@ Item{ onTextChanged: { adjust() } + onFontChanged: adjust() + } + + Image { + id: menuImage1 + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: menuRightSpace + anchors.left: label1.right + anchors.leftMargin: menuLeftSpace + + + sourceSize.width: iconWidth + sourceSize.height: iconHeight + fillMode: Image.PreserveAspectFit + cache: false + source: menuImage.source + visible: { + if(controlRoot.hasOwnProperty("_menuToolButton")) + return controlRoot._menuToolButton + else + return false + } } } + + + Component.onCompleted: { +// console.log("iconwidth:", iconWidth, iconHeight, controlRoot.icon.width, controlRoot.icon.height) + if(controlRoot.icon.width > 0 && controlRoot.icon.width !== iconWidth){ + iconWidth = controlRoot.icon.width + } + if(controlRoot.icon.height > 0 && controlRoot.icon.height !== iconHeight){ + iconHeight = controlRoot.icon.height + } + adjust() + // console.log("===> Button: controlRoot.mirrored = ", controlRoot.mirrored) } onVisibleChanged: { + if(controlRoot.icon.width > 0 && controlRoot.icon.width !== iconWidth){ + iconWidth = controlRoot.icon.width + } + if(controlRoot.icon.height > 0 && controlRoot.icon.height !== iconHeight){ + iconHeight = controlRoot.icon.height + } + + if(parseInterface.iconSource(controlRoot) != "") + imageVisible = image.visible || image1.visible + adjust() } + Connections { + target: controlRoot + function onClicked() { + updateImage() + } + function onHoveredChanged () { + updateImage() + } + function onIconChanged(){ + updateImage() + } + } + + function updateImage(){ + if(controlRoot){ + if(controlRoot.icon.width > 0 && controlRoot.icon.width !== iconWidth){ + iconWidth = controlRoot.icon.width + } + if(controlRoot.icon.height > 0 && controlRoot.icon.height !== iconHeight){ + iconHeight = controlRoot.icon.height + } + var source0 = parseInterface.iconSource(controlRoot) + image.source = source0 + var source1 = parseInterface.buttonIcon(controlRoot, "ukui-down-symbolic") + + menuImage.source = controlRoot._menuToolButton ? source1 : "" + if(parseInterface.iconSource(controlRoot) !== "") + imageVisible = image.visible || image1.visible + } + } } diff --git a/ukui-qqc2-style/org.ukui.style/private/IconLabelContent.qml b/ukui-qqc2-style/org.ukui.style/private/IconLabelContent.qml index 87bfebe..43a581b 100644 --- a/ukui-qqc2-style/org.ukui.style/private/IconLabelContent.qml +++ b/ukui-qqc2-style/org.ukui.style/private/IconLabelContent.qml @@ -40,6 +40,7 @@ Item{ // property var labelColor: controlRoot.enabled ? btn.normalTextColor : btn.disableTextColor property bool imageVisible : image.visible || image1.visible + property var textColor: labelColor() property var space: { if(controlRoot.display === AbstractButton.TextOnly || controlRoot.display === AbstractButton.IconOnly) return 0 @@ -60,16 +61,16 @@ Item{ function adjustWidth(margin){//margin表示边距 if(controlRoot.display !== AbstractButton.TextUnderIcon){ - var textwidth = (label.text !== "" && controlRoot.display !== AbstractButton.IconOnly) ? label.width : 0 + var textwidth = (label.text !== "" && controlRoot.display !== AbstractButton.IconOnly) ? label.implicitWidth : 0 var imagewidth = (!imageVisible) ? 0 : image.width if(controlRoot.display === AbstractButton.IconOnly || label.text === "") return imagewidth + margin; if(controlRoot.display !== AbstractButton.TextBesideIcon) return Math.max(textwidth + margin, imagewidth + margin) - return textwidth + imagewidth + space + margin + return textwidth + imagewidth + space + margin + leftSpace } - var textwidth1 = label1.text != "" ? label1.width : 0 - var imagewidth1 = imageVisible ? 0 : image1.width + var textwidth1 = label1.text != "" ? label1.implicitWidth : 0 + var imagewidth1 = imageVisible ? 0 : image1.implicitWidth return textwidth1 + imagewidth1 + space + margin @@ -130,6 +131,8 @@ Item{ { return parseInterface.iconSource(controlRoot) } + property var iconWidth: 16 + property var iconHeight: 16 StylePrivate.UKUIButton{ @@ -142,6 +145,20 @@ Item{ // controlRoot.width = adjustWidth(2 * btn.leftRightMargin) // controlRoot.height = adjustHeight(2 * btn.upDownMargin) } + + onIconThemeChanged: { + var source0 = iconSource() + image.source = "" + image.source = source0 + image1.source = "" + image1.source = source0 + } + + onParametryChanged: { + var source0 = iconSource() + image.source = source0 + image1.source = source0 + } } // anchors.centerIn: controlRoot @@ -176,27 +193,36 @@ Item{ return leftSpace; } + anchors.right: parent.right + anchors.rightMargin: leftSpace anchors.verticalCenter: parent.verticalCenter Image { id: image source: iconSource()//controlRoot.icon.source anchors.verticalCenter: parent.verticalCenter - width: (controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null) ? 16 : 0 + sourceSize.width: (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconWidth : 0 + sourceSize.height: (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconHeight : 0 visible: controlRoot.display !== AbstractButton.TextOnly && source !== "" && status != Image.Null + cache: false + anchors.left: controlRoot.mirrored ? undefined : parent.left + anchors.right: controlRoot.mirrored ? parent.right : undefined } - Label { + Text { id:label text: controlRoot.text font: controlRoot.font - color: labelColor() + color: getStartColor(textColor) visible: controlRoot.display !== AbstractButton.IconOnly && text !== "" + elide: Text.ElideRight anchors.verticalCenter: parent.verticalCenter - anchors.left: image.right - anchors.leftMargin: (image.visible && image.status !== Image.Null) ? labelSpace : 0 + anchors.left: controlRoot.mirrored ? undefined : image.right + anchors.leftMargin: controlRoot.mirrored ? undefined : ((image.visible && image.status !== Image.Null) ? labelSpace : 0) + anchors.right: controlRoot.mirrored ? image.left : parent.right +// anchors.rightMargin: controlRoot.mirrored ? ((image.visible && image.status !== Image.Null) ? labelSpace : 0) : 0 } } @@ -223,17 +249,18 @@ Item{ anchors.centerIn: parent Image { id: image1 - source: iconSource()//controlRoot.icon.source + source: image.source//controlRoot.icon.source anchors.horizontalCenter: parent.horizontalCenter - width: visible ? 16 : 0 - height: visible ? 16 : 0 + sourceSize.width: (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconWidth : 0 + sourceSize.height: (controlRoot.display !== AbstractButton.TextOnly && source !== "") ? iconHeight : 0 visible: controlRoot.display !== AbstractButton.TextOnly && source !== "" /*&& status != Image.Null*/ + cache: false } - Label { + Text { id:label1 text: controlRoot.text font:controlRoot.font - color: labelColor() + color: getStartColor(textColor) visible: controlRoot.display !== AbstractButton.IconOnly && text !== "" anchors.horizontalCenter: parent.horizontalCenter @@ -243,6 +270,11 @@ Item{ } Component.onCompleted: { + if(controlRoot.icon.width > 0 ) + iconWidth = controlRoot.icon.width + if(controlRoot.icon.height > 0 ) + iconHeight = controlRoot.icon.height + implicitWidth = adjustWidth(0); implicitHeight = adjustHeight(0); } @@ -251,6 +283,12 @@ Item{ implicitWidth = adjustWidth(0); implicitHeight = adjustHeight(0); } - + Connections { + target: controlRoot + // function onEnabledChanged(){ + // image.source = iconSource() + // image1.source = iconSource() + // } + } } diff --git a/ukui-qqc2-style/org.ukui.style/private/NormalBack.qml b/ukui-qqc2-style/org.ukui.style/private/NormalBack.qml new file mode 100644 index 0000000..a73a5cd --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/private/NormalBack.qml @@ -0,0 +1,240 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.6 +import QtGraphicalEffects 1.0 +import QtQuick.Controls 2.5 as Controls +import QtQuick.Templates 2.5 as T +import QtQuick.Window 2.15 +import org.ukui.qqc2style.private 1.0 as StylePrivate + + Rectangle { + id: popupwindow + width: windowLabel.implicitWidth + 2 * tooltip.padding + height: windowLabel.implicitHeight + 2 * tooltip.padding + visible: true + radius: tooltip.radius + color: { + // console.log("normalrec color:", getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor).r) + return Qt.rgba(getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor).r, + getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor).g, + getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor).b, + 1) + } + opacity: 1 + + property T.ToolTip controlRoot + // margins: tooltip.margins + //padding: tooltip.padding +// flags: Qt.NoFocus + Rectangle{ + anchors.fill: parent + color: "transparent" + border.color: getStartColor(isTransaprent ? tooltip.backBorderTransparentColor : tooltip.backBorderColor) + border.width: 1 + radius: parent.radius + } + + ParseInterface{ + id: parseInterface + } + StylePrivate.APPParameter{ + id: appP + onParametryChanged: { + // console.log("parametryyyyyyyy") + // var c = getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor) + // console.log("parametryyyyyyyy", c.r, c.g, c.b) + } + } + + StylePrivate.UKUIToolTip{ + id: tooltip + } + function getStartColor(dtcolor) + { + return parseInterface.pStartColor(dtcolor) + } + function getEndColor(dtcolor) + { + return parseInterface.pEndColor(dtcolor) + } + + function setControlRoot(control){ + controlRoot = control + } + + Connections{ + target: controlRoot + function onVisibleChanged() { + popupwindow.visible = controlRoot.visible + } + function onXChanged(){ + return popupwindow.x = Math.max(controlRoot.width - popupwindow.width, 0) + } + } + Component.onCompleted: { + // var c = getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor) + // popupwindow.color = Qt.rgba(c.red, c.green, c.blue, 255) + popupwindow.opacity = 1 + if(controlRoot){ + adjustSize() + } + } + + onVisibleChanged: { + if(visible && controlRoot){ + adjustSize(); + } + } + + // Rectangle{ + // id: rec + // visible: parent.visible + // anchors.fill: parent + // radius: tooltip.radius + // color: getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor) + // border.color: getStartColor(isTransaprent ? tooltip.backBorderTransparentColor : tooltip.backBorderColor) + // opacity: 1 + // border.width: 1 + + // } + TextMetrics{ + id: metrics + font: windowLabel.font + text: windowLabel.text + } + Controls.Label { + id: windowLabel + anchors.fill: parent + anchors.leftMargin: tooltip.padding + anchors.rightMargin: tooltip.padding + anchors.topMargin: tooltip.padding + anchors.bottomMargin: tooltip.padding + + anchors.centerIn: parent + visible: parent.visible + text: controlRoot ? controlRoot.text : "" + wrapMode: controlRoot ? controlRoot.mode : Text.NoWrap + font: controlRoot ? controlRoot.font : appP.font + color: getStartColor(tooltip.textColor) + textFormat: controlRoot ? controlRoot._textFormat : Qt.PlainText + onTextChanged: { + metrics.text = text + + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + if(controlRoot._maxWidth != 0) + if((metrics.width + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = metrics.width + + 2 * tooltip.padding + else{ + if(Window.width > 20) + popupwindow.width = Math.min(controlRoot._maxWidth, Window.width - 20) + else + popupwindow.width = controlRoot._maxWidth + } + + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + adjustSize() + } + + onWidthChanged: { + adjustSize() + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + if(controlRoot._maxWidth != 0 && (metrics.width + + 2 * tooltip.padding) < controlRoot._maxWidth){ + popupwindow.width = metrics.width + + 2 * tooltip.padding + } + } + } + onHeightChanged: { + adjustSize() + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + } + } + Component.onCompleted: { + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + } + } + } + + function setPosition() { + var window = popupwindow.Window.window; + if (!window) return; + var contentItem = window.contentItem; + var p = appP.posByCursor(popupwindow.width, popupwindow.height) + + var pointInContent = contentItem.mapFromGlobal(p.x, p.y); + var pointInParent = popupwindow.parent.mapFromItem(contentItem, pointInContent.x, pointInContent.y); + controlRoot.x = pointInParent.x; + controlRoot.y = pointInParent.y; + } + function adjustSize(){ + if(visible && controlRoot){ + // var p = appP.posByCursor(popupwindow.width, popupwindow.height) + // console.log("rec visible p", p.x, p.y) + // console.log("rec visible p", popupwindow.mapFromGlobal(p.x, p.y)) + // console.log("rec visible p", windowLabel.mapFromGlobal(p.x, p.y)) + + // p = popupwindow.mapFromGlobal(p.x, p.y) + // console.log("rec visible p1", p.x, p.y) + + // controlRoot.x = p.x + // controlRoot.y = p.y + + controlRoot.implicitWidth = popupwindow.width + controlRoot.implicitHeight = popupwindow.height + controlRoot.x = controlRoot.parent ? (parent.width - popupwindow.width)/2 : 0 + controlRoot.y = -popupwindow.height -3 + // console.log("rec visible controlRoot", controlRoot.parent, controlRoot.x, controlRoot.y) + // var p = popupwindow.mapToGlobal(popupwindow.x, popupwindow.y) + // var l = appP.posByCursor(popupwindow.width, popupwindow.height).x - (p.x) + // console.log("lllllllllllllllllllllll", popupwindow.x, p.x, popupwindow.width, appP.posByCursor(popupwindow.width, popupwindow.height).x, l) + // if(l > 10){ + // popupwindow.x = l + // } + // setPosition() + + } + + + let current = parent + var window = Window + while (current && current.parent) { + current = current.parent + } + // 如果顶层对象是 Window 则返回 + if (current && current.hasOwnProperty("window")) { + window = current.window + } + if(window.width > 0 && controlRoot.x + popupwindow.width > window.width){ + if(popupwindow.width > window.width && window.width > 20) + popupwindow.width = window.width - 20 + controlRoot.x = window.width - popupwindow.width + } + } + } + + diff --git a/ukui-qqc2-style/org.ukui.style/private/ParseInterface.qml b/ukui-qqc2-style/org.ukui.style/private/ParseInterface.qml index 501d867..f2f0ff3 100644 --- a/ukui-qqc2-style/org.ukui.style/private/ParseInterface.qml +++ b/ukui-qqc2-style/org.ukui.style/private/ParseInterface.qml @@ -47,6 +47,71 @@ Item { if((controlRoot.icon.source.toString() === "" && controlRoot.icon.name.toString() === "")){ return controlRoot.icon.source } + var closeBtn = false; + var windowBtn = false; + var importBtn = false; + if(controlRoot.hasOwnProperty("buttonType")){ + closeBtn = (controlRoot.buttonType === "closeButton" || controlRoot.buttonType === "windowTitleBarCloseButton"); + windowBtn = (controlRoot.buttonType === "windowButton" || controlRoot.buttonType === "windowTitleBarWindowButton"); + importBtn = (controlRoot.buttonType === "importButton"); + } + var model = ""; + var active = Qt.application.active + if(controlRoot.hasOwnProperty("buttonType") && (controlRoot.buttonType === "windowTitleBarCloseButton" || + controlRoot.buttonType === "windowTitleBarWindowButton")){ + if(!active && !(controlRoot.hovered || controlRoot.pressed)){ + if(appP.isDark) + model = "/highDisbale" + else + model = "/disenable" + } + } + /*if(!controlRoot.enabled && ) + model = "/disenable" + else */ + if(model === ""){ + if(!controlRoot.flat && (importBtn || controlRoot.highlighted || appP.isDark)) + model = "/highlight" + else if((controlRoot.flat && appP.isDark )|| + ((closeBtn || (controlRoot.flat &&(importBtn || controlRoot.highlighted || appP.isDark))) && + (controlRoot.pressed || controlRoot.hovered))) + + { + model = "/highlight" + } + else if(!controlRoot.enabled) + model = "/disenable" + else if(model === "" && controlRoot.enabled) + model = "/normal" + } + + if(model == "/highlight" && !controlRoot.enabled) + model = "/highDisbale" + + let s = controlRoot.icon.source.toString(); + if(s === "") + s = controlRoot.icon.name.toString(); + var lastS =pf.endString(s, "/"); + if(lastS === "disenable" || lastS === "highlight" || lastS === "normal" || lastS === "highDisbale") + model = ""; + + //var prefix = /^image:///imageProvider///i; + var prefixStr = "image://imageProvider/"; + // var qrcStr = "qrc:/"; + // console.log("start width...", s.slice(0, 5), s.slice(0, prefixStr.length)) + if(s.slice(0, 5) === "qrc:/" || s.slice(0, 5) === "file:") + { + return prefixStr + s + model; + } + + if(s.slice(0, prefixStr.length).toLowerCase() === prefixStr.toLowerCase()){ + prefixStr = ""; + } +// console.log("buttoniconlabel...", prefixStr + s + model) + return prefixStr + s + model; + } + + function buttonIcon(controlRoot, iconName){ var closeBtn = false; var windowBtn = false; var importBtn = false; @@ -56,23 +121,26 @@ Item { importBtn = (controlRoot.buttonType === "importButton"); } var model = ""; - if(!controlRoot.enabled) + /*if(!controlRoot.enabled && ) model = "/disenable" - + else */ if(!controlRoot.flat && (importBtn || controlRoot.highlighted || appP.isDark)) model = "/highlight" - else if((closeBtn || (controlRoot.flat &&(importBtn || controlRoot.highlighted || appP.isDark))) &&(controlRoot.pressed || controlRoot.hovered)) + else if((controlRoot.flat && appP.isDark )|| (closeBtn || (controlRoot.flat &&(importBtn || controlRoot.highlighted || appP.isDark))) &&(controlRoot.pressed || controlRoot.hovered)) { model = "/highlight" } - else + else if(!controlRoot.enabled) + model = "/disenable" + else if(controlRoot.enabled) model = "/normal" - let s = controlRoot.icon.source.toString(); - if(s === "") - s = controlRoot.icon.name.toString(); + if(model == "/highlight" && !controlRoot.enabled) + model = "/highDisbale" + + let s = iconName var lastS =pf.endString(s, "/"); - if(lastS == "disenable" || lastS == "highlight" || lastS == "normal") + if(lastS === "disenable" || lastS === "highlight" || lastS === "normal" || lastS === "highDisbale") model = ""; //var prefix = /^image:///imageProvider///i; @@ -81,7 +149,7 @@ Item { // console.log("start width...", s.slice(0, 5), s.slice(0, prefixStr.length)) if(s.slice(0, 5) === "qrc:/" || s.slice(0, 5) === "file:") { - return prefixStr + s; + return prefixStr + s + model; } if(s.slice(0, prefixStr.length).toLowerCase() === prefixStr.toLowerCase()){ @@ -89,6 +157,18 @@ Item { } // console.log("buttoniconlabel...", prefixStr + s + model) return prefixStr + s + model; + } + function kyIconSource(controlRoot) + { + let s = controlRoot.icon.source.toString(); + if(s === "") + s = controlRoot.icon.name.toString(); + return s + } + + function getDTColor(dtColor){ + return pf.getDtColor(dtColor); + } } diff --git a/ukui-qqc2-style/org.ukui.style/private/RadiusRectangle.qml b/ukui-qqc2-style/org.ukui.style/private/RadiusRectangle.qml index ea278b9..992097a 100644 --- a/ukui-qqc2-style/org.ukui.style/private/RadiusRectangle.qml +++ b/ukui-qqc2-style/org.ukui.style/private/RadiusRectangle.qml @@ -97,9 +97,9 @@ Item{ ctx.fill(); // 绘制边框 - ctx.strokeStyle = getStartColor(borderColor); - ctx.lineWidth = borderWidth; - ctx.stroke(); +// ctx.strokeStyle = getStartColor(borderColor); +// ctx.lineWidth = borderWidth; +// ctx.stroke(); } // 鼠标点击事件(模拟按钮点击) diff --git a/ukui-qqc2-style/org.ukui.style/private/WindowBack.qml b/ukui-qqc2-style/org.ukui.style/private/WindowBack.qml new file mode 100644 index 0000000..298e664 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/private/WindowBack.qml @@ -0,0 +1,158 @@ +/* + * Qt5-UKUI's Library + * + * Copyright (C) 2023, KylinSoft Co., Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see . + * + * Authors: Jing Tan + * + */ + +import QtQuick 2.6 +import QtGraphicalEffects 1.0 +import QtQuick.Controls 2.5 as Controls +import QtQuick.Templates 2.5 as T +import QtQuick.Window 2.15 +import org.ukui.qqc2style.private 1.0 as StylePrivate + + Window { + id: popupwindow + width: windowLabel.implicitWidth + 2 * tooltip.padding + height: windowLabel.implicitHeight + 2 * tooltip.padding + visible: controlRoot.visible + color: "transparent" + property T.ToolTip controlRoot + property alias handle: popHandle + // margins: tooltip.margins + //padding: tooltip.padding +// flags: Qt.NoFocus + + ParseInterface{ + id: parseInterface + } + StylePrivate.APPParameter{ + id: appP + } + + StylePrivate.UKUIToolTip{ + id: tooltip + } + function getStartColor(dtcolor) + { + return parseInterface.pStartColor(dtcolor) + } + function getEndColor(dtcolor) + { + return parseInterface.pEndColor(dtcolor) + } + + function setControlRoot(control){ + controlRoot = control + } + + onVisibleChanged: { + if(visible){ + var p = popHandle.posByCursor(popupwindow.width, popupwindow.height) + if(popupwindow.x !== p.x) + popupwindow.x = p.x + if(popupwindow.y !== p.y) + popupwindow.y = p.y + } + } + + StylePrivate.PopupHandle{ + id: popHandle + blur: true + titlebarVisible: false + anchors.fill: parent + posFollwMouse: true + visible: parent.visible + radius: tooltip.radius + windowStaysOnTopHint: true + } + + Rectangle{ + id: rec + visible: parent.visible + anchors.fill: parent + // radius: tooltip.radius + color: { + var baccolor = getStartColor(isTransaprent ? tooltip.backTransparentColor : tooltip.backColor) + return Qt.rgba(baccolor.r, baccolor.g, baccolor.b, (controlRoot ? controlRoot._opacity: 1.0)) + } + // border.color: getStartColor(isTransaprent ? tooltip.backBorderTransparentColor : tooltip.backBorderColor) + // border.width: 1 + + } + Controls.Label { + id: windowLabel + anchors.fill: rec + anchors.leftMargin: tooltip.padding + anchors.rightMargin: tooltip.padding + anchors.topMargin: tooltip.padding + anchors.bottomMargin: tooltip.padding + + + anchors.centerIn: rec + visible: rec.visible + text: controlRoot ? controlRoot.text : "" + wrapMode: controlRoot ? controlRoot.mode : Text.NoWrap + font: controlRoot ? controlRoot.font : appP.font + color: getStartColor(tooltip.textColor) + textFormat: controlRoot ? controlRoot._textFormat : Qt.PlainText + + onTextChanged: { + if(controlRoot) + { + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + if(controlRoot._maxWidth != 0) + if((windowLabel.implicitWidth + + 2 * tooltip.padding) < controlRoot._maxWidth) + popupwindow.width = windowLabel.implicitWidth + + 2 * tooltip.padding + else + popupwindow.width = controlRoot._maxWidth + // console.log("textchangeddd 111", popupwindow.width ) + + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + } + } + + onContentWidthChanged: { + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + if(controlRoot._maxWidth != 0 && (windowLabel.implicitWidth + + 2 * tooltip.padding) < controlRoot._maxWidth){ + popupwindow.width = windowLabel.implicitWidth + + 2 * tooltip.padding + } + } + + } + onContentHeightChanged: { + + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + } + } + Component.onCompleted: { + if(controlRoot){ + controlRoot.implicitWidth = Math.max(windowLabel.implicitWidth + 2 * tooltip.padding, 1) + controlRoot.implicitHeight = Math.max(windowLabel.implicitHeight+ 2 * tooltip.padding, 1) + } + } + + } + } + + diff --git a/ukui-qqc2-style/org.ukui.style/private/qmldir b/ukui-qqc2-style/org.ukui.style/private/qmldir new file mode 100644 index 0000000..57c12f5 --- /dev/null +++ b/ukui-qqc2-style/org.ukui.style/private/qmldir @@ -0,0 +1,5 @@ + +singleton MobileTextActionsToolBar 1.0 MobileTextActionsToolBar.qml +DefaultListItemBackground 1.0 DefaultListItemBackground.qml +MobileCursor 1.0 MobileCursor.qml +FocusRect 1.0 FocusRect.qml diff --git a/ukui-qqc2-style/org.ukui.style/qmldir b/ukui-qqc2-style/org.ukui.style/qmldir index 3559f3a..873a4cc 100644 --- a/ukui-qqc2-style/org.ukui.style/qmldir +++ b/ukui-qqc2-style/org.ukui.style/qmldir @@ -9,3 +9,5 @@ NormalControlColor 1.0 private/NormalControlColor.qml ButtonIconLabelContent 1.0 private/ButtonIconLabelContent.qml BackGroundRectangle 1.0 private/BackGroundRectangle.qml IconLabelContent 1.0 private/IconLabelContent.qml +NormalBack 1.0 private/NormalBack.qml +WindowBack 1.0 private/WindowBack.qml diff --git a/ukui-qqc2-style/qml.qrc b/ukui-qqc2-style/qml.qrc index ecbad0a..b0f4f3a 100644 --- a/ukui-qqc2-style/qml.qrc +++ b/ukui-qqc2-style/qml.qrc @@ -25,6 +25,10 @@ org.ukui.style/RadioDelegate.qml org.ukui.style/Switch.qml org.ukui.style/SwitchDelegate.qml + org.ukui.style/TextArea.qml + org.ukui.style/VerticalHeaderView.qml + org.ukui.style/HorizontalHeaderView.qml + org.ukui.style/Pane.qml org.ukui.style/private/RadiusRectangle.qml org.ukui.style/private/ParseInterface.qml org.ukui.style/private/NormalControlColor.qml @@ -36,5 +40,7 @@ org.ukui.style/private/ButtonIconLabelContent.qml org.ukui.style/private/BackGroundRectangle.qml org.ukui.style/BusyIndicator.qml + org.ukui.style/private/NormalBack.qml + org.ukui.style/private/WindowBack.qml diff --git a/ukui-styles/CMakeLists.txt b/ukui-styles/CMakeLists.txt index c80f3bc..f699404 100644 --- a/ukui-styles/CMakeLists.txt +++ b/ukui-styles/CMakeLists.txt @@ -29,6 +29,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_CURRENT_ find_package(Qt5Gui) +message(${imported_location}) +set(LIB_PATH ${imported_location}) +get_filename_component(PARENT_PATH "${LIB_PATH}" PATH) +get_filename_component(PARENT_PATH "${PARENT_PATH}" PATH) +message("qt5-style-ukui PARENT_PATH: ${PARENT_PATH}") + find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS DBus Widgets @@ -44,6 +50,7 @@ find_package(KF5Wayland CONFIG REQUIRED COMPONENTS) find_package(PkgConfig) pkg_check_modules(Qsettings REQUIRED gsettings-qt) pkg_check_modules(KYSDKCONF2 REQUIRED kysdk-conf2) +pkg_check_modules(UKUIWINDOWHELPER REQUIRED kysdk-ukuiwindowhelper) include_directories(${Qsettings_INCLUDE_DIRS}) #file(GLOB_RECURSE native_srcs /qt5-config-style-ukui/*.cpp) @@ -52,6 +59,11 @@ if (KYSDKCONF2_FOUND) link_directories(${KYSDKCONF2_LIBRARY_DIRS}) endif() +if (UKUIWINDOWHELPER_FOUND) + include_directories(${UKUIWINDOWHELPER_INCLUDE_DIRS}) + link_directories(${UKUIWINDOWHELPER_LIBRARY_DIRS}) +endif() + file(GLOB_RECURSE Header "*.h" "*.hpp" ) file(GLOB_RECURSE Src "*.cpp" "*.c") SOURCE_GROUP("header" FILES ${Header}) @@ -77,6 +89,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE gsettings-qt qt5-ukui-style ${KYSDKCONF2_LIBRARIES} + ${UKUIWINDOWHELPER_LIBRARIES} ) diff --git a/ukui-styles/blur-helper.cpp b/ukui-styles/blur-helper.cpp index fd1384b..da1dbc6 100644 --- a/ukui-styles/blur-helper.cpp +++ b/ukui-styles/blur-helper.cpp @@ -38,10 +38,10 @@ #include #include +#include "ukuiwindowhelper.h" -BlurHelper::BlurHelper(QObject *parent) : QObject(parent) +BlurHelper::BlurHelper(QObject *parent, bool systemEnable) : QObject(parent) { - qDebug() << "BlurHelper00000............."; if (QGSettings::isSchemaInstalled("org.ukui.control-center.personalise")) { QGSettings *settings = new QGSettings("org.ukui.control-center.personalise", QByteArray(), this); connect(settings, &QGSettings::changed, this, [=](const QString &key) { @@ -51,9 +51,10 @@ BlurHelper::BlurHelper(QObject *parent) : QObject(parent) } }); bool enable = settings->get("effect").toBool(); + m_system_enableBlur = systemEnable; this->onBlurEnableChanged(enable); - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) + if (!m_system_enableBlur/*!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)*/) confirmBlurEnableDelay(); } m_timer.setSingleShot(true); @@ -94,7 +95,11 @@ bool BlurHelper::eventFilter(QObject *obj, QEvent *e) } case QEvent::Hide: { //QWidget* widget = qobject_cast(obj); - KWindowEffects::enableBlurBehind(widget->winId(), false); + // KWindowEffects::enableBlurBehind(widget->winId(), false); + QRegion region(widget->geometry()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(region, 0, false); + } default: @@ -175,8 +180,11 @@ void BlurHelper::unregisterWidget(QWidget *widget) return; m_blur_widgets.removeOne(widget); widget->removeEventFilter(this); - if (widget->winId() > 0) - KWindowEffects::enableBlurBehind(widget->winId(), false); + if (widget){ + QRegion region(widget->geometry()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(region, 0, false); + } } #endif @@ -220,14 +228,16 @@ void BlurHelper::onBlurEnableChanged(bool enable) qApp->setProperty("blurEnable", false); } - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) + if (!m_system_enableBlur)//!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) return; for (auto widget : qApp->allWidgets()) { widget->update(); if (m_blur_widgets.contains(widget)) { - if (widget->winId() > 0) { - KWindowEffects::enableBlurBehind(widget->winId(), enable); + if (widget) { + QRegion region(widget->geometry()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(region, 0, enable); } } } @@ -253,7 +263,7 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) if (w->winId() <= 0) return; - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) + if (!m_system_enableBlur)//!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) return; m_update_list.append(w); @@ -288,7 +298,11 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) radius = settings->get("windowRadius").toInt(); } path.addRoundedRect(widget->rect(), radius, radius); - KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); + // KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); + + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(path.toFillPolygon().toPolygon()); + if (!updateBlurRegionOnly) widget->update(); break; @@ -302,8 +316,11 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) if(settings->keys().contains("windowRadius")) radius = settings->get("windowRadius").toInt(); } - path.addRoundedRect(widget->rect().adjusted(+4,+4,-4,-4), radius, radius); - KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); + path.addRoundedRect(widget->rect(), radius, radius); + // KWindowEffects::enableBlurBehind(widget->winId(), true, path.toFillPolygon().toPolygon()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(path.toFillPolygon().toPolygon()); + if (!updateBlurRegionOnly) widget->update(); break; @@ -316,12 +333,18 @@ void BlurHelper::delayUpdate(QWidget *w, bool updateBlurRegionOnly) //qDebug()<metaObject()->className()<geometry()<mask(); if (!region.isEmpty()) { //qDebug()<<"blur region"<winId(), true, region); + // KWindowEffects::enableBlurBehind(widget->winId(), true, region); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(region); + if (!updateBlurRegionOnly) widget->update(); } else { //qDebug()<mask(); - KWindowEffects::enableBlurBehind(widget->winId(), true, widget->mask()); + // KWindowEffects::enableBlurBehind(widget->winId(), true, widget->mask()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(widget->mask()); + if (!updateBlurRegionOnly) widget->update(widget->mask()); } @@ -350,8 +373,12 @@ void BlurHelper::confirmBlurEnableDelay() for (auto widget : qApp->allWidgets()) { widget->update(); if (m_blur_widgets.contains(widget)) { - if (widget->winId() > 0) - KWindowEffects::enableBlurBehind(widget->winId(), enable); + if (widget->winId() > 0){ + // KWindowEffects::enableBlurBehind(widget->winId(), enable); + QRegion region(widget->geometry()); + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setBlurEffect(region, 0, enable); + } } } // QTimer::singleShot(100, this, [=](){ diff --git a/ukui-styles/blur-helper.h b/ukui-styles/blur-helper.h index fae5cf8..465d08c 100644 --- a/ukui-styles/blur-helper.h +++ b/ukui-styles/blur-helper.h @@ -30,7 +30,7 @@ class BlurHelper : public QObject { Q_OBJECT public: - explicit BlurHelper(QObject *parent = nullptr); + explicit BlurHelper(QObject *parent = nullptr, bool systemEnableBlur = true); ~BlurHelper(); bool eventFilter(QObject *obj, QEvent *e); @@ -67,6 +67,7 @@ private: QTimer m_timer; bool m_blur_enable = true; + bool m_system_enableBlur = true; }; #endif // BLURHELPER_H diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.cpp b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.cpp index 6df32f6..723d7d1 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.cpp +++ b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.cpp @@ -21,46 +21,53 @@ */ #include "config-progressbar-animation-helper.h" +#include using namespace UKUIConfigStyleSpace; ConfigProgressBarAnimationHelper::ConfigProgressBarAnimationHelper(QObject *parent) : QObject(parent) { - animations = new QHash(); + animationsMap = new QHash(); } ConfigProgressBarAnimationHelper::~ConfigProgressBarAnimationHelper() { - for(auto item = animations->begin(); item != animations->end(); item++){ + for(auto item = animationsMap->begin(); item != animationsMap->end(); item++){ if(item.value()){ // delete item.value(); // item.value() = nullptr; } } - if(animations){ - delete animations; - animations = nullptr; + if(animationsMap){ + delete animationsMap; + animationsMap = nullptr; } } -void ConfigProgressBarAnimationHelper::startAnimation(QVariantAnimation *animation) +void ConfigProgressBarAnimationHelper::initAnimationMap(QWidget* w, QVariantAnimation *animation) { - stopAnimation(animation->parent()); - connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); - animations->insert(animation->parent(), animation); + if (!w || !animation) + return ; + stopAnimation(w); + // connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection); + // animationsMap->remove(w); + connect(w, &QWidget::destroyed, [&, w](){ + animationsMap->remove(w); + }); + animationsMap->insert(w, animation); // animation->start(); } -void ConfigProgressBarAnimationHelper::stopAnimation(QObject *target) +void ConfigProgressBarAnimationHelper::stopAnimation(QWidget *target) { - QVariantAnimation *animation = animations->take(target); + QVariantAnimation *animation = animationsMap->take(target); if (animation) { animation->stop(); delete animation; @@ -70,18 +77,18 @@ void ConfigProgressBarAnimationHelper::stopAnimation(QObject *target) -QVariantAnimation* ConfigProgressBarAnimationHelper::animation(QObject *target) +QVariantAnimation* ConfigProgressBarAnimationHelper::getAnimation(QWidget* w) { - return animations->value(target); + return animationsMap->value(w); } void ConfigProgressBarAnimationHelper::_q_removeAnimation() { - QObject *animation = this->sender(); - if (animation) - animations->remove(animation->parent()); + // QObject *animation = this->sender(); + // if (animation) + // animationsMap->remove(animation->parent()); } @@ -95,6 +102,11 @@ void ConfigProgressBarAnimationHelper::getTotalBarInfo(int& width,int& height) c width = totalBarWidth; height = totalBarHeight; } +//是否达到绘制白色块的条件 +bool ConfigProgressBarAnimationHelper::meetCondition(const int &conditionWidth) const +{ + return conditionWidth >= startThreshold; +} int ConfigProgressBarAnimationHelper::getSliderFixedSpan() const { return sliderFixedSpan; @@ -102,4 +114,17 @@ int ConfigProgressBarAnimationHelper::getSliderFixedSpan() const bool ConfigProgressBarAnimationHelper::canEnableNormalAnimation(int width) { return width >= startAnimationBaseWidth; -} \ No newline at end of file +} + +void ConfigProgressBarAnimationHelper::setAnimationDuration(QVariantAnimation *animation, int curPbWidth, double speed) { + if (!animation) + return ; + // if (speed < 0) + // speed = 0.0; + // if (speed > 1) + // speed = 1.0; + int baseValue = 2000; + // int duration = qRound(1.0 * baseValue + curPbWidth * speed); + int duration = 1.0 * baseValue + curPbWidth * speed; + animation->setDuration(duration); +} diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.h b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.h index 882591f..38a325f 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.h +++ b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation-helper.h @@ -37,9 +37,9 @@ public: ConfigProgressBarAnimationHelper(QObject *parent = nullptr); virtual ~ConfigProgressBarAnimationHelper(); - void startAnimation(QVariantAnimation *animation); - void stopAnimation(QObject *target); - QVariantAnimation* animation(QObject *target); + void initAnimationMap(QWidget* w, QVariantAnimation *animation); + void stopAnimation(QWidget *target); + QVariantAnimation* getAnimation(QWidget* w); private: //进度条normal动画滑片的一些参数 @@ -49,23 +49,29 @@ private: // const int baseMaxDuration = 4000; // const int baseMinDuration = 1000; - const int sliderFixedSpan = 150;//滑片本身固定宽度 - const int startAnimationBaseWidth = 200;//进度条达到200宽度才开始光片移动动画 + const int sliderFixedSpan = 80;//滑片本身固定宽度 + const int startAnimationBaseWidth = 150;//进度条达到150宽度才开始光片移动动画 int totalBarWidth;//进度条整体宽度 int totalBarHeight;//进度条整体高度 + + const int startThreshold = 200; public: bool canEnableNormalAnimation(int width); int getSliderFixedSpan() const; void cacheTotalBarInfo(const int& width,const int& height);//存储进度条信息,宽,高 void getTotalBarInfo(int& width,int& height) const;//获取进度条信息,宽,高 + bool meetCondition(const int& conditionWidth) const; + +public: + void setAnimationDuration(QVariantAnimation *animation, int curPbWidth, double speed); public slots: void _q_removeAnimation(); private: - QHash *animations = nullptr; + QHash *animationsMap = nullptr; }; } #endif // PROGRESSBARANIMATIONHELPER_H diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation.cpp b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation.cpp index 43dd14a..863858e 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation.cpp +++ b/ukui-styles/qt5-config-style-ukui/animations/config-progressbar-animation.cpp @@ -25,7 +25,9 @@ using namespace UKUIConfigStyleSpace; // ConfigProgressBarAnimation::ConfigProgressBarAnimation(QObject *parent) : QVariantAnimation (parent) -ConfigProgressBarAnimation::ConfigProgressBarAnimation(QObject *parent, ProgressBarStatus curStatus) : QVariantAnimation (parent) + +ConfigProgressBarAnimation::ConfigProgressBarAnimation(QObject *parent, ProgressBarStatus curStatus) + : QVariantAnimation (parent) { // init(); init(curStatus); diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.cpp b/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.cpp index 93db765..a0038d7 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.cpp +++ b/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.cpp @@ -52,6 +52,10 @@ ConfigRadioButtonAnimator::~ConfigRadioButtonAnimator() m_on_hover->deleteLater(); m_on_hover = nullptr; } + if (m_sunken_onhover) { + m_sunken_onhover->deleteLater(); + m_sunken_onhover = nullptr; + } } bool ConfigRadioButtonAnimator::bindWidget(QWidget *w) @@ -115,7 +119,7 @@ bool ConfigRadioButtonAnimator::bindWidget(QWidget *w) //OnHover 动画初始化 m_on_hover = new QVariantAnimation(this); m_on_hover->setStartValue(1.0); - m_on_hover->setEndValue(1.5); + m_on_hover->setEndValue(1.4); m_on_hover->setDuration(200); m_on_hover->setEasingCurve(QEasingCurve::Linear); @@ -128,6 +132,23 @@ bool ConfigRadioButtonAnimator::bindWidget(QWidget *w) w->update(); }); + //m_sunken_onhover动画初始化 + m_sunken_onhover = new QVariantAnimation(this); + m_sunken_onhover->setStartValue(1.0); + m_sunken_onhover->setEndValue(1.2); + m_sunken_onhover->setDuration(200); + m_sunken_onhover->setEasingCurve(QEasingCurve::Linear); + + addAnimation(m_sunken_onhover); + + connect(m_sunken_onhover, &QVariantAnimation::valueChanged, w, [=](const QVariant &value) { + w->update(); + }); + connect(m_sunken_onhover, &QVariantAnimation::finished, w, [=]() { + w->update(); + }); + + return true; } @@ -152,6 +173,10 @@ bool ConfigRadioButtonAnimator::unboundWidget() m_on_hover->deleteLater(); m_on_hover = nullptr; } + if (m_sunken_onhover) { + m_sunken_onhover->deleteLater(); + m_sunken_onhover = nullptr; + } if (m_widget) { this->setParent(nullptr); @@ -171,7 +196,11 @@ QVariant ConfigRadioButtonAnimator::value(const QString &property) return m_off_hover->currentValue(); } else if (property == "OnHover") { return m_on_hover->currentValue(); - } else { + } else if (property == "SunkenOnHover") { + return m_sunken_onhover->currentValue(); + } + + else { return QVariant(); } } @@ -186,7 +215,10 @@ bool ConfigRadioButtonAnimator::isRunning(const QString &property) return m_off_hover->state() == Running; } else if (property == "OnHover") { return m_on_hover->state() == Running; - } else { + } else if (property == "SunkenOnHover") { + return m_sunken_onhover->state() == Running; + } + else { return this->state() == Running; } } @@ -200,7 +232,10 @@ bool ConfigRadioButtonAnimator::isStopped(const QString &property) return m_off_hover->state() == Stopped; } else if (property == "OnHover") { return m_on_hover->state() == Stopped; - } else { + } else if (property == "SunkenOnHover") { + return m_sunken_onhover->state() == Stopped; + } + else { return this->state() == Stopped; } } @@ -219,7 +254,13 @@ bool ConfigRadioButtonAnimator::setAnimatorStartValue(const QString &property, c } else if (property == "OnHover") { m_on_hover->setStartValue(value); return true; - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->setStartValue(value); + return true; + } + + + else { return false; } } @@ -238,7 +279,12 @@ bool ConfigRadioButtonAnimator::setAnimatorEndValue(const QString &property, con } else if (property == "OnHover") { m_on_hover->setEndValue(value); return true; - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->setEndValue(value); + return true; + } + + else { return false; } } @@ -257,7 +303,12 @@ bool ConfigRadioButtonAnimator::setAnimatorDuration(const QString &property, int } else if (property == "OnHover") { m_on_hover->setDuration(duration); return true; - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->setDuration(duration); + + return true; + } + else { return false; } } @@ -273,7 +324,10 @@ void ConfigRadioButtonAnimator::setAnimatorDirectionForward(const QString &prope m_off_hover->setDirection(d); } else if (property == "OnHover") { m_on_hover->setDirection(d); - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->setDirection(d); + } + else { return; } } @@ -287,7 +341,10 @@ void ConfigRadioButtonAnimator::startAnimator(const QString &property) m_off_hover->start(); } else if (property == "OnHover") { m_on_hover->start(); - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->start(); + } + else { this->start(); } } @@ -306,7 +363,11 @@ void ConfigRadioButtonAnimator::stopAnimator(const QString &property) } else if (property == "OnHover") { m_on_hover->stop(); m_on_hover->setCurrentTime(0); - } else { + } else if (property == "SunkenOnHover") { + m_sunken_onhover->stop(); + m_sunken_onhover->setCurrentTime(0); + } + else { this->stop(); this->setCurrentTime(0); } @@ -325,7 +386,11 @@ int ConfigRadioButtonAnimator::currentAnimatorTime(const QString &property) } if (property == "OnHover") { return m_on_hover->currentTime(); - } else { + } + if (property == "SunkenOnHover") { + return m_sunken_onhover->currentTime(); + } + else { return this->currentTime(); } } @@ -340,6 +405,8 @@ void ConfigRadioButtonAnimator::setAnimatorCurrentTime(const QString &property, m_off_hover->setCurrentTime(msecs); } else if ("OnHover" == property) { m_on_hover->setCurrentTime(msecs); + } else if ("SunkenOnHover" == property) { + m_sunken_onhover->setCurrentTime(msecs); } } @@ -356,9 +423,12 @@ int ConfigRadioButtonAnimator::totalAnimationDuration(const QString &property) } if (property == "OnHover") { return m_on_hover->duration(); + } + if (property == "SunkenOnHover") { + return m_sunken_onhover->duration(); } else { return this->duration(); } - + } diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.h b/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.h index 35fd42d..7702d0a 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.h +++ b/ukui-styles/qt5-config-style-ukui/animations/config-radiobutton-animator.h @@ -65,6 +65,8 @@ private: QVariantAnimation* m_off_hover = nullptr;//用于按钮off(unchecked)状态下的hover的动画对象 QVariantAnimation* m_on_hover = nullptr;//用于按钮on(checked)状态下hover的动画对象 + + QVariantAnimation* m_sunken_onhover = nullptr;//用于按钮on状态下,鼠标按压-松开过程的动画,动画内容和普通onhover基本上一样 }; } diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.cpp b/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.cpp index 3c92579..be4f54a 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.cpp +++ b/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.cpp @@ -27,6 +27,8 @@ #include +#include + using namespace UKUIConfigStyleSpace; ConfigSliderAnimator::ConfigSliderAnimator(QObject *parent) : QParallelAnimationGroup (parent) @@ -52,6 +54,14 @@ ConfigSliderAnimator::~ConfigSliderAnimator() m_silder_move_position->deleteLater(); m_silder_move_position = nullptr; } + if (m_hover_zoomin) { + m_hover_zoomin->deleteLater(); + m_hover_zoomin = nullptr; + } + if (m_click_zoomin) { + m_click_zoomin->deleteLater(); + m_click_zoomin = nullptr; + } } /*! @@ -111,6 +121,25 @@ bool ConfigSliderAnimator::bindWidget(QWidget *w) m_silder_move_position->setEasingCurve(QEasingCurve::InOutCubic); addAnimation(m_silder_move_position); + + //hover animation + m_hover_zoomin = new QVariantAnimation(this); + m_hover_zoomin->setStartValue(1.0); + m_hover_zoomin->setEndValue(1.125); + m_hover_zoomin->setDuration(100); + m_hover_zoomin->setEasingCurve(QEasingCurve::InOutCubic); + addAnimation(m_hover_zoomin); + + //click animation + m_click_zoomin = new QVariantAnimation(this); + m_click_zoomin->setStartValue(0.0); + m_click_zoomin->setEndValue(1.0); + m_click_zoomin->setDuration(100); + m_click_zoomin->setEasingCurve(QEasingCurve::InOutCubic); + addAnimation(m_click_zoomin); + + + connect(m_slider_opacity, &QVariantAnimation::valueChanged, w, [=]() { w->update(); }); @@ -136,6 +165,20 @@ bool ConfigSliderAnimator::bindWidget(QWidget *w) w->update(); }); + connect(m_hover_zoomin, &QVariantAnimation::valueChanged, w, [=]() { + w->update(); + }); + connect(m_hover_zoomin, &QVariantAnimation::finished, w, [=]() { + w->update(); + }); + + connect(m_click_zoomin, &QVariantAnimation::valueChanged, w, [=]() { + w->update(); + }); + connect(m_click_zoomin, &QVariantAnimation::finished, w, [=]() { + w->update(); + }); + return true; } @@ -159,6 +202,14 @@ bool ConfigSliderAnimator::unboundWidget() m_silder_move_position->deleteLater(); m_silder_move_position = nullptr; } + if (m_hover_zoomin) { + m_hover_zoomin->deleteLater(); + m_hover_zoomin = nullptr; + } + if (m_click_zoomin) { + m_click_zoomin->deleteLater(); + m_click_zoomin = nullptr; + } if (m_widget) { this->setParent(nullptr); @@ -177,6 +228,10 @@ QVariant ConfigSliderAnimator::value(const QString &property) return m_silder_move_position->currentValue(); } else if (property == "bg_width") { return m_hover_bg_width->currentValue(); + } else if (property == "hover_zoomin") { + return m_hover_zoomin->currentValue(); + } else if (property == "click_zoomin") { + return m_click_zoomin->currentValue(); } else { return QVariant(); } @@ -187,16 +242,21 @@ bool ConfigSliderAnimator::setAnimatorStartValue(const QString &property, const if (property == "slider_opacity") { m_slider_opacity->setStartValue(value); return true; - } else if (property == "additional_opacity") - { + } else if (property == "additional_opacity") { m_sunken_silder_additional_opacity->setStartValue(value); return true; - } else if (property == "move_position") { + } else if (property == "move_position") { m_silder_move_position->setStartValue(value); return true; } else if (property == "bg_width") { m_hover_bg_width->setStartValue(value); return true; + } else if (property == "hover_zoomin") { + m_hover_zoomin->setStartValue(value); + return true; + } else if (property == "click_zoomin") { + m_click_zoomin->setStartValue(value); + return true; } else { return false; } @@ -216,6 +276,12 @@ bool ConfigSliderAnimator::setAnimatorEndValue(const QString &property, const QV } else if (property == "bg_width") { m_hover_bg_width->setEndValue(value); return true; + } else if (property == "hover_zoomin") { + m_hover_zoomin->setEndValue(value); + return true; + } else if (property == "click_zoomin") { + m_click_zoomin->setEndValue(value); + return true; } else { return false; } @@ -231,6 +297,10 @@ QVariant ConfigSliderAnimator::animatorStartValue(const QString &property) return m_silder_move_position->startValue(); } else if (property == "bg_width") { return m_hover_bg_width->startValue(); + } else if (property == "hover_zoomin") { + return m_hover_zoomin->startValue(); + } else if (property == "click_zoomin") { + return m_click_zoomin->startValue(); } else { return QVariant(); } @@ -246,6 +316,10 @@ QVariant ConfigSliderAnimator::animatorEndValue(const QString &property) return m_silder_move_position->endValue(); } else if (property == "bg_width") { return m_hover_bg_width->endValue(); + } else if (property == "hover_zoomin") { + return m_hover_zoomin->endValue(); + } else if (property == "click_zoomin") { + return m_click_zoomin->endValue(); } else { return QVariant(); } @@ -266,6 +340,12 @@ bool ConfigSliderAnimator::setAnimatorDuration(const QString &property, int dura } else if (property == "bg_width") { m_hover_bg_width->setDuration(duration); return true; + } else if (property == "hover_zoomin") { + m_hover_zoomin->setDuration(duration); + return true; + } else if (property == "click_zoomin") { + m_click_zoomin->setDuration(duration); + return true; } else { return false; } @@ -282,6 +362,10 @@ void ConfigSliderAnimator::setAnimatorDirectionForward(const QString &property, m_silder_move_position->setDirection(d); } else if (property == "bg_width") { m_hover_bg_width->setDirection(d); + } else if (property == "hover_zoomin") { + m_hover_zoomin->setDirection(d); + } else if (property == "click_zoomin") { + m_click_zoomin->setDirection(d); } else { return; } @@ -297,6 +381,10 @@ bool ConfigSliderAnimator::isRunning(const QString &property) return m_silder_move_position->state() == Running; } else if (property == "bg_width") { return m_hover_bg_width->state() == Running; + } else if (property == "hover_zoomin") { + return m_hover_zoomin->state() == Running; + } else if (property == "click_zoomin") { + return m_click_zoomin->state() == Running; } else { return this->state() == Running; } @@ -312,6 +400,10 @@ void ConfigSliderAnimator::startAnimator(const QString &property) m_silder_move_position->start(); } else if (property == "bg_width") { m_hover_bg_width->start(); + } else if (property == "hover_zoomin") { + m_hover_zoomin->start(); + } else if (property == "click_zoomin") { + m_click_zoomin->start(); } else { this->start(); } @@ -327,6 +419,10 @@ void ConfigSliderAnimator::stopAnimator(const QString &property) m_silder_move_position->stop(); } else if (property == "bg_width") { m_hover_bg_width->stop(); + } else if (property == "hover_zoomin") { + m_hover_zoomin->stop(); + } else if (property == "click_zoomin") { + m_click_zoomin->stop(); } else { this->stop(); } @@ -342,6 +438,10 @@ int ConfigSliderAnimator::currentAnimatorTime(const QString &property) return m_silder_move_position->currentTime(); } else if (property == "bg_width") { return m_hover_bg_width->currentTime(); + } else if (property == "hover_zoomin") { + return m_hover_zoomin->currentTime(); + } else if (property == "click_zoomin") { + return m_click_zoomin->currentTime(); } else { return this->currentTime(); } @@ -351,6 +451,10 @@ void ConfigSliderAnimator::setAnimatorCurrentTime(const QString &property, const { if ("move_position" == property) { m_silder_move_position->setCurrentTime(msecs); + } else if("hover_zoomin" == property) { + m_hover_zoomin->setCurrentTime(msecs); + } else if("click_zoomin" == property) { + m_click_zoomin->setCurrentTime(msecs); } } @@ -365,6 +469,10 @@ int ConfigSliderAnimator::totalAnimationDuration(const QString &property) return m_silder_move_position->duration(); } else if (property == "bg_width") { return m_hover_bg_width->duration(); + } else if (property == "hover_zoomin") { + return m_hover_zoomin->duration(); + } else if (property == "click_zoomin") { + return m_click_zoomin->duration(); } else { return this->duration(); } diff --git a/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.h b/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.h index 501ff27..38e6bf8 100644 --- a/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.h +++ b/ukui-styles/qt5-config-style-ukui/animations/config-slider-animator.h @@ -25,6 +25,7 @@ #include #include "animations/animator-iface.h" +#include class QVariantAnimation; @@ -59,6 +60,7 @@ public: void setExtraProperty(const QString &property, const QVariant &value); QVariant getExtraProperty(const QString &property); + private: QWidget *m_widget = nullptr; @@ -69,6 +71,10 @@ private: int m_endPosition = 0; int m_startPosition = 0; bool m_addValue; + + QVariantAnimation* m_hover_zoomin = nullptr; + QVariantAnimation* m_click_zoomin = nullptr; + }; } diff --git a/ukui-styles/qt5-config-style-ukui/config-view-helper.cpp b/ukui-styles/qt5-config-style-ukui/config-view-helper.cpp index 87e5a2a..eb76553 100644 --- a/ukui-styles/qt5-config-style-ukui/config-view-helper.cpp +++ b/ukui-styles/qt5-config-style-ukui/config-view-helper.cpp @@ -171,7 +171,7 @@ void UKUIConfigStyle::viewItemLayout(const QStyleOptionViewItem *option, QRect *textRect = QRect(QPoint(0, 0), viewItemSize(option, Qt::DisplayRole)); *checkRect = QRect(QPoint(0, 0), viewItemSize(option, Qt::CheckStateRole)); - int Margin_Width = 2; + int Margin_Width = 0; int Margin_Height = 0; const QWidget *widget = option->widget; diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp index 4bc541f..e92cd10 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.cpp @@ -47,19 +47,20 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran using namespace UKUIConfigStyleSpace; -UKUIConfigStyleParameters::UKUIConfigStyleParameters(QObject *parent, bool isDark, QString cfgName) +UKUIConfigStyleParameters::UKUIConfigStyleParameters(QObject *parent, bool isDark, QString cfgName, bool isHardwareRendering) { - QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - "get_current_tabletmode"); - QDBusMessage ret = QDBusConnection::sessionBus().call(message); - if (ret.type() != QDBusMessage::ReplyMessage) { - //从返回参数获取返回值 - cDebug << "complex type failed!"; - } else { - m_isTableMode = ret.arguments()[0].value(); - } +// QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface", +// "/", +// "com.kylin.statusmanager.interface", +// "get_current_tabletmode"); +// QDBusMessage ret = QDBusConnection::sessionBus().call(message); +// if (ret.type() != QDBusMessage::ReplyMessage) { +// //从返回参数获取返回值 +// cDebug << "complex type failed!"; +// } else { +// m_isTableMode = ret.arguments()[0].value(); +// } + m_isHardwareRendering = isHardwareRendering; updateParameters(m_isTableMode); @@ -76,6 +77,7 @@ UKUIConfigStyleParameters::UKUIConfigStyleParameters(QObject *parent, bool isDar m_dtconfig = new UKUIGlobalDTConfig::GlobalDTConfig(); initPalette(); + initElemsDefaultStyleStrategy(); } UKUIConfigStyleParameters::~UKUIConfigStyleParameters() @@ -125,7 +127,8 @@ void UKUIConfigStyleParameters::initPalette() defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, m_dtconfig->buttonTextDisable().color()); defaultPalette.setColor(QPalette::Active, QPalette::Base, m_dtconfig->baseActive().color()); - defaultPalette.setColor(QPalette::Inactive, QPalette::Base, m_dtconfig->baseInactive().color()); + // defaultPalette.setColor(QPalette::Inactive, QPalette::Base, m_dtconfig->baseInactive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Base, m_dtconfig->baseActive().color()); defaultPalette.setColor(QPalette::Disabled, QPalette::Base, m_dtconfig->baseDisable().color()); defaultPalette.setColor(QPalette::Active, QPalette::Window, m_dtconfig->windowActive().color()); @@ -174,10 +177,10 @@ void UKUIConfigStyleParameters::initPalette() defaultPalette.setColor(QPalette::Disabled, QPalette::PlaceholderText, m_dtconfig->placeholderTextDisable().color()); #endif - Indicator_IconDefault = defaultPalette.color(QPalette::Active, QPalette::Mid); - Indicator_IconHover = defaultPalette.color(QPalette::Active, QPalette::Text); - Indicator_IconSunken = defaultPalette.color(QPalette::Active, QPalette::Text); - Indicator_IconDisable = defaultPalette.color(QPalette::Disabled, QPalette::Text); + Indicator_IconDefault = m_dtconfig->kFontPrimary().color(); + Indicator_IconHover = m_dtconfig->kFontPrimary().color(); + Indicator_IconSunken = m_dtconfig->kFontPrimary().color(); + Indicator_IconDisable = m_dtconfig->kFontPrimary().color(); } QPalette UKUIConfigStyleParameters::setPalette(QPalette &palette) @@ -327,11 +330,14 @@ void UKUIConfigStyleParameters::updateParameters(bool isTabletMode) CheckBox_DefaultHeight = CheckBox_DefaultHeight_origin * m_scaleRatio4_3; Table_HeaderHeight = Table_HeaderHeight_origin * m_scaleRatio4_3; ScroolBar_Width = ScroolBar_Width_origin * m_scaleRatio3_2; - Slider_Length = Slider_Length_origin * m_scaleRatio2_1; - Slider_Thickness = Slider_Thickness_origin * m_scaleRatio2_1; + + Slider_Length = Slider_Length_origin * m_slider_handle_scaleRatio; + Slider_Thickness = Slider_Thickness_origin * m_slider_handle_scaleRatio; + Slider_DefaultWidth = Slider_DefaultWidth_origin * m_scaleRatio2_1; Slider_GrooveLength = Slider_GrooveLength_origin * m_scaleRatio2_1; Slider_DefaultLength = Slider_DefaultLength_origin * m_scaleSliderDefaultLength; + LineEdit_DefaultWidth = LineEdit_DefaultWidth_origin * m_ScaleLineEditDefaultLength; TabBar_DefaultHeight = TabBar_DefaultHeight_origin * m_scaleTabBarHeight6_5; ViewItem_DefaultHeight = ViewItem_DefaultHeight_origin * m_scaleRatio4_3; @@ -506,15 +512,28 @@ UKUIGlobalDTConfig::GlobalDTConfig* UKUIConfigStyleParameters::readCfg() return m_dtconfig; } +void UKUIConfigStyleParameters::initHeaderViewStyle() +{ + QBrush linePenBrush = m_dtconfig->kLineNormal(); + m_verticalDividerLinePen = QPen(linePenBrush, + (linePenBrush.style() == Qt::NoBrush || linePenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +} + QBrush UKUIConfigStyleParameters::parseBrush(QRect rect, QBrush dtBrush) { QBrush result; if(dtBrush.style() == Qt::SolidPattern){ result = dtBrush; } else if (dtBrush.style() == Qt::LinearGradientPattern) { - QLinearGradient linearGradient; - linearGradient.setStart(rect.topLeft()); - linearGradient.setFinalStop(rect.bottomLeft()); + + // QLinearGradient linearGradient; + // linearGradient.setStart(rect.topLeft()); 绝对坐标 + // linearGradient.setFinalStop(rect.bottomLeft()); + + QLinearGradient linearGradient(0, 0, 0, 1);// 相对坐标,(0,0) 表示矩形的 左上角; (0,1) 表示矩形的 左下角 + linearGradient.setCoordinateMode(QGradient::ObjectBoundingMode);// 渐变使用对象边界模式 + linearGradient.setStops(dtBrush.gradient()->stops()); result = QBrush(linearGradient); } @@ -522,46 +541,57 @@ QBrush UKUIConfigStyleParameters::parseBrush(QRect rect, QBrush dtBrush) return result; } +void UKUIConfigStyleParameters::initElemsDefaultStyleStrategy() +{ + int elemCnt = static_cast(StyleCtrlElement::ElementsCount); + + TransparencyUsage.resize(elemCnt); + TransparencyUsage.fill(true); + TransparencyUsage.setBit((int)StyleCtrlElement::LineEdit,false); + + FocusUsage.resize(elemCnt); + FocusUsage.fill(false); + + FocusUsage.setBit((int)StyleCtrlElement::LineEdit,true); + FocusUsage.setBit((int)StyleCtrlElement::SpinBox,true); + // FocusUsage.setBit((int)StyleCtrlElement::RadioButton,true);暂时关闭Radio按钮的焦点边框 + +// FocusUsage.setBit((int)StyleCtrlElement::PushButtonBevel,true); + +// 自定义 半透明实色切换、focus边框绘制,或者在对应组件的参数init函数中初始化 +// TransparencyUsage.setBit((int)StyleCtrlElement::RadioButton,false); +// ... +// FocusUsage.setBit((int)StyleCtrlElement::Menu,true); +// ... + + +} void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { + m_PushButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::PushButtonBevel]);//是否需要focus状态绘制,使用默认初始值初始化 + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::PushButtonBevel];//获取半透明的默认使用情况 + bool isWindowButton = false; bool isWindowColoseButton = false; bool isImportant = false; bool useButtonPalette = false; - bool needTranslucent = false; int radius = m_dtconfig->kradiusNormal(); - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - QBrush clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - - QBrush defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - QBrush clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - QBrush disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - - QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - - QBrush checkBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); + //Check的颜色应该使用important状态的颜色,无论是否半透明,都是使用同一套颜色 + QBrush checkBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); QBrush checkHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); QBrush checkClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightDisable()); + QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); - QBrush checkPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush checkHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()); - QBrush checkClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()); - QBrush checkDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()); + QBrush checkPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + QBrush checkHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + QBrush checkClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + QBrush checkDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + + QBrush inactiveBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); QPen checkPen = QPen(checkPenBrush, (checkPenBrush.style() == Qt::NoBrush || checkPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -574,6 +604,8 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + //初始化需要显示的状态 if (widget) { if (widget->property("isWindowButton").isValid()) { if (widget->property("isWindowButton").toInt() == 0x01) { @@ -596,88 +628,54 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, } } - if (isWindowColoseButton) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); - hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover()); - clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); + //初始化组件所使用的的颜色 + QBrush defaultBrush, disableBrush, hoverBrush, clickBrush, + defaultPenBrush, hoverPenBrush, clickPenBrush, disablePenBrush; - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + //半透明 + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + } else { + //实色 + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); } - if (useButtonPalette || isWindowButton) { - if (needTranslucent) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); - hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); - clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); - - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - } else { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - } + + //关闭按钮,例如窗口的 叉按钮,应该用红色,v11主题没有针对pushbutton定义这个颜色 + if (isWindowColoseButton) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); + hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover()); + clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); } + //一直选中状态的颜色, v11主题可以移除important状态的颜色设置 if (isImportant) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightDisable()); + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()); - - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); } auto *w = const_cast(widget); @@ -708,28 +706,28 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert()) { - clickBrush = widget->property("setClickBrush").value(); + clickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setClickBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setCheckBrush").isValid() && widget->property("setCheckBrush").canConvert()) { - checkBrush = widget->property("setCheckBrush").value(); + checkBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckBrush").value()); } if (widget->property("setCheckHoverBrush").isValid() && widget->property("setCheckHoverBrush").canConvert()) { - checkHoverBrush = widget->property("setCheckHoverBrush").value(); + checkHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckHoverBrush").value()); } if (widget->property("setCheckClickBrush").isValid() && widget->property("setCheckClickBrush").canConvert()) { - checkClickBrush = widget->property("setCheckClickBrush").value(); + checkClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckClickBrush").value()); } if (widget->property("setCheckDisableBrush").isValid() && widget->property("setCheckDisableBrush").canConvert()) { - checkDisableBrush = widget->property("setCheckDisableBrush").value(); + checkDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckDisableBrush").value()); } if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); @@ -769,6 +767,7 @@ void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, m_PushButtonParameters.pushButtonCheckHoverBrush = checkHoverBrush; m_PushButtonParameters.pushButtonCheckClickBrush = checkClickBrush; m_PushButtonParameters.pushButtonCheckDisableBrush = checkDisableBrush; + m_PushButtonParameters.pushButtonInactiveBrush = inactiveBrush; m_PushButtonParameters.pushButtonDefaultPen = defaultPen; m_PushButtonParameters.pushButtonClickPen = clickPen; m_PushButtonParameters.pushButtonHoverPen = hoverPen; @@ -801,7 +800,7 @@ void UKUIConfigStyleParameters::getDefaultConfigPushButtonBevelParameters(Config p->pushButtonCheckClickPen = m_PushButtonParameters.pushButtonCheckClickPen ; p->pushButtonCheckDisablePen = m_PushButtonParameters.pushButtonCheckDisablePen ; p->pushButtonFocusPen = m_PushButtonParameters.pushButtonFocusPen ; - + p->pushButtonInactiveBrush = m_PushButtonParameters.pushButtonInactiveBrush ; } void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, const QStyleOption *option, const QWidget *widget) @@ -814,7 +813,8 @@ void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, bool useButtonPalette = false; bool isImportant = false; bool isWindowColoseButton = false; - bool needTranslucent = false; + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::PushButtonLabel]; + if (widget) { if (widget->property("isWindowButton").isValid()) { @@ -838,28 +838,32 @@ void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, } } - QColor textDefaultColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color(); - QColor textHoverColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color(); - QColor textDisableColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextDisable()).color(); + QColor textDefaultColor = parseBrush(option ? option->rect : QRect(),isImportant ? + m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color(); + QColor textHoverColor = parseBrush(option ? option->rect : QRect(), (isImportant || isWindowColoseButton) ? + m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color(); + // QColor textDisableColor = parseBrush(option ? option->rect : QRect(), isImportant ? + // m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()).color(); + + QColor textDisableColor = parseBrush(option ? option->rect : QRect(), isImportant ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()).color(); + + QColor textHighlightColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightedTextActive()).color(); //icon - if (button && (isWindowButton || useButtonPalette) && !(button->state & QStyle::State_On)) { - iconHighlight = false; - } else { + if (button && (button->state & QStyle::State_On || isWindowColoseButton || isImportant)) iconHighlight = true; - } auto *w = const_cast(widget); if (w) { - w->setProperty("iconHighlight", iconHighlight); - w->setProperty("textHighlight", textHighlight); - w->setProperty("textDefaultColor", textDefaultColor); - w->setProperty("textHoverColor", textHoverColor); - w->setProperty("textDisableColor", textDisableColor); + w->setProperty("iconHighlight", iconHighlight); + w->setProperty("textHighlight", textHighlight); + w->setProperty("textDefaultColor", textDefaultColor); + w->setProperty("textHoverColor", textHoverColor); + w->setProperty("textDisableColor", textDisableColor); + w->setProperty("textHighlightColor", textHighlightColor); } if (widget) { - if (widget->property("setIconHoverClickHighlight").isValid() && widget->property("setIconHoverClickHighlight").canConvert()) { iconHighlight = widget->property("setIconHoverClickHighlight").value(); } @@ -875,6 +879,9 @@ void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, if (widget->property("setTextDisableColor").isValid() && widget->property("setTextDisableColor").canConvert()) { textDisableColor = widget->property("setTextDisableColor").value(); } + if (widget->property("setTextHighlightColor").isValid() && widget->property("setTextHighlightColor").canConvert()) { + textHighlightColor = widget->property("setTextHighlightColor").value(); + } } m_PushButtonParameters.iconHoverClickHighlight = iconHighlight; @@ -882,6 +889,7 @@ void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, m_PushButtonParameters.textDefaultColor = textDefaultColor; m_PushButtonParameters.textHoverColor = textHoverColor; m_PushButtonParameters.textDisableColor = textDisableColor; + m_PushButtonParameters.textHighlightColor = textHighlightColor; } void UKUIConfigStyleParameters::getDefaultConfigPushButtonLabelParameters(ConfigPushButtonParameters *p, bool isDark) @@ -892,42 +900,26 @@ void UKUIConfigStyleParameters::getDefaultConfigPushButtonLabelParameters(Config p->textDefaultColor = m_PushButtonParameters.textDefaultColor ; p->textHoverColor = m_PushButtonParameters.textHoverColor ; p->textDisableColor = m_PushButtonParameters.textDisableColor ; + p->textHighlightColor = m_PushButtonParameters.textHighlightColor ; } void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { + bool isWindowButton = false; bool isWindowColoseButton = false; bool isImportant = false; bool useButtonPalette = false; - bool needTranslucent = false; + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ToolButtonPanel]; + m_ToolButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ToolButtonPanel]); int radius = m_dtconfig->kradiusNormal(); - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - QBrush clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - - QBrush defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - QBrush clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - QBrush disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - - - QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QBrush checkBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); QBrush checkHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); QBrush checkClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightDisable()); + QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); QBrush checkPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); QBrush checkHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()); @@ -945,6 +937,8 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark, QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + if (widget) { if (widget->property("isWindowButton").isValid()) { if (widget->property("isWindowButton").toInt() == 0x01) { @@ -962,93 +956,59 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark, useButtonPalette = widget->property("useButtonPalette").toBool(); } + if (widget->objectName() == "ScrollLeftButton" || widget->objectName() == "ScrollRightButton") { + needTranslucent = false; + } + if (widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } } - if (isWindowColoseButton) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); - hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover()); - clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); + QBrush defaultBrush, disableBrush, hoverBrush, clickBrush, + defaultPenBrush, hoverPenBrush, clickPenBrush, disablePenBrush; - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); } - if (useButtonPalette || isWindowButton) { - if (needTranslucent) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); - hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); - clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); - - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - } else { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - } + QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + if (isWindowColoseButton) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); + hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover()); + clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0()); } if (isImportant) { - defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightDisable()); + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - - defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()); - clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()); - disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()); - - defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); } auto *w = const_cast(widget); @@ -1078,28 +1038,28 @@ void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark, radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert()) { - clickBrush = widget->property("setClickBrush").value(); + clickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setClickBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setCheckBrush").isValid() && widget->property("setCheckBrush").canConvert()) { - checkBrush = widget->property("setCheckBrush").value(); + checkBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckBrush").value()); } if (widget->property("setCheckHoverBrush").isValid() && widget->property("setCheckHoverBrush").canConvert()) { - checkHoverBrush = widget->property("setCheckHoverBrush").value(); + checkHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckHoverBrush").value()); } if (widget->property("setCheckClickBrush").isValid() && widget->property("setCheckClickBrush").canConvert()) { - checkClickBrush = widget->property("setCheckClickBrush").value(); + checkClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckClickBrush").value()); } if (widget->property("setCheckDisableBrush").isValid() && widget->property("setCheckDisableBrush").canConvert()) { - checkDisableBrush = widget->property("setCheckDisableBrush").value(); + checkDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setCheckDisableBrush").value()); } if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); @@ -1184,7 +1144,7 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark, bool useButtonPalette = false; bool isImportant = false; bool isWindowColoseButton = false; - bool needTranslucent = false; + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ToolButtonLabel]; if (widget) { if (widget->property("isWindowButton").isValid()) { @@ -1208,16 +1168,18 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark, } } - QColor textDefaultColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color(); - QColor textHoverColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextActive()).color(); - QColor textDisableColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonTextDisable()).color(); + QColor textDefaultColor = parseBrush(option ? option->rect : QRect(), isImportant + ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color(); + + QColor textHoverColor = parseBrush(option ? option->rect : QRect(), (isImportant || isWindowColoseButton) + ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color(); + QColor textDisableColor = parseBrush(option ? option->rect : QRect(), isImportant + ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()).color(); + QColor textHighlightColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightedTextActive()).color(); //icon - if ((isWindowButton || useButtonPalette) && !(button->state & QStyle::State_On)) { - iconHighlight = false; - } else { + if (button && (button->state & QStyle::State_On || isWindowColoseButton || isImportant)) iconHighlight = true; - } auto *w = const_cast(widget); if (w) { @@ -1226,6 +1188,7 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark, w->setProperty("textDefaultColor", textDefaultColor); w->setProperty("textHoverColor", textHoverColor); w->setProperty("textDisableColor", textDisableColor); + w->setProperty("textHighlightColor", textHighlightColor); } if (widget) { @@ -1244,13 +1207,17 @@ void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark, if (widget->property("setTextDisableColor").isValid() && widget->property("setTextDisableColor").canConvert()) { textDisableColor = widget->property("setTextDisableColor").value(); } + if (widget->property("setTextHighlightColor").isValid() && widget->property("setTextHighlightColor").canConvert()) { + textHighlightColor = widget->property("setTextHighlightColor").value(); + } } - m_ToolButtonParameters.iconHoverClickHighlight = iconHighlight; - m_ToolButtonParameters.textHoverClickHighlight = textHighlight; - m_ToolButtonParameters.textDefaultColor = textDefaultColor; - m_ToolButtonParameters.textHoverColor = textHoverColor; - m_ToolButtonParameters.textDisableColor = textDisableColor; + m_ToolButtonParameters.iconHoverClickHighlight = iconHighlight; + m_ToolButtonParameters.textHoverClickHighlight = textHighlight; + m_ToolButtonParameters.textDefaultColor = textDefaultColor; + m_ToolButtonParameters.textHoverColor = textHoverColor; + m_ToolButtonParameters.textDisableColor = textDisableColor; + m_ToolButtonParameters.textHighlightColor = textHighlightColor; } void UKUIConfigStyleParameters::getDefaultConfigToolButtonLabelParameters(ConfigToolButtonParameters *p, bool isDark) @@ -1265,32 +1232,49 @@ void UKUIConfigStyleParameters::getDefaultConfigToolButtonLabelParameters(Config void UKUIConfigStyleParameters::initConfigLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - int radius =m_dtconfig->kradiusNormal(); + int radius = m_dtconfig->kradiusNormal(); + + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::LineEdit]; + m_LineEditParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::LineEdit]); - bool needTranslucent = false; if (widget && widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); - QBrush defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + QBrush defaultBrush, hoverBrush, focusBrush, disableBrush, + defaultPenBrush, hoverPenBrush, focusPenBrush, disablePenBrush; + + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + + focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInputAlpha()); + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + + focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInput()); + } + + defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + + focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 1, + QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + auto *w = const_cast(widget); if (w) { w->setProperty("radius", radius); @@ -1309,16 +1293,16 @@ void UKUIConfigStyleParameters::initConfigLineEditParameters(bool isDark, const radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setFocusBrush").isValid() && widget->property("setFocusBrush").canConvert()) { - focusBrush = widget->property("setFocusBrush").value(); + focusBrush = parseBrush(option ? option->rect : QRect(), widget->property("setFocusBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); @@ -1361,36 +1345,98 @@ void UKUIConfigStyleParameters::getDefaultConfigLineEditParameters(ConfigLineEdi void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool isHorizonLayout) { + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::SpinBox]; + m_SpinBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::SpinBox]); + int radius = m_dtconfig->kradiusNormal(); - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); + QBrush defaultBrush,hoverBrush,clickBrush,disableBrush,focusBrush, + defaultPenBrush,hoverPenBrush,clickPenBrush,disablePenBrush,focusPenBrush; + + if (widget && widget->property("needTranslucent").isValid()) { + needTranslucent = widget->property("needTranslucent").toBool(); + } + + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + + focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());// +// focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInputAlpha()); 等待 ukui-globaltheme更新为kcomponentinputAlpha + + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + + focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());// +// focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInput());等待 ukui-globaltheme更新为kcomponentinputAlpha + } + + defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + clickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + + focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); - QBrush defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen hoverPen = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 1, + QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QBrush upHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover() ); - QBrush upFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); - QBrush upClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); - QBrush upDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive() ); - QBrush downHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover() ); - QBrush downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); - QBrush downClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); - QBrush downDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive() ); + QPen clickPen = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + //箭头元素相关token + + // QBrush upFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); + // QBrush upClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); + // QBrush downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); + // QBrush downClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick() ); + + + QBrush upDefaultBrush, upDisableBrush, upHoverBrush, upClickBrush, upFocusHoverBrush, + downHoverBrush, downDisableBrush, downFocusHoverBrush, downClickBrush, downDefaultBrush; + + //箭头区域背景色 + if (needTranslucent) { + upDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); + upHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + upFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + upClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + upDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); + + downDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); + downHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + downClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + downDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); + } else { + upDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); + upHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + upFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + upClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + upDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); + + downDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); + downHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + downClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + downDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); + } + + //箭头区域边框 QPen upDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()) , parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha()<= 0 ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -1406,6 +1452,7 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q QPen upDisablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()) , parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha()<= 0 ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen downDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()) , parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha()<= 0 ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -1449,19 +1496,25 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q w->setProperty("hoverPen", hoverPen); w->setProperty("disablePen", disablePen); w->setProperty("focusPen", focusPen); + w->setProperty("upDefaultBrush", upDefaultBrush); + w->setProperty("upHoverBrush", upHoverBrush); w->setProperty("upFocusHoverBrush", upFocusHoverBrush); w->setProperty("upClickBrush", upClickBrush); - w->setProperty("upHoverBrush", upHoverBrush); + w->setProperty("upDisableBrush", upDisableBrush); + w->setProperty("downDefaultBrush", downDefaultBrush); w->setProperty("downHoverBrush", downHoverBrush); w->setProperty("downFocusHoverBrush", downFocusHoverBrush); w->setProperty("downClickBrush", downClickBrush); + w->setProperty("downDisableBrush", downDisableBrush); + w->setProperty("upDefaultPen", upDefaultPen); w->setProperty("upHoverPen", upHoverPen); w->setProperty("upFocusHoverPen", upFocusHoverPen); w->setProperty("upClickPen", upClickPen); w->setProperty("upDisablePen", upDisablePen); + w->setProperty("downDefaultPen", downDefaultPen); w->setProperty("downHoverPen", downHoverPen); w->setProperty("downFocusHoverPen", downFocusHoverPen); @@ -1472,18 +1525,22 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert()) { radius = widget->property("setRadius").value(); } + + //brush if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setFocusBrush").isValid() && widget->property("setFocusBrush").canConvert()) { - focusBrush = widget->property("setFocusBrush").value(); + focusBrush = parseBrush(option ? option->rect : QRect(), widget->property("setFocusBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } + + //pen if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); } @@ -1496,30 +1553,42 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert()) { disablePen = widget->property("setDisablePen").value(); } + + //up button brush if (widget->property("setUpDefaultBrush").isValid() && widget->property("setUpDefaultBrush").canConvert()) { - upDefaultBrush = widget->property("setUpDefaultBrush").value(); + upDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setUpDefaultBrush").value()); } if (widget->property("setUpHoverBrush").isValid() && widget->property("setUpHoverBrush").canConvert()) { - upHoverBrush = widget->property("setUpHoverBrush").value(); + upHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setUpHoverBrush").value()); } if (widget->property("setUpFocusHoverBrush").isValid() && widget->property("setUpFocusHoverBrush").canConvert()) { - upFocusHoverBrush = widget->property("setUpFocusHoverBrush").value(); + upFocusHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setUpFocusHoverBrush").value()); } if (widget->property("setUpClickBrush").isValid() && widget->property("setUpClickBrush").canConvert()) { - upClickBrush = widget->property("setUpClickBrush").value(); + upClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setUpClickBrush").value()); } + if (widget->property("setUpDisableBrush").isValid() && widget->property("setUpDisableBrush").canConvert()) { + upDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setUpDisableBrush").value()); + } + + //down button brush if (widget->property("setDownDefaultBrush").isValid() && widget->property("setDownDefaultBrush").canConvert()) { - downDefaultBrush = widget->property("setDownDefaultBrush").value(); + downDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDownDefaultBrush").value()); } if (widget->property("setDownHoverBrush").isValid() && widget->property("setDownHoverBrush").canConvert()) { - downHoverBrush = widget->property("setDownHoverBrush").value(); + downHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDownHoverBrush").value()); } if (widget->property("setDownFocusHoverBrush").isValid() && widget->property("setDownFocusHoverBrush").canConvert()) { - downFocusHoverBrush = widget->property("setDownFocusHoverBrush").value(); + downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDownFocusHoverBrush").value()); } if (widget->property("setDownClickBrush").isValid() && widget->property("setDownClickBrush").canConvert()) { - downClickBrush = widget->property("setDownClickBrush").value(); + downClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDownClickBrush").value()); } + if (widget->property("setDownDisableBrush").isValid() && widget->property("setDownDisableBrush").canConvert()) { + downDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDownDisableBrush").value()); + } + + //up button pen if (widget->property("setUpDefaultPen").isValid() && widget->property("setUpDefaultPen").canConvert()) { upDefaultPen = widget->property("setUpDefaultPen").value(); } @@ -1535,6 +1604,8 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q if (widget->property("setUpDisablePen").isValid() && widget->property("setUpDisablePen").canConvert()) { upDisablePen = widget->property("setUpDisablePen").value(); } + + //down button pen if (widget->property("setDownDefaultPen").isValid() && widget->property("setDownDefaultPen").canConvert()) { downDefaultPen = widget->property("setDownDefaultPen").value(); } @@ -1557,20 +1628,25 @@ void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const Q m_SpinBoxParameters.spinBoxHoverBrush = hoverBrush; m_SpinBoxParameters.spinBoxFocusBrush = focusBrush; m_SpinBoxParameters.spinBoxDisableBrush = disableBrush; + m_SpinBoxParameters.spinBoxClickBrush = clickBrush; m_SpinBoxParameters.spinBoxDefaultPen = defaultPen; m_SpinBoxParameters.spinBoxHoverPen = hoverPen; m_SpinBoxParameters.spinBoxFocusPen = focusPen; + m_SpinBoxParameters.spinBoxClickPen = clickPen; m_SpinBoxParameters.spinBoxDisablePen = disablePen; m_SpinBoxParameters.spinBoxUpDefaultBrush = upDefaultBrush; m_SpinBoxParameters.spinBoxUpHoverBrush = upHoverBrush; m_SpinBoxParameters.spinBoxUpFocusHoverBrush = upFocusHoverBrush; m_SpinBoxParameters.spinBoxUpClickBrush = upClickBrush; + m_SpinBoxParameters.spinBoxUpDisableBrush = upDisableBrush; + + m_SpinBoxParameters.spinBoxDownDefaultBrush = downDefaultBrush; m_SpinBoxParameters.spinBoxDownHoverBrush = downHoverBrush; m_SpinBoxParameters.spinBoxDownFocusHoverBrush = downFocusHoverBrush; m_SpinBoxParameters.spinBoxDownClickBrush = downClickBrush; - m_SpinBoxParameters.spinBoxDownDefaultBrush = downDefaultBrush; + m_SpinBoxParameters.spinBoxDownDisableBrush = downDisableBrush; m_SpinBoxParameters.spinBoxUpDefaultPen = upDefaultPen; m_SpinBoxParameters.spinBoxUpHoverPen = upHoverPen; @@ -1596,11 +1672,13 @@ void UKUIConfigStyleParameters::getDefaultConfigSpinBoxParameters(ConfigSpinBoxP p->spinBoxHoverBrush = m_SpinBoxParameters.spinBoxHoverBrush ; p->spinBoxFocusBrush = m_SpinBoxParameters.spinBoxFocusBrush ; p->spinBoxDisableBrush = m_SpinBoxParameters.spinBoxDisableBrush ; + p->spinBoxClickBrush = m_SpinBoxParameters.spinBoxClickBrush ; p->spinBoxDefaultPen = m_SpinBoxParameters.spinBoxDefaultPen ; p->spinBoxHoverPen = m_SpinBoxParameters.spinBoxHoverPen ; p->spinBoxFocusPen = m_SpinBoxParameters.spinBoxFocusPen ; p->spinBoxDisablePen = m_SpinBoxParameters.spinBoxDisablePen ; + p->spinBoxClickPen = m_SpinBoxParameters.spinBoxClickPen ; p->spinBoxUpDefaultBrush = m_SpinBoxParameters.spinBoxUpDefaultBrush ; p->spinBoxUpHoverBrush = m_SpinBoxParameters.spinBoxUpHoverBrush ; @@ -1610,6 +1688,7 @@ void UKUIConfigStyleParameters::getDefaultConfigSpinBoxParameters(ConfigSpinBoxP p->spinBoxDownFocusHoverBrush = m_SpinBoxParameters.spinBoxDownFocusHoverBrush ; p->spinBoxDownClickBrush = m_SpinBoxParameters.spinBoxDownClickBrush ; p->spinBoxDownDefaultBrush = m_SpinBoxParameters.spinBoxDownDefaultBrush ; + p->spinBoxUpDisableBrush = m_SpinBoxParameters.spinBoxUpDisableBrush; p->spinBoxUpDefaultPen = m_SpinBoxParameters.spinBoxUpDefaultPen ; p->spinBoxUpHoverPen = m_SpinBoxParameters.spinBoxUpHoverPen ; @@ -1630,20 +1709,38 @@ void UKUIConfigStyleParameters::getDefaultConfigSpinBoxParameters(ConfigSpinBoxP void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { + int radius = m_dtconfig->kradiusNormal(); - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush onBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush editBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - QBrush defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); - QBrush onPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush editPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ComboBox]; + m_ComboBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ComboBox]); + + QBrush defaultBrush,hoverBrush,onBrush,editBrush,disableBrush, + defaultPenBrush,hoverPenBrush,onPenBrush,editPenBrush,disablePenBrush,focusPenBrush; + + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + onBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + editBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + onBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + editBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + } + + + defaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover()); + onPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + editPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); + disablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable()); + focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()); + QPen defaultPen = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -1655,7 +1752,7 @@ void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen disablePen = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 1, + QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); auto *w = const_cast(widget); @@ -1679,19 +1776,19 @@ void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setOnBrush").isValid() && widget->property("setOnBrush").canConvert()) { - onBrush = widget->property("setOnBrush").value(); + onBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnBrush").value()); } if (widget->property("setBoxEditBrush").isValid() && widget->property("setBoxEditBrush").canConvert()) { - editBrush = widget->property("setBoxEditBrush").value(); + editBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBoxEditBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); @@ -1754,7 +1851,10 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty } int radius = m_dtconfig->kradiusNormal(); - bool needTranslucent = false; + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::List]; + m_ListParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::List]); + + bool highlightMode = highlight; if (widget && widget->property("highlightMode").isValid()) { highlightMode = widget->property("highlightMode").toBool(); @@ -1763,34 +1863,72 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty needTranslucent = widget->property("needTranslucent").toBool(); } - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->buttonActive()) : m_dtconfig->kContainGeneralNormal()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()); - QBrush selectBrush = parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->kBrandClick() : m_dtconfig->kComponentClick()) : m_dtconfig->kContainClick()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + + QBrush defaultBrush,hoverBrush,selectBrush,disableBrush; + QBrush alternatingRowsNormalBrush , alternatingRowsDisableBrush; + + if (needTranslucent) { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? + m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? + (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kContainAlphaHover()); + + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? + m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent); + + + selectBrush = parseBrush(option ? option->rect : QRect(), select ? + (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaClick()) : m_dtconfig->kContainAlphaClick()); + + + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + + + } else { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? + m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? + (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kContainHover()); + + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? + m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent); + + selectBrush = parseBrush(option ? option->rect : QRect(), select ? + (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedClick()) : m_dtconfig->kContainClick()); + + + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + } + + QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - - QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), select ? - (highlightMode ? m_dtconfig->kLineBrandNormal() :m_dtconfig->kLineComponentNormal()) : m_dtconfig->kLineComponentNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - - QBrush hoverPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kLineComponentHover(); - QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), hoverPenBrush), - parseBrush(option ? option->rect : QRect(), hoverPenBrush).color().alpha() > 0 ? - 1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QBrush selectPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kLineComponentClick(); - QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), selectPenBrush), - parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ? - 1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), - parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ? - 2 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + (highlightMode ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + +// QBrush hoverPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kLineComponentHover(); +// QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), hoverPenBrush), +// parseBrush(option ? option->rect : QRect(), hoverPenBrush).color().alpha() > 0 ? +// 1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QBrush selectPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kLineComponentClick(); +// QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), selectPenBrush), +// parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ? +// 1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()), +// parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ? +// 2 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPen hoverPen = QPen(Qt::NoPen); + QPen selectPen = QPen(Qt::NoPen); + QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + auto *w = const_cast(widget); if (w) { @@ -1802,7 +1940,6 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty w->setProperty("textHoverPen", textHoverPen); w->setProperty("textSelectPen", textSelectPen); w->setProperty("textDisablePen", textDisablePen); - w->setProperty("defaultPen", defaultPen); w->setProperty("hoverPen", hoverPen); w->setProperty("selectPen", selectPen); w->setProperty("focusPen", focusPen); @@ -1812,16 +1949,16 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert()) { - selectBrush = widget->property("setSelectBrush").value(); + selectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSelectBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert()) { textHoverPen = widget->property("setTextHoverPen").value(); @@ -1829,11 +1966,8 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty if (widget->property("setTextSelectPen").isValid() && widget->property("setTextSelectPen").canConvert()) { textSelectPen = widget->property("setTextSelectPen").value(); } - if (widget->property("setTextDisablePen").isValid() && widget->property("setDefaultPen").canConvert()) { - defaultPen = widget->property("setDefaultPen").value(); - } - if (widget->property("setDefaultPen").isValid() && widget->property("setHoverPen").canConvert()) { - hoverPen = widget->property("setHoverPen").value(); + if (widget->property("setTextDisablePen").isValid() && widget->property("setTextDisablePen").canConvert()) { + textDisablePen = widget->property("setTextDisablePen").value(); } if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert()) { hoverPen = widget->property("setHoverPen").value(); @@ -1854,10 +1988,12 @@ void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QSty m_ListParameters.listTextHoverPen = textHoverPen; m_ListParameters.listTextSelectPen = textSelectPen; m_ListParameters.listTextDisablePen = textDisablePen; - m_ListParameters.listDefaultPen = defaultPen; m_ListParameters.listHoverPen = hoverPen; m_ListParameters.listSelectPen = selectPen; m_ListParameters.listFocusPen = focusPen; + + m_ListParameters.listAlternatingRowsNormalBrush = alternatingRowsNormalBrush; + m_ListParameters.listAlternatingRowsDisableBrush = alternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getDefaultConfigListParameters(ConfigListParameters *p, bool isDark) @@ -1875,6 +2011,9 @@ void UKUIConfigStyleParameters::getDefaultConfigListParameters(ConfigListParamet p->listHoverPen = m_ListParameters.listHoverPen ; p->listSelectPen = m_ListParameters.listSelectPen ; p->listFocusPen = m_ListParameters.listFocusPen ; + + p->listAlternatingRowsNormalBrush = m_ListParameters.listAlternatingRowsNormalBrush; + p->listAlternatingRowsDisableBrush = m_ListParameters.listAlternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getHighlightModeConfigListParameters(ConfigListParameters *p, bool isDark) @@ -1892,6 +2031,9 @@ void UKUIConfigStyleParameters::getHighlightModeConfigListParameters(ConfigListP p->listHoverPen = m_ListParameters.listHoverPen ; p->listSelectPen = m_ListParameters.listSelectPen ; p->listFocusPen = m_ListParameters.listFocusPen ; + + p->listAlternatingRowsNormalBrush = m_ListParameters.listAlternatingRowsNormalBrush; + p->listAlternatingRowsDisableBrush = m_ListParameters.listAlternatingRowsDisableBrush; } void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool highlight) { @@ -1902,28 +2044,63 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty int radius = m_dtconfig->kradiusNormal(); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Tree]; + m_TreeParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Tree]); + + if (widget && widget->property("needTranslucent").isValid()) { + needTranslucent = widget->property("needTranslucent").toBool(); + } + bool highlightMode = highlight; if (widget && widget->property("highlightMode").isValid()) { highlightMode = widget->property("highlightMode").toBool(); } - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->buttonActive()) : m_dtconfig->baseActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()); - QBrush selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandClick() : m_dtconfig->kComponentClick()) : m_dtconfig->kContainClick()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), select ? m_dtconfig->buttonDisable() : m_dtconfig->baseActive()); - QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QBrush defaultBrush,hoverBrush,selectBrush,disableBrush; + QBrush alternatingRowsNormalBrush, alternatingRowsDisableBrush; + + if (needTranslucent) { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kContainAlphaHover()); + selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal()) : QBrush(Qt::transparent)); + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent); + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + + } else { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kContainHover()); + selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal()) : QBrush(Qt::transparent)); + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent); + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + } + + +// QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); - QBrush selectPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); + QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + QBrush hoverPenBrush,selectPenBrush,focusPenBrush; + hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); + selectPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); + focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); + + +// QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPen hoverPen = QPen(Qt::NoPen); + QPen selectPen = QPen(Qt::NoPen); + QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandNormal() :m_dtconfig->kLineComponentNormal()) : m_dtconfig->kLineComponentNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QBrush branchDefaultBrush = defaultBrush; QBrush branchHoverBrush = hoverBrush; @@ -1944,7 +2121,6 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty w->setProperty("textHoverPen", textHoverPen); w->setProperty("textSelectPen", textSelectPen); w->setProperty("textDisablePen", textDisablePen); - w->setProperty("defaultPen", defaultPen); w->setProperty("hoverPen", hoverPen); w->setProperty("selectPen", selectPen); w->setProperty("focusPen", focusPen); @@ -1954,28 +2130,28 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert()) { - selectBrush = widget->property("setSelectBrush").value(); + selectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSelectBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setBranchDefaultBrush").isValid() && widget->property("setBranchDefaultBrush").canConvert()) { - branchDefaultBrush = widget->property("setBranchDefaultBrush").value(); + branchDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBranchDefaultBrush").value()); } if (widget->property("setBranchHoverBrush").isValid() && widget->property("setBranchHoverBrush").canConvert()) { - branchHoverBrush = widget->property("setBranchHoverBrush").value(); + branchHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBranchHoverBrush").value()); } if (widget->property("setBranchSelectBrush").isValid() && widget->property("setBranchSelectBrush").canConvert()) { - branchSelectBrush = widget->property("setBranchSelectBrush").value(); + branchSelectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBranchSelectBrush").value()); } if (widget->property("setBranchDisableBrush").isValid() && widget->property("setBranchDisableBrush").canConvert()) { - branchDisableBrush = widget->property("setBranchDisableBrush").value(); + branchDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBranchDisableBrush").value()); } if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert()) { textHoverPen = widget->property("setTextHoverPen").value(); @@ -1986,9 +2162,6 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty if (widget->property("setTextDisablePen").isValid() && widget->property("setTextDisablePen").canConvert()) { textDisablePen = widget->property("setTextDisablePen").value(); } - if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { - hoverPen = widget->property("setDefaultPen").value(); - } if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert()) { hoverPen = widget->property("setHoverPen").value(); } @@ -2011,13 +2184,15 @@ void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QSty m_TreeParameters.treeBranchSelectBrush = branchSelectBrush; m_TreeParameters.treeBranchDisableBrush = branchDisableBrush; - m_TreeParameters.treeDefaultPen = defaultPen; m_TreeParameters.treeHoverPen = hoverPen; m_TreeParameters.treeSelectPen = selectPen; m_TreeParameters.treeFocusPen = focusPen; m_TreeParameters.treeTextHoverPen = textHoverPen; m_TreeParameters.treeTextSelectPen = textSelectPen; m_TreeParameters.treeTextDisablePen = textDisablePen; + + m_TreeParameters.treeAlternatingRowsNormalBrush = alternatingRowsNormalBrush; + m_TreeParameters.treeAlternatingRowsDisableBrush = alternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getDefaultConfigTreeParameters(ConfigTreeParameters *p, bool isDark) @@ -2039,6 +2214,9 @@ void UKUIConfigStyleParameters::getDefaultConfigTreeParameters(ConfigTreeParamet p->treeTextHoverPen = m_TreeParameters.treeTextHoverPen ; p->treeTextSelectPen = m_TreeParameters.treeTextSelectPen ; p->treeTextDisablePen = m_TreeParameters.treeTextDisablePen ; + + p->treeAlternatingRowsNormalBrush = m_TreeParameters.treeAlternatingRowsNormalBrush; + p->treeAlternatingRowsDisableBrush = m_TreeParameters.treeAlternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getHighlightModeConfigTreeParameters(ConfigTreeParameters *p, bool isDark) @@ -2071,29 +2249,59 @@ void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QSt int radius = m_dtconfig->kradiusNormal(); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Table]; + m_TableParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Table]); + bool highlightMode = highlight; if (widget && widget->property("highlightMode").isValid()) { highlightMode = widget->property("highlightMode").toBool(); } + if (widget && widget->property("needTranslucent").isValid()) { + needTranslucent = widget->property("needTranslucent").toBool(); + } + + highlightMode = false;//v11主题设计中没有定义Table中元素的高亮 + + QBrush defaultBrush,hoverBrush,selectBrush,disableBrush; + QBrush alternatingRowsNormalBrush, alternatingRowsDisableBrush; + + if (needTranslucent) { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kComponentAlphaHover()); + selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal()) : QBrush(Qt::transparent)); + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent); + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryAlphaNormal()); + } else { + defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent); + hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kComponentHover()); + selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal()) : QBrush(Qt::transparent)); + disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent); + alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + } - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->buttonActive()) : m_dtconfig->baseActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()); - QBrush selectBrush = parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kBrandClick() : m_dtconfig->kComponentClick()) : m_dtconfig->kContainClick()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), select ? m_dtconfig->buttonDisable() : m_dtconfig->baseActive()); +// QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen textHoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen textSelectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->kFontPrimary()) : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); - QBrush selectPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); +// QBrush hoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); +// QBrush selectPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); +// QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); + +// QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +// QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPen hoverPen = QPen(Qt::NoPen); + QPen selectPen = QPen(Qt::NoPen); + QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandNormal() :m_dtconfig->kLineComponentNormal()) : m_dtconfig->kLineComponentNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen selectPen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); auto *w = const_cast(widget); if (w) { @@ -2105,7 +2313,6 @@ void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QSt w->setProperty("textHoverPen", textHoverPen); w->setProperty("textSelectPen", textSelectPen); w->setProperty("textDisablePen", textSelectPen); - w->setProperty("defaultPen", defaultPen); w->setProperty("hoverPen", hoverPen); w->setProperty("selectPen", selectPen); w->setProperty("focusPen", focusPen); @@ -2116,19 +2323,16 @@ void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QSt radius = widget->property("setRadius").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert()) { - selectBrush = widget->property("setSelectBrush").value(); + selectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSelectBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); - } - if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { - defaultPen = widget->property("setDefaultPen").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert()) { hoverPen = widget->property("setHoverPen").value(); @@ -2155,13 +2359,15 @@ void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QSt m_TableParameters.tableHoverBrush = hoverBrush; m_TableParameters.tableSelectBrush = selectBrush; m_TableParameters.tableDisableBrush = disableBrush; - m_TableParameters.tableDefaultPen = defaultPen; m_TableParameters.tableHoverPen = hoverPen; m_TableParameters.tableSelectPen = selectPen; m_TableParameters.tableFocusPen = focusPen; m_TableParameters.tableTextHoverPen = textHoverPen; m_TableParameters.tableTextSelectPen = textSelectPen; m_TableParameters.tableTextDisablePen = textDisablePen; + + m_TableParameters.tableAlternatingRowsNormalBrush = alternatingRowsNormalBrush; + m_TableParameters.tableAlternatingRowsDisableBrush = alternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getDefaultConfigTableParameters(ConfigTableParameters *p, bool isDark) @@ -2179,6 +2385,9 @@ void UKUIConfigStyleParameters::getDefaultConfigTableParameters(ConfigTableParam p->tableTextHoverPen = m_TableParameters.tableTextHoverPen ; p->tableTextSelectPen = m_TableParameters.tableTextSelectPen ; p->tableTextDisablePen = m_TableParameters.tableTextDisablePen; + + p->tableAlternatingRowsNormalBrush = m_TableParameters.tableAlternatingRowsNormalBrush; + p->tableAlternatingRowsDisableBrush = m_TableParameters.tableAlternatingRowsDisableBrush; } void UKUIConfigStyleParameters::getHighlightModeConfigTableParameters(ConfigTableParameters *p, bool isDark) @@ -2200,7 +2409,11 @@ void UKUIConfigStyleParameters::getHighlightModeConfigTableParameters(ConfigTabl void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - bool needTranslucent = false; + + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::CheckBox]; + m_CheckBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::CheckBox]); + + if (widget && widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } @@ -2208,24 +2421,59 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const int radius = (widget && widget->property("minRadius").isValid()) ? widget->property("minRadius").toInt() : m_dtconfig->kradiusMin(); - QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onHoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onClickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen contentPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - QBrush onDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush onHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); - QBrush onClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush pathBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightInactive()); - QBrush pathDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha10()); + QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPen onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen onHoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen onClickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen contentPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + QBrush defaultBrush,hoverBrush,clickBrush,disableBrush,disableOnNoChangeBrush;//Checkbox off状态下Brush + QBrush onDefaultBrush,onHoverBrush,onClickBrush;//checkbox on、nochange状态下Brush, + QBrush pathBrush,pathDisableBrush,hookLineBrush,hookLineDisableBrush; + + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + disableOnNoChangeBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + disableOnNoChangeBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); + } + + onDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + onHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); + onClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); + + pathBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightInactive()); + pathDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha10()); + hookLineBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + hookLineDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhiteDisable()); + + + + QBrush textBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary()); + QBrush textDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); bool onHoverBrushIslinearGradient = false; @@ -2240,6 +2488,7 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const w->setProperty("hoverBrush", hoverBrush); w->setProperty("clickBrush", clickBrush); w->setProperty("disableBrush", disableBrush); + w->setProperty("disableOnNoChangeBrush",disableOnNoChangeBrush); w->setProperty("onDefaultBrush", onDefaultBrush); w->setProperty("onHoverBrush", onHoverBrush); w->setProperty("onClickBrush", onClickBrush); @@ -2247,6 +2496,7 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const w->setProperty("pathBrush", pathBrush); w->setProperty("contentPen", contentPen); w->setProperty("defaultPen", defaultPen); + w->setProperty("focusPen", focusPen); w->setProperty("disablePen", disablePen); w->setProperty("hoverPen", hoverPen); w->setProperty("clickPen", clickPen); @@ -2254,6 +2504,10 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const w->setProperty("onHoverPen", onHoverPen); w->setProperty("onClickPen", onClickPen); w->setProperty("onHoverBrushIslinearGradient", onHoverBrushIslinearGradient); + + w->setProperty("textBrush", textBrush); + w->setProperty("textDisableBrush", textDisableBrush); + } if (widget) { @@ -2266,6 +2520,9 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert()) { defaultPen = widget->property("setDefaultPen").value(); } + if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert()) { + focusPen = widget->property("setFocusPen").value(); + } if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert()) { hoverPen = widget->property("setHoverPen").value(); } @@ -2285,39 +2542,49 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const onClickPen = widget->property("setOnClickPen").value(); } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert()) { - clickBrush = widget->property("setClickBrush").value(); + clickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setClickBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setOnDefaultBrush").isValid() && widget->property("setOnDefaultBrush").canConvert()) { - onDefaultBrush = widget->property("setOnDefaultBrush").value(); + onDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnDefaultBrush").value()); } if (widget->property("setOnHoverBrush").isValid() && widget->property("setOnHoverBrush").canConvert()) { - onHoverBrush = widget->property("setOnHoverBrush").value(); + onHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnHoverBrush").value()); } if (widget->property("setOnClickBrush").isValid() && widget->property("setOnClickBrush").canConvert()) { - onClickBrush = widget->property("setOnClickBrush").value(); + onClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnClickBrush").value()); } if (widget->property("setPathBrush").isValid() && widget->property("setPathBrush").canConvert()) { - pathBrush = widget->property("setPathBrush").value(); + pathBrush = parseBrush(option ? option->rect : QRect(), widget->property("setPathBrush").value()); } if (widget->property("setPathDisableBrush").isValid() && widget->property("setPathDisableBrush").canConvert()) { - pathDisableBrush = widget->property("setPathDisableBrush").value(); + pathDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setPathDisableBrush").value()); } if (widget->property("setOnHoverBrushIslinearGradient").isValid() && widget->property("setOnHoverBrushIslinearGradient").canConvert()) { onHoverBrushIslinearGradient = widget->property("setOnHoverBrushIslinearGradient").value(); } + if (widget->property("setDisableOnNoChangeBrush").isValid() && widget->property("setDisableOnNoChangeBrush").canConvert()) { + disableOnNoChangeBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableOnNoChangeBrush").value()); + } + if (widget->property("setTextBrush").isValid() && widget->property("setTextBrush").canConvert()) { + textBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTextBrush").value()); + } + if (widget->property("setTextDisableBrush").isValid() && widget->property("setTextDisableBrush").canConvert()) { + textDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTextDisableBrush").value()); + } } m_CheckBoxParameters.radius = radius; m_CheckBoxParameters.checkBoxDefaultPen = defaultPen; + m_CheckBoxParameters.checkBoxFocusPen = focusPen; m_CheckBoxParameters.checkBoxHoverPen = hoverPen; m_CheckBoxParameters.checkBoxClickPen = clickPen; m_CheckBoxParameters.checkBoxDisablePen = disablePen; @@ -2330,11 +2597,16 @@ void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const m_CheckBoxParameters.checkBoxHoverBrush = hoverBrush; m_CheckBoxParameters.checkBoxClickBrush = clickBrush; m_CheckBoxParameters.checkBoxDisableBrush = disableBrush; + m_CheckBoxParameters.checkBoxDisableOnNoChangeBrush = disableOnNoChangeBrush; m_CheckBoxParameters.checkBoxOnDefaultBrush = onDefaultBrush; m_CheckBoxParameters.checkBoxOnHoverBrush = onHoverBrush; m_CheckBoxParameters.checkBoxOnClickBrush = onClickBrush; m_CheckBoxParameters.checkBoxPathBrush = pathBrush; m_CheckBoxParameters.checkBoxPathDisableBrush = pathDisableBrush; + m_CheckBoxParameters.checkboxHookLineBrush = hookLineBrush; + m_CheckBoxParameters.checkboxHookLineDisableBrush = hookLineDisableBrush; + m_CheckBoxParameters.checkBoxTextBrush = textBrush; + m_CheckBoxParameters.checkBoxTextDisableBrush = textDisableBrush; m_CheckBoxParameters.onHoverBrushIslinearGradient = onHoverBrushIslinearGradient; } @@ -2362,31 +2634,81 @@ void UKUIConfigStyleParameters::getDefaultConfigCheckBoxParameters(ConfigCheckBo p->checkBoxPathBrush = m_CheckBoxParameters.checkBoxPathBrush ; p->checkBoxPathDisableBrush = m_CheckBoxParameters.checkBoxPathDisableBrush ; p->onHoverBrushIslinearGradient = m_CheckBoxParameters.onHoverBrushIslinearGradient; + p->checkBoxDisableOnNoChangeBrush = m_CheckBoxParameters.checkBoxDisableOnNoChangeBrush; + p->checkboxHookLineBrush = m_CheckBoxParameters.checkboxHookLineBrush; + p->checkboxHookLineDisableBrush = m_CheckBoxParameters.checkboxHookLineDisableBrush; + + p->checkBoxFocusPen = m_CheckBoxParameters.checkBoxFocusPen; + p->checkBoxTextBrush = m_CheckBoxParameters.checkBoxTextBrush ; + p->checkBoxTextDisableBrush = m_CheckBoxParameters.checkBoxDisableBrush ; + } void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::RadioButton]; + m_RadioButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::RadioButton]); + m_RadioButtonParameters.radius = m_dtconfig->kradiusMenu(); - QPen defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onHoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen onClickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - - QBrush defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonDisable()); - QBrush onDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush onClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush childrenOnDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->lightActive()); - QBrush childrenOnHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->lightActive()); - QBrush childrenOnClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive()); - QBrush childrenOnDisableBrush = QBrush(QColor(179, 179, 179)); - QBrush onHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); + QBrush defaultBrush,hoverBrush,clickBrush,disableBrush;//RadioButton整体Brsuh(off) + QBrush onDefaultBrush,onClickBrush,onHoverBrush,onDisableBrush;//On状态下外圆的Brush + QBrush childrenOnDefaultBrush,childrenOnHoverBrush,childrenOnClickBrush,childrenOnDisableBrush;//内圆的 Brush + + if (needTranslucent) { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable()); + } else { + defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + } + + onDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + onHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); + onClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); + onDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable()); + + childrenOnDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + childrenOnHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + childrenOnClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + childrenOnDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + + + QPen defaultPen,hoverPen,clickPen,disablePen,focusPen; + QPen onDefaultPen,onHoverPen,onClickPen,onDisablePen; + + // if (needTranslucent) { + // defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // } else { + // defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // } + //off状态边框 + defaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + hoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + clickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + disablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + //on状态边框 + onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + onHoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + onClickPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + onDisablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + focusPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QBrush textBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary()); + QBrush textDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable()); if(option) m_RadioButtonParameters.childrenRadius = @@ -2402,6 +2724,7 @@ void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, con w->setProperty("onDefaultBrush", onDefaultBrush); w->setProperty("onHoverBrush", onHoverBrush); w->setProperty("onClickBrush", onClickBrush); + w->setProperty("onDisableBrush", onDisableBrush); w->setProperty("childrenOnDefaultBrush", childrenOnDefaultBrush); w->setProperty("childrenOnHoverBrush", childrenOnHoverBrush); w->setProperty("childrenOnClickBrush", childrenOnClickBrush); @@ -2413,6 +2736,10 @@ void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, con w->setProperty("onDefaultPen", onDefaultPen); w->setProperty("onHoverPen", onHoverPen); w->setProperty("onClickPen", onClickPen); + w->setProperty("onDisablePen", onDisablePen); + w->setProperty("focusPen", focusPen); + w->setProperty("textBrush", textBrush); + w->setProperty("textDisableBrush", textDisableBrush); } //if set property @@ -2438,61 +2765,92 @@ void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, con if (widget->property("setOnClickPen").isValid() && widget->property("setOnClickPen").canConvert()) { onClickPen = widget->property("setOnClickPen").value(); } + if (widget->property("setOnDisablePen").isValid() && widget->property("setOnDisablePen").canConvert()) { + onDisablePen = widget->property("setOnDisablePen").value(); + } + if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert()) { + focusPen = widget->property("setFocusPen").value(); + } if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert()) { - defaultBrush = widget->property("setDefaultBrush").value(); + defaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDefaultBrush").value()); } if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert()) { - hoverBrush = widget->property("setHoverBrush").value(); + hoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHoverBrush").value()); } if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert()) { - clickBrush = widget->property("setClickBrush").value(); + clickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setClickBrush").value()); } if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert()) { - disableBrush = widget->property("setDisableBrush").value(); + disableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setDisableBrush").value()); } if (widget->property("setOnDefaultBrush").isValid() && widget->property("setOnDefaultBrush").canConvert()) { - onDefaultBrush = widget->property("setOnDefaultBrush").value(); + onDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnDefaultBrush").value()); } if (widget->property("setOnHoverBrush").isValid() && widget->property("setOnHoverBrush").canConvert()) { - onHoverBrush = widget->property("setOnHoverBrush").value(); + onHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnHoverBrush").value()); } if (widget->property("setOnClickBrush").isValid() && widget->property("setOnClickBrush").canConvert()) { - onClickBrush = widget->property("setOnClickBrush").value(); + onClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnClickBrush").value()); + } + if (widget->property("setOnDisableBrush").isValid() && widget->property("setOnDisableBrush").canConvert()) { + onClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setOnDisableBrush").value()); } if (widget->property("setChildrenOnDefaultBrush").isValid() && widget->property("setChildrenOnDefaultBrush").canConvert()) { - childrenOnDefaultBrush = widget->property("setChildrenOnDefaultBrush").value(); + childrenOnDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setChildrenOnDefaultBrush").value()); } if (widget->property("setChildrenOnHoverBrush").isValid() && widget->property("setChildrenOnHoverBrush").canConvert()) { - childrenOnHoverBrush = widget->property("setChildrenOnHoverBrush").value(); + childrenOnHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setChildrenOnHoverBrush").value()); } if (widget->property("setChildrenOnClickBrush").isValid() && widget->property("setChildrenOnClickBrush").canConvert()) { - childrenOnClickBrush = widget->property("setChildrenOnClickBrush").value(); + childrenOnClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setChildrenOnClickBrush").value()); } if (widget->property("setChildrenOnDisableBrush").isValid() && widget->property("setChildrenOnDisableBrush").canConvert()) { - childrenOnDisableBrush = widget->property("setChildrenOnDisableBrush").value(); + childrenOnDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setChildrenOnDisableBrush").value()); + } + + if (widget->property("setTextBrush").isValid() && widget->property("setTextBrush").canConvert()) { + textBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTextBrush").value()); } + if (widget->property("setTextDisableBrush").isValid() && widget->property("setTextDisableBrush").canConvert()) { + textDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTextDisableBrush").value()); + } + } m_RadioButtonParameters.radioButtonDefaultPen = defaultPen; m_RadioButtonParameters.radioButtonHoverPen = hoverPen; m_RadioButtonParameters.radioButtonClickPen = clickPen; + + m_RadioButtonParameters.radioButtonFocusPen = focusPen; + m_RadioButtonParameters.radioButtonDisablePen = disablePen; + m_RadioButtonParameters.radioButtonOnDefaultPen = onDefaultPen; m_RadioButtonParameters.radioButtonOnHoverPen = onHoverPen; m_RadioButtonParameters.radioButtonOnClickPen = onClickPen; + m_RadioButtonParameters.radioButtonOnDisablePen = onDisablePen; + + m_RadioButtonParameters.radioButtonDefaultBrush = defaultBrush; m_RadioButtonParameters.radioButtonHoverBrush = hoverBrush; m_RadioButtonParameters.radioButtonClickBrush = clickBrush; + m_RadioButtonParameters.radioButtonDisableBrush = disableBrush; m_RadioButtonParameters.radioButtonOnDefaultBrush = onDefaultBrush; m_RadioButtonParameters.radioButtonOnHoverBrush = onHoverBrush; m_RadioButtonParameters.radioButtonOnClickBrush = onClickBrush; + m_RadioButtonParameters.radioButtonOnDisableBrush = onDisableBrush; + m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush = childrenOnDefaultBrush; m_RadioButtonParameters.radioButtonChildrenOnHoverBrush = childrenOnHoverBrush; m_RadioButtonParameters.radioButtonChildrenOnClickBrush = childrenOnClickBrush; m_RadioButtonParameters.radioButtonChildrenOnDisableBrush = childrenOnDisableBrush; + + m_RadioButtonParameters.radioButtonTextBrush = textBrush; + m_RadioButtonParameters.radioButtonTextDisableBrush = textDisableBrush; + } void UKUIConfigStyleParameters::getDefaultConfigRadioButtonParameters(ConfigRadioButtonParameters *p, bool isDark) @@ -2505,6 +2863,9 @@ void UKUIConfigStyleParameters::getDefaultConfigRadioButtonParameters(ConfigRadi p->radioButtonOnDefaultPen = m_RadioButtonParameters.radioButtonOnDefaultPen ; p->radioButtonOnHoverPen = m_RadioButtonParameters.radioButtonOnHoverPen ; p->radioButtonOnClickPen = m_RadioButtonParameters.radioButtonOnClickPen ; + p->radioButtonOnDisablePen = m_RadioButtonParameters.radioButtonOnDisablePen ; + + p->radioButtonFocusPen = m_RadioButtonParameters.radioButtonFocusPen ; p->radioButtonDefaultBrush = m_RadioButtonParameters.radioButtonDefaultBrush ; p->radioButtonHoverBrush = m_RadioButtonParameters.radioButtonHoverBrush ; p->radioButtonClickBrush = m_RadioButtonParameters.radioButtonClickBrush ; @@ -2512,53 +2873,93 @@ void UKUIConfigStyleParameters::getDefaultConfigRadioButtonParameters(ConfigRadi p->radioButtonOnDefaultBrush = m_RadioButtonParameters.radioButtonOnDefaultBrush ; p->radioButtonOnHoverBrush = m_RadioButtonParameters.radioButtonOnHoverBrush ; p->radioButtonOnClickBrush = m_RadioButtonParameters.radioButtonOnClickBrush ; + p->radioButtonOnDisableBrush = m_RadioButtonParameters.radioButtonOnDisableBrush ; p->radioButtonChildrenOnDefaultBrush = m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush; p->radioButtonChildrenOnHoverBrush = m_RadioButtonParameters.radioButtonChildrenOnHoverBrush ; p->radioButtonChildrenOnClickBrush = m_RadioButtonParameters.radioButtonChildrenOnClickBrush ; p->radioButtonChildrenOnDisableBrush = m_RadioButtonParameters.radioButtonChildrenOnDisableBrush; + p->radioButtonTextBrush = m_RadioButtonParameters.radioButtonTextBrush ; + p->radioButtonTextDisableBrush = m_RadioButtonParameters.radioButtonDisableBrush ; } void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { int grooveRadius = Slider_GrooveLength/2; - bool needTranslucent = false; + float disableAlpha = 0.45f; + + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Slider]; + m_SliderParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Slider]); + if (widget && widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } - QBrush handleDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush handleHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover()); - QBrush handleClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush handleDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray11()); + //滑动控制圈的颜色 + QBrush handleDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + QBrush handleHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + QBrush handleClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite()); + QBrush handleDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());// rgba(255, 255, 255, 1) + + auto handleDisableColor = handleDisableBrush.color(); + handleDisableColor.setAlphaF(isDark ? 0.45: 0.9); + handleDisableBrush = QBrush(handleDisableColor); + + QBrush handleDisbaleBaseBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive());//rgba(255, 255, 255, 1); dark:rgba(26, 26, 26, 1); + + + //已划过的滑动条部分的颜色 + QBrush grooveValueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + QBrush grooveValueHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + QBrush grooveValueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());//rgba(54, 118, 245, 1); 实色 + + auto grooveValueDisableColor = grooveValueDisableBrush.color(); + grooveValueDisableColor.setAlphaF(disableAlpha*grooveValueDisableColor.alphaF()); + grooveValueDisableBrush.setColor(grooveValueDisableColor); + + + //未划过的滑动条部分的颜色 + QBrush grooveUnvalueDefaultBrush,grooveUnvalueHoverBrush,grooveUnvalueDisableBrush; + if (needTranslucent) { + grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + grooveUnvalueHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());//rgba(0, 0, 0, 0.04) + } else { + grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + grooveUnvalueHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());//rgba(240, 240, 240, 1); + } + QColor grooveUnvalueDisableColor = grooveUnvalueDisableBrush.color(); + grooveUnvalueDisableColor.setAlphaF(grooveUnvalueDisableColor.alphaF() * disableAlpha); + grooveUnvalueDisableBrush.setColor(grooveUnvalueDisableColor); + + + //滑动控制圈的外框 + QBrush handleDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + QBrush handleHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + QBrush handleClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + QBrush handleDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + - QBrush grooveValueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush grooveValueHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick()); - QBrush grooveValueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray12()); - QBrush grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->midlightDisable()); - QBrush grooveUnvalueHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->midlightDisable()); - QBrush grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->midlightDisable()); + QBrush sliderGroovePenBrush(Qt::NoBrush); - QBrush handleDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush handleHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush handleClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); - QBrush handleDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()); - QBrush sliderGroovePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); - QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()); + QBrush focusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()); - QPen handleDefaultPen = QPen(handleDefaultPenBrush, (handleDefaultPenBrush.style() == Qt::NoBrush || handleDefaultPenBrush.color().alpha() == 0) ? 0 : 1, + QPen handleDefaultPen = QPen(handleDefaultPenBrush, (handleDefaultPenBrush.style() == Qt::NoBrush || handleDefaultPenBrush.color().alpha() == 0) ? 0 : 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen handleHoverPen = QPen(handleHoverPenBrush, (handleHoverPenBrush.style() == Qt::NoBrush || handleHoverPenBrush.color().alpha() == 0) ? 0 : 1, + QPen handleHoverPen = QPen(handleHoverPenBrush, (handleHoverPenBrush.style() == Qt::NoBrush || handleHoverPenBrush.color().alpha() == 0) ? 0 : 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen handleClickPen = QPen(handleClickPenBrush, (handleClickPenBrush.style() == Qt::NoBrush || handleClickPenBrush.color().alpha() == 0) ? 0 : 1, + QPen handleClickPen = QPen(handleClickPenBrush, (handleClickPenBrush.style() == Qt::NoBrush || handleClickPenBrush.color().alpha() == 0) ? 0 : 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - QPen handleDisablePen = QPen(handleDisablePenBrush, (handleDisablePenBrush.style() == Qt::NoBrush || handleDisablePenBrush.color().alpha() == 0) ? 0 : 1, + QPen handleDisablePen = QPen(handleDisablePenBrush, (handleDisablePenBrush.style() == Qt::NoBrush || handleDisablePenBrush.color().alpha() == 0) ? 0 : 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen sliderGroovePen = QPen(sliderGroovePenBrush, (sliderGroovePenBrush.style() == Qt::NoBrush || sliderGroovePenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen focusPen = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + QPainterPath handlePath; int radius = m_dtconfig->kradiusNormal(); @@ -2585,6 +2986,7 @@ void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QS w->setProperty("handleHoverBrush", handleHoverBrush); w->setProperty("handleClickBrush", handleClickBrush); w->setProperty("handleDisableBrush", handleDisableBrush); + w->setProperty("handleDisbaleBaseBrush", handleDisbaleBaseBrush); w->setProperty("grooveValueDefaultBrush", grooveValueDefaultBrush); w->setProperty("grooveValueHoverBrush", grooveValueHoverBrush); w->setProperty("grooveValueDisableBrush", grooveValueDisableBrush); @@ -2607,52 +3009,55 @@ void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QS grooveRadius = widget->property("setGrooveRadius").value(); } if (widget->property("setHandleDefaultBrush").isValid() && widget->property("setHandleDefaultBrush").canConvert()) { - handleDefaultBrush = widget->property("setHandleDefaultBrush").value(); + handleDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHandleDefaultBrush").value()); } if (widget->property("setHandleHoverBrush").isValid() && widget->property("setHandleHoverBrush").canConvert()) { - handleHoverBrush = widget->property("setHandleHoverBrush").value(); + handleHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHandleHoverBrush").value()); } if (widget->property("setHandleClickBrush").isValid() && widget->property("setHandleClickBrush").canConvert()) { - handleClickBrush = widget->property("setHandleClickBrush").value(); + handleClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHandleClickBrush").value()); } if (widget->property("setHandleDisableBrush").isValid() && widget->property("setHandleDisableBrush").canConvert()) { - handleDisableBrush = widget->property("setHandleDisableBrush").value(); + handleDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHandleDisableBrush").value()); + } + if (widget->property("setHandleDisableBaseBrush").isValid() && widget->property("setHandleDisableBaseBrush").canConvert()) { + handleDisbaleBaseBrush = parseBrush(option ? option->rect : QRect(), widget->property("setHandleDisableBaseBrush").value()); } if (widget->property("setGrooveValueDefaultBrush").isValid() && widget->property("setGrooveValueDefaultBrush").canConvert()) { - grooveValueDefaultBrush = widget->property("setGrooveValueDefaultBrush").value(); + grooveValueDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveValueDefaultBrush").value()); } if (widget->property("setGrooveValueHoverBrush").isValid() && widget->property("setGrooveValueHoverBrush").canConvert()) { - grooveValueHoverBrush = widget->property("setGrooveValueHoverBrush").value(); + grooveValueHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveValueHoverBrush").value()); } if (widget->property("setGrooveValueDisableBrush").isValid() && widget->property("setGrooveValueDisableBrush").canConvert()) { - grooveValueDisableBrush = widget->property("setGrooveValueDisableBrush").value(); + grooveValueDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveValueDisableBrush").value()); } if (widget->property("setGrooveUnvalueDefaultBrush").isValid() && widget->property("setGrooveUnvalueDefaultBrush").canConvert()) { - grooveUnvalueDefaultBrush = widget->property("setGrooveUnvalueDefaultBrush").value(); + grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveUnvalueDefaultBrush").value()); } if (widget->property("setGrooveUnvalueHoverBrush").isValid() && widget->property("setGrooveUnvalueHoverBrush").canConvert()) { - grooveUnvalueHoverBrush = widget->property("setGrooveUnvalueHoverBrush").value(); + grooveUnvalueHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveUnvalueHoverBrush").value()); } if (widget->property("setGrooveUnvalueDisableBrush").isValid() && widget->property("setGrooveUnvalueDisableBrush").canConvert()) { - grooveUnvalueDisableBrush = widget->property("setGrooveUnvalueDisableBrush").value(); + grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveUnvalueDisableBrush").value()); } - if (widget->property("setHandleDefaultPen").isValid() && widget->property("setHandleDefaultPen").canConvert()) { + if (widget->property("setHandleDefaultPen").isValid() && widget->property("setHandleDefaultPen").canConvert()) { handleDefaultPen = widget->property("setHandleDefaultPen").value(); } - if (widget->property("setHandleHoverPen").isValid() && widget->property("setHandleHoverPen").canConvert()) { + if (widget->property("setHandleHoverPen").isValid() && widget->property("setHandleHoverPen").canConvert()) { handleHoverPen = widget->property("setHandleHoverPen").value(); } - if (widget->property("setHandleClickPen").isValid() && widget->property("setHandleClickPen").canConvert()) { + if (widget->property("setHandleClickPen").isValid() && widget->property("setHandleClickPen").canConvert()) { handleClickPen = widget->property("setHandleClickPen").value(); } - if (widget->property("setHandleDisablePen").isValid() && widget->property("setHandleDisablePen").canConvert()) { + if (widget->property("setHandleDisablePen").isValid() && widget->property("setHandleDisablePen").canConvert()) { handleDisablePen = widget->property("setHandleDisablePen").value(); } - if (widget->property("setSliderGroovePen").isValid() && widget->property("setSliderGroovePen").canConvert()) { + if (widget->property("setSliderGroovePen").isValid() && widget->property("setSliderGroovePen").canConvert()) { sliderGroovePen = widget->property("setSliderGroovePen").value(); } - if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert()) { + if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert()) { focusPen = widget->property("setFocusPen").value(); } } @@ -2664,6 +3069,7 @@ void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QS m_SliderParameters.sliderHandleHoverBrush = handleHoverBrush; m_SliderParameters.sliderHandleClickBrush = handleClickBrush; m_SliderParameters.sliderHandleDisableBrush = handleDisableBrush; + m_SliderParameters.sliderHandleDisbaleBaseBrush = handleDisbaleBaseBrush; m_SliderParameters.sliderGrooveValueDefaultBrush = grooveValueDefaultBrush; m_SliderParameters.sliderGrooveValueHoverBrush = grooveValueHoverBrush; @@ -2684,6 +3090,8 @@ void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QS m_SliderParameters.sliderHandlePath = handlePath; } + + void UKUIConfigStyleParameters::getDefaultSliderParameters(ConfigSliderParameters *p, bool isDark) { initConfigSliderParameters(isDark, nullptr, nullptr); @@ -2693,6 +3101,7 @@ void UKUIConfigStyleParameters::getDefaultSliderParameters(ConfigSliderParameter p->sliderHandleHoverBrush = m_SliderParameters.sliderHandleHoverBrush ; p->sliderHandleClickBrush = m_SliderParameters.sliderHandleClickBrush ; p->sliderHandleDisableBrush = m_SliderParameters.sliderHandleDisableBrush ; + p->sliderHandleDisbaleBaseBrush = m_SliderParameters.sliderHandleDisbaleBaseBrush ; p->sliderGrooveValueDefaultBrush = m_SliderParameters.sliderGrooveValueDefaultBrush ; p->sliderGrooveValueHoverBrush = m_SliderParameters.sliderGrooveValueHoverBrush ; p->sliderGrooveValueDisableBrush = m_SliderParameters.sliderGrooveValueDisableBrush ; @@ -2707,63 +3116,84 @@ void UKUIConfigStyleParameters::getDefaultSliderParameters(ConfigSliderParameter p->focusPen = m_SliderParameters.focusPen ; } + void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - int normalRadius = m_dtconfig->kradiusNormal(); - int radius = widget ? (widget->height() / 2 > normalRadius ? normalRadius : widget->height() / 2) : normalRadius; + // int normalRadius = m_dtconfig->kradiusNormal(); + // int radius = widget ? (widget->height() / 2 > normalRadius ? normalRadius : widget->height() / 2) : normalRadius; + + const QStyleOptionProgressBar *pb = qstyleoption_cast(option); + if (!pb) { + return ; + } + const bool indeterminate = (pb->minimum == 0 && pb->maximum == 0);//是否为indeterminate状态 + int radius = indeterminate ? (m_dtconfig->kradiusMin()) : (m_dtconfig->kradiusNormal()); + + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ProgressBar]; + m_ProgressBarParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ProgressBar]); - bool needTranslucent = false; if (widget && widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } - QBrush contentBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + //已划过的进度区域颜色 + QBrush contentBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); + + //未填充的进度区域颜色 + QBrush grooveDefaultBrush; + if (needTranslucent) { + grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal()); + } else { + grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + } + QBrush grooveDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); + QBrush sliderBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal()); QBrush contentPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); - QBrush grooveDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + QBrush grooveDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal()); QBrush grooveDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable()); - QPen contentPen = QPen(contentPenBrush, (contentPenBrush.style() == Qt::NoBrush || contentPenBrush.color().alpha() == 0) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + // QPen contentPen = QPen(contentPenBrush, (contentPenBrush.style() == Qt::NoBrush || contentPenBrush.color().alpha() == 0) ? 0 : 1, + // Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen contentPen = QPen(Qt::NoPen); QPen grooveDefaultPen = QPen(grooveDefaultPenBrush, (grooveDefaultPenBrush.style() == Qt::NoBrush || grooveDefaultPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen grooveDisablePen = QPen(grooveDisablePenBrush, (grooveDisablePenBrush.style() == Qt::NoBrush || grooveDisablePenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - const QStyleOptionProgressBar *pb = qstyleoption_cast(option); - const bool vertical = pb ? pb->orientation == Qt::Vertical : false; - const bool inverted = pb ? pb->invertedAppearance : false; + // const QStyleOptionProgressBar *pb = qstyleoption_cast(option); + // const bool vertical = pb ? pb->orientation == Qt::Vertical : false; + // const bool inverted = pb ? pb->invertedAppearance : false; - bool reverse = (!vertical && pb && (pb->direction == Qt::RightToLeft)) || vertical; - if (inverted) - reverse = !reverse; + // bool reverse = (!vertical && pb && (pb->direction == Qt::RightToLeft)) || vertical; + // if (inverted) + // reverse = !reverse; //content - if (contentBrush.style() == Qt::LinearGradientPattern) { - QLinearGradient linearGradient; - linearGradient.setStops(contentBrush.gradient()->stops()); - if (vertical) { - if (reverse) { - linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.bottomLeft()); - linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topLeft()); - } else { - linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft()); - linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.bottomLeft()); - } - } else { - if (reverse) { - linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topRight()); - linearGradient.setFinalStop(pb->rect.topLeft()); - } else { - linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft()); - linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topRight()); - } - } - contentBrush = QBrush(linearGradient); - } + // if (contentBrush.style() == Qt::LinearGradientPattern) { + // QLinearGradient linearGradient; + // linearGradient.setStops(contentBrush.gradient()->stops()); + // if (vertical) { + // if (reverse) { + // linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.bottomLeft()); + // linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topLeft()); + // } else { + // linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft()); + // linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.bottomLeft()); + // } + // } else { + // if (reverse) { + // linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topRight()); + // linearGradient.setFinalStop(pb->rect.topLeft()); + // } else { + // linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft()); + // linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topRight()); + // } + // } + // contentBrush = QBrush(linearGradient); + // } auto *w = const_cast(widget); if (w) { @@ -2774,6 +3204,7 @@ void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, con w->setProperty("contentBrush", contentBrush); w->setProperty("grooveDefaultBrush", grooveDefaultBrush); w->setProperty("grooveDisableBrush", grooveDisableBrush); + w->setProperty("progressSliderBrush", sliderBrush); } if(widget){ @@ -2781,13 +3212,13 @@ void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, con radius = widget->property("setRadius").value(); } if (widget->property("setContentBrush").isValid() && widget->property("setContentBrush").canConvert()) { - contentBrush = widget->property("setContentBrush").value(); + contentBrush = parseBrush(option ? option->rect : QRect(), widget->property("setContentBrush").value()); } if (widget->property("setGrooveDefaultBrush").isValid() && widget->property("setGrooveDefaultBrush").canConvert()) { - grooveDefaultBrush = widget->property("setGrooveDefaultBrush").value(); + grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveDefaultBrush").value()); } if (widget->property("setGrooveDisableBrush").isValid() && widget->property("setGrooveDisableBrush").canConvert()) { - grooveDisableBrush = widget->property("setGrooveDisableBrush").value(); + grooveDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveDisableBrush").value()); } if (widget->property("setGrooveDefaultPen").isValid() && widget->property("setGrooveDefaultPen").canConvert()) { grooveDefaultPen = widget->property("setGrooveDefaultPen").value(); @@ -2795,6 +3226,9 @@ void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, con if (widget->property("setGrooveDisablePen").isValid() && widget->property("setGrooveDisablePen").canConvert()) { grooveDisablePen = widget->property("setGrooveDisablePen").value(); } + if (widget->property("setSliderBrush").isValid() && widget->property("setSliderBrush").canConvert()) { + sliderBrush = widget->property("setSliderBrush").value(); + } } m_ProgressBarParameters.radius = radius; @@ -2806,6 +3240,8 @@ void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, con m_ProgressBarParameters.progressBarContentBrush = contentBrush; m_ProgressBarParameters.progressBarGrooveDefaultBrush = grooveDefaultBrush; m_ProgressBarParameters.progressBarGrooveDisableBrush = grooveDisableBrush; + + m_ProgressBarParameters.progressSliderBrush = sliderBrush; } void UKUIConfigStyleParameters::getDefaultProgressBarParameters(ConfigProgressBarParameters *p, bool isDark) @@ -2822,21 +3258,41 @@ void UKUIConfigStyleParameters::getDefaultProgressBarParameters(ConfigProgressBa void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - int sliderRadius; - bool needTranslucent = false; + int sliderRadius = m_dtconfig->kradiusMin(); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ScrollBar]; + m_ScrollBarParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ScrollBar]); + if (widget && widget->property("needTranslucent").isValid()) { needTranslucent = widget->property("needTranslucent").toBool(); } QBrush grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); QBrush grooveInactiveBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush sliderDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray6()); - QBrush sliderHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); - QBrush sliderClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()); - QBrush sliderDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray3()); + + //scrollbar本身颜色 + QBrush sliderDefaultBrush,sliderHoverBrush,sliderClickBrush,sliderDisableBrush; + if (needTranslucent) { + sliderDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha10()); + sliderHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha13()); + sliderClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha11()); + sliderDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha5()); + } else { + sliderDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray12()); + sliderHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray13()); + sliderClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray14()); + sliderDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGray8()); + } const QStyleOptionSlider *bar = qstyleoption_cast(option); + bool needArrow; + if (widget && widget->property("needArrow").isValid()) { + + needArrow = widget->property("needArrow").toBool(); + // ScrooBar_ShowLine = needArrow; + // qDebug() << "对于widget = " << widget << ",ScrooBar_ShowLine set = " << ScrooBar_ShowLine; + } + //radius int normalRadius = m_dtconfig->kradiusMin(); if (bar && normalRadius != 0) { @@ -2845,26 +3301,34 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const } else { sliderRadius = (bar->rect.width()) / 4; } - m_ScrollBarParameters.grooveWidthAnimation = true; - ScrooBar_ShowLine = false; - ScroolBar_LineLength = 0; + // m_ScrollBarParameters.grooveWidthAnimation = true; + // ScrooBar_ShowLine = false; + // ScroolBar_LineLength = 0; } else { int normalRadius = m_dtconfig->kradiusNormal(); sliderRadius = normalRadius; - m_ScrollBarParameters.grooveWidthAnimation = false; - ScrooBar_ShowLine = true; + // m_ScrollBarParameters.grooveWidthAnimation = false; + // ScrooBar_ShowLine = true; ScroolBar_LineLength = 16; } //slider hover - if (m_dtconfig->kContainHover().style() == Qt::LinearGradientPattern && bar && bar->orientation == Qt::Vertical) { - QLinearGradient linearGradient; - linearGradient.setStart(!option ? QPoint(0,0) : option->rect.topRight()); - linearGradient.setFinalStop(!option ? QPoint(0,0) : option->rect.topLeft()); - linearGradient.setStops(m_dtconfig->kContainHover().gradient()->stops()); - sliderHoverBrush = QBrush(linearGradient); - } - + // if (m_dtconfig->kContainHover().style() == Qt::LinearGradientPattern && bar && bar->orientation == Qt::Vertical) { + // QLinearGradient linearGradient; + // linearGradient.setStart(!option ? QPoint(0,0) : option->rect.topRight()); + // linearGradient.setFinalStop(!option ? QPoint(0,0) : option->rect.topLeft()); + // linearGradient.setStops(m_dtconfig->kContainHover().gradient()->stops()); + // sliderHoverBrush = QBrush(linearGradient); + // } + // if (m_dtconfig->kContainHover().style() == Qt::LinearGradientPattern && bar && bar->orientation == Qt::Vertical) { + // QLinearGradient linearGradient; + // // 起点:顶部中点 (0.5 * width, 0) + // linearGradient.setStart(!option ? QPoint(0,0) : QPoint(option->rect.width() * 0.5, option->rect.top())); + // // 终点:底部中点 (0.5 * width, height) + // linearGradient.setFinalStop(!option ? QPoint(0,0) : QPoint(option->rect.width() * 0.5, option->rect.bottom())); + // linearGradient.setStops(m_dtconfig->kContainHover().gradient()->stops()); + // sliderHoverBrush = QBrush(linearGradient); + // } auto *w = const_cast(widget); if (w) { w->setProperty("radius", sliderRadius); @@ -2880,22 +3344,22 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const radius = widget->property("setRadius").value(); } if (widget->property("setGrooveDefaultBrush").isValid() && widget->property("setGrooveDefaultBrush").canConvert()) { - grooveDefaultBrush = widget->property("setGrooveDefaultBrush").value(); + grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveDefaultBrush").value()); } if (widget->property("setGrooveInactiveBrush").isValid() && widget->property("setGrooveInactiveBrush").canConvert()) { - grooveInactiveBrush = widget->property("setGrooveInactiveBrush").value(); + grooveInactiveBrush = parseBrush(option ? option->rect : QRect(), widget->property("setGrooveInactiveBrush").value()); } if (widget->property("setSliderDefaultBrush").isValid() && widget->property("setSliderDefaultBrush").canConvert()) { - sliderDefaultBrush = widget->property("setSliderDefaultBrush").value(); + sliderDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSliderDefaultBrush").value()); } if (widget->property("setSliderHoverBrush").isValid() && widget->property("setSliderHoverBrush").canConvert()) { - sliderHoverBrush = widget->property("setSliderHoverBrush").value(); + sliderHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSliderHoverBrush").value()); } if (widget->property("setSliderClickBrush").isValid() && widget->property("setSliderClickBrush").canConvert()) { - sliderClickBrush = widget->property("setSliderClickBrush").value(); + sliderClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSliderClickBrush").value()); } if (widget->property("setSliderDisableBrush").isValid() && widget->property("setSliderDisableBrush").canConvert()) { - sliderDisableBrush = widget->property("setSliderDisableBrush").value(); + sliderDisableBrush = parseBrush(option ? option->rect : QRect(), widget->property("setSliderDisableBrush").value()); } } @@ -2907,6 +3371,7 @@ void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const m_ScrollBarParameters.scrollBarSliderHoverBrush = sliderHoverBrush; m_ScrollBarParameters.scrollBarSliderClickBrush = sliderClickBrush; m_ScrollBarParameters.scrollBarSliderDisableBrush = sliderDisableBrush; + m_ScrollBarParameters.scrollBarShowArrow = needArrow; } void UKUIConfigStyleParameters::getDefaultScrollBarParameters(ConfigScrollBarParameters *p, bool isDark) @@ -2923,10 +3388,16 @@ void UKUIConfigStyleParameters::getDefaultScrollBarParameters(ConfigScrollBarPar void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - QPen backgroundPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()), - (parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color().alpha() == 0 || - parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color() == Qt::NoPen ) ? 0 : 1, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Tooltip]; + m_ToolTipParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Tooltip]); + +// QPen backgroundPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()), +// (parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color().alpha() == 0 || +// parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color() == Qt::NoPen ) ? 0 : 1, +// Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + + QPen backgroundPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowInactive()),1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); //background auto color = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive()).color(); @@ -2946,7 +3417,7 @@ void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const Q } } //if blur effect is not supported, do not use transparent color. - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) { + if (!m_isHardwareRendering/*!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)*/ || blackAppListWithBlurHelper().contains(qAppName())) { color.setAlphaF(1); } QBrush backgroundBrush = color; @@ -2957,9 +3428,9 @@ void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const Q radius = widget->property("setRadius").value(); } if (widget->property("setBackgroundBrush").isValid() && widget->property("setBackgroundBrush").canConvert()) { - backgroundBrush = widget->property("setBackgroundBrush").value(); + backgroundBrush = parseBrush(option ? option->rect : QRect(), widget->property("setBackgroundBrush").value()); } - if (widget->property("setBackgroundPen").isValid() && widget->property("setBackgroundPen").canConvert()) { + if (widget->property("setBackgroundPen").isValid() && widget->property("setBackgroundPen").canConvert()) { backgroundPen = widget->property("setBackgroundPen").value(); } } @@ -2985,19 +3456,73 @@ void UKUIConfigStyleParameters::getDefaultToolTipParameters(ConfigToolTipParamet //解析TabWidget相关颜色 void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { - int tabradius = m_dtconfig->kradiusNormal(); + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::TabWidget]; + m_TabWidgetParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::TabWidget]); + + if (widget && widget->property("needTranslucent").isValid()) { + needTranslucent = widget->property("needTranslucent").toBool(); + } + bool isSecondary = false; + if (widget && widget->property("isSecondary").isValid()) { + isSecondary = widget->property("isSecondary").toBool(); + } + + bool selected = false; + if (option) { + selected = option->state & QStyle::State_Selected; + } + + int tabradius = m_dtconfig->kradiusWindow(); QBrush widgetBackgroundBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive()); - QBrush tabBarBackgroundBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush tabBarDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush tabBarHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); - QBrush tabBarSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); - QBrush tabBarClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()); - - QBrush tabBarHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); - QBrush tabBarClickPenPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); - QBrush tabBarDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + + //整个TabBar的背景色 + //QBrush tabBarBackgroundBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + QBrush tabBarBackgroundBrush = Qt::transparent; + + + //tab默认背景色 + QBrush tabBarDefaultBrush = selected ? parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()) : Qt::transparent; + + QBrush tabBarHoverBrush,tabBarSelectBrush,tabBarClickBrush,tabBarFocusBrush; + + tabBarFocusBrush = parseBrush(option ? option->rect : QRect(), selected ? m_dtconfig->kContainGeneralNormal() : Qt::transparent); + + if (needTranslucent) { + tabBarHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainAlphaHover());//是否选中,都是该token + tabBarClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainAlphaClick()); + + if(isSecondary){ + tabBarSelectBrush =parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + widgetBackgroundBrush =parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + }else{ + tabBarSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + } + + + } else { + tabBarHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover()); + tabBarClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()); + + if(isSecondary){ + tabBarSelectBrush =parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + widgetBackgroundBrush =parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainSecondaryNormal()); + }else{ + tabBarSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()); + } + } + + +// QBrush tabBarHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); +// QBrush tabBarClickPenPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); +// QBrush tabBarDefaultPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal()); + + QBrush tabBarHoverPenBrush = Qt::transparent; + QBrush tabBarClickPenPenBrush = Qt::transparent; + QBrush tabBarDefaultPenBrush = Qt::transparent; + QBrush tabBarFocusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()); + QBrush tabBarDividerPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kDivider()); QPen tabBarHoverPen = QPen(tabBarHoverPenBrush, (tabBarHoverPenBrush.style() == Qt::NoBrush || tabBarHoverPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -3008,6 +3533,19 @@ void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const QPen tabBarFocusPen = QPen(tabBarFocusPenBrush, (tabBarFocusPenBrush.style() == Qt::NoBrush || tabBarFocusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen tabBarDividerPen = QPen(tabBarDividerPenBrush, (tabBarDividerPenBrush.style() == Qt::NoBrush || tabBarDividerPenBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + + if(needTranslucent){ + m_TabWidgetParameters.tabBarIndicatorHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + m_TabWidgetParameters.tabBarIndicatorClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick().color()); + } + else{ + m_TabWidgetParameters.tabBarIndicatorHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover().color()); + m_TabWidgetParameters.tabBarIndicatorClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick().color()); + } + + // if((option->state & QStyle::State_HasFocus) && (option->state & QStyle::State_Enabled)){ // tabBarPen = tabBarFocusPen; // } @@ -3031,22 +3569,22 @@ void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const tabradius = widget->property("setRadius").value(); } if (widget->property("setWidgetBackgroundBrush").isValid() && widget->property("setWidgetBackgroundBrush").canConvert()) { - widgetBackgroundBrush = widget->property("setWidgetBackgroundBrush").value(); + widgetBackgroundBrush = parseBrush(option ? option->rect : QRect(), widget->property("setWidgetBackgroundBrush").value()); } if (widget->property("setTabBarBackgroundBrush").isValid() && widget->property("setTabBarBackgroundBrush").canConvert()) { - tabBarBackgroundBrush = widget->property("setTabBarBackgroundBrush").value(); + tabBarBackgroundBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTabBarBackgroundBrush").value()); } if (widget->property("setTabBarDefaultBrush").isValid() && widget->property("setTabBarDefaultBrush").canConvert()) { - tabBarDefaultBrush = widget->property("setTabBarDefaultBrush").value(); + tabBarDefaultBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTabBarDefaultBrush").value()); } if (widget->property("setTabBarHoverBrush").isValid() && widget->property("setTabBarHoverBrush").canConvert()) { - tabBarHoverBrush = widget->property("setTabBarHoverBrush").value(); + tabBarHoverBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTabBarHoverBrush").value()); } if (widget->property("setTabBarClickBrush").isValid() && widget->property("setTabBarClickBrush").canConvert()) { - tabBarClickBrush = widget->property("setTabBarClickBrush").value(); + tabBarClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTabBarClickBrush").value()); } if (widget->property("setTabBarSelectBrush").isValid() && widget->property("setTabBarSelectBrush").canConvert()) { - tabBarSelectBrush = widget->property("setTabBarSelectBrush").value(); + tabBarSelectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setTabBarSelectBrush").value()); } if (widget->property("setTabBarDefaultPen").isValid() && widget->property("setTabBarDefaultPen").canConvert()) { tabBarDefaultPen = widget->property("setTabBarDefaultPen").value(); @@ -3061,14 +3599,10 @@ void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const tabBarFocusPen = widget->property("setTabBarHoverPen").value(); } } - // qDebug() << "========> widgetBackgroundBrush = " << widgetBackgroundBrush; - // qDebug() << "========> tabBarBackgroundBrush = " << tabBarBackgroundBrush; - // qDebug() << "========> tabBarDefaultBrush = " << tabBarDefaultBrush; - // qDebug() << "========> tabBarHoverBrush = " << tabBarHoverBrush; m_TabWidgetParameters.radius = tabradius; m_TabWidgetParameters.tabWidgetBackgroundBrush = widgetBackgroundBrush; - m_TabWidgetParameters.tabBarBackgroundBrush = QBrush(QColor(255,0,0)); + m_TabWidgetParameters.tabBarBackgroundBrush = tabBarBackgroundBrush; m_TabWidgetParameters.tabBarDefaultBrush = tabBarDefaultBrush; m_TabWidgetParameters.tabBarHoverBrush = tabBarHoverBrush; m_TabWidgetParameters.tabBarClickBrush = tabBarClickBrush; @@ -3077,6 +3611,8 @@ void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const m_TabWidgetParameters.tabBarHoverPen = tabBarHoverPen; m_TabWidgetParameters.tabBarClickPen = tabBarClickPen; m_TabWidgetParameters.tabBarFocusPen = tabBarFocusPen; + + m_TabWidgetParameters.tabBarDividerPen = tabBarDividerPen; } void UKUIConfigStyleParameters::getDefaultTabWidgetParameters(ConfigTabWidgetParameters *p, bool isDark) @@ -3094,25 +3630,53 @@ void UKUIConfigStyleParameters::getDefaultTabWidgetParameters(ConfigTabWidgetPar p->tabBarHoverPen = m_TabWidgetParameters.tabBarHoverPen ; p->tabBarClickPen = m_TabWidgetParameters.tabBarClickPen ; p->tabBarFocusPen = m_TabWidgetParameters.tabBarFocusPen ; + p->tabBarDividerPen = m_TabWidgetParameters.tabBarDividerPen ; } void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget) { + bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Menu]; + m_MenuParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Menu]); + bool ishighlightMode = false; - int frameradius = m_dtconfig->kradiusMenu(); + int frameradius = m_dtconfig->kradiusMenu();//整个菜单的圆角 - int itemradius = m_dtconfig->kradiusNormal(); - QBrush itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + int itemradius = m_dtconfig->kradiusNormal();//被选择的item区域圆角 - QBrush menuBackgroundPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()); + //menu被选中item区域的背景色 + QBrush itemSelectBrush; + QBrush itemClickBrush; + + + if (widget && widget->property("needTranslucent").isValid()) { + needTranslucent = widget->property("needTranslucent").toBool(); + } + + if (needTranslucent) { + itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover()); + itemClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick()); + } else { + itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover()); + itemClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()); + } + + //被选中item中文本的颜色 QBrush menuHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary()); - QBrush menuItemFocusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()); + QBrush menuItemFocusPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()); + + QBrush menuItemShortCutBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPlaceholdertext()); + + //整个menu外框颜色 + QBrush menuBackgroundPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()); QPen menuBackgroundPen = QPen(menuBackgroundPenBrush, (menuBackgroundPenBrush.style() == Qt::NoBrush || menuBackgroundPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen menuHoverPen = QPen(menuHoverPenBrush, (menuHoverPenBrush.style() == Qt::NoBrush || menuHoverPenBrush.color().alpha() == 0) ? 0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen menuItemShortCutPen = QPen(menuItemShortCutBrush, (menuItemShortCutBrush.style() == Qt::NoBrush || menuItemShortCutBrush.color().alpha() == 0) ? 0 : 1, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + QPen menuItemFocusPen = QPen(menuItemFocusPenBrush, (menuItemFocusPenBrush.style() == Qt::NoBrush || menuItemFocusPenBrush.color().alpha() == 0) ? 0 : 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -3131,12 +3695,18 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty if (widget->property("useSystemStyleBlur").isValid() && !widget->property("useSystemStyleBlur").toBool()) { color.setAlphaF(1); } + if(widget->property("highlightMode").isValid()){ + ishighlightMode = widget->property("highlightMode").toBool(); + } } //if blur effect is not supported, do not use transparent color. - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) { + if (!m_isHardwareRendering/*!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)*/ || blackAppListWithBlurHelper().contains(qAppName())) { color.setAlphaF(1); } QBrush menuBackgroundBrush = color; + if(ishighlightMode){ + itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive()); + } auto *w = const_cast(widget); if (w) { @@ -3145,8 +3715,10 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty w->setProperty("menuBackgroundBrush", menuBackgroundBrush); w->setProperty("menuBackgroundPen", menuBackgroundPen); w->setProperty("itemSelectBrush", itemSelectBrush); + w->setProperty("itemClickBrush", itemClickBrush); w->setProperty("menuHoverPen", menuHoverPen); w->setProperty("itemFocusPen", menuItemFocusPen); + w->setProperty("menuItemShortCutPen", menuItemShortCutPen); } if (widget) { @@ -3157,13 +3729,16 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty itemradius = widget->property("setItemRadius").value(); } if (widget->property("setItemSelectBrush").isValid() && widget->property("setItemSelectBrush").canConvert()) { - itemSelectBrush = widget->property("setItemSelectBrush").value(); + itemSelectBrush = parseBrush(option ? option->rect : QRect(), widget->property("setItemSelectBrush").value()); + } + if (widget->property("setItemClickBrush").isValid() && widget->property("setItemClickBrush").canConvert()) { + itemClickBrush = parseBrush(option ? option->rect : QRect(), widget->property("setItemClickBrush").value()); } if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert()) { menuHoverPen = widget->property("setTextHoverPen").value(); } if (widget->property("setMenuBackgroundBrush").isValid() && widget->property("setMenuBackgroundBrush").canConvert()) { - menuBackgroundBrush = widget->property("setMenuBackgroundBrush").value(); + menuBackgroundBrush = parseBrush(option ? option->rect : QRect(), widget->property("setMenuBackgroundBrush").value()); } if (widget->property("setMenuBackgroundPen").isValid() && widget->property("setMenuBackgroundPen").canConvert()) { menuBackgroundPen = widget->property("setMenuBackgroundPen").value(); @@ -3171,6 +3746,9 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty if (widget->property("setItemFocusPen").isValid() && widget->property("setItemFocusPen").canConvert()) { menuItemFocusPen = widget->property("setItemFocusPen").value(); } + if (widget->property("setMenuItemShortCutPen").isValid() && widget->property("setMenuItemShortCutPen").canConvert()) { + menuItemFocusPen = widget->property("setMenuItemShortCutPen").value(); + } } m_MenuParameters.frameRadius = frameradius; @@ -3178,8 +3756,10 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty m_MenuParameters.menuBackgroundBrush = menuBackgroundBrush; m_MenuParameters.menuBackgroundPen = menuBackgroundPen; m_MenuParameters.menuItemSelectBrush = itemSelectBrush; + m_MenuParameters.menuItemClickBrush = itemClickBrush; m_MenuParameters.menuItemFocusPen = menuItemFocusPen; m_MenuParameters.menuTextHoverPen = menuHoverPen; + m_MenuParameters.menuItemShortCutPen = menuItemShortCutPen; } void UKUIConfigStyleParameters::getDefaultMenuParameters(ConfigMenuParameters *p, bool isDark) @@ -3190,6 +3770,8 @@ void UKUIConfigStyleParameters::getDefaultMenuParameters(ConfigMenuParameters *p p->menuBackgroundBrush = m_MenuParameters.menuBackgroundBrush; p->menuBackgroundPen = m_MenuParameters.menuBackgroundPen ; p->menuItemSelectBrush = m_MenuParameters.menuItemSelectBrush; + p->menuItemClickBrush = m_MenuParameters.menuItemClickBrush; p->menuItemFocusPen = m_MenuParameters.menuItemFocusPen ; p->menuTextHoverPen = m_MenuParameters.menuTextHoverPen ; + p->menuItemShortCutPen = m_MenuParameters.menuItemShortCutPen; } diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h index 240784a..a916dcb 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "widget-parameters/config-pushbutton-parameters.h" #include "widget-parameters/config-toolbutton-parameters.h" @@ -45,14 +47,45 @@ #include "widget-parameters/config-menu-parameters.h" #include "../readconfig.h" + using namespace UKUIGlobalDTConfig; namespace UKUIConfigStyleSpace { class UKUIConfigStyleParameters: public QObject { Q_OBJECT +private: + //用于控制是否开启 半透明,focus外框绘制 + enum class StyleCtrlElement { + PushButtonBevel = 0, + PushButtonLabel, + ToolButtonPanel, + ToolButtonLabel, + LineEdit, + SpinBox, + ComboBox, + List, + Tree, + Table, + CheckBox, + RadioButton, + Slider, + ProgressBar, + ScrollBar, + Tooltip, + TabWidget, + Menu, + ElementsCount //18,共19个组件 + }; + + QBitArray TransparencyUsage;//用于控制是否开启 半透明 + QBitArray FocusUsage;//用于控制是否开启 focus状态的绘制 + +public: + void initElemsDefaultStyleStrategy(); + public: - UKUIConfigStyleParameters(QObject *parent, bool isDark, QString cfgName = ""); + UKUIConfigStyleParameters(QObject *parent, bool isDark, QString cfgName = "", bool isHardwareRendering = true); ~UKUIConfigStyleParameters(); enum SpinBoxControlLayout { @@ -147,6 +180,8 @@ public: QBrush parseBrush(QRect rect, QBrush dtBrush); + void initHeaderViewStyle();//初始化HeaderView相关参数 + public: UKUIGlobalDTConfig::GlobalDTConfig *m_dtconfig; @@ -181,7 +216,7 @@ public: int Button_IconSize = 16; int Button_IndicatorSize = 16; int Button_DefaultIndicatorSize = 0; - int Button_DefaultWidth = 96; + int Button_DefaultWidth = 88; int Button_DefaultHeight = 36; int Button_DefaultHeight_origin = 36; int ToolButton_DefaultWidth = 60; @@ -199,10 +234,10 @@ public: QColor Indicator_IconDisable; // menu - int Menu_MarginHeight = 4; - int Menu_Combobox_Popup_MarginHeight = 4; + int Menu_MarginHeight = 8; + int Menu_Combobox_Popup_MarginHeight = 8; int Menu_MarginWidth = Menu_MarginHeight; - int Menu_Combobox_Popup_MarginWidth = Menu_MarginHeight; + int Menu_Combobox_Popup_MarginWidth = 8; int Menu_MarginPanelWidth = 0; int MenuItem_Spacing = 8; int MenuItem_HMargin = 8; @@ -224,17 +259,22 @@ public: int ScroolBar_Width_origin = 16; int ScroolBar_Height = 68; int ScroolBar_LineLength = 16; - bool ScrooBar_ShowLine = false; + bool ScrooBar_ShowLine = false;//多个scrollbar对象公用这同一个属性 // progressbar int ProgressBar_DefaultLength = 388; int ProgressBar_DefaultThick = 16; // slider + // defaultLength slider整体矩形作用域宽度 int Slider_DefaultLength = 94; int Slider_DefaultLength_origin = 94; int Slider_DefaultWidth = 34; int Slider_DefaultWidth_origin = 34; + + // int sliderHandleRadiusNormal = 8; + // int sliderHandleRadiusHover = 10; + int Slider_Length = 20; int Slider_Length_origin = 20; int Slider_Thickness = 20; @@ -242,7 +282,7 @@ public: int Slider_GrooveLength = 4; int Slider_GrooveLength_origin = 4; - int Slider_Margin = 2; + int Slider_Margin = 6; // radiobutton int ExclusiveIndicator_Width = 16; @@ -285,11 +325,15 @@ public: int TabBar_DefaultHeight = 42; int TabBar_DefaultHeight_origin = 40; int TabBar_ScrollButtonWidth = 16; - int TabBar_ScrollButtonOverlap = 2; + int TabBar_ScrollButtonOverlap = 0; bool TabBar_SplitLine = true; + //TabBar中多个Tab之间的分割线的参数 + int TabBar_SplitLine_Height = 16; + // int TabBar_SplitLine_Width = 1; + // tooltip - int ToolTip_DefaultMargin = 10; + int ToolTip_DefaultMargin = 7; int ToolTip_Height = 36; int ToolTip_Height_origin = 36; @@ -304,6 +348,7 @@ public: float m_scaleRatio4_3 = 1.0; float m_scaleRatio3_2 = 1.0; float m_scaleRatio2_1 = 1.0; + float m_slider_handle_scaleRatio = 0.8f; int m_headerDefaultSectionSizeVertical = 36; int m_headerDefaultSectionSizeVertical1_1 = 36; @@ -316,16 +361,19 @@ public: float m_ScaleLineEditDefaultLength = 1.0; float m_scaleTabBarHeight6_5 = 1.0; - bool indicatorIconHoverNeedHighLight = true; - QPalette defaultPalette; + //QHeaderView + int Line_Height = 14; + QPen m_verticalDividerLinePen = Qt::NoPen; + private: int m_spinBoxControlLayout = SpinBoxControlLayout::Vertical; QString m_styleName = "ukui-light"; QString m_widgetThemeName = "default"; QString m_themeColor = "default"; QPalette m_default_palette; + bool m_isHardwareRendering = true; }; } diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp b/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp index cb6183d..87ce4ac 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include "animations/config-tab-widget-animation-helper.h" #include "animations/config-scrollbar-animation-helper.h" @@ -61,7 +60,7 @@ #include "ukui-config-style-parameters.h" #include "settings/black-list.h" - +#include "ukuiwindowhelper.h" #include #include @@ -112,6 +111,9 @@ #include #include + +#define RADIOBUTTON_OFFHOVER_USAGE 0 + // #define LOG_ENABLED #ifdef LOG_ENABLED #define ANIMATION_LOG(str) qDebug() << str @@ -168,7 +170,18 @@ UKUIConfigStyle::UKUIConfigStyle(bool dark, bool useDefault, QString type) : QPr qWarning("org.ukui.style is null!"); } - m_blur_helper = new BlurHelper(this); + m_wlcomDBus = new QDBusInterface("com.kylin.Wlcom", + "/com/kylin/Wlcom/Renderer", + "com.kylin.Wlcom.Renderer", + QDBusConnection::sessionBus()); + if(m_wlcomDBus->isValid()){ + QDBusReply isRenderingReply = m_wlcomDBus->call("IsHardwareRendering"); + if (isRenderingReply.isValid()) { + bool isRendering = isRenderingReply.value(); + m_isHardwareRendering = isRendering; + } + } + m_blur_helper = new BlurHelper(this, m_isHardwareRendering); // m_gesture_helper = new GestureHelper(this); @@ -259,23 +272,24 @@ UKUIConfigStyle::UKUIConfigStyle(bool dark, bool useDefault, QString type) : QPr m_tree_animation_helper = new ConfigTreeAnimationHelper(this); //dbus - m_statusManagerDBus = new QDBusInterface(DBUS_STATUS_MANAGER_IF, "/" ,DBUS_STATUS_MANAGER_IF,QDBusConnection::sessionBus(),this); - if (m_statusManagerDBus) { - QDBusReply message_a = m_statusManagerDBus->call("get_current_tabletmode"); - if (message_a.isValid()) { - m_is_tablet_mode = message_a.value(); - } +// m_statusManagerDBus = new QDBusInterface(DBUS_STATUS_MANAGER_IF, "/" ,DBUS_STATUS_MANAGER_IF,QDBusConnection::sessionBus(),this); +// if (m_statusManagerDBus) { +// QDBusReply message_a = m_statusManagerDBus->call("get_current_tabletmode"); +// if (message_a.isValid()) { +// m_is_tablet_mode = message_a.value(); +// } - if (m_statusManagerDBus->isValid()) { - //平板模式切换 - connect(m_statusManagerDBus, SIGNAL(mode_change_signal(bool)), this, SLOT(updateTabletModeValue(bool))); - } - } +// if (m_statusManagerDBus->isValid()) { +// //平板模式切换 +// connect(m_statusManagerDBus, SIGNAL(mode_change_signal(bool)), this, SLOT(updateTabletModeValue(bool))); +// } +// } if(m_widget_theme == "") m_widget_theme == "default"; - sp = new UKUIConfigStyleParameters(this, isUseDarkPalette(), m_widget_theme); + sp = new UKUIConfigStyleParameters(this, isUseDarkPalette(), m_widget_theme, m_isHardwareRendering); + } UKUIConfigStyle::~UKUIConfigStyle() @@ -312,9 +326,9 @@ UKUIConfigStyle::~UKUIConfigStyle() m_shadow_helper->deleteLater(); m_shadow_helper = nullptr; } - if(m_statusManagerDBus){ - m_statusManagerDBus->deleteLater(); - m_statusManagerDBus = nullptr; + if(m_wlcomDBus){ + m_wlcomDBus->deleteLater(); + m_wlcomDBus = nullptr; } if(sp){ sp->deleteLater(); @@ -355,6 +369,34 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e) return true; } + //处理QMenu特殊情况下(子菜单位于主菜单左侧),它们的间距 + if (e->type() == QEvent::Show && qobject_cast(obj)) { + auto* curMenu = static_cast(obj); + auto* parentMenu = qobject_cast(curMenu->parent()); + + if (!parentMenu) { + QList associateWigs = curMenu->menuAction()->associatedWidgets(); + QWidget* parentWig = associateWigs.size() >= 1 ? associateWigs[0] : nullptr; + parentMenu = qobject_cast(parentWig); + } + + if (!parentMenu) { + return false; + } + + QRect parentItemRect = parentMenu->actionGeometry(parentMenu->activeAction());//主菜单,选中的那一项 的矩形区域 + QPoint parentTopLeft = parentMenu->mapToGlobal(parentItemRect.topLeft());//转为全局坐标(屏幕) + + // qDebug() << "QMenu: curMenu->geometry().right() = " << curMenu->geometry().right() << ",parent.x() = " << parentTopLeft.x(); + + // 子菜单在左,右菜单在右的特殊情况,才需要子菜单左移 + if (curMenu->geometry().right() <= parentTopLeft.x()) { + int gap = 8; + curMenu->move(curMenu->x() - gap, curMenu->y()); + } + } + + // //button animation cancel temporary // if (qobject_cast(obj) || qobject_cast(obj)) { // if (e->type() == QEvent::Hide) { @@ -383,128 +425,129 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e) if (e->type() == QEvent::Wheel) { if (QWidget *w = qobject_cast(obj)) { if (!w->hasFocus()) { - return true; + return true;//2503返回的true } } } - auto mousePressEvent = static_cast(e); - - if((e->type() ==QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) && (proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button() || - proxy()->styleHint(QStyle::SH_Slider_PageSetButtons) == mousePressEvent->button())){ - aSliderDebug << "e->type:" << e->type() << mousePressEvent->button(); - if(obj->property("animation").isValid() && !obj->property("animation").toBool()) - return false; - - auto *slider = qobject_cast(obj); - if(slider == nullptr || !slider->isEnabled()) - return false; - - auto animator = m_slider_animation_helper->animator(slider); - if(!animator) - return false; - - const bool horizontal = slider->orientation() == Qt::Horizontal; - - aSliderDebug << "MouseButtonPress............"; - QRect handleRect = sliderHandleRec(slider); - if(horizontal){ - aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x(); + //fix bug#369331 多个动效同时update的时候 可能上一个绘制还没结束 下一个就进来了导致崩溃 暂时注释 +// auto mousePressEvent = static_cast(e); - if(mousePressEvent->pos().x() <= handleRect.x()){ - animator->setExtraProperty("addValue", false); +// if((e->type() ==QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) && (proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button() || +// proxy()->styleHint(QStyle::SH_Slider_PageSetButtons) == mousePressEvent->button())){ +// aSliderDebug << "e->type:" << e->type() << mousePressEvent->button(); +// if(obj->property("animation").isValid() && !obj->property("animation").toBool()) +// return false; - } - else if(mousePressEvent->pos().x() >= handleRect.x() + handleRect.width()){ - animator->setExtraProperty("addValue", true); - } - else - return false; - } - else{ - aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().y() << handleRect.y(); - if(mousePressEvent->pos().y() <= handleRect.y()){ - animator->setExtraProperty("addValue", true); +// auto *slider = qobject_cast(obj); +// if(slider == nullptr || !slider->isEnabled()) +// return false; - } - else if(mousePressEvent->pos().y() >= handleRect.y() + handleRect.height()){ - animator->setExtraProperty("addValue", false); - } - else - return false; - } +// auto animator = m_slider_animation_helper->animator(slider); +// if(!animator) +// return false; - if(!animator->isRunning("move_position")){ - int startPosition = slider->value();//scrollbar->sliderPosition();//sliderPositionFromValue(bar->minimum, bar->maximum, scrollBar->value(), maxlen - sliderlen, bar->upsideDown); - if(startPosition <= slider->maximum() && startPosition >= slider->minimum()){ - if(animator->value("move_position") != 1.0){ - if(animator->getExtraProperty("addValue").isValid()){ - aSliderDebug << "pagestep..." << slider->pageStep() << animator->getExtraProperty("addValue").toBool(); - int step = (animator->getExtraProperty("addValue").toBool() ? 1 : -1) * slider->pageStep(); - aSliderDebug << "step............" << step; - bool absoluteButton = proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button(); - if(absoluteButton) - { - QStyleOptionSlider *opt = new QStyleOptionSlider(); - opt->init(slider); +// const bool horizontal = slider->orientation() == Qt::Horizontal; - QRect gr = proxy()->subControlRect(QStyle::CC_Slider, opt, QStyle::SC_SliderGroove, slider); - QRect sr = proxy()->subControlRect(QStyle::CC_Slider, opt, QStyle::SC_SliderHandle, slider); - int sliderMin, sliderMax, sliderLength; - QPoint center = sr.center() - sr.topLeft(); - int pos; +// aSliderDebug << "MouseButtonPress............"; +// QRect handleRect = sliderHandleRec(slider); +// if(horizontal){ +// aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x(); - if (slider->orientation() == Qt::Horizontal) { - sliderLength = sr.width(); - sliderMin = gr.x(); - sliderMax = gr.right() - sliderLength + 1; - pos = (mousePressEvent->pos() - center).x(); - aSliderDebug << "Horizontal pos....:" << mousePressEvent->pos() << center << pos; - } else { - sliderLength = sr.height(); - sliderMin = gr.y(); - sliderMax = gr.bottom() - sliderLength + 1; - pos = (mousePressEvent->pos() - center).y(); - aSliderDebug << "vertical pos....:" << mousePressEvent->pos() << center << pos; - } - aSliderDebug << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos << opt->upsideDown; - bool upsideDown = (slider->orientation() == Qt::Horizontal) ? - (slider->invertedAppearance() != (slider->layoutDirection() == Qt::RightToLeft)) - : (!slider->invertedAppearance()); - int sliderValue = sliderValueFromPosition(slider->minimum(), slider->maximum(), pos - sliderMin, sliderMax - sliderMin, upsideDown);//opt->upsideDown); - aSliderDebug << "sliderValue....." << sliderValue << slider->value(); - step = sliderValue - slider->value(); - aSliderDebug << "step0000...." << step; - aSliderDebug << "addValue........." << animator->getExtraProperty("addValue"); - } - animator->startAnimator("move_position"); +// if(mousePressEvent->pos().x() <= handleRect.x()){ +// animator->setExtraProperty("addValue", false); - int endPos = (startPosition + step) - (absoluteButton ? 0 : (startPosition + step)%step); - aSliderDebug << "endPos0000....." << endPos; - if(!animator->getExtraProperty("addValue").toBool()) - endPos = (startPosition + step) + (absoluteButton ? 0 : (((startPosition + step)%step > 0) ?(qAbs(step) - (startPosition + step)%step) : 0)); - aSliderDebug << "endPos1111....." << endPos; +// } +// else if(mousePressEvent->pos().x() >= handleRect.x() + handleRect.width()){ +// animator->setExtraProperty("addValue", true); +// } +// else +// return false; +// } +// else{ +// aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().y() << handleRect.y(); +// if(mousePressEvent->pos().y() <= handleRect.y()){ +// animator->setExtraProperty("addValue", true); - if(animator->getExtraProperty("addValue").toBool()) - endPos = qMin(endPos, slider->maximum()); - else - endPos = qMax(endPos, slider->minimum()); - aSliderDebug << "endPos....." << endPos; - animator->setExtraProperty("end_position", endPos); - animator->setExtraProperty("start_position", startPosition); +// } +// else if(mousePressEvent->pos().y() >= handleRect.y() + handleRect.height()){ +// animator->setExtraProperty("addValue", false); +// } +// else +// return false; +// } -// qApp->sendEvent(slider, e); - slider->setFocus(); - return true; - } - } - } - } - else{ - slider->setFocus(); - return true; - } - return false; - } +// if(!animator->isRunning("move_position")){ +// int startPosition = slider->value();//scrollbar->sliderPosition();//sliderPositionFromValue(bar->minimum, bar->maximum, scrollBar->value(), maxlen - sliderlen, bar->upsideDown); +// if(startPosition <= slider->maximum() && startPosition >= slider->minimum()){ +// if(animator->value("move_position") != 1.0){ +// if(animator->getExtraProperty("addValue").isValid()){ +// aSliderDebug << "pagestep..." << slider->pageStep() << animator->getExtraProperty("addValue").toBool(); +// int step = (animator->getExtraProperty("addValue").toBool() ? 1 : -1) * slider->pageStep(); +// aSliderDebug << "step............" << step; +// bool absoluteButton = proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button(); +// if(absoluteButton) +// { +// QStyleOptionSlider *opt = new QStyleOptionSlider(); +// opt->init(slider); + +// QRect gr = proxy()->subControlRect(QStyle::CC_Slider, opt, QStyle::SC_SliderGroove, slider); +// QRect sr = proxy()->subControlRect(QStyle::CC_Slider, opt, QStyle::SC_SliderHandle, slider); +// int sliderMin, sliderMax, sliderLength; +// QPoint center = sr.center() - sr.topLeft(); +// int pos; + +// if (slider->orientation() == Qt::Horizontal) { +// sliderLength = sr.width(); +// sliderMin = gr.x(); +// sliderMax = gr.right() - sliderLength + 1; +// pos = (mousePressEvent->pos() - center).x(); +// aSliderDebug << "Horizontal pos....:" << mousePressEvent->pos() << center << pos; +// } else { +// sliderLength = sr.height(); +// sliderMin = gr.y(); +// sliderMax = gr.bottom() - sliderLength + 1; +// pos = (mousePressEvent->pos() - center).y(); +// aSliderDebug << "vertical pos....:" << mousePressEvent->pos() << center << pos; +// } +// aSliderDebug << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos << opt->upsideDown; +// bool upsideDown = (slider->orientation() == Qt::Horizontal) ? +// (slider->invertedAppearance() != (slider->layoutDirection() == Qt::RightToLeft)) +// : (!slider->invertedAppearance()); +// int sliderValue = sliderValueFromPosition(slider->minimum(), slider->maximum(), pos - sliderMin, sliderMax - sliderMin, upsideDown);//opt->upsideDown); +// aSliderDebug << "sliderValue....." << sliderValue << slider->value(); +// step = sliderValue - slider->value(); +// aSliderDebug << "step0000...." << step; +// aSliderDebug << "addValue........." << animator->getExtraProperty("addValue"); +// } +// animator->startAnimator("move_position"); + +// int endPos = (startPosition + step) - (absoluteButton ? 0 : (startPosition + step)%step); +// aSliderDebug << "endPos0000....." << endPos; +// if(!animator->getExtraProperty("addValue").toBool()) +// endPos = (startPosition + step) + (absoluteButton ? 0 : (((startPosition + step)%step > 0) ?(qAbs(step) - (startPosition + step)%step) : 0)); +// aSliderDebug << "endPos1111....." << endPos; + +// if(animator->getExtraProperty("addValue").toBool()) +// endPos = qMin(endPos, slider->maximum()); +// else +// endPos = qMax(endPos, slider->minimum()); +// aSliderDebug << "endPos....." << endPos; +// animator->setExtraProperty("end_position", endPos); +// animator->setExtraProperty("start_position", startPosition); + +//// qApp->sendEvent(slider, e); +// slider->setFocus(); +// return false; +// } +// } +// } +// } +// else{ +// slider->setFocus(); +// return false; +// } +// return false; +// } } @@ -628,13 +671,13 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e) animator->setExtraProperty("start_position", startPosition); // qApp->sendEvent(scrollbar, e); - return true; + return false; } } } } else - return true; + return false; return false; @@ -715,11 +758,12 @@ int UKUIConfigStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *optio case SH_BlinkCursorWhenTextSelected: { return m_blink_cursor; } - case SH_TabBar_Alignment: { - if (widget && widget->layoutDirection() == Qt::RightToLeft) - return Qt::AlignRight; - return Qt::AlignLeft; - } + ///openkylin Isuue#I9JXTS 网络哈维科语音显示有问题 v11网络界面重构了 先注释掉 +// case SH_TabBar_Alignment: { +// if (widget && widget->layoutDirection() == Qt::RightToLeft) +// return Qt::AlignRight; +// return Qt::AlignLeft; +// } default: break; } @@ -800,15 +844,28 @@ QPalette UKUIConfigStyle::standardPalette() const bool UKUIConfigStyle::isUseDarkPalette() const { - bool usedark = (!useDefaultPaletteList().contains(qAppName()) && (m_drak_palette || (m_default_palette && useDarkPaletteList().contains(qAppName())))); - - if (qAppName() == "ukui-screensaver-dialog") { - usedark = false; - } + bool usedark = (!useLightPaletteList().contains(qAppName()) && (m_drak_palette || (m_default_palette && useDarkPaletteList().contains(qAppName())))); return usedark; } + +// 基色 值 = 255 +// colorVal = 混合色值(r,g,b) +void UKUIConfigStyle::calculateHighColor(int& colorVal) const { + // if(colorVal > 128) + // return 255 - 1.0 * (255 - colorVal) * (255 - 255) / 128.0; + // else + // return 1.0 * colorVal * 255 / 128.0; + + if(colorVal > 128) + colorVal = 255; + else + colorVal = colorVal * 255 / 128; +} + + + QColor UKUIConfigStyle::button_Click(const QStyleOption *option) const { QColor button = option->palette.color(QPalette::Active, QPalette::Button); @@ -967,7 +1024,7 @@ void UKUIConfigStyle::polish(QWidget *widget) realSetWindowSurfaceFormatAlpha(widget); - if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget && widget->inherits("QMenu"))) { + // if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget && widget->inherits("QMenu"))) { if (widget && widget->testAttribute(Qt::WA_TranslucentBackground) && widget->isTopLevel()) { //FIXME: #if (QT_VERSION >= QT_VERSION_CHECK(5,12,0)) @@ -983,22 +1040,38 @@ void UKUIConfigStyle::polish(QWidget *widget) */ } - if (widget && widget->isWindow()) { - auto var = widget->property("useStyleWindowManager"); + // if (widget && widget->isWindow()) { + // auto var = widget->property("useStyleWindowManager"); - if (var.isNull()) { - m_window_manager->registerWidget(widget); - } else { - if (var.toBool()) { - m_window_manager->registerWidget(widget); - } - } + // if (var.isNull()) { + // m_window_manager->registerWidget(widget); + // } else { + // if (var.toBool()) { + // m_window_manager->registerWidget(widget); + // } + // } + // } + + if (widget->isWindow()) { + m_window_manager->registerWidget(widget); } - } + + + + + // } Style::polish(widget); - m_shadow_helper->registerWidget(widget); + // m_shadow_helper->registerWidget(widget); + if (widget && (widget->inherits("QMenu") || widget->inherits("QTipLabel") || widget->inherits("QComboBoxPrivateContainer")) && widget->isWindow()) { + //menu shadow, radius. + UkuiWindowHelper *windowHelper = new UkuiWindowHelper(widget); + windowHelper->setDecorationCompoents(UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::Shadow) | + UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::Border) | + UkuiWindowHelper::DecorationComponents(UkuiWindowHelper::DecorationComponent::RoundCorner)); + + } if (qobject_cast(widget)) { //FIXME: unpolish, extensiable. @@ -1105,11 +1178,20 @@ void UKUIConfigStyle::polish(QWidget *widget) if (widget->isEnabled()) subOption.state |= State_Enabled; for (QAction *act : widget->findChildren()) { - act->setIcon(QIcon(HighLightEffect::ordinaryGeneratePixmap(act->icon().pixmap(16, 16), &subOption, widget, HighLightEffect::BothDefaultAndHighlit))); + act->setIcon(QIcon(HighLightEffect::ordinaryGeneratePixmap(act->icon().pixmap(64, 64), &subOption, widget, HighLightEffect::BothDefaultAndHighlit))); } } } + //为QLabel设置独立的色板 + if(qobject_cast(widget)) + { +// widget->setBackgroundRole(QPalette::Base) + if(widget && (!widget->property("isWindowLabel").isValid() || (widget->property("isWindowLabel").isValid() && !widget->property("isWindowLabel").toBool()))) + widget->setForegroundRole(QPalette::Text); + } + + if(qobject_cast(widget)) { auto tableView = qobject_cast(widget); @@ -1231,22 +1313,29 @@ void UKUIConfigStyle::unpolish(QWidget *widget) m_blur_helper->unregisterWidget(widget); #endif } - if (widget && widget->isWindow()) { - auto var = widget->property("useStyleWindowManager"); - if (var.isNull()) { - m_window_manager->unregisterWidget(widget); - } else { - if (var.toBool()) { - m_window_manager->unregisterWidget(widget); - } - } + // if (widget && widget->isWindow()) { + // auto var = widget->property("useStyleWindowManager"); + + // if (var.isNull()) { + // m_window_manager->unregisterWidget(widget); + // } else { + // if (var.toBool()) { + // m_window_manager->unregisterWidget(widget); + // } + // } + // } + + if (widget->isWindow()) { + m_window_manager->unregisterWidget(widget); } + + } if(!widget) return; - m_shadow_helper->unregisterWidget(widget); + // m_shadow_helper->unregisterWidget(widget); widget->removeEventFilter(this); @@ -1366,18 +1455,31 @@ static inline uint qt_intensity(uint r, uint g, uint b) return (77 * r + 150 * g + 28 * b) / 255; } + /*! \reimp */ QPixmap UKUIConfigStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const { switch (iconMode) { case QIcon::Disabled: { - QStyleOption tmp = *option; - tmp.state = State_Enabled; - QPixmap target = HighLightEffect::ordinaryGeneratePixmap(pixmap, &tmp); + // QStyleOption tmp = *option; + // tmp.state = State_Enabled; + // QPixmap target = HighLightEffect::ordinaryGeneratePixmap(pixmap, &tmp); + QPixmap target = pixmap; // //Fix me:QT original code QImage im = target.toImage().convertToFormat(QImage::Format_ARGB32); + for (int y = 0; y < im.height(); y++) { + QRgb* scanLine = reinterpret_cast(im.scanLine(y)); + for (int x = 0; x < im.width(); x++) { + QRgb pixel = scanLine[x];//当前像素点 (r,g,b,a) + int curAlpha = qAlpha(pixel);//0-255整数值 + scanLine[x] = qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel), int(curAlpha * 0.45));//给当前像素点赋新值 + } + } + return QPixmap::fromImage(im); + + // Create a colortable based on the background (black -> bg -> white) QColor bg = option->palette.color(QPalette::Disabled, QPalette::ButtonText); int red = bg.red(); @@ -1420,7 +1522,7 @@ QPixmap UKUIConfigStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap int r = int(reds[ci]); int g = int(greens[ci]); int b = int(blues[ci]); - int a = qAlpha(pixel)/255.0 > 0.7 ? 0.7 * 255 : qAlpha(pixel); + int a = qAlpha(pixel)/255.0 > 0.7 ? 0.7 * 255 : qAlpha(pixel);//透明度幅度变化方式 if(isPureColor){ r = qMax(int(reds[ci]), bg.red()); g = qMax(int(greens[ci]), bg.green()); @@ -1431,7 +1533,6 @@ QPixmap UKUIConfigStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap ++scanLine; } } - return QPixmap::fromImage(im); @@ -1455,7 +1556,6 @@ QPixmap UKUIConfigStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap return Style::generatedIconPixmap(iconMode, pixmap, option); } - QPixmap UKUIConfigStyle::testGeneratedSVGPixmap(QPixmap pixmap) const { QImage im = pixmap.toImage(); @@ -1491,7 +1591,6 @@ QPixmap UKUIConfigStyle::testGeneratedSVGPixmap(QPixmap pixmap) const // return target; } - void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { switch (element) { @@ -1500,12 +1599,10 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty { sp->initConfigMenuParameters(isUseDarkPalette(), option, widget); painter->save(); - painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->setBrush(sp->m_MenuParameters.menuBackgroundBrush); - painter->setPen(sp->m_MenuParameters.menuBackgroundPen); - if(widget) - painter->drawRoundedRect(widget->rect(), sp->m_MenuParameters.frameRadius, sp->m_MenuParameters.frameRadius); + painter->setPen(Qt::NoPen); + painter->drawRect(option->rect); painter->restore(); if(sp->Menu_Right_Bottom_Corner){ @@ -1570,7 +1667,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->restore(); return; } - + //QPushButton主体部分绘制 case PE_PanelButtonCommand: { if (const QStyleOptionButton *button = qstyleoption_cast(option)) { @@ -1582,7 +1679,14 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty const bool focus = button->state & State_HasFocus; const bool active = button->state & State_Active; const bool inActive = (enable && !active); + const bool inactiveNormal = inActive && !(hover || sunken || on); // 新增:inactiveNormal状态处理(启用但不活动) + + bool isWindowButton = false; + bool isWindowColoseButton = false; bool roundButton = false; + + bool focusEnable = sp->m_PushButtonParameters.getFocusEnable(); + int width = 0; QRect rect = option->rect; @@ -1590,7 +1694,14 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if (widget && widget->property("isRoundButton").isValid()) { roundButton = widget->property("isRoundButton").toBool(); } - + if (widget && widget->property("isWindowButton").isValid()) { + if (widget->property("isWindowButton").toInt() == 0x01) { + isWindowButton = true; + } + if (widget->property("isWindowButton").toInt() == 0x02) { + isWindowColoseButton = true; + } + } painter->save(); if (!enable) { // if (animator) { @@ -1647,8 +1758,14 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } } } + if (inactiveNormal) { + if (isWindowButton || isWindowColoseButton) { + painter->setBrush(sp->m_PushButtonParameters.pushButtonInactiveBrush); + } + } + //focus - if (focus) { + if (focus && focusEnable) { width = sp->m_PushButtonParameters.pushButtonFocusPen.width(); painter->setPen(width <= 0 ? Qt::NoPen : sp->m_PushButtonParameters.pushButtonFocusPen); } @@ -1776,40 +1893,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty return; } - QStyleOption opt = *option; - - painter->save(); - painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPainterPath rectPath; - rectPath.addRoundedRect(option->rect.adjusted(+4, +4, -4, -4), sp->m_ToolTipParameters.radius, sp->m_ToolTipParameters.radius); - - // Draw a black floor - QPixmap pixmap(option->rect.size()); - pixmap.fill(Qt::transparent); - QPainter pixmapPainter(&pixmap); - pixmapPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - pixmapPainter.setPen(Qt::transparent); - pixmapPainter.setBrush(option->palette.color(QPalette::Active, QPalette::BrightText)); - pixmapPainter.drawPath(rectPath); - pixmapPainter.end(); - - // Blur the black background - QImage img = pixmap.toImage(); - qt_blurImage(img, 4, false, false); - - // Dig out the center part - pixmap = QPixmap::fromImage(img); - QPainter pixmapPainter2(&pixmap); - pixmapPainter2.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); - pixmapPainter2.setPen(Qt::transparent); - pixmapPainter2.setBrush(Qt::transparent); - pixmapPainter2.drawPath(rectPath); - - // Shadow rendering - painter->drawPixmap(option->rect, pixmap, pixmap.rect()); - - //This is the beginning of drawing the bottom of the prompt box auto color = sp->m_ToolTipParameters.toolTipBackgroundBrush.color(); if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0; @@ -1824,44 +1907,22 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } //if blur effect is not supported, do not use transparent color. - if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) { + if (!m_isHardwareRendering /*!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)*/ || blackAppListWithBlurHelper().contains(qAppName())) { color.setAlphaF(1); } - opt.palette.setColor(QPalette::ToolTipBase, color); + painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPen pen(opt.palette.toolTipBase().color().darker(150), 1); - pen.setCapStyle(Qt::RoundCap); - pen.setJoinStyle(Qt::RoundJoin); - painter->setPen(Qt::transparent); + painter->setPen(Qt::NoPen); painter->setBrush(color); - - QPainterPath path; - auto region = widget->mask(); - if (region.isEmpty()) { - path.addRoundedRect(opt.rect.adjusted(+4, +4, -4, -4), sp->m_ToolTipParameters.radius, sp->m_ToolTipParameters.radius); - } else { - path.addRegion(region); - } - - painter->drawPath(path); + painter->drawRect(option->rect); painter->restore(); + return; } break; } - case PE_FrameStatusBar://UKUI Status style - { - painter->save(); - painter->setRenderHint(QPainter::Antialiasing,true); - painter->setPen(Qt::NoPen); - painter->setBrush(option->palette.color(QPalette::Dark)); - painter->drawRect(option->rect); - painter->restore(); - return; - } - case PE_IndicatorButtonDropDown: //UKUI IndicatorButton style { painter->save(); @@ -1889,6 +1950,8 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty const bool on = option->state & State_On; const bool focus = option->state & State_HasFocus; bool roundButton = false; + + bool focusEnable = sp->m_ToolButtonParameters.getFocusEnable(); int width = 0; QRect rect = option->rect; @@ -1950,12 +2013,13 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } else { width = sp->m_ToolButtonParameters.toolButtonDefaultPen.width(); painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ToolButtonParameters.toolButtonDefaultPen); - painter->setBrush(sp->m_ToolButtonParameters.toolButtonDefaultBrush); + painter->setBrush(sp->m_ToolButtonParameters.toolButtonDefaultBrush);//ToolButton默认背景色 + } } } //focus - if (focus) { + if (focus && focusEnable) { width = sp->m_ToolButtonParameters.toolButtonFocusPen.width(); painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ToolButtonParameters.toolButtonFocusPen); } @@ -2049,19 +2113,26 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty case PE_IndicatorTabClose: { QIcon icon = QIcon::fromTheme("window-close-symbolic"); - QColor color = sp->Indicator_IconDefault; + painter->save(); + painter->setPen(Qt::NoPen); if (option->state & (State_On | State_Sunken)) { - color = sp->Indicator_IconSunken; + painter->setBrush(sp->m_TabWidgetParameters.tabBarIndicatorClickBrush); } else if (option->state & (State_MouseOver)) { - color = sp->Indicator_IconHover; + painter->setBrush(sp->m_TabWidgetParameters.tabBarIndicatorHoverBrush); } + else + painter->setBrush(Qt::NoBrush); + painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + painter->drawRoundedRect(option->rect, 6, 6); + painter->restore(); + if (!icon.isNull()) { int iconSize = proxy()->pixelMetric(QStyle::PM_SmallIconSize, option, widget); QPixmap pixmap = icon.pixmap(QSize(iconSize, iconSize), QIcon::Normal, QIcon::On); pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); painter->save(); - drawColorPixmap(painter, color, pixmap); +// drawColorPixmap(painter, color, pixmap); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); painter->restore(); @@ -2152,6 +2223,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->translate(0.5, 0.5); painter->setPen(sp->m_LineEditParameters.lineEditDisablePen); painter->setBrush(sp->m_LineEditParameters.lineEditDisableBrush); + painter->drawRoundedRect(option->rect.adjusted(((width%2) == 1 ? (width - 1)/2 : width/2), ((width%2) == 1 ? (width - 1)/2 : width/2), -1 * ((width%2) == 1 ? (width + 1)/2 : width/2), @@ -2171,13 +2243,14 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty // painter->restore(); // return; // } - + bool focusEnable = sp->m_LineEditParameters.getFocusEnable(); painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_LineEditParameters.radius != 0); - if (focus) { - width = sp->m_LineEditParameters.lineEditFocusPen.width(); + if (focus && focusEnable) { + width = sp->m_LineEditParameters.lineEditFocusPen.width();//lineEdit focus时的边框 宽度 painter->setPen(sp->m_LineEditParameters.lineEditFocusPen); painter->setBrush(sp->m_LineEditParameters.lineEditFocusBrush); +// qDebug() << "LineEdit focus pen 颜色 = " << sp->m_LineEditParameters.lineEditFocusPen.color().name(QColor::HexRgb) << ",pen宽度 = " << width;// "#3790fa" Kbrand-normal token } else if (hover) { width = sp->m_LineEditParameters.lineEditHoverPen.width(); painter->setPen(sp->m_LineEditParameters.lineEditHoverPen); @@ -2185,7 +2258,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } else { width = sp->m_LineEditParameters.lineEditDefaultPen.width(); painter->setPen(sp->m_LineEditParameters.lineEditDefaultPen); - painter->setBrush(sp->m_LineEditParameters.lineEditDefaultBrush); + painter->setBrush(sp->m_LineEditParameters.lineEditDefaultBrush);//QlineEdit默认背景色 } if(width == 1 && sp->m_LineEditParameters.radius != 0) painter->translate(0.5, 0.5); @@ -2195,17 +2268,20 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty -1 * ((width%2) == 1 ? (width + 1)/2 : width/2)), sp->m_LineEditParameters.radius, sp->m_LineEditParameters.radius); +// QRectF adjustedRect = QRectF(option->rect).adjusted(0.5,0.5,-0.5,-0.5); +// painter->drawRoundedRect(adjustedRect, sp->m_LineEditParameters.radius, sp->m_LineEditParameters.radius); + painter->restore(); return; } break; } - + //QSpinBox右侧箭头 case PE_IndicatorArrowUp: { QIcon icon = QIcon::fromTheme("ukui-up-symbolic"); - if(sp->m_isTableMode){ + if (sp->m_isTableMode) { if(qobject_cast(widget)) { icon = QIcon::fromTheme("list-add-symbolic"); @@ -2216,23 +2292,24 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } } - if(!icon.isNull()) { + if (!icon.isNull()) { int indWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); int indHight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); QSize iconsize(indWidth, indHight); QRect drawRect(option->rect.topLeft(), iconsize); drawRect.moveCenter(option->rect.center()); const bool enable(option->state & State_Enabled); - QIcon::Mode mode = enable ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + QIcon::Mode mode = QIcon::Normal;//enable ? QIcon::Normal : QIcon::Disabled; + + QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::On); QPixmap target; - if(widget != nullptr && (widget->inherits("QDoubleSpinBox") || widget->inherits("QSpinBox")) && !sp->m_SpinBoxParameters.spinBoxUpIconHightPixMap) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(!sp->indicatorIconHoverNeedHighLight) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else - target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + + if(!enable){ + mode = enable ? QIcon::Normal : QIcon::Disabled; + target = proxy()->generatedIconPixmap(mode, target, option); + + } painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->drawPixmap(drawRect, target); @@ -2266,13 +2343,10 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } } QIcon icon = QIcon::fromTheme("ukui-down-symbolic"); - if(sp->m_isTableMode){ - if(qobject_cast(widget)) - { + if (sp->m_isTableMode){ + if (qobject_cast(widget)) { icon = QIcon::fromTheme("list-remove-symbolic"); - } - else if(qobject_cast(widget)) - { + } else if (qobject_cast(widget)) { icon = QIcon::fromTheme("list-remove-symbolic"); } } @@ -2284,23 +2358,78 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty QRect drawRect(option->rect.topLeft(), iconsize); drawRect.moveCenter(option->rect.center()); const bool enable(option->state & State_Enabled); - QIcon::Mode mode = enable ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + QIcon::Mode mode = QIcon::Normal;//enable ? QIcon::Normal : QIcon::Disabled; + QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::On); QPixmap target; - if(widget != nullptr && (widget->inherits("QDoubleSpinBox") || widget->inherits("QSpinBox")) && !sp->m_SpinBoxParameters.spinBoxUpIconHightPixMap) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(!sp->indicatorIconHoverNeedHighLight) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget"))){ + + if (widget && (widget->inherits("QToolButton") || widget->inherits("QPushButton"))){ + const bool sunken = option->state & State_Sunken; + const bool hover = option->state & State_MouseOver; + const bool on = option->state & State_On; + const bool inactive = enable && !(option->state & State_Active); + const bool inactiveNormal = inactive && !(hover || sunken || on); + + bool isImportant = false; + if (widget && widget->property("isImportant").isValid()) { + isImportant = widget->property("isImportant").toBool(); + } + + if (widget && !widget->property("useIconHighlightEffect").isValid()) { + if ((widget->inherits("QToolButton") && !sp->m_ToolButtonParameters.iconHoverClickHighlight) || + (widget->inherits("QPushButton") && !sp->m_PushButtonParameters.iconHoverClickHighlight)) { + pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + } else { + pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + } + } else { + pixmap = HighLightEffect::generatePixmap(pixmap, option, widget); + } + } + + + if (widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget"))){ if(widget->property("highlightMode").isValid() && widget->property("highlightMode").toBool()) target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); else target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + } else{ + bool windowInactive = false; + if(widget && (widget->inherits("QToolButton") || widget->inherits("QPushButton"))){ + const bool sunken = option->state & State_Sunken; + const bool hover = option->state & State_MouseOver; + const bool on = option->state & State_On; + const bool inactive = enable && !(option->state & State_Active); + const bool inactiveNormal = inactive && !(hover || sunken || on); + + bool isImportant = false; + if (widget && widget->property("isImportant").isValid()) { + isImportant = widget->property("isImportant").toBool(); + } + bool isWindowButton = false; + bool isWindowColoseButton = false; + if (widget && widget->property("isWindowButton").isValid()) { + if (widget->property("isWindowButton").toInt() == 0x01) { + isWindowButton = true; + } + if (widget->property("isWindowButton").toInt() == 0x02) { + isWindowColoseButton = true; + } + } + if (inactiveNormal && (isWindowButton || isWindowColoseButton)){ + mode = QIcon::Disabled; + qDebug() << "inactive normallll" << widget->objectName(); + target = generatedIconPixmap(mode, pixmap, option); + windowInactive = true; + } + } + if(!windowInactive) + target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); } - else - target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + if(!enable){ + mode = enable ? QIcon::Normal : QIcon::Disabled; + target = proxy()->generatedIconPixmap(mode, target, option); + } painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if(startAnimation){ @@ -2350,31 +2479,29 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty QIcon icon = QIcon::fromTheme("ukui-end-symbolic"); - if(!icon.isNull()) { + if (!icon.isNull()) { int indWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); int indHight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); QSize iconsize(indWidth, indHight); QRect drawRect(option->rect.topLeft(), iconsize); drawRect.moveCenter(option->rect.center()); const bool enable(option->state & State_Enabled); - QIcon::Mode mode = enable ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + QIcon::Mode mode = QIcon::Normal;//enable ? QIcon::Normal : QIcon::Disabled; + QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::On); QPixmap target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); - if(widget && (widget->inherits("QDoubleSpinBox") || widget->inherits("QSpinBox")) && !sp->m_SpinBoxParameters.spinBoxUpIconHightPixMap) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(!sp->indicatorIconHoverNeedHighLight && widget && !widget->inherits("QMenu")) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget"))){ - if(widget->property("highlightMode").isValid() && widget->property("highlightMode").toBool()) + if (widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget"))){ + if (widget->property("highlightMode").isValid() && widget->property("highlightMode").toBool()) target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); else target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - } - else - target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + } else + target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + if(!enable){ + mode = enable ? QIcon::Normal : QIcon::Disabled; + target = proxy()->generatedIconPixmap(mode, target, option); + } painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if(startAnimation){ @@ -2410,12 +2537,13 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty QRect drawRect(option->rect.topLeft(), iconsize); drawRect.moveCenter(option->rect.center()); const bool enable(option->state & State_Enabled); - QIcon::Mode mode = enable ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); - QPixmap target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); - if(!sp->indicatorIconHoverNeedHighLight && widget && !widget->inherits("QMenu")) - target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + QIcon::Mode mode = QIcon::Normal;// enable ? QIcon::Normal : QIcon::Disabled; + QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::On); + QPixmap target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + if(!enable){ + mode = enable ? QIcon::Normal : QIcon::Disabled; + target = proxy()->generatedIconPixmap(mode, target, option); + } painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); painter->drawPixmap(drawRect, target); @@ -2436,70 +2564,67 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty bool sunKen = radiobutton->state & State_Sunken; bool on = radiobutton->state & State_On; + float innerRatio = 0.375f;//内圆直径占整体直径比例, 6, 16 + int innerWidth = innerRatio * (radiobutton->rect.width() - 1); + int innerHeight = innerWidth; + + bool focus = radiobutton->state & State_HasFocus; + bool focusEnable = sp->m_RadioButtonParameters.getFocusEnable(); + + bool needFocus = focus && focusEnable; + + static QString preStatus = "NONE";//标记前一个状态 + painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); auto animator = m_radiobutton_animation_helper->animator(widget); - //bool hasAnimation = widget &&(!widget->property("animation").isValid() || - //(widget->property("animation").isValid() && widget->property("animation").toBool())); - bool hasAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); //SunkenOn动画运行过程:到checked过程 if (enable && hasAnimation && animator != nullptr && animator->isRunning("SunKenOn")) { - float value = animator->value("SunKenOn").toFloat(); - QColor clickColor = sp->m_RadioButtonParameters.radioButtonClickBrush.color(); - QColor onDefaultPenColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonOnHoverPen.color() : - sp->m_RadioButtonParameters.radioButtonOnDefaultPen.color(); - QColor onDefaultColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonOnClickBrush.color() : - sp->m_RadioButtonParameters.radioButtonOnDefaultBrush.color(); - QColor frameColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonHoverPen.color() : - sp->m_RadioButtonParameters.radioButtonDefaultPen.color(); - QBrush brush(QColor(clickColor.red() + value * (onDefaultColor.red() - clickColor.red()), - clickColor.green() + value * (onDefaultColor.green() - clickColor.green()), - clickColor.blue() + value * (onDefaultColor.blue() - clickColor.blue()), - clickColor.alpha() + value * (onDefaultColor.alpha() - clickColor.alpha()))); - QBrush frameBrush(QColor(frameColor.red() + value * (onDefaultPenColor.red() - frameColor.red()), - frameColor.green() + value * (onDefaultPenColor.green() - frameColor.green()), - frameColor.blue() + value * (onDefaultPenColor.blue() - frameColor.blue()), - frameColor.alpha() + value * (onDefaultPenColor.alpha() - frameColor.alpha()))); - QColor penColor = frameBrush.color(); - penColor.setAlphaF(onDefaultPenColor.alphaF()); - painter->setPen(QPen(QBrush(penColor), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + float value = animator->value("SunKenOn").toFloat();//0.0 ~ 1.0 //绘制外圆 - painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDefaultBrush); + painter->setBrush(mouseOver ? sp->m_RadioButtonParameters.radioButtonOnHoverBrush : sp->m_RadioButtonParameters.radioButtonOnClickBrush); + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonOnClickPen); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(rect); painter->restore(); painter->save(); //绘制内圆 - QRectF childRect(rect.x(), rect.y(), value * 1.0 * ( sp->m_RadioButtonParameters.childrenRadius), value * 1.0 * ( sp->m_RadioButtonParameters.childrenRadius)); + QRectF childRect(rect.x(), rect.y(), value * innerWidth, value * innerHeight); childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(childRect); painter->restore(); return; + } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("Off")) {//Off动画运行过程:到unchecked过程 float value = animator->value("Off").toFloat(); - QPen pen = sp->m_RadioButtonParameters.radioButtonDefaultPen; - pen.color().setAlphaF(sp->m_RadioButtonParameters.radioButtonDefaultPen.color().alphaF() * (1.0 - value)); - painter->setPen(pen); + // QPen pen = sp->m_RadioButtonParameters.radioButtonDefaultPen; + // pen.color().setAlphaF(sp->m_RadioButtonParameters.radioButtonDefaultPen.color().alphaF() * (1.0 - value)); + // painter->setPen(pen); QColor defaultColor = sp->m_RadioButtonParameters.radioButtonDefaultBrush.color(); QColor onDefaultColor = sp->m_RadioButtonParameters.radioButtonOnDefaultBrush.color(); QBrush brush(QColor(defaultColor.red() + value * (onDefaultColor.red() - defaultColor.red()), defaultColor.green() + value * (onDefaultColor.green() - defaultColor.green()), defaultColor.blue() + value * (onDefaultColor.blue() - defaultColor.blue()), defaultColor.alpha() + value * (onDefaultColor.alpha() - defaultColor.alpha()))); + + //绘制外圆 + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonDefaultPen); painter->setBrush(brush); painter->drawEllipse(rect); //绘制内圆 - QRectF childRect(rect.x(), rect.y(), ( sp->m_RadioButtonParameters.childrenRadius) * (value) * 1.0, (value) * 1.0 * ( sp->m_RadioButtonParameters.childrenRadius)); + // QRectF childRect(rect.x(), rect.y(), ( sp->m_RadioButtonParameters.childrenRadius) * (value) * 1.0, (value) * 1.0 * ( sp->m_RadioButtonParameters.childrenRadius)); + QRectF childRect(rect.x(),rect.y(), value * 1.0 * innerWidth,value * 1.0 * innerHeight); childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing); @@ -2507,65 +2632,40 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->drawEllipse(childRect); painter->restore(); return; - } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("OffHover")) {//OffHover动画运行过程:Off状态下执行Hover - - ANIMATION_LOG("[OffHover]: 动画运行过程中..."); - float value = animator->value("OffHover").toFloat(); - -// QColor defaultColor = sp->m_RadioButtonParameters.radioButtonDefaultBrush.color(); -// QColor hoverColor = sp->m_RadioButtonParameters.radioButtonHoverBrush.color();//这个brush可能没有被赋予一个颜色值 + } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("OnHover")) {//onHover动画运行过程:On状态下执行Hover -// QColor targetColor = QColor(defaultColor.red() + value * (hoverColor.red() - defaultColor.red()), -// defaultColor.green() + value * (hoverColor.green() - defaultColor.green()), -// defaultColor.blue() + value * (hoverColor.blue() - defaultColor.blue()), -// defaultColor.alpha() + value * (hoverColor.alpha() - defaultColor.alpha()) -// ); + float value = animator->value("OnHover").toFloat(); - painter->setPen(sp->m_RadioButtonParameters.radioButtonHoverPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonHoverBrush); - painter->setOpacity(value);//动画控制不透明度值 + //绘制外圆 + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen : sp->m_RadioButtonParameters.radioButtonOnHoverPen); + painter->setBrush(sunKen ? sp->m_RadioButtonParameters.radioButtonOnClickBrush : sp->m_RadioButtonParameters.radioButtonOnHoverBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(rect); painter->restore(); + painter->save(); - ANIMATION_LOG("[OffHover Running]: currentTime = " << animator->currentAnimatorTime("OffHover") << ", duration = " << animator->totalAnimationDuration("OffHover") << " , value = " << value); + //绘制内圆 onHover value: 1.0~1.4 + // QRectF childRect(rect.x(), rect.y(), value * ( sp->m_RadioButtonParameters.childrenRadius), value * ( sp->m_RadioButtonParameters.childrenRadius)); + QRectF childRect(rect.x(),rect.y(), value * 1.0 * innerWidth,value * 1.0 * innerHeight); + childRect.moveCenter(rect.center()); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->drawEllipse(childRect); + painter->restore(); return; - } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("OnHover")) {//onHover动画运行过程:On状态下执行Hover - - ANIMATION_LOG("[OnHover]: 动画运行过程中..."); - float value = animator->value("OnHover").toFloat(); + } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("SunkenOnHover")) { - QColor clickColor = sp->m_RadioButtonParameters.radioButtonClickBrush.color(); - QColor onDefaultPenColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonOnHoverPen.color() : - sp->m_RadioButtonParameters.radioButtonOnDefaultPen.color(); -// QColor onDefaultColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonOnClickBrush.color() : -// sp->m_RadioButtonParameters.radioButtonOnDefaultBrush.color(); - QColor frameColor = mouseOver ? sp->m_RadioButtonParameters.radioButtonHoverPen.color() : - sp->m_RadioButtonParameters.radioButtonDefaultPen.color(); -// QBrush brush(QColor(clickColor.red() + value * (onDefaultColor.red() - clickColor.red()), -// clickColor.green() + value * (onDefaultColor.green() - clickColor.green()), -// clickColor.blue() + value * (onDefaultColor.blue() - clickColor.blue()), -// clickColor.alpha() + value * (onDefaultColor.alpha() - clickColor.alpha()))); - QBrush frameBrush(QColor(frameColor.red() + value * (onDefaultPenColor.red() - frameColor.red()), - frameColor.green() + value * (onDefaultPenColor.green() - frameColor.green()), - frameColor.blue() + value * (onDefaultPenColor.blue() - frameColor.blue()), - frameColor.alpha() + value * (onDefaultPenColor.alpha() - frameColor.alpha()))); - - QColor penColor = frameBrush.color(); - penColor.setAlphaF(onDefaultPenColor.alphaF()); - painter->setPen(QPen(QBrush(penColor), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + float value = animator->value("SunkenOnHover").toFloat(); - //绘制外圆 + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen : sp->m_RadioButtonParameters.radioButtonOnClickPen); + painter->setBrush(sunKen ? sp->m_RadioButtonParameters.radioButtonOnClickBrush : sp->m_RadioButtonParameters.radioButtonOnHoverBrush); painter->setRenderHint(QPainter::Antialiasing); - painter->setPen(sp->m_RadioButtonParameters.radioButtonOnHoverPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnHoverBrush); painter->drawEllipse(rect); - painter->restore(); painter->save(); - //绘制内圆 - QRectF childRect(rect.x(), rect.y(), value * ( sp->m_RadioButtonParameters.childrenRadius), value * ( sp->m_RadioButtonParameters.childrenRadius)); - ANIMATION_LOG("value = " << value << " , OnHover动画绘制内圆 (w,h) = " << "(" << value * ( sp->m_RadioButtonParameters.childrenRadius) << "," << value * ( sp->m_RadioButtonParameters.childrenRadius) << ") , 默认宽高 = (" << sp->m_RadioButtonParameters.childrenRadius << "," << sp->m_RadioButtonParameters.childrenRadius << ")"); + QRectF childRect(rect.x(), rect.y(), value * 1.0 * innerWidth, value * 1.0 * innerHeight); childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing); @@ -2575,6 +2675,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty return; } + //各动画的开启、结束处理 if (enable) { if (on) { @@ -2585,50 +2686,65 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty animator->setAnimatorCurrentTime("OffHover",0); animator->setAnimatorCurrentTime("Off", 0); - //绘制on动画开始前,即Off状态 - painter->setPen(sp->m_RadioButtonParameters.radioButtonDefaultPen); - painter->setBrush(Qt::NoBrush); + //sunkenon动画之前之前(return之前)需要绘制off静态状态 + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonDefaultPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(rect); + painter->restore(); return; } if (sunKen) { - painter->setPen(sp->m_RadioButtonParameters.radioButtonOnClickPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnClickBrush); - } else if (mouseOver) {//需要开启OnHover动画 - //painter->setPen(sp->m_RadioButtonParameters.radioButtonOnHoverPen); - //painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnHoverBrush); + // qDebug() << "on, sunkenOn"; + + /* 暂时不需要,可以补充 on状态下的click动画 + if(animator && !animator->isRunning("SunkenOnHover") && animator->currentAnimatorTime("SunkenOnHover") == 0) { + animator->startAnimator("SunkenOnHover"); + + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonOnClickPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnClickBrush); + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(rect); + painter->restore(); + painter->save(); + + QRectF childRect(rect.x(),rect.y(), innerWidth, innerHeight); + childRect.moveCenter(rect.center()); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(childRect); + painter->restore(); + + return ; + } */ + + } else if (mouseOver) {//需要开启基于on状态的OnHover动画 + + animator->stopAnimator("SunkenOnHover");//作为SunkenOnHover动画执行之前的状态,重置SunkenOnHover动画为time = 0 + animator->setAnimatorCurrentTime("SunkenOnHover",0); - //情况1:on——>hover,第一次执行: if(animator && !animator->isRunning("OnHover") && animator->currentAnimatorTime("OnHover") == 0) { - ANIMATION_LOG("开启 [OnHover] 动画"); animator->startAnimator("OnHover"); - //animator->setAnimatorCurrentTime("Off",0);//重置上一个动画Off - //animator->setAnimatorCurrentTime("SunKenOn",0);//重置上一个动画SunkenOn动画 - //绘制原始静态On状态下的内外圆 - painter->setPen(sp->m_RadioButtonParameters.radioButtonOnDefaultPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDefaultBrush); + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonOnHoverPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnHoverBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(rect); painter->restore(); painter->save(); - //若onHover动画结束后,仍处于hover状态 - QRectF childRect(rect.x(), rect.y(), sp->m_RadioButtonParameters.childrenRadius, sp->m_RadioButtonParameters.childrenRadius); + QRectF childRect(rect.x(),rect.y(), innerWidth, innerHeight); childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(childRect); painter->restore(); + return ; - } else if (animator && !animator->isRunning("OnHover") && animator->currentAnimatorTime("OnHover") > 0) { - //情况2:onHover动画绘制结束 - //不能return,需绘制内容 - ANIMATION_LOG("[OnHover] 动画绘制结束/暂停"); - painter->setPen(Qt::NoPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDefaultBrush); } } else {//鼠标不处于hover状态,即鼠标已经移出了圆圈,则需要停止、重置OnHover动画 @@ -2642,23 +2758,34 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } //处理——on状态下的静态/默认绘制:绘制内外圆 painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDefaultBrush); - - painter->drawEllipse(rect); - painter->restore(); - painter->save(); + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonOnDefaultPen);//焦点状态处理 //若onHover动画结束后,仍处于hover状态 QRectF childRect; -// QRectF childRect(rect.x(), rect.y(), sp->m_RadioButtonParameters.childrenRadius, sp->m_RadioButtonParameters.childrenRadius); - if (mouseOver) { - childRect = QRectF(rect.x(), rect.y(), 1.5 * 1.0 * sp->m_RadioButtonParameters.childrenRadius, 1.5 * 1.0 * sp->m_RadioButtonParameters.childrenRadius); + + if(sunKen){ + childRect = QRectF(rect.x(), rect.y(), innerWidth, innerHeight); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnClickBrush); + } + else if (mouseOver) { + childRect = QRectF(rect.x(), rect.y(), 1.4 * innerWidth, 1.4 * innerHeight); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnHoverBrush); } else { - childRect = QRectF(rect.x(), rect.y(), sp->m_RadioButtonParameters.childrenRadius, sp->m_RadioButtonParameters.childrenRadius); + childRect = QRectF(rect.x(), rect.y(), innerWidth, innerHeight); } + + + //draw outer + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(rect); + painter->restore(); + painter->save(); + + //draw inner childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(childRect); painter->restore(); @@ -2668,57 +2795,47 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if (hasAnimation && animator != nullptr) { //On——>Off动作的处理 if (!animator->isRunning("Off") && animator->currentAnimatorTime("SunKenOn") > 0 && animator->currentAnimatorTime("Off") == 0) { - ANIMATION_LOG("开启[Off]动画"); animator->startAnimator("Off");//开启Off动画 animator->setAnimatorCurrentTime("SunKenOn", 0);//重置上一个sunken动画 + + //off 动画执行之前(return),需要绘制on的静态状态 + //绘制内外圆 + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDefaultBrush); + painter->setPen(needFocus ? sp->m_RadioButtonParameters.radioButtonFocusPen:sp->m_RadioButtonParameters.radioButtonOnDefaultPen);//焦点状态处理 + painter->drawEllipse(rect); + painter->restore(); + painter->save(); + + QRectF childRect; + // QRectF childRect(rect.x(), rect.y(), sp->m_RadioButtonParameters.childrenRadius, sp->m_RadioButtonParameters.childrenRadius); + if (mouseOver) {//若onHover动画结束后,仍处于hover状态 + childRect = QRectF(rect.x(), rect.y(), 1.2 * innerWidth, 1.2 * innerHeight); + } else { + childRect = QRectF(rect.x(), rect.y(), innerWidth, innerHeight); + } + childRect.moveCenter(rect.center()); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->drawEllipse(childRect); + + painter->restore(); return; } } - if (sunKen) { + if (sunKen) {//click painter->setPen(sp->m_RadioButtonParameters.radioButtonClickPen); painter->setBrush(sp->m_RadioButtonParameters.radioButtonClickBrush); } else if (mouseOver) { - //painter->setPen(sp->m_RadioButtonParameters.radioButtonHoverPen); - //painter->setBrush(sp->m_RadioButtonParameters.radioButtonHoverBrush); - //情况:初次状态,即off——>hover, - if (animator && !animator->isRunning("OffHover") && animator->currentAnimatorTime("OffHover") == 0) { - ANIMATION_LOG("[offHover]: 动画开启"); - animator->startAnimator("OffHover");//开启OffHover动画 - animator->setAnimatorCurrentTime("Off",0);//重置上一个动画Off - - //绘制OffHover动画之前,即默认的状态 - painter->setPen(sp->m_RadioButtonParameters.radioButtonDefaultPen); - painter->setBrush(Qt::NoBrush); - ANIMATION_LOG("[OffHover]: 动画开启后,先进行的Off默认状态的静态绘制:radioButtonDefaultPen = " << sp->m_RadioButtonParameters.radioButtonDefaultPen.color().name()); - painter->drawEllipse(rect); - painter->restore(); - return ; - } else if (animator && !animator->isRunning("OffHover") && animator->currentAnimatorTime("OffHover") > 0) { - //情况:offHover动画结束了 - //绘制结束状态 - ANIMATION_LOG("[OffHover]: 动画绘制结束/暂停"); + painter->setPen(sp->m_RadioButtonParameters.radioButtonHoverPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonHoverBrush); - animator->stopAnimator("Off"); - painter->setPen(sp->m_RadioButtonParameters.radioButtonHoverPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonHoverBrush); - ANIMATION_LOG("[OffHover]: 动画绘制结束/暂停, 结束状态绘制,使用颜色 brush = " << sp->m_RadioButtonParameters.radioButtonHoverBrush.color().name()); - painter->drawEllipse(rect); - painter->restore(); - return ; - } else if (animator && !animator->isRunning("OffHover") && animator->currentAnimatorTime("Off") > 0 && animator->currentAnimatorTime("OffHover") == 0) {//情况:On——>off——>hover - ANIMATION_LOG("[OffHover]: 动画开启"); - animator->setAnimatorCurrentTime("OffHover",0); - animator->startAnimator("OffHover");//开启OffHover动画 - animator->setAnimatorCurrentTime("Off",0);//重置上一个动画Off - painter->restore(); - return ; - } } else {//按钮的Off默认状态绘制 painter->setPen(sp->m_RadioButtonParameters.radioButtonDefaultPen); - painter->setBrush(Qt::NoBrush); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonDefaultBrush); if(animator){ animator->stopAnimator("OffHover");//stop包含time置0 @@ -2727,21 +2844,46 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty animator->stopAnimator("Off"); } } + + //焦点状态处理 + // painter->setPen(sp->m_RadioButtonParameters.radioButtonDefaultPen); + + if(needFocus){ + painter->setPen(sp->m_RadioButtonParameters.radioButtonFocusPen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonDefaultBrush); + } + + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(rect); - ANIMATION_LOG("Off状态最后的绘制: painter 使用brush = " << painter->brush().color()); } } else {//disable状态按钮绘制 - painter->setPen(sp->m_RadioButtonParameters.radioButtonDisablePen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonDisableBrush); - painter->drawEllipse(rect); + if (!on) { + painter->setPen(sp->m_RadioButtonParameters.radioButtonDisablePen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonDisableBrush); + // int span = painter->pen().width();// span = 1 + // painter->drawEllipse(rect.adjusted(span,span,-span,-span)); + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(rect); - if (on) { - QRectF childRect(rect.x(), rect.y(), sp->m_RadioButtonParameters.childrenRadius, sp->m_RadioButtonParameters.childrenRadius); + } else if (on) { + //绘制内外圆 + + //draw outer + painter->setPen(sp->m_RadioButtonParameters.radioButtonOnDisablePen); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonOnDisableBrush); + painter->setRenderHint(QPainter::Antialiasing); + // painter->drawEllipse(rect.adjusted(span,span,-span,-span)); + painter->drawEllipse(rect); + + //draw inner + QRectF childRect(rect.x(), rect.y(), innerWidth, innerHeight); childRect.moveCenter(rect.center()); painter->setPen(Qt::NoPen); - painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDisableBrush); + painter->setBrush(sp->m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); painter->drawEllipse(childRect); + } } painter->restore(); @@ -2759,6 +2901,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty bool sunKen = checkbox->state & State_Sunken; bool on = checkbox->state & State_On; bool noChange = checkbox->state & State_NoChange; + bool focus = checkbox->state & State_HasFocus; + + bool focusEnable = sp->m_CheckBoxParameters.getFocusEnable(); QRectF rect = checkbox->rect; QRectF pathrect = rect.adjusted(1, 1, -1, -1); @@ -2768,17 +2913,23 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty //hookRect用于绘制对钩的基准矩形 //hLineRect用于绘制水平线的基准矩形 - QRectF hookRect = rect.adjusted(rect.width()*0.17, rect.height()*0.28, -1*rect.width()*0.10, -1*rect.height()*0.21); + auto rectw = rect.width(); + auto recth = rect.height(); + QRectF hookRect = rect.adjusted(0.125 * rectw, 0.1875 * recth, -0.125 * rectw, -0.1875 * recth); hookRect.moveCenter(rect.center()); + QRectF hLineRect= pathrect; //原始默认的hookRect内部的绘制对钩的路径点 - QPointF startPoint(1.0*hookRect.x(),hookRect.y()+0.53*hookRect.height()); - QPointF midBottomPoint(hookRect.x()+0.41*hookRect.width(),1.0*hookRect.y()+hookRect.height()); - QPointF topRightPoint(1.0*hookRect.x()+hookRect.width(),hookRect.y()+0.15*hookRect.height()); - QPointF topLeftPoint(hookRect.x()+0.9*hookRect.width(),1.0*hookRect.y()); - QPointF midTopPoint(hookRect.x()+0.41*hookRect.width(),hookRect.y()+0.70*hookRect.height()); - QPointF endPoint(hookRect.x()+0.1*hookRect.width(),hookRect.y()+0.36*hookRect.height()); + auto hookw = hookRect.width(); + auto hookh = hookRect.height(); + + QPointF startPoint(hookRect.x(), hookRect.y() + 0.596 * hookh); + QPointF midBottomPoint(hookRect.x() + 0.420 * hookw, hookRect.y() + hookh); + QPointF topRightPoint(hookRect.x() + hookw, hookRect.y() + 0.102 * hookh); + QPointF topLeftPoint(hookRect.x() + 0.967 * hookw, hookRect.y()); + QPointF midTopPoint(hookRect.x() + 0.402 * hookw, hookRect.y() + 0.861 * hookh); + QPointF endPoint(hookRect.x() + 0.053 * hookw, hookRect.y() + 0.521 * hookh); int margin = 0; @@ -2794,32 +2945,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty auto animator = m_checkbox_animation_helper->animator(widget); - /* - CheckBox几种颜色: - checkBoxDefaultBrush = QBrush(QColor(ARGB 1, 0.901961, 0.901961, 0.901961),SolidPattern) - checkBoxHoverBrush = QBrush(QColor(Invalid),LinearGradientPattern) - checkBoxClickBrush = QBrush(QColor(Invalid),LinearGradientPattern) - checkBoxDisableBrush = QBrush(QColor(ARGB 1, 0.933333, 0.933333, 0.933333),SolidPattern) - checkBoxOnDefaultBrush = QBrush(QColor(ARGB 1, 0.470588, 0.45098, 0.960784),SolidPattern) - checkBoxOnHoverBrush = QBrush(QColor(Invalid),LinearGradientPattern) - checkBoxOnClickBrush = QBrush(QColor(Invalid),LinearGradientPattern) - checkBoxPathBrush = QBrush(QColor(ARGB 1, 0.470588, 0.45098, 0.960784),SolidPattern) - checkBoxPathDisableBrush = QBrush(QColor(ARGB 0.349996, 0, 0, 0),SolidPattern) - checkBoxDefaultPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - checkBoxHoverPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - checkBoxClickPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - checkBoxOnDefaultPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - checkBoxOnHoverPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - checkBoxOnClickPen = QPen(1,QBrush(QColor(ARGB 0.100008, 0, 0, 0),SolidPattern),SolidLine,32,128,QVector(),0,2) - - CheckBox颜色的渐变对象有: - [CheckBox]: checkBoxHoverBrush = QBrush(QColor(Invalid),LinearGradientPattern) 动画未使用 - [CheckBox]: checkBoxClickBrush = QBrush(QColor(Invalid),LinearGradientPattern) 动画使用过 - [CheckBox]: checkBoxOnHoverBrush = QBrush(QColor(Invalid),LinearGradientPattern) - [CheckBox]: checkBoxOnClickBrush = QBrush(QColor(Invalid),LinearGradientPattern) - */ - - if (hasAnimation && animator != nullptr) { if (animator->isRunning("OnBase")) { float value = animator->value("OnBase").toFloat();//0.0——>1.0 @@ -2830,36 +2955,41 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty // sp->m_CheckBoxParameters.checkBoxOnDefaultBrush.color()) : // sp->m_CheckBoxParameters.checkBoxOnDefaultBrush.color(); // QColor clickColor = sp->m_CheckBoxParameters.checkBoxClickBrush.color(); - QColor frameColor = sp->m_CheckBoxParameters.checkBoxClickPen.color();//checkBoxHoverPen.color(); - QColor onDefaultPenColor = mouseOver ? sp->m_CheckBoxParameters.checkBoxOnHoverPen.color() : sp->m_CheckBoxParameters.checkBoxOnDefaultPen.color(); +// QColor frameColor = sp->m_CheckBoxParameters.checkBoxClickPen.color();//checkBoxHoverPen.color(); +// QColor onDefaultPenColor = mouseOver ? sp->m_CheckBoxParameters.checkBoxOnHoverPen.color() : sp->m_CheckBoxParameters.checkBoxOnDefaultPen.color(); // QBrush brush(QColor(clickColor.red() + value * (onDefaultColor.red() - clickColor.red()), // clickColor.green() + value * (onDefaultColor.green() - clickColor.green()), // clickColor.blue() + value * (onDefaultColor.blue() - clickColor.blue()), // clickColor.alpha() + value * (onDefaultColor.alpha() - clickColor.alpha()))); - QBrush frameBrush(QColor(frameColor.red() + value * (onDefaultPenColor.red() - frameColor.red()), - frameColor.green() + value * (onDefaultPenColor.green() - frameColor.green()), - frameColor.blue() + value * (onDefaultPenColor.blue() - frameColor.blue()), - frameColor.alpha() + value * (onDefaultPenColor.alpha() - frameColor.alpha()))); +// QBrush frameBrush(QColor(frameColor.red() + value * (onDefaultPenColor.red() - frameColor.red()), +// frameColor.green() + value * (onDefaultPenColor.green() - frameColor.green()), +// frameColor.blue() + value * (onDefaultPenColor.blue() - frameColor.blue()), +// frameColor.alpha() + value * (onDefaultPenColor.alpha() - frameColor.alpha()))); - QColor penColor = frameBrush.color(); - painter->setPen(QPen(QBrush(penColor), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));//sp->m_CheckBoxParameters.checkBoxDefaultPen); +// QColor penColor = frameBrush.color(); +// painter->setPen(QPen(QBrush(penColor), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));//sp->m_CheckBoxParameters.checkBoxDefaultPen); - QBrush brush(sp->m_CheckBoxParameters.checkBoxOnDefaultBrush); - painter->setOpacity(value);//动画控制不透明度 - painter->setBrush(brush); +// painter->setOpacity(value);//动画控制不透明度 + + painter->setBrush(sp->m_CheckBoxParameters.checkBoxOnDefaultBrush); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); if(painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); painter->restore(); painter->save(); } else if (animator->isRunning("OnScale")) { - margin = sp->m_CheckBoxParameters.checkBoxOnDefaultPen.width(); +// margin = sp->m_CheckBoxParameters.checkBoxOnDefaultPen.width(); +// painter->setPen(mouseOver ? sp->m_CheckBoxParameters.checkBoxOnHoverPen.color() : sp->m_CheckBoxParameters.checkBoxOnDefaultPen.color()); + margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); painter->setBrush(mouseOver ? sp->m_CheckBoxParameters.checkBoxOnHoverBrush : sp->m_CheckBoxParameters.checkBoxOnDefaultBrush); - painter->setPen(mouseOver ? sp->m_CheckBoxParameters.checkBoxOnHoverPen.color() : sp->m_CheckBoxParameters.checkBoxOnDefaultPen.color()); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); if(painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); painter->restore(); painter->save(); @@ -2910,34 +3040,35 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty auto h = realTimeRect.height(); path.clear(); - path.moveTo(x,y+0.53*h); - path.lineTo(x+0.41*w,y+1.0*h); - path.lineTo(x+1.0*w,y+0.15*h); - path.lineTo(x+0.9*w,y); - path.lineTo(x+0.41*w,y+0.70*h); - path.lineTo(x+0.1*w,y+0.36*h); - path.lineTo(x,y+0.53*h); - ANIMATION_LOG("OnScale 动画 Running: value = " << value << " , 原始hookRect.(w,h) = (" << hookRect.width() << "," << hookRect.height() << ") ,realTimeRect 放大矩形 = (" << w << "," << h << ")"); + path.moveTo(x, y + 0.596 * h); + path.lineTo(x + 0.420 * w, y + h); + path.lineTo(x + w, y + 0.102 * h); + + path.lineTo(x + 0.967 * w, y); + path.lineTo(x + 0.402 * w, y + 0.861 * h); + path.lineTo(x + 0.053 * w, y + 0.521 * h); + path.lineTo(x, y + 0.596 * h); - painter->setBrush(Qt::white);//对钩内部颜色,待封装变量 + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_CheckBoxParameters.checkboxHookLineBrush); animator->setExtraProperty("nochange", false); } else if (noChange) { //path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.center().y() - 0.5); //path.lineTo(pathrect.right() - width / 4 - (1.0 - value) * 0.6 * width /4.0 , pathrect.center().y() - 0.5); - ANIMATION_LOG(" CheckBox: noChange Running...."); path.clear(); path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.center().y() - 0.5); path.lineTo(pathrect.right() - width / 4 - (1.0 - value) * 0.6 * width /4.0 , pathrect.center().y() - 0.5); - painter->setPen(QPen(Qt::white,pathrect.height()*1.0/20));//水平线内部颜色,以及高度,待封装变量 + QPen pen(sp->m_CheckBoxParameters.checkboxHookLineBrush.color(),pathrect.height()*1.0/20,Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin); + painter->setPen(pen);//水平线内部颜色,以及高度 animator->setExtraProperty("nochange", true); } - //painter->setBrush(Qt::NoBrush); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawPath(path); painter->restore(); return; @@ -2961,7 +3092,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty //Off动画:包括对钩、水平线的缩放 if (hasAnimation && animator != nullptr && animator->isRunning("Off")) { - ANIMATION_LOG("[CheckBox]: Off动画运行中"); float value = animator->value("Off").toFloat();//1.0——>0.0 margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); @@ -2990,6 +3120,8 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) painter->translate(0.5, 0.5); + + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); painter->restore(); painter->save(); @@ -3010,13 +3142,15 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty auto h = realTimeRect.height(); path.clear(); - path.moveTo(x,y+0.53*h); - path.lineTo(x+0.41*w,y+1.0*h); - path.lineTo(x+1.0*w,y+0.15*h); - path.lineTo(x+0.9*w,y); - path.lineTo(x+0.41*w,y+0.70*h); - path.lineTo(x+0.1*w,y+0.36*h); - path.lineTo(x,y+0.53*h); + + path.moveTo(x, y + 0.596 * h); + path.lineTo(x + 0.420 * w, y + h); + path.lineTo(x + w, y + 0.102 * h); + + path.lineTo(x + 0.967 * w, y); + path.lineTo(x + 0.402 * w, y + 0.861 * h); + path.lineTo(x + 0.053 * w, y + 0.521 * h); + path.lineTo(x, y + 0.596 * h); // QBrush brush = sp->m_CheckBoxParameters.checkBoxContentPen.brush(); @@ -3024,8 +3158,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty // color.setAlphaF(value); // brush.setColor(color); // painter->setPen(QPen(brush, 1.5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter->setBrush(Qt::white);//对钩内部颜色,待封装变量 - painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_CheckBoxParameters.checkboxHookLineBrush);//对钩内部颜色,待封装变量 + } else if (_nochange) {//缩小水平线 path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.center().y()); @@ -3037,11 +3172,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty // brush.setColor(color); // painter->setPen(QPen(brush, 2)); - painter->setBrush(Qt::white); - painter->setPen(QPen(Qt::white,pathrect.height()*1.0/20));//水平线内部颜色,以及高度,待封装变量 + painter->setPen(QPen(sp->m_CheckBoxParameters.checkboxHookLineBrush.color(),pathrect.height()*1.0/20, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); } - - painter->setBrush(Qt::NoBrush); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawPath(path); painter->restore(); return; @@ -3059,7 +3192,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty bool _nochange = animator->getExtraProperty("nochange").toBool(); - ANIMATION_LOG("=========_nochange = " << _nochange << " , on = " << on << " , noChange = " << noChange); //OnScale动画开启的2个条件(场景): //1、初始状态:OnScale处于未执行状态,且动画值=0(意味着应用程序还未执行过OnScale) @@ -3068,14 +3200,15 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty //if(!animator->isRunning("OnScale") && animator->currentAnimatorTime("OnScale") == 0) if (!animator->isRunning("OnScale") && (animator->currentAnimatorTime("OnScale") == 0 || ( (on && _nochange) || (noChange && !_nochange) ) )) { - ANIMATION_LOG("=========CheckBox 开启 OnScale动画"); animator->startAnimator("OnScale"); margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); - painter->setPen(sp->m_CheckBoxParameters.checkBoxClickPen); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); painter->setBrush(sp->m_CheckBoxParameters.checkBoxClickBrush); if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) painter->translate(0.5, 0.5); + + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); painter->restore(); animator->setAnimatorCurrentTime("Off", 0); @@ -3084,16 +3217,16 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } } if (sunKen) { - margin = sp->m_CheckBoxParameters.checkBoxOnClickPen.width(); - painter->setPen(sp->m_CheckBoxParameters.checkBoxOnClickPen); + margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); painter->setBrush(sp->m_CheckBoxParameters.checkBoxOnClickBrush); } else if (mouseOver) { - margin = sp->m_CheckBoxParameters.checkBoxOnHoverPen.width(); - painter->setPen(sp->m_CheckBoxParameters.checkBoxOnHoverPen); + margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); painter->setBrush(sp->m_CheckBoxParameters.checkBoxOnHoverBrush); } else { - margin = sp->m_CheckBoxParameters.checkBoxOnDefaultPen.width(); - painter->setPen(sp->m_CheckBoxParameters.checkBoxOnDefaultPen); + margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); painter->setBrush(sp->m_CheckBoxParameters.checkBoxOnDefaultBrush); } if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) @@ -3105,9 +3238,8 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty //draw path if (on) { - painter->setPen(QPen(sp->m_CheckBoxParameters.checkBoxContentPen.color(), 1.5, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter->setRenderHint(QPainter::Antialiasing, true); +// painter->setPen(QPen(sp->m_CheckBoxParameters.checkBoxContentPen.color(), 1.5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + //绘制On状态的静态时间点 对钩 path.clear(); path.moveTo(startPoint); @@ -3118,19 +3250,20 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty path.lineTo(endPoint); path.lineTo(startPoint); - painter->setBrush(Qt::white);//对钩内部颜色,待封装变量 + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_CheckBoxParameters.checkboxHookLineBrush); } else if (noChange) { - painter->setPen(QPen(sp->m_CheckBoxParameters.checkBoxContentPen.color(), 1.5, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - //绘制静nochange状态静态水平线 +// painter->setPen(QPen(sp->m_CheckBoxParameters.checkBoxContentPen.color(), 1.5, +// Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + //绘制nochange状态静态水平线 path.clear(); path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - 1.0 * 0.6 * width /4.0, pathrect.center().y() - 0.5); path.lineTo(pathrect.right() - width / 4, pathrect.center().y() - 0.5); - painter->setPen(QPen(Qt::white,pathrect.height()*1.0/20));//水平线内部颜色,以及高度,待封装变量 + painter->setPen(QPen(sp->m_CheckBoxParameters.checkboxHookLineBrush.color(),pathrect.height()*1.0/20, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); } - //painter->setBrush(Qt::NoBrush); + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawPath(path); } else {//Off @@ -3150,51 +3283,67 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } if (sunKen) { margin = sp->m_CheckBoxParameters.checkBoxClickPen.width(); - painter->setPen(sp->m_CheckBoxParameters.checkBoxClickPen); -// painter->setBrush(sp->m_CheckBoxParameters.checkBoxClickBrush); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); + painter->setBrush(sp->m_CheckBoxParameters.checkBoxClickBrush); } else if (mouseOver) { - //margin = sp->m_CheckBoxParameters.checkBoxHoverPen.width(); - //painter->setPen(sp->m_CheckBoxParameters.checkBoxHoverPen); - //painter->setBrush(sp->m_CheckBoxParameters.checkBoxHoverBrush); - - margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); - QPen offHoverPen(sp->m_CheckBoxParameters.checkBoxOnDefaultBrush,3); - painter->setPen(offHoverPen); -// painter->setBrush(sp->m_CheckBoxParameters.checkBoxDefaultBrush); + margin = sp->m_CheckBoxParameters.checkBoxHoverPen.width(); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); + painter->setBrush(sp->m_CheckBoxParameters.checkBoxHoverBrush); } else { margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width(); - //painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); + painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen); painter->setBrush(sp->m_CheckBoxParameters.checkBoxDefaultBrush); - - QPen defaultPen(Qt::lightGray,3);//复选框默认情况下边框颜色,及厚度,待封装变量 - painter->setPen(defaultPen); - painter->setBrush(Qt::NoBrush);//默认无背景色 } - if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) + if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0)//将画笔移动到像素点中心位置(目前无效) painter->translate(0.5, 0.5); - painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), - sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); +// qDebug() << "默认情况 不选中,off,样式 : pen color = " << painter->pen().color() << ",pen 宽度 = " << painter->pen().width() << +// ", 边框 radius = " << sp->m_CheckBoxParameters.radius << +// ",背景色 = " << painter->brush().color(); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); } - } else {//disabled + } else {//disabled default margin = sp->m_CheckBoxParameters.checkBoxDisablePen.width(); painter->setPen(sp->m_CheckBoxParameters.checkBoxDisablePen); - painter->setBrush(sp->m_CheckBoxParameters.checkBoxDisableBrush); + + QBrush usedBrush = (on || noChange) ? sp->m_CheckBoxParameters.checkBoxDisableOnNoChangeBrush : sp->m_CheckBoxParameters.checkBoxDisableBrush; + painter->setBrush(usedBrush); + if (painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0) painter->translate(0.5, 0.5); - painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), - sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); +// qDebug() << "CheckBox disable 状态:边框 radius = " << sp->m_CheckBoxParameters.radius << +// ",背景色 = " << sp->m_CheckBoxParameters.checkBoxDisableBrush.color() << ", 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() << ",原始解析得到的边框颜色 = sp->m_CheckBoxParameters.checkBoxDisablePen " << sp->m_CheckBoxParameters.checkBoxDisablePen.color(); + painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius); painter->restore(); painter->save(); - if (on | noChange) { - if (on) { - painter->setPen(QPen(checkbox->palette.brush(QPalette::Disabled, QPalette::ButtonText), 1.5, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - } else if (noChange) { - painter->setPen(QPen(checkbox->palette.brush(QPalette::Disabled, QPalette::ButtonText), 2)); - } - painter->setBrush(Qt::NoBrush); - painter->drawPath(path); + + //disable on 、disable noChange + if (on) { + //绘制On状态的静态时间点 对钩 + path.clear(); + path.moveTo(startPoint); + path.lineTo(midBottomPoint); + path.lineTo(topRightPoint); + path.lineTo(topLeftPoint); + path.lineTo(midTopPoint); + path.lineTo(endPoint); + path.lineTo(startPoint); + + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_CheckBoxParameters.checkboxHookLineDisableBrush); + + } else if (noChange) { +// painter->setPen(QPen(sp->m_CheckBoxParameters.checkBoxContentPen.color(), 1.5, +// Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + //绘制nochange状态静态水平线 + path.clear(); + path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - 1.0 * 0.6 * width /4.0, pathrect.center().y() - 0.5); + path.lineTo(pathrect.right() - width / 4, pathrect.center().y() - 0.5); + + painter->setPen(QPen(sp->m_CheckBoxParameters.checkboxHookLineDisableBrush.color(),pathrect.height()*1.0/20, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); } + painter->setRenderHint(QPainter::Antialiasing, true); + painter->drawPath(path); } painter->restore(); return; @@ -3238,28 +3387,37 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty cg = QPalette::Inactive; int Radius = 0;//sp->radius; - bool isTree = false; - if (qobject_cast(widget) || qobject_cast(widget)) { - isTree = true; - } + if(widget && qobject_cast(widget) && qobject_cast(widget)->alternatingRowColors()){ + if (!(vi->features & QStyleOptionViewItem::Alternate)){ - if (isTree) { - if (proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, option, widget)) { - if (vi->features & QStyleOptionViewItem::Alternate) { + if (qobject_cast(widget) || qobject_cast(widget)) { + painter->save(); + painter->setPen(Qt::NoPen); + // painter->setBrush(vi->palette.brush(cg, QPalette::AlternateBase)); + painter->setBrush(sp->m_TreeParameters.treeAlternatingRowsNormalBrush); + painter->drawRoundedRect(vi->rect, Radius, Radius); + painter->restore(); + }else if (qobject_cast(widget) || qobject_cast(widget)) { + painter->save(); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_ListParameters.listAlternatingRowsNormalBrush); + painter->drawRoundedRect(vi->rect, Radius, Radius); + painter->restore(); + }else if (qobject_cast(widget) || qobject_cast(widget)) { + painter->save(); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_TableParameters.tableAlternatingRowsNormalBrush); + painter->drawRoundedRect(vi->rect, Radius, Radius); + painter->restore(); + }else{ painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(vi->palette.brush(cg, QPalette::AlternateBase)); - painter->drawRect(vi->rect); + painter->drawRoundedRect(vi->rect, Radius, Radius); painter->restore(); } } - } else if (vi->features & QStyleOptionViewItem::Alternate) { - painter->save(); - painter->setPen(Qt::NoPen); - painter->setBrush(vi->palette.brush(cg, QPalette::AlternateBase)); - painter->drawRoundedRect(vi->rect, Radius, Radius); - painter->restore(); } if (dynamic_cast(painter->device())) { @@ -3269,7 +3427,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } break; } - + //List,Table,Tree case PE_PanelItemViewItem: { if (const QStyleOptionViewItem *vi = qstyleoption_cast(option)) { @@ -3280,14 +3438,16 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty bool focus = vi->state & State_HasFocus; int focusRadius; + QBrush defaultBrush; QBrush hoverBrush; QBrush selectBrush; QBrush disableBrush; + + QPainterPath path; QPainterPath rectPath; - QPen defaultPen = Qt::NoPen; QPen hoverPen = Qt::NoPen; QPen focusPen = Qt::NoPen; QPen selectPen = Qt::NoPen; @@ -3305,6 +3465,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if(qobject_cast(widget) || qobject_cast(widget)) isTree = true; + + // different tree,table,list + if (qobject_cast(widget) || qobject_cast(widget)) { sp->initConfigTreeParameters(isUseDarkPalette(), option, widget); // if(const QStyleOptionViewItem *vimm = qstyleoption_cast(option)){ @@ -3327,7 +3490,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty hoverBrush = sp->m_TreeParameters.treeHoverBrush; selectBrush = sp->m_TreeParameters.treeSelectBrush; disableBrush = sp->m_TreeParameters.treeDisableBrush; - defaultPen = sp->m_TreeParameters.treeDefaultPen; hoverPen = sp->m_TreeParameters.treeHoverPen; selectPen = sp->m_TreeParameters.treeSelectPen; focusPen = sp->m_TreeParameters.treeFocusPen; @@ -3340,7 +3502,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty QRect rect = vi->rect.adjusted(0, 0, 1, 1); int margin = 4; - path.setFillRule(Qt::WindingFill); path.moveTo(rect.left(), rect.top() + sp->m_TreeParameters.radius); path.arcTo(rect.left(), rect.top(), 2 * sp->m_TreeParameters.radius, 2 * sp->m_TreeParameters.radius, 180, -90); path.lineTo(rect.right(), rect.top()); @@ -3348,7 +3509,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty path.lineTo(rect.left() + sp->m_TreeParameters.radius, rect.bottom()); path.arcTo(rect.left(), rect.bottom() - 2 * sp->m_TreeParameters.radius, 2 * sp->m_TreeParameters.radius, 2 * sp->m_TreeParameters.radius, -90, -90); path.lineTo(rect.left(), rect.top() + sp->m_TreeParameters.radius); - path.addRect(rect.adjusted(sp->m_TreeParameters.radius, -margin, margin, +margin)); borderPath0.moveTo(rect.left(), rect.top() + sp->m_TreeParameters.radius); borderPath0.arcTo(rect.left(), rect.top(), 2 * sp->m_TreeParameters.radius, 2 * sp->m_TreeParameters.radius, 180, -90); @@ -3430,21 +3590,23 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } else { path.addRect(vi->rect); } - } else if(qobject_cast(widget) || qobject_cast(widget)){ + } else if (qobject_cast(widget) || qobject_cast(widget)) { sp->initConfigListParameters(isUseDarkPalette(), option, widget); + bool focusEnable = sp->m_ListParameters.getFocusEnable(); + defaultBrush = sp->m_ListParameters.listDefaultBrush; hoverBrush = sp->m_ListParameters.listHoverBrush; selectBrush = sp->m_ListParameters.listSelectBrush; disableBrush = sp->m_ListParameters.listDisableBrush; - defaultPen = sp->m_ListParameters.listDefaultPen; + hoverPen = sp->m_ListParameters.listHoverPen; selectPen = sp->m_ListParameters.listSelectPen; focusPen = sp->m_ListParameters.listFocusPen; focusRadius = sp->m_ListParameters.radius; auto *listView = qobject_cast(widget); - int focusWidth = focus ? focusPen.width()/2 : 0; + int focusWidth = (focus && focusEnable) ? focusPen.width()/2 : 0; if(select && listView != nullptr){ @@ -3515,27 +3677,29 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty } else path.addRoundedRect(vi->rect.adjusted(focusWidth, focusWidth, -1 * focusWidth, -1 * focusWidth), sp->m_ListParameters.radius, sp->m_ListParameters.radius); - } else if(qobject_cast(widget) || qobject_cast(widget)){ + + } else if (qobject_cast(widget) || qobject_cast(widget)) { sp->initConfigTableParameters(isUseDarkPalette(), option, widget); + bool focusEnable = sp->m_TableParameters.getFocusEnable(); + defaultBrush = sp->m_TableParameters.tableDefaultBrush; hoverBrush = sp->m_TableParameters.tableHoverBrush; selectBrush = sp->m_TableParameters.tableSelectBrush; disableBrush = sp->m_TableParameters.tableDisableBrush; - defaultPen = sp->m_TableParameters.tableDefaultPen; hoverPen = sp->m_TableParameters.tableHoverPen; selectPen = sp->m_TableParameters.tableSelectPen; focusPen = sp->m_TableParameters.tableFocusPen; focusRadius = sp->m_TableParameters.radius; - int focusWidth = focus ? focusPen.width()/2 : 0; + int focusWidth = (focus && focusEnable) ? focusPen.width()/2 : 0; path.addRoundedRect(vi->rect.adjusted(focusWidth, focusWidth, -1 * focusWidth, -1 * focusWidth), sp->m_TableParameters.radius, sp->m_TableParameters.radius); - } - else { + } else { path.addRect(vi->rect); focusRadius = 0; defaultBrush = QBrush(Qt::transparent); - hoverBrush = option->palette.brush(QPalette::Disabled, QPalette::Midlight); + // hoverBrush = option->palette.brush(QPalette::Disabled, QPalette::Midlight); + hoverBrush = sp->m_TableParameters.tableHoverBrush;//文件管理器内,图标放大后的结构,hover的颜色会走这里 selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight); disableBrush = QBrush(Qt::transparent); } @@ -3543,7 +3707,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if ((vi->decorationPosition == QStyleOptionViewItem::Top) || (vi->decorationPosition == QStyleOptionViewItem::Bottom)) isIconMode = true; + if (isIconMode) { + QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, option, widget); QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, option, widget); int iconMode_Radius = sp->radius; @@ -3589,7 +3755,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->setRenderHint(QPainter::Antialiasing, true); painter->setBrush(vi->palette.brush(QPalette::Active, QPalette::Button)); painter->drawPath(iconPath); + painter->setBrush(selectBrush); + painter->drawPath(textPath); painter->restore(); } else { @@ -3600,7 +3768,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->drawRoundedRect(option->rect, iconMode_Radius, iconMode_Radius); painter->restore(); } - } else { + } else { // not select painter->save(); painter->setPen(Qt::NoPen); painter->setRenderHint(QPainter::Antialiasing, true); @@ -3608,8 +3776,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->setPen((hoverPen == Qt::NoPen || hoverPen.color().alpha() == 0) ? Qt::NoPen : hoverPen); painter->setBrush(hoverBrush); painter->drawRoundedRect(option->rect, iconMode_Radius, iconMode_Radius); - } - else if (vi->backgroundBrush.style() != Qt::NoBrush) { + } else if (vi->backgroundBrush.style() != Qt::NoBrush) { QPointF oldBO = painter->brushOrigin(); painter->setBrushOrigin(vi->rect.topLeft()); painter->setBrush(vi->backgroundBrush); @@ -3620,6 +3787,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->restore(); } } else { + if (vi->backgroundBrush.style() != Qt::NoBrush) { QPointF oldBO = painter->brushOrigin(); painter->setBrushOrigin(vi->rect.topLeft()); @@ -3630,13 +3798,23 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->save(); painter->setPen(Qt::NoPen); + // if (!enable) { + // painter->setBrush(disableBrush); + // } else if (select) { + // if(hover) + // painter->setBrush(hoverBrush); + // else + // painter->setBrush(defaultBrush); + // } else if (hover) { + // painter->setBrush(hoverBrush); + // } else { + // painter->setBrush(defaultBrush); + // } + if (!enable) { - painter->setBrush(disableBrush); + painter->setBrush(disableBrush); //disableBrush等本身都是包含对select状态判断的,所以这里无需判断 } else if (select) { - if(hover) - painter->setBrush(hoverBrush); - else - painter->setBrush(defaultBrush); + painter->setBrush(selectBrush); } else if (hover) { painter->setBrush(hoverBrush); } else { @@ -3654,7 +3832,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(defaultPen); + painter->setPen(Qt::NoPen); painter->setBrush(Qt::NoBrush); if (enable && select) { painter->setPen((selectPen == Qt::NoPen || selectPen.color().alpha() == 0) ? Qt::NoPen : selectPen); @@ -3749,7 +3927,11 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty // } } - if (!isTree && focus) { + + // focus handle + + bool focusEnableState = sp->m_TableParameters.getFocusEnable() || sp->m_ListParameters.getFocusEnable(); + if (!isTree && focus && focusEnableState) { painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->setPen((focusPen == Qt::NoPen || focusPen.color().alpha() == 0) ? Qt::NoPen : focusPen); @@ -3829,7 +4011,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty QPainterPath borderPath1; sp->initConfigTreeParameters(isUseDarkPalette(), option, widget); - defaultPen = sp->m_TreeParameters.treeDefaultPen; hoverPen = sp->m_TreeParameters.treeHoverPen; selectPen = sp->m_TreeParameters.treeSelectPen; //focusPen = sp->m_TreeParameters.treeFocusPen; @@ -3837,10 +4018,10 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty if (!enable) { brush = sp->m_TreeParameters.treeBranchDisableBrush; } else if (isSelected) { - if(isHover) - brush = sp->m_TreeParameters.treeBranchHoverBrush; - else - brush = sp->m_TreeParameters.treeBranchDefaultBrush; + // if(isHover) + // brush = sp->m_TreeParameters.treeBranchHoverBrush; + // else + brush = sp->m_TreeParameters.treeBranchDefaultBrush; } else if (isHover) { brush = sp->m_TreeParameters.treeBranchHoverBrush; } else { @@ -3980,8 +4161,10 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty painter->save(); painter->setClipRect(rect); painter->setRenderHint(QPainter::Antialiasing, Radius != 0); - if(painter->pen().width() == 1 && Radius != 0) + if(option->rect.height() != 0 && painter->pen().width() == 1 && Radius != 0){ painter->translate(0.5, 0.5); + rect.adjust(0, 0, -1, -1); + } painter->setPen(option->palette.color(QPalette::Active, QPalette::Highlight)); painter->setBrush(Qt::NoBrush); if (option->rect.height() == 0) @@ -4005,59 +4188,16 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q case CC_ScrollBar: { if (const QStyleOptionSlider *bar = qstyleoption_cast(option)) { sp->initConfigScrollBarParameters(isUseDarkPalette(), option, widget); - if (widget && widget->property("drawScrollBarGroove").isValid() && (!widget->property("drawScrollBarGroove").toBool())) { - /*const bool active = bar->state & State_Active; - QColor color; - if (active) { - color = sp->m_ScrollBarParameters.scrollBarGrooveDefaultBrush.color(); - auto animator = m_scrollbar_animation_helper->animator(widget); - if (animator) { - const bool mouseOver = bar->state & State_MouseOver; - if(sp->m_ScrollBarParameters.animation) { - //hover color animation - animator->setAnimatorDirectionForward("bg_width", mouseOver); - - if (mouseOver) { - if (!animator->isRunning("bg_width") && animator->currentAnimatorTime("bg_width") == 0) { - animator->startAnimator("bg_width"); - } - } else { - if (!animator->isRunning("bg_width") && animator->currentAnimatorTime("bg_width") > 0) { - animator->startAnimator("bg_width"); - } - } - if(animator->isRunning("bg_width") || mouseOver){ - qreal ratio = animator->value("bg_width").toReal(); - color.setAlphaF(sp->m_ScrollBarParameters.scrollBarGrooveDefaultBrush.color().alphaF() * ratio); - QRect rect = bar->rect; - const bool horizontal = bar->orientation == Qt::Horizontal; - if(horizontal){ - rect = QRect(bar->rect.x(), (bar->rect.y() + bar->rect.height() * (1 - ratio)), bar->rect.width(), bar->rect.height() * ratio); - } - else{ - rect = QRect((bar->rect.x() + bar->rect.width() * (1 - ratio)), bar->rect.top(), bar->rect.width() * ratio, bar->rect.height()); - } - painter->save(); - painter->setPen(Qt::NoPen); - painter->setBrush(color); - painter->drawRect(rect); - painter->restore(); - } - } - } - }*/ - } else { - const bool enable = bar->state & State_Enabled; + if (widget && widget->property("drawScrollBarGroove").isValid() && (widget->property("drawScrollBarGroove").toBool())) { + + // const bool enable = bar->state & State_Enabled; painter->save(); painter->setPen(Qt::NoPen); - if (enable) { - painter->setBrush(sp->m_ScrollBarParameters.scrollBarGrooveDefaultBrush); - } else { - painter->setBrush(sp->m_ScrollBarParameters.scrollBarGrooveInactiveBrush); - } - + painter->setBrush(sp->m_ScrollBarParameters.scrollBarGrooveDefaultBrush);//滑动条所在的矩形的背景色 painter->drawRect(bar->rect); painter->restore(); + } else { + } // if (!(bar->activeSubControls & SC_ScrollBarSlider)) { @@ -4068,7 +4208,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q newScrollbar.rect = proxy()->subControlRect(control, option, SC_ScrollBarSlider, widget); proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, painter, widget); - if (sp->ScrooBar_ShowLine && widget && ((widget->property("drawScrollBarGroove").isValid() && + if (sp->m_ScrollBarParameters.scrollBarShowArrow && widget && ((widget->property("drawScrollBarGroove").isValid() && widget->property("drawScrollBarGroove").toBool()) || !widget->property("drawScrollBarGroove").isValid())) { if (bar->subControls & SC_ScrollBarSubLine) { QStyleOptionSlider subline = *bar; @@ -4092,7 +4232,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q { if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { sp->initConfigSliderParameters(isUseDarkPalette(), option, widget); - QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);//groove 高度需要为24 QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); int width = 0; const bool horizontal = slider->orientation == Qt::Horizontal; @@ -4100,6 +4240,14 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q const bool hover = slider->state & State_MouseOver; const bool suken = slider->state & State_Sunken; const bool focus = slider->state & State_HasFocus; + + //animation + bool hasAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); + auto animator = m_slider_animation_helper->animator(widget); + + bool focusEnable = sp->m_SliderParameters.getFocusEnable(); + + if (slider->subControls & SC_SliderGroove) { if (horizontal) { groove.setHeight(sp->Slider_GrooveLength); @@ -4113,6 +4261,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q QBrush sBrush, gBrush; QRect sRect, gRect; + //gRect: 未划过区域, sRect:划过区域 if (horizontal) { if (slider->upsideDown) { sRect.setLeft(handle.center().x()); @@ -4211,6 +4360,41 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q } } + + if (enable && hasAnimation && animator != nullptr && animator->isRunning("hover_zoomin")) { + float value = animator->value("hover_zoomin").toFloat(); + QRect curHandle; + curHandle.setWidth(value * handle.width()); + curHandle.setHeight(value * handle.height()); + curHandle.moveCenter(handle.center()); + painter->setPen(sp->m_SliderParameters.sliderHandleHoverPen); + painter->setBrush(sp->m_SliderParameters.sliderHandleHoverBrush); + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(curHandle.adjusted(1,1,-1,-1)); + return ; + } else if (enable && hasAnimation && animator != nullptr && animator->isRunning("click_zoomin")) { + float value = animator->value("click_zoomin").toFloat();// 0 ~ 1 + + painter->setPen(sp->m_SliderParameters.sliderHandleDefaultPen); + QBrush bodyColor = painter->pen().color(); + painter->setBrush(bodyColor); + + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(handle.adjusted(1,1,-1,-1)); + + float diff = value * 3; + QRect childRect(handle.x(), handle.y(), 12-diff, 12-diff); + childRect.moveCenter(handle.center()); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_SliderParameters.sliderHandleDefaultBrush); + if (childRect.width() % 2 != 0) { + painter->translate(0.5,0.5); + } + painter->drawEllipse(childRect); + return ; + } + + if (slider->subControls & SC_SliderHandle) { //we need to reinit our brush because it has QGradient without use option rect QStyleOptionSlider handleOption = *slider; @@ -4226,30 +4410,120 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q QBrush hBrush; QPen hPen; if (!enable) { - hBrush = sp->m_SliderParameters.sliderHandleDisableBrush; - hPen = sp->m_SliderParameters.sliderHandleDisablePen; + } else if (suken) { hBrush = sp->m_SliderParameters.sliderHandleClickBrush; hPen = sp->m_SliderParameters.sliderHandleClickPen; + + if (animator != nullptr && hasAnimation && !animator->isRunning("click_zoomin") && animator->currentAnimatorTime("click_zoomin") == 0) { + animator->startAnimator("click_zoomin"); + painter->setPen(sp->m_SliderParameters.sliderHandleDefaultPen); + QColor bodyColor = painter->pen().color(); + painter->setBrush(bodyColor); + + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(handle.adjusted(1,1,-1,-1)); + + QRect childRect(handle.x(), handle.y(), 12, 12); + childRect.moveCenter(handle.center()); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_SliderParameters.sliderHandleDefaultBrush); + painter->drawEllipse(childRect); + + return; + } } else if (hover) { + + animator->setAnimatorCurrentTime("click_zoomin",0); + hBrush = sp->m_SliderParameters.sliderHandleHoverBrush; hPen = sp->m_SliderParameters.sliderHandleHoverPen; - } else { + + //需要开启hover放大动画 + if (animator != nullptr && hasAnimation && !animator->isRunning("hover_zoomin") && animator->currentAnimatorTime("hover_zoomin") == 0) { + animator->startAnimator("hover_zoomin"); + painter->setPen(sp->m_SliderParameters.sliderHandleDefaultPen); + painter->setBrush(sp->m_SliderParameters.sliderHandleDefaultBrush); + painter->setRenderHint(QPainter::Antialiasing); + painter->drawEllipse(handle.adjusted(1,1,-1,-1)); + return; + } + + } else { //default status hBrush = sp->m_SliderParameters.sliderHandleDefaultBrush; - hPen = sp->m_SliderParameters.sliderHandleDefaultPen; + hPen = sp->m_SliderParameters.sliderHandleDefaultPen;//圆柄的边框 + + //animation reset + animator->stopAnimator("hover_zoomin"); + animator->setAnimatorCurrentTime("hover_zoomin",0); } painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(hPen.width() == 0 ? Qt::NoPen : hPen); - if(painter->pen().width() == 1) - painter->translate(0.5, 0.5); painter->setBrush(hBrush); - painter->drawPath(sp->m_SliderParameters.sliderHandlePath); + + painter->setPen(hPen.width() == 0 ? Qt::NoPen : hPen); + // if(painter->pen().width() == 1) + // painter->translate(0.5, 0.5); + + // painter->drawPath(sp->m_SliderParameters.sliderHandlePath); + + + if (!enable) { + + QRect targetRect = handle; + targetRect.setSize(QSize(18,18));//3层绘制 + targetRect.moveCenter(handle.center()); + + QBrush brush = sp->m_SliderParameters.sliderHandleDisbaleBaseBrush;// baseActive + painter->setPen(Qt::NoPen); + painter->setBrush(brush); + painter->drawEllipse(targetRect); + + QBrush disableBrush = sp->m_SliderParameters.sliderGrooveValueDisableBrush;//0.45 + painter->setBrush(disableBrush); + painter->drawEllipse(targetRect); + + QRect childRect = targetRect; + childRect.setSize(QSize(12,12)); + childRect.moveCenter(targetRect.center()); + painter->setPen(Qt::NoPen); + QBrush baseBrush = sp->m_SliderParameters.sliderHandleDisableBrush; // 如果用这个kfontwhite进行透明化,透明度用0.9 + painter->setBrush(baseBrush); + painter->drawEllipse(childRect.adjusted(1,1,-1,-1)); + + + } else { + if (suken) { + painter->setPen(sp->m_SliderParameters.sliderHandleDefaultPen); + QColor bodyColor = painter->pen().color(); + painter->setBrush(bodyColor); + painter->drawEllipse(handle.adjusted(1,1,-1,-1)); + + QRect childRect(handle.x(), handle.y(), 9, 9); + childRect.moveCenter(handle.center()); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_SliderParameters.sliderHandleDefaultBrush); + if (childRect.width() % 2 != 0) { + painter->translate(0.5,0.5); + } + painter->drawEllipse(childRect); + + + } else if (hover) { + QRect zoomRect; + zoomRect.setSize(1.125 * handle.size()); + zoomRect.moveCenter(handle.center()); + painter->drawEllipse(zoomRect.adjusted(1,1,-1,-1)); + } else { + painter->drawEllipse(handle.adjusted(1,1,-1,-1)); + } + } + painter->restore(); } - if (enable && focus) { + if (enable && focus && focusEnable) { painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->setPen(sp->m_SliderParameters.focusPen.width() == 0 ? Qt::NoPen : sp->m_SliderParameters.focusPen); @@ -4275,6 +4549,9 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q const bool hover = comboBox->state & State_MouseOver; const bool focus = comboBox->state & State_HasFocus; + + bool focusEnable = sp->m_ComboBoxParameters.getFocusEnable(); + int width = 0; painter->save(); @@ -4288,7 +4565,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q if (comboBox->state & (State_HasFocus | State_On)) { width = sp->m_ComboBoxParameters.comboBoxEditPen.width(); painter->setPen(sp->m_ComboBoxParameters.comboBoxEditPen); - painter->setBrush(sp->m_ComboBoxParameters.comboBoxEditBrush); + painter->setBrush(sp->m_ComboBoxParameters.comboBoxEditBrush);//editable模式下的默认背景色 } else { width = sp->m_ComboBoxParameters.comboBoxDefaultPen.width(); painter->setPen(sp->m_ComboBoxParameters.comboBoxDefaultPen); @@ -4306,12 +4583,12 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q } else { width = sp->m_ComboBoxParameters.comboBoxDefaultPen.width(); painter->setPen(sp->m_ComboBoxParameters.comboBoxDefaultPen); - painter->setBrush(sp->m_ComboBoxParameters.comboBoxDefaultBrush); + painter->setBrush(sp->m_ComboBoxParameters.comboBoxDefaultBrush);//默认非editable状态下的背景色 } } //focus - if (focus) { + if (focus && focusEnable) { width = sp->m_ComboBoxParameters.comboBoxFocusPen.width(); painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ComboBoxParameters.comboBoxFocusPen); } @@ -4354,11 +4631,15 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q downOption.rect = downRect; bool hasBorder = false; + bool needDrawArrowBorder = false;//是否绘制箭头矩形区域边框 + bool focusEnable = sp->m_SpinBoxParameters.getFocusEnable(); + painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_SpinBoxParameters.radius != 0); if(isHorizontalLayout)//xc mode { + //QSpinBox左边编辑框区域 if (!enable) { upOption.state = State_None; downOption.state = State_None; @@ -4367,36 +4648,45 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q hasBorder = false; // if(painter->pen().width() == 1) // painter->translate(0.5, 0.5); +// qDebug() << "isHorizontalLayout: SpinBox禁用状态: 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() +//// << ",边框radius = " << +// << " , 背景色 = " << painter->brush().color(); painter->drawRect(option->rect.adjusted(sp->SpinBox_DefaultHeight, 0, -sp->SpinBox_DefaultHeight, -1)); painter->restore(); - } - else - { - if (focus) { + } else { + if (focus && focusEnable) { int width = sp->m_SpinBoxParameters.spinBoxFocusPen.width(); hasBorder = true; painter->setPen(sp->m_SpinBoxParameters.spinBoxFocusPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxFocusBrush); if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); +// qDebug() << "isHorizontalLayout: SpinBox focus 状态: 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() +// // << ",边框radius = " << +// << ",背景色 = " << painter->brush().color(); painter->drawRoundedRect(option->rect.adjusted(width, width, -width, -width), sp->m_SpinBoxParameters.radius, sp->m_SpinBoxParameters.radius); painter->restore(); - } else if (hover) { + } else if (hover && !up && !down) { painter->setPen(sp->m_SpinBoxParameters.spinBoxHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxHoverBrush); // if(painter->pen().width() == 1) // painter->translate(0.5, 0.5); +// qDebug() << "isHorizontalLayout: SpinBox hover 状态: 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() +// // << ",边框radius = " << +// << ",背景色 = " << painter->brush().color(); painter->drawRect(option->rect.adjusted(sp->SpinBox_DefaultHeight, 0, -sp->SpinBox_DefaultHeight, -1)); painter->restore(); - } - else { + } else { hasBorder = false; painter->setPen(sp->m_SpinBoxParameters.spinBoxDefaultPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDefaultBrush); // if(painter->pen().width() == 1) // painter->translate(0.5, 0.5); +// qDebug() << "isHorizontalLayout: SpinBox 默认 状态: 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() +// // << ",边框radius = " << +// << ",背景色 = " << painter->brush().color(); painter->drawRect(option->rect.adjusted(sp->SpinBox_DefaultHeight, 0, -sp->SpinBox_DefaultHeight, -1)); painter->restore(); } @@ -4407,6 +4697,10 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q painter->setBrush(Qt::NoBrush); int lineWidth = hasBorder ? 2 : 0; int radius= sp->m_SpinBoxParameters.radius; + + + // QSpinBox右边剪头区域 + // up and down button if (sb->subControls & (SC_SpinBoxUp | SC_SpinBoxDown)) { QPainterPath upPath; @@ -4418,10 +4712,11 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q upPath.lineTo(upRect.left() + 2, upRect.bottom() - lineWidth); upPath.lineTo(upRect.left() + 2, upRect.top() + lineWidth + (hasBorder ? 1 : 0)); + //up button if (sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) { upOption.state |= State_Enabled; if (up && enable) { - if (focus) { + if (focus && focusEnable) { if(sunken) painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpClickBrush); else @@ -4436,29 +4731,23 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpClickBrush); upOption.state |= State_Sunken; } - painter->drawPath(upPath); - } - else { - if(enable) - { +// painter->drawPath(upPath); + } else { + if(enable) { painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDefaultBrush); } - else - { - painter->setBrush(sp->m_SpinBoxParameters.spinBoxDisableBrush); + else { + painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDisableBrush); } - painter->drawPath(upPath); +// painter->drawPath(upPath); } } else { - if(enable) - { + if (enable) { painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDefaultBrush); - } - else - { + } else { painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDefaultBrush); } - painter->drawPath(upPath); +// painter->drawPath(upPath); upOption.state = State_None; } @@ -4477,10 +4766,11 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q downPath.lineTo(downRect.right(), downRect.top() + lineWidth + (hasBorder ? 1 : 0)); downPath.lineTo(downRect.left() + 1 + radius, downRect.top() + lineWidth + (hasBorder ? 1 : 0)); + //down button if (sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) { downOption.state |= State_Enabled; if (down && enable) { - if (focus) { + if (focus && focusEnable) { if(sunken) painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownClickBrush); else @@ -4494,7 +4784,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownClickBrush); downOption.state |= State_Sunken; } - painter->drawPath(downPath); +// painter->drawPath(downPath); } else { if(enable) @@ -4505,7 +4795,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q { painter->setBrush(sp->m_SpinBoxParameters.spinBoxDisableBrush); } - painter->drawPath(downPath); +// painter->drawPath(downPath); } } else { @@ -4517,12 +4807,13 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q { painter->setBrush(sp->m_SpinBoxParameters.spinBoxDisableBrush); } - painter->drawPath(downPath); +// painter->drawPath(downPath); downOption.state = State_None; } painter->restore(); + //箭头本身,图片形式实现 if (!enable) { upOption.state = State_None; downOption.state = State_None; @@ -4535,42 +4826,49 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q proxy()->drawPrimitive(PE_IndicatorArrowDown, &downOption, painter, widget); } } - } - else{//pc mode + } else { + //pc mode if (!enable) { width = sp->m_SpinBoxParameters.spinBoxDisablePen.width(); painter->setPen(sp->m_SpinBoxParameters.spinBoxDisablePen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDisableBrush); +// qDebug() << "not HorizontalLayout: SpinBox 禁用状态 ,brush = " << painter->brush().color(); } else { - if (focus) { + if (focus && focusEnable) { width = sp->m_SpinBoxParameters.spinBoxFocusPen.width(); painter->setPen(sp->m_SpinBoxParameters.spinBoxFocusPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxFocusBrush); - } else if (hover) { +// qDebug() << "not HorizontalLayout: SpinBox 非禁用 focus 状态.正在输入状态"; + } else if (hover && !up && !down) { width = sp->m_SpinBoxParameters.spinBoxHoverPen.width(); painter->setPen(sp->m_SpinBoxParameters.spinBoxHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxHoverBrush); +// qDebug() << "not HorizontalLayout: SpinBox 非禁用 hover 状态 ,brush = " << painter->brush().color(); } else { width = sp->m_SpinBoxParameters.spinBoxDefaultPen.width(); painter->setPen(sp->m_SpinBoxParameters.spinBoxDefaultPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDefaultBrush); +// qDebug() << "not HorizontalLayout: SpinBox 非禁用 默认 状态 ,brush = " << painter->brush().color(); } } if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); - + //QSpinBox左边 编辑框 区域 + painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(option->rect.adjusted(((width%2) == 1 ? (width - 1)/2 : width/2), ((width%2) == 1 ? (width - 1)/2 : width/2), -1 * ((width%2) == 1 ? (width + 1)/2 : width/2), -1 * ((width%2) == 1 ? (width + 1)/2 : width/2)), sp->m_SpinBoxParameters.radius, sp->m_SpinBoxParameters.radius); +// qDebug() << "not HorizontalLayout 总体绘制, 边框宽度 = " << painter->pen().width() << ",边框颜色 = " << painter->pen().color() +// << ",边框radius = " << sp->m_SpinBoxParameters.radius +// << ",背景色 = " << painter->brush().color(); painter->restore(); - - //up and down button + // QSpinBox右边剪头区域 + // up and down button if (sb->subControls & (SC_SpinBoxUp | SC_SpinBoxDown)) { - //up button if (sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) { QPainterPath upPath; @@ -4578,38 +4876,42 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_SpinBoxParameters.radius != 0); if (!enable) { + //disable status upOption.state = State_None; - int width = sp->m_SpinBoxParameters.spinBoxUpDisablePen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDisablePen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDisableBrush); +// int width = sp->m_SpinBoxParameters.spinBoxUpDisablePen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDisablePen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDisableBrush); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxDisableBrush);//kline-component-disable + painter->setBrush(Qt::NoBrush);//kline-component-disable } else { upOption.state |= State_Enabled; if (up) { if (option->state & State_Sunken) { upOption.state |= State_Sunken; - int width = sp->m_SpinBoxParameters.spinBoxUpClickPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpClickPen); +// int width = sp->m_SpinBoxParameters.spinBoxUpClickPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpClickPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpClickBrush); } else { - if (focus) { + if (focus && focusEnable) { upOption.state |= State_MouseOver; - int width = sp->m_SpinBoxParameters.spinBoxUpFocusHoverPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpFocusHoverPen); +// int width = sp->m_SpinBoxParameters.spinBoxUpFocusHoverPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpFocusHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpFocusHoverBrush); } else { - int width = sp->m_SpinBoxParameters.spinBoxUpHoverPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpHoverPen); +// int width = sp->m_SpinBoxParameters.spinBoxUpHoverPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpHoverBrush); } } } else { - int width = sp->m_SpinBoxParameters.spinBoxUpDefaultPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDefaultPen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDefaultBrush); +// int width = sp->m_SpinBoxParameters.spinBoxUpDefaultPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDefaultPen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDefaultBrush); + painter->setBrush(Qt::NoBrush); } } - upRect.adjust(0, 0, 1 - width, 1); + upRect.adjust(0, width - 1, 1 - width, 1); upPath.moveTo(upRect.left(), upRect.top() + sp->m_SpinBoxParameters.radius); upPath.arcTo(upRect.left(), upRect.top(), sp->m_SpinBoxParameters.radius * 2, sp->m_SpinBoxParameters.radius * 2, 180, -90); upPath.lineTo(upRect.right() - sp->m_SpinBoxParameters.radius, upRect.top()); @@ -4622,17 +4924,23 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setPen(Qt::NoPen); painter->drawPath(upPath); -// painter->drawRect(upRect); painter->restore(); } else { + //stepUp失效的情况下,到达阈值边界,不能继续up的场景 + if (!enable) { + painter->setBrush(Qt::NoBrush); + } + painter->save(); + painter->setRenderHint(QPainter::Antialiasing, sp->m_SpinBoxParameters.radius != 0); upOption.state = State_None; int width = sp->m_SpinBoxParameters.spinBoxUpDisablePen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDisablePen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDisableBrush); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxUpDisablePen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxUpDisableBrush); QPainterPath upPath; - upRect.adjust(0, 0, 1 - width, 1); + upRect.adjust(0, width - 1, 1 - width, 1); upPath.moveTo(upRect.left(), upRect.top() + sp->m_SpinBoxParameters.radius); upPath.arcTo(upRect.left(), upRect.top(), sp->m_SpinBoxParameters.radius * 2, sp->m_SpinBoxParameters.radius * 2, 180, -90); upPath.lineTo(upRect.right() - sp->m_SpinBoxParameters.radius, upRect.top()); @@ -4645,10 +4953,9 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setPen(Qt::NoPen); painter->drawPath(upPath); -// painter->drawRect(upRect); painter->restore(); - } //down button @@ -4658,35 +4965,39 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_SpinBoxParameters.radius != 0); if (!enable) { + //disable downOption.state = State_None; - int width = sp->m_SpinBoxParameters.spinBoxDownDisablePen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDisablePen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDisableBrush); +// int width = sp->m_SpinBoxParameters.spinBoxDownDisablePen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDisablePen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDisableBrush); + painter->setBrush(Qt::NoBrush); } else { downOption.state |= State_Enabled; if (down) { if (option->state & State_Sunken) { downOption.state |= State_Sunken; - int width = sp->m_SpinBoxParameters.spinBoxDownClickPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownClickPen); +// int width = sp->m_SpinBoxParameters.spinBoxDownClickPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownClickPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownClickBrush); } else { - if (focus) { + if (focus && focusEnable) { downOption.state |= State_MouseOver; - int width = sp->m_SpinBoxParameters.spinBoxDownFocusHoverPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownFocusHoverPen); +// int width = sp->m_SpinBoxParameters.spinBoxDownFocusHoverPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownFocusHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownFocusHoverBrush); } else { - int width = sp->m_SpinBoxParameters.spinBoxDownHoverPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownHoverPen); +// int width = sp->m_SpinBoxParameters.spinBoxDownHoverPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownHoverPen); painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownHoverBrush); } } } else { - int width = sp->m_SpinBoxParameters.spinBoxDownDefaultPen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDefaultPen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDefaultBrush); +// int width = sp->m_SpinBoxParameters.spinBoxDownDefaultPen.width(); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDefaultPen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDefaultBrush); +// painter->setPen(Qt::NoPen); + painter->setBrush(Qt::NoBrush); } } downRect.adjust(0, 0, 1 - width, 1 - width); @@ -4703,18 +5014,22 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setPen(Qt::NoPen); painter->drawPath(downPath); -// painter->drawRect(downRect); painter->restore(); } else { + //stepDown失效的情况下,到达阈值边界,不能继续down的场景 + if (!enable) { + painter->setBrush(Qt::NoBrush); + } QPainterPath downPath; painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_SpinBoxParameters.radius != 0); downOption.state = State_None; int width = sp->m_SpinBoxParameters.spinBoxDownDisablePen.width(); - painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDisablePen); - painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDisableBrush); +// painter->setPen(width <= 0 ? Qt::NoPen : sp->m_SpinBoxParameters.spinBoxDownDisablePen); +// painter->setBrush(sp->m_SpinBoxParameters.spinBoxDownDisableBrush); downRect.adjust(0, 0, 1 - width, 1 - width); downPath.moveTo(downRect.left(), downRect.bottom() - sp->m_SpinBoxParameters.radius); downPath.arcTo(downRect.left(), downRect.bottom() - sp->m_SpinBoxParameters.radius * 2, sp->m_SpinBoxParameters.radius * 2, @@ -4729,11 +5044,12 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q if(painter->pen().width() == 1 && sp->m_SpinBoxParameters.radius != 0) painter->translate(0.5, 0.5); + painter->setPen(Qt::NoPen); painter->drawPath(downPath); -// painter->drawRect(downRect); painter->restore(); } + //箭头本身,以图片形式实现 if (!enable) { upOption.state = State_None; downOption.state = State_None; @@ -5022,7 +5338,8 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp else { brush = sp->m_ScrollBarParameters.scrollBarSliderDefaultBrush; } - painter->setBrush(brush); + painter->setBrush(brush);//滑动条本身的颜色 +// qDebug() << "滑动条本身颜色 = " << brush.color() << " , radius = " << sp->m_ScrollBarParameters.radius; painter->drawRoundedRect(drawRect, sp->m_ScrollBarParameters.radius, sp->m_ScrollBarParameters.radius); painter->restore(); return; @@ -5033,6 +5350,8 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp case CE_ScrollBarAddLine: { if (const QStyleOptionSlider *bar = qstyleoption_cast(option)) { const bool active = bar->state & State_Active; + const bool enabled = bar->state & State_Enabled; + painter->save(); painter->setPen(Qt::NoPen); if (active) { @@ -5040,6 +5359,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } else { painter->setBrush(sp->m_ScrollBarParameters.scrollBarGrooveInactiveBrush); } + painter->setBrush(Qt::NoBrush); painter->drawRect(bar->rect); painter->restore(); painter->save(); @@ -5064,13 +5384,10 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp icon = QIcon::fromTheme(bar->direction == Qt::LeftToRight ? "ukui-down-symbolic" : "ukui-up-symbolic"); if (!icon.isNull()) { + QIcon::Mode mode = enabled ? QIcon::Normal : QIcon::Disabled; int iconSize = proxy()->pixelMetric(QStyle::PM_SmallIconSize, option, widget); - QPixmap pixmap = icon.pixmap(QSize(iconSize, iconSize), QIcon::Normal, QIcon::On); - - if(!sp->indicatorIconHoverNeedHighLight) - pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else - pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + QPixmap pixmap = icon.pixmap(QSize(iconSize, iconSize), mode, QIcon::On); + pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); painter->save(); drawColorPixmap(painter, color, pixmap); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); @@ -5085,6 +5402,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp case CE_ScrollBarSubLine: { if (const QStyleOptionSlider *bar = qstyleoption_cast(option)) { const bool active = bar->state & State_Active; + const bool enabled = bar->state & State_Enabled; painter->save(); painter->setPen(Qt::NoPen); if (active) { @@ -5092,6 +5410,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } else { painter->setBrush(sp->m_ScrollBarParameters.scrollBarGrooveInactiveBrush); } + painter->setBrush(Qt::NoBrush); painter->drawRect(bar->rect); painter->restore(); painter->save(); @@ -5116,13 +5435,10 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp icon = QIcon::fromTheme(bar->direction == Qt::LeftToRight ? "ukui-up-symbolic" : "ukui-down-symbolic"); if (!icon.isNull()) { + QIcon::Mode mode = enabled ? QIcon::Normal : QIcon::Disabled; int iconSize = proxy()->pixelMetric(QStyle::PM_SmallIconSize, option, widget); - QPixmap pixmap = icon.pixmap(QSize(iconSize, iconSize), QIcon::Normal, QIcon::On); - - if(!sp->indicatorIconHoverNeedHighLight) - pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else - pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + QPixmap pixmap = icon.pixmap(QSize(iconSize, iconSize), mode, QIcon::On); + pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); painter->save(); drawColorPixmap(painter, color, pixmap); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); @@ -5160,15 +5476,28 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp const bool enable = button->state & State_Enabled; const bool text = !button->text.isEmpty(); const bool icon = !button->icon.isNull(); + const bool on = button->state & State_On; + const bool sunken = button->state & State_Sunken; + const bool hover = button->state & State_MouseOver; const bool inactive = enable && !(button->state & State_Active); - + const bool inactiveNormal = inactive && !(hover || sunken || on); + bool isWindowButton = false; + bool isWindowColoseButton = false; + if (widget && widget->property("isWindowButton").isValid()) { + if (widget->property("isWindowButton").toInt() == 0x01) { + isWindowButton = true; + } + if (widget->property("isWindowButton").toInt() == 0x02) { + isWindowColoseButton = true; + } + } bool isImportant = false; if (widget && widget->property("isImportant").isValid()) { isImportant = widget->property("isImportant").toBool(); } QRect drawRect = button->rect; - int spacing = 8; + int spacing = 4; QStyleOption sub = *option; if (!sp->m_PushButtonParameters.iconHoverClickHighlight) { sub.state = enable ? State_Enabled : State_None; @@ -5199,16 +5528,20 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } QPixmap pixmap; if (icon) { - QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; - if (mode == QIcon::Normal && button->state & State_HasFocus) { + QIcon::Mode mode = QIcon::Normal;//button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + if (inactiveNormal) { + if(isWindowButton || isWindowColoseButton){ + mode = QIcon::Disabled; + } + } else if (mode == QIcon::Normal && button->state & State_HasFocus) { mode = QIcon::Active; } - QIcon::State state = QIcon::Off; + QIcon::State state = QIcon::On; if (button->state & State_On) { state = QIcon::On; } pixmap = button->icon.pixmap(button->iconSize, mode, state); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, button); + // pixmap = proxy()->generatedIconPixmap(mode, pixmap, button);多余,这里只需要获取按钮原始图标pixmap } QFontMetrics fm = button->fontMetrics; @@ -5238,13 +5571,27 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp if ((widget && !widget->property("useIconHighlightEffect").isValid()) || qqcButtonUseSymbolicIcon) { if (!sp->m_PushButtonParameters.iconHoverClickHighlight) { pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, &sub, widget); - } - else{ + } else { pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, &sub, widget); } } else { pixmap = HighLightEffect::generatePixmap(pixmap, &sub, widget); } + + if (!enable) + { + QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + if (mode == QIcon::Normal && button->state & State_HasFocus) { + mode = QIcon::Active; + } + QIcon::State state = QIcon::Off; + if (button->state & State_On) { + state = QIcon::On; + } + pixmap = proxy()->generatedIconPixmap(mode, pixmap, button); + } + + painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); /* @@ -5256,27 +5603,24 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } if (textRect.isValid()) { -// if (enable) { -// if (sp->m_PushButtonParameters.textHoverClickHighlight) { -// proxy()->drawItemText(painter, textRect, tf, button->palette, true, button->text, QPalette::HighlightedText); -// } else { -// proxy()->drawItemText(painter, textRect, tf, button->palette, true, button->text, QPalette::ButtonText); -// } -// } else { -// proxy()->drawItemText(painter, textRect, tf, button->palette, false, button->text, QPalette::ButtonText); -// } - QColor penColor = sp->m_PushButtonParameters.textDefaultColor; - if(!enable) + QColor penColor = sp->m_PushButtonParameters.textDefaultColor;//QPushButton内部text文本的颜色 + + if(!enable && !on) penColor = sp->m_PushButtonParameters.textDisableColor; - else if(button->state & QStyle::State_MouseOver || button->state & QStyle::State_Sunken) + else if (on) + penColor = sp->m_PushButtonParameters.textHighlightColor; + else if (button->state & QStyle::State_MouseOver || button->state & QStyle::State_Sunken) penColor = sp->m_PushButtonParameters.textHoverColor; + if (inactiveNormal) { + if(isWindowButton || isWindowColoseButton){ + penColor = sp->m_PushButtonParameters.textDisableColor; + } + } painter->setBrush(Qt::NoBrush); painter->setPen(QPen(penColor)); // painter->drawText(textRect, button->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); painter->drawText(textRect,tf, button->text); -// proxy()->drawItemText(painter, textRect, tf, button->palette, false, button->text, sp->m_PushButtonParameters.textColor); - } return; } @@ -5292,7 +5636,27 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp const bool arrow = tb->features & QStyleOptionToolButton::MenuButtonPopup; const bool ha = tb->features & QStyleOptionToolButton::Arrow; const bool enable = tb->state & State_Enabled; + const bool on = option->state & State_On; + const bool sunken = option->state & State_Sunken; + const bool hover = option->state & State_MouseOver; const bool inactive = enable && !(tb->state & State_Active); + const bool inactiveNormal = inactive && !(hover || sunken || on); + + bool isWindowButton = false; + bool isWindowColoseButton = false; + if (widget && widget->property("isWindowButton").isValid()) { + if (widget->property("isWindowButton").toInt() == 0x01) { + isWindowButton = true; + } + if (widget->property("isWindowButton").toInt() == 0x02) { + isWindowColoseButton = true; + } + } + bool isImportant = false; + if (widget && widget->property("isImportant").isValid()) { + isImportant = widget->property("isImportant").toBool(); + } + QFontMetrics fm = tb->fontMetrics; int Margin_Height = sp->Button_MarginHeight; int ToolButton_MarginWidth = sp->ToolButton_MarginWidth; @@ -5304,10 +5668,15 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp QRect drawRect = tb->rect; QStyleOption sub = *option; + if (!sp->m_ToolButtonParameters.iconHoverClickHighlight) { - sub.state = enable ? State_Enabled : State_None; + sub.state &= enable ? ((option->state & State_Active) ? (State_Enabled | State_Active) : State_Enabled) : State_None; + } else { sub.state = option->state; + if (isImportant && !(tb->features & QStyleOptionButton::Flat)) { + sub.state = option->state | State_On; + } } if (arrow) { @@ -5333,19 +5702,32 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp int alignment = Qt::AlignCenter; if (proxy()->styleHint(SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextShowMnemonic; - int textDis = fm.boundingRect(option->rect, alignment, tb->text).width() + 2; + + // int textDis = fm.boundingRect(option->rect, alignment, tb->text).width() + 2; + + int textDis = 0; + if (text) { + QString displayText = tb->text; + if (displayText.contains("&")) { + displayText.replace("&", "&&"); + } + QRect textBoundingRect = fm.boundingRect(option->rect, alignment, displayText); + textDis = textBoundingRect.width() + 2; + } + QPixmap pixmap; if (icon) { - QIcon::State state = tb->state & State_On ? QIcon::On : QIcon::Off; + QIcon::State state = QIcon::On;//tb->state & State_On ? QIcon::On : QIcon::Off; QIcon::Mode mode; - if (!enable) + if (inactiveNormal && (isWindowButton || isWindowColoseButton)) { mode = QIcon::Disabled; + } else if ((tb->state & State_MouseOver) && (tb->state & State_AutoRaise)) mode = QIcon::Active; else mode = QIcon::Normal; pixmap = tb->icon.pixmap(tb->iconSize, mode, state); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, tb); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, tb); } if (tb->toolButtonStyle == Qt::ToolButtonTextOnly && text) { @@ -5388,24 +5770,23 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } if (textRect.isValid()) { -// if (enable) { -// if (sp->m_ToolButtonParameters.textHoverClickHighlight) { -// proxy()->drawItemText(painter, textRect, alignment, tb->palette, true, tb->text, QPalette::HighlightedText); -// } else { -// proxy()->drawItemText(painter, textRect, alignment, tb->palette, true, tb->text, QPalette::ButtonText); -// } -// } else { -// proxy()->drawItemText(painter, textRect, alignment, tb->palette, false, tb->text, QPalette::ButtonText); -// } QColor penColor = sp->m_ToolButtonParameters.textDefaultColor; - if(!enable) + if(!enable && !on) penColor = sp->m_ToolButtonParameters.textDisableColor; + else if (on) + penColor = sp->m_PushButtonParameters.textHighlightColor; else if(tb->state & QStyle::State_MouseOver || tb->state & QStyle::State_Sunken) penColor = sp->m_ToolButtonParameters.textHoverColor; painter->setBrush(Qt::NoBrush); painter->setPen(QPen(penColor)); painter->drawText(textRect, tb->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter)); + + if (inactiveNormal) { + if(isWindowButton || isWindowColoseButton){ + penColor = sp->m_ToolButtonParameters.textDisableColor; + } + } } if (iconRect.isValid()) { @@ -5444,6 +5825,18 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } else { pixmap = HighLightEffect::generatePixmap(pixmap, &sub, widget); } + if (!enable) + { + QIcon::State state = tb->state & State_On ? QIcon::On : QIcon::Off; + QIcon::Mode mode; + if (!enable) + mode = QIcon::Disabled; + else if ((tb->state & State_MouseOver) && (tb->state & State_AutoRaise)) + mode = QIcon::Active; + else + mode = QIcon::Normal; + pixmap = proxy()->generatedIconPixmap(mode, pixmap, tb); + } painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); /* @@ -5474,7 +5867,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp sp->initConfigTabWidgetParameters(isUseDarkPalette(), option, widget); bool selected = tab->state & State_Selected; bool hover = tab->state & State_MouseOver; - bool click = tab->state & (State_On | State_Sunken); + bool sunkenOn = tab->state & ( State_Sunken); QRect drawRect = option->rect; QTransform rotMatrix; bool flip = false; @@ -5540,39 +5933,153 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } QPainterPath path; QPainterPath penPath; - if (selected) { - drawRect.adjust(0, 0, tabOverlap, 0); - path.moveTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); - path.arcTo(QRect(drawRect.left(), drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); - path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); - path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, - TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, -90); - path.lineTo(drawRect.right() + TabBarTab_Radius, drawRect.bottom()); - path.arcTo(QRect(drawRect.right(), drawRect.bottom() - TabBarTab_Radius * 2, - TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, -90); - path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); - path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.top(), - TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); - path.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); - -// penPath.moveTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); -// penPath.arcTo(QRect(drawRect.left(), drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); -// penPath.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); -// penPath.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, -// TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, -90); -// penPath.moveTo(drawRect.right() - moveWidth + TabBarTab_Radius, drawRect.bottom()); -// penPath.arcTo(QRect(drawRect.right() - moveWidth, drawRect.bottom() - TabBarTab_Radius * 2, -// TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, -90); -// penPath.lineTo(drawRect.right() - moveWidth, drawRect.top() + TabBarTab_Radius); -// penPath.arcTo(QRect(drawRect.right() - moveWidth - TabBarTab_Radius * 2, drawRect.top(), -// TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); -// penPath.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); - } else if (hover){ - - path.addRoundedRect(drawRect, TabBarTab_Radius, TabBarTab_Radius); - + if (widget != NULL && qobject_cast(widget)) { + const auto *tabbar = qobject_cast(widget); + int select_index = tabbar->currentIndex(); + int now_index = tabbar->tabAt(QPoint(drawRect.x(),drawRect.y())); + int tab_count = tabbar->count(); + + if (qAppName() == "kylin-nm" || qAppName() == "ukui-volume-control-applet-qt") { + //BUG125147 BUG150441.Special in kylin-nm and ukui-volume-control-applet-qt.Set right angle on tabbar first index and last index + drawRect.adjust(0, 0, tabOverlap, 0); + if (now_index == 0) { + if (selected) { + path.moveTo(drawRect.left(), drawRect.top()); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right() + TabBarTab_Radius, drawRect.bottom()); + path.arcTo(QRect(drawRect.right(), drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, -90); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); + path.lineTo(drawRect.left(), drawRect.top()); + } else { + path.moveTo(drawRect.left(), drawRect.top()); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right() - TabBarTab_Radius, drawRect.bottom()); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, 90); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right(), drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, -90); + path.lineTo(drawRect.left(), drawRect.top()); + } + } else if (now_index == tab_count - 1) { + if (selected) { + path.moveTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left(), drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); + path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); + path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, -90); + path.lineTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top()); + path.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + } else { + path.moveTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top()); + path.lineTo(drawRect.left() - TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, -90); + path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); + path.arcTo(QRect(drawRect.left(), drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, 90); + path.lineTo(drawRect.right(), drawRect.bottom()); + } + } else { + path.addRect(drawRect); + } + } else { + if (selected) { + drawRect.adjust(0, 0, tabOverlap, 0); + path.moveTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left(), drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); + path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); + path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, -90); + path.lineTo(drawRect.right() + TabBarTab_Radius, drawRect.bottom()); + path.arcTo(QRect(drawRect.right(), drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, -90); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); + path.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + } else { + if (select_index - now_index == 1) { + //select rect left + drawRect.adjust(0, 0, tabOverlap, 0); + if (now_index == 0) { + path.moveTo(drawRect.left(), drawRect.top() + TabBarTab_Radius); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right() - TabBarTab_Radius, drawRect.bottom()); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, 90); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right(), drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, -90); + path.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left(), drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); + } else { + path.moveTo(drawRect.left(), drawRect.top()); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right() - TabBarTab_Radius, drawRect.bottom()); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 270, 90); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right(), drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, -90); + path.lineTo(drawRect.left(), drawRect.top()); + } + } else if(select_index - now_index == -1) { + //select rect right + drawRect.adjust(0, 0, tabOverlap, 0); + if (now_index == tab_count - 1) { + path.moveTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); + path.lineTo(drawRect.left() - TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, -90); + path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); + path.arcTo(QRect(drawRect.left(), drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, 90); + path.lineTo(drawRect.right(), drawRect.bottom()); + } else { + path.moveTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top()); + path.lineTo(drawRect.left() - TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left() - TabBarTab_Radius * 2, drawRect.top(), TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, -90); + path.lineTo(drawRect.left(), drawRect.bottom() - TabBarTab_Radius); + path.arcTo(QRect(drawRect.left(), drawRect.bottom() - TabBarTab_Radius * 2, + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 180, 90); + path.lineTo(drawRect.right(), drawRect.bottom()); + } + } else { + if (now_index == 0) { + drawRect.adjust(0, 0, tabOverlap, 0); + path.moveTo(drawRect.left(), drawRect.top() + TabBarTab_Radius); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top()); + path.lineTo(drawRect.left() + TabBarTab_Radius, drawRect.top()); + path.arcTo(QRect(drawRect.left(), drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 90, 90); + } else if (now_index == tab_count - 1) { + drawRect.adjust(0, 0, tabOverlap, 0); + path.moveTo(drawRect.right(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.top() + TabBarTab_Radius); + path.arcTo(QRect(drawRect.right() - TabBarTab_Radius * 2, drawRect.top(), + TabBarTab_Radius * 2, TabBarTab_Radius * 2), 0, 90); + path.lineTo(drawRect.left(), drawRect.top()); + path.lineTo(drawRect.left(), drawRect.bottom()); + path.lineTo(drawRect.right(), drawRect.bottom()); + } else { + path.addRect(drawRect); + } + } + } + } } else { - path.addRect(drawRect); } @@ -5588,13 +6095,18 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp // penPath.lineTo(drawRect.right(), drawRect.bottom() - penWidth); // penPath.lineTo(drawRect.left(), drawRect.bottom() - penWidth); - if(click) { + /** + * v11设计稿里面是错误的,click点击颜色和selected颜色不一样, + * 实际上click点击后(sunkenon)之后,就是selected状态,两者颜色应该一致才行 + * + * selected status handling first + */ + if (selected) { + painter->setBrush(sp->m_TabWidgetParameters.tabBarSelectBrush); + } else if (sunkenOn) { penWidth = sp->m_TabWidgetParameters.tabBarClickPen.width(); painter->setBrush(sp->m_TabWidgetParameters.tabBarClickBrush); pen = sp->m_TabWidgetParameters.tabBarClickPen; - } - else if (selected) { - painter->setBrush(sp->m_TabWidgetParameters.tabBarSelectBrush); } else if (hover) { penWidth = sp->m_TabWidgetParameters.tabBarHoverPen.width(); painter->setBrush(sp->m_TabWidgetParameters.tabBarHoverBrush); @@ -5604,7 +6116,10 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->setBrush(sp->m_TabWidgetParameters.tabBarDefaultBrush); pen = sp->m_TabWidgetParameters.tabBarDefaultPen; } - if((tab->state & State_Enabled) && (tab->state & State_HasFocus)){ + + bool focusEnable = sp->m_TabWidgetParameters.getFocusEnable(); + + if((tab->state & State_Enabled) && (tab->state & State_HasFocus) && focusEnable){ penWidth = sp->m_TabWidgetParameters.tabBarFocusPen.width(); pen = sp->m_TabWidgetParameters.tabBarFocusPen; } @@ -5627,6 +6142,9 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp case CE_TabBarTabLabel: { if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { + + sp->initConfigTabWidgetParameters(isUseDarkPalette(), option, widget); + int iconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); bool verticalTabs = tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularEast || tab->shape == QTabBar::TriangularWest; @@ -5667,11 +6185,16 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp if (!tab->icon.isNull()) { painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QIcon::Mode mode = (tab->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; + QIcon::Mode mode = QIcon::Normal;//(tab->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = tab->icon.pixmap(widget ? widget->window()->windowHandle() : 0, tab->iconSize, mode, (tab->state & State_Selected) ? QIcon::On : QIcon::Off); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); QPixmap drawPixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + if (!(tab->state & State_Enabled)) + { + mode = (tab->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; + pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + } painter->drawPixmap(iconRect.x(), iconRect.y(), drawPixmap); painter->restore(); } @@ -5682,10 +6205,12 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp //draw separate line if (useSeparateLine && sp->TabBar_SplitLine) { if (!(tab->state & State_Selected)) { - int dis = ((verticalTabs ? drawRect.width() : drawRect.height()) - iconSize) / 2; + // int dis = ((verticalTabs ? drawRect.width() : drawRect.height()) - iconSize) / 2; + int dis = ((verticalTabs ? drawRect.width() : drawRect.height()) - sp->TabBar_SplitLine_Height) / 2; painter->save(); painter->resetTransform(); - painter->setPen(tab->palette.color(QPalette::Active, QPalette::Midlight)); + // painter->setPen(tab->palette.color(QPalette::Active, QPalette::Midlight)); + painter->setPen(sp->m_TabWidgetParameters.tabBarDividerPen); painter->setBrush(Qt::NoBrush); if (verticalTabs) { if (tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) { @@ -5715,9 +6240,9 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if (!comboBox->currentIcon.isNull()) { - QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + QIcon::Mode mode = QIcon::Normal;//comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); QRect iconRect; if (comboBox->direction == Qt::RightToLeft) { iconRect.setRect(editRect.right() - comboBox->iconSize.width(), editRect.y(), comboBox->iconSize.width(), editRect.height()); @@ -5727,6 +6252,11 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp editRect.setRect(editRect.x() + iconRect.width() + 8, editRect.y(), editRect.width() - iconRect.width() - 8, editRect.height()); } pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + if (!(comboBox->state & State_Enabled)) + { + mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + } proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); } @@ -5784,10 +6314,16 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); if (!button->icon.isNull()) { - QIcon::Mode mode = enable ? QIcon::Normal : QIcon::Disabled; + QIcon::Mode mode = QIcon::Normal;//enable ? QIcon::Normal : QIcon::Disabled; pixmap = button->icon.pixmap(button->iconSize, mode); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, button); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, button); pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, button, widget); + if (!enable) + { + mode = enable ? QIcon::Normal : QIcon::Disabled; + pixmap = proxy()->generatedIconPixmap(mode, pixmap, button); + } + proxy()->drawItemPixmap(painter, button->rect, alignment, pixmap); if (button->direction == Qt::RightToLeft) textRect.setRight(textRect.right() - button->iconSize.width() - sp->IconButton_Distance); @@ -5795,8 +6331,18 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp textRect.setLeft(textRect.left() + button->iconSize.width() + sp->IconButton_Distance); } if (!button->text.isEmpty()){ - proxy()->drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic, - button->palette, button->state & State_Enabled, button->text, QPalette::WindowText); + QBrush penColor; + if(widget && qobject_cast(widget)) + penColor = enable ? sp->m_RadioButtonParameters.radioButtonTextBrush : sp->m_RadioButtonParameters.radioButtonTextDisableBrush; + else if(widget && qobject_cast(widget)) + penColor = enable ? sp->m_CheckBoxParameters.checkBoxTextBrush : sp->m_CheckBoxParameters.checkBoxTextDisableBrush; + + painter->setBrush(Qt::NoBrush); + painter->setPen(QPen(penColor.color())); + painter->drawText(textRect, button->text, QTextOption(Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter)); + +// proxy()->drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic, +// button->palette, button->state & State_Enabled, button->text, QPalette::WindowText); } painter->restore(); return; @@ -5878,6 +6424,8 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } sp->initConfigMenuParameters(isUseDarkPalette(), option, widget); + bool focusEnable = sp->m_MenuParameters.getFocusEnable(); + QRect drawRect = menuItem->rect; if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { painter->save(); @@ -5899,18 +6447,30 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp //if it's comobobox popup, set combobox popup size rect if (isComboBox) { int MenuItem_HMargin = proxy()->pixelMetric(PM_MenuHMargin, option, widget); + // qDebug() << "左右边距 = " << MenuItem_HMargin; drawRect.adjust(MenuItem_HMargin, sp->ComboBox_VMargin, -MenuItem_HMargin, -1 * sp->ComboBox_VMargin); } - if (enable && (selected | sunken)) { - painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - painter->setPen(Qt::NoPen); - painter->setBrush(sp->m_MenuParameters.menuItemSelectBrush); - painter->drawRoundedRect(drawRect, sp->m_MenuParameters.itemRadius, sp->m_MenuParameters.itemRadius); - painter->restore(); + if (enable) { + if (sunken) { + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_MenuParameters.menuItemClickBrush); + painter->drawRoundedRect(drawRect, sp->m_MenuParameters.itemRadius, sp->m_MenuParameters.itemRadius); + painter->restore(); + } else if (selected) { + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setPen(Qt::NoPen); + painter->setBrush(sp->m_MenuParameters.menuItemSelectBrush); + painter->drawRoundedRect(drawRect, sp->m_MenuParameters.itemRadius, sp->m_MenuParameters.itemRadius); + painter->restore(); + } } - if(enable && focus){ + + + if(enable && focus && focusEnable) { painter->save(); painter->setRenderHint(QPainter::Antialiasing); painter->setPen(sp->m_MenuParameters.menuItemFocusPen); @@ -5940,11 +6500,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp QIcon::Mode mode = enable ? QIcon::Active : QIcon::Disabled; QPixmap pixmap = icon.pixmap(iconWidth, iconWidth, mode , QIcon::On); QPixmap drawPixmap; -// if(!isComboBox && !sp->indicatorIconHoverNeedHighLight) -// drawPixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); -// else - drawPixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); - + drawPixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); QRect iconRect(drawRect.x(), drawRect.y() + (drawRect.height() - iconWidth) / 2, iconWidth, iconWidth); iconRect = visualRect(menuItem->direction, drawRect, iconRect); painter->save(); @@ -5961,11 +6517,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp QIcon::Mode mode = enable ? (selected ? QIcon::Active : QIcon::Normal) : QIcon::Disabled; QPixmap pixmap = icon.pixmap(iconWidth, iconWidth, mode , QIcon::On); QPixmap drawPixmap; -// if(!isComboBox && !sp->indicatorIconHoverNeedHighLight) -// drawPixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); -// else - drawPixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); - + drawPixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); QRect iconRect(drawRect.x(), drawRect.y() + (drawRect.height() - iconWidth) / 2, iconWidth, iconWidth); iconRect = visualRect(menuItem->direction, drawRect, iconRect); painter->save(); @@ -5986,16 +6538,40 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } else if(menuItem->maxIconWidth != 0) { hasIcon = true; } + bool oneRow = false; + bool twoRow = false; + auto *menu = qobject_cast(widget); + auto *combobox = qobject_cast(widget); - if (menuItem->menuHasCheckableItems || hasIcon) { + if(menu){ + QList actions = menu->actions(); + foreach (QAction *a, actions) { + if(a->isChecked() && (!a->icon().isNull() && a->isIconVisibleInMenu())) + twoRow = true; + else if(a->isChecked() || (!a->icon().isNull() && a->isIconVisibleInMenu()) || hasIcon) + oneRow = true; + } + } else if(combobox) + { + if(hasIcon && menuItem->menuHasCheckableItems) + twoRow = true; + else if(hasIcon || menuItem->menuHasCheckableItems) + oneRow = true; + } + + if(twoRow){ int iconWidth = proxy()->pixelMetric(PM_SmallIconSize, option, widget); - int w = (menuItem->menuHasCheckableItems ? iconWidth : 0) + - (hasIcon ? iconWidth : 0) + - ((menuItem->menuHasCheckableItems && hasIcon) ? MenuItem_Spacing : 0); + int w = 2 * iconWidth + MenuItem_Spacing; + drawRect = visualRect(menuItem->direction, drawRect, drawRect.adjusted(w + MenuItem_Spacing, 0, 0, 0)); - } else { + } else if(oneRow) + { + int iconWidth = proxy()->pixelMetric(PM_SmallIconSize, option, widget); + int w = iconWidth; + + drawRect = visualRect(menuItem->direction, drawRect, drawRect.adjusted(w + MenuItem_Spacing, 0, 0, 0)); + } else drawRect = drawRect.adjusted(4, 0, -4, -0);//去除item边框 - } if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) { @@ -6014,17 +6590,25 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp if (hasIcon) { int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); - QIcon::Mode mode = enable ? (selected ? QIcon::Active : QIcon::Normal) : QIcon::Disabled; + QIcon::Mode mode = selected ? QIcon::Active : QIcon::Normal; QIcon::State state = menuItem->checked ? QIcon::On : QIcon::Off; QPixmap pixmap = menuItem->icon.pixmap(iconSize, mode, state); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); QPixmap target; -// if(!isComboBox && !sp->indicatorIconHoverNeedHighLight) -// target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); -// else - target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + QString iconName = menuItem->icon.name(); + if (iconName.contains("symbolic", Qt::CaseInsensitive)) { + target = HighLightEffect::filledSymbolicColoredOrdinaryGeneratePixmap(pixmap, option, widget); + } else { + target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + } + if (!enable) + { + mode = enable ? (selected ? QIcon::Active : QIcon::Normal) : QIcon::Disabled; + state = menuItem->checked ? QIcon::On : QIcon::Off; + target = proxy()->generatedIconPixmap(mode, target, option); + } int recX = drawRect.x() - (MenuItem_Spacing + smallIconSize); QRect iconRect(recX, drawRect.y() + (drawRect.height() - smallIconSize)/2, smallIconSize, smallIconSize); iconRect = visualRect(menuItem->direction, drawRect, iconRect); @@ -6042,9 +6626,9 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->save(); if (enable) { if (selected | sunken) { - painter->setPen(sp->m_MenuParameters.menuTextHoverPen); + painter->setPen(sp->m_MenuParameters.menuItemShortCutPen); } else { - painter->setPen(menuItem->palette.color(QPalette::Active, QPalette::Text)); + painter->setPen(sp->m_MenuParameters.menuItemShortCutPen); } } else { painter->setPen(menuItem->palette.color(QPalette::Disabled, QPalette::Text)); @@ -6063,11 +6647,14 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp textToDraw_flags |= Qt::AlignRight; else textToDraw_flags |= Qt::AlignLeft | Qt::AlignAbsolute; + QFont font = menuItem->font; + font.setPointSize(font.pointSize() - 2); + painter->setFont(font); painter->drawText(drawRect, textToDraw_flags, textToDraw); } QFont font = menuItem->font; - font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF()); +// font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF()); if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); painter->setFont(font); @@ -6079,6 +6666,38 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp QFontMetrics metrics(font); QString elidedText = metrics.elidedText(text, Qt::ElideRight, drawRect.width()); + bool selectedElidedText = false; + bool needShowToolTip = false; + if(widget && widget->property("needShowToolTip").isValid() && widget->property("needShowToolTip").toBool()) + needShowToolTip = true; + if (enable) { + if (selected | sunken) { + painter->setPen(sp->m_MenuParameters.menuTextHoverPen); + if(needShowToolTip){ + auto w = qobject_cast(widget); + if(combobox) + w = qobject_cast(combobox->view()); + + if(elidedText != text){ + if(w && const_cast(w)){ + const_cast(w)->setToolTip(text); + if(combobox){ + selectedElidedText = true; + } + } + } + else{ + QToolTip::hideText(); + const_cast(w)->setToolTip(QString()); + selectedElidedText = false; + } + } + } else { + painter->setPen(menuItem->palette.color(QPalette::Active, QPalette::Text)); + } + } else { + painter->setPen(menuItem->palette.color(QPalette::Disabled, QPalette::Text)); + } painter->drawText(drawRect, text_flags, elidedText); painter->restore(); @@ -6209,13 +6828,14 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->setPen(width <= 0 ? Qt::NoPen : sp->m_ProgressBarParameters.progressBarGrooveDefaultPen); painter->setBrush(sp->m_ProgressBarParameters.progressBarGrooveDefaultBrush); } - if(width == 1 && sp->m_ProgressBarParameters.radius != 0) - painter->translate(0.5, 0.5); + // if(width == 1 && sp->m_ProgressBarParameters.radius != 0) + // painter->translate(0.5, 0.5); + //内缩1px painter->drawRoundedRect(option->rect.adjusted(width, width, -width, -width), sp->m_ProgressBarParameters.radius, sp->m_ProgressBarParameters.radius); painter->restore(); return; } - //绘制进度条的进度内容部分 + //绘制进度条的进度内容部分 pb here-2 case CE_ProgressBarContents: { if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { @@ -6225,126 +6845,106 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp const bool inverted = pb->invertedAppearance;//是否反向 const bool indeterminate = (pb->minimum == 0 && pb->maximum == 0);//是否为indeterminate状态 - bool reverse = (!vertical && (pb->direction == Qt::RightToLeft)) || vertical; - if (inverted) - reverse = !reverse; - QBrush brush; - - if (sp->m_ProgressBarParameters.progressBarContentBrush.style() == Qt::LinearGradientPattern) { - QLinearGradient linearGradient; - if(vertical){ - linearGradient.setStart(pb->rect.bottomRight()); - linearGradient.setFinalStop(pb->rect.topLeft()); - } - else{ - linearGradient.setStart(pb->rect.topLeft()); - linearGradient.setFinalStop(pb->rect.bottomRight()); - } - linearGradient.setStops(sp->m_ProgressBarParameters.progressBarContentBrush.gradient()->stops()); - brush = QBrush(linearGradient); - } else { - brush = sp->m_ProgressBarParameters.progressBarContentBrush; - } - - - // if (QVariantAnimation *animation = m_animation_helper->animation(option->styleObject)) { - // if(animation->state() == QAbstractAnimation::Running){ - // bool forward = animation->direction() == QAbstractAnimation::Forward; - // if(!forward) - // reverse = !reverse; - - // if (sp->m_ProgressBarParameters.progressBarContentBrush.style() == Qt::LinearGradientPattern) { - // QLinearGradient linearGradient; - // linearGradient.setStops(sp->m_ProgressBarParameters.progressBarContentBrush.gradient()->stops()); - // if (vertical) { - // if (reverse) { - // linearGradient.setStart(pb->rect.bottomLeft()); - // linearGradient.setFinalStop(pb->rect.topLeft()); - // } else { - // linearGradient.setStart(pb->rect.topLeft()); - // linearGradient.setFinalStop(pb->rect.bottomLeft()); - // } - // } else { - // if (reverse) { - // linearGradient.setStart(pb->rect.topRight()); - // linearGradient.setFinalStop(pb->rect.topLeft()); - // } else { - // linearGradient.setStart(pb->rect.topLeft()); - // linearGradient.setFinalStop(pb->rect.topRight()); - // } - // } - // brush = QBrush(linearGradient); - // } - // } - // } double curAnimationValue; - QVariantAnimation *animation = m_animation_helper->animation(option->styleObject); + // QVariantAnimation *animation = m_animation_helper->animation(option->styleObject); + + QWidget* widgetKey = const_cast(widget); + QVariantAnimation *animation = m_animation_helper->getAnimation(widgetKey); - // bool enableBarAnimation = !disableProgressBarAnimationList().contains(qAppName());//是否启用进度条动画 - bool enableBarAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); + // qDebug() << "animation 空:" << (animation ? "非空":"空"); - if (enableBarAnimation) { - if (animation) { - if (animation->state() == QAbstractAnimation::Running) { - if (indeterminate) {//indeterminate状态,动画处理 - bool forward = animation->direction() == QAbstractAnimation::Forward; - if(!forward) - reverse = !reverse; - - if (sp->m_ProgressBarParameters.progressBarContentBrush.style() == Qt::LinearGradientPattern) { - QLinearGradient linearGradient; - linearGradient.setStops(sp->m_ProgressBarParameters.progressBarContentBrush.gradient()->stops()); - if (vertical) { - if (reverse) { - linearGradient.setStart(pb->rect.bottomLeft()); - linearGradient.setFinalStop(pb->rect.topLeft()); - } else { - linearGradient.setStart(pb->rect.topLeft()); - linearGradient.setFinalStop(pb->rect.bottomLeft()); - } - } else { - if (reverse) { - linearGradient.setStart(pb->rect.topRight()); - linearGradient.setFinalStop(pb->rect.topLeft()); - } else { - linearGradient.setStart(pb->rect.topLeft()); - linearGradient.setFinalStop(pb->rect.topRight()); - } - } - brush = QBrush(linearGradient); - } - } else { //normal状态,动画处理 - curAnimationValue = animation->currentValue().toDouble(); - } - } - } + // bool enableBarAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); + + bool enableBarAnimation = true; //循环进度条,默认永远开启动画 + if (!indeterminate) { //普通进度条,默认不开启动画,除非应用设置 w->property("animation",true); + enableBarAnimation = (widget && widget->property("animation").isValid() && widget->property("animation").toBool()) ? true : false; } + if (enableBarAnimation && animation && animation->state() == QAbstractAnimation::Running) { + curAnimationValue = animation->currentValue().toDouble(); + } painter->save(); painter->setRenderHint(QPainter::Antialiasing, sp->m_ProgressBarParameters.radius != 0); QColor penColor = sp->m_ProgressBarParameters.progressBarContentPen.color(); int width = (penColor.alpha() == 0 || penColor == Qt::NoPen) ? 0 : sp->m_ProgressBarParameters.progressBarContentPen.width(); painter->setPen(width > 0 ? sp->m_ProgressBarParameters.progressBarContentPen : Qt::NoPen); - painter->setBrush(brush); + width = (sp->m_ProgressBarParameters.progressBarGrooveDefaultPen.color().alpha() == 0 || sp->m_ProgressBarParameters.progressBarGrooveDefaultPen.color() == Qt::NoPen) ? 0 : sp->m_ProgressBarParameters.progressBarGrooveDefaultPen.width(); - QRect rect = width > 0 ? pb->rect.adjusted(width + 1, width + 1, -1 * width, -1 * width) : pb->rect; + // QRect rect = width > 0 ? pb->rect.adjusted(width + 1, width + 1, -1 * width, -1 * width) : pb->rect; + QRect rect = pb->rect; + if (!indeterminate) { + rect = width > 0 ? pb->rect.adjusted(width, width, -1 * width, -1 * width) : pb->rect; + } + if(pb->rect.width() == 0) rect.setWidth(0); if(pb->rect.height() == 0) rect.setHeight(0); // painter->drawRoundedRect(rect, sp->m_ProgressBarParameters.radius, sp->m_ProgressBarParameters.radius); + + + //normal状态默认为contentBrush + QBrush brush = sp->m_ProgressBarParameters.progressBarContentBrush; + + // indeterminate状态的移动滑片,需要用渐变色 + if (indeterminate) { + + QLinearGradient gradient; + + //根据进度条状态,设置渐变方向 + if (vertical) {//垂直方向 + + gradient = QLinearGradient(rect.center().x(),rect.bottom(),rect.center().x(),rect.top()); + } else {//水平方向 + + gradient = QLinearGradient(rect.right(),rect.center().y(),rect.left(),rect.center().y()); + } + // QColor startColor(0x6C,0xEC,0xFF); + // QColor endColor(0x36,0x76,0xF5); + // gradient.setColorAt(0.0,startColor); + // gradient.setColorAt(1.0,endColor); + //循环进度条滑片颜色 + QColor baseColor = sp->m_ProgressBarParameters.progressSliderBrush.color(); + int r = baseColor.red(); + int g = baseColor.green(); + int b = baseColor.blue(); + + calculateHighColor(r); + calculateHighColor(g); + calculateHighColor(b); + + QColor targetColor(r, g, b); + + // QColor startColor(0x6C,0xEC,0xFF); + // QColor endColor(0x36,0x76,0xF5); + gradient.setColorAt(0.0, baseColor); + gradient.setColorAt(1.0, targetColor); + + brush = QBrush(gradient); + } + + painter->setBrush(brush); + + //进度条已划过区域(任意时刻只有normal,indeterminate两种状态其一) if (rect.width() > 0 && rect.height() > 0) { painter->drawRoundedRect(rect, sp->m_ProgressBarParameters.radius, sp->m_ProgressBarParameters.radius); + // qDebug() << "进度条状态:" << (indeterminate?"indeterminate":"Normal") << ",radius:" << sp->m_ProgressBarParameters.radius << ",brush = (" << + // painter->brush().color() << "," << painter->brush().color().name() <<"),pen = " << painter->pen(); } - if (!indeterminate && enableBarAnimation && animation) { - QRect sliderRectScope = vertical ? rect.adjusted(0,1,0,-1) : rect.adjusted(1,0,-1,0);//滑片作用区域 + QRect sliderRectScope = vertical ? rect.adjusted(0,1,0,-1) : rect.adjusted(1,0,-1,0);//滑片作用区域 + + int conditionWidth = vertical ? sliderRectScope.height() : sliderRectScope.width(); + + //Normal状态的亮片绘制 + if (!indeterminate && enableBarAnimation && animation && m_animation_helper->meetCondition(conditionWidth)) { + // QRect sliderRectScope = vertical ? rect.adjusted(0,1,0,-1) : rect.adjusted(1,0,-1,0);//滑片作用区域 if (rect.width() == 0) { sliderRectScope.setWidth(0); @@ -6372,27 +6972,38 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp if (inverted) {//垂直和反向,从上往下 targetX = sliderRectScope.x(); targetY = sliderRectScope.y() - sliderWidth + curAnimationValue*baseHeight; + + pbOrientation = UKUIElementStatus::VertivalInverted; } else {//仅垂直,从下往上 targetX = sliderRectScope.x(); targetY = sliderRectScope.y() + sliderRectScope.height() - curAnimationValue*baseHeight; + + pbOrientation = UKUIElementStatus::VerticalForward; } - } else { + + } else { //水平 targetW = sliderWidth; targetH = sliderRectScope.height(); auto baseWidth = sliderWidth + totalBarWidth; + if (inverted) {//仅反向 targetX = sliderRectScope.right() - curAnimationValue*baseWidth; targetY = sliderRectScope.y(); + + pbOrientation = UKUIElementStatus::HorizontalInverted; + } else {//普通状态 targetX = (sliderRectScope.x()-sliderWidth) + curAnimationValue*baseWidth; targetY = sliderRectScope.y(); + + pbOrientation = UKUIElementStatus::HorizontalForward; } } QRect targetRect(targetX,targetY,targetW,targetH); - // //滑片有效作用域 + // 滑片有效作用域 QPainterPath path; path.addRoundedRect(rect, sp->m_ProgressBarParameters.radius, sp->m_ProgressBarParameters.radius); QRegion effectRegion(path.toFillPolygon().toPolygon()); @@ -6401,19 +7012,59 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); - auto radius = targetRect.width() >= targetRect.height() ? targetRect.width() : targetRect.height(); - QRadialGradient gradient(targetRect.center(),0.6*radius,targetRect.center()); - QColor targetColor = sp->m_ProgressBarParameters.progressBarContentBrush.color().name(); - //滑片颜色 - QColor startColor(Qt::white); - gradient.setColorAt(0,startColor); - gradient.setColorAt(1,targetColor); + QLinearGradient gradient;//用于滑动光片绘制的渐变色 + bool stopStatus = false;//用来标记当前是否恰好处于结束状态 + + //根据进度条状态,初始化渐变方向,以及初始化 stopStatus判断 + switch (pbOrientation) { + + case UKUIElementStatus::VertivalInverted: { + + gradient = QLinearGradient(targetRect.center().x(),targetRect.top(),targetRect.center().x(),targetRect.bottom()); + if (targetY >= (pb->rect.y()+pb->rect.height())) { + stopStatus = true; + } + break; + } + case UKUIElementStatus::VerticalForward: { + + gradient = QLinearGradient(targetRect.center().x(),targetRect.bottom(),targetRect.center().x(),targetRect.top()); + if (targetY <= (pb->rect.y()-sliderWidth)) { + stopStatus = true; + } + break; + } + case UKUIElementStatus::HorizontalInverted: { + + gradient = QLinearGradient(targetRect.right(),targetRect.center().y(),targetRect.left(),targetRect.center().y()); + if (targetX <= (pb->rect.x()-sliderWidth)) { + stopStatus = true; + } + break; + } + case UKUIElementStatus::HorizontalForward: { + + gradient = QLinearGradient(targetRect.left(),targetRect.center().y(),targetRect.right(),targetRect.center().y()); + if (targetX >= (pb->rect.x()+pb->rect.width())) { + stopStatus = true; + } + break; + } + default: + break; + } + //亮片渐变色 + gradient.setColorAt(0.02,QColor(255,255,255,0)); + gradient.setColorAt(0.40,QColor(255,255,255,102)); + gradient.setColorAt(0.60,QColor(255,255,255,102)); + gradient.setColorAt(0.98,QColor(255,255,255,0)); + painter->setBrush(gradient); //动画重启条件,不是time结束,而是进度值更新的时候,即绘制起始点x()触碰到进度值所在矩形的右边缘,就重启 - if (targetX >= (pb->rect.x()+pb->rect.width())) { + if (stopStatus) { animation->setCurrentTime(animation->totalDuration());//设置为终止时间,模拟动画假结束状态 } else { painter->drawRect(targetRect); @@ -6516,30 +7167,45 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp case CE_HeaderSection: { if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { + + sp->initHeaderViewStyle(); + const bool enable = header->state & State_Enabled; painter->save(); painter->setPen(Qt::NoPen); painter->setBrush(header->palette.brush(enable ? QPalette::Active : QPalette::Disabled, QPalette::Base)); painter->drawRect(header->rect); painter->restore(); + + /*fix bug#348235 去掉下分割线*/ painter->save(); - QColor color = header->palette.color(QPalette::Active, isUseDarkPalette() ? QPalette::Midlight : QPalette::Shadow); - painter->setPen(color); + // QColor color = header->palette.color(QPalette::Active, isUseDarkPalette() ? QPalette::Midlight : QPalette::Shadow); + painter->setPen(sp->m_verticalDividerLinePen); painter->setBrush(Qt::NoBrush); + + double marginRatio = 0.25; + int verticalMargin = header->rect.height() * marginRatio; + int horizontalMargin = 0; + if (header->orientation == Qt::Horizontal) { // int iconSize = proxy()->pixelMetric(PM_SmallIconSize); // int dis = (header->rect.height() - iconSize) / 2 - 1; int dis = (header->rect.height() / 2) / 2; if (header->position != QStyleOptionHeader::End && header->position != QStyleOptionHeader::OnlyOneSection) { - if (header->direction == Qt::LeftToRight) { - painter->drawLine(header->rect.right(), header->rect.top() + dis, header->rect.right(), header->rect.bottom() - dis); - } else { - painter->drawLine(header->rect.left(), header->rect.top() + dis, header->rect.left(), header->rect.bottom() - dis); + + if (header->direction == Qt::LeftToRight) {//从左到右的布局 + painter->drawLine(header->rect.right() - horizontalMargin, header->rect.top() + verticalMargin + 2, + header->rect.right() - horizontalMargin, header->rect.bottom() - verticalMargin);//+2是因为正常设置垂直边距会导致垂线不能垂直居中,应该是字体本身的问题 + } else {//从右往左的布局 + painter->drawLine(header->rect.left() + horizontalMargin, header->rect.top() + verticalMargin + 2, + header->rect.left() + horizontalMargin, header->rect.bottom() - verticalMargin); } + } - painter->drawLine(header->rect.left(), header->rect.bottom(), header->rect.right(), header->rect.bottom()); + // painter->drawLine(header->rect.left(), header->rect.bottom(), header->rect.right(), header->rect.bottom());//不需要下划分割线 } painter->restore(); + return; } break; @@ -6555,10 +7221,16 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp int iconSize = proxy()->pixelMetric(PM_SmallIconSize); if (!header->icon.isNull()) { - QIcon::Mode mode = header->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + QIcon::Mode mode = QIcon::Normal;// header->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = header->icon.pixmap(iconSize, iconSize, mode); - pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); +// pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + if (!(header->state & State_Enabled)) + { + QIcon::Mode mode = header->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; + pixmap = proxy()->generatedIconPixmap(mode, pixmap, option); + } + QRect iconRect(textRect.x(), textRect.y() + (textRect.height() - iconSize) / 2, iconSize, iconSize); textRect.setRect(iconRect.right() + 1 + 8, textRect.y(), textRect.width() - iconRect.width() - 8, textRect.height()); iconRect = visualRect(header->direction, rect, iconRect); @@ -6569,13 +7241,20 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp painter->restore(); } - if (header->state & QStyle::State_On || header->state & QStyle::State_Sunken) { - QFont font = painter->font(); - font.setBold(true); - painter->setFont(font); + QFontMetrics fm(painter->font()); + QString text = header->text; + int textWidth = fm.horizontalAdvance(text); + if(textWidth > textRect.width()){ + text = fm.elidedText(text, Qt::ElideRight, textRect.width()); } + +// if (header->state & QStyle::State_On || header->state & QStyle::State_Sunken) { +// QFont font = painter->font(); +// font.setBold(true); +// painter->setFont(font); +// } proxy()->drawItemText(painter, textRect, header->textAlignment | Qt::AlignVCenter, header->palette, - (header->state & State_Enabled), header->text, QPalette::ButtonText); + (header->state & State_Enabled), text, QPalette::ButtonText); return; } break; @@ -6605,6 +7284,10 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp proxy()->drawPrimitive(PE_PanelItemViewItem, option, painter, widget); + bool isIconMode = false; + if ((vi->decorationPosition == QStyleOptionViewItem::Top) || (vi->decorationPosition == QStyleOptionViewItem::Bottom)) + isIconMode = true; + if (vi->features & QStyleOptionViewItem::HasCheckIndicator) { QStyleOptionButton option; @@ -6635,20 +7318,20 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp QIcon::State state = vi->state & QStyle::State_Open ? QIcon::On : QIcon::Off; QPixmap pixmap = vi->icon.pixmap(vi->decorationSize, mode, state); - if(!sp->indicatorIconHoverNeedHighLight) - pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - else if(widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget") || + if (!isIconMode) { + if (widget && (widget->inherits("QTreeView") || widget->inherits("QTreeWidget") || widget->inherits("QListView") || widget->inherits("QListWidget") || - widget->inherits("QTableView") || widget->inherits("QTableWidget"))){ - if(widget->property("highlightMode").isValid() && widget->property("highlightMode").toBool()){ + widget->inherits("QTableView") || widget->inherits("QTableWidget"))) { + if (widget->property("highlightMode").isValid() && widget->property("highlightMode").toBool()) { + pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + } else { + pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); + } + } else { pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); } - else{ - pixmap = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget); - } } - else - pixmap = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget); + //pixmap = proxy()->generatedIconPixmap(mode, pixmap, vi); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); @@ -6684,7 +7367,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp if (cg == QPalette::Normal && !(vi->state & QStyle::State_Active)) cg = QPalette::Inactive; - if(!vi->state & QStyle::State_Enabled) + if(!(vi->state & QStyle::State_Enabled)) // !优先级高于& painter->setPen(ViewItemDisable); else if (((vi->decorationPosition == QStyleOptionViewItem::Top) || (vi->decorationPosition == QStyleOptionViewItem::Bottom)) && !(vi->state & State_Selected) && (vi->state & QStyle::State_Enabled)) { @@ -6760,7 +7443,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp } else { qDrawShadeLine(painter, p1, p2, f->palette, frameShadow == QFrame::Sunken, lw, mlw); } - painter->restore(); + // painter->restore(); break; } case QFrame::WinPanel: @@ -6769,8 +7452,8 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp case QFrame::Box: Style::drawControl(element, option, painter, widget); } + painter->restore(); } - painter->restore(); break; default: return Style::drawControl(element, option, painter, widget); @@ -6789,6 +7472,9 @@ int UKUIConfigStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption case PM_MenuPanelWidth: return sp->Menu_MarginPanelWidth; + case PM_MenuDesktopFrameWidth: + return sp->Menu_MarginHeight; + case PM_MenuHMargin: if (qobject_cast(widget)) { return sp->Menu_Combobox_Popup_MarginWidth; @@ -6797,6 +7483,7 @@ int UKUIConfigStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption case PM_MenuVMargin: { if (qobject_cast(widget)) { + // qDebug() << "上下边距 = " << sp->Menu_Combobox_Popup_MarginHeight; return sp->Menu_Combobox_Popup_MarginHeight; } return sp->Menu_MarginHeight; @@ -6859,14 +7546,14 @@ int UKUIConfigStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption return 4; case PM_MessageBoxIconSize: - return 24; + return 16; case PM_TabCloseIndicatorWidth: case PM_TabCloseIndicatorHeight: - return 20; + return 24; case PM_TabBarTabHSpace: - return 8 * 2; + return 6 * 2; case PM_TabBarTabVSpace: return 4 * 2; @@ -6934,7 +7621,7 @@ int UKUIConfigStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption case PM_IconViewIconSize: return 32; case PM_FocusFrameHMargin: - return 4; + return 2; case PM_TreeViewIndentation: return 20; @@ -6956,7 +7643,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty const QRect rect = bar->rect; int lineLength = 0; int distance = 4; - if (sp->ScrooBar_ShowLine && widget && ((widget->property("drawScrollBarGroove").isValid() && + if (sp->m_ScrollBarParameters.scrollBarShowArrow && widget && ((widget->property("drawScrollBarGroove").isValid() && widget->property("drawScrollBarGroove").toBool()) || !widget->property("drawScrollBarGroove").isValid())) { lineLength = sp->ScroolBar_LineLength; distance = 0; @@ -7019,7 +7706,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty switch (subControl) { case SC_ScrollBarSubLine: { - if(!sp->ScrooBar_ShowLine) + if(!sp->m_ScrollBarParameters.scrollBarShowArrow) return QRect(); if (horizontal) return QRect(0, 0, lineLength, rect.height()); @@ -7028,7 +7715,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty } case SC_ScrollBarAddLine: { - if(!sp->ScrooBar_ShowLine) + if(!sp->m_ScrollBarParameters.scrollBarShowArrow) return QRect(); if (horizontal) return QRect(rect.right() - lineLength, 0, lineLength, rect.height()); @@ -7102,6 +7789,10 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty if (const QStyleOptionSlider* slider = qstyleoption_cast(option)) { QRect rect = option->rect; const bool horizontal(slider->orientation == Qt::Horizontal); + + const bool hover = slider->state & State_MouseOver; + const bool suken = slider->state & State_Sunken; + const int thickSpace = 2; if (horizontal) { if (slider->tickPosition & QSlider::TicksAbove) @@ -7170,21 +7861,26 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty } } + + // int curRadius = hover ? sp->sliderHandleRadiusHover : sp->sliderHandleRadiusNormal; + // int adjustedPos = qMax(curRadius,sliderPos); + + QRect handleRect = option->rect; int handleThickness = proxy()->pixelMetric(PM_SliderThickness, option, widget); int handleLength = proxy()->pixelMetric(PM_SliderLength, option, widget); if(horizontal) - handleRect.setSize(QSize(handleLength, handleThickness)); + handleRect.setSize(QSize(handleLength, handleThickness));//handleLength = 16 else - handleRect.setSize(QSize(handleThickness, handleLength)); + handleRect.setSize(QSize(handleThickness, handleLength));//handleThickness = 16 handleRect.moveCenter(rect.center()); - if (horizontal) { handleRect.moveLeft(sliderPos + sp->Slider_Margin); } else { - handleRect.moveTop((sliderPos + sp->Slider_Margin)); + handleRect.moveTop(sliderPos + sp->Slider_Margin); } return visualRect(slider->direction, slider->rect, handleRect); + } case SC_SliderGroove: @@ -7353,7 +8049,7 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op QRect rect = verticalTabs ? QRect(-lap, option->rect.height() - (buttonWidth * 2), option->rect.width() + 2 * lap, buttonWidth) : QStyle::visualRect(option->direction, option->rect, QRect(option->rect.left() + lap, option->rect.top() + lap, - buttonWidth, option->rect.height() - 2 * lap)); + buttonWidth, option->rect.height())); return rect; } @@ -7365,8 +8061,8 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op QRect rect = verticalTabs ? QRect(-lap, option->rect.height() - buttonWidth, option->rect.width() + 2 * lap, buttonWidth) : QStyle::visualRect(option->direction, option->rect, - QRect(option->rect.right() - buttonWidth - lap, option->rect.top() + lap, - buttonWidth, option->rect.height() - 2 * lap)); + QRect(option->rect.right() - buttonWidth - lap + 1, option->rect.top() + lap, + buttonWidth, option->rect.height())); return rect; } @@ -7700,7 +8396,8 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op } else if (!text && icon && !(button->features & QStyleOptionButton::HasMenu)) { } else { - rect.adjust(sp->ToolButton_MarginWidth, sp->Button_MarginHeight, -sp->ToolButton_MarginWidth, -sp->Button_MarginHeight); + // rect.adjust(sp->ToolButton_MarginWidth, sp->Button_MarginHeight, -sp->ToolButton_MarginWidth, -sp->Button_MarginHeight); + rect.adjust(sp->Button_MarginWidth, sp->Button_MarginHeight, -sp->Button_MarginWidth, -sp->Button_MarginHeight); } if (button->features & (QStyleOptionButton::AutoDefaultButton | QStyleOptionButton::DefaultButton)) { int dbw = proxy()->pixelMetric(PM_ButtonDefaultIndicator, option, widget); @@ -7726,26 +8423,37 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op QRect rect = f->rect; if (clear) { - rect.adjust(f->lineWidth + 4, f->lineWidth, 0, -f->lineWidth); + rect.adjust(f->lineWidth + 2, f->lineWidth, 0, -f->lineWidth); rect = visualRect(option->direction, option->rect, rect); } else { - rect.adjust(f->lineWidth + 4, f->lineWidth, -(f->lineWidth + 4), -f->lineWidth); + rect.adjust(f->lineWidth + 2, f->lineWidth, -(f->lineWidth + 4), -f->lineWidth); } return rect; } break; } - + //返回Groove的矩形区域 case SE_ProgressBarGroove: case SE_ProgressBarLabel: { if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { - return pb->rect; + // return pb->rect; + const bool indeterminate = (pb->minimum == 0 && pb->maximum == 0); + const bool vertical = pb->orientation == Qt::Vertical; + QRect grooveRect(pb->rect);// 需要一个拷贝,pb->rect是不可修改的内部成员 + if (indeterminate) { + if(vertical) + grooveRect.setWidth(pbBaseGrooveSpan);//循环进度条需要高度固定8px ,内部滑片没有边框,外层groove为了凸显边框往往会内缩1px,所以整体高度应该设为8+2=10px + else + grooveRect.setHeight(pbBaseGrooveSpan); + } + grooveRect.moveCenter(pb->rect.center()); + return grooveRect; } break; } - + // pb here-1 case SE_ProgressBarContents: { if (const QStyleOptionProgressBar *pb = qstyleoption_cast(option)) { @@ -7756,31 +8464,45 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op int maxWidth = vertical ? pb->rect.height() : pb->rect.width(); const auto totalSteps = qMax(Q_INT64_C(1), qint64(pb->maximum) - pb->minimum); + const auto progressSteps = qint64(progress) - pb->minimum; const auto progressBarWidth = progressSteps * maxWidth / totalSteps; int len = indeterminate ? maxWidth : progressBarWidth; + bool reverse = (!vertical && (pb->direction == Qt::RightToLeft)) || vertical; if (inverted) reverse = !reverse; int diff = 0; - // bool enableBarAnimation = !disableProgressBarAnimationList().contains(qAppName());//是否启用进度条动画 - bool enableBarAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); - QVariantAnimation *animation = m_animation_helper->animation(option->styleObject); - //初始化对应状态的动画对象 + // bool enableBarAnimation = widget && (!widget->property("animation").isValid() || widget->property("animation").toBool()); + + bool enableBarAnimation = true; //循环进度条,默认永远开启动画 + if (!indeterminate) { //普通进度条,默认不开启动画,除非应用设置 w->property("animation",true); + enableBarAnimation = (widget && widget->property("animation").isValid() && widget->property("animation").toBool()) ? true : false; + } + + + //refactor + // 先查找map,widget对应的animation是否存在,存在则get + // 否则,new animation对象,插入 map + + QWidget* widgetKey = const_cast(widget); + QVariantAnimation *animation = m_animation_helper->getAnimation(widgetKey); if (enableBarAnimation && !animation) { - if (indeterminate) {//indeterminate状态 - m_animation_helper->startAnimation(new ConfigProgressBarAnimation(option->styleObject, ProgressBarStatus::INDETERMINATE)); - } else if (progressBarWidth < maxWidth) {//normal状态,(进度值已经铺满,则不使用动画) - m_animation_helper->startAnimation(new ConfigProgressBarAnimation(option->styleObject, ProgressBarStatus::NORMAL)); + if (indeterminate) {//indeterminate status + animation = new ConfigProgressBarAnimation(widgetKey, ProgressBarStatus::INDETERMINATE); + } else if (progressBarWidth < maxWidth) {//normal status + animation = new ConfigProgressBarAnimation(widgetKey, ProgressBarStatus::NORMAL); } - } + m_animation_helper->initAnimationMap(widgetKey, animation); + } + if (indeterminate) { - len = 56; + len = 51; double currentValue = 0; if (animation) { currentValue = animation->currentValue().toDouble(); @@ -7799,18 +8521,19 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op } } diff = currentValue * (maxWidth - len); - } else { + } else { // m_animation_helper->stopAnimation(option->styleObject); // 确定状态,QVariantAnimation,用于确定状态下的滑动光片动画 if (animation && m_animation_helper->canEnableNormalAnimation(progressBarWidth)) {//初始状态开启动画 + + m_animation_helper->setAnimationDuration(animation, progressBarWidth, 0.5); + if (animation->currentTime() == 0 ) { animation->start(); } else if (animation->currentTime() == animation->totalDuration() && progressBarWidth >= maxWidth) {//动画运行结束,且进度值铺满了,停止动画 - m_animation_helper->stopAnimation(option->styleObject); - // animation->stop(); - // delete animation; - // animation = nullptr; + // m_animation_helper->stopAnimation(option->styleObject); + m_animation_helper->stopAnimation(widgetKey); } else if (animation->currentTime() == animation->totalDuration()) {//动画运行结束,重启动画 animation->setCurrentTime(0); animation->start(); @@ -7836,8 +8559,22 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op } } - return progressRect; + // return progressRect; + + if (!indeterminate) { + return progressRect; + } + QRect fixedProgressRect(progressRect); + + if(vertical) + fixedProgressRect.setWidth(pbBaseSliderSpan);//循环进度条内部滑片高度应为8px,且没有边框, rect不应该内缩 + else + fixedProgressRect.setHeight(pbBaseSliderSpan); + + fixedProgressRect.moveCenter(progressRect.center()); + return fixedProgressRect; } + break; } @@ -8087,7 +8824,27 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { QFontMetrics fm = tb->fontMetrics; - w -= fm.horizontalAdvance(QLatin1Char(' ')) * 2; + // 处理&符号 + QString displayText = tb->text; + bool showShortcuts = proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget); + if(showShortcuts){ + if(displayText.contains("&")){ + QString s = ""; + int n = 0; +// displayText.replace("&&", "&"); + // 计算&被qt转义过的个数 + QString visibleText = displayText; + for (int i = 0; i < visibleText.size(); ++i) { + if (visibleText[i] == '&') { + s += "&"; + n++; + i++; + } + } + w += fm.horizontalAdvance(s); + } + } + if (tb->toolButtonStyle == Qt::ToolButtonTextBesideIcon) { if (text && icon) w += 4; @@ -8099,6 +8856,8 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt else h -= 4; } + + // w += fm.horizontalAdvance(displayText); } if (tb->features & QStyleOptionToolButton::MenuButtonPopup) { w += 8; @@ -8123,7 +8882,8 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt if (text && !icon && !(button->features & QStyleOptionButton::HasMenu)) { w += Button_MarginWidth * 2; } else { - w += sp->ToolButton_MarginWidth * 2; + // w += sp->ToolButton_MarginWidth * 2; + w += sp->Button_MarginWidth * 2; } h += sp->Button_MarginHeight * 2; @@ -8461,6 +9221,7 @@ void UKUIConfigStyle::getDefaultControlParameters(QApplication *app) app->setProperty("SpinBox_DefaultParameters_DownDisablePen" ,spinbox.data()->spinBoxDownDisablePen ); app->setProperty("SpinBox_DefaultParameters_UpIconHightPixMap" ,spinbox.data()->spinBoxUpIconHightPixMap ); app->setProperty("SpinBox_DefaultParameters_DownIconHightPixMap" ,spinbox.data()->spinBoxDownIconHightPixMap); + app->setProperty("SpinBox_DefaultParameters_UpDisableBrush",spinbox.data()->spinBoxUpDisableBrush); //combobox QSharedPointer comboBox(new ConfigComboBoxParameters); @@ -8592,6 +9353,8 @@ void UKUIConfigStyle::getDefaultControlParameters(QApplication *app) app->setProperty("CheckBox_DefaultParameters_OnClickBrush" , checkBox.data()->checkBoxOnClickBrush ); app->setProperty("CheckBox_DefaultParameters_PathBrush" , checkBox.data()->checkBoxPathBrush ); app->setProperty("CheckBox_DefaultParameters_PathDisableBrush", checkBox.data()->checkBoxPathDisableBrush); + app->setProperty("CheckBox_DefaultParameters_HookLineBrush",checkBox.data()->checkboxHookLineBrush); + app->setProperty("CheckBox_DefaultParameters_DisableOnNoChangeBrush",checkBox.data()->checkBoxDisableOnNoChangeBrush); //radiobutton QSharedPointer radiobutton(new ConfigRadioButtonParameters); @@ -8604,6 +9367,8 @@ void UKUIConfigStyle::getDefaultControlParameters(QApplication *app) app->setProperty("RadioButton_DefaultParameters_OnDefaultPen" , radiobutton.data()->radioButtonOnDefaultPen ); app->setProperty("RadioButton_DefaultParameters_OnHoverPen" , radiobutton.data()->radioButtonOnHoverPen ); app->setProperty("RadioButton_DefaultParameters_OnClickPen" , radiobutton.data()->radioButtonOnClickPen ); + app->setProperty("RadioButton_DefaultParameters_OnDisablePen" , radiobutton.data()->radioButtonOnDisablePen ); + app->setProperty("RadioButton_DefaultParameters_FocusPen" , radiobutton.data()->radioButtonFocusPen ); app->setProperty("RadioButton_DefaultParameters_DefaultBrush" , radiobutton.data()->radioButtonDefaultBrush ); app->setProperty("RadioButton_DefaultParameters_HoverBrush" , radiobutton.data()->radioButtonHoverBrush ); app->setProperty("RadioButton_DefaultParameters_ClickBrush" , radiobutton.data()->radioButtonClickBrush ); @@ -8681,6 +9446,7 @@ void UKUIConfigStyle::getDefaultControlParameters(QApplication *app) app->setProperty("TabWidget_DefaultParameters_tabBarHoverPen" , tabwidget.data()->tabBarHoverPen ); app->setProperty("TabWidget_DefaultParameters_tabBarClickPen" , tabwidget.data()->tabBarClickPen ); app->setProperty("TabWidget_DefaultParameters_tabBarFocusPen" , tabwidget.data()->tabBarFocusPen ); + app->setProperty("TabWidget_DefaultParameters_tabBarDividerPen" , tabwidget.data()->tabBarDividerPen ); //menu QSharedPointer menu(new ConfigMenuParameters); @@ -8690,6 +9456,7 @@ void UKUIConfigStyle::getDefaultControlParameters(QApplication *app) app->setProperty("Menu_DefaultParameters_menuBackgroundBrush", menu.data()->menuBackgroundBrush); app->setProperty("Menu_DefaultParameters_menuBackgroundPen" , menu.data()->menuBackgroundPen ); app->setProperty("Menu_DefaultParameters_menuItemSelectBrush", menu.data()->menuItemSelectBrush); + app->setProperty("Menu_DefaultParameters_menuItemClickBrush" , menu.data()->menuItemClickBrush); app->setProperty("Menu_DefaultParameters_menuItemFocusPen" , menu.data()->menuItemFocusPen ); app->setProperty("Menu_DefaultParameters_menuTextHoverPen" , menu.data()->menuTextHoverPen ); } diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style.h b/ukui-styles/qt5-config-style-ukui/ukui-config-style.h index 8a444d7..f982ce0 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style.h +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style.h @@ -30,6 +30,8 @@ #include #include #include "widget-parameters/control-parameters.h" +#include +#include class QStyleOptionViewItem; @@ -209,6 +211,16 @@ private: bool m_blink_cursor = true; int m_blink_cursor_time = 1200; + +private: + mutable UKUIElementStatus::ProgressBarOrientation pbOrientation;//记录当前进度条状态 + const int pbBaseGrooveSpan = 10; + const int pbBaseSliderSpan = 8; + + QDBusInterface* m_wlcomDBus = nullptr; + bool m_isHardwareRendering = true; +public: + void calculateHighColor(int& colorVal) const; }; #endif // UKUICONFIGSTYLE_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.cpp index 0cc6e98..64221e0 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.cpp @@ -37,6 +37,9 @@ ConfigCheckBoxParameters::ConfigCheckBoxParameters() checkBoxOnClickBrush = QBrush(Qt::NoBrush); checkBoxPathBrush = QBrush(Qt::NoBrush); checkBoxPathDisableBrush = QBrush(Qt::NoBrush); + checkBoxDisableOnNoChangeBrush = QBrush(Qt::NoBrush); + checkboxHookLineBrush = QBrush(Qt::NoBrush); + checkboxHookLineDisableBrush = QBrush(Qt::NoBrush); checkBoxDefaultPen = QPen(Qt::NoPen); checkBoxHoverPen = QPen(Qt::NoPen); @@ -45,6 +48,8 @@ ConfigCheckBoxParameters::ConfigCheckBoxParameters() checkBoxOnDefaultPen = QPen(Qt::NoPen); checkBoxOnHoverPen = QPen(Qt::NoPen); checkBoxOnClickPen = QPen(Qt::NoPen); + checkBoxTextBrush = QBrush(Qt::NoBrush); + checkBoxTextDisableBrush = QBrush(Qt::NoBrush); checkBoxDefaultPen.setWidth(0); checkBoxHoverPen.setWidth(0); checkBoxClickPen.setWidth(0); @@ -52,4 +57,7 @@ ConfigCheckBoxParameters::ConfigCheckBoxParameters() checkBoxOnDefaultPen.setWidth(0); checkBoxOnHoverPen.setWidth(0); checkBoxOnClickPen.setWidth(0); + + checkBoxFocusPen = QPen(Qt::NoPen); + checkBoxFocusPen.setWidth(0); } diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.h index e824f49..3c490b5 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-checkbox-parameters.h @@ -43,13 +43,18 @@ public: QBrush checkBoxHoverBrush; QBrush checkBoxClickBrush; QBrush checkBoxDisableBrush; + QBrush checkBoxDisableOnNoChangeBrush; QBrush checkBoxOnDefaultBrush; QBrush checkBoxOnHoverBrush; QBrush checkBoxOnClickBrush; QBrush checkBoxPathBrush; QBrush checkBoxPathDisableBrush; + QBrush checkboxHookLineBrush; + QBrush checkboxHookLineDisableBrush; + QPen checkBoxDefaultPen; + QPen checkBoxFocusPen; QPen checkBoxHoverPen; QPen checkBoxClickPen; QPen checkBoxDisablePen; @@ -57,6 +62,10 @@ public: QPen checkBoxOnHoverPen; QPen checkBoxOnClickPen; QPen checkBoxContentPen; + + QBrush checkBoxTextBrush; + QBrush checkBoxTextDisableBrush; + // bool animation = true; bool onHoverBrushIslinearGradient = false; diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.cpp index ce53782..6418e90 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.cpp @@ -32,4 +32,8 @@ ConfigListParameters::ConfigListParameters() listTextHoverPen = QPen(Qt::NoPen); listTextSelectPen = QPen(Qt::NoPen); + + listAlternatingRowsNormalBrush = QBrush(Qt::NoBrush); + listAlternatingRowsDisableBrush = QBrush(Qt::NoBrush); + } diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.h index debc14a..7f9531c 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-list-parameters.h @@ -46,10 +46,13 @@ public: QPen listTextHoverPen; QPen listTextSelectPen; QPen listTextDisablePen; - QPen listDefaultPen; QPen listHoverPen; QPen listSelectPen; QPen listFocusPen; + + + QBrush listAlternatingRowsNormalBrush; + QBrush listAlternatingRowsDisableBrush; }; } #endif // LISTPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.cpp index 4cf74b2..3daa9b1 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.cpp @@ -27,7 +27,8 @@ using namespace UKUIConfigStyleSpace; ConfigMenuParameters::ConfigMenuParameters() { menuItemSelectBrush = QBrush(Qt::NoBrush); + menuItemClickBrush = QBrush(Qt::NoBrush); menuTextHoverPen = QPen(Qt::NoPen); - + menuItemShortCutPen = QPen(Qt::NoPen); } diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.h index 9364713..499f004 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-menu-parameters.h @@ -41,6 +41,7 @@ public: int itemRadius; QBrush menuItemSelectBrush; + QBrush menuItemClickBrush; QBrush menuBackgroundBrush; @@ -52,6 +53,8 @@ public: QPen menuItemFocusPen; + QPen menuItemShortCutPen; + }; } #endif // MENUPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.cpp index a266621..fc5987c 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.cpp @@ -32,6 +32,8 @@ ConfigProgressBarParameters::ConfigProgressBarParameters() progressBarGrooveDefaultBrush = QBrush(Qt::NoBrush); progressBarGrooveDisableBrush = QBrush(Qt::NoBrush); + progressSliderBrush = QBrush(Qt::NoBrush); + progressBarContentPen = QPen(Qt::NoPen); progressBarGrooveDefaultPen = QPen(Qt::NoPen); progressBarGrooveDisablePen = QPen(Qt::NoPen); diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.h index 62fadb8..36e6f17 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-progressbar-parameters.h @@ -46,6 +46,8 @@ public: QPen progressBarContentPen = Qt::NoPen; QPen progressBarGrooveDefaultPen = Qt::NoPen; QPen progressBarGrooveDisablePen = Qt::NoPen; + + QBrush progressSliderBrush; }; } #endif // PROGRESSBARPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.cpp index e870476..414ae0c 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.cpp @@ -38,6 +38,7 @@ ConfigPushButtonParameters::ConfigPushButtonParameters() pushButtonCheckHoverBrush = QBrush(Qt::NoBrush); pushButtonCheckClickBrush = QBrush(Qt::NoBrush); pushButtonCheckDisableBrush = QBrush(Qt::NoBrush); + pushButtonInactiveBrush = QBrush(Qt::NoBrush); pushButtonDefaultPen = QPen(Qt::NoPen); pushButtonHoverPen = QPen(Qt::NoPen); diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.h index e2e7ad2..3e95a5d 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-pushbutton-parameters.h @@ -45,6 +45,7 @@ public: QColor textDefaultColor; QColor textHoverColor; QColor textDisableColor; + QColor textHighlightColor; QBrush pushButtonDefaultBrush; @@ -55,6 +56,7 @@ public: QBrush pushButtonCheckHoverBrush; QBrush pushButtonCheckClickBrush; QBrush pushButtonCheckDisableBrush; + QBrush pushButtonInactiveBrush; QPen pushButtonDefaultPen; QPen pushButtonHoverPen; @@ -67,15 +69,6 @@ public: QPen pushButtonFocusPen; bool needPen = false; - - -// QColor PushButtonInactiveColor; - -// QColor PushButtonTextDefaultColor; -// QColor PushButtonTextHoverColor; -// QColor PushButtonTextClickColor; -// QColor PushButtonTextInactiveColor; -// QColor PushButtonTextDisableColor; }; } #endif // PUSHBUTTONPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-radiobutton-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-radiobutton-parameters.h index 66b0cd4..010fb63 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-radiobutton-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-radiobutton-parameters.h @@ -51,13 +51,23 @@ public: QBrush radioButtonChildrenOnClickBrush; QBrush radioButtonChildrenOnDisableBrush; + QBrush radioButtonOnDisableBrush; + QPen radioButtonDefaultPen; QPen radioButtonHoverPen; QPen radioButtonClickPen; + QPen radioButtonFocusPen; + QPen radioButtonDisablePen; QPen radioButtonOnDefaultPen; QPen radioButtonOnHoverPen; QPen radioButtonOnClickPen; + + QPen radioButtonOnDisablePen; + + QBrush radioButtonTextBrush; + QBrush radioButtonTextDisableBrush; + // bool animation = true; }; } diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-scrollbar-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-scrollbar-parameters.h index b406b43..72471cf 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-scrollbar-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-scrollbar-parameters.h @@ -38,6 +38,7 @@ public: //private: int radius; bool grooveWidthAnimation = true; + bool scrollBarShowArrow = false; QBrush scrollBarGrooveDefaultBrush; QBrush scrollBarGrooveInactiveBrush; diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.cpp index d204171..dc56db0 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.cpp @@ -47,4 +47,6 @@ ConfigSliderParameters::ConfigSliderParameters() sliderGrooveUnvalueDefaultBrush = QBrush(Qt::NoBrush); sliderGrooveUnvalueHoverBrush = QBrush(Qt::NoBrush); sliderGrooveUnvalueDisableBrush = QBrush(Qt::NoBrush); + + sliderHandleDisbaleBaseBrush = QBrush(Qt::NoBrush); } diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.h index bc539fd..735fa44 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-slider-parameters.h @@ -60,6 +60,9 @@ public: QPen focusPen = Qt::NoPen; QPainterPath sliderHandlePath; + + QBrush sliderHandleDisbaleBaseBrush; + // bool animation = true; int sliderGrooveRadius = 2; diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.cpp index 8c16c48..54bccdc 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.cpp @@ -31,6 +31,7 @@ ConfigSpinBoxParameters::ConfigSpinBoxParameters() spinBoxDefaultBrush = QBrush(Qt::NoBrush); spinBoxHoverBrush = QBrush(Qt::NoBrush); spinBoxFocusBrush = QBrush(Qt::NoBrush); + spinBoxClickBrush = QBrush(Qt::NoBrush); spinBoxDisableBrush = QBrush(Qt::NoBrush); spinBoxDefaultPen = QPen(Qt::NoPen); spinBoxHoverPen = QPen(Qt::NoPen); @@ -41,6 +42,9 @@ ConfigSpinBoxParameters::ConfigSpinBoxParameters() spinBoxFocusPen.setWidth(0); spinBoxDisablePen.setWidth(0); + spinBoxClickPen = QPen(Qt::NoPen); + spinBoxClickPen.setWidth(0); + //up button spinBoxUpDefaultBrush = QBrush(Qt::NoBrush); spinBoxUpHoverBrush = QBrush(Qt::NoBrush); diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.h index 7e09907..eef17bb 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-spinbox-parameters.h @@ -41,11 +41,13 @@ public: QBrush spinBoxDefaultBrush; QBrush spinBoxHoverBrush; QBrush spinBoxFocusBrush; + QBrush spinBoxClickBrush; QBrush spinBoxDisableBrush; QPen spinBoxDefaultPen; QPen spinBoxHoverPen; QPen spinBoxFocusPen; QPen spinBoxDisablePen; + QPen spinBoxClickPen; //up button QBrush spinBoxUpDefaultBrush; diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-table-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-table-parameters.h index 747b843..4831772 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-table-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-table-parameters.h @@ -42,13 +42,14 @@ public: QBrush tableHoverBrush; QBrush tableSelectBrush; QBrush tableDisableBrush; - QPen tableDefaultPen; QPen tableHoverPen; QPen tableSelectPen; QPen tableFocusPen; QPen tableTextHoverPen; QPen tableTextSelectPen; QPen tableTextDisablePen; + QBrush tableAlternatingRowsNormalBrush; + QBrush tableAlternatingRowsDisableBrush; }; } #endif // TABLEPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tabwidget-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tabwidget-parameters.h index 487a10d..f61b1ca 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tabwidget-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tabwidget-parameters.h @@ -45,11 +45,15 @@ public: QBrush tabBarHoverBrush; QBrush tabBarClickBrush; QBrush tabBarSelectBrush; + QBrush tabBarIndicatorClickBrush; + QBrush tabBarIndicatorHoverBrush; QPen tabBarDefaultPen = Qt::NoPen; QPen tabBarFocusPen = Qt::NoPen; QPen tabBarClickPen = Qt::NoPen; QPen tabBarHoverPen = Qt::NoPen; + QPen tabBarDividerPen = Qt::NoPen;//Tab之间的分割线 + }; } #endif // TABWIDGETPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-toolbutton-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-toolbutton-parameters.h index 741b812..1a19322 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-toolbutton-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-toolbutton-parameters.h @@ -41,6 +41,11 @@ public: bool iconHoverClickHighlight; bool textHoverClickHighlight; + QColor textDefaultColor; + QColor textHoverColor; + QColor textDisableColor; + QColor textHighlightColor; + QBrush toolButtonDefaultBrush; QBrush toolButtonHoverBrush; @@ -60,10 +65,6 @@ public: QPen toolButtonCheckClickPen; QPen toolButtonCheckDisablePen; QPen toolButtonFocusPen; - - QColor textDefaultColor; - QColor textHoverColor ; - QColor textDisableColor; }; } #endif // TOOLBUTTONPARAMETERS_H diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tree-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tree-parameters.h index db841fc..986d80a 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tree-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/config-tree-parameters.h @@ -46,7 +46,6 @@ public: QBrush treeBranchHoverBrush; QBrush treeBranchSelectBrush; QBrush treeBranchDisableBrush; - QPen treeDefaultPen; QPen treeHoverPen; QPen treeSelectPen; QPen treeFocusPen; @@ -54,7 +53,9 @@ public: QPen treeTextSelectPen; QPen treeTextDisablePen; - bool indicatorIconHoverNeedHighLight = true; + QBrush treeAlternatingRowsNormalBrush; + QBrush treeAlternatingRowsDisableBrush; + // bool animation = true; }; diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.cpp b/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.cpp index e5cbe7e..e1495de 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.cpp +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.cpp @@ -26,9 +26,16 @@ using namespace UKUIConfigStyleSpace; ControlParameters::ControlParameters(QObject *parent) : QObject(parent) { - + elemFocusEnable = false; } ControlParameters::~ControlParameters() { } + +void ControlParameters::setFocusEnable(bool enable) { + elemFocusEnable = enable; +} +bool ControlParameters::getFocusEnable() const { + return elemFocusEnable; +} diff --git a/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.h b/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.h index bdaf05f..7859d0f 100644 --- a/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.h +++ b/ukui-styles/qt5-config-style-ukui/widget-parameters/control-parameters.h @@ -36,7 +36,27 @@ public: ~ControlParameters(); +protected: + bool elemFocusEnable; +public: + bool getFocusEnable() const; + void setFocusEnable(bool enable); + // virtual void getParameters(){} }; } + + +namespace UKUIElementStatus { + + enum ProgressBarOrientation { //记录进度条当前形状 + HorizontalForward = 0, //正常状态 + HorizontalInverted,//水平 反向 + VerticalForward,//垂直 从下往上 + VertivalInverted //垂直,从上往下 + }; + +} + + #endif // ControlParameters_H diff --git a/ukui-styles/readconfig.cpp b/ukui-styles/readconfig.cpp index f95b58f..1c6a266 100644 --- a/ukui-styles/readconfig.cpp +++ b/ukui-styles/readconfig.cpp @@ -32,8 +32,8 @@ #include #include #include "platformthemedebug.h" +#include "settings/black-list.h" -// #define ThemeConfigPath "/usr/share/config/globaltheme/token/" #define ThemeConfigPath "/usr/share/config/themeconfig/token/" #define DefaultConfigName "kdefault-light.css" @@ -41,157 +41,283 @@ using namespace UKUIGlobalDTConfig; GlobalDTConfigPrivate::GlobalDTConfigPrivate() { - { - windowTextActive = QBrush(Qt::NoBrush); - windowTextInactive = QBrush(Qt::NoBrush); - windowTextDisable = QBrush(Qt::NoBrush); - buttonActive = QBrush(Qt::NoBrush); - buttonInactive = QBrush(Qt::NoBrush); - buttonDisable = QBrush(Qt::NoBrush); - lightActive = QBrush(Qt::NoBrush); - lightInactive = QBrush(Qt::NoBrush); - lightDisable = QBrush(Qt::NoBrush); - midlightActive = QBrush(Qt::NoBrush); - midlightInactive = QBrush(Qt::NoBrush); - midlightDisable = QBrush(Qt::NoBrush); - darkActive = QBrush(Qt::NoBrush); - darkInactive = QBrush(Qt::NoBrush); - darkDisable = QBrush(Qt::NoBrush); - midActive = QBrush(Qt::NoBrush); - midInactive = QBrush(Qt::NoBrush); - midDisable = QBrush(Qt::NoBrush); - textActive = QBrush(Qt::NoBrush); - textInactive = QBrush(Qt::NoBrush); - textDisable = QBrush(Qt::NoBrush); - brightTextActive = QBrush(Qt::NoBrush); - brightTextInactive = QBrush(Qt::NoBrush); - brightTextDisable = QBrush(Qt::NoBrush); - buttonTextActive = QBrush(Qt::NoBrush); - buttonTextInactive = QBrush(Qt::NoBrush); - buttonTextDisable = QBrush(Qt::NoBrush); - baseActive = QBrush(Qt::NoBrush); - baseInactive = QBrush(Qt::NoBrush); - baseDisable = QBrush(Qt::NoBrush); - windowActive = QBrush(Qt::NoBrush); - windowInactive = QBrush(Qt::NoBrush); - windowDisable = QBrush(Qt::NoBrush); - shadowActive = QBrush(Qt::NoBrush); - shadowInactive = QBrush(Qt::NoBrush); - shadowDisable = QBrush(Qt::NoBrush); - highLightActive = QBrush(Qt::NoBrush); - highLightInactive = QBrush(Qt::NoBrush); - highLightDisable = QBrush(Qt::NoBrush); - highLightedTextActive = QBrush(Qt::NoBrush); - highLightedTextInactive = QBrush(Qt::NoBrush); - highLightedTextDisable = QBrush(Qt::NoBrush); - linkActive = QBrush(Qt::NoBrush); - linkInactive = QBrush(Qt::NoBrush); - linkDisable = QBrush(Qt::NoBrush); - linkVisitedActive = QBrush(Qt::NoBrush); - linkVisitedInactive = QBrush(Qt::NoBrush); - linkVisitedDisable = QBrush(Qt::NoBrush); - alternateBaseActive = QBrush(Qt::NoBrush); - alternateBaseInactive = QBrush(Qt::NoBrush); - alternateBaseDisable = QBrush(Qt::NoBrush); - noRoleActive = QBrush(Qt::NoBrush); - noRoleInactive = QBrush(Qt::NoBrush); - noRoleDisable = QBrush(Qt::NoBrush); - toolTipBaseActive = QBrush(Qt::NoBrush); - toolTipBaseInactive = QBrush(Qt::NoBrush); - toolTipBaseDisable = QBrush(Qt::NoBrush); - toolTipTextActive = QBrush(Qt::NoBrush); - toolTipTextInactive = QBrush(Qt::NoBrush); - toolTipTextDisable = QBrush(Qt::NoBrush); - placeholderTextActive = QBrush(Qt::NoBrush); - placeholderTextInactive = QBrush(Qt::NoBrush); - placeholderTextDisable = QBrush(Qt::NoBrush); - - kComponentNormal = QBrush(Qt::NoBrush); - kLineBrandDisable = QBrush(Qt::NoBrush); - kFontWhiteSecondary = QBrush(Qt::NoBrush); - kGray12 = QBrush(Qt::NoBrush); - kContainSecondaryAlpphaNormal = QBrush(Qt::NoBrush); - kGray16 = QBrush(Qt::NoBrush); - kBrand1 = QBrush(Qt::NoBrush); - kLineComponentNormal = QBrush(Qt::NoBrush); - kLineBrandClick = QBrush(Qt::NoBrush); - kGray3 = QBrush(Qt::NoBrush); - kGray0 = QBrush(Qt::NoBrush); - kLineDisable = QBrush(Qt::NoBrush); - kGrayAlpha2 = QBrush(Qt::NoBrush); - kGrayAlpha0 = QBrush(Qt::NoBrush); - kBrand2 = QBrush(Qt::NoBrush); - kLineNormal = QBrush(Qt::NoBrush); - kGrayAlpha5 = QBrush(Qt::NoBrush); - kGrayAlpha12 = QBrush(Qt::NoBrush); - kErrorClick = QBrush(Qt::NoBrush); - kLineWindowActive = QBrush(Qt::NoBrush); - kComponentAlphaClick = QBrush(Qt::NoBrush); - kBrand3 = QBrush(Qt::NoBrush); - kSuccessNormal = QBrush(Qt::NoBrush); - kGrayAlpha1 = QBrush(Qt::NoBrush); - kFontWhiteSecondaryDisable = QBrush(Qt::NoBrush); - kGray4 = QBrush(Qt::NoBrush); - kContainClick = QBrush(Qt::NoBrush); - kGray8 = QBrush(Qt::NoBrush); - kGrayAlpha4 = QBrush(Qt::NoBrush); - kModalmask = QBrush(Qt::NoBrush); - kLineBrandNormal = QBrush(Qt::NoBrush); - kBrand5 = QBrush(Qt::NoBrush); - kGray10 = QBrush(Qt::NoBrush); - kWarningNormal = QBrush(Qt::NoBrush); - kGray9 = QBrush(Qt::NoBrush); - kGray1 = QBrush(Qt::NoBrush); - kGray14 = QBrush(Qt::NoBrush); - kLineComponentClick = QBrush(Qt::NoBrush); - kWhite = QBrush(Qt::NoBrush); - kGray7 = QBrush(Qt::NoBrush); - kBrandFocus = QBrush(Qt::NoBrush); - kGrayAlpha9 = QBrush(Qt::NoBrush); - kGrayAlpha10 = QBrush(Qt::NoBrush); - kGrayAlpha6 = QBrush(Qt::NoBrush); - kContainHover = QBrush(Qt::NoBrush); - kLineComponentDisable = QBrush(Qt::NoBrush); - kFontWhite = QBrush(Qt::NoBrush); - kGrayAlpha11 = QBrush(Qt::NoBrush); - kGray6 = QBrush(Qt::NoBrush); - kFontWhiteDisable = QBrush(Qt::NoBrush); - kComponentDisable = QBrush(Qt::NoBrush); - kBlack = QBrush(Qt::NoBrush); - kComponentAlphaDisable = QBrush(Qt::NoBrush); - kFontSecondaryDisable = QBrush(Qt::NoBrush); - kGrayAlpha8 = QBrush(Qt::NoBrush); - kFontPrimaryDisable = QBrush(Qt::NoBrush); - kGray5 = QBrush(Qt::NoBrush); - kFontSecondary = QBrush(Qt::NoBrush); - kErrorNormal = QBrush(Qt::NoBrush); - kComponentHover = QBrush(Qt::NoBrush); - kComponentAlphaHover = QBrush(Qt::NoBrush); - kGrayAlpha3 = QBrush(Qt::NoBrush); - kGray13 = QBrush(Qt::NoBrush); - kGray11 = QBrush(Qt::NoBrush); - kErrorHover = QBrush(Qt::NoBrush); - kContainGeneralNormal = QBrush(Qt::NoBrush); - kComponentAlphaNormal = QBrush(Qt::NoBrush); - kGray15 = QBrush(Qt::NoBrush); - kBrand7 = QBrush(Qt::NoBrush); - kGrayAlpha7 = QBrush(Qt::NoBrush); - kLineBrandHover = QBrush(Qt::NoBrush); - kGrayAlpha13 = QBrush(Qt::NoBrush); - kLineComponentHover = QBrush(Qt::NoBrush); - kBrand6 = QBrush(Qt::NoBrush); - kGray17 = QBrush(Qt::NoBrush); - kComponentClick = QBrush(Qt::NoBrush); - kBrandClick = QBrush(Qt::NoBrush); - kFontStrong = QBrush(Qt::NoBrush); - kLineWindow = QBrush(Qt::NoBrush); - kGray2 = QBrush(Qt::NoBrush); - kBrand4 = QBrush(Qt::NoBrush); - kContainSecondaryNormal = QBrush(Qt::NoBrush); - kBrandHover = QBrush(Qt::NoBrush); - kFontPrimary = QBrush(Qt::NoBrush); - kBrandNormal = QBrush(Qt::NoBrush); - } + + dtMap.insert("alternatebase-active" , QVariant::fromValue(&alternateBaseActive)); + dtMap.insert("alternatebase-disable" , QVariant::fromValue(&alternateBaseDisable)); + dtMap.insert("alternatebase-inactive" , QVariant::fromValue(&alternateBaseInactive)); + + dtMap.insert("base-active" , QVariant::fromValue(&baseActive)); + dtMap.insert("base-disable" , QVariant::fromValue(&baseDisable)); + dtMap.insert("base-inactive" , QVariant::fromValue(&baseInactive)); + + dtMap.insert("brighttext-active" , QVariant::fromValue(&brightTextActive)); + dtMap.insert("brighttext-disable" , QVariant::fromValue(&brightTextDisable)); + dtMap.insert("brighttext-inactive" , QVariant::fromValue(&brightTextInactive)); + + dtMap.insert("button-active" , QVariant::fromValue(&buttonActive)); + dtMap.insert("button-disable" , QVariant::fromValue(&buttonDisable)); + dtMap.insert("button-inactive" , QVariant::fromValue(&buttonInactive)); + dtMap.insert("buttontext-active" , QVariant::fromValue(&buttonTextActive)); + dtMap.insert("buttontext-disable" , QVariant::fromValue(&buttonTextDisable)); + dtMap.insert("buttontext-inactive" , QVariant::fromValue(&buttonTextInactive)); + + dtMap.insert("dark-active" , QVariant::fromValue(&darkActive)); + dtMap.insert("dark-disable" , QVariant::fromValue(&darkDisable)); + dtMap.insert("dark-inactive" , QVariant::fromValue(&darkInactive)); + + dtMap.insert("focusline" , QVariant::fromValue(&focusline)); + + dtMap.insert("highlight-active" , QVariant::fromValue(&highLightActive)); + dtMap.insert("highlight-disable" , QVariant::fromValue(&highLightDisable)); + dtMap.insert("highlightedtext-active" , QVariant::fromValue(&highLightedTextActive)); + dtMap.insert("highlightedtext-disable" , QVariant::fromValue(&highLightedTextDisable)); + dtMap.insert("highlightedtext-inactive" , QVariant::fromValue(&highLightedTextInactive)); + dtMap.insert("highlight-inactive" , QVariant::fromValue(&highLightInactive)); + + dtMap.insert("kblack" , QVariant::fromValue(&kBlack)); + + dtMap.insert("kbrand1" , QVariant::fromValue(&kBrand1)); + dtMap.insert("kbrand2" , QVariant::fromValue(&kBrand2)); + dtMap.insert("kbrand3" , QVariant::fromValue(&kBrand3)); + dtMap.insert("kbrand4" , QVariant::fromValue(&kBrand4)); + dtMap.insert("kbrand5" , QVariant::fromValue(&kBrand5)); + dtMap.insert("kbrand6" , QVariant::fromValue(&kBrand6)); + dtMap.insert("kbrand7" , QVariant::fromValue(&kBrand7)); + dtMap.insert("kbrand8" , QVariant::fromValue(&kBrand8)); + dtMap.insert("kbrand9" , QVariant::fromValue(&kBrand9)); + dtMap.insert("kbrand-click" , QVariant::fromValue(&kBrandClick )); + dtMap.insert("kbrand-disable" , QVariant::fromValue(&kBrandDisable)); + dtMap.insert("kbrand-focus" , QVariant::fromValue(&kBrandFocus )); + dtMap.insert("kbrand-hover" , QVariant::fromValue(&kBrandHover )); + dtMap.insert("kbrand-normal" , QVariant::fromValue(&kBrandNormal )); + + dtMap.insert("kcomponent-alpha-click" , QVariant::fromValue(&kComponentAlphaClick )); + dtMap.insert("kcomponent-alpha-disable" , QVariant::fromValue(&kComponentAlphaDisable)); + dtMap.insert("kcomponent-alpha-hover" , QVariant::fromValue(&kComponentAlphaHover )); + dtMap.insert("kcomponent-alpha-normal" , QVariant::fromValue(&kComponentAlphaNormal )); + + dtMap.insert("kcomponent-click" , QVariant::fromValue(&kComponentClick)); + dtMap.insert("kcomponent-disable" , QVariant::fromValue(&kComponentDisable)); + dtMap.insert("kcomponent-hover" , QVariant::fromValue(&kComponentHover)); + dtMap.insert("kcomponent-normal" , QVariant::fromValue(&kComponentNormal)); + + dtMap.insert("kcomponent-selected-alpha-click" ,QVariant::fromValue(&kComponentSelectedAlphaClick)); + dtMap.insert("kcomponent-selected-alpha-disable" ,QVariant::fromValue(&kComponentSelectedAlphaDisable)); + dtMap.insert("kcomponent-selected-alpha-hover" ,QVariant::fromValue(&kComponentSelectedAlphaHover)); + dtMap.insert("kcomponent-selected-alpha-normal" ,QVariant::fromValue(&kComponentSelectedAlphaNormal)); + + dtMap.insert("kcomponent-selected-click" ,QVariant::fromValue(&kComponentSelectedClick)); + dtMap.insert("kcomponent-selected-disable" ,QVariant::fromValue(&kComponentSelectedDisable)); + dtMap.insert("kcomponent-selected-hover" ,QVariant::fromValue(&kComponentSelectedHover)); + dtMap.insert("kcomponent-selected-normal" ,QVariant::fromValue(&kComponentSelectedNormal)); + + dtMap.insert("kcontain-alpha-click" , QVariant::fromValue(&kContainAlphaClick)); + dtMap.insert("kcontain-alpha-hover" , QVariant::fromValue(&kContainAlphaHover)); + dtMap.insert("kcontain-click" , QVariant::fromValue(&kContainClick)); + dtMap.insert("kcontain-general-alpha-normal" , QVariant::fromValue(&kContainGeneralAlphaNormal)); + dtMap.insert("kcontain-general-inactive" , QVariant::fromValue(&kContainGeneralInactive)); + dtMap.insert("kcontain-general-normal" , QVariant::fromValue(&kContainGeneralNormal)); + dtMap.insert("kcontain-hover" , QVariant::fromValue(&kContainHover)); + dtMap.insert("kcontain-secondary-alpha-normal", QVariant::fromValue(&kContainSecondaryAlphaNormal)); + dtMap.insert("kcontain-secondary-inactive" , QVariant::fromValue(&kContainSecondaryInactive)); + dtMap.insert("kcontain-secondary-normal" , QVariant::fromValue(&kContainSecondaryNormal)); + + dtMap.insert("kdivider" , QVariant::fromValue(&kDivider)); + dtMap.insert("kdivider-white" , QVariant::fromValue(&kDividerWhite)); + + dtMap.insert("kerror-click" , QVariant::fromValue(&kErrorClick )); + dtMap.insert("kerror-disable" , QVariant::fromValue(&kErrorDisable)); + dtMap.insert("kerror-hover" , QVariant::fromValue(&kErrorHover )); + dtMap.insert("kerror-normal" , QVariant::fromValue(&kErrorNormal )); + + dtMap.insert("kfont-placeholdertext-disable" , QVariant::fromValue(&kFontPlaceholdertextDisable )); + dtMap.insert("kfont-placeholdertext" , QVariant::fromValue(&kFontPlaceholdertext)); + dtMap.insert("kfont-primary-disable" , QVariant::fromValue(&kFontPrimaryDisable)); + dtMap.insert("kfont-primary" , QVariant::fromValue(&kFontPrimary)); + dtMap.insert("kfont-secondary-disable" , QVariant::fromValue(&kFontSecondaryDisable )); + dtMap.insert("kfont-secondary" , QVariant::fromValue(&kFontSecondary )); + dtMap.insert("kfont-strong" , QVariant::fromValue(&kFontStrong )); + dtMap.insert("kfont-white-disable" , QVariant::fromValue(&kFontWhiteDisable )); + dtMap.insert("kfont-white-placeholdertext-disable" , QVariant::fromValue(&kFontWhitePlaceholdertextDisable)); + dtMap.insert("kfont-white-placeholdertext" , QVariant::fromValue(&kFontWhiteplaceholdertext)); + dtMap.insert("kfont-white" , QVariant::fromValue(&kFontWhite)); + dtMap.insert("kfont-white-secondary-disable" , QVariant::fromValue(&kFontWhiteSecondaryDisable)); + dtMap.insert("kfont-white-secondary" , QVariant::fromValue(&kFontWhiteSecondary)); + + dtMap.insert("kgray-0" , QVariant::fromValue(&kGray0 )); + dtMap.insert("kgray-10" , QVariant::fromValue(&kGray10 )); + dtMap.insert("kgray-11" , QVariant::fromValue(&kGray11 )); + dtMap.insert("kgray-12" , QVariant::fromValue(&kGray12 )); + dtMap.insert("kgray-13" , QVariant::fromValue(&kGray13 )); + dtMap.insert("kgray-14" , QVariant::fromValue(&kGray14 )); + dtMap.insert("kgray-15" , QVariant::fromValue(&kGray15 )); + dtMap.insert("kgray-16" , QVariant::fromValue(&kGray16 )); + dtMap.insert("kgray-17" , QVariant::fromValue(&kGray17 )); + dtMap.insert("kgray-1" , QVariant::fromValue(&kGray1 )); + dtMap.insert("kgray-2" , QVariant::fromValue(&kGray2 )); + dtMap.insert("kgray-3" , QVariant::fromValue(&kGray3 )); + dtMap.insert("kgray-4" , QVariant::fromValue(&kGray4 )); + dtMap.insert("kgray-5" , QVariant::fromValue(&kGray5 )); + dtMap.insert("kgray-6" , QVariant::fromValue(&kGray6 )); + dtMap.insert("kgray-7" , QVariant::fromValue(&kGray7 )); + dtMap.insert("kgray-8" , QVariant::fromValue(&kGray8 )); + dtMap.insert("kgray-9" , QVariant::fromValue(&kGray9 )); + dtMap.insert("kgray-alpha0" , QVariant::fromValue(&kGrayAlpha0 )); + dtMap.insert("kgray-alpha10" , QVariant::fromValue(&kGrayAlpha10)); + dtMap.insert("kgray-alpha11" , QVariant::fromValue(&kGrayAlpha11)); + dtMap.insert("kgray-alpha12" , QVariant::fromValue(&kGrayAlpha12)); + dtMap.insert("kgray-alpha13" , QVariant::fromValue(&kGrayAlpha13)); + dtMap.insert("kgray-alpha1" , QVariant::fromValue(&kGrayAlpha1 )); + dtMap.insert("kgray-alpha2" , QVariant::fromValue(&kGrayAlpha2 )); + dtMap.insert("kgray-alpha3" , QVariant::fromValue(&kGrayAlpha3 )); + dtMap.insert("kgray-alpha4" , QVariant::fromValue(&kGrayAlpha4 )); + dtMap.insert("kgray-alpha5" , QVariant::fromValue(&kGrayAlpha5 )); + dtMap.insert("kgray-alpha6" , QVariant::fromValue(&kGrayAlpha6 )); + dtMap.insert("kgray-alpha7" , QVariant::fromValue(&kGrayAlpha7 )); + dtMap.insert("kgray-alpha8" , QVariant::fromValue(&kGrayAlpha8 )); + dtMap.insert("kgray-alpha9" , QVariant::fromValue(&kGrayAlpha9 )); + + dtMap.insert("kgreen1" , QVariant::fromValue(&kGreen1)); + + dtMap.insert("kline-brand-click" , QVariant::fromValue(&kLineBrandClick )); + dtMap.insert("kline-brand-disable" , QVariant::fromValue(&kLineBrandDisable )); + dtMap.insert("kline-brand-hover" , QVariant::fromValue(&kLineBrandHover )); + dtMap.insert("kline-brand-normal" , QVariant::fromValue(&kLineBrandNormal )); + + dtMap.insert("kline-component-click" , QVariant::fromValue(&kLineComponentClick )); + dtMap.insert("kline-component-disable" , QVariant::fromValue(&kLineComponentDisable)); + dtMap.insert("kline-component-hover" , QVariant::fromValue(&kLineComponentHover )); + dtMap.insert("kline-component-normal" , QVariant::fromValue(&kLineComponentNormal )); + + dtMap.insert("kline-disable" , QVariant::fromValue(&kLineDisable)); + dtMap.insert("kline-dock" , QVariant::fromValue(&kLineDock)); + + dtMap.insert("kline-error-click" , QVariant::fromValue(&kLineErrorClick )); + dtMap.insert("kline-error-disable" , QVariant::fromValue(&kLineErrorDisable)); + dtMap.insert("kline-error-hover" , QVariant::fromValue(&kLineErrorHover )); + dtMap.insert("kline-error-normal" , QVariant::fromValue(&kLineErrorNormal )); + + dtMap.insert("kline-input-click" , QVariant::fromValue(&kLineInputClick)); + dtMap.insert("kline-input-disable" , QVariant::fromValue(&kLineInputDisable )); + dtMap.insert("kline-input-hover" , QVariant::fromValue(&kLineInputHover )); + dtMap.insert("kline-input-normal" , QVariant::fromValue(&kLineInputNormal )); + + dtMap.insert("kline-menu" , QVariant::fromValue(&kLineMenu )); + dtMap.insert("kline-normal" , QVariant::fromValue(&kLineNormal )); + + dtMap.insert("kline-selectbox-click" , QVariant::fromValue(&kLineSelectboxClick )); + dtMap.insert("kline-selectbox-disable" , QVariant::fromValue(&kLineSelectboxDisable )); + dtMap.insert("kline-selectbox-hover" , QVariant::fromValue(&kLineSelectboxHover )); + dtMap.insert("kline-selectbox-normal" , QVariant::fromValue(&kLineSelectboxNormal )); + + dtMap.insert("kline-selectbox-selected" , QVariant::fromValue(&kLineSelectboxSelected )); + + dtMap.insert("kline-success-click" , QVariant::fromValue(&kLineSuccessClick )); + dtMap.insert("kline-success-disable" , QVariant::fromValue(&kLineSuccessDisable )); + dtMap.insert("kline-success-hover" , QVariant::fromValue(&kLineSuccessHover )); + dtMap.insert("kline-success-normal" , QVariant::fromValue(&kLineSuccessNormal )); + + dtMap.insert("kline-table" , QVariant::fromValue(&kLineTable )); + + dtMap.insert("kline-warning-click" , QVariant::fromValue(&kLineWarningClick )); + dtMap.insert("kline-warning-disable" , QVariant::fromValue(&kLineWarningDisable)); + dtMap.insert("kline-warning-hover" , QVariant::fromValue(&kLineWarningHover )); + dtMap.insert("kline-warning-normal" , QVariant::fromValue(&kLineWarningNormal )); + + dtMap.insert("kline-window-active" , QVariant::fromValue(&kLineWindowActive )); + dtMap.insert("kline-window-inactive" , QVariant::fromValue(&kLineWindowInactive)); + + dtMap.insert("kmenu" , QVariant::fromValue(&kMenu )); + dtMap.insert("kmodalmask" , QVariant::fromValue(&kModalmask )); + dtMap.insert("korange1" , QVariant::fromValue(&kOrange1 )); + + dtMap.insert("kradius-max" , QVariant::fromValue(&kradiusMax )); + dtMap.insert("kradius-menu" , QVariant::fromValue(&kradiusMenu )); + dtMap.insert("kradius-min" , QVariant::fromValue(&kradiusMin )); + dtMap.insert("kradius-normal" , QVariant::fromValue(&kradiusNormal)); + dtMap.insert("kradius-window" , QVariant::fromValue(&kradiusWindow)); + + dtMap.insert("kred1" , QVariant::fromValue(&kRed1)); + + dtMap.insert("kselect-alpha-white-click" , QVariant::fromValue(&kSelectAlphaWhiteClick )); + dtMap.insert("kselect-alpha-white-disable" , QVariant::fromValue(&kSelectAlphaWhiteDisable)); + dtMap.insert("kselect-alpha-white-hover" , QVariant::fromValue(&kSelectAlphaWhiteHover )); + dtMap.insert("kselect-alpha-white" , QVariant::fromValue(&kSelectAlphaWhite )); + + dtMap.insert("kshadow-component" , QVariant::fromValue(&kshadowComponent)); + dtMap.insert("kshadow-menu" , QVariant::fromValue(&kshadowMenu )); + dtMap.insert("kshadow-min" , QVariant::fromValue(&kshadowMin )); + dtMap.insert("kshadow-primary-active" , QVariant::fromValue(&kshadowPrimaryActive )); + dtMap.insert("kshadow-primary-inactive" , QVariant::fromValue(&kshadowPrimaryInactive )); + dtMap.insert("kshadow-secondary-active" , QVariant::fromValue(&kshadowSecondaryActive)); + dtMap.insert("kshadow-secondary-inactive" , QVariant::fromValue(&kshadowSecondaryInactive )); + + dtMap.insert("ksuccess-click" , QVariant::fromValue(&kSuccessClick )); + dtMap.insert("ksuccess-disable" , QVariant::fromValue(&kSuccessDisable )); + dtMap.insert("ksuccess-hover" , QVariant::fromValue(&kSuccessHover )); + dtMap.insert("ksuccess-normal" , QVariant::fromValue(&kSuccessNormal )); + + dtMap.insert("kwarning-click" , QVariant::fromValue(&kWarningClick )); + dtMap.insert("kwarning-disable" , QVariant::fromValue(&kWarningDisable)); + dtMap.insert("kwarning-hover" , QVariant::fromValue(&kWarningHover )); + dtMap.insert("kwarning-normal" , QVariant::fromValue(&kWarningNormal )); + + dtMap.insert("kwhite" , QVariant::fromValue(&kWhite)); + + dtMap.insert("light-active" , QVariant::fromValue(&lightActive)); + dtMap.insert("light-disable" , QVariant::fromValue(&lightDisable )); + dtMap.insert("light-inactive" , QVariant::fromValue(&lightInactive )); + + dtMap.insert("link-active" , QVariant::fromValue(&linkActive )); + dtMap.insert("link-disable" , QVariant::fromValue(&linkDisable )); + dtMap.insert("link-inactive" , QVariant::fromValue(&linkInactive )); + dtMap.insert("linkvisited-active" , QVariant::fromValue(&linkVisitedActive )); + dtMap.insert("linkvisited-disable" , QVariant::fromValue(&linkVisitedDisable )); + dtMap.insert("linkvisited-inactive" , QVariant::fromValue(&linkVisitedInactive )); + + dtMap.insert("mid-active" , QVariant::fromValue(&midActive )); + dtMap.insert("mid-disable" , QVariant::fromValue(&midDisable)); + dtMap.insert("mid-inactive" , QVariant::fromValue(&midInactive )); + dtMap.insert("midlight-active" , QVariant::fromValue(&midlightActive )); + dtMap.insert("midlight-disable" , QVariant::fromValue(&midlightDisable )); + dtMap.insert("midlight-inactive" , QVariant::fromValue(&midlightInactive )); + + dtMap.insert("normalline" , QVariant::fromValue(&normalline )); + dtMap.insert("norole-active" , QVariant::fromValue(&noRoleActive )); + dtMap.insert("norole-disable" , QVariant::fromValue(&noRoleDisable )); + dtMap.insert("norole-inactive" , QVariant::fromValue(&noRoleInactive )); + + dtMap.insert("placeholdertext-active" , QVariant::fromValue(&placeholderTextActive )); + dtMap.insert("placeholdertext-disable" , QVariant::fromValue(&placeholderTextDisable )); + dtMap.insert("placeholdertext-inactive" , QVariant::fromValue(&placeholderTextInactive)); + + dtMap.insert("shadow" , QVariant::fromValue(&shadow )); + dtMap.insert("shadow-active" , QVariant::fromValue(&shadowActive )); + dtMap.insert("shadow-disable" , QVariant::fromValue(&shadowDisable )); + dtMap.insert("shadow-inactive" , QVariant::fromValue(&shadowInactive)); + + dtMap.insert("text-active" , QVariant::fromValue(&textActive )); + dtMap.insert("text-disable" , QVariant::fromValue(&textDisable )); + dtMap.insert("text-inactive" , QVariant::fromValue(&textInactive)); + + dtMap.insert("tooltipbase-active" , QVariant::fromValue(&toolTipBaseActive )); + dtMap.insert("tooltipbase-disable" , QVariant::fromValue(&toolTipBaseDisable )); + dtMap.insert("tooltipbase-inactive" , QVariant::fromValue(&toolTipBaseInactive)); + dtMap.insert("tooltiptext-active" , QVariant::fromValue(&toolTipTextActive )); + dtMap.insert("tooltiptext-disable" , QVariant::fromValue(&toolTipTextDisable )); + dtMap.insert("tooltiptext-inactive" , QVariant::fromValue(&toolTipTextInactive)); + + dtMap.insert("window-active" , QVariant::fromValue(&windowActive )); + dtMap.insert("window-disable" , QVariant::fromValue(&windowDisable )); + dtMap.insert("window-inactive" , QVariant::fromValue(&windowInactive )); + dtMap.insert("windowtext-active" , QVariant::fromValue(&windowTextActive )); + dtMap.insert("windowtext-disable" , QVariant::fromValue(&windowTextDisable )); + dtMap.insert("windowtext-inactive" , QVariant::fromValue(&windowTextInactive)); + + dtMap.insert("kcomponent-input-alpha" , QVariant::fromValue(&kComponentInputAlpha)); + dtMap.insert("kcomponent-input" , QVariant::fromValue(&kComponentInput)); + + init(); } @@ -202,6 +328,7 @@ GlobalDTConfigPrivate::~GlobalDTConfigPrivate() void GlobalDTConfigPrivate::init() { + QString radiusString; if (QGSettings::isSchemaInstalled("org.ukui.style")) { QGSettings *settings = new QGSettings("org.ukui.style"); @@ -211,23 +338,57 @@ void GlobalDTConfigPrivate::init() } else if (styleName == "ukui-dark" || styleName == "ukui-black") { m_lightMode = "dark"; } - QString r = settings->get("window-radius").toString(); - kradiusWindow = r.split(",").value(0).toInt(); - kradiusMenu = r.split(",").value(1).toInt(); - + if (useLightPaletteList().contains(qAppName())) { + m_lightMode = "light"; + } else if (useDarkPaletteList().contains(qAppName())) { + m_lightMode = "dark"; + } + if(qApp && qApp->property("useLightTheme").isValid()&&qApp->property("useLightTheme").canConvert()){ + m_lightMode = "light"; + } else if (qApp && qApp->property("useDarkTheme").isValid()&&qApp->property("useDarkTheme").canConvert()) { + m_lightMode = "dark"; + } + radiusString = settings->get("window-radius").toString(); m_widgetThemeName = settings->get("widgetThemeName").toString(); - } - qDebug() << "===========> m_widgetThemeName = " << m_widgetThemeName; - QString path = ThemeConfigPath; - //dt config - m_ukui_dt_path = (QFile::exists(path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css")) ? - path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css" : - path + "k" + m_widgetThemeName + ".css"; - qDebug() << "=========> m_ukui_dt_path = " << m_ukui_dt_path; + QString path; + + QByteArray envValue = qgetenv("XDG_DATA_DIRS"); + + if (envValue.isEmpty()) { + qWarning() << "XDG_DATA_DIRS is null!"; + } else { + QString value = QString::fromUtf8(envValue); + QStringList pathList = value.split(":"); + + for(int i = 0; i < pathList.length(); i ++){ + path = pathList.at(i) + "/config/themeconfig/token/"; + if(QFile::exists(path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css")){ + m_ukui_dt_path = path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css"; + break; + } + if(QFile::exists(path + "k" + m_widgetThemeName + ".css")){ + m_ukui_dt_path = path + "k" + m_widgetThemeName + ".css"; + break; + } + } + } + qDebug() << "read DT file = " << m_ukui_dt_path; + +// //dt config +// if(m_ukui_dt_path.isEmpty()){ +// path = ThemeConfigPath; +// m_ukui_dt_path = (QFile::exists(path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css")) ? +// path + "k" + m_widgetThemeName + "-" + m_lightMode + ".css" : +// path + "k" + m_widgetThemeName + ".css"; +// } + //qDebug() << "=========> m_ukui_dt_path = " << m_ukui_dt_path; m_ukui_dt_loadConfig = this->load(m_ukui_dt_path); initUKUIGlobalThemeParameters(); + + kradiusWindow = radiusString.split(",").value(0).toInt(); + kradiusMenu = radiusString.split(",").value(1).toInt(); } @@ -260,7 +421,6 @@ QColor GlobalDTConfigPrivate::mixColor(QList colorList) bool GlobalDTConfigPrivate::load(const QString &cfg) { - qDebug() << "loadddd...." << cfg; if (!QFile::exists(cfg)) { qWarning() << "TMPReadConfig load file not exists!" << cfg; return false; @@ -395,6 +555,43 @@ inline bool GlobalDTConfigPrivate::getColorValue(QBrush &dtBrush, const QString listColor.append(color); } + solidColor = mixColor(listColor); + dtBrush = QBrush(solidColor); + } else if (colorStr.contains(": linear-gradient(rgba")) { + //mix solidcolor + start_index = colorStr.indexOf(": linear-gradient("); + if (start_index == -1) { + qWarning() << "Config file format error! type linear-gradient rgb" << key; + return false; + } + + start_index += QString(": linear-gradient(").length(); + end_index = colorStr.indexOf(";", start_index); + colorStr = colorStr.mid(start_index, end_index - start_index); + colorStr = colorStr.replace(")),", "),"); + QStringList sList = colorStr.split("rgba"); + QList listColor; + QColor solidColor; + QStringList colorList; + for(int i = 0; i < sList.length(); i++) { + QString s = sList[i]; + if(!s.isEmpty()){ + int sIndex = s.indexOf("("); + int eIndex = s.indexOf(")"); + s = s.mid(sIndex + 1, eIndex - sIndex - 1); + if(!colorList.contains(s)) + colorList.append(s); + } + } + + for (int i = 0; i < colorList.length(); i++) { + QString s = colorList[i]; + + QColor color = stringToColor(s); + if(!listColor.contains(color)) + listColor.append(color); + } + solidColor = mixColor(listColor); dtBrush = QBrush(solidColor); } else if (colorStr.contains(": linear-gradient(180deg, ")) { @@ -480,347 +677,23 @@ inline bool GlobalDTConfigPrivate::getValue(int &value, const QString key) const void GlobalDTConfigPrivate::initUKUIGlobalThemeParameters() { - qDebug() << "initUKUIGlobalThemeParameters......" << m_ukui_dt_loadConfig; if (m_ukui_dt_loadConfig) { + for(auto item = dtMap.begin(); item != dtMap.end(); item++){ + QVariant v = item.value(); + if(qApp && v.canConvert()){ + QBrush* brushPtr = v.value(); + getColorValue(*brushPtr, item.key()); + qApp->setProperty(item.key().toLocal8Bit(), *brushPtr ); + } + else if(qApp && v.canConvert()){ + int* i = v.value(); + getValue(*i, item.key()); + qApp->setProperty(item.key().toLocal8Bit(), *i ); + } + } - //default palette - getColorValue(windowTextActive , "windowtext-active"); - getColorValue(windowTextInactive , "windowtext-inactive"); - getColorValue(windowTextDisable , "windowtext-disable"); - getColorValue(buttonActive , "button-active"); - getColorValue(buttonInactive , "button-inactive"); - getColorValue(buttonDisable , "button-disable"); - getColorValue(lightActive , "light-active"); - getColorValue(lightInactive , "light-inactive"); - getColorValue(lightDisable , "light-disable"); - getColorValue(midlightActive , "midlight-active"); - getColorValue(midlightInactive , "midlight-inactive"); - getColorValue(midlightDisable , "midlight-disable"); - getColorValue(darkActive , "dark-active"); - getColorValue(darkInactive , "dark-inactive"); - getColorValue(darkDisable , "dark-disable"); - getColorValue(midActive , "mid-active"); - getColorValue(midInactive , "mid-inactive"); - getColorValue(midDisable , "mid-disable"); - getColorValue(textActive , "text-active"); - getColorValue(textInactive , "text-inactive"); - getColorValue(textDisable , "text-disable"); - getColorValue(brightTextActive , "brighttext-active"); - getColorValue(brightTextInactive , "brighttext-inactive"); - getColorValue(brightTextDisable , "brighttext-disable"); - getColorValue(buttonTextActive , "buttontext-active"); - getColorValue(buttonTextInactive , "buttontext-inactive"); - getColorValue(buttonTextDisable , "buttontext-disable"); - getColorValue(baseActive , "base-active"); - getColorValue(baseInactive , "base-inactive"); - getColorValue(baseDisable , "base-disable"); - getColorValue(windowActive , "window-active"); - getColorValue(windowInactive , "window-inactive"); - getColorValue(windowDisable , "window-disable"); - getColorValue(shadowActive , "shadow-active"); - getColorValue(shadowInactive , "shadow-inactive"); - getColorValue(shadowDisable , "shadow-disable"); - getColorValue(highLightActive , "highlight-active"); - getColorValue(highLightInactive , "highlight-inactive"); - getColorValue(highLightDisable , "highlight-disable"); - getColorValue(highLightedTextActive , "highlightedtext-active"); - getColorValue(highLightedTextInactive , "highlightedtext-inactive"); - getColorValue(highLightedTextDisable , "highlightedtext-disable"); - getColorValue(linkActive , "link-active"); - getColorValue(linkInactive , "link-inactive"); - getColorValue(linkDisable , "link-disable"); - getColorValue(linkVisitedActive , "linkvisited-active"); - getColorValue(linkVisitedInactive , "linkvisited-inactive"); - getColorValue(linkVisitedDisable , "linkvisited-disable"); - getColorValue(alternateBaseActive , "alternatebase-active"); - getColorValue(alternateBaseInactive , "alternatebase-inactive"); - getColorValue(alternateBaseDisable , "alternatebase-disable"); - getColorValue(noRoleActive , "norole-active"); - getColorValue(noRoleInactive , "norole-inactive"); - getColorValue(noRoleDisable , "norole-disable"); - getColorValue(toolTipBaseActive , "tooltipbase-active"); - getColorValue(toolTipBaseInactive , "tooltipbase-inactive"); - getColorValue(toolTipBaseDisable , "tooltipbase-disable"); - getColorValue(toolTipTextActive , "tooltiptext-active"); - getColorValue(toolTipTextInactive , "tooltiptext-inactive"); - getColorValue(toolTipTextDisable , "tooltiptext-disable"); - getColorValue(placeholderTextActive , "placeholdertext-active"); - getColorValue(placeholderTextInactive , "placeholdertext-inactive"); - getColorValue(placeholderTextDisable , "placeholdertext-disable"); - - //custom palette - getColorValue(kBlack , "kblack"); - getColorValue(kBrand1 , "kbrand1"); - getColorValue(kBrand2 , "kbrand2"); - getColorValue(kBrand3 , "kbrand3"); - getColorValue(kBrand4 , "kbrand4"); - getColorValue(kBrand5 , "kbrand5"); - getColorValue(kBrand6 , "kbrand6"); - getColorValue(kBrand7 , "kbrand7"); - getColorValue(kBrandClick , "kbrand-click"); - getColorValue(kBrandFocus , "kbrand-focus"); - getColorValue(kBrandHover , "kbrand-hover"); - getColorValue(kBrandNormal , "kbrand-normal"); - getColorValue(kComponentAlphaClick , "kcomponent-alpha-click"); - getColorValue(kComponentAlphaDisable , "kcomponent-alpha-disable"); - getColorValue(kComponentAlphaHover , "kcomponent-alpha-hover"); - getColorValue(kComponentAlphaNormal , "kcomponent-alpha-normal"); - getColorValue(kComponentClick , "kcomponent-click"); - getColorValue(kComponentDisable , "kcomponent-disable"); - getColorValue(kComponentHover , "kcomponent-hover"); - getColorValue(kComponentNormal , "kcomponent-normal"); - getColorValue(kContainClick , "kcontain-click"); - getColorValue(kContainHover , "kcontain-hover"); - getColorValue(kContainGeneralNormal , "kcontain-general-normal"); - getColorValue(kContainSecondaryAlpphaNormal , "kcontain-secondary-alpha-normal"); - getColorValue(kContainSecondaryNormal , "kcontain-secondary-normal"); - getColorValue(kErrorClick , "kerror-click"); - getColorValue(kErrorHover , "kerror-hover"); - getColorValue(kErrorNormal , "kerror-normal"); - getColorValue(kFontPrimary , "kfont-primary"); - getColorValue(kFontPrimaryDisable , "kfont-primary-disable"); - getColorValue(kFontSecondary , "kfont-secondary"); - getColorValue(kFontSecondaryDisable , "kfont-secondary-disable"); - getColorValue(kFontStrong , "kfont-strong"); - getColorValue(kFontWhite , "kfont-white"); - getColorValue(kFontWhiteDisable , "kfont-white-disable"); - getColorValue(kFontWhiteSecondary , "kfont-white-secondary"); - getColorValue(kFontWhiteSecondaryDisable , "kfont-white-secondary-disable"); - getColorValue(kGray0 , "kgray-0"); - getColorValue(kGray1 , "kgray-1"); - getColorValue(kGray2 , "kgray-2"); - getColorValue(kGray3 , "kgray-3"); - getColorValue(kGray4 , "kgray-4"); - getColorValue(kGray5 , "kgray-5"); - getColorValue(kGray6 , "kgray-6"); - getColorValue(kGray7 , "kgray-7"); - getColorValue(kGray8 , "kgray-8"); - getColorValue(kGray9 , "kgray-9"); - getColorValue(kGray10 , "kgray-10"); - getColorValue(kGray11 , "kgray-11"); - getColorValue(kGray12 , "kgray-12"); - getColorValue(kGray13 , "kgray-13"); - getColorValue(kGray14 , "kgray-14"); - getColorValue(kGray15 , "kgray-15"); - getColorValue(kGray16 , "kgray-16"); - getColorValue(kGray17 , "kgray-17"); - getColorValue(kGrayAlpha0 , "kgray-alpha0"); - getColorValue(kGrayAlpha1 , "kgray-alpha1"); - getColorValue(kGrayAlpha2 , "kgray-alpha2"); - getColorValue(kGrayAlpha3 , "kgray-alpha3"); - getColorValue(kGrayAlpha4 , "kgray-alpha4"); - getColorValue(kGrayAlpha5 , "kgray-alpha5"); - getColorValue(kGrayAlpha6 , "kgray-alpha6"); - getColorValue(kGrayAlpha7 , "kgray-alpha7"); - getColorValue(kGrayAlpha8 , "kgray-alpha8"); - getColorValue(kGrayAlpha9 , "kgray-alpha9"); - getColorValue(kGrayAlpha10 , "kgray-alpha10"); - getColorValue(kGrayAlpha11 , "kgray-alpha11"); - getColorValue(kGrayAlpha12 , "kgray-alpha12"); - getColorValue(kGrayAlpha13 , "kgray-alpha13"); - getColorValue(kLineBrandClick , "kline-brand-click"); - getColorValue(kLineBrandDisable , "kline-brand-disable"); - getColorValue(kLineBrandHover , "kline-brand-hover"); - getColorValue(kLineBrandNormal , "kline-brand-normal"); - getColorValue(kLineComponentClick , "kline-component-click"); - getColorValue(kLineComponentDisable , "kline-component-disable"); - getColorValue(kLineComponentHover , "kline-component-hover"); - getColorValue(kLineComponentNormal , "kline-component-normal"); - getColorValue(kLineDisable , "kline-disable"); - getColorValue(kLineNormal , "kline-normal"); - getColorValue(kLineWindow , "kline-window"); - getColorValue(kLineWindowActive , "kline-window-active"); - getColorValue(kModalmask , "kmodalmask"); - getColorValue(kSuccessNormal , "ksuccess-normal"); - getColorValue(kWarningNormal , "kwarning-normal"); - getColorValue(kWhite , "kwhite"); - - //line and margin - getValue(normalline , "normalline"); - getValue(focusline , "focusline"); - getValue(tokenGap4 , "token-gap-4"); - getValue(tokenGap8 , "token-gap-8"); - getValue(tokenGap16 , "token-gap-16"); - getValue(tokenGap24 , "token-gap-24"); - getValue(tokenGap40 , "token-gap-40"); - - //radius - getValue(kradiusMin , "kradius-min"); -// getValue(kradiusMenu , "kradius-menu"); - getValue(kradiusNormal , "kradius-normal"); -// getValue(kradiusWindow , "kradius-window"); } -{ - //default palette - qApp->setProperty("windowtext-active", windowTextActive); - qApp->setProperty("windowtext-inactive", windowTextInactive); - qApp->setProperty("windowtext-disable", windowTextDisable); - qApp->setProperty("button-active", buttonActive); - qApp->setProperty("button-inactive", buttonInactive); - qApp->setProperty("button-disable", buttonDisable); - qApp->setProperty("light-active", lightActive); - qApp->setProperty("light-inactive", lightInactive); - qApp->setProperty("light-disable", lightDisable); - qApp->setProperty("midlight-active", midlightActive); - qApp->setProperty("midlight-inactive", midlightInactive); - qApp->setProperty("midlight-disable", midlightDisable); - qApp->setProperty("dark-active", darkActive); - qApp->setProperty("dark-inactive", darkInactive); - qApp->setProperty("dark-disable", darkDisable); - qApp->setProperty("mid-active", midActive); - qApp->setProperty("mid-inactive", midInactive); - qApp->setProperty("mid-disable", midDisable); - qApp->setProperty("text-active", textActive); - qApp->setProperty("text-inactive", textInactive); - qApp->setProperty("text-disable", textDisable); - qApp->setProperty("brighttext-active", brightTextActive); - qApp->setProperty("brighttext-inactive", brightTextInactive); - qApp->setProperty("brighttext-disable", brightTextDisable); - qApp->setProperty("buttontext-active", buttonTextActive); - qApp->setProperty("buttontext-inactive", buttonTextInactive); - qApp->setProperty("buttontext-disable", buttonTextDisable); - qApp->setProperty("base-active", baseActive); - qApp->setProperty("base-inactive", baseInactive); - qApp->setProperty("base-disable", baseDisable); - qApp->setProperty("window-active", windowActive); - qApp->setProperty("window-inactive", windowInactive); - qApp->setProperty("window-disable", windowDisable); - qApp->setProperty("shadow-active", shadowActive); - qApp->setProperty("shadow-inactive", shadowInactive); - qApp->setProperty("shadow-disable", shadowDisable); - qApp->setProperty("highlight-active", highLightActive); - qApp->setProperty("highlight-inactive", highLightInactive); - qApp->setProperty("highlight-disable", highLightDisable); - qApp->setProperty("highlightedtext-active", highLightedTextActive); - qApp->setProperty("highlightedtext-inactive", highLightedTextInactive); - qApp->setProperty("highlightedtext-disable", highLightedTextDisable); - qApp->setProperty("link-active", linkActive); - qApp->setProperty("link-inactive", linkInactive); - qApp->setProperty("link-disable", linkDisable); - qApp->setProperty("linkvisited-active", linkVisitedActive); - qApp->setProperty("linkvisited-inactive", linkVisitedInactive); - qApp->setProperty("linkvisited-disable", linkVisitedDisable); - qApp->setProperty("alternatebase-active", alternateBaseActive); - qApp->setProperty("alternatebase-inactive", alternateBaseInactive); - qApp->setProperty("alternatebase-disable", alternateBaseDisable); - qApp->setProperty("norole-active", noRoleActive); - qApp->setProperty("norole-inactive", noRoleInactive); - qApp->setProperty("norole-disable", noRoleDisable); - qApp->setProperty("tooltipbase-active", toolTipBaseActive); - qApp->setProperty("tooltipbase-inactive", toolTipBaseInactive); - qApp->setProperty("tooltipbase-disable", toolTipBaseDisable); - qApp->setProperty("tooltiptext-active", toolTipTextActive); - qApp->setProperty("tooltiptext-inactive", toolTipTextInactive); - qApp->setProperty("tooltiptext-disable", toolTipTextDisable); - qApp->setProperty("placeholdertext-active", placeholderTextActive); - qApp->setProperty("placeholdertext-inactive", placeholderTextInactive); - qApp->setProperty("placeholdertext-disable", placeholderTextDisable); - - //custom palette - qApp->setProperty("kblack", kBlack); - qApp->setProperty("kbrand1", kBrand1); - qApp->setProperty("kbrand2", kBrand2); - qApp->setProperty("kbrand3", kBrand3); - qApp->setProperty("kbrand4", kBrand4); - qApp->setProperty("kbrand5", kBrand5); - qApp->setProperty("kbrand6", kBrand6); - qApp->setProperty("kbrand7", kBrand7); - qApp->setProperty("kbrand-click", kBrandClick); - qApp->setProperty("kbrand-focus", kBrandFocus); - qApp->setProperty("kbrand-hover", kBrandHover); - qApp->setProperty("kbrand-normal", kBrandNormal); - qApp->setProperty("kcomponent-alpha-click", kComponentAlphaClick); - qApp->setProperty("kcomponent-alpha-disable", kComponentAlphaDisable); - qApp->setProperty("kcomponent-alpha-hover", kComponentAlphaHover); - qApp->setProperty("kcomponent-alpha-normal", kComponentAlphaNormal); - qApp->setProperty("kcomponent-click", kComponentClick); - qApp->setProperty("kcomponent-disable", kComponentDisable); - qApp->setProperty("kcomponent-hover", kComponentHover); - qApp->setProperty("kcomponent-normal", kComponentNormal); - qApp->setProperty("kcontain-click", kContainClick); - qApp->setProperty("kcontain-hover", kContainHover); - qApp->setProperty("kcontain-general-normal", kContainGeneralNormal); - qApp->setProperty("kcontain-secondary-alpha-normal", kContainSecondaryAlpphaNormal); - qApp->setProperty("kcontain-secondary-normal", kContainSecondaryNormal); - qApp->setProperty("kerror-click", kErrorClick); - qApp->setProperty("kerror-hover", kErrorHover); - qApp->setProperty("kerror-normal", kErrorNormal); - qApp->setProperty("kfont-primary", kFontPrimary); - qApp->setProperty("kfont-primary-disable", kFontPrimaryDisable); - qApp->setProperty("kfont-secondary", kFontSecondary); - qApp->setProperty("kfont-secondary-disable", kFontSecondaryDisable); - qApp->setProperty("kfont-strong", kFontStrong); - qApp->setProperty("kfont-white", kFontWhite); - qApp->setProperty("kfont-white-disable", kFontWhiteDisable); - qApp->setProperty("kfont-white-secondary", kFontWhiteSecondary); - qApp->setProperty("kfont-white-secondary-disable", kFontWhiteSecondaryDisable); - qApp->setProperty("kgray-0", kGray0); - qApp->setProperty("kgray-1", kGray1); - qApp->setProperty("kgray-2", kGray2); - qApp->setProperty("kgray-3", kGray3); - qApp->setProperty("kgray-4", kGray4); - qApp->setProperty("kgray-5", kGray5); - qApp->setProperty("kgray-6", kGray6); - qApp->setProperty("kgray-7", kGray7); - qApp->setProperty("kgray-8", kGray8); - qApp->setProperty("kgray-9", kGray9); - qApp->setProperty("kgray-10", kGray10); - qApp->setProperty("kgray-11", kGray11); - qApp->setProperty("kgray-12", kGray12); - qApp->setProperty("kgray-13", kGray13); - qApp->setProperty("kgray-14", kGray14); - qApp->setProperty("kgray-15", kGray15); - qApp->setProperty("kgray-16", kGray16); - qApp->setProperty("kgray-17", kGray17); - qApp->setProperty("kgray-alpha0", kGrayAlpha0); - qApp->setProperty("kgray-alpha1", kGrayAlpha1); - qApp->setProperty("kgray-alpha2", kGrayAlpha2); - qApp->setProperty("kgray-alpha3", kGrayAlpha3); - qApp->setProperty("kgray-alpha4", kGrayAlpha4); - qApp->setProperty("kgray-alpha5", kGrayAlpha5); - qApp->setProperty("kgray-alpha6", kGrayAlpha6); - qApp->setProperty("kgray-alpha7", kGrayAlpha7); - qApp->setProperty("kgray-alpha8", kGrayAlpha8); - qApp->setProperty("kgray-alpha9", kGrayAlpha9); - qApp->setProperty("kgray-alpha10", kGrayAlpha10); - qApp->setProperty("kgray-alpha11", kGrayAlpha11); - qApp->setProperty("kgray-alpha12", kGrayAlpha12); - qApp->setProperty("kgray-alpha13", kGrayAlpha13); - qApp->setProperty("kline-brand-click", kLineBrandClick); - qApp->setProperty("kline-brand-disable", kLineBrandDisable); - qApp->setProperty("kline-brand-hover", kLineBrandHover); - qApp->setProperty("kline-brand-normal", kLineBrandNormal); - qApp->setProperty("kline-component-click", kLineComponentClick); - qApp->setProperty("kline-component-disable", kLineComponentDisable); - qApp->setProperty("kline-component-hover", kLineComponentHover); - qApp->setProperty("kline-component-normal", kLineComponentNormal); - qApp->setProperty("kline-disable", kLineDisable); - qApp->setProperty("kline-normal", kLineNormal); - qApp->setProperty("kline-window", kLineWindow); - qApp->setProperty("kline-window-active", kLineWindowActive); - qApp->setProperty("kmodalmask", kModalmask); - qApp->setProperty("ksuccess-normal", kSuccessNormal); - qApp->setProperty("kwarning-normal", kWarningNormal); - qApp->setProperty("kwhite", kWhite); - - - //line and margin - qApp->setProperty("normalline", normalline); - qApp->setProperty("focusline", focusline); - qApp->setProperty("token-gap-4", tokenGap4); - qApp->setProperty("token-gap-8", tokenGap8); - qApp->setProperty("token-gap-16", tokenGap16); - qApp->setProperty("token-gap-24", tokenGap24); - qApp->setProperty("token-gap-40", tokenGap40); - - //radius - qApp->setProperty("kradius-min", kradiusMin); - qApp->setProperty("kradius-menu", kradiusMenu); - qApp->setProperty("kradius-normal", kradiusNormal); - qApp->setProperty("kradius-window", kradiusWindow); - - } if (QGSettings::isSchemaInstalled("org.ukui.style")) { auto *settings = new QGSettings("org.ukui.style"); connect(settings, &QGSettings::changed, this, [=](const QString &key) { @@ -891,7 +764,10 @@ void GlobalDTConfigPrivate::updateColorsBasedOnAccentColor(const QColor &accentC { QBrush accentColorBrush = QBrush(QColor(accentColor)); - kBrandNormal = accentColorBrush; + kBrandNormal = accentColorBrush;// 根据系统强调色,覆盖设置kbrandnormal色板颜色 + QColor disableColor = accentColor; + disableColor.setAlphaF(0.45); + kBrandDisable = QBrush(QColor(disableColor)); linkInactive = accentColorBrush; highLightActive = accentColorBrush; linkActive = accentColorBrush; @@ -902,7 +778,7 @@ void GlobalDTConfigPrivate::updateColorsBasedOnAccentColor(const QColor &accentC // kLineBrandDisable = accentColorBrush; kLineBrandClick = accentColorBrush; kBrand1 = accentColorBrush; - kBrandFocus = accentColorBrush; +// kBrandFocus = accentColorBrush; // QString cssStringhover = "linear-gradient(0deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.05) 100%), rgba(55, 144, 250, 1)"; // QColor resultColor = processCSSColor(cssStringhover, accentColor); @@ -914,21 +790,25 @@ void GlobalDTConfigPrivate::updateColorsBasedOnAccentColor(const QColor &accentC adjustHighlightColor(highLightActive, getKeyValue("kbrand-hover"), getKeyValue("kbrand-click")); - qApp->setProperty("kbrand-normal", kBrandNormal); - qApp->setProperty("kbrand-hover", kBrandHover); - qApp->setProperty("kbrand-click", kBrandClick); + if(qApp){ + qApp->setProperty("kbrand-normal", kBrandNormal); + qApp->setProperty("kbrand-hover", kBrandHover); + qApp->setProperty("kbrand-click", kBrandClick); + qApp->setProperty("kbrand-disable", kBrandDisable); - qApp->setProperty("link-inactive", linkInactive); - qApp->setProperty("highlight-active", highLightActive); - qApp->setProperty("link-active", linkActive); - qApp->setProperty("highlight-inactive", highLightInactive); - qApp->setProperty("kline-brand-normal", kLineBrandNormal); - qApp->setProperty("kline-brand-hover", kLineBrandHover); - qApp->setProperty("kline-brand-disable", kLineBrandDisable); - qApp->setProperty("kline-brand-click", kLineBrandClick); - qApp->setProperty("kbrand1", kBrand1); - qApp->setProperty("kbrand-focus", kBrandFocus); + qApp->setProperty("link-inactive", linkInactive); + qApp->setProperty("highlight-active", highLightActive); + qApp->setProperty("link-active", linkActive); + qApp->setProperty("highlight-inactive", highLightInactive); + + qApp->setProperty("kline-brand-normal", kLineBrandNormal); + qApp->setProperty("kline-brand-hover", kLineBrandHover); + qApp->setProperty("kline-brand-disable", kLineBrandDisable); + qApp->setProperty("kline-brand-click", kLineBrandClick); + qApp->setProperty("kbrand1", kBrand1); + } +// qApp->setProperty("kbrand-focus", kBrandFocus); } @@ -959,12 +839,13 @@ void GlobalDTConfigPrivate::adjustHighlightColor(QBrush highlightColor, QString kBrandHover = QBrush(linearGradient); } else { if (isDark) { - kBrandHover = QBrush(configMixColor(highlightColor.color(), QColor(Qt::white), 0.2)); + kBrandHover = QBrush(configMixColor(highlightColor.color(), QColor(Qt::white), 0.05)); } else { kBrandHover = QBrush(configMixColor(highlightColor.color(), QColor(Qt::black), 0.05)); } } - if(clickStr.contains("linear-gradient(180deg")){ + + if (clickStr.contains("linear-gradient(180deg")) { if (isDark) { startColor = configMixColor(highlightColor.color(), QColor(Qt::white), 0.2); endColor = configMixColor(highlightColor.color(), QColor(Qt::black), 0.2); @@ -975,10 +856,9 @@ void GlobalDTConfigPrivate::adjustHighlightColor(QBrush highlightColor, QString linearGradient1.setColorAt(0, startColor); linearGradient1.setColorAt(1, endColor); kBrandClick = QBrush(linearGradient1); - } - else { + } else { if (isDark) { - kBrandClick = QBrush(configMixColor(highlightColor.color(), QColor(Qt::white), 0.05)); + kBrandClick = QBrush(configMixColor(highlightColor.color(), QColor(Qt::white), 0.2)); } else { kBrandClick = QBrush(configMixColor(highlightColor.color(), QColor(Qt::black), 0.2)); } @@ -1423,6 +1303,53 @@ QBrush GlobalDTConfig::kComponentNormal() const { return d->kComponentNormal; } +QBrush GlobalDTConfig::kComponentAlphaNormal() const +{ + return d->kComponentAlphaNormal; +} +QBrush GlobalDTConfig::kComponentInput() const +{ + return d->kComponentInput; +} +QBrush GlobalDTConfig::kComponentInputAlpha() const +{ + return d->kComponentInputAlpha; +} + +QBrush GlobalDTConfig::kComponentSelectedAlphaDisable() const +{ + return d->kComponentSelectedAlphaDisable; +} +QBrush GlobalDTConfig::kComponentSelectedAlphaNormal() const +{ + return d->kComponentSelectedAlphaNormal; +} +QBrush GlobalDTConfig::kComponentSelectedAlphaHover() const +{ + return d->kComponentSelectedAlphaHover; +} +QBrush GlobalDTConfig::kComponentSelectedAlphaClick() const +{ + return d->kComponentSelectedAlphaClick; +} + +QBrush GlobalDTConfig::kComponentSelectedClick() const +{ + return d->kComponentSelectedClick; +} +QBrush GlobalDTConfig::kComponentSelectedHover() const +{ + return d->kComponentSelectedHover; +} +QBrush GlobalDTConfig::kComponentSelectedDisable() const +{ + return d->kComponentSelectedDisable; +} +QBrush GlobalDTConfig::kComponentSelectedNormal() const +{ + return d->kComponentSelectedNormal; +} + QBrush GlobalDTConfig::kLineBrandDisable() const { @@ -1439,11 +1366,6 @@ QBrush GlobalDTConfig::kGray12() const return d->kGray12; } -QBrush GlobalDTConfig::kContainSecondaryAlpphaNormal() const -{ - return d->kContainSecondaryAlpphaNormal; -} - QBrush GlobalDTConfig::kGray16() const { return d->kGray16; @@ -1749,10 +1671,6 @@ QBrush GlobalDTConfig::kContainGeneralNormal() const return d->kContainGeneralNormal; } -QBrush GlobalDTConfig::kComponentAlphaNormal() const -{ - return d->kComponentAlphaNormal; -} QBrush GlobalDTConfig::kGray15() const { @@ -1809,11 +1727,6 @@ QBrush GlobalDTConfig::kFontStrong() const return d->kFontStrong; } -QBrush GlobalDTConfig::kLineWindow() const -{ - return d->kLineWindow; -} - QBrush GlobalDTConfig::kGray2() const { return d->kGray2; @@ -1854,49 +1767,436 @@ int GlobalDTConfig::focusline() const return d->focusline; } -int GlobalDTConfig::tokenGap4() const +int GlobalDTConfig::kradiusMin() const { - return d->tokenGap4; + return d->kradiusMin; } -int GlobalDTConfig::tokenGap8() const +int GlobalDTConfig::kradiusMenu() const { - return d->tokenGap8; + return d->kradiusMenu; } -int GlobalDTConfig::tokenGap16() const +int GlobalDTConfig::kradiusNormal() const { - return d->tokenGap16; + return d->kradiusNormal; } -int GlobalDTConfig::tokenGap24() const +int GlobalDTConfig::kradiusWindow() const { - return d->tokenGap24; + return d->kradiusWindow; } -int GlobalDTConfig::tokenGap40() const + + +QBrush GlobalDTConfig::kBrand8() const { - return d->tokenGap40; + return d->kBrand8; } -int GlobalDTConfig::kradiusMin() const +QBrush GlobalDTConfig::kBrand9() const { - return d->kradiusMin; + return d->kBrand9; } -int GlobalDTConfig::kradiusMenu() const +QBrush GlobalDTConfig::kBrandDisable() const { - return d->kradiusMenu; + return d->kBrandDisable; } -int GlobalDTConfig::kradiusNormal() const +QBrush GlobalDTConfig::kContainAlphaClick() const { - return d->kradiusNormal; + return d->kContainAlphaClick; } -int GlobalDTConfig::kradiusWindow() const +QBrush GlobalDTConfig::kContainAlphaHover() const { - return d->kradiusWindow; + return d->kContainAlphaHover; } +QBrush GlobalDTConfig::kContainGeneralAlphaNormal() const +{ + return d->kContainGeneralAlphaNormal; +} + +QBrush GlobalDTConfig::kContainGeneralInactive() const +{ + return d->kContainGeneralInactive; +} + +QBrush GlobalDTConfig::kContainSecondaryAlphaNormal() const +{ + return d->kContainSecondaryAlphaNormal; +} + +QBrush GlobalDTConfig::kContainSecondaryInactive() const +{ + return d->kContainSecondaryInactive; +} + +QBrush GlobalDTConfig::kDivider() const +{ + return d->kDivider; +} + +QBrush GlobalDTConfig::kDividerWhite() const +{ + return d->kDividerWhite; +} + +QBrush GlobalDTConfig::kErrorDisable() const +{ + return d->kErrorDisable; +} + +QBrush GlobalDTConfig::kFontPlaceholdertextDisable() const +{ + return d->kFontPlaceholdertextDisable; +} + +QBrush GlobalDTConfig::kFontPlaceholdertext() const +{ + return d->kFontPlaceholdertext; +} + +QBrush GlobalDTConfig::kFontWhitePlaceholdertextDisable() const +{ + return d->kFontWhitePlaceholdertextDisable; +} + +QBrush GlobalDTConfig::kFontWhiteplaceholdertext() const +{ + return d->kFontWhiteplaceholdertext; +} + +QBrush GlobalDTConfig::kGreen1() const +{ + return d->kGreen1; +} + +QBrush GlobalDTConfig::kLineDock() const +{ + return d->kLineDock; +} + +QBrush GlobalDTConfig::kLineErrorClick() const +{ + return d->kLineErrorClick; +} +QBrush GlobalDTConfig::kLineErrorDisable() const +{ + return d->kLineErrorDisable; +} + +QBrush GlobalDTConfig::kLineErrorHover() const +{ + return d->kLineErrorHover; +} + +QBrush GlobalDTConfig::kLineErrorNormal() const +{ + return d->kLineErrorNormal; +} + +QBrush GlobalDTConfig::kLineInputClick() const +{ + return d->kLineInputClick; +} + +QBrush GlobalDTConfig::kLineInputDisable() const +{ + return d->kLineInputDisable; +} + +QBrush GlobalDTConfig::kLineInputHover() const +{ + return d->kLineInputHover; +} + +QBrush GlobalDTConfig::kLineInputNormal() const +{ + return d->kLineInputNormal; +} + +QBrush GlobalDTConfig::kLineMenu() const +{ + return d->kLineMenu; +} + +QBrush GlobalDTConfig::kLineSelectboxClick() const +{ + return d->kLineSelectboxClick; +} + +QBrush GlobalDTConfig::kLineSelectboxDisable() const +{ + return d->kLineSelectboxDisable; +} + +QBrush GlobalDTConfig::kLineSelectboxHover() const +{ + return d->kLineSelectboxHover; +} + +QBrush GlobalDTConfig::kLineSelectboxNormal() const +{ + return d->kLineSelectboxNormal; +} + +QBrush GlobalDTConfig::kLineSelectboxSelected() const +{ + return d->kLineSelectboxSelected; +} + +QBrush GlobalDTConfig::kLineSuccessClick() const +{ + return d->kLineSuccessClick; +} + +QBrush GlobalDTConfig::kLineSuccessDisable() const +{ + return d->kLineSuccessDisable; +} + +QBrush GlobalDTConfig::kLineSuccessHover() const +{ + return d->kLineSuccessHover; +} + +QBrush GlobalDTConfig::kLineSuccessNormal() const +{ + return d->kLineSuccessNormal; +} + +QBrush GlobalDTConfig::kLineTable() const +{ + return d->kLineTable; +} + +QBrush GlobalDTConfig::kLineWarningClick() const +{ + return d->kLineWarningClick; +} + +QBrush GlobalDTConfig::kLineWarningDisable() const +{ + return d->kLineWarningDisable; +} + +QBrush GlobalDTConfig::kLineWarningHover() const +{ + return d->kLineWarningHover; +} + +QBrush GlobalDTConfig::kLineWarningNormal() const +{ + return d->kLineWarningNormal; +} + +QBrush GlobalDTConfig::kLineWindowInactive() const +{ + return d->kLineWindowInactive; +} + +QBrush GlobalDTConfig::kMenu() const +{ + return d->kMenu; +} + +QBrush GlobalDTConfig::kOrange1() const +{ + return d->kOrange1; +} + +int GlobalDTConfig::kradiusMax() const +{ + return d->kradiusMax; +} + +QBrush GlobalDTConfig::kRed1() const +{ + return d->kRed1; +} + +QBrush GlobalDTConfig::kSelectAlphaWhiteClick() const +{ + return d->kSelectAlphaWhiteClick; +} + +QBrush GlobalDTConfig::kSelectAlphaWhiteDisable() const +{ + return d->kSelectAlphaWhiteDisable; +} + +QBrush GlobalDTConfig::kSelectAlphaWhiteHover() const +{ + return d->kSelectAlphaWhiteHover; +} + +QBrush GlobalDTConfig::kSelectAlphaWhite() const +{ + return d->kSelectAlphaWhite; +} + +QBrush GlobalDTConfig::kshadowComponent() const +{ + return d->kshadowComponent; +} + +QBrush GlobalDTConfig::kshadowMenu() const +{ + return d->kshadowMenu; +} + +QBrush GlobalDTConfig::kshadowMin() const +{ + return d->kshadowMin; +} + +QBrush GlobalDTConfig::kshadowPrimaryActive() const +{ + return d->kshadowPrimaryActive; +} + +QBrush GlobalDTConfig::kshadowPrimaryInactive() const +{ + return d->kshadowPrimaryInactive; +} + +QBrush GlobalDTConfig::kshadowSecondaryActive() const +{ + return d->kshadowSecondaryActive; +} + +QBrush GlobalDTConfig::kshadowSecondaryInactive() const +{ + return d->kshadowSecondaryInactive; +} + +QBrush GlobalDTConfig::kSuccessClick() const +{ + return d->kSuccessClick; +} + +QBrush GlobalDTConfig::kSuccessDisable() const +{ + return d->kSuccessDisable; +} + +QBrush GlobalDTConfig::kSuccessHover() const +{ + return d->kSuccessHover; +} + +QBrush GlobalDTConfig::kWarningClick() const +{ + return d->kWarningClick; +} + +QBrush GlobalDTConfig::kWarningDisable() const +{ + return d->kWarningDisable; +} + +QBrush GlobalDTConfig::kWarningHover() const +{ + return d->kWarningHover; +} + +QBrush GlobalDTConfig::shadow() const +{ + return d->shadow; +} + +QPalette GlobalDTConfig::appPalette() +{ + QPalette defaultPalette; + defaultPalette.setColor(QPalette::Active, QPalette::WindowText, windowTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::WindowText, windowTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::WindowText, windowTextDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Button, buttonActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Button, buttonInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Button, buttonDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Light, lightActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Light, lightInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Light, lightDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Midlight, midlightActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Midlight, midlightInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Midlight, midlightDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Dark, darkActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Dark, darkInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Dark, darkDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Mid, midActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Mid, midInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Mid, midDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Text, textActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Text, textInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Text, textDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::BrightText, brightTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::BrightText, brightTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::BrightText, brightTextDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::ButtonText, buttonTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonTextDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Base, baseActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Base, baseInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Base, baseDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Window, windowActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Window, windowInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Window, windowDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Shadow, shadowActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Shadow, shadowInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Shadow, shadowDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Highlight, highLightActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Highlight, highLightInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Highlight, highLightDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::HighlightedText, highLightedTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightedTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightedTextDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::Link, linkActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::Link, linkInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::Link, linkDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisitedActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisitedInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisitedDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBaseActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBaseInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBaseDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::NoRole, noRoleActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::NoRole, noRoleInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::NoRole, noRoleDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::ToolTipBase, toolTipBaseActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipBase, toolTipBaseInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipBase, toolTipBaseDisable().color()); + + defaultPalette.setColor(QPalette::Active, QPalette::ToolTipText, toolTipTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipText, toolTipTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, toolTipTextDisable().color()); + +#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0)) + defaultPalette.setColor(QPalette::Active, QPalette::PlaceholderText, placeholderTextActive().color()); + defaultPalette.setColor(QPalette::Inactive, QPalette::PlaceholderText, placeholderTextInactive().color()); + defaultPalette.setColor(QPalette::Disabled, QPalette::PlaceholderText, placeholderTextDisable().color()); +#endif + + return defaultPalette; +} diff --git a/ukui-styles/readconfig.h b/ukui-styles/readconfig.h index 714cc26..ceccc31 100644 --- a/ukui-styles/readconfig.h +++ b/ukui-styles/readconfig.h @@ -37,6 +37,7 @@ class GlobalDTConfigPrivate : public QObject Q_OBJECT public: + explicit GlobalDTConfigPrivate(); ~GlobalDTConfigPrivate(); @@ -56,172 +57,238 @@ public: QColor configMixColor(const QColor &c1, const QColor &c2, qreal bias); QString getKeyValue(const QString key); - //qt palette - QBrush windowTextActive ; - QBrush windowTextInactive ; - QBrush windowTextDisable ; - QBrush buttonActive ; - QBrush buttonInactive ; - QBrush buttonDisable ; - QBrush lightActive ; - QBrush lightInactive ; - QBrush lightDisable ; - QBrush midlightActive ; - QBrush midlightInactive ; - QBrush midlightDisable ; - QBrush darkActive ; - QBrush darkInactive ; - QBrush darkDisable ; - QBrush midActive ; - QBrush midInactive ; - QBrush midDisable ; - QBrush textActive ; - QBrush textInactive ; - QBrush textDisable ; - QBrush brightTextActive ; - QBrush brightTextInactive ; - QBrush brightTextDisable ; - QBrush buttonTextActive ; - QBrush buttonTextInactive ; - QBrush buttonTextDisable ; - QBrush baseActive ; - QBrush baseInactive ; - QBrush baseDisable ; - QBrush windowActive ; - QBrush windowInactive ; - QBrush windowDisable ; - QBrush shadowActive ; - QBrush shadowInactive ; - QBrush shadowDisable ; - QBrush highLightActive ; - QBrush highLightInactive ; - QBrush highLightDisable ; - QBrush highLightedTextActive ; - QBrush highLightedTextInactive ; - QBrush highLightedTextDisable ; - QBrush linkActive ; - QBrush linkInactive ; - QBrush linkDisable ; - QBrush linkVisitedActive ; - QBrush linkVisitedInactive ; - QBrush linkVisitedDisable ; - QBrush alternateBaseActive ; - QBrush alternateBaseInactive ; - QBrush alternateBaseDisable ; - QBrush noRoleActive ; - QBrush noRoleInactive ; - QBrush noRoleDisable ; - QBrush toolTipBaseActive ; - QBrush toolTipBaseInactive ; - QBrush toolTipBaseDisable ; - QBrush toolTipTextActive ; - QBrush toolTipTextInactive ; - QBrush toolTipTextDisable ; - QBrush placeholderTextActive ; - QBrush placeholderTextInactive ; - QBrush placeholderTextDisable ; - - //custom palette - QBrush kComponentNormal ; - QBrush kLineBrandDisable ; - QBrush kFontWhiteSecondary ; - QBrush kGray12 ; - QBrush kContainSecondaryAlpphaNormal ; - QBrush kGray16 ; - QBrush kBrand1 ; - QBrush kLineComponentNormal ; - QBrush kLineBrandClick ; - QBrush kGray3 ; - QBrush kGray0 ; - QBrush kLineDisable ; - QBrush kGrayAlpha2 ; - QBrush kGrayAlpha0 ; - QBrush kBrand2 ; - QBrush kLineNormal ; - QBrush kGrayAlpha5 ; - QBrush kGrayAlpha12 ; - QBrush kErrorClick ; - QBrush kLineWindowActive ; - QBrush kComponentAlphaClick ; - QBrush kBrand3 ; - QBrush kSuccessNormal ; - QBrush kGrayAlpha1 ; - QBrush kFontWhiteSecondaryDisable ; - QBrush kGray4 ; - QBrush kContainClick ; - QBrush kGray8 ; - QBrush kGrayAlpha4 ; - QBrush kModalmask ; - QBrush kLineBrandNormal ; - QBrush kBrand5 ; - QBrush kGray10 ; - QBrush kWarningNormal ; - QBrush kGray9 ; - QBrush kGray1 ; - QBrush kGray14 ; - QBrush kLineComponentClick ; - QBrush kWhite ; - QBrush kGray7 ; - QBrush kBrandFocus ; - QBrush kGrayAlpha9 ; - QBrush kGrayAlpha10 ; - QBrush kGrayAlpha6 ; - QBrush kContainHover ; - QBrush kLineComponentDisable ; - QBrush kFontWhite ; - QBrush kGrayAlpha11 ; - QBrush kGray6 ; - QBrush kFontWhiteDisable ; - QBrush kComponentDisable ; - QBrush kBlack ; - QBrush kComponentAlphaDisable ; - QBrush kFontSecondaryDisable ; - QBrush kGrayAlpha8 ; - QBrush kFontPrimaryDisable ; - QBrush kGray5 ; - QBrush kFontSecondary ; - QBrush kErrorNormal ; - QBrush kComponentHover ; - QBrush kComponentAlphaHover ; - QBrush kGrayAlpha3 ; - QBrush kGray13 ; - QBrush kGray11 ; - QBrush kErrorHover ; - QBrush kContainGeneralNormal ; - QBrush kComponentAlphaNormal ; - QBrush kGray15 ; - QBrush kBrand7 ; - QBrush kGrayAlpha7 ; - QBrush kLineBrandHover ; - QBrush kGrayAlpha13 ; - QBrush kLineComponentHover ; - QBrush kBrand6 ; - QBrush kGray17 ; - QBrush kComponentClick ; - QBrush kBrandClick ; - QBrush kFontStrong ; - QBrush kLineWindow ; - QBrush kGray2 ; - QBrush kBrand4 ; - QBrush kContainSecondaryNormal ; - QBrush kBrandHover ; - QBrush kFontPrimary ; - QBrush kBrandNormal ; - //line and margin - int normalline = 1; - int focusline = 2; - int tokenGap4 = 4; - int tokenGap8 = 8; - int tokenGap16 = 16; - int tokenGap24 = 40; - int tokenGap40 = 24; + QBrush alternateBaseActive = QBrush(Qt::NoBrush); + QBrush alternateBaseDisable = QBrush(Qt::NoBrush); + QBrush alternateBaseInactive = QBrush(Qt::NoBrush); + QBrush baseActive = QBrush(Qt::NoBrush); + QBrush baseDisable = QBrush(Qt::NoBrush); + QBrush baseInactive = QBrush(Qt::NoBrush); + QBrush brightTextActive = QBrush(Qt::NoBrush); + QBrush brightTextDisable = QBrush(Qt::NoBrush); + QBrush brightTextInactive = QBrush(Qt::NoBrush); + QBrush buttonActive = QBrush(Qt::NoBrush); + QBrush buttonDisable = QBrush(Qt::NoBrush); + QBrush buttonInactive = QBrush(Qt::NoBrush); + QBrush buttonTextActive = QBrush(Qt::NoBrush); + QBrush buttonTextDisable = QBrush(Qt::NoBrush); + QBrush buttonTextInactive = QBrush(Qt::NoBrush); + QBrush darkActive = QBrush(Qt::NoBrush); + QBrush darkDisable = QBrush(Qt::NoBrush); + QBrush darkInactive = QBrush(Qt::NoBrush); + int focusline ; + QBrush highLightActive = QBrush(Qt::NoBrush); + QBrush highLightDisable = QBrush(Qt::NoBrush); + QBrush highLightInactive = QBrush(Qt::NoBrush); + QBrush highLightedTextActive = QBrush(Qt::NoBrush); + QBrush highLightedTextDisable = QBrush(Qt::NoBrush); + QBrush highLightedTextInactive = QBrush(Qt::NoBrush); + QBrush kBlack = QBrush(Qt::NoBrush); + QBrush kBrand1 = QBrush(Qt::NoBrush); + QBrush kBrand2 = QBrush(Qt::NoBrush); + QBrush kBrand3 = QBrush(Qt::NoBrush); + QBrush kBrand4 = QBrush(Qt::NoBrush); + QBrush kBrand5 = QBrush(Qt::NoBrush); + QBrush kBrand6 = QBrush(Qt::NoBrush); + QBrush kBrand7 = QBrush(Qt::NoBrush); + QBrush kBrand8 = QBrush(Qt::NoBrush); + QBrush kBrand9 = QBrush(Qt::NoBrush); + QBrush kBrandClick = QBrush(Qt::NoBrush); + QBrush kBrandDisable = QBrush(Qt::NoBrush); + QBrush kBrandFocus = QBrush(Qt::NoBrush); + QBrush kBrandHover = QBrush(Qt::NoBrush); + QBrush kBrandNormal = QBrush(Qt::NoBrush); + QBrush kComponentAlphaClick = QBrush(Qt::NoBrush); + QBrush kComponentAlphaDisable = QBrush(Qt::NoBrush); + QBrush kComponentAlphaHover = QBrush(Qt::NoBrush); + QBrush kComponentAlphaNormal = QBrush(Qt::NoBrush); + QBrush kComponentClick = QBrush(Qt::NoBrush); + QBrush kComponentDisable = QBrush(Qt::NoBrush); + QBrush kComponentHover = QBrush(Qt::NoBrush); + QBrush kComponentNormal = QBrush(Qt::NoBrush); + QBrush kComponentSelectedAlphaDisable = QBrush(Qt::NoBrush); + QBrush kComponentSelectedAlphaNormal = QBrush(Qt::NoBrush); + QBrush kComponentSelectedAlphaHover = QBrush(Qt::NoBrush); + QBrush kComponentSelectedAlphaClick = QBrush(Qt::NoBrush); + + QBrush kComponentInput = QBrush(Qt::NoBrush); + QBrush kComponentInputAlpha = QBrush(Qt::NoBrush); + + QBrush kComponentSelectedDisable = QBrush(Qt::NoBrush); + QBrush kComponentSelectedNormal = QBrush(Qt::NoBrush); + QBrush kComponentSelectedHover = QBrush(Qt::NoBrush); + QBrush kComponentSelectedClick = QBrush(Qt::NoBrush); + + QBrush kContainAlphaClick = QBrush(Qt::NoBrush); + QBrush kContainAlphaHover = QBrush(Qt::NoBrush); + QBrush kContainClick = QBrush(Qt::NoBrush); + QBrush kContainGeneralAlphaNormal = QBrush(Qt::NoBrush); + QBrush kContainGeneralInactive = QBrush(Qt::NoBrush); + QBrush kContainGeneralNormal = QBrush(Qt::NoBrush); + QBrush kContainHover = QBrush(Qt::NoBrush); + QBrush kContainSecondaryAlphaNormal = QBrush(Qt::NoBrush); + QBrush kContainSecondaryInactive = QBrush(Qt::NoBrush); + QBrush kContainSecondaryNormal = QBrush(Qt::NoBrush); + QBrush kDivider = QBrush(Qt::NoBrush); + QBrush kDividerWhite = QBrush(Qt::NoBrush); + QBrush kErrorClick = QBrush(Qt::NoBrush); + QBrush kErrorDisable = QBrush(Qt::NoBrush); + QBrush kErrorHover = QBrush(Qt::NoBrush); + QBrush kErrorNormal = QBrush(Qt::NoBrush); + QBrush kFontPlaceholdertextDisable = QBrush(Qt::NoBrush); + QBrush kFontPlaceholdertext = QBrush(Qt::NoBrush); + QBrush kFontPrimaryDisable = QBrush(Qt::NoBrush); + QBrush kFontPrimary = QBrush(Qt::NoBrush); + QBrush kFontSecondaryDisable = QBrush(Qt::NoBrush); + QBrush kFontSecondary = QBrush(Qt::NoBrush); + QBrush kFontStrong = QBrush(Qt::NoBrush); + QBrush kFontWhiteDisable = QBrush(Qt::NoBrush); + QBrush kFontWhitePlaceholdertextDisable = QBrush(Qt::NoBrush); + QBrush kFontWhiteplaceholdertext = QBrush(Qt::NoBrush); + QBrush kFontWhite = QBrush(Qt::NoBrush); + QBrush kFontWhiteSecondaryDisable = QBrush(Qt::NoBrush); + QBrush kFontWhiteSecondary = QBrush(Qt::NoBrush); + QBrush kGray0 = QBrush(Qt::NoBrush); + QBrush kGray1 = QBrush(Qt::NoBrush); + QBrush kGray2 = QBrush(Qt::NoBrush); + QBrush kGray3 = QBrush(Qt::NoBrush); + QBrush kGray4 = QBrush(Qt::NoBrush); + QBrush kGray5 = QBrush(Qt::NoBrush); + QBrush kGray6 = QBrush(Qt::NoBrush); + QBrush kGray7 = QBrush(Qt::NoBrush); + QBrush kGray8 = QBrush(Qt::NoBrush); + QBrush kGray9 = QBrush(Qt::NoBrush); + QBrush kGray10 = QBrush(Qt::NoBrush); + QBrush kGray11 = QBrush(Qt::NoBrush); + QBrush kGray12 = QBrush(Qt::NoBrush); + QBrush kGray13 = QBrush(Qt::NoBrush); + QBrush kGray14 = QBrush(Qt::NoBrush); + QBrush kGray15 = QBrush(Qt::NoBrush); + QBrush kGray16 = QBrush(Qt::NoBrush); + QBrush kGray17 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha0 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha10 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha11 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha12 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha13 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha1 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha2 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha3 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha4 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha5 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha6 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha7 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha8 = QBrush(Qt::NoBrush); + QBrush kGrayAlpha9 = QBrush(Qt::NoBrush); + QBrush kGreen1 = QBrush(Qt::NoBrush); + QBrush kLineBrandClick = QBrush(Qt::NoBrush); + QBrush kLineBrandDisable = QBrush(Qt::NoBrush); + QBrush kLineBrandHover = QBrush(Qt::NoBrush); + QBrush kLineBrandNormal = QBrush(Qt::NoBrush); + QBrush kLineComponentClick = QBrush(Qt::NoBrush); + QBrush kLineComponentDisable = QBrush(Qt::NoBrush); + QBrush kLineComponentHover = QBrush(Qt::NoBrush); + QBrush kLineComponentNormal = QBrush(Qt::NoBrush); + QBrush kLineDisable = QBrush(Qt::NoBrush); + QBrush kLineDock = QBrush(Qt::NoBrush); + QBrush kLineErrorClick = QBrush(Qt::NoBrush); + QBrush kLineErrorDisable = QBrush(Qt::NoBrush); + QBrush kLineErrorHover = QBrush(Qt::NoBrush); + QBrush kLineErrorNormal = QBrush(Qt::NoBrush); + QBrush kLineInputClick = QBrush(Qt::NoBrush); + QBrush kLineInputDisable = QBrush(Qt::NoBrush); + QBrush kLineInputHover = QBrush(Qt::NoBrush); + QBrush kLineInputNormal = QBrush(Qt::NoBrush); + QBrush kLineMenu = QBrush(Qt::NoBrush); + QBrush kLineNormal = QBrush(Qt::NoBrush); + QBrush kLineSelectboxClick = QBrush(Qt::NoBrush); + QBrush kLineSelectboxDisable = QBrush(Qt::NoBrush); + QBrush kLineSelectboxHover = QBrush(Qt::NoBrush); + QBrush kLineSelectboxNormal = QBrush(Qt::NoBrush); + QBrush kLineSelectboxSelected = QBrush(Qt::NoBrush); + QBrush kLineSuccessClick = QBrush(Qt::NoBrush); + QBrush kLineSuccessDisable = QBrush(Qt::NoBrush); + QBrush kLineSuccessHover = QBrush(Qt::NoBrush); + QBrush kLineSuccessNormal = QBrush(Qt::NoBrush); + QBrush kLineTable = QBrush(Qt::NoBrush); + QBrush kLineWarningClick = QBrush(Qt::NoBrush); + QBrush kLineWarningDisable = QBrush(Qt::NoBrush); + QBrush kLineWarningHover = QBrush(Qt::NoBrush); + QBrush kLineWarningNormal = QBrush(Qt::NoBrush); + QBrush kLineWindowActive = QBrush(Qt::NoBrush); + QBrush kLineWindowInactive = QBrush(Qt::NoBrush); + QBrush kMenu = QBrush(Qt::NoBrush); + QBrush kModalmask = QBrush(Qt::NoBrush); + QBrush kOrange1 = QBrush(Qt::NoBrush); + int kradiusMax ; + int kradiusMenu ; + int kradiusMin ; + int kradiusNormal ; + int kradiusWindow ; + QBrush kRed1 = QBrush(Qt::NoBrush); + QBrush kSelectAlphaWhiteClick = QBrush(Qt::NoBrush); + QBrush kSelectAlphaWhiteDisable = QBrush(Qt::NoBrush); + QBrush kSelectAlphaWhiteHover = QBrush(Qt::NoBrush); + QBrush kSelectAlphaWhite = QBrush(Qt::NoBrush); + QBrush kshadowComponent = QBrush(Qt::NoBrush); + QBrush kshadowMenu = QBrush(Qt::NoBrush); + QBrush kshadowMin = QBrush(Qt::NoBrush); + QBrush kshadowPrimaryActive = QBrush(Qt::NoBrush); + QBrush kshadowPrimaryInactive = QBrush(Qt::NoBrush); + QBrush kshadowSecondaryActive = QBrush(Qt::NoBrush); + QBrush kshadowSecondaryInactive = QBrush(Qt::NoBrush); + QBrush kSuccessClick = QBrush(Qt::NoBrush); + QBrush kSuccessDisable = QBrush(Qt::NoBrush); + QBrush kSuccessHover = QBrush(Qt::NoBrush); + QBrush kSuccessNormal = QBrush(Qt::NoBrush); + QBrush kWarningClick = QBrush(Qt::NoBrush); + QBrush kWarningDisable = QBrush(Qt::NoBrush); + QBrush kWarningHover = QBrush(Qt::NoBrush); + QBrush kWarningNormal = QBrush(Qt::NoBrush); + QBrush kWhite = QBrush(Qt::NoBrush); + QBrush lightActive = QBrush(Qt::NoBrush); + QBrush lightDisable = QBrush(Qt::NoBrush); + QBrush lightInactive = QBrush(Qt::NoBrush); + QBrush linkActive = QBrush(Qt::NoBrush); + QBrush linkDisable = QBrush(Qt::NoBrush); + QBrush linkInactive = QBrush(Qt::NoBrush); + QBrush linkVisitedActive = QBrush(Qt::NoBrush); + QBrush linkVisitedDisable = QBrush(Qt::NoBrush); + QBrush linkVisitedInactive = QBrush(Qt::NoBrush); + QBrush midActive = QBrush(Qt::NoBrush); + QBrush midDisable = QBrush(Qt::NoBrush); + QBrush midInactive = QBrush(Qt::NoBrush); + QBrush midlightActive = QBrush(Qt::NoBrush); + QBrush midlightDisable = QBrush(Qt::NoBrush); + QBrush midlightInactive = QBrush(Qt::NoBrush); + int normalline ; + QBrush noRoleActive = QBrush(Qt::NoBrush); + QBrush noRoleDisable = QBrush(Qt::NoBrush); + QBrush noRoleInactive = QBrush(Qt::NoBrush); + QBrush placeholderTextActive = QBrush(Qt::NoBrush); + QBrush placeholderTextDisable = QBrush(Qt::NoBrush); + QBrush placeholderTextInactive = QBrush(Qt::NoBrush); + QBrush shadow = QBrush(Qt::NoBrush); + QBrush shadowActive = QBrush(Qt::NoBrush); + QBrush shadowDisable = QBrush(Qt::NoBrush); + QBrush shadowInactive = QBrush(Qt::NoBrush); + QBrush textActive = QBrush(Qt::NoBrush); + QBrush textDisable = QBrush(Qt::NoBrush); + QBrush textInactive = QBrush(Qt::NoBrush); + + QBrush toolTipBaseActive = QBrush(Qt::NoBrush); + QBrush toolTipBaseDisable = QBrush(Qt::NoBrush); + QBrush toolTipBaseInactive = QBrush(Qt::NoBrush); + QBrush toolTipTextActive = QBrush(Qt::NoBrush); + QBrush toolTipTextDisable = QBrush(Qt::NoBrush); + QBrush toolTipTextInactive = QBrush(Qt::NoBrush); + QBrush windowActive = QBrush(Qt::NoBrush); + QBrush windowDisable = QBrush(Qt::NoBrush); + QBrush windowInactive = QBrush(Qt::NoBrush); + QBrush windowTextActive = QBrush(Qt::NoBrush); + QBrush windowTextDisable = QBrush(Qt::NoBrush); + QBrush windowTextInactive = QBrush(Qt::NoBrush); - //radius - int kradiusMin = 4; - int kradiusMenu = 8; - int kradiusNormal = 6; - int kradiusWindow = 12; bool m_ukui_dt_loadConfig = false; QString m_cfgPath; @@ -229,179 +296,12 @@ public: QString m_lightMode = "light"; QString m_ukui_dt_path; QString m_dt_configData; + QMap dtMap; }; class GlobalDTConfig : public QObject { Q_OBJECT - - //QT palette - Q_PROPERTY(QBrush windowTextActive READ windowTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush windowTextInactive READ windowTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush windowTextDisable READ windowTextDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonActive READ buttonActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonInactive READ buttonInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonDisable READ buttonDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush lightActive READ lightActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush lightInactive READ lightInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush lightDisable READ lightDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush midlightActive READ midlightActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush midlightInactive READ midlightInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush midlightDisable READ midlightDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush darkActive READ darkActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush darkInactive READ darkInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush darkDisable READ darkDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush midActive READ midActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush midInactive READ midInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush midDisable READ midDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush textActive READ textActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush textInactive READ textInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush textDisable READ textDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush brightTextActive READ brightTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush brightTextInactive READ brightTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush brightTextDisable READ brightTextDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonTextActive READ buttonTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonTextInactive READ buttonTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush buttonTextDisable READ buttonTextDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush baseActive READ baseActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush baseInactive READ baseInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush baseDisable READ baseDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush windowActive READ windowActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush windowInactive READ windowInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush windowDisable READ windowDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush shadowActive READ shadowActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush shadowInactive READ shadowInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush shadowDisable READ shadowDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightActive READ highLightActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightInactive READ highLightInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightDisable READ highLightDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightedTextActive READ highLightedTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightedTextInactive READ highLightedTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush highLightedTextDisable READ highLightedTextDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkActive READ linkActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkInactive READ linkInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkDisable READ linkDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkVisitedActive READ linkVisitedActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkVisitedInactive READ linkVisitedInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush linkVisitedDisable READ linkVisitedDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush alternateBaseActive READ alternateBaseActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush alternateBaseInactive READ alternateBaseInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush alternateBaseDisable READ alternateBaseDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush noRoleActive READ noRoleActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush noRoleInactive READ noRoleInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush noRoleDisable READ noRoleDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipBaseActive READ toolTipBaseActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipBaseInactive READ toolTipBaseInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipBaseDisable READ toolTipBaseDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipTextActive READ toolTipTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipTextInactive READ toolTipTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush toolTipTextDisable READ toolTipTextDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush placeholderTextActive READ placeholderTextActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush placeholderTextInactive READ placeholderTextInactive NOTIFY tokenChanged) - Q_PROPERTY(QBrush placeholderTextDisable READ placeholderTextDisable NOTIFY tokenChanged) - - //custom palette - Q_PROPERTY(QBrush kBlack READ kBlack NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand1 READ kBrand1 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand2 READ kBrand2 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand3 READ kBrand3 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand4 READ kBrand4 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand5 READ kBrand5 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand6 READ kBrand6 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrand7 READ kBrand7 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrandClick READ kBrandClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrandFocus READ kBrandFocus NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrandHover READ kBrandHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kBrandNormal READ kBrandNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentAlphaClick READ kComponentAlphaClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentAlphaDisable READ kComponentAlphaDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentAlphaHover READ kComponentAlphaHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentAlphaNormal READ kComponentAlphaNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentClick READ kComponentClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentDisable READ kComponentDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentHover READ kComponentHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kComponentNormal READ kComponentNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kContainClick READ kContainClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kContainHover READ kContainHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kContainGeneralNormal READ kContainGeneralNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kContainSecondaryAlpphaNormal READ kContainSecondaryAlpphaNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kContainSecondaryNormal READ kContainSecondaryNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kErrorClick READ kErrorClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kErrorHover READ kErrorHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kErrorNormal READ kErrorNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontPrimary READ kFontPrimary NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontPrimaryDisable READ kFontPrimaryDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontSecondary READ kFontSecondary NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontSecondaryDisable READ kFontSecondaryDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontStrong READ kFontStrong NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontWhite READ kFontWhite NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontWhiteDisable READ kFontWhiteDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontWhiteSecondary READ kFontWhiteSecondary NOTIFY tokenChanged) - Q_PROPERTY(QBrush kFontWhiteSecondaryDisable READ kFontWhiteSecondaryDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray0 READ kGray0 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray1 READ kGray1 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray2 READ kGray2 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray3 READ kGray3 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray4 READ kGray4 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray5 READ kGray5 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray6 READ kGray6 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray7 READ kGray7 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray8 READ kGray8 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray9 READ kGray9 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray10 READ kGray10 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray11 READ kGray11 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray12 READ kGray12 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray13 READ kGray13 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray14 READ kGray14 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray15 READ kGray15 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray16 READ kGray16 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGray17 READ kGray17 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha0 READ kGrayAlpha0 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha1 READ kGrayAlpha1 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha2 READ kGrayAlpha2 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha3 READ kGrayAlpha3 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha4 READ kGrayAlpha4 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha5 READ kGrayAlpha5 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha6 READ kGrayAlpha6 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha7 READ kGrayAlpha7 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha8 READ kGrayAlpha8 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha9 READ kGrayAlpha9 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha10 READ kGrayAlpha10 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha11 READ kGrayAlpha11 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha12 READ kGrayAlpha12 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kGrayAlpha13 READ kGrayAlpha13 NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineBrandClick READ kLineBrandClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineBrandDisable READ kLineBrandDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineBrandHover READ kLineBrandHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineBrandNormal READ kLineBrandNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineComponentClick READ kLineComponentClick NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineComponentDisable READ kLineComponentDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineComponentHover READ kLineComponentHover NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineComponentNormal READ kLineComponentNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineDisable READ kLineDisable NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineNormal READ kLineNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineWindow READ kLineWindow NOTIFY tokenChanged) - Q_PROPERTY(QBrush kLineWindowActive READ kLineWindowActive NOTIFY tokenChanged) - Q_PROPERTY(QBrush kModalmask READ kModalmask NOTIFY tokenChanged) - Q_PROPERTY(QBrush kSuccessNormal READ kSuccessNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kWarningNormal READ kWarningNormal NOTIFY tokenChanged) - Q_PROPERTY(QBrush kWhite READ kWhite NOTIFY tokenChanged) - - //line and margin - Q_PROPERTY(int normalline READ normalline NOTIFY tokenChanged) - Q_PROPERTY(int focusline READ focusline NOTIFY tokenChanged) - Q_PROPERTY(int tokenGap4 READ tokenGap4 NOTIFY tokenChanged) - Q_PROPERTY(int tokenGap8 READ tokenGap8 NOTIFY tokenChanged) - Q_PROPERTY(int tokenGap16 READ tokenGap16 NOTIFY tokenChanged) - Q_PROPERTY(int tokenGap24 READ tokenGap24 NOTIFY tokenChanged) - Q_PROPERTY(int tokenGap40 READ tokenGap40 NOTIFY tokenChanged) - - //radius - Q_PROPERTY(int kradiusMin READ kradiusMin NOTIFY tokenChanged) - Q_PROPERTY(int kradiusMenu READ kradiusMenu NOTIFY tokenChanged) - Q_PROPERTY(int kradiusNormal READ kradiusNormal NOTIFY tokenChanged) - Q_PROPERTY(int kradiusWindow READ kradiusWindow NOTIFY tokenChanged) - public: explicit GlobalDTConfig(); ~GlobalDTConfig(); @@ -492,10 +392,23 @@ public: QBrush kComponentDisable() const; QBrush kComponentHover() const; QBrush kComponentNormal() const; + + QBrush kComponentInput() const; + QBrush kComponentInputAlpha() const; + + QBrush kComponentSelectedAlphaDisable() const; + QBrush kComponentSelectedAlphaNormal() const; + QBrush kComponentSelectedAlphaHover() const; + QBrush kComponentSelectedAlphaClick() const; + + QBrush kComponentSelectedDisable() const; + QBrush kComponentSelectedNormal() const; + QBrush kComponentSelectedHover() const; + QBrush kComponentSelectedClick() const; + QBrush kContainClick() const; QBrush kContainHover() const; QBrush kContainGeneralNormal() const; - QBrush kContainSecondaryAlpphaNormal() const; QBrush kContainSecondaryNormal() const; QBrush kErrorClick() const; QBrush kErrorHover() const; @@ -551,7 +464,6 @@ public: QBrush kLineComponentNormal() const; QBrush kLineDisable() const; QBrush kLineNormal() const; - QBrush kLineWindow() const; QBrush kLineWindowActive() const; QBrush kModalmask() const; QBrush kSuccessNormal() const; @@ -561,11 +473,6 @@ public: //line and margin int normalline() const; int focusline() const; - int tokenGap4() const; - int tokenGap8() const; - int tokenGap16() const; - int tokenGap24() const; - int tokenGap40() const; //radius int kradiusMin() const; @@ -573,6 +480,136 @@ public: int kradiusNormal() const; int kradiusWindow() const; + QBrush kBrand8() const; + + QBrush kBrand9() const; + + QBrush kBrandDisable() const; + + QBrush kContainAlphaClick() const; + + QBrush kContainAlphaHover() const; + + QBrush kContainGeneralAlphaNormal() const; + + QBrush kContainGeneralInactive() const; + + QBrush kContainSecondaryAlphaNormal() const; + + QBrush kContainSecondaryInactive() const; + + QBrush kDivider() const; + + QBrush kDividerWhite() const; + + QBrush kErrorDisable() const; + + QBrush kFontPlaceholdertextDisable() const; + + QBrush kFontPlaceholdertext() const; + + QBrush kFontWhitePlaceholdertextDisable() const; + + QBrush kFontWhiteplaceholdertext() const; + + QBrush kGreen1() const; + + QBrush kLineDock() const; + + QBrush kLineErrorClick() const; + + QBrush kLineErrorDisable() const; + + QBrush kLineErrorHover() const; + + QBrush kLineErrorNormal() const; + + QBrush kLineInputClick() const; + + QBrush kLineInputDisable() const; + + QBrush kLineInputHover() const; + + QBrush kLineInputNormal() const; + + QBrush kLineMenu() const; + + QBrush kLineSelectboxClick() const; + + QBrush kLineSelectboxDisable() const; + + QBrush kLineSelectboxHover() const; + + QBrush kLineSelectboxNormal() const; + + QBrush kLineSelectboxSelected() const; + + QBrush kLineSuccessClick() const; + + QBrush kLineSuccessDisable() const; + + QBrush kLineSuccessHover() const; + + QBrush kLineSuccessNormal() const; + + QBrush kLineTable() const; + + QBrush kLineWarningClick() const; + + QBrush kLineWarningDisable() const; + + QBrush kLineWarningHover() const; + + QBrush kLineWarningNormal() const; + + QBrush kLineWindowInactive() const; + + QBrush kMenu() const; + + QBrush kOrange1() const; + + int kradiusMax() const; + + QBrush kRed1() const; + + QBrush kSelectAlphaWhiteClick() const; + + QBrush kSelectAlphaWhiteDisable() const; + + QBrush kSelectAlphaWhiteHover() const; + + QBrush kSelectAlphaWhite() const; + + QBrush kshadowComponent() const; + + QBrush kshadowMenu() const; + + QBrush kshadowMin() const; + + QBrush kshadowPrimaryActive() const; + + QBrush kshadowPrimaryInactive() const; + + QBrush kshadowSecondaryActive() const; + + QBrush kshadowSecondaryInactive() const; + + QBrush kSuccessClick() const; + + QBrush kSuccessDisable() const; + + QBrush kSuccessHover() const; + + QBrush kWarningClick() const; + + QBrush kWarningDisable() const; + + QBrush kWarningHover() const; + + QBrush shadow() const; + + QPalette appPalette(); + Q_SIGNALS: void tokenChanged(); @@ -583,4 +620,9 @@ private: } +Q_DECLARE_METATYPE(QBrush*) +Q_DECLARE_METATYPE(QSharedPointer) +Q_DECLARE_METATYPE(int*) +Q_DECLARE_METATYPE(QSharedPointer) + #endif // READCONFIG_H diff --git a/ukui-styles/ukui-style-plugin.cpp b/ukui-styles/ukui-style-plugin.cpp index b9b8aba..388c642 100644 --- a/ukui-styles/ukui-style-plugin.cpp +++ b/ukui-styles/ukui-style-plugin.cpp @@ -40,7 +40,6 @@ UKUIStylePlugin::UKUIStylePlugin(QObject *parent) : QStylePlugin(parent) { - qDebug() << "UKUIStylePlugin........."; if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) { auto settings = UKUIStyleSettings::globalInstance(); connect(settings, &UKUIStyleSettings::changed, this, [=](const QString &key) { @@ -60,7 +59,6 @@ UKUIStylePlugin::UKUIStylePlugin(QObject *parent) : // if (appStyleSettings->currentStyleStretagy() != ApplicationStyleSettings::Default) // return; - qDebug() << "UKUIStyleSettings change...." << key; auto styleName = settings->get("styleName").toString(); auto widgetThemeName = settings->get("widgetThemeName").toString(); @@ -95,16 +93,23 @@ UKUIStylePlugin::UKUIStylePlugin(QObject *parent) : if (key == "useSystemPalette") { onSystemPaletteChanged(); } + + if (key == "windowRadius") { + foreach (QWidget *widget, qApp->allWidgets()) { + widget->update(); + } + } + }); } - QDBusInterface *interFace = new QDBusInterface("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - QDBusConnection::sessionBus()); - if(interFace->isValid()){ - connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); - } +// QDBusInterface *interFace = new QDBusInterface("com.kylin.statusmanager.interface", +// "/", +// "com.kylin.statusmanager.interface", +// QDBusConnection::sessionBus()); +// if(interFace->isValid()){ +// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(tableModeChanged(bool))); +// } } QStyle *UKUIStylePlugin::create(const QString &key) diff --git a/ukui-styles/window-manager.cpp b/ukui-styles/window-manager.cpp index 42216d8..287422f 100644 --- a/ukui-styles/window-manager.cpp +++ b/ukui-styles/window-manager.cpp @@ -48,6 +48,7 @@ WindowManager::WindowManager(QObject *parent) : QObject(parent) if (QX11Info::isPlatformX11()) return; +#if (QT_VERSION < QT_VERSION_CHECK(5,15,0)) using namespace KWayland::Client; m_connection = ConnectionThread::fromApplication(qApp); if (!m_connection) @@ -77,6 +78,7 @@ WindowManager::WindowManager(QObject *parent) : QObject(parent) m_registry->setup(); m_connection->roundtrip(); +#endif } WindowManager::~WindowManager() @@ -103,6 +105,14 @@ void WindowManager::unregisterWidget(QWidget *w) bool WindowManager::eventFilter(QObject *obj, QEvent *e) { + + QWidget *w = qobject_cast(obj); + auto var = w->property("useStyleWindowManager"); + if (!var.isNull() && !var.toBool()) { + return false; + } + + switch (e->type()) { case QEvent::MouseButtonPress: { QMouseEvent *event = static_cast(e); -- Gitee