mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Add Signals for closing the App
This commit is contained in:
parent
b4b0f56158
commit
0f2489a4c3
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,8 @@ cmake-build-debug*
|
||||
build/
|
||||
.vscode/
|
||||
third_party/
|
||||
compile_commands.json
|
||||
|
||||
*-protocol.o
|
||||
*-protocol.c
|
||||
*-protocol.h
|
||||
*-protocol.h
|
||||
|
20
main.cpp
20
main.cpp
@ -12,6 +12,7 @@
|
||||
#include <QObject>
|
||||
#include <iterator>
|
||||
#include <qboxlayout.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qglobal.h>
|
||||
#include <qgridlayout.h>
|
||||
#include <qlabel.h>
|
||||
@ -32,12 +33,17 @@
|
||||
#include "common.h"
|
||||
|
||||
WallpaperEngine::Application::CWallpaperApplication* appPointer;
|
||||
QCoreApplication* globalApp = nullptr;
|
||||
|
||||
class UIWindow;
|
||||
|
||||
void signalhandler(int sig)
|
||||
{
|
||||
if (appPointer == nullptr)
|
||||
return;
|
||||
if (appPointer == nullptr) {
|
||||
if(globalApp != nullptr) {
|
||||
globalApp->quit();
|
||||
} else return;
|
||||
}
|
||||
|
||||
appPointer->signal (sig);
|
||||
}
|
||||
@ -68,12 +74,12 @@ int main (int argc, char* argv[]) {
|
||||
wallpaperPaths.push_back(entry.path());
|
||||
}
|
||||
|
||||
for (const std::string s : wallpaperPaths) {
|
||||
std::cout << s << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
QApplication qapp(argc, argv);
|
||||
globalApp = &qapp;
|
||||
|
||||
// Signal for properly close the app
|
||||
std::signal (SIGINT, signalhandler);
|
||||
std::signal (SIGTERM, signalhandler);
|
||||
|
||||
auto* uiWindow = new UIWindow(nullptr, &qapp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user