plasmoid: Port to pragma ComponentBehavior: Bound
This commit is contained in:
parent
d2ee2bfdd8
commit
9ee0b23727
2 changed files with 48 additions and 22 deletions
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtCore
|
import QtCore
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Dialogs as QtDialogs
|
import QtQuick.Dialogs as QtDialogs
|
||||||
|
@ -19,6 +21,9 @@ import org.kde.plasma.extras as PlasmaExtras
|
||||||
PlasmaComponents.ItemDelegate {
|
PlasmaComponents.ItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property var model
|
||||||
|
|
||||||
readonly property KDEConnect.DeviceDbusInterface device: KDEConnect.DeviceDbusInterfaceFactory.create(model.deviceId)
|
readonly property KDEConnect.DeviceDbusInterface device: KDEConnect.DeviceDbusInterfaceFactory.create(model.deviceId)
|
||||||
|
|
||||||
hoverEnabled: false
|
hoverEnabled: false
|
||||||
|
@ -177,7 +182,7 @@ PlasmaComponents.ItemDelegate {
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
id: deviceName
|
id: deviceName
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
text: model.name
|
text: root.model.name
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
}
|
}
|
||||||
|
@ -317,12 +322,15 @@ PlasmaComponents.ItemDelegate {
|
||||||
|
|
||||||
model: KDEConnect.NotificationsModel {
|
model: KDEConnect.NotificationsModel {
|
||||||
id: notificationsModel
|
id: notificationsModel
|
||||||
deviceId: root.device.id()
|
deviceId: root.model.deviceId
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: PlasmaComponents.ItemDelegate {
|
delegate: PlasmaComponents.ItemDelegate {
|
||||||
id: listitem
|
id: listitem
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property var model
|
||||||
|
|
||||||
enabled: true
|
enabled: true
|
||||||
onClicked: checked = !checked
|
onClicked: checked = !checked
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -337,64 +345,71 @@ PlasmaComponents.ItemDelegate {
|
||||||
|
|
||||||
Kirigami.Icon {
|
Kirigami.Icon {
|
||||||
id: notificationIcon
|
id: notificationIcon
|
||||||
source: appIcon
|
source: listitem.model.appIcon
|
||||||
width: (valid && appIcon.length) ? dismissButton.width : 0
|
width: (valid && listitem.model.appIcon !== "") ? dismissButton.width : 0
|
||||||
height: width
|
height: width
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.Label {
|
PlasmaComponents.Label {
|
||||||
id: notificationLabel
|
id: notificationLabel
|
||||||
text: appName + ": " + (title.length > 0 ? (appName == title ? notitext : title + ": " + notitext) : model.name)
|
text: {
|
||||||
|
const { appName, notitext, title } = listitem.model;
|
||||||
|
const description = title !== "" ? (appName === title ? notitext : `${title}: ${notitext}`) : notitext;
|
||||||
|
return `${appName}: ${description}`;
|
||||||
|
}
|
||||||
elide: listitem.checked ? Text.ElideNone : Text.ElideRight
|
elide: listitem.checked ? Text.ElideNone : Text.ElideRight
|
||||||
maximumLineCount: listitem.checked ? 0 : 1
|
maximumLineCount: listitem.checked ? 0 : 1
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.Wrap
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.ToolButton {
|
PlasmaComponents.ToolButton {
|
||||||
id: replyButton
|
id: replyButton
|
||||||
visible: repliable
|
visible: listitem.model.repliable
|
||||||
enabled: repliable && !replying
|
enabled: listitem.model.repliable && !listitem.replying
|
||||||
icon.name: "mail-reply-sender"
|
icon.name: "mail-reply-sender"
|
||||||
PlasmaComponents.ToolTip.text: i18n("Reply")
|
PlasmaComponents.ToolTip.text: i18n("Reply")
|
||||||
onClicked: { replying = true; replyTextField.forceActiveFocus(); }
|
onClicked: {
|
||||||
|
listitem.replying = true;
|
||||||
|
replyTextField.forceActiveFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.ToolButton {
|
PlasmaComponents.ToolButton {
|
||||||
id: dismissButton
|
id: dismissButton
|
||||||
visible: notificationsModel.isAnyDimissable;
|
visible: notificationsModel.isAnyDimissable;
|
||||||
enabled: dismissable
|
enabled: listitem.model.dismissable
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
icon.name: "window-close"
|
icon.name: "window-close"
|
||||||
PlasmaComponents.ToolTip.text: i18n("Dismiss")
|
PlasmaComponents.ToolTip.text: i18n("Dismiss")
|
||||||
onClicked: dbusInterface.dismiss();
|
onClicked: listitem.model.dbusInterface.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
visible: replying
|
visible: listitem.replying
|
||||||
width: notificationLabel.width + replyButton.width + dismissButton.width + Kirigami.Units.smallSpacing * 2
|
width: notificationLabel.width + replyButton.width + dismissButton.width + Kirigami.Units.smallSpacing * 2
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
PlasmaComponents.Button {
|
||||||
Layout.alignment: Qt.AlignBottom
|
|
||||||
id: replyCancelButton
|
id: replyCancelButton
|
||||||
|
Layout.alignment: Qt.AlignBottom
|
||||||
text: i18n("Cancel")
|
text: i18n("Cancel")
|
||||||
display: PlasmaComponents.AbstractButton.IconOnly
|
display: PlasmaComponents.AbstractButton.IconOnly
|
||||||
PlasmaComponents.ToolTip {
|
PlasmaComponents.ToolTip {
|
||||||
text: parent.text
|
text: replyCancelButton.text
|
||||||
}
|
}
|
||||||
icon.name: "dialog-cancel"
|
icon.name: "dialog-cancel"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
replyTextField.text = "";
|
replyTextField.text = "";
|
||||||
replying = false;
|
listitem.replying = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.TextArea {
|
PlasmaComponents.TextArea {
|
||||||
id: replyTextField
|
id: replyTextField
|
||||||
placeholderText: i18nc("@info:placeholder", "Reply to %1…", appName)
|
placeholderText: i18nc("@info:placeholder", "Reply to %1…", listitem.model.appName)
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: event => {
|
||||||
|
@ -414,11 +429,11 @@ PlasmaComponents.ItemDelegate {
|
||||||
id: replySendButton
|
id: replySendButton
|
||||||
text: i18n("Send")
|
text: i18n("Send")
|
||||||
icon.name: "document-send"
|
icon.name: "document-send"
|
||||||
enabled: replyTextField.text
|
enabled: replyTextField.text !== ""
|
||||||
onClicked: {
|
onClicked: {
|
||||||
dbusInterface.sendReply(replyTextField.text);
|
listitem.model.dbusInterface.sendReply(replyTextField.text);
|
||||||
replyTextField.text = "";
|
replyTextField.text = "";
|
||||||
replying = false;
|
listitem.replying = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,16 +468,25 @@ PlasmaComponents.ItemDelegate {
|
||||||
|
|
||||||
model: KDEConnect.RemoteCommandsModel {
|
model: KDEConnect.RemoteCommandsModel {
|
||||||
id: commandsModel
|
id: commandsModel
|
||||||
deviceId: remoteCommands.device.id()
|
deviceId: root.model.deviceId
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: PlasmaComponents.ItemDelegate {
|
delegate: PlasmaComponents.ItemDelegate {
|
||||||
|
id: commandDelegate
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property var model
|
||||||
|
|
||||||
enabled: true
|
enabled: true
|
||||||
onClicked: remoteCommands.plugin?.triggerCommand(key)
|
|
||||||
|
onClicked: {
|
||||||
|
remoteCommands.plugin?.triggerCommand(commandDelegate.model.key);
|
||||||
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
contentItem: PlasmaComponents.Label {
|
contentItem: PlasmaComponents.Label {
|
||||||
text: name + "\n" + command
|
text: `${commandDelegate.model.name}\n${commandDelegate.model.command}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls as QQC2
|
import QtQuick.Controls as QQC2
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
Loading…
Reference in a new issue