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