More dark mode fixes for Windows
Also enforce modality for progress dialog if possible
This commit is contained in:
@@ -22,6 +22,10 @@
|
|||||||
#include "qt_vmmanager_details.hpp"
|
#include "qt_vmmanager_details.hpp"
|
||||||
#include "ui_qt_vmmanager_details.h"
|
#include "ui_qt_vmmanager_details.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
extern bool windows_is_light_theme();
|
||||||
|
#endif
|
||||||
|
|
||||||
VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::VMManagerDetails) {
|
QWidget(parent), ui(new Ui::VMManagerDetails) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -71,10 +75,10 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
|||||||
screenshotThumbnailSize = QSize(240, 160);
|
screenshotThumbnailSize = QSize(240, 160);
|
||||||
|
|
||||||
// Set the icons for the screenshot navigation buttons
|
// Set the icons for the screenshot navigation buttons
|
||||||
ui->screenshotNext->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward));
|
ui->screenshotNext->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowRight));
|
||||||
ui->screenshotPrevious->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward));
|
ui->screenshotPrevious->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowLeft));
|
||||||
ui->screenshotNextTB->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward));
|
ui->screenshotNextTB->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowRight));
|
||||||
ui->screenshotPreviousTB->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward));
|
ui->screenshotPreviousTB->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowLeft));
|
||||||
// Disabled by default
|
// Disabled by default
|
||||||
ui->screenshotNext->setEnabled(false);
|
ui->screenshotNext->setEnabled(false);
|
||||||
ui->screenshotPrevious->setEnabled(false);
|
ui->screenshotPrevious->setEnabled(false);
|
||||||
@@ -90,11 +94,19 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
|||||||
ui->screenshotPrevious->setVisible(false);
|
ui->screenshotPrevious->setVisible(false);
|
||||||
QString toolButtonStyleSheet;
|
QString toolButtonStyleSheet;
|
||||||
// Simple method to try and determine if light mode is enabled
|
// Simple method to try and determine if light mode is enabled
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
const bool lightMode = windows_is_light_theme();
|
||||||
|
#else
|
||||||
const bool lightMode = QApplication::palette().window().color().value() > QApplication::palette().windowText().color().value();
|
const bool lightMode = QApplication::palette().window().color().value() > QApplication::palette().windowText().color().value();
|
||||||
|
#endif
|
||||||
if (lightMode) {
|
if (lightMode) {
|
||||||
toolButtonStyleSheet = "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(midlight)} QToolButton:pressed {background: palette(mid)}";
|
toolButtonStyleSheet = "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(midlight)} QToolButton:pressed {background: palette(mid)}";
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef Q_OS_WINDOWS
|
||||||
toolButtonStyleSheet = "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(dark)} QToolButton:pressed {background: palette(mid)}";
|
toolButtonStyleSheet = "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(dark)} QToolButton:pressed {background: palette(mid)}";
|
||||||
|
#else
|
||||||
|
toolButtonStyleSheet = "QToolButton {padding: 5px}";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ui->ssNavTBHolder->setStyleSheet(toolButtonStyleSheet);
|
ui->ssNavTBHolder->setStyleSheet(toolButtonStyleSheet);
|
||||||
|
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto current_index = ui->listView->currentIndex();
|
const auto current_index = ui->listView->currentIndex();
|
||||||
vm_model->reload();
|
vm_model->reload(this);
|
||||||
const auto created_object = vm_model->getIndexForConfigFile(new_system->config_file);
|
const auto created_object = vm_model->getIndexForConfigFile(new_system->config_file);
|
||||||
if (created_object.row() < 0) {
|
if (created_object.row() < 0) {
|
||||||
// For some reason the index of the new object couldn't be determined. Fall back to the old index.
|
// For some reason the index of the new object couldn't be determined. Fall back to the old index.
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ VMManagerModel::getConfigObjectForIndex(const QModelIndex &index) const
|
|||||||
return machines.at(index.row());
|
return machines.at(index.row());
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
VMManagerModel::reload()
|
VMManagerModel::reload(QWidget* parent)
|
||||||
{
|
{
|
||||||
// Scan for configs
|
// Scan for configs
|
||||||
auto machines_vec = VMManagerSystem::scanForConfigs();
|
auto machines_vec = VMManagerSystem::scanForConfigs(parent);
|
||||||
for (const auto &scanned_config : machines_vec) {
|
for (const auto &scanned_config : machines_vec) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
for (const auto &existing_config : machines) {
|
for (const auto &existing_config : machines) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] VMManagerSystem * getConfigObjectForIndex(const QModelIndex &index) const;
|
[[nodiscard]] VMManagerSystem * getConfigObjectForIndex(const QModelIndex &index) const;
|
||||||
QModelIndex getIndexForConfigFile(const QFileInfo& config_file);
|
QModelIndex getIndexForConfigFile(const QFileInfo& config_file);
|
||||||
void reload();
|
void reload(QWidget* parent = nullptr);
|
||||||
void updateDisplayName(const QModelIndex &index, const QString &newDisplayName);
|
void updateDisplayName(const QModelIndex &index, const QString &newDisplayName);
|
||||||
QHash <QString, int> getProcessStats();
|
QHash <QString, int> getProcessStats();
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ VMManagerSystem::~VMManagerSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVector<VMManagerSystem *>
|
QVector<VMManagerSystem *>
|
||||||
VMManagerSystem::scanForConfigs(const QString &searchPath)
|
VMManagerSystem::scanForConfigs(QWidget* parent, const QString &searchPath)
|
||||||
{
|
{
|
||||||
QProgressDialog progDialog;
|
QProgressDialog progDialog(parent);
|
||||||
unsigned int found = 0;
|
unsigned int found = 0;
|
||||||
progDialog.setCancelButton(nullptr);
|
progDialog.setCancelButton(nullptr);
|
||||||
progDialog.setWindowTitle(tr("Searching for VMs..."));
|
progDialog.setWindowTitle(tr("Searching for VMs..."));
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
|
|
||||||
~VMManagerSystem() override;
|
~VMManagerSystem() override;
|
||||||
|
|
||||||
static QVector<VMManagerSystem *> scanForConfigs(const QString &searchPath = {});
|
static QVector<VMManagerSystem *> scanForConfigs(QWidget* parent = nullptr, const QString &searchPath = {});
|
||||||
static QString generateTemporaryFilename();
|
static QString generateTemporaryFilename();
|
||||||
|
|
||||||
QFileInfo config_file;
|
QFileInfo config_file;
|
||||||
|
|||||||
Reference in New Issue
Block a user