1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007,2008,2015 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 |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
#include "qsamplerAbout.h" |
#include "qsampler.h" |
24 |
|
|
25 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
|
#include <QApplication> |
|
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 |
#ifndef CONFIG_PREFIX |
37 |
#define lighter(x) light(x) |
#define CONFIG_PREFIX "/usr/local" |
|
#define darker(x) dark(x) |
|
|
#endif |
|
|
|
|
|
#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" |
|
38 |
#endif |
#endif |
39 |
|
|
40 |
#if defined(LOCALEDIR) |
#ifndef CONFIG_DATADIR |
41 |
#define CONFIG_LOCALEDIR CONFIG_QUOTED(LOCALEDIR) |
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
|
#else |
|
|
#define CONFIG_LOCALEDIR CONFIG_DATADIR "/locale" |
|
42 |
#endif |
#endif |
43 |
|
|
44 |
#if WIN32 |
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) |
45 |
#define RELATIVE_LOCALE_DIR "/share/locale" |
#define RELATIVE_LOCALE_DIR "/share/locale" |
46 |
#elif defined(__APPLE__) |
#elif defined(__APPLE__) |
47 |
#define RELATIVE_LOCALE_DIR "/../Resources" |
#define RELATIVE_LOCALE_DIR "/../Resources" |
52 |
// Singleton application instance stuff (Qt/X11 only atm.) |
// Singleton application instance stuff (Qt/X11 only atm.) |
53 |
// |
// |
54 |
|
|
55 |
#if defined(Q_WS_X11) |
#ifdef CONFIG_XUNIQUE |
56 |
|
|
57 |
|
#define QSAMPLER_XUNIQUE "qsamplerApplication" |
58 |
|
|
59 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
60 |
|
#ifdef CONFIG_X11 |
61 |
|
|
62 |
#include <QX11Info> |
#include <unistd.h> /* for gethostname() */ |
63 |
|
|
64 |
#include <X11/Xatom.h> |
#include <X11/Xatom.h> |
65 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
66 |
|
|
67 |
#define QSAMPLER_XUNIQUE "qsamplerMainForm_xunique" |
#endif // CONFIG_X11 |
68 |
|
#else |
69 |
|
#include <QSharedMemory> |
70 |
|
#include <QLocalServer> |
71 |
|
#include <QLocalSocket> |
72 |
|
#include <QHostInfo> |
73 |
#endif |
#endif |
74 |
|
|
75 |
class qsamplerApplication : public QApplication |
#endif // CONFIG_XUNIQUE |
|
{ |
|
|
public: |
|
76 |
|
|
77 |
// Constructor. |
|
78 |
qsamplerApplication(int& argc, char **argv) : QApplication(argc, argv), |
// Constructor. |
79 |
m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0) |
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
80 |
{ |
: QApplication(argc, argv), |
81 |
// Load translation support. |
m_pQtTranslator(nullptr), m_pMyTranslator(nullptr), m_pWidget(nullptr) |
82 |
QLocale loc; |
{ |
83 |
if (loc.language() != QLocale::C) { |
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) |
84 |
// Try own Qt translation... |
QApplication::setApplicationName(QSAMPLER_TITLE); |
85 |
m_pQtTranslator = new QTranslator(this); |
QApplication::setApplicationDisplayName(QSAMPLER_TITLE); |
86 |
QString sLocName = "qt_" + loc.name(); |
// QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE)); |
87 |
QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
#endif |
88 |
|
// Load translation support. |
89 |
|
QLocale loc; |
90 |
|
if (loc.language() != QLocale::C) { |
91 |
|
// Try own Qt translation... |
92 |
|
m_pQtTranslator = new QTranslator(this); |
93 |
|
QString sLocName = "qt_" + loc.name(); |
94 |
|
QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
95 |
|
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
96 |
|
QApplication::installTranslator(m_pQtTranslator); |
97 |
|
} else { |
98 |
|
#ifdef RELATIVE_LOCALE_DIR |
99 |
|
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
100 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
101 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
102 |
} else { |
} else { |
|
#ifdef RELATIVE_LOCALE_DIR |
|
|
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
|
|
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
|
|
QApplication::installTranslator(m_pQtTranslator); |
|
|
} else { |
|
103 |
#endif |
#endif |
104 |
delete m_pQtTranslator; |
delete m_pQtTranslator; |
105 |
m_pQtTranslator = 0; |
m_pQtTranslator = 0; |
106 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
107 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
108 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
109 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
110 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
111 |
#endif |
#endif |
112 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
|
} |
|
|
#endif |
|
113 |
} |
} |
114 |
// Try own application translation... |
#endif |
115 |
m_pMyTranslator = new QTranslator(this); |
} |
116 |
sLocName = "qsampler_" + loc.name(); |
// Try own application translation... |
117 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
m_pMyTranslator = new QTranslator(this); |
118 |
QApplication::installTranslator(m_pMyTranslator); |
sLocName = "qsampler_" + loc.name(); |
119 |
} else { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
120 |
|
QApplication::installTranslator(m_pMyTranslator); |
121 |
|
} else { |
122 |
#ifdef RELATIVE_LOCALE_DIR |
#ifdef RELATIVE_LOCALE_DIR |
123 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
124 |
#else |
#else |
125 |
sLocPath = CONFIG_LOCALEDIR; |
sLocPath = CONFIG_DATADIR "/qsampler/translations"; |
126 |
#endif |
#endif |
127 |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
128 |
QApplication::installTranslator(m_pMyTranslator); |
QApplication::installTranslator(m_pMyTranslator); |
129 |
} else { |
} else { |
130 |
delete m_pMyTranslator; |
delete m_pMyTranslator; |
131 |
m_pMyTranslator = 0; |
m_pMyTranslator = 0; |
132 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
133 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
134 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
135 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
136 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
137 |
#endif |
#endif |
|
} |
|
138 |
} |
} |
139 |
} |
} |
|
#if defined(Q_WS_X11) |
|
|
m_pDisplay = QX11Info::display(); |
|
|
m_aUnique = XInternAtom(m_pDisplay, QSAMPLER_XUNIQUE, false); |
|
|
XGrabServer(m_pDisplay); |
|
|
m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique); |
|
|
XUngrabServer(m_pDisplay); |
|
|
#endif |
|
140 |
} |
} |
141 |
|
#ifdef CONFIG_XUNIQUE |
142 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
143 |
|
#ifdef CONFIG_X11 |
144 |
|
m_pDisplay = nullptr; |
145 |
|
m_aUnique = 0; |
146 |
|
m_wOwner = 0; |
147 |
|
#endif // CONFIG_X11 |
148 |
|
#else |
149 |
|
m_pMemory = nullptr; |
150 |
|
m_pServer = nullptr; |
151 |
|
#endif |
152 |
|
#endif // CONFIG_XUNIQUE |
153 |
|
} |
154 |
|
|
155 |
// Destructor. |
|
156 |
~qsamplerApplication() |
// Destructor. |
157 |
{ |
qsamplerApplication::~qsamplerApplication (void) |
158 |
if (m_pMyTranslator) delete m_pMyTranslator; |
{ |
159 |
if (m_pQtTranslator) delete m_pQtTranslator; |
#ifdef CONFIG_XUNIQUE |
160 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
161 |
|
if (m_pServer) { |
162 |
|
m_pServer->close(); |
163 |
|
delete m_pServer; |
164 |
|
m_pServer = nullptr; |
165 |
} |
} |
166 |
|
if (m_pMemory) { |
167 |
|
delete m_pMemory; |
168 |
|
m_pMemory = nullptr; |
169 |
|
} |
170 |
|
#endif |
171 |
|
#endif // CONFIG_XUNIQUE |
172 |
|
if (m_pMyTranslator) delete m_pMyTranslator; |
173 |
|
if (m_pQtTranslator) delete m_pQtTranslator; |
174 |
|
} |
175 |
|
|
176 |
// Main application widget accessors. |
|
177 |
void setMainWidget(QWidget *pWidget) |
// Main application widget accessors. |
178 |
{ |
void qsamplerApplication::setMainWidget ( QWidget *pWidget ) |
179 |
m_pWidget = pWidget; |
{ |
180 |
#if defined(Q_WS_X11) |
m_pWidget = pWidget; |
181 |
|
#ifdef CONFIG_XUNIQUE |
182 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
183 |
|
#ifdef CONFIG_X11 |
184 |
|
m_wOwner = m_pWidget->winId(); |
185 |
|
if (m_pDisplay && m_wOwner) { |
186 |
XGrabServer(m_pDisplay); |
XGrabServer(m_pDisplay); |
|
m_wOwner = m_pWidget->winId(); |
|
187 |
XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime); |
XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime); |
188 |
XUngrabServer(m_pDisplay); |
XUngrabServer(m_pDisplay); |
|
#endif |
|
189 |
} |
} |
190 |
|
#endif // CONFIG_X11 |
191 |
|
#endif |
192 |
|
#endif // CONFIG_XUNIQUE |
193 |
|
} |
194 |
|
|
|
QWidget *mainWidget() const { return m_pWidget; } |
|
195 |
|
|
196 |
// Check if another instance is running, |
// Check if another instance is running, |
197 |
// and raise its proper main widget... |
// and raise its proper main widget... |
198 |
bool setup() |
bool qsamplerApplication::setup (void) |
199 |
{ |
{ |
200 |
#if defined(Q_WS_X11) |
#ifdef CONFIG_XUNIQUE |
201 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
202 |
|
#ifdef CONFIG_X11 |
203 |
|
m_pDisplay = QX11Info::display(); |
204 |
|
if (m_pDisplay) { |
205 |
|
QString sUnique = QSAMPLER_XUNIQUE; |
206 |
|
char szHostName[255]; |
207 |
|
if (::gethostname(szHostName, sizeof(szHostName)) == 0) { |
208 |
|
sUnique += '@'; |
209 |
|
sUnique += szHostName; |
210 |
|
} |
211 |
|
m_aUnique = XInternAtom(m_pDisplay, sUnique.toUtf8().constData(), false); |
212 |
|
XGrabServer(m_pDisplay); |
213 |
|
m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique); |
214 |
|
XUngrabServer(m_pDisplay); |
215 |
if (m_wOwner != None) { |
if (m_wOwner != None) { |
216 |
// First, notify any freedesktop.org WM |
// First, notify any freedesktop.org WM |
217 |
// that we're about to show the main widget... |
// that we're about to show the main widget... |
235 |
XSync(m_pDisplay, false); |
XSync(m_pDisplay, false); |
236 |
XRaiseWindow(m_pDisplay, m_wOwner); |
XRaiseWindow(m_pDisplay, m_wOwner); |
237 |
// And then, let it get caught on destination |
// And then, let it get caught on destination |
238 |
// by QApplication::x11EventFilter... |
// by QApplication::native/x11EventFilter... |
239 |
QByteArray value = QSAMPLER_XUNIQUE; |
const QByteArray value = QSAMPLER_XUNIQUE; |
240 |
XChangeProperty( |
XChangeProperty( |
241 |
m_pDisplay, |
m_pDisplay, |
242 |
m_wOwner, |
m_wOwner, |
248 |
// Done. |
// Done. |
249 |
return true; |
return true; |
250 |
} |
} |
|
#endif |
|
|
return false; |
|
251 |
} |
} |
252 |
|
#endif // CONFIG_X11 |
253 |
#if defined(Q_WS_X11) |
return false; |
254 |
bool x11EventFilter(XEvent *pEv) |
#else |
255 |
{ |
m_sUnique = QCoreApplication::applicationName(); |
256 |
if (m_pWidget && m_wOwner != None |
m_sUnique += '@'; |
257 |
&& pEv->type == PropertyNotify |
m_sUnique += QHostInfo::localHostName(); |
258 |
&& pEv->xproperty.window == m_wOwner |
#ifdef Q_OS_UNIX |
259 |
&& pEv->xproperty.state == PropertyNewValue) { |
m_pMemory = new QSharedMemory(m_sUnique); |
260 |
// Always check whether our property-flag is still around... |
m_pMemory->attach(); |
261 |
Atom aType; |
delete m_pMemory; |
262 |
int iFormat = 0; |
#endif |
263 |
unsigned long iItems = 0; |
m_pMemory = new QSharedMemory(m_sUnique); |
264 |
unsigned long iAfter = 0; |
bool bServer = false; |
265 |
unsigned char *pData = 0; |
const qint64 pid = QCoreApplication::applicationPid(); |
266 |
if (XGetWindowProperty( |
struct Data { qint64 pid; }; |
267 |
m_pDisplay, |
if (m_pMemory->create(sizeof(Data))) { |
268 |
m_wOwner, |
m_pMemory->lock(); |
269 |
m_aUnique, |
Data *pData = static_cast<Data *> (m_pMemory->data()); |
270 |
0, 1024, |
if (pData) { |
271 |
false, |
pData->pid = pid; |
272 |
m_aUnique, |
bServer = true; |
|
&aType, |
|
|
&iFormat, |
|
|
&iItems, |
|
|
&iAfter, |
|
|
&pData) == Success |
|
|
&& aType == m_aUnique && iItems > 0 && iAfter == 0) { |
|
|
// Avoid repeating it-self... |
|
|
XDeleteProperty(m_pDisplay, m_wOwner, m_aUnique); |
|
|
// Just make it always shows up fine... |
|
|
m_pWidget->show(); |
|
|
m_pWidget->raise(); |
|
|
m_pWidget->activateWindow(); |
|
|
} |
|
|
// Free any left-overs... |
|
|
if (iItems > 0 && pData) |
|
|
XFree(pData); |
|
273 |
} |
} |
274 |
return QApplication::x11EventFilter(pEv); |
m_pMemory->unlock(); |
275 |
} |
} |
276 |
|
else |
277 |
|
if (m_pMemory->attach()) { |
278 |
|
m_pMemory->lock(); // maybe not necessary? |
279 |
|
Data *pData = static_cast<Data *> (m_pMemory->data()); |
280 |
|
if (pData) |
281 |
|
bServer = (pData->pid == pid); |
282 |
|
m_pMemory->unlock(); |
283 |
|
} |
284 |
|
if (bServer) { |
285 |
|
QLocalServer::removeServer(m_sUnique); |
286 |
|
m_pServer = new QLocalServer(); |
287 |
|
m_pServer->setSocketOptions(QLocalServer::UserAccessOption); |
288 |
|
m_pServer->listen(m_sUnique); |
289 |
|
QObject::connect(m_pServer, |
290 |
|
SIGNAL(newConnection()), |
291 |
|
SLOT(newConnectionSlot())); |
292 |
|
} else { |
293 |
|
QLocalSocket socket; |
294 |
|
socket.connectToServer(m_sUnique); |
295 |
|
if (socket.state() == QLocalSocket::ConnectingState) |
296 |
|
socket.waitForConnected(200); |
297 |
|
if (socket.state() == QLocalSocket::ConnectedState) { |
298 |
|
socket.write(QCoreApplication::arguments().join(' ').toUtf8()); |
299 |
|
socket.flush(); |
300 |
|
socket.waitForBytesWritten(200); |
301 |
|
} |
302 |
|
} |
303 |
|
return !bServer; |
304 |
#endif |
#endif |
305 |
|
#else |
306 |
private: |
return false; |
307 |
|
#endif // !CONFIG_XUNIQUE |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
// Translation support. |
#ifdef CONFIG_XUNIQUE |
312 |
QTranslator *m_pQtTranslator; |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
313 |
QTranslator *m_pMyTranslator; |
#ifdef CONFIG_X11 |
314 |
|
|
315 |
// Instance variables. |
void qsamplerApplication::x11PropertyNotify ( Window w ) |
316 |
QWidget *m_pWidget; |
{ |
317 |
|
if (m_pDisplay && m_pWidget && m_wOwner == w) { |
318 |
|
// Always check whether our property-flag is still around... |
319 |
|
Atom aType; |
320 |
|
int iFormat = 0; |
321 |
|
unsigned long iItems = 0; |
322 |
|
unsigned long iAfter = 0; |
323 |
|
unsigned char *pData = 0; |
324 |
|
if (XGetWindowProperty( |
325 |
|
m_pDisplay, |
326 |
|
m_wOwner, |
327 |
|
m_aUnique, |
328 |
|
0, 1024, |
329 |
|
false, |
330 |
|
m_aUnique, |
331 |
|
&aType, |
332 |
|
&iFormat, |
333 |
|
&iItems, |
334 |
|
&iAfter, |
335 |
|
&pData) == Success |
336 |
|
&& aType == m_aUnique && iItems > 0 && iAfter == 0) { |
337 |
|
// Avoid repeating it-self... |
338 |
|
XDeleteProperty(m_pDisplay, m_wOwner, m_aUnique); |
339 |
|
// Just make it always shows up fine... |
340 |
|
m_pWidget->show(); |
341 |
|
m_pWidget->raise(); |
342 |
|
m_pWidget->activateWindow(); |
343 |
|
} |
344 |
|
// Free any left-overs... |
345 |
|
if (iItems > 0 && pData) |
346 |
|
XFree(pData); |
347 |
|
} |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
bool qsamplerApplication::x11EventFilter ( XEvent *pEv ) |
352 |
|
{ |
353 |
|
if (pEv->type == PropertyNotify |
354 |
|
&& pEv->xproperty.state == PropertyNewValue) |
355 |
|
x11PropertyNotify(pEv->xproperty.window); |
356 |
|
return QApplication::x11EventFilter(pEv); |
357 |
|
} |
358 |
|
|
359 |
|
#endif // CONFIG_X11 |
360 |
|
#else |
361 |
|
|
362 |
|
// Local server conection slot. |
363 |
|
void qsamplerApplication::newConnectionSlot (void) |
364 |
|
{ |
365 |
|
QLocalSocket *pSocket = m_pServer->nextPendingConnection(); |
366 |
|
QObject::connect(pSocket, |
367 |
|
SIGNAL(readyRead()), |
368 |
|
SLOT(readyReadSlot())); |
369 |
|
} |
370 |
|
|
371 |
|
// Local server data-ready slot. |
372 |
|
void qsamplerApplication::readyReadSlot (void) |
373 |
|
{ |
374 |
|
QLocalSocket *pSocket = qobject_cast<QLocalSocket *> (sender()); |
375 |
|
if (pSocket) { |
376 |
|
const qint64 nread = pSocket->bytesAvailable(); |
377 |
|
if (nread > 0) { |
378 |
|
const QByteArray data = pSocket->read(nread); |
379 |
|
// Just make it always shows up fine... |
380 |
|
m_pWidget->hide(); |
381 |
|
m_pWidget->show(); |
382 |
|
m_pWidget->raise(); |
383 |
|
m_pWidget->activateWindow(); |
384 |
|
} |
385 |
|
} |
386 |
|
} |
387 |
|
|
|
#if defined(Q_WS_X11) |
|
|
Display *m_pDisplay; |
|
|
Atom m_aUnique; |
|
|
Window m_wOwner; |
|
388 |
#endif |
#endif |
389 |
}; |
#endif // CONFIG_XUNIQUE |
390 |
|
|
391 |
|
|
392 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
410 |
char cmd[80]; |
char cmd[80]; |
411 |
|
|
412 |
// Reinstall default handler; prevent race conditions... |
// Reinstall default handler; prevent race conditions... |
413 |
signal(signo, SIG_DFL); |
::signal(signo, SIG_DFL); |
414 |
|
|
415 |
static const char *shell = "/bin/sh"; |
static const char *shell = "/bin/sh"; |
416 |
static const char *format = "gdb -q --batch --pid=%d" |
static const char *format = "gdb -q --batch --pid=%d" |
426 |
|
|
427 |
// Fork child... |
// Fork child... |
428 |
if (pid == 0) { |
if (pid == 0) { |
429 |
execl(shell, shell, "-c", cmd, NULL); |
execl(shell, shell, "-c", cmd, nullptr); |
430 |
_exit(1); |
_exit(1); |
431 |
return; |
return; |
432 |
} |
} |
456 |
Q_INIT_RESOURCE(qsampler); |
Q_INIT_RESOURCE(qsampler); |
457 |
#ifdef CONFIG_STACKTRACE |
#ifdef CONFIG_STACKTRACE |
458 |
#if defined(__GNUC__) && defined(Q_OS_LINUX) |
#if defined(__GNUC__) && defined(Q_OS_LINUX) |
459 |
signal(SIGILL, stacktrace); |
::signal(SIGILL, stacktrace); |
460 |
signal(SIGFPE, stacktrace); |
::signal(SIGFPE, stacktrace); |
461 |
signal(SIGSEGV, stacktrace); |
::signal(SIGSEGV, stacktrace); |
462 |
signal(SIGABRT, stacktrace); |
::signal(SIGABRT, stacktrace); |
463 |
signal(SIGBUS, stacktrace); |
::signal(SIGBUS, stacktrace); |
464 |
|
#endif |
465 |
#endif |
#endif |
466 |
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) |
467 |
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
468 |
#endif |
#endif |
469 |
qsamplerApplication app(argc, argv); |
qsamplerApplication app(argc, argv); |
470 |
|
|
500 |
// Dark themes grayed/disabled color group fix... |
// Dark themes grayed/disabled color group fix... |
501 |
QPalette pal(app.palette()); |
QPalette pal(app.palette()); |
502 |
if (pal.base().color().value() < 0x7f) { |
if (pal.base().color().value() < 0x7f) { |
503 |
#if QT_VERSION >= 0x050000 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
504 |
const QColor& color = pal.window().color(); |
const QColor& color = pal.window().color(); |
505 |
const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; |
const int iGroups = int(QPalette::Active | QPalette::Inactive) + 1; |
506 |
for (int i = 0; i < iGroups; ++i) { |
for (int i = 0; i < iGroups; ++i) { |
527 |
} |
} |
528 |
|
|
529 |
// Set default base font... |
// Set default base font... |
|
int iBaseFontSize = app.font().pointSize(); |
|
530 |
if (options.iBaseFontSize > 0) |
if (options.iBaseFontSize > 0) |
531 |
iBaseFontSize = options.iBaseFontSize; |
app.setFont(QFont(app.font().family(), options.iBaseFontSize)); |
|
app.setFont(QFont(app.font().family(), iBaseFontSize)); |
|
532 |
|
|
533 |
// Construct, setup and show the main form. |
// Construct, setup and show the main form. |
534 |
QSampler::MainForm w; |
QSampler::MainForm w; |
546 |
|
|
547 |
|
|
548 |
// end of qsampler.cpp |
// end of qsampler.cpp |
549 |
|
|