aconfig.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "aconfig.h"
  2. #include <QApplication>
  3. AConfig::AConfig() {
  4. filename_ = QApplication::applicationDirPath() + "/settings.ini";
  5. }
  6. void AConfig::saveConfig(){
  7. QSettings settings(filename_, QSettings::IniFormat);
  8. //Global
  9. settings.setValue("Global/current_theme", "lotro");
  10. settings.setValue("Global/default_theme", "lotro");
  11. //Editor
  12. settings.setValue("Editor/texts", true);
  13. settings.setValue("Editor/fonts", true);
  14. settings.setValue("Editor/images", true);
  15. settings.setValue("Editor/sounds", true);
  16. settings.setValue("Editor/videos", false);
  17. settings.setValue("Editor/screens", true);
  18. settings.setValue("Editor/textures", true);
  19. //Network
  20. settings.setValue("Network/server", "http://translate.lotros.ru");
  21. settings.setValue("Network/coupon", "http://translate.lotros.ru/coupon");
  22. settings.setValue("Network/servers", "http://translate.lotros.ru/servers");
  23. settings.setValue("Network/foot", "http://translate.lotros.ru/profmessage");
  24. settings.setValue("Network/news", "http://translate.lotros.ru/groupware/launcher_news");
  25. settings.setValue("Network/launcher", "http://translate.lotros.ru/upload/launcher");
  26. settings.setValue("Network/releases", "http://translate.lotros.ru/groupware/check_updates");
  27. settings.setValue("Network/info", "http://translate.lotros.ru/paths");
  28. settings.setValue("Network/update", "http://translate.lotros.ru/groupware/update");
  29. // Values
  30. settings.setValue("Values/coupon", "");
  31. settings.setValue("Values/servers", "");
  32. // Local
  33. settings.setValue("Local/file", "client_local_English.dat");
  34. //Datetime
  35. settings.setValue("Datetime/texts", true);
  36. settings.setValue("Datetime/fonts", true);
  37. settings.setValue("Datetime/images", true);
  38. settings.setValue("Datetime/sounds", true);
  39. settings.setValue("Datetime/videos", false);
  40. settings.setValue("Datetime/loadscreens", true);
  41. settings.setValue("Datetime/textures", true);
  42. //Updates
  43. settings.setValue("Updates/update", false);
  44. settings.setValue("Updates/micro", false);
  45. settings.sync();
  46. }
  47. QString AConfig::getValue(QString section, QString key){
  48. QSettings settings(filename_, QSettings::IniFormat);
  49. settings.beginGroup(section);
  50. key = settings.value(key, -1).toString();
  51. settings.endGroup();
  52. return key;
  53. }
  54. void AConfig::setValue(QString section, QString key, QString value){
  55. QSettings settings(filename_, QSettings::IniFormat);
  56. settings.beginGroup(section);
  57. settings.setValue(key, value);
  58. settings.sync();
  59. }
  60. void AConfig::deleteKey(QString section, QString key){
  61. QSettings settings(filename_, QSettings::IniFormat);
  62. QStringList keys = settings.childKeys();
  63. settings.beginGroup(section);
  64. if (keys.contains(key))
  65. settings.remove(key);
  66. settings.endGroup();
  67. }
  68. void AConfig::deleteSection(QString section){
  69. QSettings settings(filename_, QSettings::IniFormat );
  70. settings.beginGroup(section);
  71. settings.remove("");
  72. settings.endGroup();
  73. }