/[svn]/qsampler/trunk/src/qsampler.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2839 by capela, Tue Aug 25 18:36:55 2015 UTC revision 3560 by capela, Fri Aug 23 10:27:34 2019 UTC
# Line 1  Line 1 
1  // qsampler.cpp  // qsampler.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2015, 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
# Line 20  Line 20 
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>
# Line 33  Line 33 
33  #include <QDir>  #include <QDir>
34  #endif  #endif
35    
36  #define CONFIG_QUOTE1(x) #x  #ifndef CONFIG_PREFIX
37  #define CONFIG_QUOTED(x) CONFIG_QUOTE1(x)  #define CONFIG_PREFIX   "/usr/local"
38    #endif
39    
40  #if defined(DATADIR)  #ifndef CONFIG_DATADIR
41  #define CONFIG_DATADIR CONFIG_QUOTED(DATADIR)  #define CONFIG_DATADIR  CONFIG_PREFIX "/share"
 #else  
 #define CONFIG_DATADIR CONFIG_PREFIX "/share"  
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"
# Line 53  Line 52 
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(nullptr), m_pMyTranslator(nullptr), m_pWidget(nullptr)
82  {  {
83  public:  #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
84            QApplication::setApplicationName(QSAMPLER_TITLE);
85          // Constructor.          QApplication::setApplicationDisplayName(QSAMPLER_TITLE);
86          qsamplerApplication(int& argc, char **argv) : QApplication(argc, argv),          //      QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE));
87                  m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0)  #endif
88          {          // Load translation support.
89                  // Load translation support.          QLocale loc;
90                  QLocale loc;          if (loc.language() != QLocale::C) {
91                  if (loc.language() != QLocale::C) {                  // Try own Qt translation...
92                          // Try own Qt translation...                  m_pQtTranslator = new QTranslator(this);
93                          m_pQtTranslator = new QTranslator(this);                  QString sLocName = "qt_" + loc.name();
94                          QString sLocName = "qt_" + loc.name();                  QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
95                          QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);                  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 {
103                          #ifdef RELATIVE_LOCALE_DIR                  #endif
104                                  sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;                          delete m_pQtTranslator;
105                                  if (m_pQtTranslator->load(sLocName, sLocPath)) {                          m_pQtTranslator = 0;
106                                          QApplication::installTranslator(m_pQtTranslator);                  #ifdef CONFIG_DEBUG
107                                  } else {                          qWarning("Warning: no translation found for '%s' locale: %s/%s.qm",
108                          #endif                                  loc.name().toUtf8().constData(),
109                                  delete m_pQtTranslator;                                  sLocPath.toUtf8().constData(),
110                                  m_pQtTranslator = 0;                                  sLocName.toUtf8().constData());
111                    #endif
112                    #ifdef RELATIVE_LOCALE_DIR
113                            }
114                    #endif
115                    }
116                    // Try own application translation...
117                    m_pMyTranslator = new QTranslator(this);
118                    sLocName = "qsampler_" + loc.name();
119                    if (m_pMyTranslator->load(sLocName, sLocPath)) {
120                            QApplication::installTranslator(m_pMyTranslator);
121                    } else {
122                    #ifdef RELATIVE_LOCALE_DIR
123                            sLocPath = QApplication::applicationDirPath() + RELATIVE_LOCALE_DIR;
124                    #else
125                            sLocPath = CONFIG_DATADIR "/qsampler/translations";
126                    #endif
127                            if (m_pMyTranslator->load(sLocName, sLocPath)) {
128                                    QApplication::installTranslator(m_pMyTranslator);
129                            } else {
130                                    delete m_pMyTranslator;
131                                    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
                         #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  
                                 }  
138                          }                          }
139                  }                  }
         #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  
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    
         // 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;  
         }  
