Port to KSvg

port Svg and FrameSvg items to KSvg
This commit is contained in:
Marco Martin 2023-06-21 15:16:39 +00:00
parent 2132dddf0d
commit 569e0f8f64
11 changed files with 51 additions and 40 deletions

View file

@ -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'

View file

@ -82,6 +82,7 @@ find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS
IdleTime
Package
Plasma
Svg
WidgetsAddons
WindowSystem
)

View file

@ -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"

View file

@ -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

View file

@ -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
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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);

View file

@ -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"
}