DebugConsole must now be created from components
Remove the default console from UI.qml and add a utils.js function to create one quickly. Using this function from the component we actually want to debug gives the console full access to that component's scope, children IDs, etc.
This commit is contained in:
parent
d20ab5a348
commit
7b482de727
|
@ -170,10 +170,8 @@ Column {
|
||||||
icon.name: "settings"
|
icon.name: "settings"
|
||||||
text: qsTr("Set as debug console target")
|
text: qsTr("Set as debug console target")
|
||||||
visible: debugMode
|
visible: debugMode
|
||||||
onTriggered: {
|
onTriggered:
|
||||||
mainUI.debugConsole.target = [eventDelegate, eventContent]
|
Utils.debug(eventDelegate, con => { con.runJS("json()") })
|
||||||
mainUI.debugConsole.runJS("t[0].json()")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@ Window {
|
||||||
property alias t: debugConsole.target
|
property alias t: debugConsole.target
|
||||||
|
|
||||||
|
|
||||||
onTargetChanged: {
|
Component.onCompleted: {
|
||||||
|
print(parent)
|
||||||
|
mainUI.shortcuts.debugConsole = debugConsole
|
||||||
commandsView.model.insert(0, {
|
commandsView.model.insert(0, {
|
||||||
input: "t = " + String(target),
|
input: "target = " + String(target),
|
||||||
output: "",
|
output: "",
|
||||||
error: false,
|
error: false,
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,7 +3,8 @@ import "Base"
|
||||||
import "utils.js" as Utils
|
import "utils.js" as Utils
|
||||||
|
|
||||||
HShortcutHandler {
|
HShortcutHandler {
|
||||||
property Item flickTarget: Item {}
|
property Item flickTarget
|
||||||
|
property DebugConsole debugConsole
|
||||||
|
|
||||||
// App
|
// App
|
||||||
|
|
||||||
|
@ -14,9 +15,9 @@ HShortcutHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
enabled: debugMode
|
enabled: debugMode && debugConsole
|
||||||
sequences: settings.keys.toggleDebugConsole
|
sequences: settings.keys.toggleDebugConsole
|
||||||
onPressed: mainUI.debugConsole.visible = ! mainUI.debugConsole.visible
|
onPressed: debugConsole.visible = ! debugConsole.visible
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
@ -27,18 +28,21 @@ HShortcutHandler {
|
||||||
// Page scrolling
|
// Page scrolling
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollUp
|
sequences: settings.keys.scrollUp
|
||||||
onPressed: Utils.smartVerticalFlick(flickTarget, -335)
|
onPressed: Utils.smartVerticalFlick(flickTarget, -335)
|
||||||
onHeld: pressed(event)
|
onHeld: pressed(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollDown
|
sequences: settings.keys.scrollDown
|
||||||
onPressed: Utils.smartVerticalFlick(flickTarget, 335)
|
onPressed: Utils.smartVerticalFlick(flickTarget, 335)
|
||||||
onHeld: pressed(event)
|
onHeld: pressed(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollPageUp
|
sequences: settings.keys.scrollPageUp
|
||||||
onPressed: Utils.smartVerticalFlick(
|
onPressed: Utils.smartVerticalFlick(
|
||||||
flickTarget, -2.3 * flickTarget.height, 8,
|
flickTarget, -2.3 * flickTarget.height, 8,
|
||||||
|
@ -49,6 +53,7 @@ HShortcutHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollPageDown
|
sequences: settings.keys.scrollPageDown
|
||||||
onPressed: Utils.smartVerticalFlick(
|
onPressed: Utils.smartVerticalFlick(
|
||||||
flickTarget, 2.3 * flickTarget.height, 8,
|
flickTarget, 2.3 * flickTarget.height, 8,
|
||||||
|
@ -58,12 +63,14 @@ HShortcutHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollToTop
|
sequences: settings.keys.scrollToTop
|
||||||
onPressed: Utils.flickToTop(flickTarget)
|
onPressed: Utils.flickToTop(flickTarget)
|
||||||
onHeld: pressed(event)
|
onHeld: pressed(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
HShortcut {
|
HShortcut {
|
||||||
|
enabled: flickTarget
|
||||||
sequences: settings.keys.scrollToBottom
|
sequences: settings.keys.scrollToBottom
|
||||||
onPressed: Utils.flickToBottom(flickTarget)
|
onPressed: Utils.flickToBottom(flickTarget)
|
||||||
onHeld: pressed(event)
|
onHeld: pressed(event)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import QtQuick.Window 2.7
|
||||||
import QtGraphicalEffects 1.12
|
import QtGraphicalEffects 1.12
|
||||||
import "Base"
|
import "Base"
|
||||||
import "SidePane"
|
import "SidePane"
|
||||||
|
import "utils.js" as Utils
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mainUI
|
id: mainUI
|
||||||
|
@ -16,7 +17,6 @@ Item {
|
||||||
readonly property alias sidePane: sidePane
|
readonly property alias sidePane: sidePane
|
||||||
readonly property alias pageLoader: pageLoader
|
readonly property alias pageLoader: pageLoader
|
||||||
readonly property alias pressAnimation: pressAnimation
|
readonly property alias pressAnimation: pressAnimation
|
||||||
readonly property alias debugConsole: debugConsoleLoader.item
|
|
||||||
readonly property alias fullScreenPopup: fullScreenPopup
|
readonly property alias fullScreenPopup: fullScreenPopup
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
|
@ -33,7 +33,6 @@ Item {
|
||||||
(modelSources["Account"] || []).length > 0 ||
|
(modelSources["Account"] || []).length > 0 ||
|
||||||
py.startupAnyAccountsSaved
|
py.startupAnyAccountsSaved
|
||||||
|
|
||||||
|
|
||||||
Shortcuts { id: shortcuts }
|
Shortcuts { id: shortcuts }
|
||||||
|
|
||||||
HImage {
|
HImage {
|
||||||
|
@ -142,11 +141,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HLoader {
|
|
||||||
id: debugConsoleLoader
|
|
||||||
source: debugMode ? "DebugConsole.qml" : ""
|
|
||||||
}
|
|
||||||
|
|
||||||
HPopup {
|
HPopup {
|
||||||
id: fullScreenPopup
|
id: fullScreenPopup
|
||||||
dim: false
|
dim: false
|
||||||
|
|
|
@ -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) {
|
function isEmptyObject(obj) {
|
||||||
return Object.entries(obj).length === 0 && obj.constructor === Object
|
return Object.entries(obj).length === 0 && obj.constructor === Object
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user