Skip to content

Commit 3ce1fe7

Browse files
committed
GUI - vendor - update SingleApplication to v3.5.2
1 parent 2034482 commit 3ce1fe7

File tree

17 files changed

+314
-58
lines changed

17 files changed

+314
-58
lines changed

app/gui/vendor/SingleApplication/.github/workflows/main.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ jobs:
1515
name: Build
1616
strategy:
1717
matrix:
18-
qt_version: [5.12.6, 5.15.0, 6.0.0, 6.2.0]
19-
platform: [ubuntu-20.04, windows-latest, macos-latest]
18+
qt_version:
19+
- 5.15.0
20+
- 6.2.4
21+
- 6.5.0
22+
platform:
23+
- ubuntu-20.04
24+
- windows-latest
25+
- macos-latest
2026
include:
21-
- qt_version: 6.0.0
27+
- qt_version: 6.2.4
2228
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
23-
- qt_version: 6.2.0
29+
- qt_version: 6.5.0
2430
additional_arguments: -D QT_DEFAULT_MAJOR_VERSION=6
2531
- platform: ubuntu-20.04
2632
make: make
@@ -41,13 +47,16 @@ jobs:
4147

4248
steps:
4349
- name: Clone repo
44-
uses: actions/checkout@v2.3.4
50+
uses: actions/checkout@v3
4551

4652
- name: Install Qt
47-
uses: jurplel/install-qt-action@v2.14.0
53+
uses: jurplel/install-qt-action@v3
4854
with:
4955
version: ${{ matrix.qt_version }}
5056

57+
- name: Setup MSVC environment for QMake
58+
uses: ilammy/msvc-dev-cmd@v1
59+
5160
- name: Build library with CMake
5261
run: |
5362
cmake . ${{ matrix.additional_arguments }}
@@ -59,7 +68,7 @@ jobs:
5968
cmake . ${{ matrix.additional_arguments }}
6069
cmake --build .
6170
62-
- name: Build calculator example CMake
71+
- name: Build calculator example with CMake
6372
working-directory: examples/calculator/
6473
run: |
6574
cmake . ${{ matrix.additional_arguments }}
@@ -71,16 +80,19 @@ jobs:
7180
cmake . ${{ matrix.additional_arguments }}
7281
cmake --build .
7382
74-
- name: Setup MSVC environment for QMake
75-
uses: ilammy/msvc-dev-cmd@v1
83+
- name: Build windows_raise_widget example with CMake
84+
working-directory: examples/windows_raise_widget/
85+
run: |
86+
cmake . ${{ matrix.additional_arguments }}
87+
cmake --build .
7688
7789
- name: Build basic example with QMake
7890
working-directory: examples/basic/
7991
run: |
8092
qmake
8193
${{ matrix.make }}
8294
83-
- name: Build calculator example QMake
95+
- name: Build calculator example with QMake
8496
working-directory: examples/calculator/
8597
run: |
8698
qmake
@@ -91,3 +103,9 @@ jobs:
91103
run: |
92104
qmake
93105
${{ matrix.make }}
106+
107+
- name: Build windows_raise_widget example with QMake
108+
working-directory: examples/windows_raise_widget/
109+
run: |
110+
qmake
111+
${{ matrix.make }}

app/gui/vendor/SingleApplication/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.idea
12
/examples/*/*.o
23
/examples/*/Makefile
34
/examples/*/moc_*.cpp

app/gui/vendor/SingleApplication/CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
# Changelog
22

3+
## 3.5.1
4+
5+
* Bug Fix: Maximum QNativeIpcKey key size on macOS. - _Jonas Kvinge_
6+
7+
## 3.5.0
8+
9+
* Switch to the new QNativeIpcKey based QSharedMemory constructor with Qt 6.6 and higher. - _Jonas Kvinge_
10+
11+
## 3.4.1
12+
13+
* Improved Windows advapi32 link library dependency. - _Frederik Seiffert_
14+
315
## 3.4.0
416

517
* Provide API for blocking sendMessage. - _Christoph Cullmann_
6-
18+
* New documentation generation using Doxygen
19+
* Improved Windows basic widget example
20+
* Updated Project License
721

822
## 3.3.4
923

app/gui/vendor/SingleApplication/LICENSE

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) Itay Grudev 2015 - 2020
1+
Copyright (c) Itay Grudev 2015 - 2023
42

53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
@@ -9,6 +7,9 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97
copies of the Software, and to permit persons to whom the Software is
108
furnished to do so, subject to the following conditions:
119

10+
Permission is not granted to use this software or any of the associated files
11+
as sample data for the purposes of building machine learning models.
12+
1213
The above copyright notice and this permission notice shall be included in
1314
all copies or substantial portions of the Software.
1415

app/gui/vendor/SingleApplication/README.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Keeps the Primary Instance of your Application and kills each subsequent
88
instances. It can (if enabled) spawn secondary (non-related to the primary)
99
instances and can send data to the primary instance from secondary instances.
1010

11-
## Documentation
11+
# [Documentation](https://itay-grudev.github.io/SingleApplication/)
1212

13-
You can find the full usage reference [here](https://itay-grudev.github.io/SingleApplication/classSingleApplication.html).
13+
You can find the full usage reference and examples [here](https://itay-grudev.github.io/SingleApplication/classSingleApplication.html).
1414

1515
## Usage
1616

@@ -60,6 +60,50 @@ add_subdirectory(src/third-party/singleapplication)
6060
target_link_libraries(${PROJECT_NAME} SingleApplication::SingleApplication)
6161
```
6262

63+
Directly including this repository as a Git submodule, or even just a shallow copy of the
64+
source code into new projects might not be ideal when using CMake.
65+
Another option is using CMake's `FetchContent` module, available since version `3.11`.
66+
```cmake
67+
68+
# Define the minumun CMake version, as an example 3.24
69+
cmake_minimum_required(VERSION 3.24)
70+
71+
# Include the module
72+
include(FetchContent)
73+
74+
# If using Qt6, override DEFAULT_MAJOR_VERSION
75+
set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "Qt version to use, defaults to 6")
76+
77+
# Set QAPPLICATION_CLASS
78+
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
79+
80+
81+
# Declare how is the source going to be obtained
82+
FetchContent_Declare(
83+
SingleApplication
84+
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication
85+
GIT_TAG master
86+
#GIT_TAG e22a6bc235281152b0041ce39d4827b961b66ea6
87+
)
88+
89+
# Fetch the repository and make it available to the build
90+
FetchContent_MakeAvailable(SingleApplication)
91+
92+
# Then simply use find_package as usual
93+
find_package(SingleApplication)
94+
95+
# Finally add it to the target_link_libraries() section
96+
target_link_libraries(ClientePOS PRIVATE
97+
Qt${QT_VERSION_MAJOR}::Widgets
98+
Qt${QT_VERSION_MAJOR}::Network
99+
Qt${QT_VERSION_MAJOR}::Sql
100+
101+
SingleApplication::SingleApplication
102+
)
103+
104+
```
105+
106+
63107
The library sets up a `QLocalServer` and a `QSharedMemory` block. The first
64108
instance of your Application is your Primary Instance. It would check if the
65109
shared memory block exists and if not it will start a `QLocalServer` and listen
@@ -168,6 +212,11 @@ instances running.
168212

169213
## License
170214

171-
This library and it's supporting documentation are released under
172-
`The MIT License (MIT)` with the exception of the Qt calculator examples which
173-
is distributed under the BSD license.
215+
This library and it's supporting documentation, with the exception of the Qt
216+
calculator examples which is distributed under the BSD license, are released
217+
under the terms of `The MIT License (MIT)` with an extra condition, that:
218+
219+
```txt
220+
Permission is not granted to use this software or any of the associated files
221+
as sample data for the purposes of building machine learning models.
222+
```

app/gui/vendor/SingleApplication/Windows.md

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,15 @@ application can bring it's primary instance window whenever a second copy
77
of the application is started.
88

99
On Windows the ability to bring the application windows to the foreground is
10-
restricted, see [AllowSetForegroundWindow()][https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx] for more
11-
details.
10+
restricted, see [AllowSetForegroundWindow()](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx) for more details.
1211

1312
The background process (the primary instance) can bring its windows to the
1413
foreground if it is allowed by the current foreground process (the secondary
1514
instance). To bypass this `SingleApplication` must be initialized with the
16-
`allowSecondary` parameter set to `true` and the `options` parameter must
17-
include `Mode::SecondaryNotification`, See `SingleApplication::Mode` for more
18-
details.
15+
`allowSecondary` parameter set to `true` .
1916

20-
Here is an example:
17+
If the widget is minimized to Windows task bar, `QWidget::raise()` or
18+
`QWidget::show()` can not bring it to the front, you have to use Windows API
19+
`ShowWindow()` .
2120

22-
```cpp
23-
if( app.isSecondary() ) {
24-
// This API requires LIBS += User32.lib to be added to the project
25-
AllowSetForegroundWindow( DWORD( app.primaryPid() ) );
26-
}
27-
28-
if( app.isPrimary() ) {
29-
QObject::connect(
30-
&app,
31-
&SingleApplication::instanceStarted,
32-
this,
33-
&App::instanceStarted
34-
);
35-
}
36-
```
37-
38-
```cpp
39-
void App::instanceStarted() {
40-
QApplication::setActiveWindow( [window/widget to set to the foreground] );
41-
}
42-
```
21+
You can find [demo code](examples/windows_raise_widget/main.cpp) in the examples directory.

app/gui/vendor/SingleApplication/examples/basic/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
// Copyright (c) Itay Grudev 2015 - 2023
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// Permission is not granted to use this software or any of the associated files
11+
// as sample data for the purposes of building machine learning models.
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
124
#include <singleapplication.h>
225

326
int main(int argc, char *argv[])

app/gui/vendor/SingleApplication/examples/sending_arguments/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
// Copyright (c) Itay Grudev 2015 - 2023
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// Permission is not granted to use this software or any of the associated files
11+
// as sample data for the purposes of building machine learning models.
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
124
#include <singleapplication.h>
225
#include "messagereceiver.h"
326

app/gui/vendor/SingleApplication/examples/sending_arguments/messagereceiver.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
// Copyright (c) Itay Grudev 2015 - 2023
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// Permission is not granted to use this software or any of the associated files
11+
// as sample data for the purposes of building machine learning models.
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
124
#include <QDebug>
225
#include "messagereceiver.h"
326

app/gui/vendor/SingleApplication/examples/sending_arguments/messagereceiver.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
// Copyright (c) Itay Grudev 2015 - 2023
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// Permission is not granted to use this software or any of the associated files
11+
// as sample data for the purposes of building machine learning models.
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
124
#ifndef MESSAGERECEIVER_H
225
#define MESSAGERECEIVER_H
326

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.7.0)
2+
3+
project(windows_raise_widget LANGUAGES CXX)
4+
5+
set(CMAKE_AUTOMOC ON)
6+
set(CMAKE_WIN32_EXECUTABLE TRUE)
7+
8+
# SingleApplication base class
9+
set(QAPPLICATION_CLASS QApplication)
10+
add_subdirectory(../.. SingleApplication)
11+
12+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Core Widgets REQUIRED)
13+
14+
add_executable(${PROJECT_NAME} main.cpp)
15+
16+
target_link_libraries(${PROJECT_NAME} SingleApplication::SingleApplication)

0 commit comments

Comments
 (0)