Add config option closeMinimizesToTray
Options of the system tray icon: - Hide/show Mirage - Quit Mirage Draw attention to Mirage when clicking on the icon
This commit is contained in:
parent
6061b2f061
commit
56ad0b9975
@ -273,6 +273,7 @@ class UISettings(JSONDataFile):
|
||||
"clearRoomFilterOnEnter": True,
|
||||
"clearRoomFilterOnEscape": True,
|
||||
"clearMemberFilterOnEscape": True,
|
||||
"closeMinimizesToTray": False,
|
||||
"collapseSidePanesUnderWindowWidth": 450,
|
||||
"enableKineticScrolling": True,
|
||||
"hideProfileChangeEvents": True,
|
||||
|
@ -23,6 +23,7 @@ ApplicationWindow {
|
||||
property var uiState: ({})
|
||||
property var history: ({})
|
||||
property var theme: null
|
||||
property bool closing: false
|
||||
|
||||
readonly property var visibleMenus: ({})
|
||||
readonly property var visiblePopups: ({})
|
||||
@ -65,6 +66,11 @@ ApplicationWindow {
|
||||
)
|
||||
}
|
||||
|
||||
function drawAttention() {
|
||||
window.show()
|
||||
window.raise()
|
||||
window.requestActivate()
|
||||
}
|
||||
|
||||
|
||||
flags: Qt.WA_TranslucentBackground
|
||||
@ -81,6 +87,11 @@ ApplicationWindow {
|
||||
onUiStateChanged: py.saveConfig("ui_state", uiState)
|
||||
onHistoryChanged: py.saveConfig("history", history)
|
||||
|
||||
onClosing: {
|
||||
close.accepted = ! settings.closeMinimizesToTray
|
||||
onTriggered: if (settings.closeMinimizesToTray) hide()
|
||||
}
|
||||
|
||||
PythonRootBridge { id: py }
|
||||
|
||||
Utils { id: utils }
|
||||
@ -109,12 +120,25 @@ ApplicationWindow {
|
||||
tooltip: qsTr("Mirage")
|
||||
icon.source: `../icons/${iconPack}/tray-icon.png`
|
||||
|
||||
onActivated: window.show()
|
||||
onActivated:
|
||||
if (reason !== SystemTrayIcon.Context)
|
||||
window.drawAttention()
|
||||
|
||||
|
||||
menu: Menu {
|
||||
MenuItem {
|
||||
text: qsTr("Quit")
|
||||
onTriggered: window.hide()
|
||||
text: window.visible ? "Hide Mirage" : "Show Mirage"
|
||||
onTriggered:
|
||||
window.visible ?
|
||||
window.hide() :
|
||||
window.drawAttention()
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Quit Mirage")
|
||||
onTriggered: {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,6 +180,9 @@ int main(int argc, char *argv[]) {
|
||||
QQmlEngine engine;
|
||||
QQmlContext *objectContext = new QQmlContext(engine.rootContext());
|
||||
|
||||
// For being able to use Qt.quit() in QML side
|
||||
QObject::connect(&engine, &QQmlEngine::quit, &QApplication::quit);
|
||||
|
||||
// Set the debugMode properties depending of if we're running in debug mode
|
||||
// or not (`qmake CONFIG+=dev ...`, default in live-reload.sh)
|
||||
#ifdef QT_DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user