QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
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
29class RLocalPeer;
30
31class QCADCORE_EXPORT RSingleApplication : public QApplication {
32 Q_OBJECT
33
34public:
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 bool notify(QObject* receiver, QEvent* e);
55
56public slots:
57 void registerGlobalShortcut(int key, int modifiers) {
58 globalShortcuts.append(QPair<int, int>(key, modifiers));
59 }
60 bool sendMessage(const QString& message, int timeout = 5000);
61 void activateWindow();
62
63signals:
64 void messageReceived(const QString& message);
65 void fileOpenRequestReceived(const QString& fileName);
66 void globalShortcutPressed(int key, int modifiers);
67
68protected:
69 virtual bool event(QEvent* e);
70
71private:
72 void sysInit(const QString& appId = QString());
74 QWidget* actWin;
78
79 QList<QPair<int, int> > globalShortcuts;
80};
81
83
84#endif
Q_DECLARE_METATYPE(RMath *)
Definition RLocalPeer.h:29
Definition RSingleApplication.h:31
void fileOpenRequestReceived(const QString &fileName)
RLocalPeer * peer
Definition RSingleApplication.h:73
static RSingleApplication * singleInstance
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RSingleApplication.h:77
void globalShortcutPressed(int key, int modifiers)
void registerGlobalShortcut(int key, int modifiers)
Definition RSingleApplication.h:57
QMutex mutexEvents
Definition RSingleApplication.h:75
QList< QPair< int, int > > globalShortcuts
Definition RSingleApplication.h:79
QThread * mutexEventsLocker
Definition RSingleApplication.h:76
QWidget * actWin
Definition RSingleApplication.h:74
void messageReceived(const QString &message)
#define QCADCORE_EXPORT
Definition core_global.h:10