Settings.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. };
  35. typedef QList<Server> ServerList;
  36. /**
  37. The class single instance.
  38. @return The settings class
  39. */
  40. static Settings* globalInstance();
  41. /**
  42. Changes the config file used by us.
  43. @param fileName The filename to be used
  44. @return True if the file was loaded successfully, false otherwise
  45. */
  46. bool changeConfigFile(const QString& fileName);
  47. /**
  48. Gets and sets the serverlist
  49. */
  50. ServerList serverList();
  51. void setServerList(ServerList& list);
  52. /**
  53. Config file direct parameter accessors
  54. */
  55. QString quakeFolder() const; // QuakeWorld folder
  56. QString botName() const; // Bot name
  57. int botPing() const; // Bot ping
  58. int botTopColor() const; // Bot shirts color
  59. int botBottomColor() const; // Bot pants color
  60. bool botSpectator() const; // Bot joins as spectator
  61. int floodProtTime() const; // Flood protection time
  62. int qwFloodProtTime() const; // Flood protection time for .qw command
  63. int spamFloodProtTime() const; // Flood protection time for .spam command
  64. unsigned int queryInterval() const; // Interval between server status queries (check if there are or there arent players on a given server)
  65. int timeToSayHiAfterConnected() const; // OBSOLETE
  66. int timeToWaitForCountReply() const; // Time to wait from a reply from central about the amount of people that the message we broadcasted has reached
  67. bool developerMode() const; // Developer mode
  68. QString sshUserName() const; // Username on central
  69. QString sshHostName() const; // Central's HostName
  70. quint16 sshPort() const; // Central's port
  71. int refreshHostNamesHour() const; // An specific hour that the bot must refresh his hostname list
  72. int maxServers() const; // Maximum servers that we can monitor
  73. /**
  74. Save current settings to the file.
  75. */
  76. void save();
  77. private:
  78. static Settings* ourInstance; // Myself
  79. static QSettings* ourSettings; // The QSettings object
  80. // Disable direct object creation, copy and destruction
  81. Settings();
  82. ~Settings();
  83. Settings(Settings&) {}
  84. };
  85. #endif // SETTINGS_H