]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
Upload 3.9.3-2 to unstable
[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 "mac_startup.h"
31 #include "macutils.h"
32 #endif
33 #include "appwidget.h"
34 #include "clickablelabel.h"
35 #include "fontutils.h"
36 #include "iconutils.h"
37 #include "mainwindow.h"
38
39 AboutView::AboutView(QWidget *parent) : View(parent) {
40     const int padding = 30;
41     const char *buildYear = __DATE__ + 7;
42
43     setBackgroundRole(QPalette::Base);
44     setForegroundRole(QPalette::Text);
45     setAutoFillBackground(true);
46
47     QBoxLayout *verticalLayout = new QVBoxLayout(this);
48     verticalLayout->setMargin(0);
49     verticalLayout->setSpacing(0);
50
51     QBoxLayout *aboutlayout = new QHBoxLayout();
52     verticalLayout->addLayout(aboutlayout, 1);
53     aboutlayout->setAlignment(Qt::AlignCenter);
54     aboutlayout->setMargin(padding);
55     aboutlayout->setSpacing(padding);
56
57     ClickableLabel *logo = new ClickableLabel();
58     auto setLogoPixmap = [logo] {
59         logo->setPixmap(IconUtils::pixmap(":/images/app.png", logo->devicePixelRatioF()));
60     };
61     setLogoPixmap();
62     connect(window()->windowHandle(), &QWindow::screenChanged, this, setLogoPixmap);
63
64     connect(logo, &ClickableLabel::clicked, MainWindow::instance(), &MainWindow::visitSite);
65     aboutlayout->addWidget(logo, 0, Qt::AlignTop);
66
67     QBoxLayout *layout = new QVBoxLayout();
68     layout->setAlignment(Qt::AlignCenter);
69     layout->setSpacing(padding);
70     aboutlayout->addLayout(layout);
71
72     QColor lightTextColor = palette().text().color();
73 #ifdef APP_MAC
74     lightTextColor.setAlphaF(.75);
75 #endif
76 #ifdef APP_MAC
77     QColor linkColor = mac::accentColor();
78 #else
79     QColor linkColor = palette().highlight().color();
80 #endif
81
82     QString info = "<html><style>"
83                    "body { color: " +
84                    lightTextColor.name(QColor::HexArgb) +
85                    "; } "
86                    "h1 { color: palette(text); font-weight: 100; } "
87                    "a { color: " +
88                    linkColor.name(QColor::HexArgb) +
89                    "; text-decoration: none; font-weight: normal; }"
90                    "</style><body>";
91
92     info += "<h1>" + QString(Constants::NAME) +
93             "</h1>"
94             "<p>" +
95             tr("There's life outside the browser!") +
96             "</p>"
97             "<p>" +
98             tr("Version %1").arg(Constants::VERSION) + "</p>" +
99             QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
100
101 #ifdef APP_ACTIVATION
102     QString email = Activation::instance().getEmail();
103     if (!email.isEmpty()) info += "<p>" + tr("Licensed to: %1").arg("<b>" + email + "</b>");
104 #endif
105
106 #ifndef APP_EXTRA
107     info += "<p>" +
108             tr("%1 is Free Software but its development takes precious time.")
109                     .arg(Constants::NAME) +
110             "<br/>" +
111             tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
112                     .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) +
113             "</p>";
114 #endif
115
116     info += "<p>" +
117             tr("Translate %1 to your native language using %2")
118                     .arg(Constants::NAME)
119                     .arg("<a href='http://www.transifex.net/projects/p/" +
120                          QString(Constants::UNIX_NAME) + "/'>Transifex</a>") +
121             "</p>";
122
123     info += "<p>" +
124             tr("Powered by %1")
125                     .arg("<a href='https://" + QLatin1String(Constants::ORG_DOMAIN) +
126                          "/opensource'>" + tr("Open-source software") + "</a>") +
127             "</p>";
128
129     info += "<p>" +
130             tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>") +
131             "</p>"
132
133 #ifndef APP_EXTRA
134             "<p>" +
135             tr("Released under the <a href='%1'>GNU General Public License</a>")
136                     .arg("http://www.gnu.org/licenses/gpl.html") +
137             "</p>"
138 #endif
139             "<p>&copy; " +
140             buildYear + " " + Constants::ORG_NAME +
141             "</p>"
142             "</body></html>";
143
144     QLabel *infoLabel = new QLabel(info, this);
145     infoLabel->setOpenExternalLinks(true);
146     infoLabel->setWordWrap(true);
147     layout->addWidget(infoLabel);
148
149     QLayout *buttonLayout = new QHBoxLayout();
150     buttonLayout->setAlignment(Qt::AlignLeft);
151     closeButton = new QPushButton(tr("&Close"), this);
152     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
153
154     closeButton->setDefault(true);
155     closeButton->setFocus();
156     connect(closeButton, SIGNAL(clicked()), MainWindow::instance(), SLOT(goBack()));
157     buttonLayout->addWidget(closeButton);
158
159     layout->addLayout(buttonLayout);
160
161     verticalLayout->addWidget(new AppsWidget());
162 }
163
164 void AboutView::appear() {
165     closeButton->setFocus();
166 }