diff --git a/src/qml/Chat/Timeline/EventDelegate.qml b/src/qml/Chat/Timeline/EventDelegate.qml index 66574d61..46e57c1e 100644 --- a/src/qml/Chat/Timeline/EventDelegate.qml +++ b/src/qml/Chat/Timeline/EventDelegate.qml @@ -170,10 +170,8 @@ Column { icon.name: "settings" text: qsTr("Set as debug console target") visible: debugMode - onTriggered: { - mainUI.debugConsole.target = [eventDelegate, eventContent] - mainUI.debugConsole.runJS("t[0].json()") - } + onTriggered: + Utils.debug(eventDelegate, con => { con.runJS("json()") }) } } } diff --git a/src/qml/DebugConsole.qml b/src/qml/DebugConsole.qml index 39a71618..49bd4302 100644 --- a/src/qml/DebugConsole.qml +++ b/src/qml/DebugConsole.qml @@ -17,9 +17,11 @@ Window { property alias t: debugConsole.target - onTargetChanged: { + Component.onCompleted: { + print(parent) + mainUI.shortcuts.debugConsole = debugConsole commandsView.model.insert(0, { - input: "t = " + String(target), + input: "target = " + String(target), output: "", error: false, }) diff --git a/src/qml/Shortcuts.qml b/src/qml/Shortcuts.qml index e688ee48..ea106016 100644 --- a/src/qml/Shortcuts.qml +++ b/src/qml/Shortcuts.qml @@ -3,7 +3,8 @@ import "Base" import "utils.js" as Utils HShortcutHandler { - property Item flickTarget: Item {} + property Item flickTarget + property DebugConsole debugConsole // App @@ -14,9 +15,9 @@ HShortcutHandler { } HShortcut { - enabled: debugMode + enabled: debugMode && debugConsole sequences: settings.keys.toggleDebugConsole - onPressed: mainUI.debugConsole.visible = ! mainUI.debugConsole.visible + onPressed: debugConsole.visible = ! debugConsole.visible } HShortcut { @@ -27,18 +28,21 @@ HShortcutHandler { // Page scrolling HShortcut { + enabled: flickTarget sequences: settings.keys.scrollUp onPressed: Utils.smartVerticalFlick(flickTarget, -335) onHeld: pressed(event) } HShortcut { + enabled: flickTarget sequences: settings.keys.scrollDown onPressed: Utils.smartVerticalFlick(flickTarget, 335) onHeld: pressed(event) } HShortcut { + enabled: flickTarget sequences: settings.keys.scrollPageUp onPressed: Utils.smartVerticalFlick( flickTarget, -2.3 * flickTarget.height, 8, @@ -49,6 +53,7 @@ HShortcutHandler { } HShortcut { + enabled: flickTarget sequences: settings.keys.scrollPageDown onPressed: Utils.smartVerticalFlick( flickTarget, 2.3 * flickTarget.height, 8, @@ -58,12 +63,14 @@ HShortcutHandler { } HShortcut { + enabled: flickTarget sequences: settings.keys.scrollToTop onPressed: Utils.flickToTop(flickTarget) onHeld: pressed(event) } HShortcut { + enabled: flickTarget sequences: settings.keys.scrollToBottom onPressed: Utils.flickToBottom(flickTarget) onHeld: pressed(event) diff --git a/src/qml/UI.qml b/src/qml/UI.qml index 6e425869..70d11883 100644 --- a/src/qml/UI.qml +++ b/src/qml/UI.qml @@ -5,6 +5,7 @@ import QtQuick.Window 2.7 import QtGraphicalEffects 1.12 import "Base" import "SidePane" +import "utils.js" as Utils Item { id: mainUI @@ -16,7 +17,6 @@ Item { readonly property alias sidePane: sidePane readonly property alias pageLoader: pageLoader readonly property alias pressAnimation: pressAnimation - readonly property alias debugConsole: debugConsoleLoader.item readonly property alias fullScreenPopup: fullScreenPopup SequentialAnimation { @@ -33,7 +33,6 @@ Item { (modelSources["Account"] || []).length > 0 || py.startupAnyAccountsSaved - Shortcuts { id: shortcuts } HImage { @@ -142,11 +141,6 @@ Item { } } - HLoader { - id: debugConsoleLoader - source: debugMode ? "DebugConsole.qml" : "" - } - HPopup { id: fullScreenPopup dim: false diff --git a/src/qml/utils.js b/src/qml/utils.js index 47add7ae..5410d6fc 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -41,6 +41,11 @@ function makePopup(url, parent=null, properties={}, callback=null, } +function debug(target, callback=null) { + return Utils.makeObject("DebugConsole.qml", target, { target }, callback) +} + + function isEmptyObject(obj) { return Object.entries(obj).length === 0 && obj.constructor === Object }