X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Faboutview.cpp;h=2c5b456ae356a3ea2f5bcf75c165a139bc57d014;hb=HEAD;hp=92d6638c804cd589b78753ab71d464235ab8ce1b;hpb=a1ece70ffc585241e4ea552f0d8b10c8ae5fa0b8;p=minitube diff --git a/src/aboutview.cpp b/src/aboutview.cpp index 92d6638..e60c173 100644 --- a/src/aboutview.cpp +++ b/src/aboutview.cpp @@ -27,108 +27,185 @@ $END_LICENSE */ #include "activation.h" #endif #ifdef APP_MAC -#include "macutils.h" #include "mac_startup.h" +#include "macutils.h" #endif +#include "appwidget.h" +#include "clickablelabel.h" +#include "fontutils.h" +#include "iconutils.h" +#include "mainwindow.h" + +#ifdef UPDATER +#include "updater.h" +#include "waitingspinnerwidget.h" +#endif + +AboutView::AboutView(QWidget *parent) : View(parent) { + const int padding = 30; + const char *buildYear = __DATE__ + 7; -AboutView::AboutView(QWidget *parent) : QWidget(parent) { + setBackgroundRole(QPalette::Base); + setForegroundRole(QPalette::Text); + setAutoFillBackground(true); - QBoxLayout *hLayout = new QHBoxLayout(this); - hLayout->setAlignment(Qt::AlignCenter); - hLayout->setMargin(30); - hLayout->setSpacing(30); + QBoxLayout *verticalLayout = new QVBoxLayout(this); + verticalLayout->setMargin(0); + verticalLayout->setSpacing(0); - QLabel *logo = new QLabel(this); - logo->setPixmap(QPixmap(":/images/app.png")); - hLayout->addWidget(logo, 0, Qt::AlignTop); + QBoxLayout *aboutlayout = new QHBoxLayout(); + verticalLayout->addLayout(aboutlayout, 1); + aboutlayout->setAlignment(Qt::AlignCenter); + aboutlayout->setMargin(padding); + aboutlayout->setSpacing(padding); + + ClickableLabel *logo = new ClickableLabel(); + auto setLogoPixmap = [logo] { + logo->setPixmap(IconUtils::pixmap(":/images/app.png", logo->devicePixelRatioF())); + }; + setLogoPixmap(); + connect(window()->windowHandle(), &QWindow::screenChanged, this, setLogoPixmap); + + connect(logo, &ClickableLabel::clicked, MainWindow::instance(), &MainWindow::visitSite); + aboutlayout->addWidget(logo, 0, Qt::AlignTop); QBoxLayout *layout = new QVBoxLayout(); layout->setAlignment(Qt::AlignCenter); - layout->setSpacing(30); - hLayout->addLayout(layout); + layout->setSpacing(padding); + layout->setMargin(padding / 2); + aboutlayout->addLayout(layout); + + QColor lightTextColor = palette().text().color(); +#ifdef APP_MAC + lightTextColor.setAlphaF(.75); +#endif +#ifdef APP_MAC + QColor linkColor = mac::accentColor(); +#else + QColor linkColor = palette().highlight().color(); +#endif - QString info = "" - "

" + QString(Constants::NAME) + "

" - "

" + tr("There's life outside the browser!") + "

" - "

" + tr("Version %1").arg(Constants::VERSION) + "

" - + QString("

%1

").arg(Constants::WEBSITE); + QString info = ""; + + info += "

" + QString(Constants::NAME) + + "

" + "

" + + tr("There's life outside the browser!") + + "

" + "

" + + tr("Version %1").arg(Constants::VERSION) + "

" + + QString("

%1

").arg(Constants::WEBSITE); #ifdef APP_ACTIVATION - if (Activation::instance().isActivated()) - info += "

" + tr("Licensed to: %1").arg("" + Activation::instance().getEmail() + ""); + QString email = Activation::instance().getEmail(); + if (!email.isEmpty()) info += "

" + tr("Licensed to: %1").arg("" + email + ""); #endif #ifndef APP_EXTRA - info += "

" + tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "
" - + tr("Please donate to support the continued development of %2.") - .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "

