forked from psemiletov/tea-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_application.h
51 lines (35 loc) · 919 Bytes
/
single_application.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* taken from http://www.qtcentre.org/wiki/index.php?title=SingleApplication
* LGPL'ed source code
* modified by Peter Semiletov
*
*/
#ifndef SINGLE_APP_H
#define SINGLE_APP_H
#include <QApplication>
#ifndef Q_OS_OS2
#include <QSharedMemory>
#endif
#include <QLocalServer>
class CSingleApplication : public QApplication
{
Q_OBJECT
public:
CSingleApplication (int &argc, char *argv[], const QString uniqueKey);
bool isRunning();
bool sendMessage(const QString &message);
static int cursorFlashTime() {return 0;};
public slots:
void receiveMessage();
signals:
void messageAvailable(QString message);
private:
bool _isRunning;
QString _uniqueKey;
#ifndef Q_OS_OS2
QSharedMemory sharedMemory;
#endif
QLocalServer *localServer;
static const int timeout = 1000;
};
#endif // SINGLE_APP_H