1 |
// qsampler.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
Copyright (C) 2003-2024, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2008,2015,2019 Christian Schoenebeck |
6 |
|
7 |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
9 |
as published by the Free Software Foundation; either version 2 |
10 |
of the License, or (at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License along |
18 |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#ifndef __qsampler_h |
24 |
#define __qsampler_h |
25 |
|
26 |
#include "qsamplerAbout.h" |
27 |
|
28 |
#include <QApplication> |
29 |
|
30 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
31 |
#if defined(Q_WS_X11) |
32 |
#define CONFIG_X11 |
33 |
#endif |
34 |
#endif |
35 |
|
36 |
|
37 |
// Forward decls. |
38 |
class QWidget; |
39 |
class QTranslator; |
40 |
|
41 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
42 |
#ifdef CONFIG_XUNIQUE |
43 |
#ifdef CONFIG_X11 |
44 |
#include <QX11Info> |
45 |
typedef unsigned long Window; |
46 |
typedef unsigned long Atom; |
47 |
#endif // CONFIG_X11 |
48 |
#endif // CONFIG_XUNIQUE |
49 |
#else |
50 |
#ifdef CONFIG_XUNIQUE |
51 |
class QSharedMemory; |
52 |
class QLocalServer; |
53 |
#endif // CONFIG_XUNIQUE |
54 |
#endif |
55 |
|
56 |
|
57 |
//------------------------------------------------------------------------- |
58 |
// Singleton application instance stuff (Qt/X11 only atm.) |
59 |
// |
60 |
|
61 |
class qsamplerApplication : public QApplication |
62 |
{ |
63 |
Q_OBJECT |
64 |
|
65 |
public: |
66 |
|
67 |
// Constructor. |
68 |
qsamplerApplication(int& argc, char **argv); |
69 |
|
70 |
// Destructor. |
71 |
~qsamplerApplication(); |
72 |
|
73 |
// Main application widget accessors. |
74 |
void setMainWidget(QWidget *pWidget); |
75 |
QWidget *mainWidget() const |
76 |
{ return m_pWidget; } |
77 |
|
78 |
// Check if another instance is running, |
79 |
// and raise its proper main widget... |
80 |
bool setup(); |
81 |
|
82 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
83 |
#ifdef CONFIG_XUNIQUE |
84 |
#ifdef CONFIG_X11 |
85 |
void x11PropertyNotify(Window w); |
86 |
bool x11EventFilter(XEvent *pEv) |
87 |
#endif // CONFIG_X11 |
88 |
#endif // CONFIG_XUNIQUE |
89 |
#else |
90 |
#ifdef CONFIG_XUNIQUE |
91 |
protected slots: |
92 |
// Local server slots. |
93 |
void newConnectionSlot(); |
94 |
void readyReadSlot(); |
95 |
protected: |
96 |
// Local server/shmem setup/cleanup. |
97 |
bool setupServer(); |
98 |
void clearServer(); |
99 |
#endif // CONFIG_XUNIQUE |
100 |
#endif |
101 |
|
102 |
private: |
103 |
|
104 |
// Translation support. |
105 |
QTranslator *m_pQtTranslator; |
106 |
QTranslator *m_pMyTranslator; |
107 |
|
108 |
// Instance variables. |
109 |
QWidget *m_pWidget; |
110 |
|
111 |
#ifdef CONFIG_XUNIQUE |
112 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
113 |
#ifdef CONFIG_X11 |
114 |
Display *m_pDisplay; |
115 |
Atom m_aUnique; |
116 |
Window m_wOwner; |
117 |
#endif // CONFIG_X11 |
118 |
#else |
119 |
QString m_sUnique; |
120 |
QSharedMemory *m_pMemory; |
121 |
QLocalServer *m_pServer; |
122 |
#endif |
123 |
#endif // CONFIG_XUNIQUE |
124 |
}; |
125 |
|
126 |
|
127 |
#endif // __qsampler_h |
128 |
|
129 |
// end of qsampler.h |