"; + info += "

" + + tr("%1 is Free Software but its development takes precious time.") + .arg(Constants::NAME) + + "
" + + tr("Please donate to support the continued development of %2.") + .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + + "

"; #endif - info += "

" + tr("You may want to try my other apps as well:") + "

" - "" + info += "

" + + tr("Translate %1 to your native language using %2") + .arg(Constants::NAME) + .arg("Transifex") + + "

"; - "

" + tr("Translate %1 to your native language using %2").arg(Constants::NAME) - .arg("Transifex") - + "

" + info += "

" + + tr("Powered by %1") + .arg("" + tr("Open-source software") + "") + + "

"; - "

" - + tr("Icon designed by %1.").arg("David Nel") - + "

" + info += "

" + + tr("Icon designed by %1.").arg("David Nel") + + "

" - #ifndef APP_EXTRA - "

" + tr("Released under the GNU General Public License") - .arg("http://www.gnu.org/licenses/gpl.html") + "

" - #endif - "

© 2009-2014 " + Constants::ORG_NAME + "

" +#ifndef APP_EXTRA + "

" + + tr("Released under the GNU General Public License") + .arg("http://www.gnu.org/licenses/gpl.html") + + "

" +#endif + "

© " + + buildYear + " " + Constants::ORG_NAME + + "

" ""; + QLabel *infoLabel = new QLabel(info, this); infoLabel->setOpenExternalLinks(true); infoLabel->setWordWrap(true); layout->addWidget(infoLabel); +#ifdef UPDATER + int capHeight = fontMetrics().capHeight(); + + QBoxLayout *updateLayout = new QHBoxLayout(); + updateLayout->setMargin(0); + updateLayout->setSpacing(capHeight); + updateLayout->setAlignment(Qt::AlignLeft); + + auto spinner = new WaitingSpinnerWidget(this, false, false); + spinner->setColor(palette().windowText().color()); + spinner->setLineLength(capHeight / 2); + spinner->setNumberOfLines(spinner->lineLength() * 2); + spinner->setInnerRadius(spinner->lineLength()); + auto spinnerStartStop = [spinner](auto status) { + if (status == Updater::Status::DownloadingUpdate) + spinner->start(); + else + spinner->stop(); + }; + connect(&Updater::instance(), &Updater::statusChanged, this, spinnerStartStop); + updateLayout->addWidget(spinner); + spinnerStartStop(Updater::instance().getStatus()); + + updateLayout->addWidget(Updater::instance().getLabel()); + + layout->addLayout(updateLayout); +#endif + QLayout *buttonLayout = new QHBoxLayout(); buttonLayout->setMargin(0); - buttonLayout->setSpacing(0); buttonLayout->setAlignment(Qt::AlignLeft); - closeButton = new QPushButton(tr("&Close")); +#ifdef UPDATER + buttonLayout->addWidget(Updater::instance().getButton()); +#endif + + closeButton = new QPushButton(tr("&Close"), this); closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); closeButton->setDefault(true); - connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack())); + closeButton->setShortcut(Qt::Key_Escape); + closeButton->setFocus(); + connect(closeButton, SIGNAL(clicked()), MainWindow::instance(), SLOT(goBack())); buttonLayout->addWidget(closeButton); layout->addLayout(buttonLayout); -} -void AboutView::paintEvent(QPaintEvent * /*event*/) { -#if defined(APP_MAC) | defined(APP_WIN) - QBrush brush; - if (window()->isActiveWindow()) { - brush = QBrush(QColor(0xdd, 0xe4, 0xeb)); - } else { - brush = palette().window(); - } - QPainter painter(this); - painter.fillRect(0, 0, width(), height(), brush); +#ifndef APP_WIN_STORE + verticalLayout->addWidget(new AppsWidget()); #endif } void AboutView::appear() { -#ifdef APP_MAC - mac::uncloseWindow(window()->winId()); -#ifdef APP_ACTIVATION - mac::CheckForUpdates(); -#endif -#endif closeButton->setFocus(); +#ifdef UPDATER + Updater::instance().checkWithoutUI(); +#endif }