dotherside/lib/include/DOtherSide/DOtherSideSingleInstance.h

33 lines
662 B
C
Raw Normal View History

2021-07-21 19:34:28 +03:00
#ifndef SINGLEINSTANCE_H
#define SINGLEINSTANCE_H
#include <QObject>
class QLocalServer;
class SingleInstance : public QObject
{
Q_OBJECT
public:
// uniqueName - the name of named pipe
// eventStr - optional event to send if another instance is detected
explicit SingleInstance(const QString &uniqueName, const QString &eventStr, QObject *parent = nullptr);
2021-07-21 19:34:28 +03:00
~SingleInstance() override;
bool isFirstInstance() const;
signals:
void secondInstanceDetected();
void eventReceived(const QString &eventStr);
private slots:
void handleNewConnection();
2021-07-21 19:34:28 +03:00
private:
QLocalServer *m_localServer;
};
#endif // SINGLEINSTANCE_H