Skip to content

Commit 8da5ef9

Browse files
committed
[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 4dc5b07
1 parent 04d01bd commit 8da5ef9

File tree

7 files changed

+106
-132
lines changed

7 files changed

+106
-132
lines changed

src/kirigami_ui/+android/main.qml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,13 @@ Kirigami.ApplicationWindow {
302302
}
303303
Kirigami.Action {
304304
text: i18nc("Main menu actions. Enters Performance tweaks submenu.", "Performance tweaks")
305-
// Kirigami.Action {
306-
// text: i18nc("Main menu actions", "Disable screen projections")
307-
// enabled: !checked
308-
// checkable: true
309-
// checked: !projectionManager.isEnabled
310-
// onTriggered: projectionManager.toggle()
311-
// }
305+
Kirigami.Action {
306+
text: i18nc("Main menu actions", "Disable screen projections")
307+
enabled: !checked
308+
checkable: true
309+
checked: !projectionManager.isEnabled
310+
onTriggered: projectionManager.toggle()
311+
}
312312
Kirigami.Action {
313313
text: i18nc("Main menu actions", "Disable timers")
314314
enabled: !checked

src/kirigami_ui/+windows/main.qml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,13 @@ Kirigami.ApplicationWindow {
330330
}
331331
Kirigami.Action {
332332
text: i18nc("Main menu actions. Enters Performance tweaks submenu.", "Performance tweaks")
333-
// Kirigami.Action {
334-
// text: i18nc("Main menu actions", "Disable screen projections")
335-
// enabled: !checked
336-
// checkable: true
337-
// checked: !projectionManager.isEnabled
338-
// onTriggered: projectionManager.toggle()
339-
// }
333+
Kirigami.Action {
334+
text: i18nc("Main menu actions", "Disable screen projections")
335+
enabled: !checked
336+
checkable: true
337+
checked: !projectionManager.isEnabled
338+
onTriggered: projectionManager.toggle()
339+
}
340340
Kirigami.Action {
341341
text: i18nc("Main menu actions", "Disable timers")
342342
enabled: !checked
@@ -661,15 +661,12 @@ Kirigami.ApplicationWindow {
661661
// 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.
662662
root.pageStack.currentItem.prompter.markerCompare();
663663
// Update Projections
664-
if (projectionManager.isEnabled/* && projectionManager.model.count*/)
665-
// Recount projections on each for loop iteration to prevent value from going stale because a window was closed from a different thread.
666-
for (var i=0; i<projectionManager.projections.count; i++) {
667-
const w = projectionManager.projections.objectAt(i);
668-
if (w!==null && root.visible)
669-
w.update();
670-
else
671-
break;
672-
}
664+
if (projectionManager.isEnabled)
665+
root.pageStack.currentItem.viewport.grabToImage(function(p) {
666+
// Recount projections on each for loop iteration to prevent value from going stale because a window was closed from a different thread.
667+
for (var i=0; i<projectionManager.projections.count; i++)
668+
projectionManager.model.setProperty(i, "p", String(p.url));
669+
});
673670
}
674671

675672
ProjectionsManager {

src/kirigami_ui/PrompterPage.qml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ Kirigami.Page {
614614
},
615615
Kirigami.Action {
616616
id: displaySettings
617-
visible: false
618-
// visible: (!Kirigami.Settings.isMobile || Qt.platform.os==='linux') && Qt.platform.os!=='haiku'
617+
visible: (!Kirigami.Settings.isMobile || Qt.platform.os==='linux') && Qt.platform.os!=='haiku'
619618
text: i18nc("Screens refers to computer displays", "Screens")
620619

621620
Kirigami.Action {

src/kirigami_ui/main.qml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,13 @@ Kirigami.ApplicationWindow {
330330
}
331331
Kirigami.Action {
332332
text: i18nc("Main menu actions. Enters Performance tweaks submenu.", "Performance tweaks")
333-
// Kirigami.Action {
334-
// text: i18nc("Main menu actions", "Disable screen projections")
335-
// enabled: !checked
336-
// checkable: true
337-
// checked: !projectionManager.isEnabled
338-
// onTriggered: projectionManager.toggle()
339-
// }
333+
Kirigami.Action {
334+
text: i18nc("Main menu actions", "Disable screen projections")
335+
enabled: !checked
336+
checkable: true
337+
checked: !projectionManager.isEnabled
338+
onTriggered: projectionManager.toggle()
339+
}
340340
Kirigami.Action {
341341
text: i18nc("Main menu actions", "Disable timers")
342342
enabled: !checked
@@ -962,15 +962,12 @@ Kirigami.ApplicationWindow {
962962
// 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.
963963
root.pageStack.currentItem.prompter.markerCompare();
964964
// Update Projections
965-
if (projectionManager.isEnabled/* && projectionManager.model.count*/)
966-
// Recount projections on each for loop iteration to prevent value from going stale because a window was closed from a different thread.
967-
for (var i=0; i<projectionManager.projections.count; i++) {
968-
const w = projectionManager.projections.objectAt(i);
969-
if (w!==null && root.visible)
970-
w.update();
971-
else
972-
break;
973-
}
965+
if (projectionManager.isEnabled)
966+
root.pageStack.currentItem.viewport.grabToImage(function(p) {
967+
// Recount projections on each for loop iteration to prevent value from going stale because a window was closed from a different thread.
968+
for (var i=0; i<projectionManager.projections.count; i++)
969+
projectionManager.model.setProperty(i, "p", String(p.url));
970+
});
974971
}
975972

976973
ProjectionsManager {

src/main.cpp

Lines changed: 47 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
#include <QHotkey>
5555
#endif
5656

57-
// #if defined(Q_OS_MACOS)
58-
// #include <../3rdparty/KDMacTouchBar/src/kdmactouchbar.h>
59-
// #endif
57+
#if defined(Q_OS_MACOS)
58+
#include <../3rdparty/KDMacTouchBar/src/kdmactouchbar.h>
59+
#endif
6060

6161
#include "../qprompt_version.h"
6262
#include "abstractunits.hpp"
@@ -72,25 +72,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
7272
qputenv("QT_QUICK_CONTROLS_STYLE", QByteArray("Material"));
7373
qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", QByteArray("Dark"));
7474
qputenv("QT_QUICK_CONTROLS_MATERIAL_ACCENT", QByteArray("#3daee9"));
75-
76-
// Initialize app metadata
77-
QCoreApplication::setOrganizationName(QString::fromUtf8("Cuperino"));
78-
QCoreApplication::setOrganizationDomain(QString::fromUtf8(QPROMPT_URI));
79-
QCoreApplication::setApplicationName(QString::fromUtf8("QPrompt"));
80-
81-
// Acquire saved settings
82-
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName().toLower());
83-
84-
// The following code forces the use of a specific language.
85-
QString language = settings.value("ui/language", "").toString();
86-
if (!language.isEmpty()) {
87-
auto langCode = language.append(".UTF-8").toStdString();
88-
qDebug() << langCode;
89-
qputenv("LANGUAGE", langCode);
90-
qputenv("LC_ALL", langCode);
91-
qputenv("LANG", langCode);
92-
}
93-
9475
// Instantiate app
9576
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
9677
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@@ -100,10 +81,11 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
10081
#else
10182
QApplication app(argc, argv);
10283
#endif
103-
104-
// Initialize i18n metadata
84+
// Initialize app metadata
10585
KLocalizedString::setApplicationDomain("qprompt");
106-
86+
QCoreApplication::setOrganizationName(QString::fromUtf8("Cuperino"));
87+
QCoreApplication::setOrganizationDomain(QString::fromUtf8(QPROMPT_URI));
88+
QCoreApplication::setApplicationName(QString::fromUtf8("QPrompt"));
10789
// Parse command line arguments
10890
QCommandLineParser parser;
10991
parser.setApplicationDescription(
@@ -121,6 +103,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
121103
if (positionalArguments.length())
122104
fileToOpen = parser.positionalArguments().at(0);
123105

106+
// Acquire saved settings
107+
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName().toLower());
108+
124109
// Substract from 2 because order in app is intentionally inverted from order in Qt
125110
app.setLayoutDirection(static_cast<Qt::LayoutDirection>(2 - settings.value("ui/layout", 0).toInt()));
126111

@@ -181,43 +166,43 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
181166
// KirigamiPlugin::getInstance().registerTypes();
182167
// #endif
183168

184-
// #if defined(Q_OS_MACOS)
185-
// // Enable automatic display of dialog prompts on the touchbar.
186-
// KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(true);
187-
// // // Create touchbar for use through all of QPrompt's execusion
188-
// // KDMacTouchBar *touchBar = new KDMacTouchBar();
189-
// // //QMainWindow *mainWindow = nullptr;
190-
// // //foreach(QWidget *widget, app.topLevelWidgets())
191-
// // // if(widget->inherits("QMainWindow")) {
192-
// // // mainWindow = qobject_cast<QMainWindow *>(widget);
193-
// // // break;
194-
// // // };
195-
// // //KDMacTouchBar *touchBar = new KDMacTouchBar(mainWindow);
196-
// // // Toggle teleprompter state
197-
// // QIcon qpromptIcon(QStringLiteral(":images/qprompt"));
198-
// // QAction *action = new QAction(qpromptIcon, "Toggle");
199-
// // touchBar->addAction(action);
200-
// // // connect(action, &QAction::triggered, this, &MainWindow::activated);
201-
// // touchBar->addSeparator();
202-
// // // Velocity and placement toachbar controls
203-
// // touchBar->setTouchButtonStyle(KDMacTouchBar::IconOnly);
204-
// // // Up
205-
// // QIcon upIcon(QStringLiteral(":icons/go-previous"));
206-
// // QAction *reduceAction = new QAction(upIcon, "Reduce");
207-
// // touchBar->addAction(reduceAction);
208-
// // touchBar->setPrincipialAction(reduceAction);
209-
// // // connect(reduceAction, &QAction::triggered, this, &MainWindow::activated);
210-
// // // Down
211-
// // QIcon downIcon(QStringLiteral(":icons/go-next"));
212-
// // QAction *increaseAction = new QAction(downIcon, "Increase");
213-
// // touchBar->addAction(increaseAction);
214-
// // // connect(increaseAction, &QAction::triggered, this, &MainWindow::activated);
215-
// //// touchBar->addSeparator();
216-
// //// // Stop prompter
217-
// //// QAction *stopAction = new QAction(upIcon, "Stop");
218-
// //// touchBar->addAction(stopAction);
219-
// //// // connect(stopAction, &QAction::triggered, this, &MainWindow::activated);
220-
// #endif
169+
#if defined(Q_OS_MACOS)
170+
// Enable automatic display of dialog prompts on the touchbar.
171+
KDMacTouchBar::setAutomaticallyCreateMessageBoxTouchBar(true);
172+
// // Create touchbar for use through all of QPrompt's execusion
173+
// KDMacTouchBar *touchBar = new KDMacTouchBar();
174+
// //QMainWindow *mainWindow = nullptr;
175+
// //foreach(QWidget *widget, app.topLevelWidgets())
176+
// // if(widget->inherits("QMainWindow")) {
177+
// // mainWindow = qobject_cast<QMainWindow *>(widget);
178+
// // break;
179+
// // };
180+
// //KDMacTouchBar *touchBar = new KDMacTouchBar(mainWindow);
181+
// // Toggle teleprompter state
182+
// QIcon qpromptIcon(QStringLiteral(":images/qprompt"));
183+
// QAction *action = new QAction(qpromptIcon, "Toggle");
184+
// touchBar->addAction(action);
185+
// // connect(action, &QAction::triggered, this, &MainWindow::activated);
186+
// touchBar->addSeparator();
187+
// // Velocity and placement toachbar controls
188+
// touchBar->setTouchButtonStyle(KDMacTouchBar::IconOnly);
189+
// // Up
190+
// QIcon upIcon(QStringLiteral(":icons/go-previous"));
191+
// QAction *reduceAction = new QAction(upIcon, "Reduce");
192+
// touchBar->addAction(reduceAction);
193+
// touchBar->setPrincipialAction(reduceAction);
194+
// // connect(reduceAction, &QAction::triggered, this, &MainWindow::activated);
195+
// // Down
196+
// QIcon downIcon(QStringLiteral(":icons/go-next"));
197+
// QAction *increaseAction = new QAction(downIcon, "Increase");
198+
// touchBar->addAction(increaseAction);
199+
// // connect(increaseAction, &QAction::triggered, this, &MainWindow::activated);
200+
//// touchBar->addSeparator();
201+
//// // Stop prompter
202+
//// QAction *stopAction = new QAction(upIcon, "Stop");
203+
//// touchBar->addAction(stopAction);
204+
//// // connect(stopAction, &QAction::triggered, this, &MainWindow::activated);
205+
#endif
221206

222207
#if defined(QHotkey_FOUND)
223208
// Toggle transparency of all windows
@@ -252,9 +237,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
252237
engine.addImportPath(QStringLiteral("../../lib/qml/"));
253238
engine.addImportPath(QStringLiteral("../lib/qml/"));
254239
engine.addImportPath(QStringLiteral("./lib/qml/"));
255-
engine.addImportPath(QStringLiteral("../../../install/lib/qml/"));
256-
engine.addImportPath(QStringLiteral("../../install/lib/qml/"));
257-
engine.addImportPath(QStringLiteral("./../install/lib/qml/"));
258240
// MacOS paths
259241
engine.addImportPath(QStringLiteral("../build/"));
260242
engine.addImportPath(QStringLiteral("../Resources/qml/"));

src/prompter/ProjectionsManager.qml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Item {
4141
property bool isEnabled: false
4242
property string screensStringified: ""
4343
required property var forwardTo // prompter
44-
property bool projectionRestartPrompt: true
44+
property bool projectionRestartPrompt: false
45+
// property bool projectionRestartPrompt: true
4546
property int projectionRestartModulus: 1
4647

4748
function toggle() {
@@ -50,17 +51,17 @@ Item {
5051
closeAll();
5152
projectionSettings.sync();
5253

53-
// If it was initially off, prompt to restart each time it's turned on.
54-
// If initially on and turning off, don't prompt to restart more than once.
55-
if (projectionRestartModulus % 2) {
56-
if (projectionRestartPrompt)
57-
restartDialog.visible = true;
58-
if (!isEnabled && projectionRestartPrompt)
59-
projectionRestartPrompt = false;
60-
projectionRestartModulus = 0;
61-
}
62-
else
63-
projectionRestartModulus++;
54+
// // If it was initially off, prompt to restart each time it's turned on.
55+
// // If initially on and turning off, don't prompt to restart more than once.
56+
// if (projectionRestartModulus % 2) {
57+
// if (projectionRestartPrompt)
58+
// restartDialog.visible = true;
59+
// if (!isEnabled && projectionRestartPrompt)
60+
// projectionRestartPrompt = false;
61+
// projectionRestartModulus = 0;
62+
// }
63+
// else
64+
// projectionRestartModulus++;
6465
}
6566
function getDisplayFlip(screenName, flipSetting) {
6667
const totalDisplays = displayModel.count;
@@ -274,19 +275,26 @@ Item {
274275
opacity: 0.6
275276
}
276277
// The actual projection
277-
ShaderEffect {
278+
Image {
278279
id: img
279-
property variant source: projectionManager.forwardTo
280+
// property variant source: projectionManager.forwardTo
281+
source: model.flip ? model.p : false
282+
// Keep loading asynchronous. Improve responsiveness of main thread.
283+
asynchronous: true
284+
// Cache image if it's not being re-scaled so it could be used on n projection without much additional cost.
285+
cache: !reScale
286+
// Mirror Horizontally: Save time by mirroring image on copy instead of flipping the result
287+
mirror: model.flip===2 || model.flip===4
288+
// Keep image vertically centered relative to the window's MouseArea, which fills the window.
280289
anchors.horizontalCenter: parent.horizontalCenter
281290
anchors.verticalCenter: parent.verticalCenter
282291
width: reScale ? parent.width : projectionManager.forwardTo.width
283292
height: reScale ? (parent.width / projectionManager.forwardTo.width) * projectionManager.forwardTo.height : projectionManager.forwardTo.height
284-
blending: false
285293
transform: Scale {
286294
origin.y: img.height/2
287295
yScale: model.flip===3 || model.flip===4 ? -1 : 1
288-
origin.x: img.width/2
289-
xScale: model.flip===2 || model.flip===4 ? -1 : 1
296+
// origin.x: img.width/2
297+
// xScale: model.flip===2 || model.flip===4 ? -1 : 1
290298
}
291299
Rectangle {
292300
color: "#000000"

src/prompter/PrompterView.qml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ Item {
4242
property real __baseSpeed: editorToolbar.baseSpeedSlider.value
4343
property real __curvature: editorToolbar.baseAccelerationSlider.value
4444

45-
//layer.enabled: true
46-
// Undersample
47-
//layer.mipmap: true
48-
// Oversample
49-
//layer.samples: 2
50-
//layer.smooth: true
51-
// Make texture the size of the largest destinations.
52-
//layer.textureSize: Qt.size(projectionWindow.width, projectionWindow.height)
53-
5445
transform: Rotation {
5546
origin.x: (forcedOrientation && forcedOrientation!==3 ? parent.height/2 : parent.width*0.15);
5647
origin.y: (forcedOrientation && forcedOrientation!==3 ? parent.width/2 : parent.height);

0 commit comments

Comments
 (0)