]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
1fe723a4215df4afc037859e7707f66370826e98
[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 #include "appwidget.h"
36 #include "clickablelabel.h"
37 #include "mainwindow.h"
38
39 AboutView::AboutView(QWidget *parent) : View(parent) {
40
41     const int padding = 30;
42     const char *buildYear = __DATE__ + 7;
43
44     // speedup painting since we'll paint the whole background
45     // by ourselves anyway in paintEvent()
46     setAttribute(Qt::WA_OpaquePaintEvent);
47
48     QBoxLayout *verticalLayout = new QVBoxLayout(this);
49     verticalLayout->setMargin(0);
50     verticalLayout->setSpacing(0);
51
52     QBoxLayout *aboutlayout = new QHBoxLayout();
53     verticalLayout->addLayout(aboutlayout, 1);
54     aboutlayout->setAlignment(Qt::AlignCenter);
55     aboutlayout->setMargin(padding);
56     aboutlayout->setSpacing(padding);
57
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);
62
63     QBoxLayout *layout = new QVBoxLayout();
64     layout->setAlignment(Qt::AlignCenter);
65     layout->setSpacing(padding);
66     aboutlayout->addLayout(layout);
67
68     QString css = "a { color: palette(text); text-decoration: none; font-weight: bold } h1 { font-weight: 300 }";
69
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);
75
76 #ifdef APP_ACTIVATION
77     QString email = Activation::instance().getEmail();
78     if (!email.isEmpty())
79         info += "<p>" + tr("Licensed to: %1").arg("<b>" + email + "</b>");
80 #endif
81
82 #ifndef APP_EXTRA
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>";
86 #endif
87
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>")
90             + "</p>"
91
92             "<p>"
93             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>")
94             + "</p>"
95
96         #ifndef APP_EXTRA
97             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
98             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
99         #endif
100             "<p>&copy; " + buildYear + " " + Constants::ORG_NAME + "</p>"
101             "</body></html>";
102
103     QLabel *infoLabel = new QLabel(info, this);
104     infoLabel->setOpenExternalLinks(true);
105     infoLabel->setWordWrap(true);
106     layout->addWidget(infoLabel);
107
108     QLayout *buttonLayout = new QHBoxLayout();
109     buttonLayout->setAlignment(Qt::AlignLeft);
110     closeButton = new QPushButton(tr("&Close"), this);
111     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
112
113     closeButton->setDefault(true);
114     closeButton->setFocus();
115     connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
116     buttonLayout->addWidget(closeButton);
117
118     layout->addLayout(buttonLayout);
119
120     verticalLayout->addWidget(new AppsWidget());
121 }
122
123 void AboutView::appear() {
124     closeButton->setFocus();
125     connect(window()->windowHandle(), SIGNAL(screenChanged(QScreen*)), SLOT(screenChanged()), Qt::UniqueConnection);
126 }
127
128 void AboutView::paintEvent(QPaintEvent *event) {
129     QWidget::paintEvent(event);
130     QBrush brush;
131     if (window()->isActiveWindow()) {
132         brush = Qt::white;
133     } else {
134         brush = palette().window();
135     }
136     QPainter painter(this);
137     painter.fillRect(0, 0, width(), height(), brush);
138     painter.end();
139 }
140
141 void AboutView::screenChanged() {
142     logo->setPixmap(IconUtils::pixmap(":/images/app.png"));
143 }