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

29 lines
596 B
C++

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