mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
The LibUsb (and possibly other classes) need to know what operating system we are running on at runtime. In the past this has been achieved with lots of #ifdef pre- processor conditionals, but this makes the code quite difficult to read in places. This patch introduces the variable OperatingSystem and it can be one of WINDOWS, LINUX, OSX.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include <QDir>
|
|
#include "Settings.h"
|
|
#include <QSettings>
|
|
#include <QDebug>
|
|
|
|
#ifdef Q_OS_MAC
|
|
int OperatingSystem = OSX;
|
|
#elif defined Q_OS_WIN32
|
|
int OperatingSystem = WINDOWS;
|
|
#elif defined Q_OS_LINUX
|
|
int OperatingSystem = LINUX;
|
|
#endif
|
|
|
|
static GSettings *GetApplicationSettings()
|
|
{
|
|
GSettings *settings;
|
|
QDir home = QDir();
|
|
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
|
if(!home.exists("Library/GoldenCheetah"))
|
|
settings = new GSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
|
else
|
|
settings = new GSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
|
return settings;
|
|
}
|
|
|
|
QVariant
|
|
GSettings::value(const QObject * /*me*/, const QString key, const QVariant def) const
|
|
{
|
|
|
|
// debug output ?
|
|
//for (const QObject *p=me; p; p = p->parent()) {
|
|
//if (p->property("instanceName").toString() != "")
|
|
//qDebug()<<p->property("instanceName").toString();
|
|
//}
|
|
|
|
return QSettings::value(key, def);
|
|
}
|
|
|
|
|
|
// initialise with no cyclist
|
|
// as soon as a cyclist is opened it will be intialised via mainwindow
|
|
GSettings *appsettings = GetApplicationSettings();
|