SingleApplication
=================
This is a replacement of the QSingleApplication for `Qt5`.
Keeps the Primary Instance of your Application and kills each subsequent
instances. It can (if enabled) spawn a certain number of secondary instances
(with the `--secondary` command line argument).
Usage
-----
The `SingleApplication` class inherits from whatever `Q[Core|Gui]Application`
class you specify. Further usage is similar to the use of the
`Q[Core|Gui]Application` classes.
The library uses your `Organization Name` and `Application Name` to set 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 then listen for connections
on it. 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 it that a new instance had been started, after which it would terminate
with status code `0`. The Primary Instance, `SingleApplication` would emit the
`showUp()` signal upon detecting that a new instance had been started.
The library uses `stdlib` to terminate the program with the `exit()` function.
Here is an example usage of the library:
```cpp
// In your Project.pro
DEFINES += QAPPLICATION_CLASS=QGuiApplication # QApplication is the default
// main.cpp
#include "singleapplication.h"
int main( int argc, char* argv[] )
{
QApplication::setApplicationName("{Your App Name}");
QApplication::setOrganizationName("{Your Organization Name}");
SingleApplication app( argc, argv );
return app.exec();
}
```
The `Show Up` signal
------------------------
The SingleApplication class implements a `showUp()` signal. You can bind to that
signal to raise your application's window when a new instance had been started.
Note that since `SingleApplication` extends the `QApplication` class you can do
the following:
```cpp
// window is a QWindow instance
QObject::connect( &app, &SingleApplication::showUp, window, &QWindow::raise );
```
Using `QApplication::instance()` is a neat way to get the `SingleApplication`
instance anywhere in your program.
Secondary Instances
-------------------
If you want to be able to launch additional Secondary Instances (not related to
your Primary Instance) you have to enable that with the third parameter of the
`SingleApplication` constructor. The default is `0` meaning no Secondary
Instances. Here is an example allowing spawning up to `2` Secondary Instances.
```cpp
SingleApplication app( argc, argv, 2 );
```
After which just call your program with the `--secondary` argument to launch a
secondary instance.
__*Note:*__ If your Primary Instance is terminated upon launch of a new one it
will replace it as Primary even if the `--secondary` argument has been set.
*P.S. If you think this behavior could be improved create an issue and explain
why.*
Implementation
--------------
The library is implemented with a QSharedMemory block which is thread safe and
guarantees a race condition will not occur. It also uses a QLocalSocket to
notify the main process that a new instance had been spawned and thus invoke the
`showUp()` signal.
To handle an issue on `*nix` systems, where the operating system owns the shared
memory block and if the program crashes the memory remains untouched, the
library binds to the following signals and closes the program with error code =
`128 + signum` where signum is the number representation of the signal listed
below. Handling the signal is required in order to safely delete the
`QSharedMemory` block. Each of these signals are potentially lethal and will
results in process termination.
* `SIGHUP` - `1`, Hangup.
* `SIGINT` - `2`, Terminal interrupt signal
* `SIGQUIT` - `3`, Terminal quit signal.
* `SIGILL` - `4`, Illegal instruction.
* `SIGABRT` - `6`, Process abort signal.
* `SIGBUS` - `7`, Access to an undefined portion of a memory object.
* `SIGFPE` - `8`, Erroneous arithmetic operation (such as division by zero).
* `SIGSEGV` - `11`, Invalid memory reference.
* `SIGSYS` - `12`, Bad system call.
* `SIGPIPE` - `13`, Write on a pipe with no one to read it.
* `SIGALRM` - `14`, Alarm clock.
* `SIGTERM` - `15`, Termination signal.
* `SIGXCPU` - `24`, CPU time limit exceeded.
* `SIGXFSZ` - `25`, File size limit exceeded.
License
-------
This library and it's supporting documentation are released under `The MIT License (MIT)`.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
[按键映射工具] QKeyMapper,Qt开发Win10&Win11可用,不修改注册表、不需重新启动系统,可立即生效和停止,新增虚拟游戏手柄功能,可鼠标控制虚拟手柄摇杆。在Win10和Win11下可以正常使用的按键映射工具,使用Qt Widget + WinAPI开发,v1.2.8(2022-12-24)开始更新了对Qt6的支持,v1.2.8及之后的Release中使用Qt6编译的版本,v1.3.6(Build 20231220)新增游戏手柄按键和虚拟游戏手柄支持。v1.3.7(Build 20240410)增加多键鼠+多虚拟手柄支持。
资源推荐
资源详情
资源评论
收起资源包目录
按键映射工具QKeyMapper,Qt开发Win10&Win11可用,不修改注册表、不需重新启动系统,可立即生效和停止 (467个子文件)
.clang-format 3KB
SDL_config.h.cmake 23KB
SDL_revision.h.cmake 214B
qkeymapper_worker.cpp 471KB
qkeymapper.cpp 455KB
interception_worker.cpp 38KB
qkeymapper_constants.cpp 38KB
qitemsetupdialog.cpp 37KB
qinputdevicelistwindow.cpp 26KB
QJoysticks.cpp 17KB
qtablesetupdialog.cpp 14KB
SDL_Joysticks.cpp 11KB
qhotkey.cpp 10KB
VirtualJoystick.cpp 10KB
main.cpp 9KB
qhotkey_mac.cpp 8KB
singleapplication.cpp 8KB
qhotkey_x11.cpp 7KB
qhotkey_win.cpp 7KB
main.cpp 3KB
main.cpp 1KB
Android_Joystick.cpp 0B
doxygen.css 25KB
search.css 4KB
tabs.css 1KB
SDL2.dll 1.53MB
SDL2.dll 1.31MB
dbghelp.dll 1.31MB
dbghelp.dll 1.03MB
vld_x64.dll 457KB
vld_x86.dll 335KB
libusb-1.0.dll 154KB
ViGEmClient.dll 138KB
libusb-1.0.dll 127KB
ViGEmClient.dll 99KB
interception.dll 11KB
interception.dll 11KB
doxyfile 105KB
doxyfile 64KB
install-interception.exe 460KB
libusb-1.0.exp 28KB
libusb-1.0.exp 28KB
.gitattributes 77B
.gitignore 497B
.gitignore 279B
.gitignore 143B
SDL_opengl_glext.h 844KB
SDL_opengles2_gl2ext.h 236KB
SDL_hints.h 120KB
SDL_egl.h 106KB
libusb.h 81KB
SDL_opengl.h 79KB
SDL_video.h 79KB
SDL_render.h 72KB
SDL_audio.h 58KB
SDL_events.h 46KB
SDL_haptic.h 42KB
SDL_opengles2_gl2.h 42KB
SDL_gamecontroller.h 40KB
SDL_joystick.h 38KB
SDL_surface.h 36KB
qkeymapper_worker.h 34KB
SDL_stdinc.h 30KB
qkeymapper_constants.h 30KB
SDL_rwops.h 27KB
SDL_pixels.h 25KB
qkeymapper.h 24KB
SDL_system.h 21KB
Client.h 20KB
SDL_hidapi.h 17KB
SDL_cpuinfo.h 17KB
SDL_thread.h 17KB
SDL_mouse.h 17KB
SDL_scancode.h 17KB
SDL_mutex.h 16KB
SDL_keycode.h 15KB
SDL_atomic.h 14KB
SDL_test_fuzzer.h 13KB
SDL_rect.h 13KB
SDL_assert.h 12KB
BusShared.h 12KB
SDL_log.h 11KB
SDL_syswm.h 11KB
SDL_keyboard.h 11KB
SDL_opengles2_khrplatform.h 11KB
vld.h 11KB
SDL_sensor.h 10KB
SDL_endian.h 10KB
SDL_blendmode.h 9KB
SDL_main.h 9KB
SDL_config_windows.h 9KB
SDL_vulkan.h 8KB
SDL.h 8KB
interception.h 7KB
SDL_timer.h 7KB
Common.h 7KB
SDL_config_macosx.h 7KB
SDL_platform.h 7KB
SDL_test_common.h 7KB
SDL_version.h 7KB
共 467 条
- 1
- 2
- 3
- 4
- 5
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7265
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功