Use settingsFolder instead of configDir

This commit is contained in:
vslg 2020-09-05 15:02:13 -03:00
parent c41ed5d77d
commit 6f9d983e03
2 changed files with 9 additions and 9 deletions

View File

@ -22,7 +22,7 @@ ApplicationWindow {
property var uiState: ({}) property var uiState: ({})
property var history: ({}) property var history: ({})
property var theme: null property var theme: null
property string configDir property string settingsFolder
readonly property var visibleMenus: ({}) readonly property var visibleMenus: ({})
readonly property var visiblePopups: ({}) readonly property var visiblePopups: ({})
@ -114,6 +114,6 @@ ApplicationWindow {
HTrayIcon { HTrayIcon {
window: window window: window
settingsFolder: configDir settingsFolder: settingsFolder
} }
} }

View File

@ -95,14 +95,14 @@ void onExitSignal(int signum) {
bool setLockFile(QString configPath) { bool setLockFile(QString configPath) {
QDir configDir(configPath); QDir settingsFolder(configPath);
if (! configDir.mkpath(".")) { if (! settingsFolder.mkpath(".")) {
qFatal("Could not create config file."); qFatal("Could not create config file.");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
lockFile = new QLockFile(configDir.absoluteFilePath(".lock")); lockFile = new QLockFile(settingsFolder.absoluteFilePath(".lock"));
lockFile->tryLock(0); lockFile->tryLock(0);
switch (lockFile->error()) { switch (lockFile->error()) {
@ -111,7 +111,7 @@ bool setLockFile(QString configPath) {
} }
case QLockFile::LockFailedError: { case QLockFile::LockFailedError: {
qWarning("Opening already running Mirage instance."); qWarning("Opening already running Mirage instance.");
QFile showFile(configDir.absoluteFilePath(".show")); QFile showFile(settingsFolder.absoluteFilePath(".show"));
showFile.open(QIODevice::WriteOnly); showFile.open(QIODevice::WriteOnly);
showFile.close(); showFile.close();
return false; return false;
@ -135,14 +135,14 @@ int main(int argc, char *argv[]) {
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QString customConfigDir(qEnvironmentVariable("MIRAGE_CONFIG_DIR")); QString customConfigDir(qEnvironmentVariable("MIRAGE_CONFIG_DIR"));
QString configDir( QString settingsFolder(
customConfigDir.isEmpty() ? customConfigDir.isEmpty() ?
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)
+ "/" + QCoreApplication::applicationName() : + "/" + QCoreApplication::applicationName() :
customConfigDir customConfigDir
); );
if (! setLockFile(configDir)) return EXIT_SUCCESS; if (! setLockFile(settingsFolder)) return EXIT_SUCCESS;
QApplication app(argc, argv); QApplication app(argc, argv);
// Register handlers for quit signals, e.g. SIGINT/Ctrl-C in unix terminals // Register handlers for quit signals, e.g. SIGINT/Ctrl-C in unix terminals
@ -246,7 +246,7 @@ int main(int argc, char *argv[]) {
app.exit(EXIT_FAILURE); app.exit(EXIT_FAILURE);
} }
component.create(objectContext)->setProperty("configDir", configDir); component.create(objectContext)->setProperty("settingsFolder", settingsFolder);
// Finally, execute the app. Return its exit code after clearing the lock. // Finally, execute the app. Return its exit code after clearing the lock.
int exit_code = app.exec(); int exit_code = app.exec();