author | koda |
Sun, 07 Jul 2013 18:23:10 +0200 | |
changeset 9321 | 1d56051f70c8 |
parent 9131 | 07f3bf8d98a3 |
child 9327 | 02caf698a8f1 |
permissions | -rw-r--r-- |
187 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
9080 | 3 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
187 | 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 |
||
221 | 19 |
#include <QGridLayout> |
235 | 20 |
#include <QLabel> |
6175 | 21 |
#include <QList> |
22 |
#include <QUrl> |
|
23 |
#include <QRegExp> |
|
8256 | 24 |
#include <QNetworkAccessManager> |
25 |
#include <QNetworkRequest> |
|
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
26 |
#include <QMessageBox> |
8256 | 27 |
#include <QNetworkReply> |
28 |
#include <QDebug> |
|
6175 | 29 |
#include "hwconsts.h" |
30 |
#include "SDLInteraction.h" |
|
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
31 |
#include "SDL.h" |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
32 |
#include "SDL_version.h" |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
33 |
#include "physfs.h" |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
34 |
|
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
35 |
#ifdef VIDEOREC |
8391 | 36 |
extern "C" |
37 |
{ |
|
38 |
#include "libavutil/avutil.h" |
|
39 |
} |
|
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
40 |
#endif |
6175 | 41 |
|
187 | 42 |
#include "about.h" |
43 |
||
44 |
About::About(QWidget * parent) : |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
45 |
QWidget(parent) |
187 | 46 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
47 |
QGridLayout *mainLayout = new QGridLayout(this); |
2525 | 48 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
49 |
QVBoxLayout * leftLayout = new QVBoxLayout(); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
50 |
mainLayout->addLayout(leftLayout, 0, 0, 2, 1); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
51 |
|
5646 | 52 |
QLabel *imageLabel = new QLabel; |
53 |
QImage image(":/res/Hedgehog.png"); |
|
54 |
imageLabel->setPixmap(QPixmap::fromImage(image)); |
|
9131
07f3bf8d98a3
Hedgewars.png had a resolution more than twice as high as required; also fixed some (mostly obsolete) code that also contained a typo that would cause a warning/note in clang
sheepluva
parents:
9080
diff
changeset
|
55 |
imageLabel->setFixedWidth(273); |
07f3bf8d98a3
Hedgewars.png had a resolution more than twice as high as required; also fixed some (mostly obsolete) code that also contained a typo that would cause a warning/note in clang
sheepluva
parents:
9080
diff
changeset
|
56 |
imageLabel->setFixedHeight(300); |
5646 | 57 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
58 |
leftLayout->addWidget(imageLabel, 0, Qt::AlignHCenter); |
235 | 59 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
60 |
QLabel *lbl1 = new QLabel(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
61 |
lbl1->setOpenExternalLinks(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
62 |
lbl1->setText( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
63 |
"<style type=\"text/css\">" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
64 |
"a { color: #ffcc00; }" |
1897 | 65 |
// "a:hover { color: yellow; }" |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
66 |
"</style>" |
8613
82c649dfc7c3
split cVersionString into its three separate components (version, revision, hash) and apply the new values sensibly on the frontend (esp. title, info and feedback)
koda
parents:
8447
diff
changeset
|
67 |
"<div align=\"center\"><h1>Hedgewars " + *cVersionString + "</h1>" |
8652 | 68 |
"<h3>" + QLabel::tr("Revision") + " " + *cRevisionString + " (" + *cHashString + ")</h3>" |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
69 |
"<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p>" + |
8654 | 70 |
QLabel::tr("This program is distributed under the %1").arg("<a \ |
71 |
href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU GPL v2</a>") + |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
72 |
"</div>" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
73 |
); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
74 |
lbl1->setWordWrap(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
75 |
mainLayout->addWidget(lbl1, 0, 1); |
235 | 76 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
77 |
lbl2 = new QTextBrowser(this); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
78 |
lbl2->setOpenExternalLinks(true); |
8434 | 79 |
QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html"); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
80 |
lbl2->setSource(localpage); //sets the source of the label from the file above |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
81 |
mainLayout->addWidget(lbl2, 1, 1); |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
82 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
83 |
/* Library information */ |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
84 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
85 |
QString libinfo = "<style type=text/css>a:link { color: #FFFF6E; }</style>"; |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
86 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
87 |
#ifdef __GNUC__ |
8447 | 88 |
libinfo.append(QString("<a href=\"http://gcc.gnu.org\">GCC</a> %1<br>").arg(__VERSION__)); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
89 |
#else |
8447 | 90 |
libinfo.append(QString(tr("Unknown Compiler")).arg(__VERSION__) + QString("<br>")); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
91 |
#endif |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
92 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
93 |
libinfo.append(QString("<a href=\"http://www.libsdl.org/\">SDL</a> version: %1.%2.%3<br>") |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
94 |
.arg(SDL_MAJOR_VERSION) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
95 |
.arg(SDL_MINOR_VERSION) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
96 |
.arg(SDL_PATCHLEVEL)); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
97 |
|
9321 | 98 |
libinfo.append(QString("<a href=\"http://www.libsdl.org/\">SDL_mixer</a> version: %1.%2.%3<br>") |
99 |
.arg(MIX_MAJOR_VERSION) |
|
100 |
.arg(MIX_MINOR_VERSION) |
|
101 |
.arg(MIX_PATCHLEVEL)); |
|
102 |
||
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
103 |
libinfo.append(QString("<a href=\"http://qt-project.org/\">Qt</a> version: %1<br>").arg(QT_VERSION_STR)); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
104 |
|
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
105 |
#ifdef VIDEOREC |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
106 |
libinfo.append(QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3<br>") |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
107 |
.arg(LIBAVUTIL_VERSION_MAJOR) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
108 |
.arg(LIBAVUTIL_VERSION_MINOR) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
109 |
.arg(LIBAVUTIL_VERSION_MICRO)); |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
110 |
#endif |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
111 |
|
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
112 |
libinfo.append(QString("<a href=\"http://icculus.org/physfs/\">PhysFS</a> version: %1.%2.%3<br>") |
8390
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
113 |
.arg(PHYSFS_VER_MAJOR) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
114 |
.arg(PHYSFS_VER_MINOR) |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
115 |
.arg(PHYSFS_VER_PATCH)); |
0b2403003640
Added "what we use" section to "about" page. From GCI.
dag10 <gottlieb.drew@gmail.com>
parents:
8256
diff
changeset
|
116 |
|
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
117 |
QLabel * lblLibInfo = new QLabel(); |
8760
534e30885b66
enable/fix links on about page. why don't people test that stuff when they insert it? it's just one click...
sheepluva
parents:
8654
diff
changeset
|
118 |
lblLibInfo->setOpenExternalLinks(true); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
119 |
lblLibInfo->setText(libinfo); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
120 |
lblLibInfo->setWordWrap(true); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
121 |
lblLibInfo->setMaximumWidth(280); |
8447 | 122 |
leftLayout->addWidget(lblLibInfo, 0, Qt::AlignHCenter); |
8404
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
123 |
leftLayout->addStretch(1); |
f06227b2ea14
Moved library version info out of about.html and into a QLabel beneath Hedgehog.png on about page.
dag10 <gottlieb.drew@gmail.com>
parents:
8391
diff
changeset
|
124 |
|
6175 | 125 |
setAcceptDrops(true); |
187 | 126 |
} |
6175 | 127 |
|
128 |
void About::dragEnterEvent(QDragEnterEvent * event) |
|
129 |
{ |
|
130 |
if (event->mimeData()->hasUrls()) |
|
131 |
{ |
|
132 |
QList<QUrl> urls = event->mimeData()->urls(); |
|
133 |
QString url = urls[0].toString(); |
|
134 |
if (urls.count() == 1) |
|
135 |
if (url.contains(QRegExp("^file://.*\\.ogg$"))) |
|
136 |
event->acceptProposedAction(); |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
void About::dropEvent(QDropEvent * event) |
|
141 |
{ |
|
142 |
QString file = |
|
143 |
event->mimeData()->urls()[0].toString().remove(QRegExp("^file://")); |
|
144 |
||
145 |
SDLInteraction::instance().setMusicTrack(file); |
|
146 |
||
147 |
event->acceptProposedAction(); |
|
148 |
} |