1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2022, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2008,2015,2019 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 |
35 |
#include <QTranslator> |
#include <QTranslator> |
36 |
#include <QLocale> |
#include <QLocale> |
37 |
|
|
38 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) |
39 |
|
#include <lscp/client.h> |
40 |
|
#ifdef CONFIG_LIBGIG |
41 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
42 |
|
#pragma GCC diagnostic push |
43 |
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
44 |
|
#endif |
45 |
|
#include <gig.h> |
46 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
47 |
|
#pragma GCC diagnostic pop |
48 |
|
#endif |
49 |
|
#endif |
50 |
|
#endif |
51 |
|
|
52 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
53 |
#include <QDir> |
#include <QDir> |
54 |
#endif |
#endif |
57 |
#define CONFIG_PREFIX "/usr/local" |
#define CONFIG_PREFIX "/usr/local" |
58 |
#endif |
#endif |
59 |
|
|
60 |
|
#ifndef CONFIG_BINDIR |
61 |
|
#define CONFIG_BINDIR CONFIG_PREFIX "/bin" |
62 |
|
#endif |
63 |
|
|
64 |
#ifndef CONFIG_DATADIR |
#ifndef CONFIG_DATADIR |
65 |
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
66 |
#endif |
#endif |
124 |
QApplication::setApplicationName(QSAMPLER_TITLE); |
QApplication::setApplicationName(QSAMPLER_TITLE); |
125 |
QApplication::setApplicationDisplayName(QSAMPLER_TITLE); |
QApplication::setApplicationDisplayName(QSAMPLER_TITLE); |
126 |
// QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE)); |
// QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE)); |
127 |
|
QString sVersion(CONFIG_BUILD_VERSION); |
128 |
|
sVersion += '\n'; |
129 |
|
sVersion += QString("Qt: %1").arg(qVersion()); |
130 |
|
#if defined(QT_STATIC) |
131 |
|
sVersion += "-static"; |
132 |
|
#endif |
133 |
|
sVersion += '\n'; |
134 |
|
#ifdef CONFIG_LIBGIG |
135 |
|
sVersion += QString("%1: %2") |
136 |
|
.arg(gig::libraryName().c_str()) |
137 |
|
.arg(gig::libraryVersion().c_str()); |
138 |
|
sVersion += '\n'; |
139 |
|
#endif |
140 |
|
sVersion += QString("%1: %2") |
141 |
|
.arg(::lscp_client_package()) |
142 |
|
.arg(::lscp_client_version()); |
143 |
|
QApplication::setApplicationVersion(sVersion); |
144 |
#endif |
#endif |
145 |
// Load translation support. |
// Load translation support. |
146 |
QLocale loc; |
QLocale loc; |
156 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
157 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
158 |
} else { |
} else { |
159 |
|
sLocPath = QApplication::applicationDirPath(); |
160 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
161 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath.append(RELATIVE_LOCALE_DIR); |
162 |
|
#else |
163 |
|
sLocPath.remove(CONFIG_BINDIR); |
164 |
|
sLocPath.append(CONFIG_DATADIR "/qsampler/translations"); |
165 |
|
#endif |
166 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
167 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
168 |
} else { |
} else { |
169 |
#endif |
delete m_pQtTranslator; |
170 |
delete m_pQtTranslator; |
m_pQtTranslator = nullptr; |
171 |
m_pQtTranslator = nullptr; |
#ifdef CONFIG_DEBUG |
172 |
#ifdef CONFIG_DEBUG |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
173 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
loc.name().toUtf8().constData(), |
174 |
loc.name().toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
175 |
sLocPath.toUtf8().constData(), |
sLocName.toUtf8().constData()); |
176 |
sLocName.toUtf8().constData()); |
#endif |
|
#endif |
|
|
#ifdef RELATIVE_LOCALE_DIR |
|
177 |
} |
} |
|
#endif |
|
178 |
} |
} |
179 |
// Try own application translation... |
// Try own application translation... |
180 |
m_pMyTranslator = new QTranslator(this); |
m_pMyTranslator = new QTranslator(this); |