config.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * <one line to give the library's name and an idea of what it does.>
  3. * Copyright 2015 Malte Veerman maldela@halloarsch.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License or (at your option) version 3 or any later version
  9. * accepted by the membership of KDE e.V. (or its successor approved
  10. * by the membership of KDE e.V.), which shall act as a proxy
  11. * defined in Section 14 of version 3 of the license.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "config.h"
  23. #define CONFIG_NAME "fancontrol-gui"
  24. #ifndef STANDARD_CONFIG_FILE
  25. #define STANDARD_CONFIG_FILE "/etc/fancontrol"
  26. #endif
  27. #ifndef STANDARD_SERVICE_NAME
  28. #define STANDARD_SERVICE_NAME "fancontrol"
  29. #endif
  30. namespace Fancontrol
  31. {
  32. Config *Config::m_instance = Q_NULLPTR;
  33. Config::Config(QObject *parent) : KCoreConfigSkeleton(KSharedConfig::openConfig(CONFIG_NAME), parent)
  34. {
  35. setCurrentGroup("preferences");
  36. addItemDouble("MinTemp", m_minTemp, 30.0);
  37. addItemDouble("MaxTemp", m_maxTemp, 90.0);
  38. addItemString("ServiceName", m_serviceName, QString(STANDARD_SERVICE_NAME));
  39. addItemPath("ConfigUrl", m_configUrl, QString("file://") + QString(STANDARD_CONFIG_FILE));
  40. load();
  41. }
  42. Config* Config::instance()
  43. {
  44. if (!m_instance)
  45. m_instance = new Config;
  46. return m_instance;
  47. }
  48. }
  49. // #include "config.moc"