From 5fff2202b513f00e553e1ec955909db5815a189f Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Fri, 27 Mar 2020 08:00:14 +0100 Subject: [PATCH] Add SingleApplication::currentUser() --- CHANGELOG.md | 5 +++++ README.md | 8 ++++++++ singleapplication.cpp | 6 ++++++ singleapplication.h | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eea70c..103fa88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +__3.1.1a__ +---------- + +* Added currentUser() method that returns the user the current instance is running as. + __3.1.0a__ ---------- diff --git a/README.md b/README.md index d3071eb..1dbbb84 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,14 @@ QString SingleApplication::primaryUser() Returns the username the primary instance is running as. +--- + +```cpp +QString SingleApplication::currentUser() +``` + +Returns the username the current instance is running as. + ### Signals ```cpp diff --git a/singleapplication.cpp b/singleapplication.cpp index 26e4ca2..7c955aa 100644 --- a/singleapplication.cpp +++ b/singleapplication.cpp @@ -178,6 +178,12 @@ QString SingleApplication::primaryUser() return d->primaryUser(); } +QString SingleApplication::currentUser() +{ + Q_D(SingleApplication); + return d->getUsername(); +} + bool SingleApplication::sendMessage( QByteArray message, int timeout ) { Q_D(SingleApplication); diff --git a/singleapplication.h b/singleapplication.h index f91e3a2..14c9615 100644 --- a/singleapplication.h +++ b/singleapplication.h @@ -118,6 +118,12 @@ public: */ QString primaryUser(); + /** + * @brief Returns the username of the current user + * @returns {QString} + */ + QString currentUser(); + /** * @brief Sends a message to the primary instance. Returns true on success. * @param {int} timeout - Timeout for connecting