🎉 FINALLY! Extra window in any wayland compositor

This required switching from a QML Window to a QQuickView in C++. I
want to try to eventually subclass that in Rust, but for now it works.

I'll have to still tinker with this to find out how to specifically
set the screen in certain environments, but for now the user will need
to move the window on their own.
This commit is contained in:
Chris Cochrun 2023-05-19 13:01:15 -05:00
parent bbc5bf3d7c
commit b74e85bfe6
5 changed files with 98 additions and 42 deletions

View file

@ -152,7 +152,12 @@ int main(int argc, char *argv[])
Settings *settings = new Settings;
settings->setup();
// preswin->setSource(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml")));
QQuickView *PresWindow = new QQuickView;
qDebug() << PresWindow;
// PresWindow->create();
// PresWindow->setSource(QUrl(QStringLiteral("qrc://qml/presenter/PresentationWindow.qml")));
qDebug() << PresWindow->isVisible();
QObject::connect(serviceItemModel.get(),
SIGNAL(itemInserted(const int&, const ServiceItem&)),
@ -223,7 +228,11 @@ int main(int argc, char *argv[])
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideMod", slideMod.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slideobject.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", PresWindow);
qmlRegisterSingletonInstance("org.presenter", 1, 0, "RSettings", settings);
// qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", preswin.get());
PresWindow->rootContext()->setContextProperty("SlideObj", slideobject.get());
PresWindow->setTitle("presentation-window");
connectToDatabase();
@ -231,6 +240,7 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl(QStringLiteral("qrc:qml/main.qml")));
// engine.load(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml")));
qDebug() << app.topLevelWindows();
qDebug() << app.allWindows();
@ -246,11 +256,6 @@ int main(int argc, char *argv[])
}
QWindow *window = windowFromEngine(&engine);
QQuickWindow *PresWindow = new QQuickWindow;
qDebug() << PresWindow;
PresWindow->create();
// PresWindow->setVisible(true);
qDebug() << PresWindow->isVisible();
window->setIcon(QIcon::fromTheme(QStringLiteral("system-config-display")));
// KWindowSystem::setMainWindow(window);

View file

@ -29,6 +29,7 @@ Kirigami.ApplicationWindow {
signal edit()
onActiveFocusItemChanged: console.log("FOCUS CHANGED TO: " + activeFocusControl)
onClosing: mainPage.closeAll()
/* pageStack.initialPage: mainPage */
header: Presenter.Header {}

View file

@ -128,9 +128,14 @@ Controls.Page {
}
}
Presenter.PresentationWindow {
id: pWindow
}
/* Loader { */
/* id: presWinLoader */
/* active: false */
/* sourceComponent: Presenter.PresentationWindow {} */
/* } */
/* Presenter.PresentationWindow { */
/* id: pWindow */
/* } */
SongProxyModel { id: songProxyModel }
ImageProxyModel { id: imageProxyModel }
@ -272,16 +277,20 @@ Controls.Page {
function present(present) {
if (present)
{
/* presentation.loadVideo(); */
console.log("For window: Screen is: " + pWindow.screen + " And selected screen is: " + presentationScreen);
pWindow.showFullScreen();
/* pWindow.screen = presentationScreen; */
console.log("For window: Screen is: " + pWindow.screen + " And selected screen is: " + presentationScreen);
PresWindow.showFullScreen();
PresWindow.setSource("qrc:qml/presenter/PresentationWindow.qml")
console.log(PresWindow);
/* presWinLoader.active = true; */
}
else {
PresWindow.close();
/* presWinLoader.active = false; */
}
else
pWindow.close();
}
function closeAll() { PresWindow.close() }
function changeVidPos(pos) {
presentation.slide.seek(pos);
pWindow.slide.seek(pos);

View file

@ -7,49 +7,64 @@ import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import org.presenter 1.0
Window {
Item {
id: presentationWindow
property Item slide: presentationSlide
/* property var slideObj */
property var pWin
anchors.fill: parent
title: "presentation-window"
height: maximumHeight
width: maximumWidth
screen: presentationScreen
opacity: 1.0
/* title: "presentation-window" */
/* height: maximumHeight */
/* width: maximumWidth */
/* screen: presentationScreen */
/* opacity: 1.0 */
/* transientParent: null */
/* modality: Qt.NonModal */
flags: Qt.FramelessWindowHint
onClosing: {
presentationSlide.stopVideo();
SlideObject.pause();
presentationSlide.stopAudio();
presenting = false;
/* flags: Qt.FramelessWindowHint */
/* onClosing: { */
/* presentationSlide.stopVideo(); */
/* SlideObj.pause(); */
/* presentationSlide.stopAudio(); */
/* presenting = false; */
/* } */
Connections {
target: PresWindow
function onClosing() {
presentationSlide.stopVideo();
SlideObj.pause();
presentationSlide.stopAudio();
presenting = false;
}
}
Component.onCompleted: {
console.log(screen.name);
/* console.log(screen.name); */
/* presentationWindow.showFullScreen(); */
}
Presenter.Slide {
id: presentationSlide
anchors.fill: parent
imageSource: SlideObject.imageBackground
webSource: SlideObject.html
videoSource: presentationWindow.visible ? SlideObject.videoBackground : ""
audioSource: SlideObject.audio
text: SlideObject.text
chosenFont: SlideObject.font
textSize: SlideObject.fontSize
pdfIndex: SlideObject.pdfIndex
itemType: SlideObject.ty
vidLoop: SlideObject.looping
imageSource: SlideObj.imageBackground
webSource: SlideObj.html
videoSource: presentationWindow.visible ? SlideObj.videoBackground : ""
audioSource: SlideObj.audio
text: SlideObj.text
chosenFont: SlideObj.font
textSize: SlideObj.fontSize
pdfIndex: SlideObj.slideIndex
itemType: SlideObj.ty
vidLoop: SlideObj.looping
}
Connections {
target: SlideObject
target: SlideObj
function onVideoBackgroundChanged() {
if (SlideObject.videoBackground === "")
if (SlideObj.videoBackground === "")
stopVideo();
else {
loadVideo();
@ -57,7 +72,7 @@ Window {
}
}
function onIsPlayingChanged() {
if(SlideObject.isPlaying)
if(SlideObj.isPlaying)
presentationSlide.playVideo();
pauseVideo();
}

View file

@ -20,6 +20,7 @@ Kirigami.OverlaySheet {
/* } */
Kirigami.FormLayout {
implicitHeight: Kirigami.Units.gridUnit * 30
Controls.ComboBox {
id: screenSelectionField
Kirigami.FormData.label: i18nc("@label:textbox", "Presentation Screen:")
@ -27,6 +28,31 @@ Kirigami.OverlaySheet {
textRole: "name"
onActivated: {
presentationScreen = screens[currentIndex];
console.log(PresWindow.screen);
PresWindow.screen = screens[currentIndex];
console.log(PresWindow.screen);
}
popup: Controls.Popup {
y: screenSelectionField.height + 10
z: 1000
width: screenSelectionField.width
implicitHeight: contentItem.implicitHeight
padding: 1
contentItem: ListView {
clip: true
implicitHeight: contentHeight
model: screenSelectionField.popup.visible ? screenSelectionField.delegateModel : null
currentIndex: screenSelectionField.highlightedIndex
Controls.ScrollIndicator.vertical: Controls.ScrollIndicator { }
}
background: Rectangle {
border.color: Kirigami.Theme.hoverColor
radius: 2
}
}
}
Controls.ToolButton {