[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 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"
|
---|
[176] | 25 | #include "inforeader.h"
|
---|
| 26 | #include "links.h"
|
---|
[112] | 27 |
|
---|
| 28 | #include <QFile>
|
---|
[124] | 29 | #include <QDesktopServices>
|
---|
[112] | 30 |
|
---|
[181] | 31 | #if QT_VERSION >= 0x050000
|
---|
| 32 | #include "myscroller.h"
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[112] | 35 | using namespace Global;
|
---|
| 36 |
|
---|
| 37 | About::About(QWidget * parent, Qt::WindowFlags f)
|
---|
[124] | 38 | : QDialog(parent, f)
|
---|
[112] | 39 | {
|
---|
| 40 | setupUi(this);
|
---|
| 41 | setWindowIcon( Images::icon("logo", 64) );
|
---|
| 42 |
|
---|
[181] | 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 |
|
---|
[176] | 50 | logo->setPixmap( QPixmap(":/default-theme/logo.png").scaledToHeight(64, Qt::SmoothTransformation) );
|
---|
[112] | 51 | contrib_icon->setPixmap( Images::icon("contributors" ) );
|
---|
| 52 | translators_icon->setPixmap( Images::icon("translators" ) );
|
---|
| 53 | license_icon->setPixmap( Images::icon("license" ) );
|
---|
| 54 |
|
---|
[176] | 55 | InfoReader * i = InfoReader::obj(pref->mplayer_bin);
|
---|
| 56 | i->getInfo();
|
---|
| 57 | QString mplayer_version = tr("Using %1").arg(i->playerVersion());
|
---|
[112] | 58 |
|
---|
[124] | 59 | info->setText(
|
---|
[188] | 60 | "<b>SMPlayer</b> © 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net><br><br>"
|
---|
[156] | 61 | "<b>" + tr("Version: %1").arg(Version::printable()) + "</b>" +
|
---|
[188] | 62 | (Version::is_unstable() ? "<br><i>" + tr("Development version") +"</i>" : "") +
|
---|
[112] | 63 | #if PORTABLE_APP
|
---|
[188] | 64 | "<br>" + tr("Portable Edition") +
|
---|
[112] | 65 | #endif
|
---|
[188] | 66 | "<p>" +
|
---|
| 67 | tr("Using Qt %1 (compiled with Qt %2)").arg(qVersion()).arg(QT_VERSION_STR) + "<br>" +
|
---|
[176] | 68 | mplayer_version + "<br><br>" +
|
---|
[142] | 69 | "<b>"+ tr("Links:") +"</b><br>"+
|
---|
[176] | 70 | tr("Official website:") +" "+ link(URL_HOMEPAGE) +"<br>"+
|
---|
| 71 | tr("Support forum:") +" "+ link(URL_FORUM) +"<br>"+
|
---|
| 72 | "<br>" +
|
---|
| 73 | /*
|
---|
[124] | 74 | tr("SMPlayer uses the award-winning MPlayer as playback engine. See %1")
|
---|
[176] | 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>" */
|
---|
[112] | 93 | );
|
---|
| 94 |
|
---|
| 95 |
|
---|
[124] | 96 | QString license_text =
|
---|
| 97 | "<i>"
|
---|
| 98 | "This program is free software; you can redistribute it and/or modify "
|
---|
[176] | 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>";
|
---|
[124] | 102 |
|
---|
| 103 | QString license_file = Paths::doc("gpl.html", "en");
|
---|
[112] | 104 | if (QFile::exists(license_file)) {
|
---|
[124] | 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 | }
|
---|
[112] | 108 |
|
---|
[124] | 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"));
|
---|
[112] | 115 | }
|
---|
| 116 | }
|
---|
[124] | 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&)));
|
---|
[112] | 121 |
|
---|
| 122 | translators->setHtml( getTranslators() );
|
---|
| 123 |
|
---|
| 124 | contributions->setText(
|
---|
| 125 | tr("SMPlayer logo by %1").arg("Charles Barcza <kbarcza@blackpanther.hu>") + "<br><br>" +
|
---|
[124] | 126 | tr("Packages for Windows created by %1").arg("redxii <redxii@users.sourceforge.net>") + "<br><br>" +
|
---|
| 127 | tr("Many other people contributed with patches. See the Changelog for details.")
|
---|
[112] | 128 | );
|
---|
| 129 |
|
---|
[139] | 130 |
|
---|
[112] | 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);
|
---|
[124] | 137 |
|
---|
[112] | 138 | QPalette pal = info_tab->palette();
|
---|
| 139 | pal.setColor(QPalette::Window, palette().color(QPalette::Window) );
|
---|
[124] | 140 |
|
---|
[112] | 141 | info_tab->setPalette(pal);
|
---|
| 142 | contributions_tab->setPalette(pal);
|
---|
| 143 | translations_tab->setPalette(pal);
|
---|
| 144 | license_tab->setPalette(pal);
|
---|
[124] | 145 |
|
---|
[112] | 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);
|
---|
[124] | 153 | license->setPalette(p);
|
---|
[112] | 154 |
|
---|
[165] | 155 | tab_widget->removeTab(0);
|
---|
| 156 |
|
---|
[112] | 157 | adjustSize();
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | About::~About() {
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | QString About::getTranslators() {
|
---|
| 164 | return QString(
|
---|
[165] | 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>") +
|
---|
[176] | 168 | "<p><a href=\"" URL_TRANSLATORS "\">" +
|
---|
| 169 | tr("Click here to know the translators from the transifex teams") +
|
---|
| 170 | "</a>");
|
---|
[112] | 171 | }
|
---|
| 172 |
|
---|
| 173 | QString About::trad(const QString & lang, const QString & author) {
|
---|
| 174 | return trad(lang, QStringList() << author);
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | QString 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("<", "<").replace(">", ">");
|
---|
[165] | 182 | if (n < (authors.count()-1)) s += ", ";
|
---|
[112] | 183 | }
|
---|
[165] | 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);
|
---|
[112] | 186 | }
|
---|
| 187 |
|
---|
| 188 | QString About::link(const QString & url, QString name) {
|
---|
| 189 | if (name.isEmpty()) name = url;
|
---|
| 190 | return QString("<a href=\"" + url + "\">" + name +"</a>");
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | QString About::contr(const QString & author, const QString & thing) {
|
---|
| 194 | return "<li>"+ tr("<b>%1</b> (%2)").arg(author).arg(thing) +"</li>";
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | QSize About::sizeHint () const {
|
---|
| 198 | return QSize(518, 326);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
[124] | 201 | void About::openLink(const QUrl & link) {
|
---|
| 202 | qDebug("About::openLink: '%s'", link.toString().toUtf8().constData());
|
---|
| 203 | QDesktopServices::openUrl(link);
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[112] | 206 | #include "moc_about.cpp"
|
---|