]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
19c5ee547ea88b41d94464e35dfc269c79931563
[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 #include "fontutils.h"
34 #include "iconutils.h"
35
36 AboutView::AboutView(QWidget *parent) : View(parent) {
37
38     QBoxLayout *hLayout = new QHBoxLayout(this);
39     hLayout->setAlignment(Qt::AlignCenter);
40     hLayout->setMargin(30);
41     hLayout->setSpacing(30);
42
43     QLabel *logo = new QLabel(this);
44     logo->setPixmap(IconUtils::pixmap(":/images/app.png"));
45     hLayout->addWidget(logo, 0, Qt::AlignTop);
46
47     QBoxLayout *layout = new QVBoxLayout();
48     layout->setAlignment(Qt::AlignCenter);
49     layout->setSpacing(30);
50     hLayout->addLayout(layout);
51
52     QString css = "a { color: palette(text); text-decoration: none; font-weight: bold } h1 { font-weight: 100 }";
53 #ifdef APP_MAC
54     css += " h1 { font-family: 'Helvetica Neue' }";
55 #endif
56
57     QString info = "<html><style>" + css + "</style><body>"
58             "<h1>" + QString(Constants::NAME) + "</h1>"
59             "<p>" + tr("There's life outside the browser!") + "</p>"
60             "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
61             + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
62
63 #ifdef APP_ACTIVATION
64     if (Activation::instance().isActivated())
65         info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
66 #endif
67
68 #ifndef APP_EXTRA
69     info += "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
70             + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
71             .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
72 #endif
73
74     info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
75             "<ul>"
76
77             "<li>" + tr("%1, a YouTube music player")
78             .arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
79             + "</li>"
80
81             "<li>" + tr("%1, a music player")
82             .arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
83             + "</li>"
84
85             "</ul>"
86
87             "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
88             .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
89             + "</p>"
90
91             "<p>"
92             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>")
93             + "</p>"
94
95         #ifndef APP_EXTRA
96             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
97             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
98         #endif
99             "<p>&copy; 2009-2015 " + Constants::ORG_NAME + "</p>"
100             "</body></html>";
101     QLabel *infoLabel = new QLabel(info, this);
102     infoLabel->setOpenExternalLinks(true);
103     infoLabel->setWordWrap(true);
104     layout->addWidget(infoLabel);
105
106     QLayout *buttonLayout = new QHBoxLayout();
107     buttonLayout->setMargin(0);
108     buttonLayout->setSpacing(0);
109     buttonLayout->setAlignment(Qt::AlignLeft);
110
111     closeButton = new QPushButton(tr("&Close"));
112     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
113     closeButton->setDefault(true);
114     connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
115     buttonLayout->addWidget(closeButton);
116
117     layout->addLayout(buttonLayout);
118 }
119
120 void AboutView::appear() {
121 #ifdef APP_MAC
122     mac::uncloseWindow(window()->winId());
123 #ifdef APP_ACTIVATION
124     mac::CheckForUpdates();
125 #endif
126 #endif
127     closeButton->setFocus();
128 }
129
130 void AboutView::paintEvent(QPaintEvent *event) {
131     QWidget::paintEvent(event);
132 #if defined(APP_MAC) | defined(APP_WIN)
133     QBrush brush;
134     if (window()->isActiveWindow()) {
135         brush = Qt::white;
136     } else {
137         brush = palette().window();
138     }
139     QPainter painter(this);
140     painter.fillRect(0, 0, width(), height(), brush);
141     painter.end();
142 #endif
143 #ifdef APP_UBUNTU
144     QStyleOption o;
145     o.initFrom(this);
146     QPainter p(this);
147     style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
148 #endif
149 }