QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RSingleApplication.h
Go to the documentation of this file.
1 
20 #ifndef RSINGLEAPPLICATION_H
21 #define RSINGLEAPPLICATION_H
22 
23 #include "core_global.h"
24 
25 #include <QApplication>
26 #include <QMetaType>
27 #include <QMutex>
28 
29 class RLocalPeer;
30 
31 class QCADCORE_EXPORT RSingleApplication : public QApplication {
32  Q_OBJECT
33 
34 public:
35  RSingleApplication(int& argc, char **argv, bool GUIenabled = true);
36  RSingleApplication(const QString& id, int& argc, char **argv, bool GUIenabled = true);
37  //RSingleApplication(int& argc, char **argv, Type type);
38 #if defined(Q_OS_X11)
39  RSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
40  RSingleApplication(Display *dpy, int& argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
41  RSingleApplication(Display* dpy, const QString& appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
42 #endif
43 
44  static RSingleApplication* getInstance();
45 
46  bool isRunning();
47  QString id() const;
48 
49  void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
50  QWidget* activationWindow() const;
51 
52 public slots:
53  bool sendMessage(const QString& message, int timeout = 5000);
54  void activateWindow();
55 
56 signals:
57  void messageReceived(const QString& message);
58  void fileOpenRequestReceived(const QString& fileName);
59 
60 protected:
61  virtual bool event(QEvent* e);
62 
63 private:
64  void sysInit(const QString& appId = QString());
66  QWidget* actWin;
67  QMutex mutexEvents;
70 };
71 
73 
74 #endif