settings.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "settings.h"
  2. namespace Keys {
  3. constexpr auto ServiceUrl = "serviceUrl";
  4. constexpr auto Login = "login";
  5. constexpr auto Password = "password";
  6. }
  7. QString Settings::serviceUrl() const
  8. {
  9. return m_settings.value(Keys::ServiceUrl, "https://mynoolightservice.org").toString();
  10. }
  11. void Settings::setServiceUrl(const QString &newServiceUrl)
  12. {
  13. if (serviceUrl() == newServiceUrl) {
  14. return;
  15. }
  16. m_settings.setValue(Keys::ServiceUrl, newServiceUrl);
  17. emit serviceUrlChanged();
  18. }
  19. QString Settings::login() const
  20. {
  21. return m_settings.value(Keys::Login).toString();
  22. }
  23. void Settings::setLogin(const QString &newLogin)
  24. {
  25. if (login() == newLogin) {
  26. return;
  27. }
  28. m_settings.setValue(Keys::Login, newLogin);
  29. emit loginChanged();
  30. }
  31. QString Settings::password() const
  32. {
  33. return m_settings.value(Keys::Password).toString();
  34. }
  35. void Settings::setPassword(const QString &newPassword)
  36. {
  37. if (password() == newPassword) {
  38. return;
  39. }
  40. m_settings.setValue(Keys::Password, newPassword);
  41. emit passwordChanged();
  42. }