|
30 | 30 |
|
31 | 31 | #define LEMON_MODULE_NAME "ResultViewer" |
32 | 32 |
|
| 33 | +static bool shouldApplyDarkFrame() { |
| 34 | + const QPalette &defaultPalette = QApplication::palette(); |
| 35 | + return defaultPalette.color(QPalette::WindowText).lightness() > |
| 36 | + defaultPalette.color(QPalette::Window).lightness(); |
| 37 | +} |
| 38 | + |
33 | 39 | ResultViewer::ResultViewer(QWidget *parent) : QTableWidget(parent) { |
34 | 40 | curContest = nullptr; |
35 | 41 | deleteContestantAction = new QAction(tr("Delete"), this); |
@@ -110,12 +116,20 @@ void ResultViewer::refreshViewer() { |
110 | 116 | curContest->copySettings(setting); |
111 | 117 | ColorTheme colors = setting.getCurrentColorTheme(); |
112 | 118 |
|
113 | | -#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) |
114 | | - if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) { |
| 119 | + // #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) |
| 120 | + // if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) { |
| 121 | + // colors.invertLightness(); |
| 122 | + // LOG("Auto dark mode has been set"); |
| 123 | + // } |
| 124 | + // #endif |
| 125 | + // https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5 |
| 126 | + // Waiting QPalette::colorScheme implement |
| 127 | + // So we use an alternative method. |
| 128 | + if (shouldApplyDarkFrame()) { |
115 | 129 | colors.invertLightness(); |
116 | 130 | LOG("Auto dark mode has been set"); |
117 | 131 | } |
118 | | -#endif |
| 132 | + |
119 | 133 | for (auto &i : taskList) { |
120 | 134 | headerList << i->getProblemTitle(); |
121 | 135 | } |
|
0 commit comments