155    
156          // Main application widget accessors.  // Destructor.
157          void setMainWidget(QWidget *pWidget)  qsamplerApplication::~qsamplerApplication (void)
158          {  {
159                  m_pWidget = pWidget;  #ifdef CONFIG_XUNIQUE
160          #ifdef CONFIG_X11  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
161          #ifdef CONFIG_XUNIQUE          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    
177    // Main application widget accessors.
178    void qsamplerApplication::setMainWidget ( QWidget *pWidget )
179    {
180            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  // CONFIG_XUNIQUE  
         #endif  // CONFIG_X11  
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          #ifdef CONFIG_X11  #ifdef CONFIG_XUNIQUE
201          #ifdef CONFIG_XUNIQUE  #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...
# Line 256  public: Line 248  public:
248                          // Done.                          // Done.
249                          return true;                          return true;
250                  }                  }
         #endif  // CONFIG_XUNIQUE  
         #endif  // CONFIG_X11  
                 return false;  
251          }          }
252    #endif  // CONFIG_X11
253  #ifdef CONFIG_X11          return false;
254  #ifdef CONFIG_XUNIQUE  #else
255          void x11PropertyNotify(Window w)          m_sUnique = QCoreApplication::applicationName();
256          {          m_sUnique += '@';
257                  if (m_pWidget && m_wOwner == w) {          m_sUnique += QHostInfo::localHostName();
258                          // Always check whether our property-flag is still around...  #ifdef Q_OS_UNIX
259                          Atom aType;          m_pMemory = new QSharedMemory(m_sUnique);
260                          int iFormat = 0;          m_pMemory->attach();
261                          unsigned long iItems = 0;          delete m_pMemory;
262                          unsigned long iAfter = 0;  #endif
263                          unsigned char *pData = 0;          m_pMemory = new QSharedMemory(m_sUnique);
264                          if (XGetWindowProperty(          bool bServer = false;
265                                          m_pDisplay,          const qint64 pid = QCoreApplication::applicationPid();
266                                          m_wOwner,          struct Data { qint64 pid; };
267                                          m_aUnique,          if (m_pMemory->create(sizeof(Data))) {
268                                          0, 1024,                  m_pMemory->lock();
269                                          false,                  Data *pData = static_cast<Data *> (m_pMemory->data());
270                                          m_aUnique,                  if (pData) {
271                                          &aType,                          pData->pid = pid;
272                                          &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);  
273                  }                  }
274                    m_pMemory->unlock();
275          }          }
276  #if QT_VERSION < 0x050000          else
277          bool x11EventFilter(XEvent *pEv)          if (m_pMemory->attach()) {
278          {                  m_pMemory->lock(); // maybe not necessary?
279                  if (pEv->type == PropertyNotify                  Data *pData = static_cast<Data *> (m_pMemory->data());
280                          && pEv->xproperty.state == PropertyNewValue)                  if (pData)
281                          x11PropertyNotify(pEv->xproperty.window);                          bServer = (pData->pid == pid);
282                  return QApplication::x11EventFilter(pEv);                  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  #endif  // CONFIG_XUNIQUE  #else
306  #endif  // CONFIG_X11          return false;
307            #endif  // !CONFIG_XUNIQUE
308  private:  }
   
         // Translation support.  
         QTranslator *m_pQtTranslator;  
         QTranslator *m_pMyTranslator;  
309    
         // Instance variables.  
         QWidget *m_pWidget;  
310    
 #ifdef CONFIG_X11  
311  #ifdef CONFIG_XUNIQUE  #ifdef CONFIG_XUNIQUE
312          Display *m_pDisplay;  #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
313          Atom     m_aUnique;  #ifdef CONFIG_X11
314          Window   m_wOwner;  
315  #if QT_VERSION >= 0x050100  void qsamplerApplication::x11PropertyNotify ( Window w )
316          qsamplerXcbEventFilter *m_pXcbEventFilter;  {
317  #endif          if (m_pDisplay && m_pWidget && m_wOwner == w) {
318  #endif  // CONFIG_XUNIQUE                  // 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  #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  #ifdef CONFIG_X11  // Local server data-ready slot.
372  #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 * )  
373  {  {
374          if (eventType == "xcb_generic_event_t") {          QLocalSocket *pSocket = qobject_cast<QLocalSocket *> (sender());
375                  xcb_property_notify_event_t *pEv          if (pSocket) {
376                          = static_cast<xcb_property_notify_event_t *> (message);                  const qint64 nread = pSocket->bytesAvailable();
377                  if ((pEv->response_type & ~0x80) == XCB_PROPERTY_NOTIFY                  if (nread > 0) {
378                          && pEv->state == XCB_PROPERTY_NEW_VALUE)                          const QByteArray data = pSocket->read(nread);
379                          m_pApp->x11PropertyNotify(pEv->window);                          // 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          }          }
         return false;  
386  }  }
387    
388  #endif  #endif
389  #endif  // CONFIG_XUNIQUE  #endif  // CONFIG_XUNIQUE
 #endif  // CONFIG_X11  
390    
391    
392  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 373  void stacktrace ( int signo ) Line 410  void stacktrace ( int signo )
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"
# Line 389  void stacktrace ( int signo ) Line 426  void stacktrace ( int signo )
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          }          }
# Line 419  int main ( int argc, char **argv ) Line 456  int main ( int argc, char **argv )
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    
# Line 460  int main ( int argc, char **argv ) Line 500  int main ( int argc, char **argv )
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) {
# Line 506  int main ( int argc, char **argv ) Line 546  int main ( int argc, char **argv )
546    
547    
548  // end of qsampler.cpp  // end of qsampler.cpp
549    

Legend:
Removed from v.2839  
changed lines
  Added in v.3560

  ViewVC Help
Powered by ViewVC