1 /*************************************************************************** 2 * Copyright (C) 2017 by Hendrik Vennekate * 3 * * 4 * This program is free software; you can redistribute it and/or modify * 5 * it under the terms of the GNU General Public License as published by * 6 * the Free Software Foundation; either version 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 * GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License * 15 * along with this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 18 ***************************************************************************/ 19 20 #ifndef APPLICATIONSETTINGS_H 21 #define APPLICATIONSETTINGS_H 22 23 #include <QObject> 24 #include "scenesettings.h" 25 26 class ProgramVersion; 27 class QByteArray; 28 29 namespace Molsketch { 30 class StringListSettingsItem; 31 class StringSettingsItem; 32 } 33 34 class ApplicationSettingsPrivate; 35 36 class ApplicationSettings : public Molsketch::SceneSettings // TODO this doesn't seem to be such a very good idea... better have these settings independent of the scene settings 37 { 38 Q_OBJECT 39 Q_DECLARE_PRIVATE(ApplicationSettings) 40 QScopedPointer<ApplicationSettingsPrivate> d_ptr; 41 public: 42 explicit ApplicationSettings(Molsketch::SettingsFacade *facade, QObject *parent = 0); 43 ~ApplicationSettings(); 44 45 ProgramVersion latestReleaseNotesVersionShown() const; 46 ProgramVersion currentVersion() const; 47 void updateReleaseNotesShownVersion(); 48 QString versionNick() const; 49 PROPERTY_DECL(Molsketch::StringListSettingsItem, libraries) 50 void setToolButtonStyle(const Qt::ToolButtonStyle&); 51 Qt::ToolButtonStyle getToolButtonStyle() const; 52 void setWindowSize(const QSize&); 53 QSize getWindowSize() const; 54 void setWindowState(const QByteArray&); 55 QByteArray windowState() const; 56 void setLastPath(const QString&); 57 QString lastPath() const; 58 void setAutoSaveInterval(const int&); 59 int autoSaveInterval() const; 60 void setObabelIfacePath(const QString&); 61 QString obabelIfacePath() const; 62 void setObabelFormatsPath(const QString&); 63 QString obabelFormatsPath() const; 64 void setPixelScalingFactor(const qreal&); 65 qreal pixelScalingFactor() const; 66 PROPERTY_DECL(Molsketch::StringSettingsItem, wikiQueryUrl) 67 signals: 68 void changedObabelIfacePath(const QString&); 69 void changeObabelFormatsPath(const QString&); 70 }; 71 72 #define APP_PROPERTY(NAME, TYPE, CONFIGSTRING) \ 73 void ApplicationSettings::set##NAME(const TYPE& value) { settingsFacade().setValue(CONFIGSTRING, value); } \ 74 TYPE ApplicationSettings::get##NAME() const { return settingsFacade().value(CONFIGSTRING).value<TYPE>(); } 75 76 77 #endif // APPLICATIONSETTINGS_H 78