-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from scgtrp/profiles
support multiple machine-specific configurations ("profiles")
- Loading branch information
Showing
6 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "profiles.h" | ||
#include <QUrl> | ||
|
||
// chosen for backward compatibility with pre-profiles versions, which always stored settings in `settings.ini` | ||
const QString default_profile_name = "settings"; | ||
|
||
QStringList getProfileNames() { | ||
const QDir configDir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); | ||
const QStringList configFiles = configDir.entryList({"*.ini"}, QDir::Files); | ||
QStringList rv; | ||
for (QString configFile : configFiles) { | ||
rv << QUrl::fromPercentEncoding(configFile.replace(QRegExp("\\.ini$"), "").toUtf8()); | ||
} | ||
return rv; | ||
} | ||
|
||
QString configPathForProfile(QString profile_name) { | ||
const QDir configDir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); | ||
return configDir.filePath(QUrl::toPercentEncoding(profile_name) + ".ini"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef PROFILES_H | ||
#define PROFILES_H | ||
#include <QStringList> | ||
#include <QStandardPaths> | ||
#include <QDir> | ||
|
||
extern const QString default_profile_name; | ||
QStringList getProfileNames(); | ||
QString configPathForProfile(QString profile_name); | ||
|
||
#endif // PROFILES_H |