/[svn]/qsampler/trunk/src/qsampler.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3558 by capela, Wed Aug 21 17:10:11 2019 UTC revision 3849 by capela, Thu Jan 7 16:18:02 2021 UTC
# Line 1  Line 1 
1  // qsampler.cpp  // qsampler.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007,2008,2015,2019 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 25  Line 25 
25  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
26  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
27    
28    #include "qsamplerPaletteForm.h"
29    
30    #include <QDir>
31    
32    #include <QStyleFactory>
33    
34  #include <QLibraryInfo>  #include <QLibraryInfo>
35  #include <QTranslator>  #include <QTranslator>
36  #include <QLocale>  #include <QLocale>
# Line 41  Line 47 
47  #define CONFIG_DATADIR  CONFIG_PREFIX "/share"  #define CONFIG_DATADIR  CONFIG_PREFIX "/share"
48  #endif  #endif
49    
50    #ifndef CONFIG_LIBDIR
51    #if defined(__x86_64__)
52    #define CONFIG_LIBDIR  CONFIG_PREFIX "/lib64"
53    #else
54    #define CONFIG_LIBDIR  CONFIG_PREFIX "/lib"
55    #endif
56    #endif
57    
58    #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
59    #define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt4/plugins"
60    #else
61    #define CONFIG_PLUGINSDIR CONFIG_LIBDIR "/qt5/plugins"
62    #endif
63    
64  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
65  #define RELATIVE_LOCALE_DIR "/share/locale"  #define RELATIVE_LOCALE_DIR "/share/locale"
66  #elif defined(__APPLE__)  #elif defined(__APPLE__)
# Line 82  qsamplerApplication::qsamplerApplication Line 102  qsamplerApplication::qsamplerApplication
102  {  {
103  #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)  #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
104          QApplication::setApplicationName(QSAMPLER_TITLE);          QApplication::setApplicationName(QSAMPLER_TITLE);
105          QApplication::setApplicationDisplayName(          QApplication::setApplicationDisplayName(QSAMPLER_TITLE);
106                  QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE));          //      QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE));
107  #endif  #endif
108          // Load translation support.          // Load translation support.
109          QLocale loc;          QLocale loc;
# Line 91  qsamplerApplication::qsamplerApplication Line 111  qsamplerApplication::qsamplerApplication
111                  // Try own Qt translation...                  // Try own Qt translation...
112                  m_pQtTranslator = new QTranslator(this);                  m_pQtTranslator = new QTranslator(this);
113                  QString sLocName = "qt_" + loc.name();                  QString sLocName = "qt_" + loc.name();
114            #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
115                    QString sLocPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
116            #else
117                  QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);                  QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
118            #endif
119                  if (m_pQtTranslator->load(sLocName, sLocPath)) {                  if (m_pQtTranslator->load(sLocName, sLocPath)) {
120                          QApplication::installTranslator(m_pQtTranslator);                          QApplication::installTranslator(m_pQtTranslator);
121                  } else {                  } else {
# Line 102  qsamplerApplication::qsamplerApplication Line 126  qsamplerApplication::qsamplerApplication
126                          } else {                          } else {
127                  #endif                  #endif
128                          delete m_pQtTranslator;                          delete m_pQtTranslator;
129                          m_pQtTranslator = 0;                          m_pQtTranslator = nullptr;
130                  #ifdef CONFIG_DEBUG                  #ifdef CONFIG_DEBUG
131                          qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",                          qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",
132                                  loc.name().toUtf8().constData(),                                  loc.name().toUtf8().constData(),
# Line 128  qsamplerApplication::qsamplerApplication Line 152  qsamplerApplication::qsamplerApplication
152                                  QApplication::installTranslator(m_pMyTranslator);                                  QApplication::installTranslator(m_pMyTranslator);
153                          } else {                          } else {
154                                  delete m_pMyTranslator;                                  delete m_pMyTranslator;
155                                  m_pMyTranslator = 0;                                  m_pMyTranslator = nullptr;
156                          #ifdef CONFIG_DEBUG                          #ifdef CONFIG_DEBUG
157                                  qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",                                  qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",
158                                          loc.name().toUtf8().constData(),                                          loc.name().toUtf8().constData(),
# Line 464  int main ( int argc, char **argv ) Line 488  int main ( int argc, char **argv )
488  #endif  #endif
489  #endif  #endif
490  #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)  #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
491    #if QT_VERSION <  QT_VERSION_CHECK(6, 0, 0)
492          QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);          QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
493  #endif  #endif
494    #endif
495          qsamplerApplication app(argc, argv);          qsamplerApplication app(argc, argv);
496    
497          #if defined(__APPLE__)  //  Toshi Nagata 20080105          #if defined(__APPLE__)  //  Toshi Nagata 20080105
# Line 497  int main ( int argc, char **argv ) Line 523  int main ( int argc, char **argv )
523                  return 2;                  return 2;
524          }          }
525    
526          // Dark themes grayed/disabled color group fix...          // Special custom styles...
527            if (QDir(CONFIG_PLUGINSDIR).exists())
528                    app.addLibraryPath(CONFIG_PLUGINSDIR);
529            if (!options.sCustomStyleTheme.isEmpty())
530                    app.setStyle(QStyleFactory::create(options.sCustomStyleTheme));
531    
532            // Custom color theme (eg. "KXStudio")...
533          QPalette pal(app.palette());          QPalette pal(app.palette());
534          if (pal.base().color().value() < 0x7f) {          if (QSampler::PaletteForm::namedPalette(
535          #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)                          &options.settings(), options.sCustomColorTheme, pal))
                 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());  
536                  app.setPalette(pal);                  app.setPalette(pal);
         }  
537    
538          // Set default base font...          // Set default base font...
539          if (options.iBaseFontSize > 0)          if (options.iBaseFontSize > 0)

Legend:
Removed from v.3558  
changed lines
  Added in v.3849

  ViewVC Help
Powered by ViewVC