mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-08 06:25:37 -05:00
plugins: improve update/tooltips/UI
This commit is contained in:
@@ -12,6 +12,7 @@ FocusScope {
|
|||||||
property string expandedPluginId: ""
|
property string expandedPluginId: ""
|
||||||
property bool isRefreshingPlugins: false
|
property bool isRefreshingPlugins: false
|
||||||
property var parentModal: null
|
property var parentModal: null
|
||||||
|
property var installedPluginsData: ({})
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
|
|
||||||
@@ -245,9 +246,13 @@ FocusScope {
|
|||||||
property var pluginPermissions: pluginData ? (pluginData.permissions || []) : []
|
property var pluginPermissions: pluginData ? (pluginData.permissions || []) : []
|
||||||
property bool hasSettings: pluginData && pluginData.settings !== undefined && pluginData.settings !== ""
|
property bool hasSettings: pluginData && pluginData.settings !== undefined && pluginData.settings !== ""
|
||||||
property bool isExpanded: pluginsTab.expandedPluginId === pluginId
|
property bool isExpanded: pluginsTab.expandedPluginId === pluginId
|
||||||
|
property bool hasUpdate: {
|
||||||
|
if (DMSService.apiVersion < 8) return true
|
||||||
|
return pluginsTab.installedPluginsData[pluginDirectoryName] || pluginsTab.installedPluginsData[pluginId] || pluginsTab.installedPluginsData[pluginName] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
color: pluginMouseArea.containsMouse ? Theme.surfacePressed : (isExpanded ? Theme.surfaceContainerHighest : Theme.surfaceContainerHigh)
|
color: (pluginMouseArea.containsMouse || updateArea.containsMouse || uninstallArea.containsMouse || reloadArea.containsMouse) ? Theme.surfacePressed : (isExpanded ? Theme.surfaceContainerHighest : Theme.surfaceContainerHigh)
|
||||||
border.width: 0
|
border.width: 0
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -326,7 +331,7 @@ FocusScope {
|
|||||||
height: 28
|
height: 28
|
||||||
radius: 14
|
radius: 14
|
||||||
color: updateArea.containsMouse ? Theme.surfaceContainerHighest : "transparent"
|
color: updateArea.containsMouse ? Theme.surfaceContainerHighest : "transparent"
|
||||||
visible: DMSService.dmsAvailable && PluginService.isPluginLoaded(pluginDelegate.pluginId)
|
visible: DMSService.dmsAvailable && PluginService.isPluginLoaded(pluginDelegate.pluginId) && pluginDelegate.hasUpdate
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@@ -343,15 +348,32 @@ FocusScope {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
const currentPluginDirName = pluginDelegate.pluginDirectoryName
|
const currentPluginDirName = pluginDelegate.pluginDirectoryName
|
||||||
const currentPluginName = pluginDelegate.pluginName
|
const currentPluginName = pluginDelegate.pluginName
|
||||||
|
const currentPluginId = pluginDelegate.pluginId
|
||||||
DMSService.update(currentPluginDirName, response => {
|
DMSService.update(currentPluginDirName, response => {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
ToastService.showError("Update failed: " + response.error)
|
ToastService.showError("Update failed: " + response.error)
|
||||||
} else {
|
} else {
|
||||||
ToastService.showInfo("Plugin updated: " + currentPluginName)
|
ToastService.showInfo("Plugin updated: " + currentPluginName)
|
||||||
PluginService.scanPlugins()
|
PluginService.forceRescanPlugin(currentPluginId)
|
||||||
|
if (DMSService.apiVersion >= 8) {
|
||||||
|
DMSService.listInstalled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
onEntered: {
|
||||||
|
tooltipLoader.active = true
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
const p = mapToItem(null, width / 2, 0)
|
||||||
|
tooltipLoader.item.show(I18n.tr("Update Plugin"), p.x, p.y - 40, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
tooltipLoader.item.hide()
|
||||||
|
}
|
||||||
|
tooltipLoader.active = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,6 +411,19 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
onEntered: {
|
||||||
|
tooltipLoader.active = true
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
const p = mapToItem(null, width / 2, 0)
|
||||||
|
tooltipLoader.item.show(I18n.tr("Uninstall Plugin"), p.x, p.y - 40, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
tooltipLoader.item.hide()
|
||||||
|
}
|
||||||
|
tooltipLoader.active = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,6 +457,19 @@ FocusScope {
|
|||||||
pluginsTab.isReloading = false
|
pluginsTab.isReloading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onEntered: {
|
||||||
|
tooltipLoader.active = true
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
const p = mapToItem(null, width / 2, 0)
|
||||||
|
tooltipLoader.item.show(I18n.tr("Reload Plugin"), p.x, p.y - 40, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
if (tooltipLoader.item) {
|
||||||
|
tooltipLoader.item.hide()
|
||||||
|
}
|
||||||
|
tooltipLoader.active = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,6 +609,12 @@ FocusScope {
|
|||||||
visible: pluginDelegate.isExpanded && (!settingsLoader.active || settingsLoader.status === Loader.Error)
|
visible: pluginDelegate.isExpanded && (!settingsLoader.active || settingsLoader.status === Loader.Error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: tooltipLoader
|
||||||
|
active: false
|
||||||
|
sourceComponent: DankTooltip {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,6 +658,9 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onPluginListUpdated() {
|
function onPluginListUpdated() {
|
||||||
|
if (DMSService.apiVersion >= 8) {
|
||||||
|
DMSService.listInstalled()
|
||||||
|
}
|
||||||
refreshPluginList()
|
refreshPluginList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -615,6 +672,21 @@ FocusScope {
|
|||||||
pluginBrowserModal.allPlugins = plugins
|
pluginBrowserModal.allPlugins = plugins
|
||||||
pluginBrowserModal.updateFilteredPlugins()
|
pluginBrowserModal.updateFilteredPlugins()
|
||||||
}
|
}
|
||||||
|
function onInstalledPluginsReceived(plugins) {
|
||||||
|
var pluginMap = {}
|
||||||
|
for (var i = 0; i < plugins.length; i++) {
|
||||||
|
var plugin = plugins[i]
|
||||||
|
var hasUpdate = plugin.hasUpdate || false
|
||||||
|
if (plugin.path) {
|
||||||
|
pluginMap[plugin.path] = hasUpdate
|
||||||
|
}
|
||||||
|
if (plugin.name) {
|
||||||
|
pluginMap[plugin.name] = hasUpdate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
installedPluginsData = pluginMap
|
||||||
|
Qt.callLater(refreshPluginList)
|
||||||
|
}
|
||||||
function onOperationSuccess(message) {
|
function onOperationSuccess(message) {
|
||||||
ToastService.showInfo(message)
|
ToastService.showInfo(message)
|
||||||
}
|
}
|
||||||
@@ -625,6 +697,9 @@ FocusScope {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
pluginBrowserModal.parentModal = pluginsTab.parentModal
|
pluginBrowserModal.parentModal = pluginsTab.parentModal
|
||||||
|
if (DMSService.dmsAvailable && DMSService.apiVersion >= 8) {
|
||||||
|
DMSService.listInstalled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DankModal {
|
DankModal {
|
||||||
@@ -701,6 +776,9 @@ FocusScope {
|
|||||||
function refreshPlugins() {
|
function refreshPlugins() {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
DMSService.listPlugins()
|
DMSService.listPlugins()
|
||||||
|
if (DMSService.apiVersion >= 8) {
|
||||||
|
DMSService.listInstalled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
|
|||||||
@@ -516,6 +516,19 @@ Singleton {
|
|||||||
resyncDebounce.restart()
|
resyncDebounce.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function forceRescanPlugin(pluginId) {
|
||||||
|
const plugin = availablePlugins[pluginId]
|
||||||
|
if (plugin && plugin.manifestPath) {
|
||||||
|
const manifestPath = plugin.manifestPath
|
||||||
|
const source = plugin.source || "user"
|
||||||
|
delete knownManifests[manifestPath]
|
||||||
|
const newMap = Object.assign({}, availablePlugins)
|
||||||
|
delete newMap[pluginId]
|
||||||
|
availablePlugins = newMap
|
||||||
|
loadPluginManifestFile(manifestPath, source, Date.now())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createPluginDirectory() {
|
function createPluginDirectory() {
|
||||||
const mkdirProcess = Qt.createComponent("data:text/plain,import Quickshell.Io; Process { }")
|
const mkdirProcess = Qt.createComponent("data:text/plain,import Quickshell.Io; Process { }")
|
||||||
if (mkdirProcess.status === Component.Ready) {
|
if (mkdirProcess.status === Component.Ready) {
|
||||||
|
|||||||
Reference in New Issue
Block a user