56 |
|
|
57 |
#define QSAMPLER_XUNIQUE "qsamplerApplication" |
#define QSAMPLER_XUNIQUE "qsamplerApplication" |
58 |
|
|
59 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
60 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
61 |
|
|
62 |
#include <unistd.h> /* for gethostname() */ |
#include <unistd.h> /* for gethostname() */ |
78 |
// Constructor. |
// Constructor. |
79 |
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
80 |
: QApplication(argc, argv), |
: QApplication(argc, argv), |
81 |
m_pQtTranslator(NULL), m_pMyTranslator(NULL), m_pWidget(NULL) |
m_pQtTranslator(nullptr), m_pMyTranslator(nullptr), m_pWidget(nullptr) |
82 |
{ |
{ |
83 |
// Load translation support. |
// Load translation support. |
84 |
QLocale loc; |
QLocale loc; |
134 |
} |
} |
135 |
} |
} |
136 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
137 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
138 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
139 |
m_pDisplay = NULL; |
m_pDisplay = nullptr; |
140 |
m_aUnique = 0; |
m_aUnique = 0; |
141 |
m_wOwner = 0; |
m_wOwner = 0; |
142 |
#endif // CONFIG_X11 |
#endif // CONFIG_X11 |
143 |
#else |
#else |
144 |
m_pMemory = NULL; |
m_pMemory = nullptr; |
145 |
m_pServer = NULL; |
m_pServer = nullptr; |
146 |
#endif |
#endif |
147 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
148 |
} |
} |
152 |
qsamplerApplication::~qsamplerApplication (void) |
qsamplerApplication::~qsamplerApplication (void) |
153 |
{ |
{ |
154 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
155 |
#if QT_VERSION >= 0x050000 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
156 |
if (m_pServer) { |
if (m_pServer) { |
157 |
m_pServer->close(); |
m_pServer->close(); |
158 |
delete m_pServer; |
delete m_pServer; |
159 |
m_pServer = NULL; |
m_pServer = nullptr; |
160 |
} |
} |
161 |
if (m_pMemory) { |
if (m_pMemory) { |
162 |
delete m_pMemory; |
delete m_pMemory; |
163 |
m_pMemory = NULL; |
m_pMemory = nullptr; |
164 |
} |
} |
165 |
#endif |
#endif |
166 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
174 |
{ |
{ |
175 |
m_pWidget = pWidget; |
m_pWidget = pWidget; |
176 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
177 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
178 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
179 |
m_wOwner = m_pWidget->winId(); |
m_wOwner = m_pWidget->winId(); |
180 |
if (m_pDisplay && m_wOwner) { |
if (m_pDisplay && m_wOwner) { |
193 |
bool qsamplerApplication::setup (void) |
bool qsamplerApplication::setup (void) |
194 |
{ |
{ |
195 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
196 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
197 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
198 |
m_pDisplay = QX11Info::display(); |
m_pDisplay = QX11Info::display(); |
199 |
if (m_pDisplay) { |
if (m_pDisplay) { |
304 |
|
|
305 |
|
|
306 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
307 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
308 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
309 |
|
|
310 |
void qsamplerApplication::x11PropertyNotify ( Window w ) |
void qsamplerApplication::x11PropertyNotify ( Window w ) |
370 |
if (pSocket) { |
if (pSocket) { |
371 |
const qint64 nread = pSocket->bytesAvailable(); |
const qint64 nread = pSocket->bytesAvailable(); |
372 |
if (nread > 0) { |
if (nread > 0) { |
373 |
QByteArray data = pSocket->read(nread); |
const QByteArray data = pSocket->read(nread); |
374 |
// Just make it always shows up fine... |
// Just make it always shows up fine... |
375 |
m_pWidget->hide(); |
m_pWidget->hide(); |
376 |
m_pWidget->show(); |
m_pWidget->show(); |
405 |
char cmd[80]; |
char cmd[80]; |
406 |
|
|
407 |
// Reinstall default handler; prevent race conditions... |
// Reinstall default handler; prevent race conditions... |
408 |
signal(signo, SIG_DFL); |
::signal(signo, SIG_DFL); |
409 |
|
|
410 |
static const char *shell = "/bin/sh"; |
static const char *shell = "/bin/sh"; |
411 |
static const char *format = "gdb -q --batch --pid=%d" |
static const char *format = "gdb -q --batch --pid=%d" |
421 |
|
|
422 |
// Fork child... |
// Fork child... |
423 |
if (pid == 0) { |
if (pid == 0) { |
424 |
execl(shell, shell, "-c", cmd, NULL); |
execl(shell, shell, "-c", cmd, nullptr); |
425 |
_exit(1); |
_exit(1); |
426 |
return; |
return; |
427 |
} |
} |
451 |
Q_INIT_RESOURCE(qsampler); |
Q_INIT_RESOURCE(qsampler); |
452 |
#ifdef CONFIG_STACKTRACE |
#ifdef CONFIG_STACKTRACE |
453 |
#if defined(__GNUC__) && defined(Q_OS_LINUX) |
#if defined(__GNUC__) && defined(Q_OS_LINUX) |
454 |
signal(SIGILL, stacktrace); |
::signal(SIGILL, stacktrace); |
455 |
signal(SIGFPE, stacktrace); |
::signal(SIGFPE, stacktrace); |
456 |
signal(SIGSEGV, stacktrace); |
::signal(SIGSEGV, stacktrace); |
457 |
signal(SIGABRT, stacktrace); |
::signal(SIGABRT, stacktrace); |
458 |
signal(SIGBUS, stacktrace); |
::signal(SIGBUS, stacktrace); |
459 |
#endif |
#endif |
460 |
#endif |
#endif |
461 |
qsamplerApplication app(argc, argv); |
qsamplerApplication app(argc, argv); |
462 |
#if QT_VERSION >= 0x050600 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) |
463 |
app.setAttribute(Qt::AA_EnableHighDpiScaling); |
app.setAttribute(Qt::AA_EnableHighDpiScaling); |
464 |
#endif |
#endif |
465 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
494 |
// Dark themes grayed/disabled color group fix... |
// Dark themes grayed/disabled color group fix... |
495 |
QPalette pal(app.palette()); |
QPalette pal(app.palette()); |
496 |
if (pal.base().color().value() < 0x7f) { |
if (pal.base().color().value() < 0x7f) { |
497 |
#if QT_VERSION >= 0x050000 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
498 |
const QColor& color = pal.window().color(); |
const QColor& color = pal.window().color(); |
499 |
const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; |
const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; |
500 |
for (int i = 0; i < iGroups; ++i) { |
for (int i = 0; i < iGroups; ++i) { |