source: smplayer/trunk/src/about.cpp@ 188

Last change on this file since 188 was 188, checked in by Silvan Scherrer, 8 years ago

SMPlayer: update trunk to version 17.1.0

  • Property svn:eol-style set to LF
File size: 7.4 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "about.h"
20#include "images.h"
21#include "version.h"
22#include "global.h"
23#include "preferences.h"
24#include "paths.h"
25#include "inforeader.h"
26#include "links.h"
27
28#include <QFile>
29#include <QDesktopServices>
30
31#if QT_VERSION >= 0x050000
32#include "myscroller.h"
33#endif
34
35using namespace Global;
36
37About::About(QWidget * parent, Qt::WindowFlags f)
38 : QDialog(parent, f)
39{
40 setupUi(this);
41 setWindowIcon( Images::icon("logo", 64) );
42
43#if QT_VERSION >= 0x050000
44 MyScroller::setScroller(info->viewport());
45 MyScroller::setScroller(contributions->viewport());
46 MyScroller::setScroller(translators->viewport());
47 MyScroller::setScroller(license->viewport());
48#endif
49
50 logo->setPixmap( QPixmap(":/default-theme/logo.png").scaledToHeight(64, Qt::SmoothTransformation) );
51 contrib_icon->setPixmap( Images::icon("contributors" ) );
52 translators_icon->setPixmap( Images::icon("translators" ) );
53 license_icon->setPixmap( Images::icon("license" ) );
54
55 InfoReader * i = InfoReader::obj(pref->mplayer_bin);
56 i->getInfo();
57 QString mplayer_version = tr("Using %1").arg(i->playerVersion());
58
59 info->setText(
60 "<b>SMPlayer</b> &copy; 2006-2017 Ricardo Villalba &lt;rvm@users.sourceforge.net&gt;<br><br>"
61 "<b>" + tr("Version: %1").arg(Version::printable()) + "</b>" +
62 (Version::is_unstable() ? "<br><i>" + tr("Development version") +"</i>" : "") +
63#if PORTABLE_APP
64 "<br>" + tr("Portable Edition") +
65#endif
66 "<p>" +
67 tr("Using Qt %1 (compiled with Qt %2)").arg(qVersion()).arg(QT_VERSION_STR) + "<br>" +
68 mplayer_version + "<br><br>" +
69 "<b>"+ tr("Links:") +"</b><br>"+
70 tr("Official website:") +" "+ link(URL_HOMEPAGE) +"<br>"+
71 tr("Support forum:") +" "+ link(URL_FORUM) +"<br>"+
72 "<br>" +
73 /*
74 tr("SMPlayer uses the award-winning MPlayer as playback engine. See %1")
75 .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">http://www.mplayerhq.hu</a>") +
76 */
77#if defined(MPV_SUPPORT) && defined(MPLAYER_SUPPORT)
78 tr("SMPlayer is a graphical interface for %1 and %2.")
79 .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">MPlayer</a>")
80 .arg("<a href=\"http://www.mpv.io\">mpv</a>") +
81#else
82 tr("SMPlayer is a graphical interface for %1.")
83 #ifdef MPV_SUPPORT
84 .arg("<a href=\"http://www.mpv.io\">mpv</a>") +
85 #endif
86 #ifdef MPLAYER_SUPPORT
87 .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">MPlayer</a>") +
88 #endif
89#endif
90 "<br><br>" +
91 tr("Subtitles service powered by %1").arg("<a href=\"http://www.opensubtitles.org\">www.OpenSubtitles.org</a>")
92 /* + "<br><a href=\"http://www.opensubtitles.org\"><img src=\":default-theme/opensubtitles-logo.png\"></a>" */
93 );
94
95
96 QString license_text =
97 "<i>"
98 "This program is free software; you can redistribute it and/or modify "
99 "it under the terms of the GNU General Public License as published by "
100 "the Free Software Foundation; either version 2 of the License, or "
101 "(at your option) any later version." "</i><br><br>";
102
103 QString license_file = Paths::doc("gpl.html", "en");
104 if (QFile::exists(license_file)) {
105 license_file = QUrl::fromLocalFile(license_file).toString();
106 license_text += QString("<a href=\"%1\">%2</a>").arg(license_file).arg(tr("Read the entire license"));
107 }
108
109 if ((pref->language != "en") && (pref->language != "en_US")) {
110 QString license_trans_file = Paths::doc("gpl.html", pref->language, false);
111 //qDebug("license_trans_file: %s", license_trans_file.toUtf8().constData());
112 if (QFile::exists(license_trans_file)) {
113 license_trans_file = QUrl::fromLocalFile(license_trans_file).toString();
114 license_text += QString("<br><a href=\"%1\">%2</a>").arg(license_trans_file).arg(tr("Read a translation"));
115 }
116 }
117 license->setText(license_text);
118 license->setOpenLinks(false);
119 license->setOpenExternalLinks(false);
120 connect(license, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl&)));
121
122 translators->setHtml( getTranslators() );
123
124 contributions->setText(
125 tr("SMPlayer logo by %1").arg("Charles Barcza &lt;kbarcza@blackpanther.hu&gt;") + "<br><br>" +
126 tr("Packages for Windows created by %1").arg("redxii &lt;redxii@users.sourceforge.net&gt;") + "<br><br>" +
127 tr("Many other people contributed with patches. See the Changelog for details.")
128 );
129
130
131 // Copy the background color ("window") of the tab widget to the "base" color of the qtextbrowsers
132 // Problem, it doesn't work with some styles, so first we change the "window" color of the tab widgets.
133 info_tab->setAutoFillBackground(true);
134 contributions_tab->setAutoFillBackground(true);
135 translations_tab->setAutoFillBackground(true);
136 license_tab->setAutoFillBackground(true);
137
138 QPalette pal = info_tab->palette();
139 pal.setColor(QPalette::Window, palette().color(QPalette::Window) );
140
141 info_tab->setPalette(pal);
142 contributions_tab->setPalette(pal);
143 translations_tab->setPalette(pal);
144 license_tab->setPalette(pal);
145
146 QPalette p = info->palette();
147 //p.setBrush(QPalette::Base, info_tab->palette().window());
148 p.setColor(QPalette::Base, info_tab->palette().color(QPalette::Window));
149
150 info->setPalette(p);
151 contributions->setPalette(p);
152 translators->setPalette(p);
153 license->setPalette(p);
154
155 tab_widget->removeTab(0);
156
157 adjustSize();
158}
159
160About::~About() {
161}
162
163QString About::getTranslators() {
164 return QString(
165 tr("Many people contributed with translations.") +" "+
166 tr("You can also help to translate SMPlayer into your own language.") +"<p>"+
167 tr("Visit %1 and join a translation team.").arg("<a href=\"http://www.transifex.com/projects/p/smplayer/\">http://www.transifex.com/projects/p/smplayer/</a>") +
168 "<p><a href=\"" URL_TRANSLATORS "\">" +
169 tr("Click here to know the translators from the transifex teams") +
170 "</a>");
171}
172
173QString About::trad(const QString & lang, const QString & author) {
174 return trad(lang, QStringList() << author);
175}
176
177QString About::trad(const QString & lang, const QStringList & authors) {
178 QString s;
179 for (int n = 0; n < authors.count(); n++) {
180 QString author = authors[n];
181 s += author.replace("<", "&lt;").replace(">", "&gt;");
182 if (n < (authors.count()-1)) s += ", ";
183 }
184 //return QString("<h3>%1:</h3><h4>%2</h4><hr>").arg(lang).arg(s);
185 return QString("<p><b>%1</b>: %2</p>").arg(lang).arg(s);
186}
187
188QString About::link(const QString & url, QString name) {
189 if (name.isEmpty()) name = url;
190 return QString("<a href=\"" + url + "\">" + name +"</a>");
191}
192
193QString About::contr(const QString & author, const QString & thing) {
194 return "<li>"+ tr("<b>%1</b> (%2)").arg(author).arg(thing) +"</li>";
195}
196
197QSize About::sizeHint () const {
198 return QSize(518, 326);
199}
200
201void About::openLink(const QUrl & link) {
202 qDebug("About::openLink: '%s'", link.toString().toUtf8().constData());
203 QDesktopServices::openUrl(link);
204}
205
206#include "moc_about.cpp"
Note: See TracBrowser for help on using the repository browser.