From 569e0f8f6474e30fae3a2c5edb82d4424f0f2178 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 21 Jun 2023 15:16:39 +0000 Subject: [PATCH] Port to KSvg port Svg and FrameSvg items to KSvg --- .kde-ci.yml | 1 + CMakeLists.txt | 1 + .../package/contents/ui/osd.qml | 5 ++-- .../aurorae/src/qml/AuroraeButton.qml | 19 ++++++------- .../kdecorations/aurorae/src/qml/aurorae.qml | 27 ++++++++++--------- .../private/qml/WindowHeapDelegate.qml | 3 ++- src/plugins/tileseditor/qml/main.qml | 11 ++++---- src/qml/frames/plasma/frame_styled.qml | 3 ++- src/qml/outline/plasma/outline.qml | 15 ++++++----- src/scripting/scripting.cpp | 1 + .../thumbnail_grid/contents/ui/main.qml | 5 ++-- 11 files changed, 51 insertions(+), 40 deletions(-) diff --git a/.kde-ci.yml b/.kde-ci.yml index a99ec1e5bb..65c9a9716b 100644 --- a/.kde-ci.yml +++ b/.kde-ci.yml @@ -30,6 +30,7 @@ Dependencies: 'frameworks/plasma-framework': '@latest-kf6' 'libraries/libqaccessibilityclient': '@latest-kf6' 'libraries/plasma-wayland-protocols': '@latest-kf6' + 'frameworks/ksvg': '@latest-kf6' 'plasma/breeze': '@same' 'plasma/kdecoration': '@same' 'plasma/kglobalacceld': '@same' diff --git a/CMakeLists.txt b/CMakeLists.txt index 47c7167c4a..994bee9574 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS IdleTime Package Plasma + Svg WidgetsAddons WindowSystem ) diff --git a/src/plugins/desktopchangeosd/package/contents/ui/osd.qml b/src/plugins/desktopchangeosd/package/contents/ui/osd.qml index 4aeff40008..0e9cab3f6e 100644 --- a/src/plugins/desktopchangeosd/package/contents/ui/osd.qml +++ b/src/plugins/desktopchangeosd/package/contents/ui/osd.qml @@ -9,6 +9,7 @@ import QtQuick import QtQuick.Window import org.kde.plasma.core as PlasmaCore +import org.kde.ksvg 1.0 as KSvg import org.kde.plasma.extras as PlasmaExtras import org.kde.kwin @@ -95,12 +96,12 @@ PlasmaCore.Dialog { Item { width: view.itemWidth height: view.itemHeight - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { anchors.fill: parent imagePath: "widgets/pager" prefix: "normal" } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: activeElement anchors.fill: parent imagePath: "widgets/pager" diff --git a/src/plugins/kdecorations/aurorae/src/qml/AuroraeButton.qml b/src/plugins/kdecorations/aurorae/src/qml/AuroraeButton.qml index 9ba4d6deb6..b0f687508f 100644 --- a/src/plugins/kdecorations/aurorae/src/qml/AuroraeButton.qml +++ b/src/plugins/kdecorations/aurorae/src/qml/AuroraeButton.qml @@ -5,6 +5,7 @@ */ import QtQuick import org.kde.plasma.core as PlasmaCore +import org.kde.ksvg 1.0 as KSvg import org.kde.kwin.decoration DecorationButton { @@ -79,7 +80,7 @@ DecorationButton { } width: widthForButton() * auroraeTheme.buttonSizeFactor height: auroraeTheme.buttonHeight * auroraeTheme.buttonSizeFactor - PlasmaCore.FrameSvg { + KSvg.FrameSvg { property bool supportsHover: hasElementPrefix("hover") property bool supportsPressed: hasElementPrefix("pressed") property bool supportsDeactivated: hasElementPrefix("deactivated") @@ -90,7 +91,7 @@ DecorationButton { id: buttonSvg imagePath: pathForButton() } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonActive property bool shown: (decoration.client.active || !buttonSvg.supportsInactive) && ((!pressed && !toggled) || !buttonSvg.supportsPressed) && (!hovered || !buttonSvg.supportsHover) && (enabled || !buttonSvg.supportsDeactivated) anchors.fill: parent @@ -103,7 +104,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonActiveHover property bool shown: hovered && !pressed && !toggled && buttonSvg.supportsHover && (decoration.client.active || !buttonSvg.supportsInactiveHover) anchors.fill: parent @@ -116,7 +117,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonActivePressed property bool shown: (toggled || pressed) && buttonSvg.supportsPressed && (decoration.client.active || !buttonSvg.supportsInactivePressed) anchors.fill: parent @@ -129,7 +130,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonActiveDeactivated property bool shown: !enabled && buttonSvg.supportsDeactivated && (decoration.client.active || !buttonSvg.supportsInactiveDeactivated) anchors.fill: parent @@ -142,7 +143,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonInactive property bool shown: !decoration.client.active && buttonSvg.supportsInactive && !hovered && !pressed && !toggled && enabled anchors.fill: parent @@ -155,7 +156,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonInactiveHover property bool shown: !decoration.client.active && hovered && !pressed && !toggled && buttonSvg.supportsInactiveHover anchors.fill: parent @@ -168,7 +169,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonInactivePressed property bool shown: !decoration.client.active && (toggled || pressed) && buttonSvg.supportsInactivePressed anchors.fill: parent @@ -181,7 +182,7 @@ DecorationButton { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: buttonInactiveDeactivated property bool shown: !decoration.client.active && !enabled && buttonSvg.supportsInactiveDeactivated anchors.fill: parent diff --git a/src/plugins/kdecorations/aurorae/src/qml/aurorae.qml b/src/plugins/kdecorations/aurorae/src/qml/aurorae.qml index 0e1bf527eb..bdfc4c066c 100644 --- a/src/plugins/kdecorations/aurorae/src/qml/aurorae.qml +++ b/src/plugins/kdecorations/aurorae/src/qml/aurorae.qml @@ -6,6 +6,7 @@ import QtQuick import org.kde.kwin.decoration import org.kde.plasma.core as PlasmaCore +import org.kde.ksvg 1.0 as KSvg Decoration { id: root @@ -41,7 +42,7 @@ Decoration { decoration.installTitleItem(titleRect); } } - PlasmaCore.FrameSvg { + KSvg.FrameSvg { property bool supportsInactive: hasElementPrefix("decoration-inactive") property bool supportsMask: hasElementPrefix("mask") property bool supportsMaximized: hasElementPrefix("decoration-maximized") @@ -51,14 +52,14 @@ Decoration { id: backgroundSvg imagePath: auroraeTheme.decorationPath } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: decorationActive property bool shown: (!decoration.client.maximized || !backgroundSvg.supportsMaximized) && (decoration.client.active || !backgroundSvg.supportsInactive) anchors.fill: parent imagePath: backgroundSvg.imagePath prefix: "decoration" opacity: shown ? 1 : 0 - enabledBorders: decoration.client.maximized ? PlasmaCore.FrameSvg.NoBorder : PlasmaCore.FrameSvg.TopBorder | PlasmaCore.FrameSvg.BottomBorder | PlasmaCore.FrameSvg.LeftBorder | PlasmaCore.FrameSvg.RightBorder + enabledBorders: decoration.client.maximized ? KSvg.FrameSvg.NoBorder : KSvg.FrameSvg.TopBorder | KSvg.FrameSvg.BottomBorder | KSvg.FrameSvg.LeftBorder | KSvg.FrameSvg.RightBorder Behavior on opacity { enabled: root.animate NumberAnimation { @@ -66,13 +67,13 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: decorationInactive anchors.fill: parent imagePath: backgroundSvg.imagePath prefix: "decoration-inactive" opacity: (!decoration.client.active && backgroundSvg.supportsInactive) ? 1 : 0 - enabledBorders: decoration.client.maximized ? PlasmaCore.FrameSvg.NoBorder : PlasmaCore.FrameSvg.TopBorder | PlasmaCore.FrameSvg.BottomBorder | PlasmaCore.FrameSvg.LeftBorder | PlasmaCore.FrameSvg.RightBorder + enabledBorders: decoration.client.maximized ? KSvg.FrameSvg.NoBorder : KSvg.FrameSvg.TopBorder | KSvg.FrameSvg.BottomBorder | KSvg.FrameSvg.LeftBorder | KSvg.FrameSvg.RightBorder Behavior on opacity { enabled: root.animate NumberAnimation { @@ -80,7 +81,7 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: decorationMaximized property bool shown: decoration.client.maximized && backgroundSvg.supportsMaximized && (decoration.client.active || !backgroundSvg.supportsMaximizedInactive) anchors { @@ -95,7 +96,7 @@ Decoration { prefix: "decoration-maximized" height: parent.maximizedBorders.top opacity: shown ? 1 : 0 - enabledBorders: PlasmaCore.FrameSvg.NoBorder + enabledBorders: KSvg.FrameSvg.NoBorder Behavior on opacity { enabled: root.animate NumberAnimation { @@ -103,7 +104,7 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: decorationMaximizedInactive anchors { left: parent.left @@ -117,7 +118,7 @@ Decoration { prefix: "decoration-maximized-inactive" height: parent.maximizedBorders.top opacity: (!decoration.client.active && decoration.client.maximized && backgroundSvg.supportsMaximizedInactive) ? 1 : 0 - enabledBorders: PlasmaCore.FrameSvg.NoBorder + enabledBorders: KSvg.FrameSvg.NoBorder Behavior on opacity { enabled: root.animate NumberAnimation { @@ -171,7 +172,7 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: innerBorder anchors { fill: parent @@ -195,7 +196,7 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: innerBorderInactive anchors { fill: parent @@ -220,7 +221,7 @@ Decoration { } } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: maskItem anchors.fill: parent // This makes the mask slightly smaller than the frame. Since the svg will have antialiasing and the mask not, @@ -228,6 +229,6 @@ Decoration { anchors.margins: 1 imagePath: backgroundSvg.imagePath opacity: 0 - enabledBorders: PlasmaCore.FrameSvg.TopBorder | PlasmaCore.FrameSvg.BottomBorder | PlasmaCore.FrameSvg.LeftBorder | PlasmaCore.FrameSvg.RightBorder + enabledBorders: KSvg.FrameSvg.TopBorder | KSvg.FrameSvg.BottomBorder | KSvg.FrameSvg.LeftBorder | KSvg.FrameSvg.RightBorder } } diff --git a/src/plugins/private/qml/WindowHeapDelegate.qml b/src/plugins/private/qml/WindowHeapDelegate.qml index 22c3e5e508..74c405a147 100644 --- a/src/plugins/private/qml/WindowHeapDelegate.qml +++ b/src/plugins/private/qml/WindowHeapDelegate.qml @@ -13,6 +13,7 @@ import org.kde.kwin.private.effects import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.core as PlasmaCore import org.kde.kirigami 2.20 as Kirigami +import org.kde.ksvg 1.0 as KSvg Item { id: thumb @@ -124,7 +125,7 @@ Item { thumb.windowHeap.deleteDND(thumb.window.internalId); } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { anchors { fill: parent topMargin: -Kirigami.Units.smallSpacing * 2 diff --git a/src/plugins/tileseditor/qml/main.qml b/src/plugins/tileseditor/qml/main.qml index fdb5621181..44f099398f 100644 --- a/src/plugins/tileseditor/qml/main.qml +++ b/src/plugins/tileseditor/qml/main.qml @@ -11,6 +11,7 @@ import org.kde.kwin as KWinComponents import org.kde.kwin.private.effects import org.kde.plasma.core as PlasmaCore import org.kde.kirigami 2.20 as Kirigami +import org.kde.ksvg 1.0 as KSvg import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.kitemmodels as KitemModels @@ -171,9 +172,9 @@ FocusScope { } } } - background: PlasmaCore.FrameSvgItem { + background: KSvg.FrameSvgItem { imagePath: "widgets/background" - enabledBorders: PlasmaCore.FrameSvg.LeftBorder | PlasmaCore.FrameSvg.BottomBorder + enabledBorders: KSvg.FrameSvg.LeftBorder | KSvg.FrameSvg.BottomBorder } } PlasmaComponents.Popup { @@ -187,7 +188,7 @@ FocusScope { dim: true onOpened: forceActiveFocus() onClosed: root.forceActiveFocus() - PlasmaCore.Svg { + KSvg.Svg { id: layoutsSvg imagePath: Qt.resolvedUrl("layouts.svg") } @@ -196,13 +197,13 @@ FocusScope { Layout.fillWidth: true Layout.fillHeight: true property alias image: svgItem.elementId - contentItem: PlasmaCore.SvgItem { + contentItem: KSvg.SvgItem { id: svgItem svg: layoutsSvg implicitWidth: naturalSize.width implicitHeight: naturalSize.height } - background: PlasmaCore.FrameSvgItem { + background: KSvg.FrameSvgItem { imagePath: "widgets/viewitem" prefix: "hover" opacity: parent.hovered || parent.focus diff --git a/src/qml/frames/plasma/frame_styled.qml b/src/qml/frames/plasma/frame_styled.qml index 190ace1ea4..e184ae4c1d 100644 --- a/src/qml/frames/plasma/frame_styled.qml +++ b/src/qml/frames/plasma/frame_styled.qml @@ -10,6 +10,7 @@ import QtQuick.Layouts import org.kde.plasma.core as PlasmaCore import org.kde.kirigami 2.20 as Kirigami +import org.kde.ksvg 1.0 as KSvg import org.kde.plasma.components 3.0 as PlasmaComponents Item { @@ -20,7 +21,7 @@ Item { implicitWidth: layout.implicitWidth + layout.anchors.leftMargin + layout.anchors.rightMargin implicitHeight: layout.implicitHeight + layout.anchors.topMargin + layout.anchors.bottomMargin - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: frameSvg imagePath: "widgets/background" opacity: root.effectFrame.frameOpacity diff --git a/src/qml/outline/plasma/outline.qml b/src/qml/outline/plasma/outline.qml index ce878bac26..6e78fed4a8 100644 --- a/src/qml/outline/plasma/outline.qml +++ b/src/qml/outline/plasma/outline.qml @@ -8,6 +8,7 @@ import QtQuick import QtQuick.Window import org.kde.kwin import org.kde.plasma.core as PlasmaCore +import org.kde.ksvg 1.0 as KSvg Window { id: window @@ -57,7 +58,7 @@ Window { } } - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: svg // takes into account the offset inside unified geometry @@ -83,21 +84,21 @@ Window { var top = outline.geometry.y === maximizedArea.y; var bottom = outline.geometry.y + outline.geometry.height === maximizedArea.y + maximizedArea.height; - var borders = PlasmaCore.FrameSvgItem.AllBorders; + var borders = KSvg.FrameSvgItem.AllBorders; if (left) { - borders = borders & ~PlasmaCore.FrameSvgItem.LeftBorder; + borders = borders & ~KSvg.FrameSvgItem.LeftBorder; } if (right) { - borders = borders & ~PlasmaCore.FrameSvgItem.RightBorder; + borders = borders & ~KSvg.FrameSvgItem.RightBorder; } if (top) { - borders = borders & ~PlasmaCore.FrameSvgItem.TopBorder; + borders = borders & ~KSvg.FrameSvgItem.TopBorder; } if (bottom) { - borders = borders & ~PlasmaCore.FrameSvgItem.BottomBorder; + borders = borders & ~KSvg.FrameSvgItem.BottomBorder; } if (left && right && bottom && top) { - borders = PlasmaCore.FrameSvgItem.AllBorders; + borders = KSvg.FrameSvgItem.AllBorders; } return borders; } diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index 5d5b319879..02e0413b22 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -625,6 +625,7 @@ KWin::Scripting::Scripting(QObject *parent) , m_declarativeScriptSharedContext(new QQmlContext(m_qmlEngine, this)) , m_workspaceWrapper(new QtScriptWorkspaceWrapper(this)) { + m_qmlEngine->setProperty("_kirigamiTheme", QStringLiteral("KirigamiPlasmaStyle")); init(); QDBusConnection::sessionBus().registerObject(QStringLiteral("/Scripting"), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportScriptableInvokables); connect(Workspace::self(), &Workspace::configChanged, this, &Scripting::start); diff --git a/src/tabbox/switchers/thumbnail_grid/contents/ui/main.qml b/src/tabbox/switchers/thumbnail_grid/contents/ui/main.qml index c2d83ad58f..a1927124dc 100644 --- a/src/tabbox/switchers/thumbnail_grid/contents/ui/main.qml +++ b/src/tabbox/switchers/thumbnail_grid/contents/ui/main.qml @@ -11,6 +11,7 @@ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.ksvg 1.0 as KSvg import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.kwin 3.0 as KWin import org.kde.kirigami 2.20 as Kirigami @@ -85,7 +86,7 @@ KWin.TabBoxSwitcher { } // Just to get the margin sizes - PlasmaCore.FrameSvgItem { + KSvg.FrameSvgItem { id: hoverItem imagePath: "widgets/viewitem" prefix: "hover" @@ -196,7 +197,7 @@ KWin.TabBoxSwitcher { } } // GridView.delegate - highlight: PlasmaCore.FrameSvgItem { + highlight: KSvg.FrameSvgItem { imagePath: "widgets/viewitem" prefix: "hover" }