fix qt title bar and proper qt 6.5 impl
All checks were successful
eden-license / license-header (pull_request) Successful in 15s
All checks were successful
eden-license / license-header (pull_request) Successful in 15s
This commit is contained in:
parent
bdf5674d7e
commit
5370ee1c2f
2 changed files with 13 additions and 19 deletions
|
@ -96,6 +96,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStyleHints>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
@ -299,16 +300,16 @@ static void OverrideWindowsFont() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool GMainWindow::CheckDarkMode() {
|
inline static bool isDarkMode() {
|
||||||
#ifdef __unix__
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
const QPalette test_palette(qApp->palette());
|
const auto scheme = QGuiApplication::styleHints()->colorScheme();
|
||||||
const QColor text_color = test_palette.color(QPalette::Active, QPalette::Text);
|
return scheme == Qt::ColorScheme::Dark;
|
||||||
const QColor window_color = test_palette.color(QPalette::Active, QPalette::Window);
|
|
||||||
return (text_color.value() > window_color.value());
|
|
||||||
#else
|
#else
|
||||||
// TODO: Windows
|
const QPalette defaultPalette;
|
||||||
return false;
|
const auto text = defaultPalette.color(QPalette::WindowText);
|
||||||
#endif // __unix__
|
const auto window = defaultPalette.color(QPalette::Window);
|
||||||
|
return text.lightness() > window.lightness();
|
||||||
|
#endif // QT_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
GMainWindow::GMainWindow(bool has_broken_vulkan)
|
GMainWindow::GMainWindow(bool has_broken_vulkan)
|
||||||
|
@ -358,7 +359,6 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
|
||||||
statusBar()->hide();
|
statusBar()->hide();
|
||||||
|
|
||||||
// Check dark mode before a theme is loaded
|
// Check dark mode before a theme is loaded
|
||||||
os_dark_mode = CheckDarkMode();
|
|
||||||
startup_icon_theme = QIcon::themeName();
|
startup_icon_theme = QIcon::themeName();
|
||||||
// fallback can only be set once, colorful theme icons are okay on both light/dark
|
// fallback can only be set once, colorful theme icons are okay on both light/dark
|
||||||
QIcon::setFallbackThemeName(QStringLiteral("colorful"));
|
QIcon::setFallbackThemeName(QStringLiteral("colorful"));
|
||||||
|
@ -5383,15 +5383,11 @@ void GMainWindow::UpdateUITheme() {
|
||||||
current_theme = default_theme;
|
current_theme = default_theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
QIcon::setThemeName(current_theme);
|
|
||||||
AdjustLinkColor();
|
|
||||||
#else
|
|
||||||
if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) {
|
if (current_theme == QStringLiteral("default") || current_theme == QStringLiteral("colorful")) {
|
||||||
QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme
|
QIcon::setThemeName(current_theme == QStringLiteral("colorful") ? current_theme
|
||||||
: startup_icon_theme);
|
: startup_icon_theme);
|
||||||
QIcon::setThemeSearchPaths(QStringList(default_theme_paths));
|
QIcon::setThemeSearchPaths(QStringList(default_theme_paths));
|
||||||
if (CheckDarkMode()) {
|
if (isDarkMode()) {
|
||||||
current_theme = QStringLiteral("default_dark");
|
current_theme = QStringLiteral("default_dark");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -5399,7 +5395,7 @@ void GMainWindow::UpdateUITheme() {
|
||||||
QIcon::setThemeSearchPaths(QStringList(QStringLiteral(":/icons")));
|
QIcon::setThemeSearchPaths(QStringList(QStringLiteral(":/icons")));
|
||||||
AdjustLinkColor();
|
AdjustLinkColor();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (current_theme != default_theme) {
|
if (current_theme != default_theme) {
|
||||||
QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
|
QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
|
||||||
QFile f(theme_uri);
|
QFile f(theme_uri);
|
||||||
|
@ -5661,7 +5657,7 @@ int main(int argc, char* argv[]) {
|
||||||
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
|
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
QApplication::setStyle(QStringLiteral("windowsvista"));
|
QApplication::setStyle(QStringLiteral("fusion"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
|
@ -466,7 +466,6 @@ private:
|
||||||
void OpenURL(const QUrl& url);
|
void OpenURL(const QUrl& url);
|
||||||
void LoadTranslation();
|
void LoadTranslation();
|
||||||
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
|
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
|
||||||
bool CheckDarkMode();
|
|
||||||
bool CheckFirmwarePresence();
|
bool CheckFirmwarePresence();
|
||||||
void SetFirmwareVersion();
|
void SetFirmwareVersion();
|
||||||
void ConfigureFilesystemProvider(const std::string& filepath);
|
void ConfigureFilesystemProvider(const std::string& filepath);
|
||||||
|
@ -557,7 +556,6 @@ private:
|
||||||
QTimer update_input_timer;
|
QTimer update_input_timer;
|
||||||
|
|
||||||
QString startup_icon_theme;
|
QString startup_icon_theme;
|
||||||
bool os_dark_mode = false;
|
|
||||||
|
|
||||||
// FS
|
// FS
|
||||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue