mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
parent
d51e486a84
commit
c2e10f5783
@ -76,11 +76,12 @@ ConfigMgr::~ConfigMgr()
|
||||
|
||||
void ConfigMgr::locateConfigFolder()
|
||||
{
|
||||
const auto appDirPath = getApplicationDirPath();
|
||||
qInfo() << "app folder" << appDirPath;
|
||||
// Check app config.
|
||||
{
|
||||
const QString configFolderName("vnotex_files");
|
||||
QString folderPath(QCoreApplication::applicationDirPath()
|
||||
+ '/' + configFolderName);
|
||||
QString folderPath(appDirPath + '/' + configFolderName);
|
||||
if (QDir(folderPath).exists()) {
|
||||
// Config folder in app/.
|
||||
m_appConfigFolderPath = PathUtils::cleanPath(folderPath);
|
||||
@ -92,8 +93,7 @@ void ConfigMgr::locateConfigFolder()
|
||||
// Check user config.
|
||||
{
|
||||
const QString configFolderName("user_files");
|
||||
QString folderPath(QCoreApplication::applicationDirPath()
|
||||
+ '/' + configFolderName);
|
||||
QString folderPath(appDirPath + '/' + configFolderName);
|
||||
if (QDir(folderPath).exists()) {
|
||||
// Config folder in app/.
|
||||
m_userConfigFolderPath = PathUtils::cleanPath(folderPath);
|
||||
@ -375,3 +375,25 @@ QString ConfigMgr::getLogFile() const
|
||||
{
|
||||
return PathUtils::concatenateFilePath(ConfigMgr::getInst().getUserFolder(), "vnotex.log");
|
||||
}
|
||||
|
||||
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.
|
||||
#elif defined(Q_OS_MACOS)
|
||||
auto exePath = QCoreApplication::applicationFilePath();
|
||||
const QString exeName = c_appName.toLower() + ".app";
|
||||
int idx = exePath.indexOf(exeName + QStringLiteral("/Contents/MacOS/"));
|
||||
if (idx != -1) {
|
||||
return exePath.left(idx + exeName.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
return QCoreApplication::applicationFilePath();
|
||||
}
|
||||
|
||||
QString ConfigMgr::getApplicationDirPath()
|
||||
{
|
||||
return PathUtils::parentDirPath(getApplicationFilePath());
|
||||
}
|
||||
|
@ -94,6 +94,10 @@ namespace vnotex
|
||||
// Called at boostrap without QApplication instance.
|
||||
static QString locateSessionConfigFilePathAtBootstrap();
|
||||
|
||||
static QString getApplicationFilePath();
|
||||
|
||||
static QString getApplicationDirPath();
|
||||
|
||||
static const QString c_orgName;
|
||||
|
||||
static const QString c_appName;
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
||||
if (ret == RESTART_EXIT_CODE) {
|
||||
// Asked to restart VNote.
|
||||
guard.exit();
|
||||
QProcess::startDetached(qApp->applicationFilePath(), QStringList());
|
||||
QProcess::startDetached(ConfigMgr::getApplicationFilePath(), QStringList());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -313,11 +313,13 @@ 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