diff --git a/src/backend/backend.py b/src/backend/backend.py index b6dfee84..2f79e925 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -243,6 +243,10 @@ class Backend: # General functions + async def get_config_dir(self) -> Path: + return Path(self.appdirs.user_config_dir) + + async def load_settings(self) -> tuple: """Return parsed user config files.""" diff --git a/src/gui/GlobalShortcuts.qml b/src/gui/GlobalShortcuts.qml index f4f68b17..d4e0611b 100644 --- a/src/gui/GlobalShortcuts.qml +++ b/src/gui/GlobalShortcuts.qml @@ -33,33 +33,34 @@ Item { flickTarget + function toggleConsole() { + if (debugConsole) { + debugConsole.visible = ! debugConsole.visible + + } else if (! defaultDebugConsoleLoader.active) { + defaultDebugConsoleLoader.active = true + + } else { + defaultDebugConsole.visible = ! defaultDebugConsole.visible + } + } + + // App HShortcut { - enabled: debugMode sequences: settings.keys.startPythonDebugger onActivated: py.call("BRIDGE.pdb") } HShortcut { - enabled: debugMode sequences: settings.keys.toggleDebugConsole - onActivated: { - if (debugConsole) { - debugConsole.visible = ! debugConsole.visible - - } else if (! defaultDebugConsoleLoader.active) { - defaultDebugConsoleLoader.active = true - - } else { - defaultDebugConsole.visible = ! defaultDebugConsole.visible - } - } + onActivated: toggleConsole() } HShortcut { sequences: settings.keys.reloadConfig - onActivated: py.loadSettings(() => { mainUI.pressAnimation.start() }) + onActivated: mainUI.reloadSettings() } HShortcut { diff --git a/src/gui/MainPane/Account.qml b/src/gui/MainPane/Account.qml index 4486adf5..295d3e0b 100644 --- a/src/gui/MainPane/Account.qml +++ b/src/gui/MainPane/Account.qml @@ -7,18 +7,17 @@ import "../Base" HTileDelegate { id: account - spacing: 0 - topPadding: model.index > 0 ? theme.spacing / 2 : 0 - bottomPadding: topPadding - + rightPadding: 0 backgroundColor: theme.mainPane.account.background opacity: collapsed && ! mainPane.filter ? theme.mainPane.account.collapsedOpacity : 1 - title.color: theme.mainPane.account.name title.text: model.display_name || model.id title.font.pixelSize: theme.fontSize.big - title.leftPadding: theme.spacing + title.color: + hovered ? + utils.nameColor(model.display_name || model.id.substring(1)) : + theme.mainPane.account.name image: HUserAvatar { userId: model.id @@ -68,63 +67,66 @@ HTileDelegate { } + Behavior on title.color { HColorAnimation {} } Behavior on opacity { HNumberAnimation {} } - HButton { - id: addChat - iconItem.small: true - icon.name: "add-chat" - backgroundColor: "transparent" - toolTip.text: qsTr("Add new chat") - onClicked: pageLoader.showPage( - "AddChat/AddChat", {userId: model.id}, - ) + HRowLayout { + HButton { + id: addChat + iconItem.small: true + icon.name: "add-chat" + backgroundColor: "transparent" + toolTip.text: qsTr("Add new chat") + onClicked: pageLoader.showPage( + "AddChat/AddChat", {userId: model.id}, + ) - leftPadding: theme.spacing / 2 - rightPadding: leftPadding + leftPadding: theme.spacing / 2 + rightPadding: leftPadding - opacity: expand.loading ? 0 : 1 - visible: opacity > 0 && Layout.maximumWidth > 0 + opacity: expand.loading ? 0 : 1 + visible: opacity > 0 && Layout.maximumWidth > 0 - Layout.fillHeight: true - Layout.maximumWidth: - account.width >= 100 * theme.uiScale ? implicitWidth : 0 + Layout.fillHeight: true + Layout.maximumWidth: + account.width >= 100 * theme.uiScale ? implicitWidth : 0 - Behavior on Layout.maximumWidth { HNumberAnimation {} } - Behavior on opacity { HNumberAnimation {} } - } - - HButton { - id: expand - loading: - ! model.first_sync_done || model.profile_updated < new Date(1) - iconItem.small: true - icon.name: "expand" - backgroundColor: "transparent" - toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse") - onClicked: account.toggleCollapse() - - leftPadding: theme.spacing / 2 - rightPadding: leftPadding - - opacity: ! loading && mainPane.filter ? 0 : 1 - visible: opacity > 0 && Layout.maximumWidth > 0 - - Layout.fillHeight: true - Layout.maximumWidth: - account.width >= 120 * theme.uiScale ? implicitWidth : 0 - - - iconItem.transform: Rotation { - origin.x: expand.iconItem.width / 2 - origin.y: expand.iconItem.height / 2 - angle: expand.loading ? 0 : collapsed ? 180 : 90 - - Behavior on angle { HNumberAnimation {} } + Behavior on Layout.maximumWidth { HNumberAnimation {} } + Behavior on opacity { HNumberAnimation {} } } - Behavior on Layout.maximumWidth { HNumberAnimation {} } - Behavior on opacity { HNumberAnimation {} } + HButton { + id: expand + loading: + ! model.first_sync_done || model.profile_updated < new Date(1) + iconItem.small: true + icon.name: "expand" + backgroundColor: "transparent" + toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse") + onClicked: account.toggleCollapse() + + leftPadding: theme.spacing / 2 + rightPadding: theme.spacing + + opacity: ! loading && mainPane.filter ? 0 : 1 + visible: opacity > 0 && Layout.maximumWidth > 0 + + Layout.fillHeight: true + Layout.maximumWidth: + account.width >= 120 * theme.uiScale ? implicitWidth : 0 + + + iconItem.transform: Rotation { + origin.x: expand.iconItem.width / 2 + origin.y: expand.iconItem.height / 2 + angle: expand.loading ? 0 : collapsed ? 180 : 90 + + Behavior on angle { HNumberAnimation {} } + } + + Behavior on Layout.maximumWidth { HNumberAnimation {} } + Behavior on opacity { HNumberAnimation {} } + } } } diff --git a/src/gui/MainPane/MainPane.qml b/src/gui/MainPane/MainPane.qml index 4734b494..38935fc4 100644 --- a/src/gui/MainPane/MainPane.qml +++ b/src/gui/MainPane/MainPane.qml @@ -45,6 +45,12 @@ HDrawer { HColumnLayout { anchors.fill: parent + TopBar { + Layout.fillWidth: true + Layout.fillHeight: false + Layout.preferredHeight: theme.baseElementsHeight + } + AccountRoomsList { id: mainPaneList clip: true @@ -60,7 +66,6 @@ HDrawer { Layout.fillWidth: true Layout.fillHeight: false Layout.preferredHeight: theme.baseElementsHeight - } } } diff --git a/src/gui/MainPane/Room.qml b/src/gui/MainPane/Room.qml index fa760740..91690846 100644 --- a/src/gui/MainPane/Room.qml +++ b/src/gui/MainPane/Room.qml @@ -7,10 +7,14 @@ import ".." import "../Base" HTileDelegate { - spacing: theme.spacing backgroundColor: theme.mainPane.room.background opacity: model.left ? theme.mainPane.room.leftRoomOpacity : 1 + topPadding: theme.spacing / (model.index === 0 ? 1 : 1.5) + bottomPadding: theme.spacing / (model.index === view.count - 1 ? 1 : 1.5) + leftPadding: theme.spacing * 2 + rightPadding: theme.spacing + image: HRoomAvatar { roomId: model.id displayName: model.display_name diff --git a/src/gui/MainPane/TopBar.qml b/src/gui/MainPane/TopBar.qml new file mode 100644 index 00000000..3b9ef0f5 --- /dev/null +++ b/src/gui/MainPane/TopBar.qml @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later + +import QtQuick 2.12 +import QtQuick.Layouts 1.12 +import "../Base" + +Rectangle { + color: theme.mainPane.topBar.background + + HRowLayout { + anchors.fill: parent + + HButton { + icon.name: "placeholder-logo" + icon.color: theme.mainPane.topBar.placeholderLogo + + text: qsTr("%1 %2") + .arg(Qt.application.displayName).arg(Qt.application.version) + label.color: theme.mainPane.topBar.nameVersionLabel + label.horizontalAlignment: Text.AlignLeft + toolTip.text: qsTr("Open project repository") + + onClicked: + Qt.openUrlExternally("https://github.com/mirukan/mirage") + + Layout.fillWidth: true + Layout.fillHeight: true + } + + HButton { + icon.name: "developper-console" + toolTip.text: qsTr("Developper console") + + onClicked: mainUI.shortcuts.toggleConsole() // FIXME + + Layout.fillHeight: true + } + + HButton { + icon.name: "reload-config-files" + toolTip.text: qsTr("Reload config files") + + onClicked: mainUI.reloadSettings() + + Layout.fillHeight: true + } + + HButton { + icon.name: "settings" + toolTip.text: qsTr("Open config folder") + + onClicked: py.callCoro("get_config_dir", [], Qt.openUrlExternally) + + Layout.fillHeight: true + } + } +} diff --git a/src/gui/Pages/Chat/Timeline/EventDelegate.qml b/src/gui/Pages/Chat/Timeline/EventDelegate.qml index 900cc003..8535cf67 100644 --- a/src/gui/Pages/Chat/Timeline/EventDelegate.qml +++ b/src/gui/Pages/Chat/Timeline/EventDelegate.qml @@ -168,7 +168,6 @@ HColumnLayout { HMenuItem { icon.name: "debug" text: qsTr("Debug this event") - visible: debugMode onTriggered: eventContent.debugConsoleLoader.toggle() } diff --git a/src/gui/UI.qml b/src/gui/UI.qml index ca4734df..c4fb485e 100644 --- a/src/gui/UI.qml +++ b/src/gui/UI.qml @@ -24,6 +24,11 @@ Item { readonly property alias pressAnimation: pressAnimation + function reloadSettings() { + py.loadSettings(() => { mainUI.pressAnimation.start() }) + } + + SequentialAnimation { id: pressAnimation HNumberAnimation { diff --git a/src/icons/thin/developper-console.svg b/src/icons/thin/developper-console.svg new file mode 100644 index 00000000..d1cc9a6e --- /dev/null +++ b/src/icons/thin/developper-console.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/thin/placeholder-logo.svg b/src/icons/thin/placeholder-logo.svg new file mode 100644 index 00000000..06f821b9 --- /dev/null +++ b/src/icons/thin/placeholder-logo.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/thin/reload-config-files.svg b/src/icons/thin/reload-config-files.svg new file mode 100644 index 00000000..f5e68332 --- /dev/null +++ b/src/icons/thin/reload-config-files.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/thin/settings.svg b/src/icons/thin/settings.svg index 93439b12..bd8786c6 100644 --- a/src/icons/thin/settings.svg +++ b/src/icons/thin/settings.svg @@ -1,3 +1,3 @@ - + diff --git a/src/themes/Glass.qpl b/src/themes/Glass.qpl index 31f02120..ececcfe8 100644 --- a/src/themes/Glass.qpl +++ b/src/themes/Glass.qpl @@ -256,6 +256,11 @@ ui: mainPane: color background: colors.mediumBackground + topBar: + color background: colors.strongBackground + color placeholderLogo: colors.accentElement + color nameVersionLabel: colors.text + account: real collapsedOpacity: 0.3 color background: "transparent" diff --git a/src/themes/Midnight.qpl b/src/themes/Midnight.qpl index 43bdeb8a..87d332cf 100644 --- a/src/themes/Midnight.qpl +++ b/src/themes/Midnight.qpl @@ -263,6 +263,11 @@ ui: mainPane: color background: colors.mediumBackground + topBar: + color background: colors.strongBackground + color placeholderLogo: colors.accentElement + color nameVersionLabel: colors.text + account: real collapsedOpacity: 0.3 color background: "transparent"