Refactor window handling code
Currently when we want to show/raise the window in reaction to the tray icon/notification being clicked etc we do this by emitting a signal on the controller. This is connected to in main.qml, which does some things, then calls back to controller to do more things. This is quite convoluted. Instead introduce a new class WindowController that is responsible for all things window, in particular showing/raising and config saving
This commit is contained in:
committed by
Tobias Fella
parent
736c4b02ed
commit
55847cb9cc
21
qml/main.qml
21
qml/main.qml
@@ -51,7 +51,7 @@ Kirigami.ApplicationWindow {
|
||||
Timer {
|
||||
id: saveWindowGeometryTimer
|
||||
interval: 1000
|
||||
onTriggered: Controller.saveWindowGeometry(root)
|
||||
onTriggered: Controller.saveWindowGeometry()
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -59,7 +59,7 @@ Kirigami.ApplicationWindow {
|
||||
enabled: false // Disable on startup to avoid writing wrong values if the window is hidden
|
||||
target: root
|
||||
|
||||
function onClosing() { Controller.saveWindowGeometry(root); }
|
||||
function onClosing() { Controller.saveWindowGeometry(); }
|
||||
function onWidthChanged() { saveWindowGeometryTimer.restart(); }
|
||||
function onHeightChanged() { saveWindowGeometryTimer.restart(); }
|
||||
function onXChanged() { saveWindowGeometryTimer.restart(); }
|
||||
@@ -139,13 +139,6 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
function showWindow() {
|
||||
root.show()
|
||||
root.raise()
|
||||
root.requestActivate()
|
||||
Controller.raiseWindow(root)
|
||||
}
|
||||
|
||||
contextDrawer: RoomDrawer {
|
||||
id: contextDrawer
|
||||
modal: !root.wideScreen || !enabled
|
||||
@@ -353,16 +346,6 @@ Kirigami.ApplicationWindow {
|
||||
showPassiveNotification(i18n("%1: %2", error, detail));
|
||||
}
|
||||
|
||||
function onShowWindow(token = null) {
|
||||
root.showWindow()
|
||||
if (token && KWindowSystem) {
|
||||
KWindowSystem.setCurrentXdgActivationToken(basicNotification.xdgActivationToken)
|
||||
KWindowSystem.activateWindow(root)
|
||||
} else {
|
||||
root.raise()
|
||||
}
|
||||
}
|
||||
|
||||
function onUserConsentRequired(url) {
|
||||
consentSheet.url = url
|
||||
consentSheet.open()
|
||||
|
||||
Reference in New Issue
Block a user