[gui] Add dev mode background

This commit is contained in:
hawkeyexp 2018-06-05 15:47:24 +02:00
parent 3f241ee283
commit a1f010fa5b

View File

@ -54,8 +54,14 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
QFileInfo wallpaperNightFile("wallpaper-night.png"); QFileInfo wallpaperNightFile("wallpaper-night.png");
bool wallpaperNightFileExists = wallpaperNightFile.exists(); bool wallpaperNightFileExists = wallpaperNightFile.exists();
QFileInfo nightSwitchFile("/tmp/night_mode_enabled"); QFileInfo wallpaperDevFile("wallpaper-devmode.png");
bool nightSwitchExists = nightSwitchFile.exists(); bool wallpaperDevFileExists = wallpaperDevFile.exists();
QFileInfo nightModeFile("/tmp/night_mode_enabled");
bool nightModeEnabled = nightModeFile.exists();
QFileInfo devModeFile("/tmp/dev_mode_enabled");
bool devModeEnabled = devModeFile.exists();
if (wallpaperDayFile.isSymLink()) { if (wallpaperDayFile.isSymLink()) {
QFileInfo linkTarget(wallpaperDayFile.symLinkTarget()); QFileInfo linkTarget(wallpaperDayFile.symLinkTarget());
@ -67,6 +73,11 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
wallpaperNightFileExists = linkTarget.exists(); wallpaperNightFileExists = linkTarget.exists();
} }
if (wallpaperDevFile.isSymLink()) {
QFileInfo linkTarget(wallpaperDevFile.symLinkTarget());
wallpaperDevFileExists = linkTarget.exists();
}
ui_->setupUi(this); ui_->setupUi(this);
connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings); connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings);
connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit);
@ -79,22 +90,30 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog); connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider);
if (!nightSwitchExists) { if (devModeEnabled) {
ui_->pushButtonNight->show(); if (wallpaperDevFileExists) {
ui_->pushButtonDay->hide(); this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(wallpaper-devmode.png) }") );
if (wallpaperDayFileExists) {
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(wallpaper.png) }") );
} else { } else {
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(:/connect.png) }") ); this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(:/connect.png) }") );
} }
} else { } else {
ui_->pushButtonDay->show(); if (!nightModeEnabled) {
ui_->pushButtonNight->hide(); ui_->pushButtonNight->show();
if (wallpaperNightFileExists) { ui_->pushButtonDay->hide();
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(wallpaper-night.png) }") ); if (wallpaperDayFileExists) {
} else { this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(wallpaper.png) }") );
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(:/connect.png) }") ); } else {
} this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(:/connect.png) }") );
}
} else {
ui_->pushButtonDay->show();
ui_->pushButtonNight->hide();
if (wallpaperNightFileExists) {
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(wallpaper-night.png) }") );
} else {
this->setStyleSheet( this->styleSheet().append("QMainWindow { background: url(:/connect.png) }") );
}
}
} }
QTimer *timer=new QTimer(this); QTimer *timer=new QTimer(this);