mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-15 00:32:47 -04:00
refactor(SysUpdate): Explicit Run on Startup option in settings
- Relocated DMS System Updater to System Setting section - Removed forced auto refresh upon update & widget loading
This commit is contained in:
@@ -79,8 +79,6 @@ func NewManager() (*Manager, error) {
|
||||
m.schedulerWG.Add(1)
|
||||
go m.scheduler()
|
||||
|
||||
go m.runRefresh(context.Background())
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -183,14 +181,11 @@ func (m *Manager) Cancel() {
|
||||
}
|
||||
|
||||
func (m *Manager) Acquire() {
|
||||
first := atomic.AddInt32(&m.acquireCount, 1) == 1
|
||||
atomic.AddInt32(&m.acquireCount, 1)
|
||||
select {
|
||||
case m.wakeSched <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
if first {
|
||||
go m.runRefresh(context.Background())
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) Release() {
|
||||
@@ -415,7 +410,6 @@ func (m *Manager) finishSuccessfulUpgrade(clearPackages bool) {
|
||||
}
|
||||
m.mu.Unlock()
|
||||
m.markDirty()
|
||||
go m.runRefresh(context.Background())
|
||||
}
|
||||
|
||||
func upgradeBackends(sel Selection, opts UpgradeOptions) []Backend {
|
||||
|
||||
@@ -720,6 +720,7 @@ Singleton {
|
||||
property string customPowerActionPowerOff: ""
|
||||
|
||||
property bool updaterHideWidget: false
|
||||
property bool updaterCheckOnStart: false
|
||||
property bool updaterUseCustomCommand: false
|
||||
property string updaterCustomCommand: ""
|
||||
property string updaterTerminalAdditionalParams: ""
|
||||
|
||||
@@ -431,6 +431,7 @@ var SPEC = {
|
||||
customPowerActionPowerOff: { def: "" },
|
||||
|
||||
updaterHideWidget: { def: false },
|
||||
updaterCheckOnStart: { def: false },
|
||||
updaterUseCustomCommand: { def: false },
|
||||
updaterCustomCommand: { def: "" },
|
||||
updaterTerminalAdditionalParams: { def: "" },
|
||||
|
||||
@@ -159,13 +159,6 @@ Rectangle {
|
||||
"icon": "tune",
|
||||
"tabIndex": 18
|
||||
},
|
||||
{
|
||||
"id": "updater",
|
||||
"text": I18n.tr("System Updater"),
|
||||
"icon": "refresh",
|
||||
"tabIndex": 20,
|
||||
"updaterOnly": true
|
||||
},
|
||||
{
|
||||
"id": "desktop_widgets",
|
||||
"text": I18n.tr("Desktop Widgets"),
|
||||
@@ -293,6 +286,13 @@ Rectangle {
|
||||
"icon": "terminal",
|
||||
"tabIndex": 32
|
||||
},
|
||||
{
|
||||
"id": "updater",
|
||||
"text": I18n.tr("System Updater"),
|
||||
"icon": "refresh",
|
||||
"tabIndex": 20,
|
||||
"updaterOnly": true
|
||||
},
|
||||
{
|
||||
"id": "window_rules",
|
||||
"text": I18n.tr("Window Rules"),
|
||||
|
||||
@@ -75,16 +75,6 @@ DankPopout {
|
||||
close();
|
||||
}
|
||||
|
||||
onShouldBeVisibleChanged: {
|
||||
if (!shouldBeVisible) {
|
||||
return;
|
||||
}
|
||||
const stale = !SystemUpdateService.lastCheckUnix || (Date.now() / 1000 - SystemUpdateService.lastCheckUnix) > 300;
|
||||
if (stale && !SystemUpdateService.isChecking && !SystemUpdateService.isUpgrading) {
|
||||
SystemUpdateService.checkForUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Rectangle {
|
||||
id: updaterPanel
|
||||
|
||||
@@ -93,6 +93,13 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
text: I18n.tr("Check on startup")
|
||||
description: I18n.tr("When enabled, checks updates on startup. When disabled, only the interval above or a manual refresh runs a check.")
|
||||
checked: SettingsData.updaterCheckOnStart
|
||||
onToggled: checked => SettingsData.set("updaterCheckOnStart", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
text: I18n.tr("Include Flatpak updates")
|
||||
description: I18n.tr("Apply Flatpak updates alongside system updates when running 'Update All'.")
|
||||
|
||||
@@ -43,22 +43,36 @@ Singleton {
|
||||
root.checkCapabilities();
|
||||
} else {
|
||||
root.sysupdateAvailable = false;
|
||||
root._startupCheckDone = false;
|
||||
}
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
function onSysupdateStateUpdate(data) {
|
||||
root._applyState(data);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsData
|
||||
function onUpdaterCheckOnStartChanged() {
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
function on_HasLoadedChanged() {
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (DMSService.dmsAvailable) {
|
||||
checkCapabilities();
|
||||
}
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
|
||||
function checkCapabilities() {
|
||||
if (!DMSService.capabilities || !Array.isArray(DMSService.capabilities)) {
|
||||
sysupdateAvailable = false;
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
return;
|
||||
}
|
||||
const has = DMSService.capabilities.includes("sysupdate");
|
||||
@@ -68,6 +82,7 @@ Singleton {
|
||||
} else if (!has) {
|
||||
sysupdateAvailable = false;
|
||||
}
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
|
||||
function requestState() {
|
||||
@@ -171,10 +186,31 @@ Singleton {
|
||||
|
||||
Process {
|
||||
id: customRunner
|
||||
onExited: root.checkForUpdates()
|
||||
}
|
||||
|
||||
onRefCountChanged: _syncAcquire()
|
||||
property bool _startupCheckDone: false
|
||||
|
||||
function _maybeStartupCheck() {
|
||||
if (refCount <= 0) {
|
||||
_startupCheckDone = false;
|
||||
return;
|
||||
}
|
||||
if (!SettingsData.updaterCheckOnStart)
|
||||
return;
|
||||
if (_startupCheckDone)
|
||||
return;
|
||||
if (!DMSService.isConnected || !sysupdateAvailable)
|
||||
return;
|
||||
_startupCheckDone = true;
|
||||
Qt.callLater(() => root.checkForUpdates());
|
||||
}
|
||||
|
||||
onRefCountChanged: {
|
||||
if (refCount <= 0)
|
||||
_startupCheckDone = false;
|
||||
_syncAcquire();
|
||||
Qt.callLater(() => root._maybeStartupCheck());
|
||||
}
|
||||
onSysupdateAvailableChanged: _syncAcquire()
|
||||
|
||||
property bool _acquired: false
|
||||
|
||||
Reference in New Issue
Block a user