24 #ifndef SINGLE_APPLICATION_H
25 #define SINGLE_APPLICATION_H
27 #include <QtCore/QtGlobal>
28 #include <QtNetwork/QLocalSocket>
30 #ifndef QAPPLICATION_CLASS
31 #define QAPPLICATION_CLASS QCoreApplication
34 #include QT_STRINGIFY(QAPPLICATION_CLASS)
36 class SingleApplicationPrivate;
47 using app_t = QAPPLICATION_CLASS;
81 Q_DECLARE_FLAGS(Options,
Mode)
179 SingleApplicationPrivate *d_ptr;
184 Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options)
Handles multiple instances of the same Application.
Definition: singleapplication.h:44
QString currentUser() const
Returns the username of the current user.
void receivedMessage(quint32 instanceId, QByteArray message)
Triggered whenever there is a message received from a secondary instance.
void instanceStarted()
Triggered whenever a new instance had been started, except for secondary instances if the Mode::Secon...
SendMode
Mode of operation of sendMessage.
Definition: singleapplication.h:145
@ BlockUntilPrimaryExit
Definition: singleapplication.h:147
bool isSecondary() const
Checks if the instance is a secondary instance.
bool isPrimary() const
Checks if the instance is primary instance.
QStringList userData() const
Get the set user data.
qint64 primaryPid() const
Returns the process ID (PID) of the primary instance.
QString primaryUser() const
Returns the username of the user running the primary instance.
quint32 instanceId() const
Returns a unique identifier for the current instance.
bool sendMessage(const QByteArray &message, int timeout=100, SendMode sendMode=NonBlocking)
Sends a message to the primary instance.
Mode
Mode of operation of SingleApplication. Whether the block should be user-wide or system-wide and whet...
Definition: singleapplication.h:59
@ User
Definition: singleapplication.h:63
@ System
Definition: singleapplication.h:67
@ ExcludeAppVersion
Definition: singleapplication.h:75
@ ExcludeAppPath
Definition: singleapplication.h:79
@ SecondaryNotification
Definition: singleapplication.h:71