Verified Commit 12d81677 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

plasmoidviewer: Port from plasmoid context property to Plasmoid

No regressions found.

Requires frameworks/plasma-framework!483 for the Plasmoid.self property
as a workaround until Qt 6.

Some of this code mirrors desktoppackage code, so a parity patch will
be made to plasma-desktop soon™.
parent 00099ad1
Pipeline #154732 passed with stage
in 1 minute and 57 seconds
......@@ -9,6 +9,7 @@ import QtQuick.Window 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0
import org.kde.kquickcontrolsaddons 2.0
PlasmaCore.ToolTipArea {
......@@ -16,12 +17,12 @@ PlasmaCore.ToolTipArea {
objectName: "org.kde.desktop-CompactApplet"
anchors.fill: parent
mainText: plasmoid.toolTipMainText
subText: plasmoid.toolTipSubText
location: plasmoid.location
active: !plasmoid.expanded
textFormat: plasmoid.toolTipTextFormat
mainItem: plasmoid.toolTipItem ? plasmoid.toolTipItem : null
mainText: Plasmoid.toolTipMainText
subText: Plasmoid.toolTipSubText
location: Plasmoid.location
active: !Plasmoid.expanded
textFormat: Plasmoid.toolTipTextFormat
mainItem: Plasmoid.toolTipItem ? Plasmoid.toolTipItem : null
property Item fullRepresentation
property Item compactRepresentation
......@@ -90,7 +91,7 @@ PlasmaCore.ToolTipArea {
visible: fromCurrentTheme && opacity > 0
prefix: {
var prefix;
switch (plasmoid.location) {
switch (Plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
prefix = "west-active-tab";
break;
......@@ -108,7 +109,7 @@ PlasmaCore.ToolTipArea {
}
return prefix;
}
opacity: plasmoid.expanded ? 1 : 0
opacity: Plasmoid.expanded ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.shortDuration
......@@ -120,16 +121,17 @@ PlasmaCore.ToolTipArea {
Timer {
id: expandedSync
interval: 100
onTriggered: plasmoid.expanded = popupWindow.visible;
onTriggered: Plasmoid.expanded = popupWindow.visible;
}
Connections {
target: plasmoid.action("configure")
function onTriggered() { plasmoid.expanded = false }
target: Plasmoid.action("configure")
function onTriggered() { Plasmoid.expanded = false }
}
Connections {
target: plasmoid
// TODO KF6: strip `.self` as it is a workaround that is no longer needed in Qt 6
target: Plasmoid.self
function onContextualActionsAboutToShow() { root.hideToolTip() }
}
......@@ -137,11 +139,11 @@ PlasmaCore.ToolTipArea {
id: popupWindow
objectName: "popupWindow"
flags: Qt.WindowStaysOnTopHint
visible: plasmoid.expanded && fullRepresentation
visible: Plasmoid.expanded && fullRepresentation
visualParent: compactRepresentation ? compactRepresentation : null
location: plasmoid.location
hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate
backgroundHints: (plasmoid.containmentDisplayHints & PlasmaCore.Types.DesktopFullyCovered) ? PlasmaCore.Dialog.SolidBackground : PlasmaCore.Dialog.StandardBackground
location: Plasmoid.location
hideOnWindowDeactivate: Plasmoid.hideOnWindowDeactivate
backgroundHints: (Plasmoid.containmentDisplayHints & PlasmaCore.Types.DesktopFullyCovered) ? PlasmaCore.Dialog.SolidBackground : PlasmaCore.Dialog.StandardBackground
property var oldStatus: PlasmaCore.Types.UnknownStatus
......@@ -152,7 +154,7 @@ PlasmaCore.ToolTipArea {
focus: true
Keys.onEscapePressed: {
plasmoid.expanded = false;
Plasmoid.expanded = false;
}
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
......@@ -177,10 +179,10 @@ PlasmaCore.ToolTipArea {
onVisibleChanged: {
if (!visible) {
expandedSync.restart();
plasmoid.status = oldStatus;
Plasmoid.status = oldStatus;
} else {
oldStatus = plasmoid.status;
plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus;
oldStatus = Plasmoid.status;
Plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus;
// This call currently fails and complains at runtime:
// QWindow::setWindowState: QWindow::setWindowState does not accept Qt::WindowActive
popupWindow.requestActivate();
......
......@@ -6,18 +6,20 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
PlasmaCore.IconItem {
id: icon
readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge
|| plasmoid.location === PlasmaCore.Types.RightEdge
|| plasmoid.location === PlasmaCore.Types.BottomEdge
|| plasmoid.location === PlasmaCore.Types.LeftEdge)
readonly property bool inPanel: (Plasmoid.location === PlasmaCore.Types.TopEdge
|| Plasmoid.location === PlasmaCore.Types.RightEdge
|| Plasmoid.location === PlasmaCore.Types.BottomEdge
|| Plasmoid.location === PlasmaCore.Types.LeftEdge)
Layout.minimumWidth: {
switch (plasmoid.formFactor) {
switch (Plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return 0;
case PlasmaCore.Types.Horizontal:
......@@ -28,7 +30,7 @@ PlasmaCore.IconItem {
}
Layout.minimumHeight: {
switch (plasmoid.formFactor) {
switch (Plasmoid.formFactor) {
case PlasmaCore.Types.Vertical:
return width;
case PlasmaCore.Types.Horizontal:
......@@ -41,7 +43,7 @@ PlasmaCore.IconItem {
Layout.maximumWidth: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1;
Layout.maximumHeight: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1;
source: plasmoid.icon ? plasmoid.icon : "plasma"
source: Plasmoid.icon ? Plasmoid.icon : "plasma"
active: mouseArea.containsMouse
MouseArea {
......@@ -51,7 +53,7 @@ PlasmaCore.IconItem {
anchors.fill: parent
hoverEnabled: true
onPressed: wasExpanded = plasmoid.expanded
onClicked: plasmoid.expanded = !wasExpanded
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
}
}
......@@ -10,6 +10,7 @@ import QtQuick.Controls 2.4 as QQC2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.6 as Kirigami
import org.kde.plasma.plasmoid 2.0
/**
* A copy of Kirigami.AboutPage adapted to KPluginMetadata instead of KAboutData
......@@ -70,18 +71,18 @@ Kirigami.ScrollablePage {
Layout.preferredWidth: height
Layout.maximumWidth: page.width / 3;
Layout.rightMargin: Kirigami.Units.largeSpacing
source: plasmoid.metaData.iconName || plasmoid.metaData.pluginId
source: Plasmoid.metaData.iconName || Plasmoid.metaData.pluginId
fallback: "application-x-plasma"
}
Kirigami.Heading {
Layout.fillWidth: true
text: plasmoid.metaData.name + " " + plasmoid.metaData.version
text: Plasmoid.metaData.name + " " + Plasmoid.metaData.version
}
Kirigami.Heading {
Layout.fillWidth: true
level: 2
wrapMode: Text.WordWrap
text: plasmoid.metaData.description
text: Plasmoid.metaData.description
}
}
......@@ -95,17 +96,17 @@ Kirigami.ScrollablePage {
}
QQC2.Label {
Layout.leftMargin: Kirigami.Units.gridUnit
text: plasmoid.metaData.extraInformation
text: Plasmoid.metaData.extraInformation
visible: text.length > 0
}
QQC2.Label {
Layout.leftMargin: Kirigami.Units.gridUnit
text: plasmoid.metaData.copyrightText
text: Plasmoid.metaData.copyrightText
visible: text.length > 0
}
Kirigami.UrlButton {
Layout.leftMargin: Kirigami.Units.gridUnit
url: plasmoid.metaData.website
url: Plasmoid.metaData.website
visible: url.length > 0
}
......@@ -113,10 +114,10 @@ Kirigami.ScrollablePage {
Layout.leftMargin: Kirigami.Units.smallSpacing
QQC2.Label { text: i18nd("plasma_shell_org.kde.plasma.desktop", "License:") }
Kirigami.LinkButton {
text: plasmoid.metaData.license
text: Plasmoid.metaData.license
onClicked: {
licenseSheet.text = plasmoid.metaData.licenseText
licenseSheet.title = plasmoid.metaData.license
licenseSheet.text = Plasmoid.metaData.licenseText
licenseSheet.title = Plasmoid.metaData.license
licenseSheet.open()
}
}
......@@ -125,10 +126,10 @@ Kirigami.ScrollablePage {
Layout.fillWidth: true
Kirigami.FormData.isSection: visible
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Authors")
visible: plasmoid.metaData.authors.length > 0
visible: Plasmoid.metaData.authors.length > 0
}
Repeater {
model: plasmoid.metaData.authors
model: Plasmoid.metaData.authors
delegate: personDelegate
}
Kirigami.Heading {
......@@ -139,7 +140,7 @@ Kirigami.ScrollablePage {
}
Repeater {
id: repCredits
model: plasmoid.metaData.otherContributors
model: Plasmoid.metaData.otherContributors
delegate: personDelegate
}
Kirigami.Heading {
......@@ -150,7 +151,7 @@ Kirigami.ScrollablePage {
}
Repeater {
id: repTranslators
model: plasmoid.metaData.translators
model: Plasmoid.metaData.translators
delegate: personDelegate
}
}
......
......@@ -7,6 +7,7 @@
import QtQuick 2.0
import org.kde.kirigami 2.10 as Kirigami
import org.kde.plasma.plasmoid 2.0
Kirigami.ScrollablePage {
id: root
......@@ -18,9 +19,9 @@ Kirigami.ScrollablePage {
signal settingValueChanged()
function saveConfig() {
for (let key in plasmoid.configuration) {
for (let key in Plasmoid.configuration) {
if (loader.item["cfg_" + key] != undefined) {
plasmoid.configuration[key] = loader.item["cfg_" + key]
Plasmoid.configuration[key] = loader.item["cfg_" + key]
}
}
......@@ -43,11 +44,11 @@ Kirigami.ScrollablePage {
height: Math.max(root.availableHeight, item.implicitHeight ? item.implicitHeight : item.childrenRect.height)
Component.onCompleted: {
const plasmoidConfig = plasmoid.configuration
const plasmoidConfig = Plasmoid.configuration
const props = {}
for (let key in plasmoidConfig) {
props["cfg_" + key] = plasmoid.configuration[key]
props["cfg_" + key] = Plasmoid.configuration[key]
}
setSource(configItem.source, props)
......
......@@ -12,6 +12,7 @@ import QtQml 2.15
import org.kde.newstuff 1.62 as NewStuff
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kcm 1.4
......@@ -64,7 +65,7 @@ AbstractKCM {
}
Kirigami.InlineMessage {
visible: plasmoid.immutable || animating
visible: Plasmoid.immutable || animating
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes have been restricted by the system administrator")
showCloseButton: true
Layout.fillWidth: true
......@@ -81,7 +82,7 @@ AbstractKCM {
id: pluginComboBox
Layout.preferredWidth: Math.max(implicitWidth, wallpaperComboBox.implicitWidth)
Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:")
enabled: !plasmoid.immutable
enabled: !Plasmoid.immutable
model: configDialog.containmentPluginsConfigModel
implicitWidth: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 24
textRole: "name"
......
......@@ -7,8 +7,10 @@
import QtQuick 2.0
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0
import org.kde.kquickcontrols 2.0
import org.kde.kirigami 2.14 as Kirigami
import org.kde.plasma.plasmoid 2.0
Kirigami.ScrollablePage {
id: root
......@@ -17,7 +19,7 @@ Kirigami.ScrollablePage {
signal configurationChanged
function saveConfig() {
plasmoid.globalShortcut = button.keySequence
Plasmoid.globalShortcut = button.keySequence
}
ColumnLayout {
......@@ -28,9 +30,9 @@ Kirigami.ScrollablePage {
}
KeySequenceItem {
id: button
keySequence: plasmoid.globalShortcut
keySequence: Plasmoid.globalShortcut
onKeySequenceChanged: {
if (keySequence != plasmoid.globalShortcut) {
if (keySequence != Plasmoid.globalShortcut) {
root.configurationChanged();
}
}
......
......@@ -6,10 +6,12 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.configuration 2.0
import org.kde.plasma.plasmoid 2.0
AppletConfiguration {
......@@ -19,8 +21,8 @@ AppletConfiguration {
Layout.minimumHeight: PlasmaCore.Units.gridUnit * 20
Layout.preferredWidth: PlasmaCore.Units.gridUnit * 32
Layout.preferredHeight: PlasmaCore.Units.gridUnit * 36
Layout.maximumWidth: plasmoid.availableScreenRect.width
Layout.maximumHeight: plasmoid.availableScreenRect.height
Layout.maximumWidth: Plasmoid.availableScreenRect.width
Layout.maximumHeight: Plasmoid.availableScreenRect.height
//BEGIN model
globalConfigModel: globalContainmentConfigModel
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment