| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 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 |
|
|---|
| 35 | using namespace Global;
|
|---|
| 36 |
|
|---|
| 37 | About::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> © 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net><br><br>"
|
|---|
| 61 | "<b>" + tr("Version: %1").arg(Version::printable()) + "</b>" +
|
|---|
| 62 | #if PORTABLE_APP
|
|---|
| 63 | " (" + tr("Portable Edition") + ")" +
|
|---|
| 64 | #endif
|
|---|
| 65 | #ifdef EXPERIMENTAL
|
|---|
| 66 | "<br>Experimental branch<br>"
|
|---|
| 67 | #endif
|
|---|
| 68 | "<br>" +
|
|---|
| 69 | tr("Using Qt %1 (compiled with Qt %2)").arg(qVersion()).arg(QT_VERSION_STR) + "<br>" +
|
|---|
| 70 | mplayer_version + "<br><br>" +
|
|---|
| 71 | "<b>"+ tr("Links:") +"</b><br>"+
|
|---|
| 72 | tr("Official website:") +" "+ link(URL_HOMEPAGE) +"<br>"+
|
|---|
| 73 | tr("Support forum:") +" "+ link(URL_FORUM) +"<br>"+
|
|---|
| 74 | "<br>" +
|
|---|
| 75 | /*
|
|---|
| 76 | tr("SMPlayer uses the award-winning MPlayer as playback engine. See %1")
|
|---|
| 77 | .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">http://www.mplayerhq.hu</a>") +
|
|---|
| 78 | */
|
|---|
| 79 | #if defined(MPV_SUPPORT) && defined(MPLAYER_SUPPORT)
|
|---|
| 80 | tr("SMPlayer is a graphical interface for %1 and %2.")
|
|---|
| 81 | .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">MPlayer</a>")
|
|---|
| 82 | .arg("<a href=\"http://www.mpv.io\">mpv</a>") +
|
|---|
| 83 | #else
|
|---|
| 84 | tr("SMPlayer is a graphical interface for %1.")
|
|---|
| 85 | #ifdef MPV_SUPPORT
|
|---|
| 86 | .arg("<a href=\"http://www.mpv.io\">mpv</a>") +
|
|---|
| 87 | #endif
|
|---|
| 88 | #ifdef MPLAYER_SUPPORT
|
|---|
| 89 | .arg("<a href=\"http://www.mplayerhq.hu/design7/info.html\">MPlayer</a>") +
|
|---|
| 90 | #endif
|
|---|
| 91 | #endif
|
|---|
| 92 | "<br><br>" +
|
|---|
| 93 | tr("Subtitles service powered by %1").arg("<a href=\"http://www.opensubtitles.org\">www.OpenSubtitles.org</a>")
|
|---|
| 94 | /* + "<br><a href=\"http://www.opensubtitles.org\"><img src=\":default-theme/opensubtitles-logo.png\"></a>" */
|
|---|
| 95 | );
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | QString license_text =
|
|---|
| 99 | "<i>"
|
|---|
| 100 | "This program is free software; you can redistribute it and/or modify "
|
|---|
| 101 | "it under the terms of the GNU General Public License as published by "
|
|---|
| 102 | "the Free Software Foundation; either version 2 of the License, or "
|
|---|
| 103 | "(at your option) any later version." "</i><br><br>";
|
|---|
| 104 |
|
|---|
| 105 | QString license_file = Paths::doc("gpl.html", "en");
|
|---|
| 106 | if (QFile::exists(license_file)) {
|
|---|
| 107 | license_file = QUrl::fromLocalFile(license_file).toString();
|
|---|
| 108 | license_text += QString("<a href=\"%1\">%2</a>").arg(license_file).arg(tr("Read the entire license"));
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | if ((pref->language != "en") && (pref->language != "en_US")) {
|
|---|
| 112 | QString license_trans_file = Paths::doc("gpl.html", pref->language, false);
|
|---|
| 113 | //qDebug("license_trans_file: %s", license_trans_file.toUtf8().constData());
|
|---|
| 114 | if (QFile::exists(license_trans_file)) {
|
|---|
| 115 | license_trans_file = QUrl::fromLocalFile(license_trans_file).toString();
|
|---|
| 116 | license_text += QString("<br><a href=\"%1\">%2</a>").arg(license_trans_file).arg(tr("Read a translation"));
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | license->setText(license_text);
|
|---|
| 120 | license->setOpenLinks(false);
|
|---|
| 121 | license->setOpenExternalLinks(false);
|
|---|
| 122 | connect(license, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl&)));
|
|---|
| 123 |
|
|---|
| 124 | translators->setHtml( getTranslators() );
|
|---|
| 125 |
|
|---|
| 126 | contributions->setText(
|
|---|
| 127 | tr("SMPlayer logo by %1").arg("Charles Barcza <kbarcza@blackpanther.hu>") + "<br><br>" +
|
|---|
| 128 | tr("Packages for Windows created by %1").arg("redxii <redxii@users.sourceforge.net>") + "<br><br>" +
|
|---|
| 129 | tr("Many other people contributed with patches. See the Changelog for details.")
|
|---|
| 130 | );
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | // Copy the background color ("window") of the tab widget to the "base" color of the qtextbrowsers
|
|---|
| 134 | // Problem, it doesn't work with some styles, so first we change the "window" color of the tab widgets.
|
|---|
| 135 | info_tab->setAutoFillBackground(true);
|
|---|
| 136 | contributions_tab->setAutoFillBackground(true);
|
|---|
| 137 | translations_tab->setAutoFillBackground(true);
|
|---|
| 138 | license_tab->setAutoFillBackground(true);
|
|---|
| 139 |
|
|---|
| 140 | QPalette pal = info_tab->palette();
|
|---|
| 141 | pal.setColor(QPalette::Window, palette().color(QPalette::Window) );
|
|---|
| 142 |
|
|---|
| 143 | info_tab->setPalette(pal);
|
|---|
| 144 | contributions_tab->setPalette(pal);
|
|---|
| 145 | translations_tab->setPalette(pal);
|
|---|
| 146 | license_tab->setPalette(pal);
|
|---|
| 147 |
|
|---|
| 148 | QPalette p = info->palette();
|
|---|
| 149 | //p.setBrush(QPalette::Base, info_tab->palette().window());
|
|---|
| 150 | p.setColor(QPalette::Base, info_tab->palette().color(QPalette::Window));
|
|---|
| 151 |
|
|---|
| 152 | info->setPalette(p);
|
|---|
| 153 | contributions->setPalette(p);
|
|---|
| 154 | translators->setPalette(p);
|
|---|
| 155 | license->setPalette(p);
|
|---|
| 156 |
|
|---|
| 157 | tab_widget->removeTab(0);
|
|---|
| 158 |
|
|---|
| 159 | adjustSize();
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | About::~About() {
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | QString About::getTranslators() {
|
|---|
| 166 | return QString(
|
|---|
| 167 | tr("Many people contributed with translations.") +" "+
|
|---|
| 168 | tr("You can also help to translate SMPlayer into your own language.") +"<p>"+
|
|---|
| 169 | 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>") +
|
|---|
| 170 | "<p><a href=\"" URL_TRANSLATORS "\">" +
|
|---|
| 171 | tr("Click here to know the translators from the transifex teams") +
|
|---|
| 172 | "</a>");
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | QString About::trad(const QString & lang, const QString & author) {
|
|---|
| 176 | return trad(lang, QStringList() << author);
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | QString About::trad(const QString & lang, const QStringList & authors) {
|
|---|
| 180 | QString s;
|
|---|
| 181 | for (int n = 0; n < authors.count(); n++) {
|
|---|
| 182 | QString author = authors[n];
|
|---|
| 183 | s += author.replace("<", "<").replace(">", ">");
|
|---|
| 184 | if (n < (authors.count()-1)) s += ", ";
|
|---|
| 185 | }
|
|---|
| 186 | //return QString("<h3>%1:</h3><h4>%2</h4><hr>").arg(lang).arg(s);
|
|---|
| 187 | return QString("<p><b>%1</b>: %2</p>").arg(lang).arg(s);
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | QString About::link(const QString & url, QString name) {
|
|---|
| 191 | if (name.isEmpty()) name = url;
|
|---|
| 192 | return QString("<a href=\"" + url + "\">" + name +"</a>");
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | QString About::contr(const QString & author, const QString & thing) {
|
|---|
| 196 | return "<li>"+ tr("<b>%1</b> (%2)").arg(author).arg(thing) +"</li>";
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | QSize About::sizeHint () const {
|
|---|
| 200 | return QSize(518, 326);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | void About::openLink(const QUrl & link) {
|
|---|
| 204 | qDebug("About::openLink: '%s'", link.toString().toUtf8().constData());
|
|---|
| 205 | QDesktopServices::openUrl(link);
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | #include "moc_about.cpp"
|
|---|