author | koda |
Wed, 19 Dec 2012 18:17:23 +0100 | |
changeset 8312 | 9e8781faabab |
parent 8256 | 19dbb3209f46 |
child 8330 | aaefa587e277 |
child 8390 | 0b2403003640 |
permissions | -rw-r--r-- |
187 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
6952 | 3 |
* Copyright (c) 2004-2012 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> |
|
26 |
#include <QNetworkReply> |
|
27 |
#include <QDebug> |
|
6175 | 28 |
#include "hwconsts.h" |
29 |
#include "SDLInteraction.h" |
|
30 |
||
187 | 31 |
#include "about.h" |
32 |
||
33 |
About::About(QWidget * parent) : |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
34 |
QWidget(parent) |
187 | 35 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
36 |
QGridLayout *mainLayout = new QGridLayout(this); |
2525 | 37 |
|
5646 | 38 |
QLabel *imageLabel = new QLabel; |
39 |
QImage image(":/res/Hedgehog.png"); |
|
40 |
imageLabel->setPixmap(QPixmap::fromImage(image)); |
|
41 |
imageLabel->setScaledContents(true); |
|
42 |
imageLabel->setMinimumWidth(2.8); |
|
43 |
imageLabel->setMaximumWidth(280); |
|
44 |
imageLabel->setMinimumHeight(30); |
|
45 |
imageLabel->setMaximumHeight(300); |
|
46 |
||
47 |
mainLayout->addWidget(imageLabel, 0, 0, 2, 1); |
|
235 | 48 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
49 |
QLabel *lbl1 = new QLabel(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
50 |
lbl1->setOpenExternalLinks(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
51 |
lbl1->setText( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
52 |
"<style type=\"text/css\">" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
53 |
"a { color: #ffcc00; }" |
1897 | 54 |
// "a:hover { color: yellow; }" |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
55 |
"</style>" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
56 |
"<div align=\"center\"><h1>Hedgewars</h1>" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
57 |
"<h3>" + QLabel::tr("Version") + " " + *cVersionString + "</h3>" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
58 |
"<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p><br>" + |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
59 |
QLabel::tr("This program is distributed under the GNU General Public License v2") + |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
60 |
"</div>" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6175
diff
changeset
|
61 |
); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
62 |
lbl1->setWordWrap(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
63 |
mainLayout->addWidget(lbl1, 0, 1); |
235 | 64 |
|
6175 | 65 |
lbl2 = new QTextBrowser(this); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
66 |
lbl2->setOpenExternalLinks(true); |
8256 | 67 |
QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html"); |
68 |
lbl2->setSource(localpage); //sets the source of the label from the file above |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2751
diff
changeset
|
69 |
mainLayout->addWidget(lbl2, 1, 1); |
8256 | 70 |
|
6175 | 71 |
setAcceptDrops(true); |
187 | 72 |
} |
6175 | 73 |
|
74 |
void About::dragEnterEvent(QDragEnterEvent * event) |
|
75 |
{ |
|
76 |
if (event->mimeData()->hasUrls()) |
|
77 |
{ |
|
78 |
QList<QUrl> urls = event->mimeData()->urls(); |
|
79 |
QString url = urls[0].toString(); |
|
80 |
if (urls.count() == 1) |
|
81 |
if (url.contains(QRegExp("^file://.*\\.ogg$"))) |
|
82 |
event->acceptProposedAction(); |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
void About::dropEvent(QDropEvent * event) |
|
87 |
{ |
|
88 |
QString file = |
|
89 |
event->mimeData()->urls()[0].toString().remove(QRegExp("^file://")); |
|
90 |
||
91 |
SDLInteraction::instance().setMusicTrack(file); |
|
92 |
||
93 |
event->acceptProposedAction(); |
|
94 |
} |