mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
fix restart on Linux (#1617)
This commit is contained in:
parent
c2e10f5783
commit
06ee73dcd5
@ -378,9 +378,13 @@ QString ConfigMgr::getLogFile() const
|
||||
|
||||
QString ConfigMgr::getApplicationFilePath()
|
||||
{
|
||||
#if defined(Q_OS_Linux)
|
||||
// TODO: Check if it is from AppImage.
|
||||
// We could get the APPIMAGE env variable from the AppRun script and pass it to vnote via cmd.
|
||||
#if defined(Q_OS_LINUX)
|
||||
// We could get the APPIMAGE env variable from the AppRun script.
|
||||
auto appImageVar = QString::fromLocal8Bit(qgetenv("APPIMAGE"));
|
||||
qInfo() << "APPIMAGE" << appImageVar;
|
||||
if (!appImageVar.isEmpty()) {
|
||||
return appImageVar;
|
||||
}
|
||||
#elif defined(Q_OS_MACOS)
|
||||
auto exePath = QCoreApplication::applicationFilePath();
|
||||
const QString exeName = c_appName.toLower() + ".app";
|
||||
|
@ -72,9 +72,6 @@ namespace vnotex
|
||||
IncrementalSearch = 0x10U
|
||||
};
|
||||
Q_DECLARE_FLAGS(FindOptions, FindOption);
|
||||
|
||||
enum { RESTART_EXIT_CODE = 1000 };
|
||||
|
||||
} // ns vnotex
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(vnotex::FindOptions);
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <core/singleinstanceguard.h>
|
||||
#include <core/vnotex.h>
|
||||
#include <core/logger.h>
|
||||
#include <core/global.h>
|
||||
#include <widgets/mainwindow.h>
|
||||
#include <QWebEngineSettings>
|
||||
#include <core/exception.h>
|
||||
@ -131,7 +130,10 @@ int main(int argc, char *argv[])
|
||||
if (ret == RESTART_EXIT_CODE) {
|
||||
// Asked to restart VNote.
|
||||
guard.exit();
|
||||
QProcess::startDetached(ConfigMgr::getApplicationFilePath(), QStringList());
|
||||
QProcess::startDetached(QCoreApplication::applicationFilePath(), QStringList());
|
||||
// Must use exit() in Linux to quit the parent process in Qt 5.12.
|
||||
// Thanks to @ygcaicn.
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <core/coreconfig.h>
|
||||
#include <core/events.h>
|
||||
#include <core/fileopenparameters.h>
|
||||
#include <core/global.h>
|
||||
#include <widgets/dialogs/scrolldialog.h>
|
||||
#include "viewwindow.h"
|
||||
#include "outlineviewer.h"
|
||||
|
@ -18,6 +18,8 @@ namespace vnotex
|
||||
class Event;
|
||||
class OutlineViewer;
|
||||
|
||||
enum { RESTART_EXIT_CODE = 1000 };
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -313,13 +313,12 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
|
||||
[p_win]() {
|
||||
p_win->quitApp();
|
||||
});
|
||||
#if !defined(Q_OS_LINUX)
|
||||
|
||||
menu->addAction(MainWindow::tr("Restart"),
|
||||
menu,
|
||||
[p_win]() {
|
||||
p_win->restart();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
// Help.
|
||||
|
Loading…
x
Reference in New Issue
Block a user