mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Servatrice: group all the use of QSettings in a single file
and add a method to guess the path of servatrice.ini
This commit is contained in:
parent
277aba79dc
commit
a1b6600fe1
7 changed files with 113 additions and 53 deletions
37
servatrice/src/settingscache.cpp
Normal file
37
servatrice/src/settingscache.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "settingscache.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
QString SettingsCache::guessConfigurationPath(QString & specificPath)
|
||||
{
|
||||
const QString fileName="servatrice.ini";
|
||||
QString guessFileName;
|
||||
|
||||
// specific path
|
||||
if(!specificPath.isEmpty() && QFile::exists(specificPath))
|
||||
return specificPath;
|
||||
|
||||
// application directory path
|
||||
guessFileName = QCoreApplication::applicationDirPath() + "/" + fileName;
|
||||
if(QFile::exists(guessFileName))
|
||||
return guessFileName;
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
// /etc
|
||||
guessFileName = "/etc/" + fileName;
|
||||
if(QFile::exists(guessFileName))
|
||||
return guessFileName;
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
guessFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + fileName;
|
||||
#else
|
||||
guessFileName = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + fileName;
|
||||
#endif
|
||||
return guessFileName;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue