status-desktop/src-cpp/dotherside/DOtherSideSingleInstance.h

29 lines
596 B
C
Raw Normal View History

#pragma once
2022-01-06 19:29:19 +00:00
#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);
2022-01-06 19:29:19 +00:00
~SingleInstance() override;
bool isFirstInstance() const;
signals:
void secondInstanceDetected();
void eventReceived(const QString& eventStr);
2022-01-06 19:29:19 +00:00
private slots:
void handleNewConnection();
private:
QLocalServer* m_localServer;
2022-01-06 19:29:19 +00:00
};