From 9a7c0c538763be31a1e53e43dad4c4443a24acb8 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Thu, 24 Mar 2022 22:08:00 +0100 Subject: [PATCH 1/5] [Mobile UI] Add TextArea for displaying debug messages This is only shown in full mobile UI builds for now, on desktop builds the desktop debug view has to be used instead. --- qml/ConfigPageDebug.qml | 27 ++++++++++++++++++++++++++- qml/Firebird/Emu/Emu.qml | 1 + qmlbridge.cpp | 2 ++ qmlbridge.h | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/qml/ConfigPageDebug.qml b/qml/ConfigPageDebug.qml index a55e8ee4..faaa0d82 100644 --- a/qml/ConfigPageDebug.qml +++ b/qml/ConfigPageDebug.qml @@ -151,7 +151,32 @@ ColumnLayout { } } - Item { + FBLabel { + text: qsTr("Debug Messages") + font.pixelSize: TextMetrics.title2Size + Layout.topMargin: 5 + Layout.bottomMargin: 5 + visible: debugMessages.visible + } + + TextArea { + id: debugMessages Layout.fillHeight: true + Layout.fillWidth: true + Layout.minimumHeight: TextMetrics.normalSize * 12 + font.pixelSize: TextMetrics.normalSize + font.family: "monospace" + readOnly: true + visible: Emu.isMobile() + + Connections { + target: Emu + // TODO: Use once QtQuick 2.7+ works + // enabled: debugMessages.visible + function onDebugStr(str) { + // if(debugMessages.visible) is false for some reason... + debugMessages.insert(debugMessages.length, str); + } + } } } diff --git a/qml/Firebird/Emu/Emu.qml b/qml/Firebird/Emu/Emu.qml index ef3d397e..3136fd87 100644 --- a/qml/Firebird/Emu/Emu.qml +++ b/qml/Firebird/Emu/Emu.qml @@ -25,4 +25,5 @@ QtObject { function setButtonState(keymap_id, down) {} function toLocalFile(url) { return url; } function basename(path) { return path; } + signal debugStr } diff --git a/qmlbridge.cpp b/qmlbridge.cpp index 2b916c31..a7bea147 100644 --- a/qmlbridge.cpp +++ b/qmlbridge.cpp @@ -430,6 +430,7 @@ void QMLBridge::setActive(bool b) connect(&emu_thread, SIGNAL(started(bool)), this, SLOT(started(bool)), Qt::QueuedConnection); connect(&emu_thread, SIGNAL(resumed(bool)), this, SLOT(resumed(bool)), Qt::QueuedConnection); connect(&emu_thread, SIGNAL(suspended(bool)), this, SLOT(suspended(bool)), Qt::QueuedConnection); + connect(&emu_thread, SIGNAL(debugStr(QString)), this, SIGNAL(debugStr(QString)), Qt::QueuedConnection); // We might have missed some events. turboModeChanged(); @@ -447,6 +448,7 @@ void QMLBridge::setActive(bool b) disconnect(&emu_thread, SIGNAL(started(bool)), this, SLOT(started(bool))); disconnect(&emu_thread, SIGNAL(resumed(bool)), this, SLOT(resumed(bool))); disconnect(&emu_thread, SIGNAL(suspended(bool)), this, SLOT(suspended(bool))); + disconnect(&emu_thread, SIGNAL(debugStr(QString)), this, SIGNAL(debugStr(QString))); } is_active = b; diff --git a/qmlbridge.h b/qmlbridge.h index 606a2ada..aafccff4 100644 --- a/qmlbridge.h +++ b/qmlbridge.h @@ -163,6 +163,8 @@ public slots: void touchpadStateChanged(qreal x, qreal y, bool contact, bool down); void buttonStateChanged(int id, bool state); + void debugStr(QString str); + /* Never called. Used as NOTIFY value for writable properties * that aren't used outside of QML. */ void neverEmitted(); From 318a33b258321724332ec258f6cdb74c29c576da Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Thu, 24 Mar 2022 22:25:01 +0100 Subject: [PATCH 2/5] WIP: Put ConfigPageDebug into a ScrollView --- qml/ConfigPageDebug.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qml/ConfigPageDebug.qml b/qml/ConfigPageDebug.qml index faaa0d82..db2c7f26 100644 --- a/qml/ConfigPageDebug.qml +++ b/qml/ConfigPageDebug.qml @@ -4,8 +4,14 @@ import QtQuick.Layouts 1.0 import Firebird.Emu 1.0 import Firebird.UIComponents 1.0 -ColumnLayout { +ScrollView { + id: sv + // TODO: Find out why this breaks on desktop + flickableItem.interactive: Emu.isMobile() + + ColumnLayout { spacing: 5 + width: sv.viewport.width FBLabel { text: qsTr("Remote GDB debugging") @@ -180,3 +186,4 @@ ColumnLayout { } } } +} From 2bf9e38659e35aebd7e91007bfcdaccdf8a5a7a9 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sun, 27 Mar 2022 21:42:18 +0200 Subject: [PATCH 3/5] WIP: Introduce a global default directory for file selection TODO: - Save as QSettings item instead? --- qml/Firebird/UIComponents/FileSelect.qml | 3 ++- qml/Firebird/UIComponents/Global.qml | 6 ++++++ qml/Firebird/UIComponents/qmldir | 1 + resources.qrc | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 qml/Firebird/UIComponents/Global.qml diff --git a/qml/Firebird/UIComponents/FileSelect.qml b/qml/Firebird/UIComponents/FileSelect.qml index 9692a728..a24a6926 100644 --- a/qml/Firebird/UIComponents/FileSelect.qml +++ b/qml/Firebird/UIComponents/FileSelect.qml @@ -18,11 +18,12 @@ RowLayout { id: dialogLoader active: false sourceComponent: FileDialog { - folder: Emu.dir(filePath) + folder: filePath ? Emu.dir(filePath) : Global.lastFileDialogDir // If save dialogs are not supported, force an open dialog selectExisting: parent.selectExisting || !Emu.saveDialogSupported() onAccepted: { filePath = Emu.toLocalFile(fileUrl); + Global.lastFileDialogDir = Emu.dir(filePath); forceRefresh++; } } diff --git a/qml/Firebird/UIComponents/Global.qml b/qml/Firebird/UIComponents/Global.qml new file mode 100644 index 00000000..77d27d71 --- /dev/null +++ b/qml/Firebird/UIComponents/Global.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property string lastFileDialogDir: "" +} diff --git a/qml/Firebird/UIComponents/qmldir b/qml/Firebird/UIComponents/qmldir index d3353c64..ce6cb841 100644 --- a/qml/Firebird/UIComponents/qmldir +++ b/qml/Firebird/UIComponents/qmldir @@ -9,3 +9,4 @@ FBLink 1.0 FBLink.qml Toast 1.0 Toast.qml VerticalSwipeBar 1.0 VerticalSwipeBar.qml singleton TextMetrics 1.0 TextMetrics.qml +singleton Global 1.0 Global.qml diff --git a/resources.qrc b/resources.qrc index 7008cea3..5ba3d243 100644 --- a/resources.qrc +++ b/resources.qrc @@ -58,6 +58,7 @@ qml/MobileUIDrawer.qml qml/DrawerButton.qml qml/Firebird/UIComponents/VerticalSwipeBar.qml + qml/Firebird/UIComponents/Global.qml qml/FlashDialog.qml qml/Firebird/UIComponents/IconButton.qml From a33cf2f8bc4d4988148e7fadd4df039c703091d0 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Tue, 12 Apr 2022 18:46:38 +0200 Subject: [PATCH 4/5] WIP: Fix TextMetrics with QtQuick 2.4+ TextMetrics conflicts with a built-in, provide it under a different name. TODO: Rename to FBTextMetrics or use "import .. as FBUI" instead. --- qml/ConfigPageDebug.qml | 28 +++++++++++++--------------- qml/Firebird/UIComponents/qmldir | 1 + 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/qml/ConfigPageDebug.qml b/qml/ConfigPageDebug.qml index db2c7f26..62d8aa0a 100644 --- a/qml/ConfigPageDebug.qml +++ b/qml/ConfigPageDebug.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.7 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import Firebird.Emu 1.0 @@ -15,7 +15,7 @@ ScrollView { FBLabel { text: qsTr("Remote GDB debugging") - font.pixelSize: TextMetrics.title2Size + font.pixelSize: TextSize.title2Size Layout.topMargin: 5 Layout.bottomMargin: 5 } @@ -24,7 +24,7 @@ ScrollView { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("If enabled, a remote GDB debugger can be connected to the port and be used for debugging.") - font.pixelSize: TextMetrics.normalSize + font.pixelSize: TextSize.normalSize } RowLayout { @@ -47,7 +47,7 @@ ScrollView { SpinBox { id: gdbPort - Layout.maximumWidth: TextMetrics.normalSize * 8 + Layout.maximumWidth: TextSize.normalSize * 8 minimumValue: 1 maximumValue: 65535 @@ -64,7 +64,7 @@ ScrollView { Layout.fillWidth: true text: qsTr("Remote access to internal debugger") wrapMode: Text.WordWrap - font.pixelSize: TextMetrics.title2Size + font.pixelSize: TextSize.title2Size Layout.topMargin: 10 Layout.bottomMargin: 5 } @@ -73,7 +73,7 @@ ScrollView { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("Enable this to access the internal debugger via TCP (telnet/netcat), like for firebird-send.") - font.pixelSize: TextMetrics.normalSize + font.pixelSize: TextSize.normalSize } RowLayout { @@ -95,7 +95,7 @@ ScrollView { SpinBox { id: rdbPort - Layout.maximumWidth: TextMetrics.normalSize * 8 + Layout.maximumWidth: TextSize.normalSize * 8 minimumValue: 1 maximumValue: 65535 @@ -110,7 +110,7 @@ ScrollView { FBLabel { text: qsTr("Enter into Debugger") - font.pixelSize: TextMetrics.title2Size + font.pixelSize: TextSize.title2Size Layout.topMargin: 5 Layout.bottomMargin: 5 } @@ -119,7 +119,7 @@ ScrollView { Layout.fillWidth: true wrapMode: Text.WordWrap text: qsTr("Configure which situations cause the emulator to trap into the debugger.") - font.pixelSize: TextMetrics.normalSize + font.pixelSize: TextSize.normalSize } CheckBox { @@ -159,7 +159,7 @@ ScrollView { FBLabel { text: qsTr("Debug Messages") - font.pixelSize: TextMetrics.title2Size + font.pixelSize: TextSize.title2Size Layout.topMargin: 5 Layout.bottomMargin: 5 visible: debugMessages.visible @@ -169,18 +169,16 @@ ScrollView { id: debugMessages Layout.fillHeight: true Layout.fillWidth: true - Layout.minimumHeight: TextMetrics.normalSize * 12 - font.pixelSize: TextMetrics.normalSize + Layout.minimumHeight: TextSize.normalSize * 12 + font.pixelSize: TextSize.normalSize font.family: "monospace" readOnly: true visible: Emu.isMobile() Connections { target: Emu - // TODO: Use once QtQuick 2.7+ works - // enabled: debugMessages.visible + enabled: debugMessages.visible function onDebugStr(str) { - // if(debugMessages.visible) is false for some reason... debugMessages.insert(debugMessages.length, str); } } diff --git a/qml/Firebird/UIComponents/qmldir b/qml/Firebird/UIComponents/qmldir index ce6cb841..e6c1d0e9 100644 --- a/qml/Firebird/UIComponents/qmldir +++ b/qml/Firebird/UIComponents/qmldir @@ -9,4 +9,5 @@ FBLink 1.0 FBLink.qml Toast 1.0 Toast.qml VerticalSwipeBar 1.0 VerticalSwipeBar.qml singleton TextMetrics 1.0 TextMetrics.qml +singleton TextSize 1.0 TextMetrics.qml singleton Global 1.0 Global.qml From 13df5b8f7fa2e84ea85c25a45aee897613fa88f9 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sun, 17 Apr 2022 19:52:42 +0200 Subject: [PATCH 5/5] WIP: Show default kit in drawer button TODO: - Make prettier - Refresh on name changes --- qml/DrawerButton.qml | 34 +++++++++++++++++++++++++--------- qml/MobileUIDrawer.qml | 1 + 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/qml/DrawerButton.qml b/qml/DrawerButton.qml index 7dc64c35..ff405f69 100644 --- a/qml/DrawerButton.qml +++ b/qml/DrawerButton.qml @@ -6,6 +6,7 @@ import Firebird.UIComponents 1.0 Rectangle { property alias icon: image.source property alias title: label.text + property alias subtitle: subtitleLabel.text property alias borderTopVisible: borderTop.visible property alias borderBottomVisible: borderBottom.visible property bool disabled: false @@ -76,19 +77,34 @@ Rectangle { fillMode: Image.PreserveAspectFit } - FBLabel { - id: label - - color: "black" - - x: image.x + image.width + spacing - + ColumnLayout { anchors { + margins: spacing + left: image.right top: parent.top bottom: parent.bottom + right: parent.right } - font.pixelSize: TextMetrics.title2Size - verticalAlignment: Text.AlignVCenter + FBLabel { + id: label + + color: "black" + + font.pixelSize: TextMetrics.title2Size + verticalAlignment: Text.AlignVCenter + Layout.fillWidth: true + Layout.fillHeight: true + } + + FBLabel { + id: subtitleLabel + elide: "ElideRight" + + font.pixelSize: TextMetrics.normalSize * 0.8 + Layout.fillWidth: true + Layout.fillHeight: true + visible: text !== "" + } } } diff --git a/qml/MobileUIDrawer.qml b/qml/MobileUIDrawer.qml index bde2437c..85ad7982 100644 --- a/qml/MobileUIDrawer.qml +++ b/qml/MobileUIDrawer.qml @@ -40,6 +40,7 @@ Rectangle { id: restartButton title: qsTr("Start") + subtitle: qsTr("Kit: ") + Emu.kits.getDataRow(Emu.kitIndexForID(Emu.defaultKit), KitModel.NameRole) icon: "qrc:/icons/resources/icons/edit-bomb.png" onClicked: {