Some code clean-up in "About" dialog.
[LameXP.git] / src / Dialog_About.cpp
blob91f84a126c4657ff0bc9d9e21e9ae57ff90dee69
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Dialog_About.h"
25 #include "UIC_AboutDialog.h"
27 //Internal
28 #include "Global.h"
29 #include "Model_Settings.h"
31 //MUtils
32 #include <MUtils/Global.h>
33 #include <MUtils/OSSupport.h>
34 #include <MUtils/Sound.h>
35 #include <MUtils/GUI.h>
36 #include <MUtils/Version.h>
38 //Qt
39 #include <QDate>
40 #include <QApplication>
41 #include <QIcon>
42 #include <QPushButton>
43 #include <QDesktopServices>
44 #include <QUrl>
45 #include <QTimer>
46 #include <QFileInfo>
47 #include <QDir>
48 #include <QDesktopWidget>
49 #include <QLabel>
50 #include <QMessageBox>
51 #include <QTextStream>
52 #include <QScrollBar>
53 #include <QCloseEvent>
54 #include <QElapsedTimer>
55 #include <QWindowsVistaStyle>
56 #include <QWindowsXPStyle>
58 //CRT
59 #include <math.h>
61 //Helper macros
62 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;"))
63 #define TRIM_RIGHT(STR) do { while(STR.endsWith(QChar(' ')) || STR.endsWith(QChar('\t')) || STR.endsWith(QChar('\r')) || STR.endsWith(QChar('\n'))) STR.chop(1); } while(0)
64 #define MAKE_TRANSPARENT(WIDGET) do { QPalette _p = (WIDGET)->palette(); _p.setColor(QPalette::Background, Qt::transparent); (WIDGET)->setPalette(_p); } while(0)
66 //Constants
67 const char *AboutDialog::neroAacUrl = "http://www.videohelp.com/software/Nero-AAC-Codec"; //"http://www.nero.com/eng/company/about-nero/nero-aac-codec.php"
68 const char *AboutDialog::disqueUrl = "http://muldersoft.com/?player_url=n4bply6Ibqw"; //38X-MXOB014
70 //Contributors
71 static const struct
73 char *pcFlag;
74 wchar_t *pcLanguage;
75 wchar_t *pcName;
76 char *pcMail;
78 g_lamexp_translators[] =
80 {"en", L"Englisch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
81 {"de", L"Deutsch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
82 {"", L"", L"Bodo Thevissen", "Bodo@thevissen.de" },
83 {"es", L"Español", L"Rub3nCT", "Rub3nCT@gmail.com" },
84 {"fr", L"Française", L"Dodich Informatique", "Dodich@live.fr" },
85 {"", L"Française", L"Sami Ghoul-Duclos", "samgd14@live.ca" },
86 {"hu", L"Magyarul", L"ZityiSoft Team", "zityisoft@gmail.com" },
87 {"it", L"Italiano", L"Roberto", "Gulliver_69@libero.it" },
88 {"", L"", L"Gianluca Papi", "johnnyb.goode68@gmail.com"},
89 {"kr", L"한국어", L"JaeHyung Lee", "Kolanp@gmail.com" },
90 {"pl", L"Polski", L"Sir Daniel K", "Sir.Daniel.K@gmail.com" },
91 {"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" },
92 {"", L"", L"Иван Митин", "bardak@inbox.ru" },
93 {"sv", L"Svenska", L"Åke Engelbrektson", "eson@svenskasprakfiler.se"},
94 {"tw", L"繁体中文", L"456Vv", "123@456vv.com" },
95 {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
96 {"zh", L"简体中文", L"456Vv", "123@456vv.com" },
97 {"", L"", L"庄泓川", "kidneybean@sohu.com" },
98 {NULL, NULL, NULL, NULL}
101 //Special Thanks
102 static const struct
104 char* pcName;
105 char *pcAddress;
107 g_lamexp_specialThanks[] =
109 { "Doom9's Forum", "http://forum.doom9.org/" },
110 { "Gleitz | German Doom9", "http://forum.gleitz.info/" },
111 { "Hydrogenaudio Forums", "http://www.hydrogenaudio.org/" },
112 { "RareWares", "http://www.rarewares.org/" },
113 { "GitHub", "http://github.com/" },
114 { "SourceForge", "http://sourceforge.net/" },
115 { "Qt Developer Network", "https://www.qt.io/developers/" },
116 { "CodePlex", "http://www.codeplex.com/" },
117 { "Marius Hudea", "http://savedonthe.net/" },
118 { "Codecs.com", "http://www.codecs.com/" },
119 { NULL, NULL }
122 //Mirrors
123 static const struct
125 char* pcName;
126 char *pcAddress;
128 g_lamexp_mirrors[] =
130 { "GitHub.com", "https://github.com/lordmulder/LameXP" },
131 { "SourceForge.net", "http://sourceforge.net/p/lamexp/code/" },
132 { "Bitbucket.org", "https://bitbucket.org/muldersoft/lamexp" },
133 { "GitLab.com" , "https://gitlab.com/lamexp/lamexp" },
134 { "Codeplex.com", "https://lamexp.codeplex.com/SourceControl/latest" },
135 { "Assembla.com", "https://www.assembla.com/spaces/lamexp/" },
136 { NULL, NULL }
139 ////////////////////////////////////////////////////////////
140 // Constructor
141 ////////////////////////////////////////////////////////////
143 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
145 QDialog(parent),
146 ui(new Ui::AboutDialog),
147 m_settings(settings),
148 m_initFlags(new QMap<QWidget*,bool>),
149 m_disque(NULL),
150 m_disqueTimer(NULL),
151 m_rotateNext(false),
152 m_lastTab(0),
153 m_firstStart(firstStart)
155 //Init the dialog, from the .ui file
156 ui->setupUi(this);
157 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
158 setMinimumSize(this->size());
160 //Adjust size to DPI settings and re-center
161 MUtils::GUI::scale_widget(this);
163 //Disable "X" button
164 if(firstStart)
166 MUtils::GUI::enable_close_button(this, false);
169 //Init tab widget
170 connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
172 //Make transparent
173 const type_info &styleType = typeid(*qApp->style());
174 if((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType))
176 MAKE_TRANSPARENT(ui->infoScrollArea);
177 MAKE_TRANSPARENT(ui->contributorsScrollArea);
178 MAKE_TRANSPARENT(ui->softwareScrollArea);
179 MAKE_TRANSPARENT(ui->licenseScrollArea);
182 //Show about dialog for the first time?
183 if(!firstStart)
185 ui->acceptButton->hide();
186 ui->declineButton->hide();
187 ui->aboutQtButton->show();
188 ui->closeButton->show();
190 QPixmap disque(":/images/Disque.png");
191 m_disque.reset(new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
192 m_disque->resize(disque.size());
193 m_disque->setStyleSheet("background:transparent;");
194 m_disque->setAttribute(Qt::WA_TranslucentBackground);
195 m_disque->setPixmap(disque);
196 m_disque->setCursor(QCursor(Qt::PointingHandCursor));
197 m_disque->installEventFilter(this);
199 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(geometryUpdated()));
200 geometryUpdated();
202 m_discOpacity = 0.01;
203 m_disquePos.setX(static_cast<int>(MUtils::next_rand_u32() % static_cast<unsigned int>(m_disqueBound.right() - disque.width() - m_disqueBound.left())) + m_disqueBound.left());
204 m_disquePos.setY(static_cast<int>(MUtils::next_rand_u32() % static_cast<unsigned int>(m_disqueBound.bottom() - disque.height() - m_disqueBound.top())) + m_disqueBound.top());
205 m_disqueFlags[0] = (MUtils::next_rand_u32() > (UINT_MAX/2));
206 m_disqueFlags[1] = (MUtils::next_rand_u32() > (UINT_MAX/2));
207 m_disque->move(m_disquePos);
208 m_disque->setWindowOpacity(m_discOpacity);
210 m_disqueTimer.reset(new QTimer());
212 connect(m_disqueTimer.data(), SIGNAL(timeout()), this, SLOT(moveDisque()));
213 connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
215 else
217 ui->acceptButton->show();
218 ui->declineButton->show();
219 ui->aboutQtButton->hide();
220 ui->closeButton->hide();
223 //Activate "show license" button
224 ui->showLicenseButton->show();
225 connect(ui->showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
228 AboutDialog::~AboutDialog(void)
230 if(m_disque)
232 m_disque->close();
234 if(m_disqueTimer)
236 m_disqueTimer->stop();
238 MUTILS_DELETE(ui);
241 ////////////////////////////////////////////////////////////
242 // Public Functions
243 ////////////////////////////////////////////////////////////
245 int AboutDialog::exec()
247 if(m_settings->soundsEnabled())
249 if(m_firstStart)
251 if(!MUtils::Sound::play_sound_file("imageres.dll", 5080, true))
253 MUtils::Sound::play_system_sound("SystemStart", true);
256 else
258 MUtils::Sound::play_sound("ghost", true);
262 switch(QDialog::exec())
264 case 1:
265 return 1;
266 break;
267 case 2:
268 return -1;
269 break;
270 default:
271 return 0;
272 break;
276 ////////////////////////////////////////////////////////////
277 // Slots
278 ////////////////////////////////////////////////////////////
280 #define TEMP_HIDE_DISQUE(CMD) do \
282 bool _tmp = (m_disque) ? m_disque->isVisible() : false; \
283 if(_tmp) m_disque->hide(); \
284 { CMD } \
285 if(_tmp) \
287 m_discOpacity = 0.01; \
288 m_disque->setWindowOpacity(m_discOpacity); \
289 m_disque->show(); \
292 while(0)
294 void AboutDialog::tabChanged(int index, const bool silent)
296 bool bInitialized = m_initFlags->value(ui->tabWidget->widget(index), false);
298 if(!bInitialized)
300 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
302 if(QWidget *tab = ui->tabWidget->widget(index))
304 bool ok = false;
306 if(tab == ui->infoTab) { initInformationTab(); ok = true; }
307 if(tab == ui->contributorsTab) { initContributorsTab(); ok = true; }
308 if(tab == ui->softwareTab) { initSoftwareTab(); ok = true; }
309 if(tab == ui->licenseTab) { initLicenseTab(); ok = true; }
311 if(ok)
313 m_initFlags->insert(tab, true);
315 else
317 qWarning("Unknown tab %p encountered, cannot initialize !!!", tab);
322 ui->tabWidget->widget(index)->update();
323 qApp->processEvents();
324 qApp->restoreOverrideCursor();
327 //Play tick sound
328 if(m_settings->soundsEnabled() && (!silent))
330 MUtils::Sound::play_sound("tick", true);
333 //Scroll to the top
334 if(QWidget *tab = ui->tabWidget->widget(index))
336 if(tab == ui->infoTab) ui->infoScrollArea->verticalScrollBar()->setSliderPosition(0);
337 if(tab == ui->contributorsTab) ui->contributorsScrollArea->verticalScrollBar()->setSliderPosition(0);
338 if(tab == ui->softwareTab) ui->softwareScrollArea->verticalScrollBar()->setSliderPosition(0);
339 if(tab == ui->licenseTab) ui->licenseScrollArea->verticalScrollBar()->setSliderPosition(0);
342 //Update license button
343 ui->showLicenseButton->setChecked(ui->tabWidget->widget(index) == ui->licenseTab);
344 if(ui->tabWidget->widget(index) != ui->licenseTab) m_lastTab = index;
347 void AboutDialog::enableButtons(void)
349 ui->acceptButton->setEnabled(true);
350 ui->declineButton->setEnabled(true);
351 setCursor(QCursor(Qt::ArrowCursor));
354 void AboutDialog::openURL(const QString &url)
356 if(!QDesktopServices::openUrl(QUrl(url)))
358 MUtils::OS::shell_open(this, url);
362 void AboutDialog::showAboutQt(void)
364 TEMP_HIDE_DISQUE
366 QMessageBox::aboutQt(this);
370 void AboutDialog::gotoLicenseTab(void)
372 ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->showLicenseButton->isChecked() ? ui->licenseTab : ui->tabWidget->widget(m_lastTab)));
375 void AboutDialog::moveDisque(void)
377 int delta = 2;
378 QElapsedTimer elapsedTimer;
379 elapsedTimer.start();
381 if((!m_disqueDelay.isNull()) && m_disqueDelay->isValid())
383 const qint64 delay = m_disqueDelay->restart();
384 delta = qBound(1, static_cast<int>(ceil(static_cast<double>(delay) / 5.12)), 128);
386 else
388 m_disqueDelay.reset(new QElapsedTimer());
389 m_disqueDelay->start();
392 if(m_disque)
394 if(m_disquePos.x() <= m_disqueBound.left()) { m_disqueFlags[0] = true; m_rotateNext = true; }
395 if(m_disquePos.x() >= m_disqueBound.right()) { m_disqueFlags[0] = false; m_rotateNext = true; }
396 if(m_disquePos.y() <= m_disqueBound.top()) { m_disqueFlags[1] = true; m_rotateNext = true; }
397 if(m_disquePos.y() >= m_disqueBound.bottom()) { m_disqueFlags[1] = false; m_rotateNext = true; }
399 m_disquePos.setX(m_disqueFlags[0] ? (m_disquePos.x() + delta) : (m_disquePos.x() - delta));
400 m_disquePos.setY(m_disqueFlags[1] ? (m_disquePos.y() + delta) : (m_disquePos.y() - delta));
402 m_disque->move(m_disquePos);
404 if(m_rotateNext)
406 const QPixmap *const cartoon = m_cartoon[m_disqueFlags[0] ? (m_disqueFlags[1] ? 1 : 0): (m_disqueFlags[1] ? 2 : 3)].data();
407 if(cartoon)
409 m_disque->setPixmap(*cartoon);
410 if(m_disque->size() != cartoon->size())
412 m_disque->resize(cartoon->size());
413 geometryUpdated();
416 m_rotateNext = false;
419 if(m_discOpacity != 1.0)
421 m_discOpacity = m_discOpacity + 0.01;
422 if(qFuzzyCompare(m_discOpacity, 1.0) || (m_discOpacity > 1.0))
424 m_discOpacity = 1.0;
426 m_disque->setWindowOpacity(m_discOpacity);
427 m_disque->update();
432 void AboutDialog::geometryUpdated(void)
434 if(m_disque)
436 QRect screenGeometry = QApplication::desktop()->availableGeometry();
437 m_disqueBound.setLeft(screenGeometry.left());
438 m_disqueBound.setRight(screenGeometry.width() - m_disque->width() + screenGeometry.left());
439 m_disqueBound.setTop(screenGeometry.top());
440 m_disqueBound.setBottom(screenGeometry.height() - m_disque->height() + screenGeometry.top());
442 else
444 m_disqueBound = QApplication::desktop()->availableGeometry();
448 void AboutDialog::adjustSize(void)
450 const int maxH = QApplication::desktop()->availableGeometry().height();
451 const int maxW = QApplication::desktop()->availableGeometry().width();
453 const int deltaH = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
454 const int deltaW = ui->infoScrollArea->widget()->width() - ui->infoScrollArea->viewport()->width();
456 if(deltaH > 0)
458 this->resize(this->width(), qMin(this->height() + deltaH, maxH));
459 this->move(this->x(), this->y() - (deltaH / 2));
460 this->setMinimumHeight(qMax(this->minimumHeight(), this->height()));
463 if(deltaW > 0)
465 this->resize(qMin(this->width() + deltaW, maxW), this->height());
466 this->move(this->x() - (deltaW / 2), this->y());
467 this->setMinimumWidth(qMax(this->minimumWidth(), this->width()));
471 ////////////////////////////////////////////////////////////
472 // Protected Functions
473 ////////////////////////////////////////////////////////////
475 void AboutDialog::showEvent(QShowEvent *e)
477 QDialog::showEvent(e);
479 ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
480 tabChanged(m_lastTab = ui->tabWidget->currentIndex(), true);
482 if(m_firstStart)
484 ui->acceptButton->setEnabled(false);
485 ui->declineButton->setEnabled(false);
486 QTimer::singleShot(5000, this, SLOT(enableButtons()));
487 setCursor(QCursor(Qt::WaitCursor));
490 if (!(m_disque.isNull() || m_disqueTimer.isNull()))
492 m_disque->show();
493 m_disqueTimer->start(10);
496 QTimer::singleShot(0, this, SLOT(adjustSize()));
499 void AboutDialog::closeEvent(QCloseEvent *e)
501 if (m_firstStart)
503 e->ignore();
507 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
509 if((!m_disque.isNull()) && (obj == m_disque.data()) && (event->type() == QEvent::MouseButtonPress))
511 MUtils::Sound::play_sound("chicken", true);
512 if (!m_cartoon[0])
514 QPixmap cartoon(":/images/Cartoon.png");
515 for(int i = 0; i < 4; i++)
517 m_cartoon[i].reset(new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation)));
518 m_rotateNext = true;
521 QDesktopServices::openUrl(QUrl(disqueUrl));
524 return false;
527 ////////////////////////////////////////////////////////////
528 // Private Functions
529 ////////////////////////////////////////////////////////////
531 void AboutDialog::initInformationTab(void)
533 const QDate versionDate = MUtils::Version::app_build_date();
535 const QString versionStr = QString().sprintf
537 "Version %d.%02d %s, Build %d [%s], %s %s, Qt v%s",
538 lamexp_version_major(),
539 lamexp_version_minor(),
540 lamexp_version_release(),
541 lamexp_version_build(),
542 versionDate.toString(Qt::ISODate).toLatin1().constData(),
543 MUtils::Version::compiler_version(),
544 MUtils::Version::compiler_arch(),
545 qVersion()
548 const QString copyrightStr = QString().sprintf
550 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
551 qMax(versionDate.year(), MUtils::OS::current_date().year())
554 QString aboutText;
556 aboutText += QString("<h2>%1</h2>").arg(NOBR(tr("LameXP - Audio Encoder Front-end")));
557 aboutText += QString("<b>%1</b><br>").arg(NOBR(copyrightStr));
558 aboutText += QString("<b>%1</b><br><br>").arg(NOBR(versionStr));
559 aboutText += QString("%1<br>").arg(NOBR(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url()))));
561 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
562 const QDate currentDate = MUtils::OS::current_date();
563 if(MUTILS_DEBUG)
565 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
566 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
568 else if(lamexp_version_demo())
570 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
571 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
573 #else
574 const QDate currentDate = lamexp_current_date_safe();
575 if(LAMEXP_DEBUG)
577 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
578 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
580 else if(lamexp_version_demo())
582 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
583 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
585 #endif
587 aboutText += "<hr><br>";
589 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or modify<br>";
590 aboutText += "it under the terms of the GNU General Public License as published by<br>";
591 aboutText += "the Free Software Foundation; either version 2 of the License, or<br>";
592 aboutText += "(at your option) any later version, but always including the *additional*<br>";
593 aboutText += "restrictions defined in the \"License.txt\" file (see \"License\" tab).<br><br>";
594 aboutText += "This program is distributed in the hope that it will be useful,<br>";
595 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
596 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
597 aboutText += "GNU General Public License for more details.<br><br>";
598 aboutText += "You should have received a copy of the GNU General Public License<br>";
599 aboutText += "along with this program; if not, write to the Free Software<br>";
600 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110&minus;1301, USA.</tt></nobr><br>";
601 aboutText += "<hr><table style=\"margin-top:4px\"><tr>";
602 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
603 aboutText += QString("<td><font color=\"darkred\">%1</font></td>").arg(tr("Note: LameXP is free software. Do <b>not</b> pay money to obtain or use LameXP! If some third-party website tries to make you pay for downloading LameXP, you should <b>not</b> respond to the offer !!!"));
604 aboutText += "</tr></table>";
606 ui->infoLabel->setText(aboutText);
607 ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
608 connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
611 void AboutDialog::initContributorsTab(void)
613 const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
614 const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
616 QString contributorsAboutText;
617 contributorsAboutText += QString("<h3>%1</h3>").arg(NOBR(tr("The following people have contributed to LameXP:")));
618 contributorsAboutText += "<table style=\"margin-top:12px;white-space:nowrap\">";
620 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Programmers:"), extraVSpace);
621 QString icon = QString("<img src=\":/icons/%1.png\">").arg("user_gray");
622 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(icon, spaces);
623 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(tr("Project Leader"), spaces);
624 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td><a href=\"mailto:%3\">&lt;%3&gt;</a></td></tr>").arg("LoRd_MuldeR", spaces, "MuldeR2@GMX.de");
625 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
627 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Translators:"), extraVSpace);
628 for(int i = 0; g_lamexp_translators[i].pcName; i++)
630 QString flagIcon = (strlen(g_lamexp_translators[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_translators[i].pcFlag) : QString();
631 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(flagIcon, spaces);
632 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(MUTILS_QSTR(g_lamexp_translators[i].pcLanguage), spaces);
633 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td><a href=\"mailto:%3\">&lt;%3&gt;</a></td></tr>").arg(MUTILS_QSTR(g_lamexp_translators[i].pcName), spaces, g_lamexp_translators[i].pcMail);
636 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
637 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Special thanks to:"), extraVSpace);
639 QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
640 for(int i = 0; g_lamexp_specialThanks[i].pcName; i++)
642 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
643 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td valign=\"middle\" colspan=\"3\"><a href=\"%3\">%3</td></tr>").arg(QString::fromLatin1(g_lamexp_specialThanks[i].pcName), spaces, QString::fromLatin1(g_lamexp_specialThanks[i].pcAddress));
646 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
647 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Official Mirrors:"), extraVSpace);
649 QString serverIcon = QString("<img src=\":/icons/%1.png\">").arg("server_database");
650 for(int i = 0; g_lamexp_mirrors[i].pcName; i++)
652 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(serverIcon, spaces);
653 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td valign=\"middle\" colspan=\"3\"><a href=\"%3\">%3</td></tr>").arg(QString::fromLatin1(g_lamexp_mirrors[i].pcName), spaces, QString::fromLatin1(g_lamexp_mirrors[i].pcAddress));
656 contributorsAboutText += "</table><br><br><br>";
657 contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
659 ui->contributorsLabel->setText(contributorsAboutText);
660 ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
661 connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
664 void AboutDialog::initSoftwareTab(void)
666 QString moreAboutText;
668 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
669 moreAboutText += "<div style=\"margin-left:-25px;white-space:nowrap\"><table><tr><td><ul>"; //;font-size:7pt
671 moreAboutText += makeToolText
673 tr("LAME - OpenSource mp3 Encoder"),
674 "lame.exe", "v?.???, #-?",
675 tr("Released under the terms of the GNU Lesser General Public License."),
676 "http://lame.sourceforge.net/"
678 moreAboutText += makeToolText
680 tr("OggEnc - Vorbis Encoder"),
681 "oggenc2.exe", "v?.??, libvorbis v?.?? + aoTuV b?.??_#",
682 tr("Completely open and patent-free audio encoding technology."),
683 "http://www.rarewares.org/ogg-oggenc.php"
685 moreAboutText += makeToolText
687 tr("Nero AAC Reference MPEG-4 Encoder"),
688 "neroAacEnc.exe", "v?.?.?.?",
689 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
690 neroAacUrl,
691 tr("Available from vendor web-site as free download:")
693 moreAboutText += makeToolText
695 tr("Aften - A/52 audio encoder"),
696 "aften.exe", "v?.?.?",
697 tr("Released under the terms of the GNU Lesser General Public License."),
698 "http://aften.sourceforge.net/"
700 moreAboutText += makeToolText
702 tr("FLAC - Free Lossless Audio Codec"),
703 "flac.exe", "v?.?.?",
704 tr("Open and patent-free lossless audio compression technology."),
705 "http://flac.sourceforge.net/"
707 moreAboutText += makeToolText
709 tr("Opus Audio Codec"),
710 "opusenc.exe", "#, ????-??-??",
711 tr("Totally open, royalty-free, highly versatile audio codec."),
712 "http://www.opus-codec.org/"
714 moreAboutText += makeToolText
716 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
717 "mpg123.exe", "v?.??.?",
718 tr("Released under the terms of the GNU Lesser General Public License."),
719 "http://www.mpg123.de/"
721 moreAboutText += makeToolText
723 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
724 "faad.exe", "v?.?",
725 tr("Released under the terms of the GNU General Public License."),
726 "http://www.audiocoding.com/"
728 moreAboutText += makeToolText
730 tr("OggDec - Vorbis Decoder"),
731 "oggdec.exe", "v?.??.?",
732 tr("Command line Ogg Vorbis decoder created by John33."),
733 "http://www.rarewares.org/ogg-oggdec.php"
735 moreAboutText += makeToolText
737 tr("Valdec from AC3Filter Tools - AC3/DTS Decoder"),
738 "valdec.exe", "v?.??#",
739 tr("Released under the terms of the GNU Lesser General Public License."),
740 "http://www.ac3filter.net/projects/tools"
742 moreAboutText += makeToolText
744 tr("WavPack - Hybrid Lossless Compression"),
745 "wvunpack.exe", "v?.??.?",
746 tr("Completely open audio compression format."),
747 "http://www.wavpack.com/"
749 moreAboutText += makeToolText
751 tr("Musepack - Living Audio Compression"),
752 "mpcdec.exe", "r???",
753 tr("Released under the terms of the GNU Lesser General Public License."),
754 "http://www.musepack.net/"
756 moreAboutText += makeToolText
758 tr("Monkey's Audio - Lossless Audio Compressor"),
759 "mac.exe", "v?.??",
760 tr("Freely available source code, simple SDK and non-restrictive licensing."),
761 "http://www.monkeysaudio.com/"
763 moreAboutText += makeToolText
765 tr("Shorten - Lossless Audio Compressor"),
766 "shorten.exe", "v?.?.?",
767 tr("Released under the terms of the GNU Lesser General Public License."),
768 "http://etree.org/shnutils/shorten/"
770 moreAboutText += makeToolText
772 tr("Speex - Free Codec For Free Speech"),
773 "speexdec.exe", "v?.?",
774 tr("Open Source patent-free audio format designed for speech."),
775 "http://www.speex.org/"
777 moreAboutText += makeToolText
779 tr("The True Audio - Lossless Audio Codec"),
780 "tta.exe", "v?.?",
781 tr("Released under the terms of the GNU Lesser General Public License."),
782 "http://tta.sourceforge.net/"
784 moreAboutText += makeToolText
786 tr("refalac - Win32 command line ALAC encoder/decoder"),
787 "refalac.exe", "v?.??",
788 tr("The ALAC reference implementation by Apple is available under the Apache license."),
789 "http://alac.macosforge.org/"
791 moreAboutText += makeToolText
793 tr("wma2wav - Dump WMA files to Wave Audio"),
794 "wma2wav.exe", "????-??-??",
795 tr("Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved."),
796 "http://forum.doom9.org/showthread.php?t=140273"
798 moreAboutText += makeToolText
800 tr("avs2wav - Avisynth to Wave Audio converter"),
801 "avs2wav.exe", "v?.?",
802 tr("By Jory Stone <jcsston@toughguy.net> and LoRd_MuldeR <mulder2@gmx.de>."),
803 "http://forum.doom9.org/showthread.php?t=70882"
805 moreAboutText += makeToolText
807 tr("dcaenc"),
808 "dcaenc.exe", "????-??-??",
809 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
810 "https://gitlab.com/patrakov/dcaenc"
812 moreAboutText += makeToolText
814 tr("MediaInfo - Media File Analysis Tool"),
815 "mediainfo.exe", "v?.?.??",
816 tr("Released under the terms of the GNU Lesser General Public License."),
817 "http://mediainfo.sourceforge.net/"
819 moreAboutText += makeToolText
821 tr("SoX - Sound eXchange"),
822 "sox.exe", "v??.?.?",
823 tr("Released under the terms of the GNU Lesser General Public License."),
824 "http://sox.sourceforge.net/"
826 moreAboutText += makeToolText
828 tr("GnuPG - The GNU Privacy Guard"),
829 "gpgv.exe", "v?.?.??",
830 tr("Released under the terms of the GNU Lesser General Public License."),
831 "http://www.gnupg.org/"
833 moreAboutText += makeToolText
835 tr("GNU Wget - Software for retrieving files using HTTP"),
836 "wget.exe", "v?.??.?",
837 tr("Released under the terms of the GNU Lesser General Public License."),
838 "http://www.gnu.org/software/wget/"
840 moreAboutText += makeToolText
842 tr("UPX - The Ultimate Packer for eXecutables"),
843 QString(), "v3.09",
844 tr("Released under the terms of the GNU Lesser General Public License."),
845 "http://upx.sourceforge.net/"
847 moreAboutText += makeToolText
849 tr("Silk Icons - Over 700 icons in PNG format"),
850 QString(), "v1.3",
851 tr("By Mark James, released under the Creative Commons 'BY' License."),
852 "http://www.famfamfam.com/lab/icons/silk/"
854 moreAboutText += makeToolText
856 tr("Angry Chicken and Ghost Scream sound"),
857 QString(), "v1.0",
858 tr("By Alexander, released under the Creative Commons 'BY' License."),
859 "http://www.orangefreesounds.com/"
861 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><br><i>%1</i><br>").arg
863 tr("The copyright of LameXP as a whole belongs to LoRd_MuldeR. The copyright of third-party software used in LameXP belongs to the individual authors.")
866 ui->softwareLabel->setText(moreAboutText);
867 ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
868 connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
871 void AboutDialog::initLicenseTab(void)
873 bool bFoundHeader = false;
874 QRegExp header("^(\\s*)(GNU GENERAL PUBLIC LICENSE)(\\s*)$");
876 QString licenseText;
877 licenseText += ("<tt>");
879 QFile file(":/License.txt");
880 if(file.open(QIODevice::ReadOnly))
882 QTextStream stream(&file);
883 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
885 QString line = stream.readLine();
886 line.replace('<', "&lt;").replace('>', "&gt;");
887 if((!bFoundHeader) && (header.indexIn(line) >= 0))
889 line.replace(header, "\\1<b>\\2</b>\\3");
890 bFoundHeader = true;
892 TRIM_RIGHT(line);
893 licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
895 licenseText += QString("<br>");
896 stream.device()->close();
898 else
900 licenseText += QString("<font color=\"darkred\">Oups, failed to load license text. Please refer to:</font><br>");
901 licenseText += LINK("http://www.gnu.org/licenses/gpl-2.0.html");
904 licenseText += ("</tt>");
906 ui->licenseLabel->setText(licenseText);
907 ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
908 connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
912 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
914 QString toolText, toolTag, verStr(toolVerFmt);
916 if(!toolBin.isEmpty())
918 const unsigned int version = lamexp_tools_version(toolBin, &toolTag);
919 verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), toolTag);
922 toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));
923 toolText += QString("%1<br>").arg(NOBR(toolLicense));
924 if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(NOBR(extraInfo));
925 toolText += QString("<nobr>%1</nobr>").arg(LINK(toolWebsite));
926 toolText += QString("<font style=\"font-size:9px\"><br>&nbsp;</font>");
928 return toolText;