diff --git a/CMakeLists.txt b/CMakeLists.txt index cfa577e..3848c15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/src/backgroundscreen.cpp b/src/backgroundscreen.cpp new file mode 100644 index 0000000..e8ce92f --- /dev/null +++ b/src/backgroundscreen.cpp @@ -0,0 +1,27 @@ +#include "backgroundscreen.h" + +#include +#include +#include + +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() +{ +} diff --git a/src/backgroundscreen.h b/src/backgroundscreen.h new file mode 100644 index 0000000..d6d5d38 --- /dev/null +++ b/src/backgroundscreen.h @@ -0,0 +1,14 @@ +#ifndef BACKGROUNDSCREEN_H +#define BACKGROUNDSCREEN_H + +#include + +class BackgroundScreen : public QWidget { + Q_OBJECT + +public: + explicit BackgroundScreen(QWidget *parent = nullptr); + virtual ~BackgroundScreen(); +}; + +#endif // BACKGROUNDSCREEN_H diff --git a/src/main.cpp b/src/main.cpp index 5467f8a..a1b5125 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,7 @@ */ #include "installerprompt.h" +#include "backgroundscreen.h" #include #include #include @@ -32,23 +33,20 @@ int main(int argc, char *argv[]) } } - QList ws; + InstallerPrompt* w; + QList 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();