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"
30 #include "mac_startup.h"
33 #include "appwidget.h"
34 #include "clickablelabel.h"
35 #include "fontutils.h"
36 #include "iconutils.h"
37 #include "mainwindow.h"
41 #include "waitingspinnerwidget.h"
44 AboutView::AboutView(QWidget *parent) : View(parent) {
45 const int padding = 30;
46 const char *buildYear = __DATE__ + 7;
48 setBackgroundRole(QPalette::Base);
49 setForegroundRole(QPalette::Text);
50 setAutoFillBackground(true);
52 QBoxLayout *verticalLayout = new QVBoxLayout(this);
53 verticalLayout->setMargin(0);
54 verticalLayout->setSpacing(0);
56 QBoxLayout *aboutlayout = new QHBoxLayout();
57 verticalLayout->addLayout(aboutlayout, 1);
58 aboutlayout->setAlignment(Qt::AlignCenter);
59 aboutlayout->setMargin(padding);
60 aboutlayout->setSpacing(padding);
62 ClickableLabel *logo = new ClickableLabel();
63 auto setLogoPixmap = [logo] {
64 logo->setPixmap(IconUtils::pixmap(":/images/app.png", logo->devicePixelRatioF()));
67 connect(window()->windowHandle(), &QWindow::screenChanged, this, setLogoPixmap);
69 connect(logo, &ClickableLabel::clicked, MainWindow::instance(), &MainWindow::visitSite);
70 aboutlayout->addWidget(logo, 0, Qt::AlignTop);
72 QBoxLayout *layout = new QVBoxLayout();
73 layout->setAlignment(Qt::AlignCenter);
74 layout->setSpacing(padding);
75 layout->setMargin(padding / 2);
76 aboutlayout->addLayout(layout);
78 QColor lightTextColor = palette().text().color();
80 lightTextColor.setAlphaF(.75);
83 QColor linkColor = mac::accentColor();
85 QColor linkColor = palette().highlight().color();
88 QString info = "<html><style>"
90 lightTextColor.name(QColor::HexArgb) +
92 "h1 { color: palette(text); font-weight: 100; } "
94 linkColor.name(QColor::HexArgb) +
95 "; text-decoration: none; font-weight: normal; }"
98 info += "<h1>" + QString(Constants::NAME) +
101 tr("There's life outside the browser!") +
104 tr("Version %1").arg(Constants::VERSION) + "</p>" +
105 QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
107 #ifdef APP_ACTIVATION
108 QString email = Activation::instance().getEmail();
109 if (!email.isEmpty()) info += "<p>" + tr("Licensed to: %1").arg("<b>" + email + "</b>");
114 tr("%1 is Free Software but its development takes precious time.")
115 .arg(Constants::NAME) +
117 tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
118 .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) +
123 tr("Translate %1 to your native language using %2")
124 .arg(Constants::NAME)
125 .arg("<a href='http://www.transifex.net/projects/p/" +
126 QString(Constants::UNIX_NAME) + "/'>Transifex</a>") +
131 .arg("<a href='https://" + QLatin1String(Constants::ORG_DOMAIN) +
132 "/opensource'>" + tr("Open-source software") + "</a>") +
136 tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>") +
141 tr("Released under the <a href='%1'>GNU General Public License</a>")
142 .arg("http://www.gnu.org/licenses/gpl.html") +
146 buildYear + " " + Constants::ORG_NAME +
150 QLabel *infoLabel = new QLabel(info, this);
151 infoLabel->setOpenExternalLinks(true);
152 infoLabel->setWordWrap(true);
153 layout->addWidget(infoLabel);
156 int capHeight = fontMetrics().capHeight();
158 QBoxLayout *updateLayout = new QHBoxLayout();
159 updateLayout->setMargin(0);
160 updateLayout->setSpacing(capHeight);
161 updateLayout->setAlignment(Qt::AlignLeft);
163 auto spinner = new WaitingSpinnerWidget(this, false, false);
164 spinner->setColor(palette().windowText().color());
165 spinner->setLineLength(capHeight / 2);
166 spinner->setNumberOfLines(spinner->lineLength() * 2);
167 spinner->setInnerRadius(spinner->lineLength());
168 auto spinnerStartStop = [spinner](auto status) {
169 if (status == Updater::Status::DownloadingUpdate)
174 connect(&Updater::instance(), &Updater::statusChanged, this, spinnerStartStop);
175 updateLayout->addWidget(spinner);
176 spinnerStartStop(Updater::instance().getStatus());
178 updateLayout->addWidget(Updater::instance().getLabel());
180 layout->addLayout(updateLayout);
183 QLayout *buttonLayout = new QHBoxLayout();
184 buttonLayout->setMargin(0);
185 buttonLayout->setAlignment(Qt::AlignLeft);
188 buttonLayout->addWidget(Updater::instance().getButton());
191 closeButton = new QPushButton(tr("&Close"), this);
192 closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
193 closeButton->setDefault(true);
194 closeButton->setShortcut(Qt::Key_Escape);
195 closeButton->setFocus();
196 connect(closeButton, SIGNAL(clicked()), MainWindow::instance(), SLOT(goBack()));
197 buttonLayout->addWidget(closeButton);
199 layout->addLayout(buttonLayout);
201 #ifndef APP_WIN_STORE
202 verticalLayout->addWidget(new AppsWidget());
206 void AboutView::appear() {
207 closeButton->setFocus();
209 Updater::instance().checkWithoutUI();