mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-15 16:52: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)
|
m.schedulerWG.Add(1)
|
||||||
go m.scheduler()
|
go m.scheduler()
|
||||||
|
|
||||||
go m.runRefresh(context.Background())
|
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,14 +181,11 @@ func (m *Manager) Cancel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Acquire() {
|
func (m *Manager) Acquire() {
|
||||||
first := atomic.AddInt32(&m.acquireCount, 1) == 1
|
atomic.AddInt32(&m.acquireCount, 1)
|
||||||
select {
|
select {
|
||||||
case m.wakeSched <- struct{}{}:
|
case m.wakeSched <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
if first {
|
|
||||||
go m.runRefresh(context.Background())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Release() {
|
func (m *Manager) Release() {
|
||||||
@@ -415,7 +410,6 @@ func (m *Manager) finishSuccessfulUpgrade(clearPackages bool) {
|
|||||||
}
|
}
|
||||||
m.mu.Unlock()
|
m.mu.Unlock()
|
||||||
m.markDirty()
|
m.markDirty()
|
||||||
go m.runRefresh(context.Background())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeBackends(sel Selection, opts UpgradeOptions) []Backend {
|
func upgradeBackends(sel Selection, opts UpgradeOptions) []Backend {
|
||||||
|
|||||||
@@ -720,6 +720,7 @@ Singleton {
|
|||||||
property string customPowerActionPowerOff: ""
|
property string customPowerActionPowerOff: ""
|
||||||
|
|
||||||
property bool updaterHideWidget: false
|
property bool updaterHideWidget: false
|
||||||
|
property bool updaterCheckOnStart: false
|
||||||
property bool updaterUseCustomCommand: false
|
property bool updaterUseCustomCommand: false
|
||||||
property string updaterCustomCommand: ""
|
property string updaterCustomCommand: ""
|
||||||
property string updaterTerminalAdditionalParams: ""
|
property string updaterTerminalAdditionalParams: ""
|
||||||
|
|||||||
@@ -431,6 +431,7 @@ var SPEC = {
|
|||||||
customPowerActionPowerOff: { def: "" },
|
customPowerActionPowerOff: { def: "" },
|
||||||
|
|
||||||
updaterHideWidget: { def: false },
|
updaterHideWidget: { def: false },
|
||||||
|
updaterCheckOnStart: { def: false },
|
||||||
updaterUseCustomCommand: { def: false },
|
updaterUseCustomCommand: { def: false },
|
||||||
updaterCustomCommand: { def: "" },
|
updaterCustomCommand: { def: "" },
|
||||||
updaterTerminalAdditionalParams: { def: "" },
|
updaterTerminalAdditionalParams: { def: "" },
|
||||||
|
|||||||
@@ -159,13 +159,6 @@ Rectangle {
|
|||||||
"icon": "tune",
|
"icon": "tune",
|
||||||
"tabIndex": 18
|
"tabIndex": 18
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "updater",
|
|
||||||
"text": I18n.tr("System Updater"),
|
|
||||||
"icon": "refresh",
|
|
||||||
"tabIndex": 20,
|
|
||||||
"updaterOnly": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "desktop_widgets",
|
"id": "desktop_widgets",
|
||||||
"text": I18n.tr("Desktop Widgets"),
|
"text": I18n.tr("Desktop Widgets"),
|
||||||
@@ -293,6 +286,13 @@ Rectangle {
|
|||||||
"icon": "terminal",
|
"icon": "terminal",
|
||||||
"tabIndex": 32
|
"tabIndex": 32
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "updater",
|
||||||
|
"text": I18n.tr("System Updater"),
|
||||||
|
"icon": "refresh",
|
||||||
|
"tabIndex": 20,
|
||||||
|
"updaterOnly": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "window_rules",
|
"id": "window_rules",
|
||||||
"text": I18n.tr("Window Rules"),
|
"text": I18n.tr("Window Rules"),
|
||||||
|
|||||||
@@ -75,16 +75,6 @@ DankPopout {
|
|||||||
close();
|
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 {
|
content: Component {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: updaterPanel
|
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 {
|
SettingsToggleRow {
|
||||||
text: I18n.tr("Include Flatpak updates")
|
text: I18n.tr("Include Flatpak updates")
|
||||||
description: I18n.tr("Apply Flatpak updates alongside system updates when running 'Update All'.")
|
description: I18n.tr("Apply Flatpak updates alongside system updates when running 'Update All'.")
|
||||||
|
|||||||
@@ -43,22 +43,36 @@ Singleton {
|
|||||||
root.checkCapabilities();
|
root.checkCapabilities();
|
||||||
} else {
|
} else {
|
||||||
root.sysupdateAvailable = false;
|
root.sysupdateAvailable = false;
|
||||||
|
root._startupCheckDone = false;
|
||||||
}
|
}
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
}
|
}
|
||||||
function onSysupdateStateUpdate(data) {
|
function onSysupdateStateUpdate(data) {
|
||||||
root._applyState(data);
|
root._applyState(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SettingsData
|
||||||
|
function onUpdaterCheckOnStartChanged() {
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
|
}
|
||||||
|
function on_HasLoadedChanged() {
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (DMSService.dmsAvailable) {
|
if (DMSService.dmsAvailable) {
|
||||||
checkCapabilities();
|
checkCapabilities();
|
||||||
}
|
}
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCapabilities() {
|
function checkCapabilities() {
|
||||||
if (!DMSService.capabilities || !Array.isArray(DMSService.capabilities)) {
|
if (!DMSService.capabilities || !Array.isArray(DMSService.capabilities)) {
|
||||||
sysupdateAvailable = false;
|
sysupdateAvailable = false;
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const has = DMSService.capabilities.includes("sysupdate");
|
const has = DMSService.capabilities.includes("sysupdate");
|
||||||
@@ -68,6 +82,7 @@ Singleton {
|
|||||||
} else if (!has) {
|
} else if (!has) {
|
||||||
sysupdateAvailable = false;
|
sysupdateAvailable = false;
|
||||||
}
|
}
|
||||||
|
Qt.callLater(() => root._maybeStartupCheck());
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestState() {
|
function requestState() {
|
||||||
@@ -171,10 +186,31 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: customRunner
|
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()
|
onSysupdateAvailableChanged: _syncAcquire()
|
||||||
|
|
||||||
property bool _acquired: false
|
property bool _acquired: false
|
||||||
|
|||||||
Reference in New Issue
Block a user