This commit is contained in:
2026-03-31 20:13:15 +08:00
parent 48044e957d
commit 08c513b995
1155 changed files with 79920 additions and 0 deletions

View File

@ -0,0 +1,62 @@
/*
SPDX-FileCopyrightText: 2024 Evgeny Kazantsev <exequtic@gmail.com>
SPDX-License-Identifier: MIT
*/
import QtQuick
import org.kde.kirigami as Kirigami
Rectangle {
property var iconName: ""
property var iconColor: ""
property bool pauseBadge: iconName === pausedIcon
function setAnchor(anchor) {
if (counterRow) {
var topLeft = { top: parent.top, bottom: undefined, left: parent.left, right: undefined }
var topRight = { top: parent.top, bottom: undefined, left: undefined, right: parent.right }
var positions = pauseBadge ? topLeft : topRight
} else {
var normal = {
top: (cfg.counterTop && !cfg.counterBottom) ? parent.top : undefined,
bottom: (cfg.counterBottom && !cfg.counterTop) ? parent.bottom : undefined,
left: (cfg.counterLeft && !cfg.counterRight) ? parent.left : undefined,
right: (cfg.counterRight && !cfg.counterLeft) ? parent.right : undefined
}
var reverse = {
top: (cfg.counterBottom && !cfg.counterTop) ? parent.top : undefined,
bottom: (cfg.counterTop && !cfg.counterBottom) ? parent.bottom : undefined,
left: (cfg.counterRight && !cfg.counterLeft) ? parent.left : undefined,
right: (cfg.counterLeft && !cfg.counterRight) ? parent.right : undefined
}
var positions = pauseBadge ? reverse : normal
}
return positions[anchor]
}
width: (counterOverlay ? trayIconSize : parent.width) / 3
height: width
radius: width / 2
color: cfg.counterColor ? cfg.counterColor : Kirigami.Theme.backgroundColor
anchors {
top: setAnchor("top")
bottom: setAnchor("bottom")
left: setAnchor("left")
right: setAnchor("right")
topMargin: counterOverlay ? 0 : 5
bottomMargin: counterOverlay ? 0 : 0
leftMargin: counterOverlay ? 0 : -1
rightMargin: counterOverlay ? 0 : -1
}
Kirigami.Icon {
anchors.fill: parent
source: cfg.ownIconsUI ? Qt.resolvedUrl("../assets/icons/" + iconName + ".svg") : iconName
color: iconColor
isMask: cfg.ownIconsUI
}
}

View File

@ -0,0 +1,49 @@
/*
SPDX-FileCopyrightText: 2024 Evgeny Kazantsev <exequtic@gmail.com>
SPDX-License-Identifier: MIT
*/
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import org.kde.kirigami as Kirigami
import "../../tools/tools.js" as JS
RowLayout {
property alias labelText: label.text
ComboBox {
id: comboBox
implicitWidth: 250
textRole: "name"
model: [
{"name": i18n("None"), "value": ""},
{"name": i18n("Check updates"), "value": "checkUpdates"},
{"name": i18n("Upgrade system"), "value": "upgradeSystem"},
{"name": i18n("Switch interval"), "value": "switchInterval"},
{"name": i18n("Management"), "value": "management"}
]
onCurrentIndexChanged: {
var action = model[currentIndex]["value"]
switch (type) {
case "middle": cfg_middleAction = action; break;
case "right": cfg_rightAction = action; break;
case "scrollUp": cfg_scrollUpAction = action; break;
case "scrollDown": cfg_scrollDownAction = action; break;
}
}
Component.onCompleted: {
currentIndex = JS.setIndex(plasmoid.configuration[type + "Action"], model)
}
}
Label {
id: label
text: ""
}
property string type: ""
}

View File

