1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 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 |
28 |
#include <QLibraryInfo> |
#include <QLibraryInfo> |
29 |
#include <QTranslator> |
#include <QTranslator> |
30 |
#include <QLocale> |
#include <QLocale> |
31 |
|
|
32 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
33 |
#include <QDir> |
#include <QDir> |
34 |
#endif |
#endif |
35 |
|
|
36 |
#if QT_VERSION < 0x040300 |
#define CONFIG_QUOTE1(x) #x |
37 |
#define lighter(x) light(x) |
#define CONFIG_QUOTED(x) CONFIG_QUOTE1(x) |
38 |
#define darker(x) dark(x) |
|
39 |
|
#if defined(DATADIR) |
40 |
|
#define CONFIG_DATADIR CONFIG_QUOTED(DATADIR) |
41 |
|
#else |
42 |
|
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
43 |
#endif |
#endif |
44 |
|
|
45 |
#if WIN32 |
#if WIN32 |
82 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
83 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
84 |
} else { |
} else { |
85 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
86 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
87 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
88 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
89 |
} else { |
} else { |
90 |
#endif |
#endif |
91 |
delete m_pQtTranslator; |
delete m_pQtTranslator; |
92 |
m_pQtTranslator = 0; |
m_pQtTranslator = 0; |
93 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
94 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
95 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
96 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
97 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
98 |
#endif |
#endif |
99 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
100 |
} |
} |
101 |
#endif |
#endif |
102 |
} |
} |
103 |
// Try own application translation... |
// Try own application translation... |
104 |
m_pMyTranslator = new QTranslator(this); |
m_pMyTranslator = new QTranslator(this); |
106 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
107 |
QApplication::installTranslator(m_pMyTranslator); |
QApplication::installTranslator(m_pMyTranslator); |
108 |
} else { |
} else { |
109 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
110 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
111 |
#else |
#else |
112 |
sLocPath = CONFIG_PREFIX "/share/locale"; |
sLocPath = CONFIG_DATADIR "/qsampler/translations"; |
113 |
#endif |
#endif |
114 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
115 |
QApplication::installTranslator(m_pMyTranslator); |
QApplication::installTranslator(m_pMyTranslator); |
116 |
} else { |
} else { |
117 |
delete m_pMyTranslator; |
delete m_pMyTranslator; |
118 |
m_pMyTranslator = 0; |
m_pMyTranslator = 0; |
119 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
120 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
121 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
122 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
123 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
124 |
#endif |
#endif |
125 |
} |
} |
126 |
} |
} |
127 |
} |
} |
268 |
#include <stdio.h> |
#include <stdio.h> |
269 |
#include <errno.h> |
#include <errno.h> |
270 |
#include <signal.h> |
#include <signal.h> |
271 |
|
#include <unistd.h> |
272 |
#include <sys/wait.h> |
#include <sys/wait.h> |
273 |
|
|
274 |
void stacktrace ( int signo ) |
void stacktrace ( int signo ) |
366 |
// Dark themes grayed/disabled color group fix... |
// Dark themes grayed/disabled color group fix... |
367 |
QPalette pal(app.palette()); |
QPalette pal(app.palette()); |
368 |
if (pal.base().color().value() < 0x7f) { |
if (pal.base().color().value() < 0x7f) { |
369 |
|
#if QT_VERSION >= 0x050000 |
370 |
|
const QColor& color = pal.window().color(); |
371 |
|
const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; |
372 |
|
for (int i = 0; i < iGroups; ++i) { |
373 |
|
const QPalette::ColorGroup group = QPalette::ColorGroup(i); |
374 |
|
pal.setBrush(group, QPalette::Light, color.lighter(150)); |
375 |
|
pal.setBrush(group, QPalette::Midlight, color.lighter(120)); |
376 |
|
pal.setBrush(group, QPalette::Dark, color.darker(150)); |
377 |
|
pal.setBrush(group, QPalette::Mid, color.darker(120)); |
378 |
|
pal.setBrush(group, QPalette::Shadow, color.darker(200)); |
379 |
|
} |
380 |
|
// pal.setColor(QPalette::Disabled, QPalette::ButtonText, pal.mid().color()); |
381 |
|
#endif |
382 |
pal.setColorGroup(QPalette::Disabled, |
pal.setColorGroup(QPalette::Disabled, |
383 |
pal.windowText().color().darker(), |
pal.windowText().color().darker(), |
384 |
pal.button(), |
pal.button(), |