--- qsampler/trunk/src/qsampler.cpp 2011/07/18 08:18:36 2210 +++ qsampler/trunk/src/qsampler.cpp 2014/10/09 08:50:14 2677 @@ -1,7 +1,7 @@ // qsampler.cpp // /**************************************************************************** - Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2007, 2008 Christian Schoenebeck This program is free software; you can redistribute it and/or @@ -28,13 +28,18 @@ #include #include #include + #if defined(__APPLE__) // Toshi Nagata 20080105 #include #endif -#if QT_VERSION < 0x040300 -#define lighter(x) light(x) -#define darker(x) dark(x) +#define CONFIG_QUOTE1(x) #x +#define CONFIG_QUOTED(x) CONFIG_QUOTE1(x) + +#if defined(DATADIR) +#define CONFIG_DATADIR CONFIG_QUOTED(DATADIR) +#else +#define CONFIG_DATADIR CONFIG_PREFIX "/share" #endif #if WIN32 @@ -77,23 +82,23 @@ if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { - #ifdef RELATIVE_LOCALE_DIR + #ifdef RELATIVE_LOCALE_DIR sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { - #endif + #endif delete m_pQtTranslator; m_pQtTranslator = 0; - #ifdef CONFIG_DEBUG + #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toUtf8().constData(), sLocPath.toUtf8().constData(), sLocName.toUtf8().constData()); - #endif - #ifdef RELATIVE_LOCALE_DIR + #endif + #ifdef RELATIVE_LOCALE_DIR } - #endif + #endif } // Try own application translation... m_pMyTranslator = new QTranslator(this); @@ -101,22 +106,22 @@ if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { - #ifdef RELATIVE_LOCALE_DIR + #ifdef RELATIVE_LOCALE_DIR sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; - #else - sLocPath = CONFIG_PREFIX "/share/locale"; - #endif + #else + sLocPath = CONFIG_DATADIR "/qsampler/translations"; + #endif if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { delete m_pMyTranslator; m_pMyTranslator = 0; - #ifdef CONFIG_DEBUG + #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toUtf8().constData(), sLocPath.toUtf8().constData(), sLocName.toUtf8().constData()); - #endif + #endif } } } @@ -263,6 +268,7 @@ #include #include #include +#include #include void stacktrace ( int signo ) @@ -360,6 +366,19 @@ // Dark themes grayed/disabled color group fix... QPalette pal(app.palette()); if (pal.base().color().value() < 0x7f) { + #if QT_VERSION >= 0x050000 + 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(), @@ -374,10 +393,8 @@ } // Set default base font... - int iBaseFontSize = app.font().pointSize(); if (options.iBaseFontSize > 0) - iBaseFontSize = options.iBaseFontSize; - app.setFont(QFont(app.font().family(), iBaseFontSize)); + app.setFont(QFont(app.font().family(), options.iBaseFontSize)); // Construct, setup and show the main form. QSampler::MainForm w;