QTfrontend/ui/widget/about.cpp
author koda
Thu, 27 Dec 2012 15:56:02 +0100
changeset 8335 bc948db1273a
parent 8256 19dbb3209f46
child 8330 aaefa587e277
child 8390 0b2403003640
permissions -rw-r--r--
oops, forgot that data absolute path only applies to linux
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 1052
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6700
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     4
 *
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     8
 *
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    13
 *
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    17
 */
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    18
221
0f451dae4251 Hedgehog on About page
unc0rr
parents: 187
diff changeset
    19
#include <QGridLayout>
235
28903e620258 About page
unc0rr
parents: 221
diff changeset
    20
#include <QLabel>
6175
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    21
#include <QList>
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    22
#include <QUrl>
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    23
#include <QRegExp>
8256
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    24
#include <QNetworkAccessManager>
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    25
#include <QNetworkRequest>
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    26
#include <QNetworkReply>
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    27
#include <QDebug>
6175
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    28
#include "hwconsts.h"
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    29
#include "SDLInteraction.h"
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    30
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    31
#include "about.h"
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    32
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    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
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    35
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2751
diff changeset
    36
    QGridLayout *mainLayout = new QGridLayout(this);
2525
e6cdc0251cd1 remove the svg dependency
koda
parents: 2460
diff changeset
    37
5646
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    38
    QLabel *imageLabel = new QLabel;
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    39
    QImage image(":/res/Hedgehog.png");
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    40
    imageLabel->setPixmap(QPixmap::fromImage(image));
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    41
    imageLabel->setScaledContents(true);
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    42
    imageLabel->setMinimumWidth(2.8);
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    43
    imageLabel->setMaximumWidth(280);
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    44
    imageLabel->setMinimumHeight(30);
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    45
    imageLabel->setMaximumHeight(300);
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    46
1d44c448cfa4 enable a tip on osx, remove trailing whitespaces
koda
parents: 5626
diff changeset
    47
    mainLayout->addWidget(imageLabel, 0, 0, 2, 1);
235
28903e620258 About page
unc0rr
parents: 221
diff changeset
    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
e9dcb47013c7 - Some style changes by nemo
unc0rr
parents: 1796
diff changeset
    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
28903e620258 About page
unc0rr
parents: 221
diff changeset
    64
6175
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    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
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    67
    QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html"); 
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    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
19dbb3209f46 GCI2012: Refactor Authors Page
koda
parents: 7930
diff changeset
    70
    
6175
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    71
    setAcceptDrops(true);
187
96c3154efee5 "About" page, not yet filled with content
unc0rr
parents:
diff changeset
    72
}
6175
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    73
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    74
void About::dragEnterEvent(QDragEnterEvent * event)
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    75
{
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    76
    if (event->mimeData()->hasUrls())
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    77
    {
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    78
        QList<QUrl> urls = event->mimeData()->urls();
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    79
        QString url = urls[0].toString();
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    80
        if (urls.count() == 1)
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    81
            if (url.contains(QRegExp("^file://.*\\.ogg$")))
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    82
                event->acceptProposedAction();
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    83
    }
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    84
}
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    85
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    86
void About::dropEvent(QDropEvent * event)
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    87
{
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    88
    QString file =
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    89
        event->mimeData()->urls()[0].toString().remove(QRegExp("^file://"));
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    90
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    91
    SDLInteraction::instance().setMusicTrack(file);
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    92
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    93
    event->acceptProposedAction();
a80833ddaef0 moving a file around, fixing a png, etc.
sheepluva
parents: 6067
diff changeset
    94
}