@ -0,0 +1,69 @@
/*
SPDX-FileCopyrightText: 2024 Evgeny Kazantsev <exequtic@gmail.com>
SPDX-License-Identifier: MIT
*/
import QtQuick
import org.kde.notification
import "../../tools/tools.js" as JS
Item {
Component {
id: notifyComponent
Notification {
componentName: "apdatifier"
flags: cfg.notifyPersistent ? Notification.Persistent : Notification.CloseOnTimeout
}
}
Component {
id: upgradeAction
NotificationAction {
label: i18n("Upgrade system")
onActivated: JS.upgradeSystem()
}
}
Component {
id: openArticleAction
NotificationAction {
property string link
label: i18n("Read article")
onActivated: Qt.openUrlExternally(link)
}
}
function send(event, title, body, link) {
const params = {
updates: {
icon: "apdatifier-packages",
urgency: "DefaultUrgency"
},
news: {
icon: "news-subscribe",
urgency: "HighUrgency"
},
error: {
icon: "error",
urgency: "CriticalUrgency"
}
}
const { icon, urgency } = params[event]
const action = (event === "updates" && cfg.notifyUpdatesAction) ? upgradeAction.createObject(root)
: (event === "news" && cfg.notifyNewsAction) ? openArticleAction.createObject(root, { link: link })
: []
if (cfg.notifySound) event += "Sound"
notifyComponent.createObject(root, {
eventId: event,
iconName: icon,
title: title,
text: body,
actions: action,
urgency: urgency
})?.sendEvent()
}
}

View File

@ -0,0 +1,79 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import org.kde.plasma.extras
import org.kde.plasma.components
import org.kde.kirigami as Kirigami
Item {
width: parent.width
height: implicitHeight
anchors.centerIn: parent
Loader {
width: parent.width - (Kirigami.Units.largeSpacing * 4)
anchors.centerIn: parent
active: sts.updated
sourceComponent: Kirigami.PlaceholderMessage {
width: parent.width - (Kirigami.Units.largeSpacing * 4)
icon.name: "checkmark"
text: i18n("System updated")
}
}
Loader {
width: parent.width - (Kirigami.Units.largeSpacing * 4)
anchors.centerIn: parent
active: !sts.busy && sts.err
sourceComponent: Kirigami.PlaceholderMessage {
icon.name: "error"
text: sts.statusMsg
explanation: sts.errMsg
}
}
Loader {
width: parent.width - (Kirigami.Units.largeSpacing * 4)
anchors.centerIn: parent
active: sts.busy
sourceComponent: ColumnLayout {
spacing: Kirigami.Units.largeSpacing * 4
BusyIndicator {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 128
Layout.preferredHeight: 128
opacity: 0.6
running: true
}
RowLayout {
spacing: Kirigami.Units.smallSpacing
visible: !cfg.showStatusText
ToolButton {
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
hoverEnabled: false
highlighted: false
enabled: false
Kirigami.Icon {
height: parent.height
width: parent.height
anchors.centerIn: parent
source: cfg.ownIconsUI ? svg(statusIcon) : statusIcon
color: Kirigami.Theme.colorSet
scale: cfg.ownIconsUI ? 0.7 : 0.9
isMask: cfg.ownIconsUI
smooth: true
}
}
DescriptiveLabel {
text: sts.statusMsg
font.bold: true
}
}
}
}
}

View File

@ -0,0 +1,45 @@
/*
SPDX-FileCopyrightText: 2024 Evgeny Kazantsev <exequtic@gmail.com>
SPDX-License-Identifier: MIT
*/
import QtQuick
import org.kde.plasma.plasma5support as Plasma5Support
Plasma5Support.DataSource {
id: executable
engine: "executable"
connectedSources: []
onNewData: (sourceName, data) => {
var cmd = sourceName
var out = data["stdout"]
var err = data["stderr"]
var code = data["exit code"]
exited(cmd, out, err, code)
listeners[cmd](cmd, out, err, code)
}
signal exited(string cmd, string out, string err, int code)
property var listeners: ({})
function exec(cmd, callback) {
listeners[cmd] = execCallback.bind(executable, callback)
connectSource(cmd)
}
function execCallback(callback, cmd, out, err, code) {
cleanup()
if (callback) callback(cmd, out, err, code)
}
function cleanup() {
for (var cmd in listeners) {
delete listeners[cmd]
disconnectSource(cmd)
}
this.destroy()
}
}