]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
f173a385c1fbfbcff29dc4302ea76b9b96fa89b5
[minitube] / src / aboutview.cpp
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #include "aboutview.h"
22 #include "constants.h"
23 #ifdef APP_EXTRA
24 #include "extra.h"
25 #endif
26 #ifdef APP_ACTIVATION
27 #include "activation.h"
28 #endif
29 #ifdef APP_MAC
30 #include "macutils.h"
31 #include "mac_startup.h"
32 #endif
33
34 AboutView::AboutView(QWidget *parent) : QWidget(parent) {
35
36     QBoxLayout *hLayout = new QHBoxLayout(this);
37     hLayout->setAlignment(Qt::AlignCenter);
38     hLayout->setMargin(30);
39     hLayout->setSpacing(30);
40
41     QLabel *logo = new QLabel(this);
42     logo->setPixmap(QPixmap(":/images/app.png"));
43     hLayout->addWidget(logo, 0, Qt::AlignTop);
44
45     QBoxLayout *layout = new QVBoxLayout();
46     layout->setAlignment(Qt::AlignCenter);
47     layout->setSpacing(30);
48     hLayout->addLayout(layout);
49
50     QString info = "<html><style>a { color: palette(text); text-decoration: none; font-weight: bold }</style><body>"
51             "<h1>" + QString(Constants::NAME) + "</h1>"
52             "<p>" + tr("There's life outside the browser!") + "</p>"
53             "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
54             + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
55
56 #ifdef APP_ACTIVATION
57     if (Activation::instance().isActivated())
58         info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
59 #endif
60
61 #ifndef APP_EXTRA
62     info += "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
63             + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
64             .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
65 #endif
66
67     info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
68             "<ul>"
69
70             "<li>" + tr("%1, a YouTube music player")
71             .arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
72             + "</li>"
73
74             "<li>" + tr("%1, a music player")
75             .arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
76             + "</li>"
77
78             "</ul>"
79
80             "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
81             .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
82             + "</p>"
83
84             "<p>"
85             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.com/'>David Nel</a>")
86             + "</p>"
87
88         #ifndef APP_EXTRA
89             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
90             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
91         #endif
92             "<p>&copy; 2009-2013 " + Constants::ORG_NAME + "</p>"
93             "</body></html>";
94     QLabel *infoLabel = new QLabel(info, this);
95     infoLabel->setOpenExternalLinks(true);
96     infoLabel->setWordWrap(true);
97     layout->addWidget(infoLabel);
98
99     QLayout *buttonLayout = new QHBoxLayout();
100     buttonLayout->setMargin(0);
101     buttonLayout->setSpacing(0);
102     buttonLayout->setAlignment(Qt::AlignLeft);
103
104     closeButton = new QPushButton(tr("&Close"));
105     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
106     closeButton->setDefault(true);
107     connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
108     buttonLayout->addWidget(closeButton);
109
110     layout->addLayout(buttonLayout);
111 }
112
113 void AboutView::paintEvent(QPaintEvent * /*event*/) {
114 #if defined(APP_MAC) | defined(APP_WIN)
115     QBrush brush;
116     if (window()->isActiveWindow()) {
117         brush = QBrush(QColor(0xdd, 0xe4, 0xeb));
118     } else {
119         brush = palette().window();
120     }
121     QPainter painter(this);
122     painter.fillRect(0, 0, width(), height(), brush);
123 #endif
124 }
125
126 void AboutView::appear() {
127 #ifdef APP_MAC
128     mac::uncloseWindow(window()->winId());
129 #ifdef APP_ACTIVATION
130     mac::CheckForUpdates();
131 #endif
132 #endif
133     closeButton->setFocus();
134 }