]> git.sur5r.net Git - minitube/blob - src/aboutview.cpp
Imported Upstream version 2.0
[minitube] / src / aboutview.cpp
1 #include "aboutview.h"
2 #include "constants.h"
3 #ifndef Q_WS_X11
4 #include "extra.h"
5 #endif
6 #ifdef APP_ACTIVATION
7 #include "activation.h"
8 #endif
9 #ifdef APP_MAC
10 #include "macutils.h"
11 #include "mac_startup.h"
12 #endif
13
14 AboutView::AboutView(QWidget *parent) : QWidget(parent) {
15
16     QBoxLayout *hLayout = new QHBoxLayout(this);
17     hLayout->setAlignment(Qt::AlignCenter);
18     hLayout->setMargin(30);
19     hLayout->setSpacing(30);
20
21     QLabel *logo = new QLabel(this);
22     logo->setPixmap(QPixmap(":/images/app.png"));
23     hLayout->addWidget(logo, 0, Qt::AlignTop);
24
25     QBoxLayout *layout = new QVBoxLayout();
26     layout->setAlignment(Qt::AlignCenter);
27     layout->setSpacing(30);
28     hLayout->addLayout(layout);
29
30     QString info = "<html><style>a { color: palette(text); text-decoration: none; font-weight: bold }</style><body>"
31             "<h1>" + QString(Constants::NAME) + "</h1>"
32             "<p>" + tr("There's life outside the browser!") + "</p>"
33             "<p>" + tr("Version %1").arg(Constants::VERSION) + "</p>"
34             + QString("<p><a href=\"%1/\">%1</a></p>").arg(Constants::WEBSITE);
35
36 #ifdef APP_ACTIVATION
37     if (Activation::instance().isActivated())
38         info += "<p>" + tr("Licensed to: %1").arg("<b>" + Activation::instance().getEmail() + "</b>");
39 #endif
40
41 #ifdef Q_WS_X11
42     info += "<p>" +  tr("%1 is Free Software but its development takes precious time.").arg(Constants::NAME) + "<br/>"
43             + tr("Please <a href='%1'>donate</a> to support the continued development of %2.")
44             .arg(QString(Constants::WEBSITE).append("#donate"), Constants::NAME) + "</p>";
45 #endif
46
47     info += "<p>" + tr("You may want to try my other apps as well:") + "</p>"
48             "<ul>"
49
50             "<li>" + tr("%1, a YouTube music player")
51             .arg("<a href='http://flavio.tordini.org/musictube'>Musictube</a>")
52             + "</li>"
53
54             "<li>" + tr("%1, a music player")
55             .arg("<a href='http://flavio.tordini.org/musique'>Musique</a>")
56             + "</li>"
57
58             "</ul>"
59
60             "<p>" + tr("Translate %1 to your native language using %2").arg(Constants::NAME)
61             .arg("<a href='http://www.transifex.net/projects/p/" + QString(Constants::UNIX_NAME) + "/'>Transifex</a>")
62             + "</p>"
63
64             "<p>"
65             + tr("Icon designed by %1.").arg("<a href='http://www.kolorguild.com/'>David Nel</a>")
66             + "</p>"
67
68         #ifdef Q_WS_X11
69             "<p>" + tr("Released under the <a href='%1'>GNU General Public License</a>")
70             .arg("http://www.gnu.org/licenses/gpl.html") + "</p>"
71         #endif
72             "<p>&copy; 2009-2013 " + Constants::ORG_NAME + "</p>"
73             "</body></html>";
74     QLabel *infoLabel = new QLabel(info, this);
75     infoLabel->setOpenExternalLinks(true);
76     infoLabel->setWordWrap(true);
77     layout->addWidget(infoLabel);
78
79     QLayout *buttonLayout = new QHBoxLayout();
80     buttonLayout->setMargin(0);
81     buttonLayout->setSpacing(0);
82     buttonLayout->setAlignment(Qt::AlignLeft);
83
84     QPushButton *closeButton = new QPushButton(tr("&Close"), this);
85     closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
86     closeButton->setDefault(true);
87     closeButton->setFocus(Qt::OtherFocusReason);
88     connect(closeButton, SIGNAL(clicked()), parent, SLOT(goBack()));
89     buttonLayout->addWidget(closeButton);
90
91     layout->addLayout(buttonLayout);
92 }
93
94 void AboutView::paintEvent(QPaintEvent * /*event*/) {
95 #if defined(APP_MAC) | defined(APP_WIN)
96     QBrush brush;
97     if (window()->isActiveWindow()) {
98         brush = QBrush(QColor(0xdd, 0xe4, 0xeb));
99     } else {
100         brush = palette().window();
101     }
102     QPainter painter(this);
103     painter.fillRect(0, 0, width(), height(), brush);
104 #endif
105 }
106
107 void AboutView::appear() {
108 #ifdef APP_MAC
109     mac::uncloseWindow(window()->winId());
110 #ifdef APP_ACTIVATION
111     mac::CheckForUpdates();
112 #endif
113 #endif
114 }