3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
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.
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.
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/>.
21 #include "aboutview.h"
22 #include "constants.h"
27 #include "activation.h"
31 #include "mac_startup.h"
33 #include "fontutils.h"
34 #include "iconutils.h"
35 #include "appwidget.h"
36 #include "clickablelabel.h"
37 #include "mainwindow.h"
39 AboutView::AboutView(QWidget *parent) : View(parent) {
41 const int padding = 30;
42 const char *buildYear = __DATE__ + 7;
44 // speedup painting since we'll paint the whole background
45 // by ourselves anyway in paintEvent()
46 setAttribute(Qt::WA_OpaquePaintEvent);
48 QBoxLayout *verticalLayout = new QVBoxLayout(this);
49 verticalLayout->setMargin(0);
50 verticalLayout->setSpacing(0);
52 QBoxLayout *aboutlayout = new QHBoxLayout();
53 verticalLayout->addLayout(aboutlayout, 1);
54 aboutlayout->setAlignment(Qt::AlignCenter);
55 aboutlayout->setMargin(padding);
56 aboutlayout->setSpacing(padding);
58 logo = new ClickableLabel();
59 logo->setPixmap(IconUtils::pixmap(":/images/app.png"));
60 connect(logo, &ClickableLabel::clicked, MainWindow::instance(), &MainWindow::visitSite);
61 aboutlayout->addWidget(logo, 0, Qt::AlignTop);
63 QBoxLayout *layout = new QVBoxLayout();
64 layout->setAlignment(Qt::AlignCenter);
65 layout->setSpacing(padding);
66 aboutlayout->addLayout(layout);
68 QString css = "a { color: palette(text); text-decoration: none; font-weight: bold } h1 { font-weight: 300 }";
70 QString info = "<html><style>" + css + "</style><body>"
71 "<h1>" + QString(Constants::NAME) + "</h1>"
72 "<p>" + tr("There's life outside the browser!") + "</p>"
73 "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
74 + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
77 QString email = Activation::instance().getEmail();
79 info += "<p>" + tr("Licensed to: %1").arg("<b>" + email + "</b>");
83 info += "<p>" + tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
84 + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
85 .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
88 info += "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
89 .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
93 + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>")
97 "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
98 .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
100 "<p>© " + buildYear + " " + Constants::ORG_NAME + "</p>"
103 QLabel *infoLabel = new QLabel(info, this);
104 infoLabel->setOpenExternalLinks(true);
105 infoLabel->setWordWrap(true);
106 layout->addWidget(infoLabel);
108 QLayout *buttonLayout = new QHBoxLayout();
109 buttonLayout->setAlignment(Qt::AlignLeft);
110 closeButton = new QPushButton(tr("&Close"), this);
111 closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
113 closeButton->setDefault(true);
114 closeButton->setFocus();
115 connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
116 buttonLayout->addWidget(closeButton);
118 layout->addLayout(buttonLayout);
120 verticalLayout->addWidget(new AppsWidget());
123 void AboutView::appear() {
124 closeButton->setFocus();
125 connect(window()->windowHandle(), SIGNAL(screenChanged(QScreen*)), SLOT(screenChanged()), Qt::UniqueConnection);
128 void AboutView::paintEvent(QPaintEvent *event) {
129 QWidget::paintEvent(event);
131 if (window()->isActiveWindow()) {
134 brush = palette().window();
136 QPainter painter(this);
137 painter.fillRect(0, 0, width(), height(), brush);
141 void AboutView::screenChanged() {
142 logo->setPixmap(IconUtils::pixmap(":/images/app.png"));