--- qsampler/trunk/src/qsampler.cpp 2019/08/23 10:27:34 3560 +++ qsampler/trunk/src/qsampler.cpp 2020/09/17 16:34:38 3823 @@ -1,8 +1,8 @@ // qsampler.cpp // /**************************************************************************** - Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. - Copyright (C) 2007,2008,2015 Christian Schoenebeck + Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2007,2008,2015,2019 Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,6 +25,12 @@ #include "qsamplerOptions.h" #include "qsamplerMainForm.h" +#include "qsamplerPaletteForm.h" + +#include + +#include + #include #include #include @@ -41,6 +47,20 @@ #define CONFIG_DATADIR CONFIG_PREFIX "/share" #endif +#ifndef CONFIG_LIBDIR +#if defined(__x86_64__) +#define CONFIG_LIBDIR CONFIG_PREFIX "/lib64" +#else +#define CONFIG_LIBDIR CONFIG_PREFIX "/lib" +#endif +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt4/plugins" +#else +#define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt5/plugins" +#endif + #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) #define RELATIVE_LOCALE_DIR "/share/locale" #elif defined(__APPLE__) @@ -91,7 +111,11 @@ // Try own Qt translation... m_pQtTranslator = new QTranslator(this); QString sLocName = "qt_" + loc.name(); + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QString sLocPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath); + #else QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + #endif if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { @@ -464,8 +488,10 @@ #endif #endif #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif +#endif qsamplerApplication app(argc, argv); #if defined(__APPLE__) // Toshi Nagata 20080105 @@ -497,34 +523,17 @@ return 2; } - // Dark themes grayed/disabled color group fix... + // Special custom styles... + if (QDir(CONFIG_PLUGINSDIR).exists()) + app.addLibraryPath(CONFIG_PLUGINSDIR); + if (!options.sCustomStyleTheme.isEmpty()) + app.setStyle(QStyleFactory::create(options.sCustomStyleTheme)); + + // Custom color theme (eg. "KXStudio")... QPalette pal(app.palette()); - if (pal.base().color().value() < 0x7f) { - #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - const QColor& color = pal.window().color(); - const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; - for (int i = 0; i < iGroups; ++i) { - const QPalette::ColorGroup group = QPalette::ColorGroup(i); - pal.setBrush(group, QPalette::Light, color.lighter(150)); - pal.setBrush(group, QPalette::Midlight, color.lighter(120)); - pal.setBrush(group, QPalette::Dark, color.darker(150)); - pal.setBrush(group, QPalette::Mid, color.darker(120)); - pal.setBrush(group, QPalette::Shadow, color.darker(200)); - } - // pal.setColor(QPalette::Disabled, QPalette::ButtonText, pal.mid().color()); - #endif - pal.setColorGroup(QPalette::Disabled, - pal.windowText().color().darker(), - pal.button(), - pal.light(), - pal.dark(), - pal.mid(), - pal.text().color().darker(), - pal.text().color().lighter(), - pal.base(), - pal.window()); + if (QSampler::PaletteForm::namedPalette( + &options.settings(), options.sCustomColorTheme, pal)) app.setPalette(pal); - } // Set default base font... if (options.iBaseFontSize > 0)