mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
parent
d51e486a84
commit
c2e10f5783
@ -76,11 +76,12 @@ ConfigMgr::~ConfigMgr()
|
|||||||
|
|
||||||
void ConfigMgr::locateConfigFolder()
|
void ConfigMgr::locateConfigFolder()
|
||||||
{
|
{
|
||||||
|
const auto appDirPath = getApplicationDirPath();
|
||||||
|
qInfo() << "app folder" << appDirPath;
|
||||||
// Check app config.
|
// Check app config.
|
||||||
{
|
{
|
||||||
const QString configFolderName("vnotex_files");
|
const QString configFolderName("vnotex_files");
|
||||||
QString folderPath(QCoreApplication::applicationDirPath()
|
QString folderPath(appDirPath + '/' + configFolderName);
|
||||||
+ '/' + configFolderName);
|
|
||||||
if (QDir(folderPath).exists()) {
|
if (QDir(folderPath).exists()) {
|
||||||
// Config folder in app/.
|
// Config folder in app/.
|
||||||
m_appConfigFolderPath = PathUtils::cleanPath(folderPath);
|
m_appConfigFolderPath = PathUtils::cleanPath(folderPath);
|
||||||
@ -92,8 +93,7 @@ void ConfigMgr::locateConfigFolder()
|
|||||||
// Check user config.
|
// Check user config.
|
||||||
{
|
{
|
||||||
const QString configFolderName("user_files");
|
const QString configFolderName("user_files");
|
||||||
QString folderPath(QCoreApplication::applicationDirPath()
|
QString folderPath(appDirPath + '/' + configFolderName);
|
||||||
+ '/' + configFolderName);
|
|
||||||
if (QDir(folderPath).exists()) {
|
if (QDir(folderPath).exists()) {
|
||||||
// Config folder in app/.
|
// Config folder in app/.
|
||||||
m_userConfigFolderPath = PathUtils::cleanPath(folderPath);
|
m_userConfigFolderPath = PathUtils::cleanPath(folderPath);
|
||||||
@ -375,3 +375,25 @@ QString ConfigMgr::getLogFile() const
|
|||||||
{
|
{
|
||||||
return PathUtils::concatenateFilePath(ConfigMgr::getInst().getUserFolder(), "vnotex.log");
|
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.
|
// Called at boostrap without QApplication instance.
|
||||||
static QString locateSessionConfigFilePathAtBootstrap();
|
static QString locateSessionConfigFilePathAtBootstrap();
|
||||||
|
|
||||||
|
static QString getApplicationFilePath();
|
||||||
|
|
||||||
|
static QString getApplicationDirPath();
|
||||||
|
|
||||||
static const QString c_orgName;
|
static const QString c_orgName;
|
||||||
|
|
||||||
static const QString c_appName;
|
static const QString c_appName;
|
||||||
|
@ -131,7 +131,7 @@ 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(qApp->applicationFilePath(), QStringList());
|
QProcess::startDetached(ConfigMgr::getApplicationFilePath(), QStringList());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,11 +313,13 @@ 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