summaryrefslogtreecommitdiffstats
path: root/singleapplication.h
blob: ad642446a892b68df71e4c99b3cb1f83239d92c2 (plain)
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
#ifndef SINGLEAPPLICATION_H_
#define SINGLEAPPLICATION_H_

#include <QApplication>
#include <QSharedMemory>
#include <QLocalServer>

class SingleApplication : public QApplication {
  Q_OBJECT
 public:
  SingleApplication(int &argc, char *argv[], const QString uniqueKey);
  bool isRunning();
  bool sendMessage(const QString &message);

 public slots:
  void receiveMessage();

 signals:
  void messageAvailable(QString message);

 private:
  bool _isRunning;
  QString _uniqueKey;
  QSharedMemory sharedMemory;
  QScopedPointer<QLocalServer> localServer;

  static const int timeout = 1000;
};

#endif  // SINGLEAPPLICATION_H_