From 4a75b81acb3325674fac4d9aafce1badae3f80a3 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Sat, 20 Mar 2021 15:37:24 +0800 Subject: [PATCH] Multiple improvements --- src/controls/BlurBackground.qml | 81 --------------------------------- src/controls/Menu.qml | 64 -------------------------- src/controls/Theme.qml | 3 ++ src/controls/Window.qml | 21 +++++++++ src/images/dark/close.svg | 6 +-- src/images/dark/maximize.svg | 2 +- src/images/dark/minimize.svg | 4 +- src/images/dark/restore.svg | 24 ++++------ src/meui-style/Button.qml | 8 ++-- src/meui-style/ComboBox.qml | 2 +- src/meui-style/TextField.qml | 5 +- src/meuikit.cpp | 2 - src/meuikit.qrc | 2 - src/thememanager.cpp | 7 +++ src/thememanager.h | 3 ++ 15 files changed, 58 insertions(+), 176 deletions(-) delete mode 100644 src/controls/BlurBackground.qml delete mode 100644 src/controls/Menu.qml diff --git a/src/controls/BlurBackground.qml b/src/controls/BlurBackground.qml deleted file mode 100644 index ad55c7f..0000000 --- a/src/controls/BlurBackground.qml +++ /dev/null @@ -1,81 +0,0 @@ - -/* - * Copyright 2021 Rui Wang - * - * 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 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * 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 . - */ - -import QtQuick 2.12 -import QtGraphicalEffects 1.0 - -Item { - id: blurBackground - - property QtObject sourceItem: null - - property real blurRadius: 0 - property real radius: 0 - property color backgroundColor - - property int startX: 0 - property int startY: 0 - - ShaderEffectSource { - id:eff - anchors.fill: parent - sourceItem: blurBackground.sourceItem - sourceRect: Qt.rect(blurBackground.startX,blurBackground.startY,blurBackground.width,blurBackground.height) - visible: false - } - - onStartXChanged: { - var jx = eff.mapToItem(blurBackground.sourceItem, blurBackground.x, blurBackground.y) - blurBackground.startX = jx.x - blurBackground.startY = jx.y - eff.sourceRect = Qt.rect(blurBackground.startX,blurBackground.startY,blurBackground.width,blurBackground.height) - } - - FastBlur { - id:fastBlur - anchors.fill: parent - source: eff - radius: blurBackground.blurRadius - cached: true - visible: true - } - - Rectangle { - id: maskRect - anchors.fill: parent - color: blurBackground.backgroundColor - radius: blurBackground.radius - visible: false - } - - OpacityMask { - id:mask - anchors.fill: maskRect - source: fastBlur - maskSource: maskRect - } - - Rectangle { - anchors.fill: parent - color: blurBackground.backgroundColor - radius: blurBackground.radius - } -} \ No newline at end of file diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml deleted file mode 100644 index 7f83fd7..0000000 --- a/src/controls/Menu.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 as QQC2 -import QtGraphicalEffects 1.0 -import MeuiKit 1.0 as Meui - -QQC2.Menu { - id: control - - property real blurRadius: 100 - // property alias blurRadius: bkground.blurRadius - property alias backgroundOpacity: _menubg.backgroundOpacity - property real backgroundRadius: Meui.Theme.smallRadius - - background: Meui.RoundedRect { - id: _menubg - backgroundOpacity: 0.7 - radius: control.backgroundRadius - blurEnabled: true - sourceItem: control.parent - - layer.enabled: true - layer.effect: DropShadow { - transparentBorder: true - radius: 32 - samples: 32 - horizontalOffset: 0 - verticalOffset: 0 - color: Qt.rgba(0, 0, 0, 0.11) - } - } - - // background: Meui.BlurBackground { - // id: bkground - // sourceItem: control.parent - // backgroundColor: "transparent" - // startX: control.x - // startY: control.y - // blurRadius: 144 - // radius: control.backgroundRadius - - // Meui.RoundedRect { - // id: roundedRect - // anchors.fill: parent - // backgroundOpacity: 0.7 - // radius: control.backgroundRadius - // } - - // layer.enabled: true - // layer.effect: DropShadow { - // transparentBorder: true - // radius: 32 - // samples: 32 - // horizontalOffset: 0 - // verticalOffset: 0 - // color: Qt.rgba(0, 0, 0, 0.11) - // } - // } - - // onVisibleChanged: { - // var jx = contentItem.mapToItem(control.parent, control.x, control.y) - // bkground.startX = jx.x - // bkground.startY = jx.y - // } -} \ No newline at end of file diff --git a/src/controls/Theme.qml b/src/controls/Theme.qml index 6a34434..4a63516 100644 --- a/src/controls/Theme.qml +++ b/src/controls/Theme.qml @@ -6,6 +6,8 @@ import MeuiKit.Core 1.0 as MeuiKitCore QtObject { id: theme + property real devicePixelRatio: MeuiKitCore.ThemeManager.devicePixelRatio + property bool darkMode: MeuiKitCore.ThemeManager.darkMode property color blueColor: MeuiKitCore.ThemeManager.blueColor @@ -33,6 +35,7 @@ QtObject { property color visitedLinkBackgroundColor: "#2196F3" property real smallRadius: 8.0 + property real mediumRadius: 10.0 property real bigRadius: 12.0 property font defaultFont: fontMetrics.font diff --git a/src/controls/Window.qml b/src/controls/Window.qml index eb408bd..c14a9e0 100644 --- a/src/controls/Window.qml +++ b/src/controls/Window.qml @@ -87,6 +87,27 @@ Window { } } + // Top edge + MouseArea { + height: edgeSize / 2 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.leftMargin: edgeSize * 2 + anchors.rightMargin: edgeSize * 2 + visible: !isMaximized && !isFullScreen + cursorShape: Qt.SizeVerCursor + z: 999 + + onPressed: mouse.accepted = false + + DragHandler { + grabPermissions: TapHandler.CanTakeOverFromAnything + target: null + onActiveChanged: if (active) { windowHelper.startSystemResize(root, Qt.TopEdge) } + } + } + // Bottom edge MouseArea { height: edgeSize / 2 diff --git a/src/images/dark/close.svg b/src/images/dark/close.svg index e5552e1..d21bb35 100644 --- a/src/images/dark/close.svg +++ b/src/images/dark/close.svg @@ -79,14 +79,14 @@ + style="fill:#FFFFFF;fill-opacity:1"> + style="fill:#FFFFFF;fill-opacity:1"> + style="fill:#FFFFFF;fill-opacity:1" /> diff --git a/src/images/dark/maximize.svg b/src/images/dark/maximize.svg index 60fdc15..eb7956a 100644 --- a/src/images/dark/maximize.svg +++ b/src/images/dark/maximize.svg @@ -87,7 +87,7 @@ y="294.87387" ry="4.4795979e-06" /> + style="fill:#ffffff;fill-opacity:1" /> diff --git a/src/images/dark/restore.svg b/src/images/dark/restore.svg index 070d900..ecef38b 100644 --- a/src/images/dark/restore.svg +++ b/src/images/dark/restore.svg @@ -72,19 +72,15 @@ transform="matrix(0.26458333,0,0,0.26458333,8.6603107,0.81148024)" inkscape:label="#g3842" id="4-75" /> - - - - + + diff --git a/src/meui-style/Button.qml b/src/meui-style/Button.qml index 5fd631a..1a8cb4c 100644 --- a/src/meui-style/Button.qml +++ b/src/meui-style/Button.qml @@ -6,7 +6,7 @@ import QtQuick.Controls.impl 2.4 T.Button { id: control - implicitWidth: Math.max(background.implicitWidth + Meui.Units.extendBorderWidth, + implicitWidth: Math.max(background.implicitWidth + Meui.Units.extendBorderWidth + Meui.Theme.mediumRadius / 2, contentItem.implicitWidth + Meui.Units.largeSpacing + Meui.Units.extendBorderWidth) implicitHeight: background.implicitHeight + Meui.Units.extendBorderWidth hoverEnabled: true @@ -48,9 +48,9 @@ T.Button color: "transparent" border.color: control.activeFocus ? Qt.rgba(Meui.Theme.highlightColor.r, Meui.Theme.highlightColor.g, - Meui.Theme.highlightColor.b, 0.3) : "transparent" + Meui.Theme.highlightColor.b, 0.2) : "transparent" border.width: Meui.Units.extendBorderWidth - radius: Meui.Theme.smallRadius + Meui.Units.extendBorderWidth + radius: Meui.Theme.mediumRadius + Meui.Units.extendBorderWidth Behavior on border.color { ColorAnimation { @@ -62,7 +62,7 @@ T.Button Rectangle { anchors.fill: parent anchors.margins: Meui.Units.extendBorderWidth - radius: Meui.Theme.smallRadius + radius: Meui.Theme.mediumRadius border.color: control.activeFocus || control.pressed ? Meui.Theme.highlightColor : Qt.tint(Meui.Theme.textColor, Qt.rgba(Meui.Theme.backgroundColor.r, Meui.Theme.backgroundColor.g, Meui.Theme.backgroundColor.b, 0.7)) border.width: 1 diff --git a/src/meui-style/ComboBox.qml b/src/meui-style/ComboBox.qml index badd79e..d5742d0 100644 --- a/src/meui-style/ComboBox.qml +++ b/src/meui-style/ComboBox.qml @@ -111,7 +111,7 @@ T.ComboBox { color: "transparent" border.color: control.activeFocus ? Qt.rgba(Meui.Theme.highlightColor.r, Meui.Theme.highlightColor.g, - Meui.Theme.highlightColor.b, 0.3) : "transparent" + Meui.Theme.highlightColor.b, 0.2) : "transparent" border.width: Meui.Units.extendBorderWidth radius: Meui.Theme.smallRadius + Meui.Units.extendBorderWidth diff --git a/src/meui-style/TextField.qml b/src/meui-style/TextField.qml index 1e7c9f9..f5315d7 100644 --- a/src/meui-style/TextField.qml +++ b/src/meui-style/TextField.qml @@ -76,7 +76,8 @@ T.TextField { background: Rectangle { implicitWidth: (Meui.Units.iconSizes.medium * 3) + Meui.Units.smallSpacing + Meui.Units.extendBorderWidth implicitHeight: Meui.Units.iconSizes.medium + Meui.Units.smallSpacing + Meui.Units.extendBorderWidth - color: control.activeFocus ? Qt.lighter(Meui.Theme.backgroundColor, 1.4) : Meui.Theme.backgroundColor + // color: control.activeFocus ? Qt.lighter(Meui.Theme.backgroundColor, 1.4) : Meui.Theme.backgroundColor + color: "transparent" radius: Meui.Theme.smallRadius Rectangle { @@ -85,7 +86,7 @@ T.TextField { color: "transparent" border.color: control.activeFocus ? Qt.rgba(Meui.Theme.highlightColor.r, Meui.Theme.highlightColor.g, - Meui.Theme.highlightColor.b, 0.3) : "transparent" + Meui.Theme.highlightColor.b, 0.2) : "transparent" border.width: Meui.Units.extendBorderWidth radius: Meui.Theme.smallRadius + Meui.Units.extendBorderWidth diff --git a/src/meuikit.cpp b/src/meuikit.cpp index b6028a3..7f1c4b7 100644 --- a/src/meuikit.cpp +++ b/src/meuikit.cpp @@ -56,10 +56,8 @@ void MeuiKit::registerTypes(const char *uri) qmlRegisterSingletonType(componentUrl(QStringLiteral("Theme.qml")), uri, 1, 0, "Theme"); qmlRegisterSingletonType(componentUrl(QStringLiteral("Units.qml")), uri, 1, 0, "Units"); - qmlRegisterType(componentUrl(QStringLiteral("BlurBackground.qml")), uri, 1, 0, "BlurBackground"); qmlRegisterType(componentUrl(QStringLiteral("BusyIndicator.qml")), uri, 1, 0, "BusyIndicator"); qmlRegisterType(componentUrl(QStringLiteral("Icon.qml")), uri, 1, 0, "Icon"); - qmlRegisterType(componentUrl(QStringLiteral("Menu.qml")), uri, 1, 0, "Menu"); qmlRegisterType(componentUrl(QStringLiteral("MouseHover.qml")), uri, 1, 0, "MouseHover"); qmlRegisterType(componentUrl(QStringLiteral("PopupTips.qml")), uri, 1, 0, "PopupTips"); qmlRegisterType(componentUrl(QStringLiteral("RoundedRect.qml")), uri, 1, 0, "RoundedRect"); diff --git a/src/meuikit.qrc b/src/meuikit.qrc index 978d5f6..88d4bdc 100644 --- a/src/meuikit.qrc +++ b/src/meuikit.qrc @@ -1,9 +1,7 @@ - controls/BlurBackground.qml controls/BusyIndicator.qml controls/Icon.qml - controls/Menu.qml controls/MouseHover.qml controls/PopupTips.qml controls/RoundedRect.qml diff --git a/src/thememanager.cpp b/src/thememanager.cpp index 2add4ce..943dc4c 100644 --- a/src/thememanager.cpp +++ b/src/thememanager.cpp @@ -19,6 +19,8 @@ #include "thememanager.h" +#include + #include #include #include @@ -44,6 +46,11 @@ ThemeManager::ThemeManager(QObject *parent) initData(); } +qreal ThemeManager::devicePixelRatio() const +{ + return qApp->devicePixelRatio(); +} + void ThemeManager::initData() { QDBusInterface iface(Service, ObjectPath, Interface, QDBusConnection::sessionBus(), this); diff --git a/src/thememanager.h b/src/thememanager.h index 4a3d0a9..4683f01 100644 --- a/src/thememanager.h +++ b/src/thememanager.h @@ -42,10 +42,13 @@ class ThemeManager : public QObject Q_PROPERTY(QColor purpleColor READ purpleColor CONSTANT) Q_PROPERTY(QColor pinkColor READ pinkColor CONSTANT) Q_PROPERTY(QColor orangeColor READ orangeColor CONSTANT) + Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio CONSTANT) public: explicit ThemeManager(QObject *parent = nullptr); + qreal devicePixelRatio() const; + bool darkMode() { return m_darkMode; } QColor accentColor() { return m_accentColor; }