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/
|
build/
|
||||||
.vscode/
|
.vscode/
|
||||||
third_party/
|
third_party/
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
*-protocol.o
|
*-protocol.o
|
||||||
*-protocol.c
|
*-protocol.c
|
||||||
*-protocol.h
|
*-protocol.h
|
||||||
|
20
main.cpp
20
main.cpp
@ -12,6 +12,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <qboxlayout.h>
|
#include <qboxlayout.h>
|
||||||
|
#include <qcoreapplication.h>
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
#include <qgridlayout.h>
|
#include <qgridlayout.h>
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
@ -32,12 +33,17 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
WallpaperEngine::Application::CWallpaperApplication* appPointer;
|
WallpaperEngine::Application::CWallpaperApplication* appPointer;
|
||||||
|
QCoreApplication* globalApp = nullptr;
|
||||||
|
|
||||||
class UIWindow;
|
class UIWindow;
|
||||||
|
|
||||||
void signalhandler(int sig)
|
void signalhandler(int sig)
|
||||||
{
|
{
|
||||||
if (appPointer == nullptr)
|
if (appPointer == nullptr) {
|
||||||
return;
|
if(globalApp != nullptr) {
|
||||||
|
globalApp->quit();
|
||||||
|
} else return;
|
||||||
|
}
|
||||||
|
|
||||||
appPointer->signal (sig);
|
appPointer->signal (sig);
|
||||||
}
|
}
|
||||||
@ -68,12 +74,12 @@ int main (int argc, char* argv[]) {
|
|||||||
wallpaperPaths.push_back(entry.path());
|
wallpaperPaths.push_back(entry.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string s : wallpaperPaths) {
|
|
||||||
std::cout << s << "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QApplication qapp(argc, argv);
|
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);
|
auto* uiWindow = new UIWindow(nullptr, &qapp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user