summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 56f927f..314493c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -16,14 +16,13 @@
#include "loginform.h"
#include "settings.h"
-MainWindow::MainWindow(int screen, QWidget *parent) :
+MainWindow::MainWindow(bool primary, int screen, const QRect &screenRect, QWidget *parent) :
QWidget(parent),
- m_Screen(screen)
+ m_Screen(screen),
+ m_Primary(primary)
{
setObjectName(QString("MainWindow_%1").arg(screen));
-
- QRect screenRect = QApplication::desktop()->screenGeometry(screen);
setGeometry(screenRect);
setBackground();
@@ -59,7 +58,7 @@ MainWindow::~MainWindow()
bool MainWindow::showLoginForm()
{
- return m_Screen == QApplication::desktop()->primaryScreen();
+ return m_Primary;
}
void MainWindow::setFocus(Qt::FocusReason reason)
@@ -98,29 +97,38 @@ int MainWindow::getOffset(QString settingsOffset, int maxVal, int defaultVal)
void MainWindow::setBackground()
{
- QImage backgroundImage;
QSettings greeterSettings(CONFIG_FILE, QSettings::IniFormat);
if (greeterSettings.contains(BACKGROUND_IMAGE_KEY)) {
- QString pathToBackgroundImage = greeterSettings.value(BACKGROUND_IMAGE_KEY).toString();
+ QString pathTom_background = greeterSettings.value(BACKGROUND_IMAGE_KEY).toString();
- backgroundImage = QImage(pathToBackgroundImage);
- if (backgroundImage.isNull()) {
- qWarning() << "Not able to read" << pathToBackgroundImage << "as image";
+ m_background = QImage(pathTom_background);
+ if (m_background.isNull()) {
+ qWarning() << "Not able to read" << pathTom_background << "as image";
}
}
+ if (m_background.isNull()) {
+ m_background = QImage(2, 2, QImage::Format_RGB32);
+ m_background.setPixel(0, 0, 0xffffffff);
+ m_background.setPixel(1, 0, 0xff888687);
+ m_background.setPixel(0, 1, 0xff888687);
+ m_background.setPixel(1, 1, 0xfff9a72b);
+ }
QPalette palette;
QRect rect = QApplication::desktop()->screenGeometry(m_Screen);
- if (backgroundImage.isNull()) {
+ if (m_background.isNull()) {
palette.setColor(QPalette::Background, Qt::black);
}
else {
- backgroundImage = backgroundImage.scaled(rect.width(), rect.height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
- int xoff = (backgroundImage.width() - rect.width()) / 2;
- int yoff = (backgroundImage.height() - rect.height()) / 2;
- QBrush brush(backgroundImage.copy(xoff, yoff, backgroundImage.width(), backgroundImage.height()));
+ m_background = m_background.scaled(rect.width(), rect.height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
+ int xoff = (m_background.width() - rect.width()) / 2;
+ int yoff = (m_background.height() - rect.height()) / 2;
+ if (xoff != 0 || yoff != 0) {
+ m_background = m_background.copy(xoff, yoff, m_background.width(), m_background.height());
+ }
+ QBrush brush(m_background);
palette.setBrush(this->backgroundRole(), brush);
}
this->setPalette(palette);