1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2020, 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 |
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> |
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__) |
98 |
// Constructor. |
// Constructor. |
99 |
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
100 |
: QApplication(argc, argv), |
: QApplication(argc, argv), |
101 |
m_pQtTranslator(NULL), m_pMyTranslator(NULL), m_pWidget(NULL) |
m_pQtTranslator(nullptr), m_pMyTranslator(nullptr), m_pWidget(nullptr) |
102 |
{ |
{ |
103 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) |
104 |
|
QApplication::setApplicationName(QSAMPLER_TITLE); |
105 |
|
QApplication::setApplicationDisplayName(QSAMPLER_TITLE); |
106 |
|
// QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE)); |
107 |
|
#endif |
108 |
// Load translation support. |
// Load translation support. |
109 |
QLocale loc; |
QLocale loc; |
110 |
if (loc.language() != QLocale::C) { |
if (loc.language() != QLocale::C) { |
161 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
162 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
163 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
164 |
m_pDisplay = NULL; |
m_pDisplay = nullptr; |
165 |
m_aUnique = 0; |
m_aUnique = 0; |
166 |
m_wOwner = 0; |
m_wOwner = 0; |
167 |
#endif // CONFIG_X11 |
#endif // CONFIG_X11 |
168 |
#else |
#else |
169 |
m_pMemory = NULL; |
m_pMemory = nullptr; |
170 |
m_pServer = NULL; |
m_pServer = nullptr; |
171 |
#endif |
#endif |
172 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
173 |
} |
} |
181 |
if (m_pServer) { |
if (m_pServer) { |
182 |
m_pServer->close(); |
m_pServer->close(); |
183 |
delete m_pServer; |
delete m_pServer; |
184 |
m_pServer = NULL; |
m_pServer = nullptr; |
185 |
} |
} |
186 |
if (m_pMemory) { |
if (m_pMemory) { |
187 |
delete m_pMemory; |
delete m_pMemory; |
188 |
m_pMemory = NULL; |
m_pMemory = nullptr; |
189 |
} |
} |
190 |
#endif |
#endif |
191 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
395 |
if (pSocket) { |
if (pSocket) { |
396 |
const qint64 nread = pSocket->bytesAvailable(); |
const qint64 nread = pSocket->bytesAvailable(); |
397 |
if (nread > 0) { |
if (nread > 0) { |
398 |
QByteArray data = pSocket->read(nread); |
const QByteArray data = pSocket->read(nread); |
399 |
// Just make it always shows up fine... |
// Just make it always shows up fine... |
400 |
m_pWidget->hide(); |
m_pWidget->hide(); |
401 |
m_pWidget->show(); |
m_pWidget->show(); |
446 |
|
|
447 |
// Fork child... |
// Fork child... |
448 |
if (pid == 0) { |
if (pid == 0) { |
449 |
execl(shell, shell, "-c", cmd, NULL); |
execl(shell, shell, "-c", cmd, nullptr); |
450 |
_exit(1); |
_exit(1); |
451 |
return; |
return; |
452 |
} |
} |
483 |
::signal(SIGBUS, stacktrace); |
::signal(SIGBUS, stacktrace); |
484 |
#endif |
#endif |
485 |
#endif |
#endif |
|
qsamplerApplication app(argc, argv); |
|
486 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) |
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) |
487 |
app.setAttribute(Qt::AA_EnableHighDpiScaling); |
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
488 |
#endif |
#endif |
489 |
|
qsamplerApplication app(argc, argv); |
490 |
|
|
491 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
492 |
{ |
{ |
493 |
// Set the plugin path to @exetutable_path/../plugins |
// Set the plugin path to @exetutable_path/../plugins |
517 |
return 2; |
return 2; |
518 |
} |
} |
519 |
|
|
520 |
// Dark themes grayed/disabled color group fix... |
// Special custom styles... |
521 |
|
if (QDir(CONFIG_PLUGINSDIR).exists()) |
522 |
|
app.addLibraryPath(CONFIG_PLUGINSDIR); |
523 |
|
if (!options.sCustomStyleTheme.isEmpty()) |
524 |
|
app.setStyle(QStyleFactory::create(options.sCustomStyleTheme)); |
525 |
|
|
526 |
|
// Custom color theme (eg. "KXStudio")... |
527 |
QPalette pal(app.palette()); |
QPalette pal(app.palette()); |
528 |
if (pal.base().color().value() < 0x7f) { |
if (QSampler::PaletteForm::namedPalette( |
529 |
#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()); |
|
530 |
app.setPalette(pal); |
app.setPalette(pal); |
|
} |
|
531 |
|
|
532 |
// Set default base font... |
// Set default base font... |
533 |
if (options.iBaseFontSize > 0) |
if (options.iBaseFontSize > 0) |