Use true fullscreen mode, display just the background image on all but one screen

pull/2/head
Aaron Rainbolt 5 months ago
parent edc608e98a
commit e05ca8280e

@ -27,6 +27,8 @@ set(PROJECT_SOURCES
src/installerprompt.cpp
src/installerprompt.h
src/installerprompt.ui
src/backgroundscreen.h
src/backgroundscreen.cpp
src/resource.qrc
)

@ -0,0 +1,27 @@
#include "backgroundscreen.h"
#include <QMessageBox>
#include <QGuiApplication>
#include <QScreen>
BackgroundScreen::BackgroundScreen(QWidget *parent)
: QWidget(parent) {
// Set the background image and scale it
QPixmap bg(":/background");
if (bg.isNull()) {
// the user will see the warning message that the InstallerPrompt object pops up, no need to bombard them with one message per screen
return;
}
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
bg = bg.scaled(screenGeometry.size(), Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Window, bg);
this->setPalette(palette);
}
BackgroundScreen::~BackgroundScreen()
{
}

@ -0,0 +1,14 @@
#ifndef BACKGROUNDSCREEN_H
#define BACKGROUNDSCREEN_H
#include <QWidget>
class BackgroundScreen : public QWidget {
Q_OBJECT
public:
explicit BackgroundScreen(QWidget *parent = nullptr);
virtual ~BackgroundScreen();
};
#endif // BACKGROUNDSCREEN_H

@ -14,6 +14,7 @@
*/
#include "installerprompt.h"
#include "backgroundscreen.h"
#include <QApplication>
#include <QScreen>
#include <QTranslator>
@ -32,23 +33,20 @@ int main(int argc, char *argv[])
}
}
QList<InstallerPrompt*> ws;
InstallerPrompt* w;
QList<BackgroundScreen *> bss;
// Iterate through all available screens
for (QScreen *screen : QApplication::screens()) {
InstallerPrompt *w = new InstallerPrompt();
w->setGeometry(screen->geometry());
w->show();
ws.append(w);
}
for (InstallerPrompt *w : ws) {
for (InstallerPrompt *otherWindow : ws) {
if (w != otherWindow) {
// Connect signals and slots for synchronization
// Example: connect(ws.last(), &InstallerPrompt::someSignal, otherWindow, &InstallerPrompt::someSlot);
}
if (screen == QApplication::primaryScreen()) {
w = new InstallerPrompt();
w->showFullScreen();
continue;
}
BackgroundScreen *backscreen = new BackgroundScreen();
backscreen->setGeometry(screen->geometry());
backscreen->showFullScreen();
bss.append(backscreen);
}
return app.exec();

Loading…
Cancel
Save