]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
Views refactoring, don't use RTTI
[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
35 AboutView::AboutView(QWidget *parent) : View(parent) {
36
37     QBoxLayout *hLayout = new QHBoxLayout(this);
38     hLayout->setAlignment(Qt::AlignCenter);
39     hLayout->setMargin(30);
40     hLayout->setSpacing(30);
41
42     QLabel *logo = new QLabel(this);
43     logo->setPixmap(QPixmap(":/images/app.png"));
44     hLayout->addWidget(logo, 0, Qt::AlignTop);
45
46     QBoxLayout *layout = new QVBoxLayout();
47     layout->setAlignment(Qt::AlignCenter);
48     layout->setSpacing(30);
49     hLayout->addLayout(layout);
50
51     QString css = "a { color: palette(text); text-decoration: none; font-weight: bold } h1 { font-weight: 100 }";
52 #ifdef APP_MAC
53     css += " h1 { font-family: 'Helvetica Neue' }";
54 #endif
55
56     QString info = "<html><style>" + css + "</style><body>"
57             "<h1>" + QString(Constants::NAME) + "</h1>"
58             "<p>" + tr("There's life outside the browser!") + "</p>"
59             "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
60             + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
61
62 #ifdef APP_ACTIVATION
63     if (Activation::instance().isActivated())
64         info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
65 #endif
66
67 #ifndef APP_EXTRA
68     info += "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
69             + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
70             .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
71 #endif
72
73     info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
74             "<ul>"
75
76             "<li>" + tr("%1, a YouTube music player")
77             .arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
78             + "</li>"
79
80             "<li>" + tr("%1, a music player")
81             .arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
82             + "</li>"
83
84             "</ul>"
85
86             "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
87             .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
88             + "</p>"
89
90             "<p>"
91             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.co.za/'>David Nel</a>")
92             + "</p>"
93
94         #ifndef APP_EXTRA
95             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
96             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
97         #endif
98             "<p>&copy; 2009-2015 " + Constants::ORG_NAME + "</p>"
99             "</body></html>";
100     QLabel *infoLabel = new QLabel(info, this);
101     infoLabel->setOpenExternalLinks(true);
102     infoLabel->setWordWrap(true);
103     layout->addWidget(infoLabel);
104
105     QLayout *buttonLayout = new QHBoxLayout();
106     buttonLayout->setMargin(0);
107     buttonLayout->setSpacing(0);
108     buttonLayout->setAlignment(Qt::AlignLeft);
109
110     closeButton = new QPushButton(tr("&Close"));
111     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
112     closeButton->setDefault(true);
113     connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
114     buttonLayout->addWidget(closeButton);
115
116     layout->addLayout(buttonLayout);
117 }
118
119 void AboutView::appear() {
120 #ifdef APP_MAC
121     mac::uncloseWindow(window()->winId());
122 #ifdef APP_ACTIVATION
123     mac::CheckForUpdates();
124 #endif
125 #endif
126     closeButton->setFocus();
127 }
128
129 void AboutView::paintEvent(QPaintEvent *event) {
130     QWidget::paintEvent(event);
131 #if defined(APP_MAC) | defined(APP_WIN)
132     QBrush brush;
133     if (window()->isActiveWindow()) {
134         brush = Qt::white;
135     } else {
136         brush = palette().window();
137     }
138     QPainter painter(this);
139     painter.fillRect(0, 0, width(), height(), brush);
140     painter.end();
141 #endif
142 #ifdef APP_UBUNTU
143     QStyleOption o;
144     o.initFrom(this);
145     QPainter p(this);
146     style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
147 #endif
148 }