From 8da5ef9f290713b74f34b3280b1d1b0003f41074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Sun, 1 Dec 2024 17:38:57 -0400 Subject: [PATCH] [Merge] Revert to the way of doing screen projections in v1.1 This earlier way of doing things isn't incompatible with Qt 6. Let's use it as means to have the feature until a better solution is found. Merges 4dc5b074ef2c774977049fa0fe46466571638a27 --- src/kirigami_ui/+android/main.qml | 14 ++-- src/kirigami_ui/+windows/main.qml | 29 ++++--- src/kirigami_ui/PrompterPage.qml | 3 +- src/kirigami_ui/main.qml | 29 ++++--- src/main.cpp | 112 ++++++++++++---------------- src/prompter/ProjectionsManager.qml | 42 ++++++----- src/prompter/PrompterView.qml | 9 --- 7 files changed, 106 insertions(+), 132 deletions(-) diff --git a/src/kirigami_ui/+android/main.qml b/src/kirigami_ui/+android/main.qml index 773e1fa0..b5e2d383 100644 --- a/src/kirigami_ui/+android/main.qml +++ b/src/kirigami_ui/+android/main.qml @@ -302,13 +302,13 @@ Kirigami.ApplicationWindow { } Kirigami.Action { text: i18nc("Main menu actions. Enters Performance tweaks submenu.", "Performance tweaks") - // Kirigami.Action { - // text: i18nc("Main menu actions", "Disable screen projections") - // enabled: !checked - // checkable: true - // checked: !projectionManager.isEnabled - // onTriggered: projectionManager.toggle() - // } + Kirigami.Action { + text: i18nc("Main menu actions", "Disable screen projections") + enabled: !checked + checkable: true + checked: !projectionManager.isEnabled + onTriggered: projectionManager.toggle() + } Kirigami.Action { text: i18nc("Main menu actions", "Disable timers") enabled: !checked diff --git a/src/kirigami_ui/+windows/main.qml b/src/kirigami_ui/+windows/main.qml index abd11aa7..c18640c5 100644 --- a/src/kirigami_ui/+windows/main.qml +++ b/src/kirigami_ui/+windows/main.qml @@ -330,13 +330,13 @@ Kirigami.ApplicationWindow { } Kirigami.Action { text: i18nc("Main menu actions. Enters Performance tweaks submenu.", "Performance tweaks") - // Kirigami.Action { - // text: i18nc("Main menu actions", "Disable screen projections") - // enabled: !checked - // checkable: true - // checked: !projectionManager.isEnabled - // onTriggered: projectionManager.toggle() - // } + Kirigami.Action { + text: i18nc("Main menu actions", "Disable screen projections") + enabled: !checked + checkable: true + checked: !projectionManager.isEnabled + onTriggered: projectionManager.toggle() + } Kirigami.Action { text: i18nc("Main menu actions", "Disable timers") enabled: !checked @@ -661,15 +661,12 @@ Kirigami.ApplicationWindow { // Thus runs from here because there's no event that occurs on each bit of scroll, and this takes much less CPU than a timer, is more precise and scales better. root.pageStack.currentItem.prompter.markerCompare(); // Update Projections - if (projectionManager.isEnabled/* && projectionManager.model.count*/) - // Recount projections on each for loop iteration to prevent value from going stale because a window was closed from a different thread. - for (var i=0; i #endif -// #if defined(Q_OS_MACOS) -// #include <../3rdparty/KDMacTouchBar/src/kdmactouchbar.h> -// #endif +#if defined(Q_OS_MACOS) +#include <../3rdparty/KDMacTouchBar/src/kdmactouchbar.h> +#endif #include "../qprompt_version.h" #include "abstractunits.hpp" @@ -72,25 +72,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) qputenv("QT_QUICK_CONTROLS_STYLE", QByteArray("Material")); qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", QByteArray("Dark")); qputenv("QT_QUICK_CONTROLS_MATERIAL_ACCENT", QByteArray("#3daee9")); - - // Initialize app metadata - QCoreApplication::setOrganizationName(QString::fromUtf8("Cuperino")); - QCoreApplication::setOrganizationDomain(QString::fromUtf8(QPROMPT_URI)); - QCoreApplication::setApplicationName(QString::fromUtf8("QPrompt")); - - // Acquire saved settings - QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName().toLower()); - - // The following code forces the use of a specific language. - QString language = settings.value("ui/language", "").toString(); - if (!language.isEmpty()) { - auto langCode = language.append(".UTF-8").toStdString(); - qDebug() << langCode; - qputenv("LANGUAGE", langCode); - qputenv("LC_ALL", langCode); - qputenv("LANG", langCode); - } - // Instantiate app #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -100,10 +81,11 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) #else QApplication app(argc, argv); #endif - - // Initialize i18n metadata + // Initialize app metadata KLocalizedString::setApplicationDomain("qprompt"); - + QCoreApplication::setOrganizationName(QString::fromUtf8("Cuperino")); + QCoreApplication::setOrganizationDomain(QString::fromUtf8(QPROMPT_URI)); + QCoreApplication::setApplicationName(QString::fromUtf8("QPrompt")); // Parse command line arguments QCommandLineParser parser; parser.setApplicationDescription( @@ -121,6 +103,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) if (positionalArguments.length()) fileToOpen = parser.positionalArguments().at(0); + // Acquire saved settings + QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName().toLower()); + // Substract from 2 because order in app is intentionally inverted from order in Qt app.setLayoutDirection(static_cast(2 - settings.value("ui/layout", 0).toInt())); @@ -181,43 +166,43 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) // KirigamiPlugin::getInstance().registerTypes(); // #endif -// #if defined(Q_OS_MACOS) -// // Enable automatic display of dialog prompts on the touchbar. -// KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(true); -// // // Create touchbar for use through all of QPrompt's execusion -// // KDMacTouchBar *touchBar = new KDMacTouchBar(); -// // //QMainWindow *mainWindow = nullptr; -// // //foreach(QWidget *widget, app.topLevelWidgets()) -// // // if(widget->inherits("QMainWindow")) { -// // // mainWindow = qobject_cast(widget); -// // // break; -// // // }; -// // //KDMacTouchBar *touchBar = new KDMacTouchBar(mainWindow); -// // // Toggle teleprompter state -// // QIcon qpromptIcon(QStringLiteral(":images/qprompt")); -// // QAction *action = new QAction(qpromptIcon, "Toggle"); -// // touchBar->addAction(action); -// // // connect(action, &QAction::triggered, this, &MainWindow::activated); -// // touchBar->addSeparator(); -// // // Velocity and placement toachbar controls -// // touchBar->setTouchButtonStyle(KDMacTouchBar::IconOnly); -// // // Up -// // QIcon upIcon(QStringLiteral(":icons/go-previous")); -// // QAction *reduceAction = new QAction(upIcon, "Reduce"); -// // touchBar->addAction(reduceAction); -// // touchBar->setPrincipialAction(reduceAction); -// // // connect(reduceAction, &QAction::triggered, this, &MainWindow::activated); -// // // Down -// // QIcon downIcon(QStringLiteral(":icons/go-next")); -// // QAction *increaseAction = new QAction(downIcon, "Increase"); -// // touchBar->addAction(increaseAction); -// // // connect(increaseAction, &QAction::triggered, this, &MainWindow::activated); -// //// touchBar->addSeparator(); -// //// // Stop prompter -// //// QAction *stopAction = new QAction(upIcon, "Stop"); -// //// touchBar->addAction(stopAction); -// //// // connect(stopAction, &QAction::triggered, this, &MainWindow::activated); -// #endif +#if defined(Q_OS_MACOS) + // Enable automatic display of dialog prompts on the touchbar. + KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(true); +// // Create touchbar for use through all of QPrompt's execusion +// KDMacTouchBar *touchBar = new KDMacTouchBar(); +// //QMainWindow *mainWindow = nullptr; +// //foreach(QWidget *widget, app.topLevelWidgets()) +// // if(widget->inherits("QMainWindow")) { +// // mainWindow = qobject_cast(widget); +// // break; +// // }; +// //KDMacTouchBar *touchBar = new KDMacTouchBar(mainWindow); +// // Toggle teleprompter state +// QIcon qpromptIcon(QStringLiteral(":images/qprompt")); +// QAction *action = new QAction(qpromptIcon, "Toggle"); +// touchBar->addAction(action); +// // connect(action, &QAction::triggered, this, &MainWindow::activated); +// touchBar->addSeparator(); +// // Velocity and placement toachbar controls +// touchBar->setTouchButtonStyle(KDMacTouchBar::IconOnly); +// // Up +// QIcon upIcon(QStringLiteral(":icons/go-previous")); +// QAction *reduceAction = new QAction(upIcon, "Reduce"); +// touchBar->addAction(reduceAction); +// touchBar->setPrincipialAction(reduceAction); +// // connect(reduceAction, &QAction::triggered, this, &MainWindow::activated); +// // Down +// QIcon downIcon(QStringLiteral(":icons/go-next")); +// QAction *increaseAction = new QAction(downIcon, "Increase"); +// touchBar->addAction(increaseAction); +// // connect(increaseAction, &QAction::triggered, this, &MainWindow::activated); +//// touchBar->addSeparator(); +//// // Stop prompter +//// QAction *stopAction = new QAction(upIcon, "Stop"); +//// touchBar->addAction(stopAction); +//// // connect(stopAction, &QAction::triggered, this, &MainWindow::activated); +#endif #if defined(QHotkey_FOUND) // Toggle transparency of all windows @@ -252,9 +237,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) engine.addImportPath(QStringLiteral("../../lib/qml/")); engine.addImportPath(QStringLiteral("../lib/qml/")); engine.addImportPath(QStringLiteral("./lib/qml/")); - engine.addImportPath(QStringLiteral("../../../install/lib/qml/")); - engine.addImportPath(QStringLiteral("../../install/lib/qml/")); - engine.addImportPath(QStringLiteral("./../install/lib/qml/")); // MacOS paths engine.addImportPath(QStringLiteral("../build/")); engine.addImportPath(QStringLiteral("../Resources/qml/")); diff --git a/src/prompter/ProjectionsManager.qml b/src/prompter/ProjectionsManager.qml index 68b3cb4a..445812a7 100644 --- a/src/prompter/ProjectionsManager.qml +++ b/src/prompter/ProjectionsManager.qml @@ -41,7 +41,8 @@ Item { property bool isEnabled: false property string screensStringified: "" required property var forwardTo // prompter - property bool projectionRestartPrompt: true + property bool projectionRestartPrompt: false + // property bool projectionRestartPrompt: true property int projectionRestartModulus: 1 function toggle() { @@ -50,17 +51,17 @@ Item { closeAll(); projectionSettings.sync(); - // If it was initially off, prompt to restart each time it's turned on. - // If initially on and turning off, don't prompt to restart more than once. - if (projectionRestartModulus % 2) { - if (projectionRestartPrompt) - restartDialog.visible = true; - if (!isEnabled && projectionRestartPrompt) - projectionRestartPrompt = false; - projectionRestartModulus = 0; - } - else - projectionRestartModulus++; + // // If it was initially off, prompt to restart each time it's turned on. + // // If initially on and turning off, don't prompt to restart more than once. + // if (projectionRestartModulus % 2) { + // if (projectionRestartPrompt) + // restartDialog.visible = true; + // if (!isEnabled && projectionRestartPrompt) + // projectionRestartPrompt = false; + // projectionRestartModulus = 0; + // } + // else + // projectionRestartModulus++; } function getDisplayFlip(screenName, flipSetting) { const totalDisplays = displayModel.count; @@ -274,19 +275,26 @@ Item { opacity: 0.6 } // The actual projection - ShaderEffect { + Image { id: img - property variant source: projectionManager.forwardTo + // property variant source: projectionManager.forwardTo + source: model.flip ? model.p : false + // Keep loading asynchronous. Improve responsiveness of main thread. + asynchronous: true + // Cache image if it's not being re-scaled so it could be used on n projection without much additional cost. + cache: !reScale + // Mirror Horizontally: Save time by mirroring image on copy instead of flipping the result + mirror: model.flip===2 || model.flip===4 + // Keep image vertically centered relative to the window's MouseArea, which fills the window. anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter width: reScale ? parent.width : projectionManager.forwardTo.width height: reScale ? (parent.width / projectionManager.forwardTo.width) * projectionManager.forwardTo.height : projectionManager.forwardTo.height - blending: false transform: Scale { origin.y: img.height/2 yScale: model.flip===3 || model.flip===4 ? -1 : 1 - origin.x: img.width/2 - xScale: model.flip===2 || model.flip===4 ? -1 : 1 + // origin.x: img.width/2 + // xScale: model.flip===2 || model.flip===4 ? -1 : 1 } Rectangle { color: "#000000" diff --git a/src/prompter/PrompterView.qml b/src/prompter/PrompterView.qml index 6dc8b86b..6dcef621 100644 --- a/src/prompter/PrompterView.qml +++ b/src/prompter/PrompterView.qml @@ -42,15 +42,6 @@ Item { property real __baseSpeed: editorToolbar.baseSpeedSlider.value property real __curvature: editorToolbar.baseAccelerationSlider.value - //layer.enabled: true - // Undersample - //layer.mipmap: true - // Oversample - //layer.samples: 2 - //layer.smooth: true - // Make texture the size of the largest destinations. - //layer.textureSize: Qt.size(projectionWindow.width, projectionWindow.height) - transform: Rotation { origin.x: (forcedOrientation && forcedOrientation!==3 ? parent.height/2 : parent.width*0.15); origin.y: (forcedOrientation && forcedOrientation!==3 ? parent.width/2 : parent.height);