2020#include < QDir>
2121#include < QFile>
2222#include < QFileInfo>
23+ #include < QProcessEnvironment>
2324#include < QSplashScreen>
2425#include < QStyleFactory>
2526#include < QTimer>
2627#include < cstdio>
2728#include < fcntl.h>
2829#include < iostream>
30+ #include " dive_application.h"
2931#include " dive_core/common.h"
3032#include " dive_core/pm4_info.h"
3133#include " application_controller.h"
@@ -247,29 +249,52 @@ int main(int argc, char *argv[])
247249
248250 // Try setting "Fusion" style. If not found, set "Windows".
249251 // And if that's not found, default to whatever style the factory provides.
250- if (!SetApplicationStyle (" Fusion" ))
252+ bool use_default_style = false ;
253+
254+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
255+ QString desktopEnvironment = env.value (" XDG_CURRENT_DESKTOP" );
256+ if (desktopEnvironment.contains (" KDE" , Qt::CaseInsensitive))
257+ {
258+ use_default_style = true ;
259+ }
260+
261+ if (!use_default_style)
251262 {
252- if (!SetApplicationStyle (" Windows " ))
263+ if (!SetApplicationStyle (" Fusion " ))
253264 {
254- if (!QStyleFactory::keys (). empty ( ))
265+ if (!SetApplicationStyle ( " Windows " ))
255266 {
256- SetApplicationStyle (QStyleFactory::keys ()[0 ]);
267+ if (!QStyleFactory::keys ().empty ())
268+ {
269+ SetApplicationStyle (QStyleFactory::keys ()[0 ]);
270+ }
257271 }
258272 }
259273 }
260274
261275 Dive::RegisterCustomMetaType ();
262276
263277 QApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
264- QApplication app (argc, argv);
278+ DiveApplication app (argc, argv);
265279 app.setWindowIcon (QIcon (" :/images/dive.ico" ));
266- SetDarkMode (app);
267280
268- // Load and apply the style sheet
269- QFile style_sheet (" :/stylesheet.qss" );
270- style_sheet.open (QFile::ReadOnly);
271- QString style (style_sheet.readAll ());
272- app.setStyleSheet (style);
281+ if (!use_default_style)
282+ {
283+ SetDarkMode (app);
284+ // Load and apply the style sheet
285+ QFile style_sheet (" :/stylesheet.qss" );
286+ style_sheet.open (QFile::ReadOnly);
287+ QString style (style_sheet.readAll ());
288+ app.SetStyleSheet (style);
289+ }
290+ else
291+ {
292+ // Load and apply the style sheet
293+ QFile style_sheet (" :/stylesheet_adaptive.qss" );
294+ style_sheet.open (QFile::ReadOnly);
295+ QString style (style_sheet.readAll ());
296+ app.SetStyleSheet (style);
297+ }
273298
274299 // Display splash screen
275300 QSplashScreen *splash_screen = new QSplashScreen ();
@@ -285,6 +310,7 @@ int main(int argc, char *argv[])
285310 {
286311 QObject::connect (main_window, &MainWindow::FileLoaded, main_window, &MainWindow::close);
287312 }
313+ main_window->SetUseDefaultStyle (use_default_style);
288314
289315 if (!controller.InitializePlugins ())
290316 {
0 commit comments