From d6364ce76607d699132048f4b880bb66a0c97070 Mon Sep 17 00:00:00 2001 From: namedkitten Date: Thu, 14 May 2020 11:51:51 +0100 Subject: [PATCH] Add debug dialog and configurable window height/width --- src/qml/Dialogs/DebugDialog.qml | 77 +++++++++++++++++++++++++++++++++ src/qml/main.qml | 11 ++++- src/qml/qml.qrc | 1 + version | 2 +- 4 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 src/qml/Dialogs/DebugDialog.qml diff --git a/src/qml/Dialogs/DebugDialog.qml b/src/qml/Dialogs/DebugDialog.qml new file mode 100644 index 0000000..fd63145 --- /dev/null +++ b/src/qml/Dialogs/DebugDialog.qml @@ -0,0 +1,77 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.3 +import QtQuick.Dialogs 1.3 +import QtQuick.Window 2.2 +import player 1.0 + +Dialog { + id: debugDialog + title: "Debug" + height: 480 + width: 720 + modality: Qt.NonModal + standardButtons: Dialog.NoButton + + Component { + id: delegate + Item { + width: 200; height: 30 + Label { + text: theOutput + } + } + } + + ListModel { + id: modelly + } + + ListView { + id: output + model: modelly + delegate: delegate + height: 50 + width: parent.width + anchors { + top: parent.top + bottom: input.top + left: parent.left + right: parent.right + } + } + + + TextField { + id: input + width: parent.width + height: 40 + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + } + text: "h" + function doJsEval() { + var output; + try { + let result = eval(input.text) + output = result instanceof Array ? "[" + String(result) + "]" : String(result) + modelly.append({theOutput: output}) + } catch (e) { + output = String(e) + modelly.append({theOutput: output}) + } + } + + Keys.onReturnPressed: { + doJsEval() + event.accepted = true + } + } + Action { + shortcut: "Ctrl+Shift+i" + onTriggered: { + debugDialog.open() + } + } +} diff --git a/src/qml/main.qml b/src/qml/main.qml index bb00c86..ec07e3e 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -8,13 +8,18 @@ Window { id: mainWindow title: "KittehPlayer" visible: true - width: Math.min(720, Screen.width) - height: Math.min(480, Screen.height) + width: Math.min(appearance.defaultWidth, Screen.width) + height: Math.min(appearance.defaultHeight, Screen.height) property bool controlsShowing: true property int virtualHeight: Screen.height * appearance.scaleFactor property int virtualWidth: Screen.width * appearance.scaleFactor property bool onTop: false + DebugDialog { + + } + + QMLDebugger { id: qmlDebugger } @@ -66,6 +71,8 @@ Window { property string fontName: "Roboto" property double scaleFactor: 1.0 property int subtitlesFontSize: 24 + property int defaultHeight: 405 + property int defaultWidth: 720 property int uiFadeTimer: 1000 property bool doubleTapToSeek: true property double doubleTapToSeekBy: 5 diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index f3e0072..3ed79dc 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -35,6 +35,7 @@ Dialogs/SettingsDialog.qml Dialogs/SettingsItems/LanguageSettings.qml Dialogs/PlaylistDialog.qml + Dialogs/DebugDialog.qml icons/YouTube/play.svg icons/YouTube/pause.svg icons/YouTube/forward.svg diff --git a/version b/version index 9d60796..3cacc0b 100644 --- a/version +++ b/version @@ -1 +1 @@ -11 \ No newline at end of file +12 \ No newline at end of file