Port PlasmaCore.Theme/ColorScope/Units etc to Kirigami

see https://pointieststick.com/2023/06/14/call-to-action-easy-porting-opportunity-in-plasma/
This commit is contained in:
Laurent Montel 2023-06-16 14:39:21 +00:00 committed by Nate Graham
parent ad4ce627ae
commit ba3bfbf4be
14 changed files with 71 additions and 58 deletions

View file

@ -10,6 +10,7 @@ import QtQuick
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.plasma.components 3.0 as PC3
import org.kde.kwin.private.desktopgrid
@ -175,7 +176,7 @@ FocusScope {
PC3.Control {
id: desktopLabel
anchors.margins: PlasmaCore.Units.largeSpacing
anchors.margins: Kirigami.Units.gridUnit
z: 9999
visible: effect.desktopNameAlignment !== 0
@ -291,13 +292,13 @@ FocusScope {
]
scale: 1 / desktopView.parent.scale
leftPadding: PlasmaCore.Units.smallSpacing
rightPadding: PlasmaCore.Units.smallSpacing
leftPadding: Kirigami.Units.smallSpacing
rightPadding: Kirigami.Units.smallSpacing
contentItem: PC3.Label {
text: desktopView.desktop.name
}
background: Rectangle {
color: PlasmaCore.Theme.backgroundColor
color: Kirigami.Theme.backgroundColor
radius: height
opacity: 0.6
}

View file

@ -13,6 +13,7 @@ import QtQuick.Window
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.plasma.components 3.0 as PC3
Rectangle {
@ -196,8 +197,8 @@ Rectangle {
width: (parent.width + columnSpacing) * columns - columnSpacing
height: (parent.height + rowSpacing) * rows - rowSpacing
rowSpacing: PlasmaCore.Units.gridUnit
columnSpacing: PlasmaCore.Units.gridUnit
rowSpacing: Kirigami.Units.gridUnit
columnSpacing: Kirigami.Units.gridUnit
rows: container.effect.gridRows
columns: container.effect.gridColumns
transformOrigin: Item.TopLeft
@ -274,7 +275,7 @@ Rectangle {
anchors.fill: parent
color: "transparent"
border {
color: PlasmaCore.Theme.highlightColor
color: Kirigami.Theme.highlightColor
width: 1 / grid.scale
}
visible: parent.activeFocus
@ -295,9 +296,9 @@ Rectangle {
anchors {
right: parent.right
bottom: parent.bottom
margins: PlasmaCore.Units.smallSpacing
margins: Kirigami.Units.smallSpacing
}
spacing: PlasmaCore.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing
visible: container.effect.showAddRemove
PC3.Button {
id: addButton

View file

@ -14,20 +14,21 @@ import org.kde.kwin as KWinComponents
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
Item {
id: bar
readonly property real desktopHeight: PlasmaCore.Units.gridUnit * 4
readonly property real desktopHeight: Kirigami.Units.gridUnit * 4
readonly property real desktopWidth: desktopHeight * targetScreen.geometry.width / targetScreen.geometry.height
readonly property real columnHeight: desktopHeight + PlasmaCore.Units.gridUnit
readonly property real columnHeight: desktopHeight + Kirigami.Units.gridUnit
property QtObject windowModel
property alias desktopModel: desktopRepeater.model
property QtObject selectedDesktop: null
property WindowHeap heap
implicitHeight: columnHeight + 2 * PlasmaCore.Units.smallSpacing
implicitHeight: columnHeight + 2 * Kirigami.Units.smallSpacing
Flickable {
anchors.fill: parent
@ -40,7 +41,7 @@ Item {
flickableDirection: Flickable.HorizontalFlick
Row {
spacing: PlasmaCore.Units.largeSpacing
spacing: Kirigami.Units.gridUnit
Repeater {
id: desktopRepeater
@ -50,7 +51,7 @@ Item {
activeFocusOnTab: true
width: bar.desktopWidth
height: bar.columnHeight
spacing: PlasmaCore.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing
required property QtObject desktop
required property int index
@ -191,7 +192,7 @@ Item {
Item {
id: label
width: bar.desktopWidth
height: PlasmaCore.Units.gridUnit
height: Kirigami.Units.gridUnit
state: "normal"
PC3.Label {

View file

@ -14,6 +14,7 @@ import org.kde.kwin.private.effects
import org.kde.milou as Milou
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.plasma.extras as PlasmaExtras
FocusScope {
@ -177,7 +178,7 @@ FocusScope {
Rectangle {
id: desktopBar
width: parent.width
implicitHeight: bar.implicitHeight + 2 * PlasmaCore.Units.smallSpacing
implicitHeight: bar.implicitHeight + 2 * Kirigami.Units.smallSpacing
color: container.lightBackground ? Qt.rgba(PlasmaCore.ColorScope.backgroundColor.r,
PlasmaCore.ColorScope.backgroundColor.g,
PlasmaCore.ColorScope.backgroundColor.b, 0.75)
@ -197,12 +198,12 @@ FocusScope {
id: searchBar
anchors.top: desktopBar.bottom
width: parent.width
height: searchField.height + 2 * PlasmaCore.Units.largeSpacing
height: searchField.height + 2 * Kirigami.Units.gridUnit
PlasmaExtras.SearchField {
id: searchField
anchors.centerIn: parent
width: Math.min(parent.width, 20 * PlasmaCore.Units.gridUnit)
width: Math.min(parent.width, 20 * Kirigami.Units.gridUnit)
focus: true
Keys.priority: Keys.BeforeItem
Keys.forwardTo: text && currentHeap.count === 0 ? searchResults : currentHeap
@ -263,7 +264,7 @@ FocusScope {
visible: !(container.organized && effect.searchText.length > 0) || heap.count !== 0
layout.mode: effect.layout
focus: true
padding: PlasmaCore.Units.largeSpacing
padding: Kirigami.Units.gridUnit
animationDuration: effect.animationDuration
animationEnabled: container.animationEnabled
organized: container.organized
@ -315,7 +316,7 @@ FocusScope {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 2
height: parent.height - placeholderMessage.height - PlasmaCore.Units.largeSpacing
height: parent.height - placeholderMessage.height - Kirigami.Units.gridUnit
queryString: effect.searchText
visible: container.organized && effect.searchText.length > 0 && currentHeap.count === 0

View file

@ -12,6 +12,7 @@ import org.kde.kwin as KWinComponents
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
FocusScope {
id: heap
@ -39,7 +40,7 @@ FocusScope {
property alias layout: expoLayout
property int selectedIndex: -1
property int animationDuration: PlasmaCore.Units.longDuration
property int animationDuration: Kirigami.Units.longDuration
property bool animationEnabled: false
property bool absolutePositioning: true
property real padding: 0
@ -127,7 +128,7 @@ FocusScope {
anchors.fill: parent
anchors.margins: heap.padding
fillGaps: true
spacing: PlasmaCore.Units.smallSpacing * 5
spacing: Kirigami.Units.smallSpacing * 5
Instantiator {
id: windowsInstantiator

View file

@ -12,6 +12,7 @@ import org.kde.kwin as KWinComponents
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
Item {
id: thumb
@ -126,10 +127,10 @@ Item {
PlasmaCore.FrameSvgItem {
anchors {
fill: parent
topMargin: -PlasmaCore.Units.smallSpacing * 2
leftMargin: -PlasmaCore.Units.smallSpacing * 2
rightMargin: -PlasmaCore.Units.smallSpacing * 2
bottomMargin: -(Math.round(icon.height / 4) + (thumb.windowTitleVisible ? caption.height : 0) + (PlasmaCore.Units.smallSpacing * 2))
topMargin: -Kirigami.Units.smallSpacing * 2
leftMargin: -Kirigami.Units.smallSpacing * 2
rightMargin: -Kirigami.Units.smallSpacing * 2
bottomMargin: -(Math.round(icon.height / 4) + (thumb.windowTitleVisible ? caption.height : 0) + (Kirigami.Units.smallSpacing * 2))
}
imagePath: "widgets/viewitem"
prefix: "hover"
@ -155,8 +156,8 @@ Item {
PlasmaCore.IconItem {
id: icon
width: PlasmaCore.Units.iconSizes.large
height: PlasmaCore.Units.iconSizes.large
width: Kirigami.Units.iconSizes.large
height: Kirigami.Units.iconSizes.large
source: thumb.window.icon
usesPlasmaTheme: false
anchors.horizontalCenter: thumbSource.horizontalCenter
@ -443,7 +444,7 @@ Item {
anchors {
right: thumbSource.right
top: thumbSource.top
margins: PlasmaCore.Units.smallSpacing
margins: Kirigami.Units.smallSpacing
}
visible: thumb.closeButtonVisible && (hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.window.closeable && !thumb.activeDragHandler.active

View file

@ -10,6 +10,7 @@ import QtQuick.Layouts
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
Rectangle {
id: handle
@ -20,11 +21,11 @@ Rectangle {
z: 2
implicitWidth: PlasmaCore.Units.gridUnit
implicitHeight: PlasmaCore.Units.gridUnit
implicitWidth: Kirigami.Units.gridUnit
implicitHeight: Kirigami.Units.gridUnit
radius: 3
color: PlasmaCore.Theme.highlightColor
color: Kirigami.Theme.highlightColor
opacity: hoverHandler.hovered || dragHandler.active ? 0.4 : 0
visible: tile &&
(tile.layoutDirection === KWinComponents.Tile.Floating ||

View file

@ -8,6 +8,7 @@ import QtQuick
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
Rectangle {
id: handle
@ -22,11 +23,11 @@ Rectangle {
z: 2
implicitWidth: PlasmaCore.Units.smallSpacing * 2
implicitHeight: PlasmaCore.Units.smallSpacing * 2
implicitWidth: Kirigami.Units.smallSpacing * 2
implicitHeight: Kirigami.Units.smallSpacing * 2
radius: 3
color: PlasmaCore.Theme.highlightColor
color: Kirigami.Theme.highlightColor
opacity: hoverHandler.hovered || dragHandler.active ? 0.4 : 0
visible: valid && (tile.layoutDirection === KWinComponents.Tile.Floating || tile.positionInLayout > 0)

View file

@ -9,6 +9,7 @@ import QtQuick.Layouts
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.plasma.components 3.0 as PlasmaComponents
Item {
@ -107,13 +108,13 @@ Item {
Rectangle {
anchors {
fill: parent
margins: PlasmaCore.Units.smallSpacing
margins: Kirigami.Units.smallSpacing
}
visible: tile.tiles.length === 0
radius: 3
opacity: tile.layoutDirection === KWinComponents.Tile.Floating ? 0.6 : 0.3
color: tile.layoutDirection === KWinComponents.Tile.Floating ? PlasmaCore.Theme.backgroundColor : "transparent"
border.color: PlasmaCore.Theme.textColor
color: tile.layoutDirection === KWinComponents.Tile.Floating ? Kirigami.Theme.backgroundColor : "transparent"
border.color: Kirigami.Theme.textColor
Rectangle {
anchors {
fill: parent
@ -121,7 +122,7 @@ Item {
}
radius: 3
color: "transparent"
border.color: PlasmaCore.Theme.backgroundColor
border.color: Kirigami.Theme.backgroundColor
}
MouseArea {
anchors.fill: parent
@ -157,7 +158,7 @@ Item {
GridLayout {
anchors.centerIn: parent
visible: tile.tiles.length === 0
readonly property bool compact: delegate.width < PlasmaCore.Units.gridUnit * 10 || delegate.height < splitButton.implicitHeight * visibleChildren.length + rowSpacing * visibleChildren.length + PlasmaCore.Units.gridUnit
readonly property bool compact: delegate.width < Kirigami.Units.gridUnit * 10 || delegate.height < splitButton.implicitHeight * visibleChildren.length + rowSpacing * visibleChildren.length + Kirigami.Units.gridUnit
rows: compact ? 1 : -1
columns: compact ? -1 : 1
PlasmaComponents.Button {
@ -204,7 +205,7 @@ Item {
anchors {
right: parent.right
bottom: parent.bottom
margins: PlasmaCore.Units.smallSpacing
margins: Kirigami.Units.smallSpacing
}
visible: tile.layoutDirection === KWinComponents.Tile.Floating && tile.isLayout
icon.name: "window-duplicate"

View file

@ -10,6 +10,7 @@ import QtQuick.Layouts
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.plasma.components 3.0 as PlasmaComponents
import org.kde.kitemmodels as KitemModels
@ -89,7 +90,7 @@ FocusScope {
Rectangle {
anchors.fill: parent
color: PlasmaCore.Theme.backgroundColor
color: Kirigami.Theme.backgroundColor
opacity: root.active ? 0.4 : 0
Behavior on opacity {
OpacityAnimator {
@ -129,8 +130,8 @@ FocusScope {
anchors.right: parent.right
y: root.active ? 0 : -height
leftPadding: background.margins.left
topPadding: PlasmaCore.Units.smallSpacing
rightPadding: PlasmaCore.Units.smallSpacing
topPadding: Kirigami.Units.smallSpacing
rightPadding: Kirigami.Units.smallSpacing
bottomPadding: background.margins.bottom
opacity: root.active
Behavior on opacity {
@ -151,7 +152,7 @@ FocusScope {
}
PlasmaComponents.SpinBox {
from: 0
to: PlasmaCore.Units.gridUnit * 2
to: Kirigami.Units.gridUnit * 2
value: KWinComponents.Workspace.tilingForScreen(root.targetScreen.name).rootTile.padding
onValueModified: KWinComponents.Workspace.tilingForScreen(root.targetScreen.name).rootTile.padding = value
}
@ -163,7 +164,7 @@ FocusScope {
MouseArea {
anchors {
fill: parent
margins: -PlasmaCore.Units.smallSpacing
margins: -Kirigami.Units.smallSpacing
}
z: -1
onClicked: parent.clicked()
@ -179,7 +180,7 @@ FocusScope {
id: loadLayoutDialog
x: Math.round(parent.width / 2 - width / 2)
y: Math.round(parent.height / 2 - height / 2)
width: Math.min(root.width - PlasmaCore.Units.gridUnit * 4, implicitWidth)
width: Math.min(root.width - Kirigami.Units.gridUnit * 4, implicitWidth)
height: Math.round(implicitHeight * (width / implicitWidth))
modal: true

View file

@ -11,6 +11,7 @@ import QtQuick.Layouts
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.plasma.extras as PlasmaExtras
import org.kde.KWin.Effect.WindowView
@ -91,7 +92,7 @@ Item {
Loader {
anchors.centerIn: parent
width: parent.width - (PlasmaCore.Units.gridUnit * 8)
width: parent.width - (Kirigami.Units.gridUnit * 8)
active: heap.activeEmpty
@ -114,8 +115,8 @@ Item {
PlasmaExtras.SearchField {
id: searchField
Layout.alignment: Qt.AlignCenter
Layout.topMargin: PlasmaCore.Units.gridUnit
Layout.preferredWidth: Math.min(parent.width, 20 * PlasmaCore.Units.gridUnit)
Layout.topMargin: Kirigami.Units.gridUnit
Layout.preferredWidth: Math.min(parent.width, 20 * Kirigami.Units.gridUnit)
focus: false
// Don't confuse users into thinking it's a full search
@ -165,7 +166,7 @@ Item {
Layout.fillWidth: true
Layout.fillHeight: true
focus: true
padding: PlasmaCore.Units.largeSpacing
padding: Kirigami.Units.gridUnit
animationDuration: container.effect.animationDuration
animationEnabled: container.animationEnabled
organized: container.organized

View file

@ -9,6 +9,7 @@ import QtQuick
import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.components 3.0 as PlasmaComponents
Item {
@ -35,7 +36,7 @@ Item {
topMargin: frameSvg.fixedMargins.top
bottomMargin: frameSvg.fixedMargins.bottom
}
spacing: PlasmaCore.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing
PlasmaCore.IconItem {
id: icon

View file

@ -10,6 +10,7 @@ import QtQuick.Layouts
import QtQuick.Window
import org.kde.plasma.core as PlasmaCore
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.components 3.0 as PlasmaComponents3
PlasmaCore.Dialog {
@ -20,9 +21,9 @@ PlasmaCore.Dialog {
outputOnly: true
mainItem: RowLayout {
spacing: PlasmaCore.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing
PlasmaCore.IconItem {
implicitWidth: PlasmaCore.Units.iconSizes.medium
implicitWidth: Kirigami.Units.iconSizes.medium
implicitHeight: implicitWidth
source: osd.iconName
visible: osd.iconName !== ""

View file

@ -98,10 +98,10 @@ KWin.TabBoxSwitcher {
model: tabBox.model
readonly property int iconSize: PlasmaCore.Units.iconSizes.huge
readonly property int captionRowHeight: PlasmaCore.Units.gridUnit * 2
readonly property int columnSpacing: PlasmaCore.Units.largeSpacing
readonly property int thumbnailWidth: PlasmaCore.Units.gridUnit * 16
readonly property int iconSize: Kirigami.Units.iconSizes.huge
readonly property int captionRowHeight: Kirigami.Units.gridUnit * 2
readonly property int columnSpacing: Kirigami.Units.gridUnit
readonly property int thumbnailWidth: Kirigami.Units.gridUnit * 16
readonly property int thumbnailHeight: thumbnailWidth * (1.0/dialogMainItem.screenFactor)
cellWidth: hoverItem.margins.left + thumbnailWidth + hoverItem.margins.right
cellHeight: hoverItem.margins.top + captionRowHeight + thumbnailHeight + hoverItem.margins.bottom