16 #include "Base/Util/Assert.h"
17 #include <QApplication>
20 #include <QStandardPaths>
25 const QString S_CREATE_NEW_PROJECT_ON_STARTUP =
"CreateNewProjectOnStartup";
26 const QString S_STYLE =
"UiStyle";
27 const QString S_SIZE =
"Size";
28 const QString S_POS =
"Pos";
29 const QString S_DEFAULT_FUNCTIONALITIES =
"DefaultFunctionalities";
30 const QString S_SINGLE_INSTRUMENT_MODE =
"SingleInstrumentMode";
31 const QString S_SINGLE_SAMPLE_MODE =
"SingleSampleMode";
32 const QString S_DEFAULT_UNIT_IS_ANGSTROM =
"DefaultUnitIsAngstrom";
55 return QSettings().value(S_CREATE_NEW_PROJECT_ON_STARTUP,
true).toBool();
60 QSettings().setValue(S_CREATE_NEW_PROJECT_ON_STARTUP, b);
65 return static_cast<Style>(QSettings().value(S_STYLE,
static_cast<int>(
Style::light)).toInt());
70 QSettings().setValue(S_STYLE,
static_cast<int>(style));
75 return QSettings().value(S_DEFAULT_FUNCTIONALITIES, absenceValue);
80 QSettings().setValue(S_DEFAULT_FUNCTIONALITIES, functionalities);
85 return QSettings().value(S_SINGLE_INSTRUMENT_MODE,
false).toBool();
90 QSettings().setValue(S_SINGLE_INSTRUMENT_MODE, b);
95 return QSettings().value(S_SINGLE_SAMPLE_MODE,
false).toBool();
100 QSettings().setValue(S_SINGLE_SAMPLE_MODE, b);
105 return QSettings().value(S_DEFAULT_UNIT_IS_ANGSTROM,
false).toBool();
110 QSettings().setValue(S_DEFAULT_UNIT_IS_ANGSTROM, b);
115 ASSERT(!w->objectName().isEmpty());
117 settings.setValue(S_SIZE +
"/" + w->objectName(), w->size());
118 settings.setValue(S_POS +
"/" + w->objectName(), w->pos());
123 ASSERT(!w->objectName().isEmpty());
126 const QSize size = settings.value(S_SIZE +
"/" + w->objectName(), QSize()).toSize();
129 if (settings.contains(S_POS +
"/" + w->objectName()))
130 w->move(settings.value(S_POS +
"/" + w->objectName()).toPoint());
139 QFile base(
":/styles/Base.stylesheet");
140 base.open(QFile::ReadOnly);
141 QFile light(
":/styles/Light.stylesheet");
142 light.open(QFile::ReadOnly);
143 stylesheet = base.readAll() + light.readAll();
147 QFile base(
":/styles/Base.stylesheet");
148 base.open(QFile::ReadOnly);
149 QFile dark(
":/styles/Dark.stylesheet");
150 dark.open(QFile::ReadOnly);
151 stylesheet = base.readAll() + dark.readAll();
155 QFile native(
":/styles/Native.stylesheet");
156 native.open(QFile::ReadOnly);
157 stylesheet = native.readAll();
162 qApp->setStyleSheet(stylesheet);
ApplicationSettings * appSettings
global pointer to the instance
Defines class ApplicationSettings.
Application wide settings.
void setStyleToUse(Style style)
void setDefaultIsSingleInstrumentMode(bool b)
void setDefaultUnitIsAngstrom(bool b) const
Palette m_styleSheetPalette
void loadWindowSizeAndPos(QWidget *w)
bool defaultIsSingleSampleMode() const
const Palette & styleSheetPalette() const
bool defaultIsSingleInstrumentMode() const
void saveWindowSizeAndPos(const QWidget *w)
bool useNativeFileDialog() const
ApplicationSettings::Style currentStyle()
bool createNewProjectOnStartup() const
void setDefaultFunctionalities(const QVariant &functionalities)
void setDefaultIsSingleSampleMode(bool b)
QVariant defaultFunctionalities(const QVariant &absenceValue) const
bool defaultUnitIsAngstrom() const
void loadStyle(ApplicationSettings::Style style)
ApplicationSettings::Style m_currentStyle
void setCreateNewProjectOnStartup(bool b)
QColor headlineBackground