equal
deleted
inserted
replaced
34 #include <QMessageBox> |
34 #include <QMessageBox> |
35 #include <QTextStream> |
35 #include <QTextStream> |
36 #include "gameuiconfig.h" |
36 #include "gameuiconfig.h" |
37 #include "hwform.h" |
37 #include "hwform.h" |
38 #include "pages.h" |
38 #include "pages.h" |
|
39 #include "hwconsts.h" |
39 |
40 |
40 GameUIConfig::GameUIConfig(HWForm * FormWidgets) |
41 GameUIConfig::GameUIConfig(HWForm * FormWidgets) |
41 : QObject() |
42 : QObject() |
42 { |
43 { |
43 Form = FormWidgets; |
44 Form = FormWidgets; |
44 |
45 |
45 cfgdir.setPath(cfgdir.homePath()); |
46 QFile settings(cfgdir->absolutePath() + "/options"); |
46 if (!cfgdir.exists(".hedgewars")) |
|
47 { |
|
48 if (!cfgdir.mkdir(".hedgewars")) |
|
49 { |
|
50 QMessageBox::critical(0, |
|
51 tr("Error"), |
|
52 tr("Cannot create directory %1").arg("/.hedgewars"), |
|
53 tr("Quit")); |
|
54 return ; |
|
55 } |
|
56 } |
|
57 cfgdir.cd(".hedgewars"); |
|
58 |
|
59 QFile settings(cfgdir.absolutePath() + "/options"); |
|
60 if (settings.open(QIODevice::ReadOnly)) |
47 if (settings.open(QIODevice::ReadOnly)) |
61 { |
48 { |
62 QTextStream stream(&settings); |
49 QTextStream stream(&settings); |
63 stream.setCodec("UTF-8"); |
50 stream.setCodec("UTF-8"); |
64 QString str; |
51 QString str; |
88 } |
75 } |
89 } |
76 } |
90 |
77 |
91 QStringList GameUIConfig::GetTeamsList() |
78 QStringList GameUIConfig::GetTeamsList() |
92 { |
79 { |
93 return cfgdir.entryList(QStringList("*.cfg")); |
80 return cfgdir->entryList(QStringList("*.cfg")); |
94 } |
81 } |
95 |
82 |
96 void GameUIConfig::SaveOptions() |
83 void GameUIConfig::SaveOptions() |
97 { |
84 { |
98 QFile settings(cfgdir.absolutePath() + "/options"); |
85 QFile settings(cfgdir->absolutePath() + "/options"); |
99 if (!settings.open(QIODevice::WriteOnly)) |
86 if (!settings.open(QIODevice::WriteOnly)) |
100 { |
87 { |
101 QMessageBox::critical(0, |
88 QMessageBox::critical(0, |
102 tr("Error"), |
89 tr("Error"), |
103 tr("Cannot save options to file %1").arg(settings.fileName()), |
90 tr("Cannot save options to file %1").arg(settings.fileName()), |