diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index dc430d68c..bed9d27c0 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -193,8 +193,10 @@ add_library(ui STATIC qt_updatecheck.hpp qt_updatecheckdialog.cpp qt_updatecheckdialog.hpp + qt_updatecheckdialog.ui qt_updatedetails.cpp qt_updatedetails.hpp + qt_updatedetails.ui qt_downloader.cpp qt_downloader.hpp @@ -211,10 +213,12 @@ add_library(ui STATIC qt_vmmanager_addmachine.hpp qt_vmmanager_detailsection.cpp qt_vmmanager_detailsection.hpp + qt_vmmanager_detailsection.ui qt_vmmanager_listviewdelegate.hpp qt_vmmanager_listviewdelegate.cpp qt_vmmanager_preferences.cpp qt_vmmanager_preferences.hpp + qt_vmmanager_preferences.ui qt_vmmanager_main.hpp qt_vmmanager_main.cpp qt_vmmanager_main.ui @@ -226,6 +230,7 @@ add_library(ui STATIC qt_vmmanager_config.hpp qt_vmmanager_mainwindow.cpp qt_vmmanager_mainwindow.hpp + qt_vmmanager_mainwindow.ui ../qt_resources.qrc ./qdarkstyle/dark/darkstyle.qrc diff --git a/src/qt/qt_vmmanager_details.cpp b/src/qt/qt_vmmanager_details.cpp index f72102c25..e427ca140 100644 --- a/src/qt/qt_vmmanager_details.cpp +++ b/src/qt/qt_vmmanager_details.cpp @@ -127,8 +127,14 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { // Set the scrollarea background but also set the scroll bar to none. Otherwise it will also // set the scrollbar background to the same. - ui->scrollArea->setStyleSheet("QWidget {background-color: palette(light)} QScrollBar{ background-color: none }"); - ui->systemLabel->setStyleSheet("background-color: palette(midlight);"); +#ifdef Q_OS_WINDOWS + extern bool windows_is_light_theme(); + if (windows_is_light_theme()) +#endif + { + ui->scrollArea->setStyleSheet("QWidget {background-color: palette(light)} QScrollBar{ background-color: none }"); + ui->systemLabel->setStyleSheet("background-color: palette(midlight);"); + } // Margins are a little different on macos #ifdef Q_OS_MACOS ui->systemLabel->setMargin(15); diff --git a/src/qt/qt_vmmanager_detailsection.cpp b/src/qt/qt_vmmanager_detailsection.cpp index 95a600d8f..f6b77baf9 100644 --- a/src/qt/qt_vmmanager_detailsection.cpp +++ b/src/qt/qt_vmmanager_detailsection.cpp @@ -38,12 +38,22 @@ VMManagerDetailSection(const QString §ionName) ui->collapseButtonHolder->setContentsMargins(getMargins(MarginSection::ToolButton)); // Simple method to try and determine if light mode is enabled on the host +#ifdef Q_OS_WINDOWS + extern bool windows_is_light_theme(); + const bool lightMode = windows_is_light_theme(); +#else const bool lightMode = QApplication::palette().window().color().value() > QApplication::palette().windowText().color().value(); +#endif // Alternate layout if ( lightMode) { ui->collapseButtonHolder->setStyleSheet("background-color: palette(midlight);"); } else { +#ifdef Q_OS_WINDOWS + ui->outerFrame->setStyleSheet("background-color: #272727;"); + ui->collapseButtonHolder->setStyleSheet("background-color: #616161;"); +#else ui->collapseButtonHolder->setStyleSheet("background-color: palette(mid);"); +#endif } const auto sectionLabel = new QLabel(sectionName); sectionLabel->setStyleSheet(sectionLabel->styleSheet().append("font-weight: bold;")); diff --git a/src/qt/qt_vmmanager_listviewdelegate.cpp b/src/qt/qt_vmmanager_listviewdelegate.cpp index 167c805ee..28820a044 100644 --- a/src/qt/qt_vmmanager_listviewdelegate.cpp +++ b/src/qt/qt_vmmanager_listviewdelegate.cpp @@ -21,6 +21,10 @@ #include "qt_vmmanager_listviewdelegate.hpp" #include "qt_vmmanager_model.hpp" +#ifdef Q_OS_WINDOWS +extern bool windows_is_light_theme(); +#endif + // Thanks to scopchanov https://github.com/scopchanov/SO-MessageLog // from https://stackoverflow.com/questions/53105343/is-it-possible-to-add-a-custom-widget-into-a-qlistview @@ -37,6 +41,10 @@ VMManagerListViewDelegate::~VMManagerListViewDelegate() void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + bool windows_light_mode = true; +#ifdef Q_OS_WINDOWS + windows_light_mode = windows_is_light_theme(); +#endif QStyleOptionViewItem opt(option); initStyleOption(&opt, index); const QPalette &palette(opt.palette); @@ -97,13 +105,13 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI // When selected, only draw the highlighted part until the horizontal separator int offset = 2; auto highlightRect = rect.adjusted(0, 0, 0, -offset); - painter->fillRect(highlightRect, palette.highlight().color()); + painter->fillRect(highlightRect, windows_light_mode ? palette.highlight().color() : QColor("#616161")); // Then fill the remainder with the normal color auto regularRect = rect.adjusted(0, rect.height()-offset, 0, 0); - painter->fillRect(regularRect, palette.light().color()); + painter->fillRect(regularRect, windows_light_mode ? palette.light().color() : QColor("#272727")); } else { // Otherwise just draw the background color as usual - painter->fillRect(rect, palette.light().color()); + painter->fillRect(rect, windows_light_mode ? palette.light().color() : QColor("#272727")); } // Draw bottom line. Last line gets a different color @@ -238,4 +246,4 @@ qreal VMManagerListViewDelegateStyle::statusFontPointSize(const QFont &f) const QRect VMManagerListViewDelegateStyle::systemNameBox(const QStyleOptionViewItem &option, const QModelIndex &index) const { return option.fontMetrics.boundingRect(option.text).adjusted(0, 0, 1, 1); -} \ No newline at end of file +}