1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2  * (c)LGPL2+
3  *
4  * Flacon - audio File Encoder
5  * https://github.com/flacon/flacon
6  *
7  * Copyright: 2012-2013
8  *   Alexander Sokoloff <sokoloff.a@gmail.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14 
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19 
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23  *
24  * END_COMMON_COPYRIGHT_HEADER */
25 
26 #include "aboutdialog.h"
27 #include "translatorsinfo.h"
28 #include "types.h"
29 #include <QDate>
30 #include <QList>
31 #include <QDebug>
32 #include <QPaintEvent>
33 #include <QPainter>
34 
35 /************************************************
36 
37  ************************************************/
AboutDialog(QWidget * parent)38 AboutDialog::AboutDialog(QWidget *parent) :
39     QDialog(parent)
40 {
41     setupUi(this);
42     setWindowTitle(tr("About Flacon"));
43 
44     this->layout()->setSpacing(10);
45     titleLabel->setStyleSheet("color: #FFFFFF;");
46 
47     authorsEdit->viewport()->setAutoFillBackground(false);
48     thanksEdit->viewport()->setAutoFillBackground(false);
49     translationsEdit->viewport()->setAutoFillBackground(false);
50     programsEdit->viewport()->setAutoFillBackground(false);
51 
52     QString css = "<style TYPE='text/css'> "
53                   "body { font-family: sans-serif;} "
54                   ".name { font-size: 16pt; } "
55                   "a { white-space: nowrap ;} "
56                   "h2 { font-size: 10pt;} "
57                   "li { line-height: 120%;} "
58                   ".techInfoKey { white-space: nowrap ; margin: 0 20px 0 16px; } "
59                   "</style>";
60 
61     titleLabel->setText(css + titleText());
62 
63     aboutLabel->setText(descriptionText() + "<br><br><br>" + copyrightText() + "<hr>" +
64 
65                         tr("Homepage: %1").arg(homepageText()) + "<p>" +
66 
67                         tr("Bug tracker %1", "About dialog, About tab").arg(bugTrackerText()) + "<p>" +
68 
69                         tr("License: %1").arg(licenseText()));
70 
71     authorsEdit->setHtml(css + authorsInfo().asString());
72     thanksEdit->setHtml(css + tr("Special thanks to:") + thanksInfo().asString());
73     translationsEdit->setHtml(css + translationsText());
74     programsEdit->setHtml(css + tr("Flacon uses external programs. Many thanks to their authors!") + programsInfo().asString());
75 }
76 
77 /************************************************
78  *
79  ************************************************/
paintEvent(QPaintEvent *)80 void AboutDialog::paintEvent(QPaintEvent *)
81 {
82     QRect    rect(0, 0, this->width(), titleLabel->pos().y() + titleLabel->height());
83     QPainter painter(this);
84     painter.fillRect(rect, QColor::fromRgb(0x404040));
85 }
86 
87 /************************************************
88 
89  ************************************************/
titleText() const90 QString AboutDialog::titleText() const
91 {
92     return "<table style='width:100%' border=0><tr>"
93            "<td style='padding:8px 8px;'><img src=':/48/mainicon' style='margin:8 px;'></td>"
94            "<td style='padding:8px 8px;'>"
95             +
96 #ifdef GIT_BRANCH
97             QString("<div class=name>Flacon</div> developer version."
98                     "<div class=ver>%1 + git %2</b> "
99                     "<a href='https://github.com/flacon/flacon/commit/%3'>%3</a></div>")
100                     .arg(FLACON_VERSION)
101                     .arg(GIT_BRANCH)
102                     .arg(GIT_COMMIT_HASH)
103             +
104 #else
105             QString("<div class=name>Flacon</div><div class=ver>Version %1</div>").arg(FLACON_VERSION) +
106 #endif
107             "</td></tr></table>";
108 }
109 
110 /************************************************
111 
112  ************************************************/
descriptionText() const113 QString AboutDialog::descriptionText() const
114 {
115     return tr("Extracts individual tracks from one big audio file containing the entire album.");
116 }
117 
118 /************************************************
119 
120  ************************************************/
copyrightText() const121 QString AboutDialog::copyrightText() const
122 {
123     return tr("Copyright: %1-%2 %3").arg("2012", QDate::currentDate().toString("yyyy"), "Alexander Sokolov");
124 }
125 
126 /************************************************
127 
128  ************************************************/
bugTrackerText() const129 QString AboutDialog::bugTrackerText() const
130 {
131     return "<a href='https://github.com/flacon/flacon/issues'>https://github.com/flacon/flacon/issues</a>";
132 }
133 
134 /************************************************
135 
136  ************************************************/
homepageText() const137 QString AboutDialog::homepageText() const
138 {
139     return "<a href='http://flacon.github.io/'>flacon.github.io</a>";
140 }
141 
142 /************************************************
143 
144  ************************************************/
licenseText() const145 QString AboutDialog::licenseText() const
146 {
147     return "<a href='http://www.gnu.org/licenses/lgpl-2.1.html'>GNU Lesser General Public License version 2.1 or later</a>";
148 }
149 
150 /************************************************
151 
152  ************************************************/
authorsInfo() const153 AboutInfo AboutDialog::authorsInfo() const
154 {
155     AboutInfo result;
156     result.add("Alexander Sokolov", "mailto:sokoloff.a@gmail.com");
157     return result;
158 }
159 
160 /************************************************
161 
162  ************************************************/
thanksInfo() const163 AboutInfo AboutDialog::thanksInfo() const
164 {
165     AboutInfo result;
166 
167     result.add("Artem Aleksuk",
168                "mailto:h31mail@yandex.ru",
169                tr("WavPack support patch", "Thanks on the about page"));
170 
171     result.add("Kyrill Detinov",
172                "mailto:lazy.kent@opensuse.org",
173                tr("Packaging, testing", "Thanks on the about page"));
174 
175     result.add("",
176                "mailto:ao.french.l10n@rbox.me",
177                tr("Improvements in the UI", "Thanks on the about page"));
178 
179     result.add("Taras Sokol",
180                "mailto:tsokolp@gmail.com",
181                tr("Flacon account on github.com", "Thanks on the about page"));
182 
183     result.add("FlatIcon",
184                "https://www.flaticon.com",
185                tr("Icon for application", "Thanks on the about page"));
186 
187     result.add("Icons8",
188                "https://icons8.com",
189                tr("Icons for application", "Thanks on the about page"));
190 
191     return result;
192 }
193 
194 /************************************************
195 
196  ************************************************/
translationsText() const197 QString AboutDialog::translationsText() const
198 {
199     TranslatorsInfo translatorsInfo;
200     return QString("%1<p><ul>%2</ul>").arg(tr("Flacon is translated into many languages thanks to the work of the Flacon translation teams on <a href='%1'>Transifex</a>.").arg("https://www.transifex.com/sokoloff/flacon/"), translatorsInfo.asHtml());
201 }
202 
203 /************************************************
204 
205  ************************************************/
programsInfo() const206 AboutInfo AboutDialog::programsInfo() const
207 {
208     AboutInfo result;
209 
210     result.add("flac and metaflac",
211                "http://flac.sourceforge.net");
212 
213     result.add("mac",
214                "http://etree.org/shnutils/shntool/support/formats/ape/unix http://www.monkeysaudio.com");
215 
216     result.add("oggenc",
217                "http://www.xiph.org");
218 
219     result.add("LAME",
220                "http://lame.sourceforge.net");
221 
222     result.add("WavPack",
223                "http://www.wavpack.com");
224 
225     result.add("VorbisGain",
226                "http://sjeng.org/vorbisgain.html");
227 
228     result.add("MP3Gain",
229                "http://mp3gain.sourceforge.net");
230 
231     result.add("ttaenc",
232                "http://tta.sourceforge.net");
233 
234     result.add("FAAC",
235                "http://www.audiocoding.com");
236 
237     result.add("opusenc",
238                "http://www.xiph.org");
239 
240     return result;
241 }
242 
243 /************************************************
244 
245  ************************************************/
aboutItemLessThan(const AboutInfoItem & i1,const AboutInfoItem & i2)246 bool aboutItemLessThan(const AboutInfoItem &i1, const AboutInfoItem &i2)
247 {
248     return i1.name.toLower() < i2.name.toLower();
249 }
250 
251 /************************************************
252 
253  ************************************************/
AboutInfo()254 AboutInfo::AboutInfo() :
255     QList<AboutInfoItem>()
256 {
257 }
258 
259 /************************************************
260 
261  ************************************************/
asString() const262 QString AboutInfo::asString() const
263 {
264     AboutInfo list = *this;
265     std::sort(list.begin(), list.end(), aboutItemLessThan);
266     QString result;
267 
268     result += "<ul>";
269     foreach (AboutInfoItem item, list) {
270         result += "<li>" + item.name;
271 
272 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
273         QStringList urls = item.url.split(" ", QString::SkipEmptyParts);
274 #else
275         QStringList urls = item.url.split(" ", Qt::SkipEmptyParts);
276 #endif
277         foreach (QString url, urls) {
278             QString text = QString(url).remove("mailto:").remove("http://");
279             result += QString(" <a href='%1'>%2</a>").arg(url, text);
280         }
281 
282         if (!item.description.isEmpty())
283             result += "  - " + item.description;
284         result += "</li>";
285     }
286 
287     return result;
288 }
289 
290 /************************************************
291 
292  ************************************************/
add(const QString & name,const QString & url,const QString & description)293 void AboutInfo::add(const QString &name, const QString &url, const QString &description)
294 {
295     AboutInfoItem item;
296     item.name        = name;
297     item.url         = url;
298     item.description = description;
299     this->append(item);
300 }
301