author | Florian Fabre |
Fri, 14 Oct 2011 11:36:46 -0400 | |
changeset 6129 | d1e37b104683 |
parent 5925 | 2a9353b800cd |
child 6160 | 863d3edf5690 |
permissions | -rw-r--r-- |
579 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com> |
579 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
5252 | 19 |
#include "HWApplication.h" |
20 |
||
579 | 21 |
#include <QTranslator> |
22 |
#include <QLocale> |
|
23 |
#include <QMessageBox> |
|
1416
60b86d6fe9ae
Force plastique style, as others don't fully support stylesheets
unc0rr
parents:
1415
diff
changeset
|
24 |
#include <QPlastiqueStyle> |
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
25 |
#include <QRegExp> |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
26 |
#include <QMap> |
2898 | 27 |
#include <QSettings> |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
28 |
#include <QStringListModel> |
1146 | 29 |
|
579 | 30 |
#include "hwform.h" |
31 |
#include "hwconsts.h" |
|
32 |
||
3333 | 33 |
#ifdef _WIN32 |
34 |
#include <Shlobj.h> |
|
35 |
#endif |
|
5095
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
36 |
#ifdef __APPLE__ |
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
37 |
#include "CocoaInitializer.h" |
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
38 |
#endif |
3333 | 39 |
|
579 | 40 |
bool checkForDir(const QString & dir) |
41 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
42 |
QDir tmpdir; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
43 |
if (!tmpdir.exists(dir)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
44 |
if (!tmpdir.mkdir(dir)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
45 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
46 |
QMessageBox::critical(0, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
47 |
QObject::tr("Error"), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
48 |
QObject::tr("Cannot create directory %1").arg(dir), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
49 |
QObject::tr("OK")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
50 |
return false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
51 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
52 |
return true; |
579 | 53 |
} |
54 |
||
3697 | 55 |
int main(int argc, char *argv[]) { |
5252 | 56 |
HWApplication app(argc, argv); |
4888 | 57 |
app.setAttribute(Qt::AA_DontShowIconsInMenus,false); |
579 | 58 |
|
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
59 |
QStringList arguments = app.arguments(); |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
60 |
QMap<QString, QString> parsedArgs; |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
61 |
{ |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
62 |
QList<QString>::iterator i = arguments.begin(); |
2035 | 63 |
while(i != arguments.end()) { |
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
64 |
QString arg = *i; |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
65 |
|
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
66 |
QRegExp opt("--(\\S+)=(.+)"); |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
67 |
if(opt.exactMatch(arg)) { |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
68 |
parsedArgs[opt.cap(1)] = opt.cap(2); |
2035 | 69 |
i = arguments.erase(i); |
70 |
} else { |
|
71 |
++i; |
|
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
72 |
} |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
73 |
} |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
74 |
} |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
75 |
|
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
76 |
if(parsedArgs.contains("data-dir")) { |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
77 |
QFileInfo f(parsedArgs["data-dir"]); |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
78 |
if(!f.exists()) { |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
79 |
qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath(); |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
80 |
} |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
81 |
*cDataDir = f.absoluteFilePath(); |
3932 | 82 |
custom_data = true; |
2034
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
83 |
} |
decdf48cffd7
david_ac adding a commandline parameter for the data dir, as requested by svenstaro
nemo
parents:
1969
diff
changeset
|
84 |
|
2428 | 85 |
if(parsedArgs.contains("config-dir")) { |
86 |
QFileInfo f(parsedArgs["config-dir"]); |
|
87 |
*cConfigDir = f.absoluteFilePath(); |
|
3932 | 88 |
custom_config = true; |
2428 | 89 |
} |
90 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
91 |
app.setStyle(new QPlastiqueStyle); |
2377 | 92 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
93 |
QDateTime now = QDateTime::currentDateTime(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
94 |
srand(now.toTime_t()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
95 |
rand(); |
579 | 96 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
97 |
Q_INIT_RESOURCE(hedgewars); |
579 | 98 |
|
5849 | 99 |
QString styleSheetFromHell = |
100 |
QString( |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
101 |
"HWForm,QDialog{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
102 |
"background-image: url(\":/res/Background.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
103 |
"background-position: bottom center;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
104 |
"background-repeat: repeat-x;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
105 |
"background-color: #141250;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
106 |
"}" |
1154 | 107 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
108 |
"* {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
109 |
"color: #ffcc00;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
110 |
"selection-background-color: #ffcc00;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
111 |
"selection-color: #00351d;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
112 |
"}" |
1893 | 113 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
114 |
"QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " |
1893 | 115 |
"QComboBox QAbstractItemView, QMenu::item {" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
116 |
"background-color: rgba(13, 5, 68, 70%);" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
117 |
"}" |
1893 | 118 |
|
3185 | 119 |
"QComboBox::separator {" |
120 |
"border: solid; border-width: 3px; border-color: #ffcc00;" |
|
121 |
"}" |
|
122 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
123 |
"QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
124 |
"QTextBrowser, QSpinBox, QToolBox, QComboBox, " |
1893 | 125 |
"QComboBox QAbstractItemView, IconedGroupBox, " |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
126 |
".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, " |
1897 | 127 |
"QTabWidget::pane, QTabBar::tab {" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
128 |
"border: solid;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
129 |
"border-width: 3px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
130 |
"border-color: #ffcc00;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
131 |
"}" |
1893 | 132 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
133 |
"QPushButton:hover, QLineEdit:hover, QListWidget:hover, " |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
134 |
"QSpinBox:hover, QToolBox:hover, QComboBox:hover {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
135 |
"border-color: yellow;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
136 |
"}" |
1893 | 137 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
138 |
"QLineEdit, QListWidget,QTableView, QTextBrowser, " |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
139 |
"QSpinBox, QToolBox { " |
3019 | 140 |
"border-radius: 10px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
141 |
"}" |
1893 | 142 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
143 |
"QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
144 |
"QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
145 |
"IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " |
3019 | 146 |
"SelWeaponWidget, QCheckBox, QRadioButton, QPushButton {" |
147 |
"font: bold 13px;" |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
148 |
"}" |
2517 | 149 |
"SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected {" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
150 |
"background-position: bottom center;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
151 |
"background-repeat: repeat-x;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
152 |
"background-color: #000000;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
153 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
154 |
".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
155 |
"background-position: bottom center;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
156 |
"background-repeat: repeat-x;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
157 |
"border-radius: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
158 |
"background-color: rgba(13, 5, 68, 70%);" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
159 |
"padding: 6px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
160 |
"}" |
2072
6e0fcbcc3f60
Custom controls implementing paintEvent play poorly with stars, especially SquareLabel
nemo
parents:
2035
diff
changeset
|
161 |
/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
162 |
"IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, " |
2072
6e0fcbcc3f60
Custom controls implementing paintEvent play poorly with stars, especially SquareLabel
nemo
parents:
2035
diff
changeset
|
163 |
"IconedGroupBox QSpinBox {" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
164 |
"border-radius: 0;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
165 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
166 |
"IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
167 |
"IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
168 |
"background-color: #130f2c;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
169 |
"}" |
1893 | 170 |
|
171 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
172 |
"QPushButton {" |
3019 | 173 |
"border-radius: 8px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
174 |
"background-origin: margin;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
175 |
"background-position: top left;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
176 |
"background-color: rgba(18, 42, 5, 70%);" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
177 |
"}" |
1893 | 178 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
179 |
"QPushButton:pressed{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
180 |
"border-color: white;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
181 |
"}" |
1154 | 182 |
|
6129 | 183 |
"QPushButton:focus {" |
184 |
"outline: none;" |
|
185 |
"}" |
|
186 |
||
187 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
188 |
"QHeaderView {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
189 |
"border-radius: 0;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
190 |
"border-width: 0;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
191 |
"border-bottom-width: 3px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
192 |
"background-color: #00351d;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
193 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
194 |
"QTableView {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
195 |
"alternate-background-color: #2f213a;" |
3865 | 196 |
"gridline-color: transparent;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
197 |
"}" |
1172 | 198 |
|
1893 | 199 |
"QTabBar::tab {" |
1897 | 200 |
"border-bottom-width: 0;" |
1893 | 201 |
"border-radius: 0;" |
202 |
"border-top-left-radius: 6px;" |
|
203 |
"border-top-right-radius: 6px;" |
|
204 |
"padding: 3px;" |
|
205 |
"}" |
|
206 |
"QTabBar::tab:!selected {" |
|
207 |
"color: #0d0544;" |
|
208 |
"background-color: #ffcc00;" |
|
209 |
"}" |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
210 |
"QSpinBox::up-button{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
211 |
"background: transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
212 |
"width: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
213 |
"height: 10px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
214 |
"}" |
1893 | 215 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
216 |
"QSpinBox::up-arrow {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
217 |
"image: url(\":/res/spin_up.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
218 |
"}" |
1893 | 219 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
220 |
"QSpinBox::down-arrow {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
221 |
"image: url(\":/res/spin_down.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
222 |
"}" |
1893 | 223 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
224 |
"QSpinBox::down-button {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
225 |
"background: transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
226 |
"width: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
227 |
"height: 10px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
228 |
"}" |
1172 | 229 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
230 |
"QComboBox {" |
3019 | 231 |
"border-radius: 10px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
232 |
"padding: 3px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
233 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
234 |
"QComboBox:pressed{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
235 |
"border-color: white;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
236 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
237 |
"QComboBox::drop-down{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
238 |
"border: transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
239 |
"width: 25px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
240 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
241 |
"QComboBox::down-arrow {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
242 |
"image: url(\":/res/dropdown.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
243 |
"}" |
2377 | 244 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
245 |
"VertScrArea {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
246 |
"background-position: bottom center;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
247 |
"background-repeat: repeat-x;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
248 |
"}" |
2377 | 249 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
250 |
"IconedGroupBox {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
251 |
"border-radius: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
252 |
"padding: 2px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
253 |
"}" |
1893 | 254 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
255 |
"QGroupBox::title{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
256 |
"subcontrol-origin: margin;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
257 |
"subcontrol-position: top left;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
258 |
"text-align: left;" |
5925
2a9353b800cd
Move options caption to box title. This frees up quite a bit of space at 800x600
nemo
parents:
5849
diff
changeset
|
259 |
"left: 15px;" |
2a9353b800cd
Move options caption to box title. This frees up quite a bit of space at 800x600
nemo
parents:
5849
diff
changeset
|
260 |
"top: -4px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
261 |
"}" |
1155 | 262 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
263 |
"QCheckBox::indicator:checked{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
264 |
"image: url(\":/res/checked.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
265 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
266 |
"QCheckBox::indicator:unchecked{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
267 |
"image: url(\":/res/unchecked.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
268 |
"}" |
2377 | 269 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
270 |
".QWidget{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
271 |
"background: transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
272 |
"}" |
1893 | 273 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
274 |
"QTabWidget::pane {" |
1893 | 275 |
"border-top-width: 2px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
276 |
"}" |
1413 | 277 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
278 |
"QMenu{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
279 |
"background-color: #ffcc00;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
280 |
"margin: 3px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
281 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
282 |
"QMenu::item {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
283 |
"background-color: #0d0544;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
284 |
"border: 1px solid transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
285 |
"font: bold;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
286 |
"padding: 2px 25px 2px 20px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
287 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
288 |
"QMenu::item:selected {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
289 |
"background-color: #2d2564;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
290 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
291 |
"QMenu::indicator {" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
292 |
"width: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
293 |
"height: 16px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
294 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
295 |
"QMenu::indicator:non-exclusive:checked{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
296 |
"image: url(\":/res/checked.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
297 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
298 |
"QMenu::indicator:non-exclusive:unchecked{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
299 |
"image: url(\":/res/unchecked.png\");" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
300 |
"}" |
1450 | 301 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
302 |
"QToolTip{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
303 |
"background-color: #0d0544;" |
3019 | 304 |
"border: 1px solid #ffcc00;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
305 |
"}" |
2377 | 306 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
307 |
":disabled{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
308 |
"color: #a0a0a0;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
309 |
"}" |
2072
6e0fcbcc3f60
Custom controls implementing paintEvent play poorly with stars, especially SquareLabel
nemo
parents:
2035
diff
changeset
|
310 |
"SquareLabel, ItemNum {" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
311 |
"background-color: #000000;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
312 |
"}" |
3714 | 313 |
"QSlider::groove::horizontal {" |
314 |
"height: 2px;" |
|
315 |
"margin: 2px 0px;" |
|
316 |
"background-color: #ffcc00;" |
|
317 |
"}" |
|
318 |
"QSlider::handle::horizontal {" |
|
319 |
"border: 0px;" |
|
320 |
"margin: -2px 0px;" |
|
321 |
"border-radius: 3px;" |
|
322 |
"background-color: #ffcc00;" |
|
323 |
"width: 8px;" |
|
324 |
"}" |
|
5849 | 325 |
); |
1150 | 326 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
327 |
bindir->cd("bin"); // workaround over NSIS installer |
579 | 328 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
329 |
if(cConfigDir->length() == 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
330 |
cfgdir->setPath(cfgdir->homePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
331 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
332 |
cfgdir->setPath(*cConfigDir); |
2428 | 333 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
334 |
if(cConfigDir->length() == 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
335 |
{ |
1965 | 336 |
#ifdef __APPLE__ |
3758 | 337 |
checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
338 |
cfgdir->cd("Library/Application Support/Hedgewars"); |
3333 | 339 |
#elif defined _WIN32 |
340 |
char path[1024]; |
|
341 |
if(!SHGetFolderPathA(0, CSIDL_PERSONAL, NULL, 0, path)) |
|
342 |
{ |
|
343 |
cfgdir->cd(path); |
|
3758 | 344 |
checkForDir(cfgdir->absolutePath() + "/Hedgewars"); |
3333 | 345 |
cfgdir->cd("Hedgewars"); |
346 |
} |
|
3758 | 347 |
else // couldn't retrieve documents folder? almost impossible, but in case fall back to classic path |
3333 | 348 |
{ |
3758 | 349 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
3333 | 350 |
cfgdir->cd(".hedgewars"); |
351 |
} |
|
2428 | 352 |
#else |
3758 | 353 |
checkForDir(cfgdir->absolutePath() + "/.hedgewars"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
354 |
cfgdir->cd(".hedgewars"); |
2428 | 355 |
#endif |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
356 |
} |
3758 | 357 |
|
358 |
if (checkForDir(cfgdir->absolutePath())) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
359 |
{ |
3758 | 360 |
// alternative loading/lookup paths |
361 |
// TODO: Uncomment paths as they're implemented |
|
362 |
checkForDir(cfgdir->absolutePath() + "/Data"); |
|
363 |
//checkForDir(cfgdir->absolutePath() + "/Data/Forts"); |
|
364 |
//checkForDir(cfgdir->absolutePath() + "/Data/Graphics"); |
|
365 |
//checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Flags"); |
|
366 |
//checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Graves"); |
|
367 |
//checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Hats"); |
|
368 |
//checkForDir(cfgdir->absolutePath() + "/Data/Maps"); |
|
369 |
//checkForDir(cfgdir->absolutePath() + "/Data/Missions"); |
|
370 |
//checkForDir(cfgdir->absolutePath() + "/Data/Missions/Campaign"); |
|
371 |
//checkForDir(cfgdir->absolutePath() + "/Data/Missions/Training"); |
|
372 |
//checkForDir(cfgdir->absolutePath() + "/Data/Sounds"); |
|
373 |
//checkForDir(cfgdir->absolutePath() + "/Data/Sounds/voices"); |
|
374 |
//checkForDir(cfgdir->absolutePath() + "/Data/Themes"); |
|
375 |
||
376 |
// config/save paths |
|
377 |
checkForDir(cfgdir->absolutePath() + "/Demos"); |
|
378 |
checkForDir(cfgdir->absolutePath() + "/Saves"); |
|
379 |
checkForDir(cfgdir->absolutePath() + "/Screenshots"); |
|
380 |
checkForDir(cfgdir->absolutePath() + "/Teams"); |
|
3914 | 381 |
checkForDir(cfgdir->absolutePath() + "/Logs"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
382 |
} |
579 | 383 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
384 |
datadir->cd(bindir->absolutePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
385 |
datadir->cd(*cDataDir); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
386 |
if(!datadir->cd("hedgewars/Data")) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
387 |
QMessageBox::critical(0, QMessageBox::tr("Error"), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
388 |
QMessageBox::tr("Failed to open data directory:\n%1\n" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
389 |
"Please check your installation"). |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
390 |
arg(datadir->absolutePath()+"/hedgewars/Data")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
391 |
return 1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
392 |
} |
579 | 393 |
|
5276
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
394 |
{ |
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
395 |
QDir dir; |
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
396 |
dir.setPath(cfgdir->absolutePath() + "/Data/Themes"); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
397 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
398 |
QStringList themes; |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
399 |
themes.append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); |
5276
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
400 |
|
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
401 |
dir.setPath(datadir->absolutePath() + "/Themes"); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
402 |
themes.append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
403 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
404 |
QList<QPair<QIcon, QIcon> > icons; |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
405 |
|
5307 | 406 |
themes.sort(); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
407 |
for(int i = themes.size() - 1; i >= 0; --i) |
5276
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
408 |
{ |
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
409 |
QFile tmpfile; |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
410 |
tmpfile.setFileName(QString("%1/Data/Themes/%2/icon.png").arg(cfgdir->absolutePath()).arg(themes.at(i))); |
5276
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
411 |
if (!tmpfile.exists()) |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
412 |
tmpfile.setFileName(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(themes.at(i))); |
5307 | 413 |
|
414 |
if(tmpfile.exists()) |
|
415 |
{ // load icon |
|
416 |
QPair<QIcon, QIcon> ic; |
|
417 |
ic.first = QIcon(QFileInfo(tmpfile).absoluteFilePath()); |
|
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
418 |
|
5307 | 419 |
QFile previewIconFile; |
420 |
previewIconFile.setFileName(QString("%1/Data/Themes/%2/icon@2x.png").arg(cfgdir->absolutePath()).arg(themes.at(i))); |
|
421 |
if (previewIconFile.exists()) ic.second = QIcon(QFileInfo(previewIconFile).absoluteFilePath()); |
|
422 |
else ic.second = QIcon(QString("%1/Themes/%2/icon@2x.png").arg(datadir->absolutePath()).arg(themes.at(i))); |
|
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
423 |
|
5307 | 424 |
icons.prepend(ic); |
425 |
} |
|
426 |
else |
|
427 |
{ |
|
428 |
themes.removeAt(i); |
|
5276
562070d3f978
Derive themes list from list of dirs in Themes folder which have icon.png inside
unc0rr
parents:
5257
diff
changeset
|
429 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
430 |
} |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
431 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
432 |
themesModel = new ThemesModel(themes); |
5307 | 433 |
Q_ASSERT(themes.size() == icons.size()); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
434 |
for(int i = 0; i < icons.size(); ++i) |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
435 |
{ |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
436 |
themesModel->setData(themesModel->index(i), icons[i].first, Qt::DecorationRole); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
437 |
themesModel->setData(themesModel->index(i), icons[i].second, Qt::UserRole); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
438 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
439 |
} |
579 | 440 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
441 |
QDir tmpdir; |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
442 |
tmpdir.cd(cfgdir->absolutePath()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
443 |
tmpdir.cd("Data/Maps"); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
444 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
445 |
mapList = new QStringList(tmpdir.entryList(QStringList("*"))); |
1210 | 446 |
|
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
3932
diff
changeset
|
447 |
tmpdir.cd(datadir->absolutePath()); |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
448 |
tmpdir.cd("Maps"); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
449 |
tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
450 |
QStringList tmplist = QStringList(tmpdir.entryList(QStringList("*"))); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
451 |
for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
452 |
if (!mapList->contains(*it,Qt::CaseInsensitive)) mapList->append(*it); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
453 |
|
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
454 |
tmpdir.cd(cfgdir->absolutePath()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
455 |
tmpdir.cd("Data/Scripts/Multiplayer"); |
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
3932
diff
changeset
|
456 |
tmpdir.setFilter(QDir::Files | QDir::NoDotAndDotDot); |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
3932
diff
changeset
|
457 |
scriptList = new QStringList(tmpdir.entryList(QStringList("*.lua"))); |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
3932
diff
changeset
|
458 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
459 |
tmpdir.cd(datadir->absolutePath()); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
460 |
tmpdir.cd("Scripts/Multiplayer"); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
461 |
tmpdir.setFilter(QDir::Files | QDir::NoDotAndDotDot); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
462 |
tmplist = QStringList(tmpdir.entryList(QStringList("*.lua"))); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
463 |
for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
464 |
if (!scriptList->contains(*it,Qt::CaseInsensitive)) scriptList->append(*it); |
2898 | 465 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
466 |
QTranslator Translator; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
467 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
468 |
QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
469 |
QString cc = settings.value("misc/locale", QString()).toString(); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5276
diff
changeset
|
470 |
if(cc.isEmpty()) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
471 |
cc = QLocale::system().name(); |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
472 |
QFile tmpfile; |
5300 | 473 |
tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Locale/hedgewars_" + cc); |
474 |
if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Locale/hedgewars_" + cc); |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5095
diff
changeset
|
475 |
Translator.load(QFileInfo(tmpfile).absoluteFilePath()); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
476 |
app.installTranslator(&Translator); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
477 |
} |
2898 | 478 |
|
5756 | 479 |
#ifdef _WIN32 |
3679 | 480 |
// Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir) |
3932 | 481 |
if(!custom_config) |
3679 | 482 |
{ |
3932 | 483 |
QSettings registry_hklm("HKEY_LOCAL_MACHINE", QSettings::NativeFormat); |
484 |
registry_hklm.setValue("Software/Hedgewars/Frontend", bindir->absolutePath().replace("/", "\\") + "\\hedgewars.exe"); |
|
485 |
registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); |
|
3679 | 486 |
} |
487 |
#endif |
|
5095
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
488 |
#ifdef __APPLE__ |
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
489 |
// this creates the autoreleasepool that prevents leaking |
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
490 |
CocoaInitializer initializer; |
15dd764b728c
fix autorelease pools not being set (issue 209) and format code a little
koda
parents:
4976
diff
changeset
|
491 |
#endif |
2898 | 492 |
|
5849 | 493 |
app.form = new HWForm(NULL,styleSheetFromHell); |
2377 | 494 |
|
5252 | 495 |
app.form->show(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2913
diff
changeset
|
496 |
return app.exec(); |
2845 | 497 |
} |