aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorItay Grudev <itay+github.com@grudev.com>2020-05-25 07:05:11 +0100
committerGitHub <noreply@github.com>2020-05-25 07:05:11 +0100
commit777aee67346a185e5ad1decf7d466fd4bb3cb8f6 (patch)
treedbb6dccdbb5a2c5e15e6fdceadaf9f9f0bbdd2ce /README.md
parentMerge pull request #105 from Shatur95/add_cmake_alias (diff)
downloadsingleapplication-777aee67346a185e5ad1decf7d466fd4bb3cb8f6.tar.xz
Improved CMake example
Diffstat (limited to 'README.md')
-rw-r--r--README.md31
1 files changed, 16 insertions, 15 deletions
diff --git a/README.md b/README.md
index cb18ac7..3c36b55 100644
--- a/README.md
+++ b/README.md
@@ -16,18 +16,6 @@ class you specify via the `QAPPLICATION_CLASS` macro (`QCoreApplication` is the
default). Further usage is similar to the use of the `Q[Core|Gui]Application`
classes.
-The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
-instance of your Application is your Primary Instance. It would check if the
-shared memory block exists and if not it will start a `QLocalServer` and listen
-for connections. Each subsequent instance of your application would check if the
-shared memory block exists and if it does, it will connect to the QLocalServer
-to notify the primary instance that a new instance had been started, after which
-it would terminate with status code `0`. In the Primary Instance
-`SingleApplication` would emit the `instanceStarted()` signal upon detecting
-that a new instance had been started.
-
-The library uses `stdlib` to terminate the program with the `exit()` function.
-
You can use the library as if you use any other `QCoreApplication` derived
class:
@@ -44,8 +32,7 @@ int main( int argc, char* argv[] )
```
To include the library files I would recommend that you add it as a git
-submodule to your project and include it's contents with a `.pri` file. Here is
-how:
+submodule to your project. Here is how:
```bash
git submodule add git@github.com:itay-grudev/SingleApplication.git singleapplication
@@ -67,13 +54,27 @@ Then include the subdirectory in your `CMakeLists.txt` project file.
```cmake
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(src/third-party/singleapplication)
+target_link_libraries(${PROJECT_NAME} SingleApplication::SingleApplication)
```
+
+The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
+instance of your Application is your Primary Instance. It would check if the
+shared memory block exists and if not it will start a `QLocalServer` and listen
+for connections. Each subsequent instance of your application would check if the
+shared memory block exists and if it does, it will connect to the QLocalServer
+to notify the primary instance that a new instance had been started, after which
+it would terminate with status code `0`. In the Primary Instance
+`SingleApplication` would emit the `instanceStarted()` signal upon detecting
+that a new instance had been started.
+
+The library uses `stdlib` to terminate the program with the `exit()` function.
+
Also don't forget to specify which `QCoreApplication` class your app is using if it
is not `QCoreApplication` as in examples above.
The `Instance Started` signal
-------------------------
+-----------------------------
The SingleApplication class implements a `instanceStarted()` signal. You can
bind to that signal to raise your application's window when a new instance had