Settings.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. GNU General Public License version 3 notice
  3. Copyright (C) 2012 Mihawk <luiz@netdome.biz>. All rights reserved.
  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 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see < http://www.gnu.org/licenses/ >.
  14. */
  15. #ifndef SETTINGS_H
  16. #define SETTINGS_H
  17. #include <QList>
  18. #include <QString>
  19. class QSettings;
  20. /**
  21. This class provides direct settings file access for the whole application.
  22. @author Mihawk <luiz@netdome.biz>
  23. @file Settings.h
  24. */
  25. class Settings
  26. {
  27. public:
  28. // Server information struct
  29. // Struct to save server information from the config file
  30. struct Server
  31. {
  32. QString address;
  33. quint16 port;
  34. bool supportsSendPrivate;
  35. };
  36. typedef QList<Server> ServerList;
  37. /**
  38. The class single instance.
  39. @return The settings class
  40. */
  41. static Settings* globalInstance();
  42. /**
  43. Changes the config file used by us.
  44. @param fileName The filename to be used
  45. @return True if the file was loaded successfully, false otherwise
  46. */
  47. bool changeConfigFile(const QString& fileName);
  48. /**
  49. Gets and sets the serverlist
  50. */
  51. ServerList serverList();
  52. void setServerList(ServerList& list);
  53. /**
  54. Config file direct parameter accessors
  55. */
  56. QString quakeFolder() const;
  57. QString botName() const;
  58. int botPing() const;
  59. int botTopColor() const;
  60. int botBottomColor() const;
  61. bool botSpectator() const;
  62. int floodProtTime() const;
  63. int qwFloodProtTime() const;
  64. int spamFloodProtTime() const;
  65. unsigned int queryInterval() const;
  66. int timeToSayHiAfterConnected() const;
  67. int timeToWaitForCountReply() const;
  68. bool developerMode() const;
  69. QString sshUserName() const;
  70. QString sshHostName() const;
  71. int refreshHostNamesHour() const;
  72. /**
  73. Save current settings to the file.
  74. */
  75. void save();
  76. private:
  77. static Settings* ourInstance; // Myself
  78. static QSettings* ourSettings; // The QSettings object
  79. // Disable direct object creation, copy and destruction
  80. Settings();
  81. ~Settings();
  82. Settings(Settings&) {}
  83. };
  84. #endif // SETTINGS_H