Settings.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. QString password; // Used for spectator VIP slots
  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; // QuakeWorld folder
  57. QString botName() const; // Bot name
  58. int botPing() const; // Bot ping
  59. int botTopColor() const; // Bot shirts color
  60. int botBottomColor() const; // Bot pants color
  61. bool botSpectator() const; // Bot joins as spectator
  62. int floodProtTime() const; // Flood protection time
  63. int qwFloodProtTime() const; // Flood protection time for .qw command
  64. int spamFloodProtTime() const; // Flood protection time for .spam command
  65. unsigned int queryInterval() const; // Interval between server status queries (check if there are or there arent players on a given server)
  66. int timeToSayHiAfterConnected() const; // OBSOLETE
  67. int timeToWaitForCountReply() const; // Time to wait from a reply from central about the amount of people that the message we broadcasted has reached
  68. bool developerMode() const; // Developer mode
  69. QString sshUserName() const; // Username on central
  70. QString sshHostName() const; // Central's HostName
  71. quint16 sshPort() const; // Central's port
  72. int refreshHostNamesHour() const; // An specific hour that the bot must refresh his hostname list
  73. int maxServers() const; // Maximum servers that we can monitor
  74. /**
  75. Save current settings to the file.
  76. */
  77. void save();
  78. private:
  79. static Settings* ourInstance; // Myself
  80. static QSettings* ourSettings; // The QSettings object
  81. // Disable direct object creation, copy and destruction
  82. Settings();
  83. ~Settings();
  84. Settings(Settings&) {}
  85. };
  86. #endif // SETTINGS_H