mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-01-30 15:34:06 +08:00
Updated code style and added inline documentation to public methods
This commit is contained in:
parent
e93c12ab69
commit
a136c734c9
@ -38,7 +38,9 @@
|
|||||||
* if another instance already exists
|
* if another instance already exists
|
||||||
* @param argc
|
* @param argc
|
||||||
* @param argv
|
* @param argv
|
||||||
* @param {bool} allowSecondaryInstances
|
* @param allowSecondary Whether to enable secondary instance support
|
||||||
|
* @param options Optional flags to toggle specific behaviour
|
||||||
|
* @param timeout Maximum time blocking functions are allowed during app load
|
||||||
*/
|
*/
|
||||||
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout )
|
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout )
|
||||||
: app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) )
|
: app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) )
|
||||||
@ -139,51 +141,82 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
|
|||||||
::exit( EXIT_SUCCESS );
|
::exit( EXIT_SUCCESS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destructor
|
|
||||||
*/
|
|
||||||
SingleApplication::~SingleApplication()
|
SingleApplication::~SingleApplication()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current application instance is primary.
|
||||||
|
* @return Returns true if the instance is primary, false otherwise.
|
||||||
|
*/
|
||||||
bool SingleApplication::isPrimary()
|
bool SingleApplication::isPrimary()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->server != nullptr;
|
return d->server != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the current application instance is secondary.
|
||||||
|
* @return Returns true if the instance is secondary, false otherwise.
|
||||||
|
*/
|
||||||
bool SingleApplication::isSecondary()
|
bool SingleApplication::isSecondary()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->server == nullptr;
|
return d->server == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows you to identify an instance by returning unique consecutive instance
|
||||||
|
* ids. It is reset when the first (primary) instance of your app starts and
|
||||||
|
* only incremented afterwards.
|
||||||
|
* @return Returns a unique instance id.
|
||||||
|
*/
|
||||||
quint32 SingleApplication::instanceId()
|
quint32 SingleApplication::instanceId()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->instanceNumber;
|
return d->instanceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the OS PID (Process Identifier) of the process running the primary
|
||||||
|
* instance. Especially useful when SingleApplication is coupled with OS.
|
||||||
|
* specific APIs.
|
||||||
|
* @return Returns the primary instance PID.
|
||||||
|
*/
|
||||||
qint64 SingleApplication::primaryPid()
|
qint64 SingleApplication::primaryPid()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->primaryPid();
|
return d->primaryPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the username the primary instance is running as.
|
||||||
|
* @return Returns the username the primary instance is running as.
|
||||||
|
*/
|
||||||
QString SingleApplication::primaryUser()
|
QString SingleApplication::primaryUser()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->primaryUser();
|
return d->primaryUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the username the current instance is running as.
|
||||||
|
* @return Returns the username the current instance is running as.
|
||||||
|
*/
|
||||||
QString SingleApplication::currentUser()
|
QString SingleApplication::currentUser()
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
return d->getUsername();
|
return d->getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends message to the Primary Instance.
|
||||||
|
* @param message The message to send.
|
||||||
|
* @param timeout the maximum timeout in milliseconds for blocking functions.
|
||||||
|
* @return true if the message was sent successfuly, false otherwise.
|
||||||
|
*/
|
||||||
bool SingleApplication::sendMessage( const QByteArray &message, int timeout )
|
bool SingleApplication::sendMessage( const QByteArray &message, int timeout )
|
||||||
{
|
{
|
||||||
Q_D( SingleApplication );
|
Q_D( SingleApplication );
|
||||||
|
Loading…
Reference in New Issue
Block a user