1 |
// qsampler.cpp |
// qsampler.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2016, 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> |
33 |
#include <QDir> |
#include <QDir> |
34 |
#endif |
#endif |
35 |
|
|
36 |
#if WIN32 |
#ifndef CONFIG_PREFIX |
37 |
|
#define CONFIG_PREFIX "/usr/local" |
38 |
|
#endif |
39 |
|
|
40 |
|
#ifndef CONFIG_DATADIR |
41 |
|
#define CONFIG_DATADIR CONFIG_PREFIX "/share" |
42 |
|
#endif |
43 |
|
|
44 |
|
#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 QT_VERSION < 0x050000 |
#ifdef CONFIG_XUNIQUE |
|
#if defined(Q_WS_X11) |
|
|
#define CONFIG_X11 |
|
|
#endif |
|
|
#else |
|
|
#if defined(QT_X11EXTRAS_LIB) |
|
|
#define CONFIG_X11 |
|
|
#endif |
|
|
#endif |
|
56 |
|
|
57 |
|
#define QSAMPLER_XUNIQUE "qsamplerApplication" |
58 |
|
|
59 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
60 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_X11 |
|
#ifdef CONFIG_XUNIQUE |
|
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 "qsamplerApplication" |
#endif // CONFIG_X11 |
68 |
|
#else |
69 |
#if QT_VERSION >= 0x050100 |
#include <QSharedMemory> |
70 |
|
#include <QLocalServer> |
71 |
#include <xcb/xcb.h> |
#include <QLocalSocket> |
72 |
#include <xcb/xproto.h> |
#include <QHostInfo> |
|
|
|
|
#include <QAbstractNativeEventFilter> |
|
|
|
|
|
class qsamplerApplication; |
|
|
|
|
|
class qsamplerXcbEventFilter : public QAbstractNativeEventFilter |
|
|
{ |
|
|
public: |
|
|
|
|
|
// Constructor. |
|
|
qsamplerXcbEventFilter(qsamplerApplication *pApp) |
|
|
: QAbstractNativeEventFilter(), m_pApp(pApp) {} |
|
|
|
|
|
// XCB event filter (virtual processor). |
|
|
bool nativeEventFilter(const QByteArray& eventType, void *message, long *); |
|
|
|
|
|
private: |
|
|
|
|
|
// Instance variable. |
|
|
qsamplerApplication *m_pApp; |
|
|
}; |
|
|
|
|
73 |
#endif |
#endif |
74 |
|
|
75 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
|
#endif // CONFIG_X11 |
|
76 |
|
|
77 |
|
|
78 |
class qsamplerApplication : public QApplication |
// Constructor. |
79 |
|
qsamplerApplication::qsamplerApplication ( int& argc, char **argv ) |
80 |
|
: QApplication(argc, argv), |
81 |
|
m_pQtTranslator(NULL), m_pMyTranslator(NULL), m_pWidget(NULL) |
82 |
{ |
{ |
83 |
public: |
// Load translation support. |
84 |
|
QLocale loc; |
85 |
// Constructor. |
if (loc.language() != QLocale::C) { |
86 |
qsamplerApplication(int& argc, char **argv) : QApplication(argc, argv), |
// Try own Qt translation... |
87 |
m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0) |
m_pQtTranslator = new QTranslator(this); |
88 |
{ |
QString sLocName = "qt_" + loc.name(); |
89 |
// Load translation support. |
QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
90 |
QLocale loc; |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
91 |
if (loc.language() != QLocale::C) { |
QApplication::installTranslator(m_pQtTranslator); |
92 |
// Try own Qt translation... |
} else { |
93 |
m_pQtTranslator = new QTranslator(this); |
#ifdef RELATIVE_LOCALE_DIR |
94 |
QString sLocName = "qt_" + loc.name(); |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
|
QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
|
95 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
96 |
QApplication::installTranslator(m_pQtTranslator); |
QApplication::installTranslator(m_pQtTranslator); |
97 |
} else { |
} else { |
98 |
#ifdef RELATIVE_LOCALE_DIR |
#endif |
99 |
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
delete m_pQtTranslator; |
100 |
if (m_pQtTranslator->load(sLocName, sLocPath)) { |
m_pQtTranslator = 0; |
101 |
QApplication::installTranslator(m_pQtTranslator); |
#ifdef CONFIG_DEBUG |
102 |
} else { |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
103 |
#endif |
loc.name().toUtf8().constData(), |
104 |
delete m_pQtTranslator; |
sLocPath.toUtf8().constData(), |
105 |
m_pQtTranslator = 0; |
sLocName.toUtf8().constData()); |
106 |
|
#endif |
107 |
|
#ifdef RELATIVE_LOCALE_DIR |
108 |
|
} |
109 |
|
#endif |
110 |
|
} |
111 |
|
// Try own application translation... |
112 |
|
m_pMyTranslator = new QTranslator(this); |
113 |
|
sLocName = "qsampler_" + loc.name(); |
114 |
|
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
115 |
|
QApplication::installTranslator(m_pMyTranslator); |
116 |
|
} else { |
117 |
|
#ifdef RELATIVE_LOCALE_DIR |
118 |
|
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
119 |
|
#else |
120 |
|
sLocPath = CONFIG_DATADIR "/qsampler/translations"; |
121 |
|
#endif |
122 |
|
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
123 |
|
QApplication::installTranslator(m_pMyTranslator); |
124 |
|
} else { |
125 |
|
delete m_pMyTranslator; |
126 |
|
m_pMyTranslator = 0; |
127 |
#ifdef CONFIG_DEBUG |
#ifdef CONFIG_DEBUG |
128 |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
129 |
loc.name().toUtf8().constData(), |
loc.name().toUtf8().constData(), |
130 |
sLocPath.toUtf8().constData(), |
sLocPath.toUtf8().constData(), |
131 |
sLocName.toUtf8().constData()); |
sLocName.toUtf8().constData()); |
132 |
#endif |
#endif |
|
#ifdef RELATIVE_LOCALE_DIR |
|
|
} |
|
|
#endif |
|
|
} |
|
|
// Try own application translation... |
|
|
m_pMyTranslator = new QTranslator(this); |
|
|
sLocName = "qsampler_" + loc.name(); |
|
|
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
|
|
QApplication::installTranslator(m_pMyTranslator); |
|
|
} else { |
|
|
#ifdef RELATIVE_LOCALE_DIR |
|
|
sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR; |
|
|
#else |
|
|
sLocPath = CONFIG_DATADIR "/qsampler/translations"; |
|
|
#endif |
|
|
if (m_pMyTranslator->load(sLocName, sLocPath)) { |
|
|
QApplication::installTranslator(m_pMyTranslator); |
|
|
} else { |
|
|
delete m_pMyTranslator; |
|
|
m_pMyTranslator = 0; |
|
|
#ifdef CONFIG_DEBUG |
|
|
qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", |
|
|
loc.name().toUtf8().constData(), |
|
|
sLocPath.toUtf8().constData(), |
|
|
sLocName.toUtf8().constData()); |
|
|
#endif |
|
|
} |
|
133 |
} |
} |
134 |
} |
} |
|
#ifdef CONFIG_X11 |
|
|
#ifdef CONFIG_XUNIQUE |
|
|
// Instance uniqueness initialization... |
|
|
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); |
|
|
#if QT_VERSION >= 0x050100 |
|
|
m_pXcbEventFilter = new qsamplerXcbEventFilter(this); |
|
|
installNativeEventFilter(m_pXcbEventFilter); |
|
|
#endif |
|
|
#endif // CONFIG_XUNIQUE |
|
|
#endif // CONFIG_X11 |
|
135 |
} |
} |
136 |
|
#ifdef CONFIG_XUNIQUE |
137 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
138 |
|
#ifdef CONFIG_X11 |
139 |
|
m_pDisplay = NULL; |
140 |
|
m_aUnique = 0; |
141 |
|
m_wOwner = 0; |
142 |
|
#endif // CONFIG_X11 |
143 |
|
#else |
144 |
|
m_pMemory = NULL; |
145 |
|
m_pServer = NULL; |
146 |
|
#endif |
147 |
|
#endif // CONFIG_XUNIQUE |
148 |
|
} |
149 |
|
|
|
// Destructor. |
|
|
~qsamplerApplication() |
|
|
{ |
|
|
#ifdef CONFIG_X11 |
|
|
#ifdef CONFIG_XUNIQUE |
|
|
#if QT_VERSION >= 0x050100 |
|
|
removeNativeEventFilter(m_pXcbEventFilter); |
|
|
delete m_pXcbEventFilter; |
|
|
#endif |
|
|
#endif // CONFIG_XUNIQUE |
|
|
#endif // CONFIG_X11 |
|
|
if (m_pMyTranslator) delete m_pMyTranslator; |
|
|
if (m_pQtTranslator) delete m_pQtTranslator; |
|
|
} |
|
150 |
|
|
151 |
// Main application widget accessors. |
// Destructor. |
152 |
void setMainWidget(QWidget *pWidget) |
qsamplerApplication::~qsamplerApplication (void) |
153 |
{ |
{ |
154 |
m_pWidget = pWidget; |
#ifdef CONFIG_XUNIQUE |
155 |
#ifdef CONFIG_X11 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
156 |
#ifdef CONFIG_XUNIQUE |
if (m_pServer) { |
157 |
|
m_pServer->close(); |
158 |
|
delete m_pServer; |
159 |
|
m_pServer = NULL; |
160 |
|
} |
161 |
|
if (m_pMemory) { |
162 |
|
delete m_pMemory; |
163 |
|
m_pMemory = NULL; |
164 |
|
} |
165 |
|
#endif |
166 |
|
#endif // CONFIG_XUNIQUE |
167 |
|
if (m_pMyTranslator) delete m_pMyTranslator; |
168 |
|
if (m_pQtTranslator) delete m_pQtTranslator; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
// Main application widget accessors. |
173 |
|
void qsamplerApplication::setMainWidget ( QWidget *pWidget ) |
174 |
|
{ |
175 |
|
m_pWidget = pWidget; |
176 |
|
#ifdef CONFIG_XUNIQUE |
177 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
178 |
|
#ifdef CONFIG_X11 |
179 |
|
m_wOwner = m_pWidget->winId(); |
180 |
|
if (m_pDisplay && m_wOwner) { |
181 |
XGrabServer(m_pDisplay); |
XGrabServer(m_pDisplay); |
|
m_wOwner = m_pWidget->winId(); |
|
182 |
XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime); |
XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime); |
183 |
XUngrabServer(m_pDisplay); |
XUngrabServer(m_pDisplay); |
|
#endif // CONFIG_XUNIQUE |
|
|
#endif // CONFIG_X11 |
|
184 |
} |
} |
185 |
|
#endif // CONFIG_X11 |
186 |
|
#endif |
187 |
|
#endif // CONFIG_XUNIQUE |
188 |
|
} |
189 |
|
|
|
QWidget *mainWidget() const { return m_pWidget; } |
|
190 |
|
|
191 |
// Check if another instance is running, |
// Check if another instance is running, |
192 |
// and raise its proper main widget... |
// and raise its proper main widget... |
193 |
bool setup() |
bool qsamplerApplication::setup (void) |
194 |
{ |
{ |
195 |
#ifdef CONFIG_X11 |
#ifdef CONFIG_XUNIQUE |
196 |
#ifdef CONFIG_XUNIQUE |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
197 |
|
#ifdef CONFIG_X11 |
198 |
|
m_pDisplay = QX11Info::display(); |
199 |
|
if (m_pDisplay) { |
200 |
|
QString sUnique = QSAMPLER_XUNIQUE; |
201 |
|
char szHostName[255]; |
202 |
|
if (::gethostname(szHostName, sizeof(szHostName)) == 0) { |
203 |
|
sUnique += '@'; |
204 |
|
sUnique += szHostName; |
205 |
|
} |
206 |
|
m_aUnique = XInternAtom(m_pDisplay, sUnique.toUtf8().constData(), false); |
207 |
|
XGrabServer(m_pDisplay); |
208 |
|
m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique); |
209 |
|
XUngrabServer(m_pDisplay); |
210 |
if (m_wOwner != None) { |
if (m_wOwner != None) { |
211 |
// First, notify any freedesktop.org WM |
// First, notify any freedesktop.org WM |
212 |
// that we're about to show the main widget... |
// that we're about to show the main widget... |
243 |
// Done. |
// Done. |
244 |
return true; |
return true; |
245 |
} |
} |
|
#endif // CONFIG_XUNIQUE |
|
|
#endif // CONFIG_X11 |
|
|
return false; |
|
246 |
} |
} |
247 |
|
#endif // CONFIG_X11 |
248 |
#ifdef CONFIG_X11 |
return false; |
249 |
#ifdef CONFIG_XUNIQUE |
#else |
250 |
void x11PropertyNotify(Window w) |
m_sUnique = QCoreApplication::applicationName(); |
251 |
{ |
m_sUnique += '@'; |
252 |
if (m_pWidget && m_wOwner == w) { |
m_sUnique += QHostInfo::localHostName(); |
253 |
// Always check whether our property-flag is still around... |
#ifdef Q_OS_UNIX |
254 |
Atom aType; |
m_pMemory = new QSharedMemory(m_sUnique); |
255 |
int iFormat = 0; |
m_pMemory->attach(); |
256 |
unsigned long iItems = 0; |
delete m_pMemory; |
257 |
unsigned long iAfter = 0; |
#endif |
258 |
unsigned char *pData = 0; |
m_pMemory = new QSharedMemory(m_sUnique); |
259 |
if (XGetWindowProperty( |
bool bServer = false; |
260 |
m_pDisplay, |
const qint64 pid = QCoreApplication::applicationPid(); |
261 |
m_wOwner, |
struct Data { qint64 pid; }; |
262 |
m_aUnique, |
if (m_pMemory->create(sizeof(Data))) { |
263 |
0, 1024, |
m_pMemory->lock(); |
264 |
false, |
Data *pData = static_cast<Data *> (m_pMemory->data()); |
265 |
m_aUnique, |
if (pData) { |
266 |
&aType, |
pData->pid = pid; |
267 |
&iFormat, |
bServer = true; |
|
&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); |
|
268 |
} |
} |
269 |
|
m_pMemory->unlock(); |
270 |
} |
} |
271 |
#if QT_VERSION < 0x050000 |
else |
272 |
bool x11EventFilter(XEvent *pEv) |
if (m_pMemory->attach()) { |
273 |
{ |
m_pMemory->lock(); // maybe not necessary? |
274 |
if (pEv->type == PropertyNotify |
Data *pData = static_cast<Data *> (m_pMemory->data()); |
275 |
&& pEv->xproperty.state == PropertyNewValue) |
if (pData) |
276 |
x11PropertyNotify(pEv->xproperty.window); |
bServer = (pData->pid == pid); |
277 |
return QApplication::x11EventFilter(pEv); |
m_pMemory->unlock(); |
278 |
|
} |
279 |
|
if (bServer) { |
280 |
|
QLocalServer::removeServer(m_sUnique); |
281 |
|
m_pServer = new QLocalServer(); |
282 |
|
m_pServer->setSocketOptions(QLocalServer::UserAccessOption); |
283 |
|
m_pServer->listen(m_sUnique); |
284 |
|
QObject::connect(m_pServer, |
285 |
|
SIGNAL(newConnection()), |
286 |
|
SLOT(newConnectionSlot())); |
287 |
|
} else { |
288 |
|
QLocalSocket socket; |
289 |
|
socket.connectToServer(m_sUnique); |
290 |
|
if (socket.state() == QLocalSocket::ConnectingState) |
291 |
|
socket.waitForConnected(200); |
292 |
|
if (socket.state() == QLocalSocket::ConnectedState) { |
293 |
|
socket.write(QCoreApplication::arguments().join(' ').toUtf8()); |
294 |
|
socket.flush(); |
295 |
|
socket.waitForBytesWritten(200); |
296 |
|
} |
297 |
} |
} |
298 |
|
return !bServer; |
299 |
#endif |
#endif |
300 |
#endif // CONFIG_XUNIQUE |
#else |
301 |
#endif // CONFIG_X11 |
return false; |
302 |
|
#endif // !CONFIG_XUNIQUE |
303 |
private: |
} |
|
|
|
|
// Translation support. |
|
|
QTranslator *m_pQtTranslator; |
|
|
QTranslator *m_pMyTranslator; |
|
304 |
|
|
|
// Instance variables. |
|
|
QWidget *m_pWidget; |
|
305 |
|
|
|
#ifdef CONFIG_X11 |
|
306 |
#ifdef CONFIG_XUNIQUE |
#ifdef CONFIG_XUNIQUE |
307 |
Display *m_pDisplay; |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
308 |
Atom m_aUnique; |
#ifdef CONFIG_X11 |
309 |
Window m_wOwner; |
|
310 |
#if QT_VERSION >= 0x050100 |
void qsamplerApplication::x11PropertyNotify ( Window w ) |
311 |
qsamplerXcbEventFilter *m_pXcbEventFilter; |
{ |
312 |
#endif |
if (m_pDisplay && m_pWidget && m_wOwner == w) { |
313 |
#endif // CONFIG_XUNIQUE |
// Always check whether our property-flag is still around... |
314 |
|
Atom aType; |
315 |
|
int iFormat = 0; |
316 |
|
unsigned long iItems = 0; |
317 |
|
unsigned long iAfter = 0; |
318 |
|
unsigned char *pData = 0; |
319 |
|
if (XGetWindowProperty( |
320 |
|
m_pDisplay, |
321 |
|
m_wOwner, |
322 |
|
m_aUnique, |
323 |
|
0, 1024, |
324 |
|
false, |
325 |
|
m_aUnique, |
326 |
|
&aType, |
327 |
|
&iFormat, |
328 |
|
&iItems, |
329 |
|
&iAfter, |
330 |
|
&pData) == Success |
331 |
|
&& aType == m_aUnique && iItems > 0 && iAfter == 0) { |
332 |
|
// Avoid repeating it-self... |
333 |
|
XDeleteProperty(m_pDisplay, m_wOwner, m_aUnique); |
334 |
|
// Just make it always shows up fine... |
335 |
|
m_pWidget->show(); |
336 |
|
m_pWidget->raise(); |
337 |
|
m_pWidget->activateWindow(); |
338 |
|
} |
339 |
|
// Free any left-overs... |
340 |
|
if (iItems > 0 && pData) |
341 |
|
XFree(pData); |
342 |
|
} |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
bool qsamplerApplication::x11EventFilter ( XEvent *pEv ) |
347 |
|
{ |
348 |
|
if (pEv->type == PropertyNotify |
349 |
|
&& pEv->xproperty.state == PropertyNewValue) |
350 |
|
x11PropertyNotify(pEv->xproperty.window); |
351 |
|
return QApplication::x11EventFilter(pEv); |
352 |
|
} |
353 |
|
|
354 |
#endif // CONFIG_X11 |
#endif // CONFIG_X11 |
355 |
}; |
#else |
356 |
|
|
357 |
|
// Local server conection slot. |
358 |
|
void qsamplerApplication::newConnectionSlot (void) |
359 |
|
{ |
360 |
|
QLocalSocket *pSocket = m_pServer->nextPendingConnection(); |
361 |
|
QObject::connect(pSocket, |
362 |
|
SIGNAL(readyRead()), |
363 |
|
SLOT(readyReadSlot())); |
364 |
|
} |
365 |
|
|
366 |
#ifdef CONFIG_X11 |
// Local server data-ready slot. |
367 |
#ifdef CONFIG_XUNIQUE |
void qsamplerApplication::readyReadSlot (void) |
|
#if QT_VERSION >= 0x050100 |
|
|
// XCB Event filter (virtual processor). |
|
|
bool qsamplerXcbEventFilter::nativeEventFilter ( |
|
|
const QByteArray& eventType, void *message, long * ) |
|
368 |
{ |
{ |
369 |
if (eventType == "xcb_generic_event_t") { |
QLocalSocket *pSocket = qobject_cast<QLocalSocket *> (sender()); |
370 |
xcb_property_notify_event_t *pEv |
if (pSocket) { |
371 |
= static_cast<xcb_property_notify_event_t *> (message); |
const qint64 nread = pSocket->bytesAvailable(); |
372 |
if ((pEv->response_type & ~0x80) == XCB_PROPERTY_NOTIFY |
if (nread > 0) { |
373 |
&& pEv->state == XCB_PROPERTY_NEW_VALUE) |
QByteArray data = pSocket->read(nread); |
374 |
m_pApp->x11PropertyNotify(pEv->window); |
// Just make it always shows up fine... |
375 |
|
m_pWidget->hide(); |
376 |
|
m_pWidget->show(); |
377 |
|
m_pWidget->raise(); |
378 |
|
m_pWidget->activateWindow(); |
379 |
|
} |
380 |
} |
} |
|
return false; |
|
381 |
} |
} |
382 |
|
|
383 |
#endif |
#endif |
384 |
#endif // CONFIG_XUNIQUE |
#endif // CONFIG_XUNIQUE |
|
#endif // CONFIG_X11 |
|
385 |
|
|
386 |
|
|
387 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
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" |
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 >= QT_VERSION_CHECK(5, 6, 0) |
463 |
|
app.setAttribute(Qt::AA_EnableHighDpiScaling); |
464 |
|
#endif |
465 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
466 |
{ |
{ |
467 |
// Set the plugin path to @exetutable_path/../plugins |
// Set the plugin path to @exetutable_path/../plugins |
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) { |
540 |
|
|
541 |
|
|
542 |
// end of qsampler.cpp |
// end of qsampler.cpp |
543 |
|
|