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 
45 
46  static RSingleApplication* getInstance();
47 
48  bool isRunning();
49  QString id() const;
50 
51  void setActivationWindow(QWidget* aw, bool activateOnMessage = true);
52  QWidget* activationWindow() const;
53 
54 public slots:
55  bool sendMessage(const QString& message, int timeout = 5000);
56  void activateWindow();
57 
58 signals:
59  void messageReceived(const QString& message);
60  void fileOpenRequestReceived(const QString& fileName);
61 
62 protected:
63  virtual bool event(QEvent* e);
64 
65 private:
66  void sysInit(const QString& appId = QString());
68  QWidget* actWin;
69  QMutex mutexEvents;
72 };
73 
75 
76 #endif