mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
fix shutdown
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "ui/mainwindow.h"
|
#include "ui/mainwindow.h"
|
||||||
|
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
@@ -13,6 +15,13 @@
|
|||||||
#include "sys/windows/MiniDump.h"
|
#include "sys/windows/MiniDump.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void signal_handler(int signum) {
|
||||||
|
if (qApp) {
|
||||||
|
GetMainWindow()->on_commitDataRequest();
|
||||||
|
qApp->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// Core dump
|
// Core dump
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@@ -120,6 +129,10 @@ int main(int argc, char *argv[]) {
|
|||||||
QCoreApplication::installTranslator(&trans_qt);
|
QCoreApplication::installTranslator(&trans_qt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Signals
|
||||||
|
signal(SIGTERM, signal_handler);
|
||||||
|
signal(SIGINT, signal_handler);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,6 +425,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(qApp, &QGuiApplication::commitDataRequest, this, &MainWindow::on_commitDataRequest);
|
||||||
|
|
||||||
if (!NekoRay::dataStore->start_minimal) show();
|
if (!NekoRay::dataStore->start_minimal) show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,11 +540,8 @@ void MainWindow::on_menu_hotkey_settings_triggered() {
|
|||||||
USE_DIALOG(DialogHotkey)
|
USE_DIALOG(DialogHotkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_exit_triggered() {
|
void MainWindow::on_commitDataRequest() {
|
||||||
neko_set_spmode(NekoRay::SystemProxyMode::DISABLE, false);
|
qDebug() << "Start of data save";
|
||||||
if (title_spmode == NekoRay::SystemProxyMode::VPN) return;
|
|
||||||
RegisterHotkey(true);
|
|
||||||
|
|
||||||
if (!isMaximized()) {
|
if (!isMaximized()) {
|
||||||
auto olds = NekoRay::dataStore->mw_size;
|
auto olds = NekoRay::dataStore->mw_size;
|
||||||
auto news = QString("%1x%2").arg(size().width()).arg(size().height());
|
auto news = QString("%1x%2").arg(size().width()).arg(size().height());
|
||||||
@@ -551,17 +550,26 @@ void MainWindow::on_menu_exit_triggered() {
|
|||||||
NekoRay::dataStore->Save();
|
NekoRay::dataStore->Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
auto last_id = NekoRay::dataStore->started_id;
|
auto last_id = NekoRay::dataStore->started_id;
|
||||||
neko_stop();
|
neko_stop();
|
||||||
if (NekoRay::dataStore->remember_enable && last_id >= 0) {
|
if (NekoRay::dataStore->remember_enable && last_id >= 0) {
|
||||||
NekoRay::dataStore->UpdateStartedId(last_id);
|
NekoRay::dataStore->UpdateStartedId(last_id);
|
||||||
}
|
}
|
||||||
|
qDebug() << "End of data save";
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_menu_exit_triggered() {
|
||||||
|
neko_set_spmode(NekoRay::SystemProxyMode::DISABLE, false);
|
||||||
|
if (title_spmode == NekoRay::SystemProxyMode::VPN) return;
|
||||||
|
RegisterHotkey(true);
|
||||||
|
//
|
||||||
|
on_commitDataRequest();
|
||||||
|
//
|
||||||
core_process_killed = true;
|
core_process_killed = true;
|
||||||
hide();
|
hide();
|
||||||
ExitNekorayCore();
|
ExitNekorayCore();
|
||||||
|
//
|
||||||
if (exit_update) {
|
if (exit_update) {
|
||||||
QDir::setCurrent(QApplication::applicationDirPath());
|
QDir::setCurrent(QApplication::applicationDirPath());
|
||||||
QProcess::startDetached("./updater", QStringList{});
|
QProcess::startDetached("./updater", QStringList{});
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
void on_commitDataRequest();
|
||||||
|
|
||||||
void on_menu_exit_triggered();
|
void on_menu_exit_triggered();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user