forked from psemiletov/tea-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_application_shared.h
62 lines (40 loc) · 1.05 KB
/
single_application_shared.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
51
52
53
54
55
56
57
58
59
60
61
62
/*
* taken from http://berenger.eu/blog/c-qt-singleapplication-single-app-instance/
* code by Berenger Bramas
* modified by Peter Semiletov
*
*/
#ifndef SINGLE_APP_SHARED_H
#define SINGLE_APP_SHARED_H
#include <QApplication>
#include <QStringList>
#include <QSharedMemory>
class CSingleApplicationShared: public QApplication
{
Q_OBJECT
private:
QSharedMemory sharedMemory;
bool bAlreadyExists;
public:
CSingleApplicationShared (int &argc, char *argv[], const QString &uniqueKey);
~CSingleApplicationShared() {/*qDebug() << "~CSingleApplicationShared";*/};
static int cursorFlashTime()
{
return 0;
}
bool alreadyExists() const
{
return bAlreadyExists;
}
bool isMasterApp() const
{
return ! alreadyExists();
}
bool sendMessage (const QString &message);
public slots:
void checkForMessage();
signals:
void messageAvailable(const QStringList &messages);
void signal_commit_data();
};
#endif // SINGLE_APP_SHARED_H