OSDN Git Service

Updated copyright year.
[lamexp/LameXP.git] / src / Dialog_About.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2022 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; always including the non-optional
9 // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
10 //
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.
15 //
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.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include "Dialog_About.h"
24
25 #include "UIC_AboutDialog.h"
26
27 //Internal
28 #include "Global.h"
29 #include "Model_Settings.h"
30
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>
37
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 <QLibraryInfo>
56 #include <QWindowsVistaStyle>
57 #include <QWindowsXPStyle>
58
59 //CRT
60 #include <math.h>
61 #include <typeinfo>
62
63 //Helper macros
64 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;"))
65 #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)
66 #define PLAY_SOUND_OPTIONAL(NAME, ASYNC) do { if(m_settings->soundsEnabled()) MUtils::Sound::play_sound((NAME), (ASYNC)); } while(0)
67 #define MAKE_TRANSPARENT(WIDGET) do { QPalette _p = (WIDGET)->palette(); _p.setColor(QPalette::Background, Qt::transparent); (WIDGET)->setPalette(_p); } while(0)
68
69 //Constants
70 const char *AboutDialog::neroAacUrl = "http://www.videohelp.com/software/Nero-AAC-Codec"; //"http://www.nero.com/eng/company/about-nero/nero-aac-codec.php"
71 const char *AboutDialog::disqueUrl =  "http://muldersoft.com/?player_url=n4bply6Ibqw"; //38X-MXOB014
72
73 //Contributors
74 static const struct 
75 {
76         char *pcFlag;
77         wchar_t *pcLanguage;
78         wchar_t *pcName;
79         char *pcContactAddr;
80 }
81 g_lamexp_translators[] =
82 {
83         {"en", L"English",    L"LoRd_MuldeR",         "MuldeR2@GMX.de"           },
84         {"de", L"Deutsch",    L"LoRd_MuldeR",         "MuldeR2@GMX.de"           },
85         {"",   L"",           L"Bodo Thevissen",      "Bodo@thevissen.de"        },
86         {"es", L"Español",    L"Rub3nCT",             "Rub3nCT@gmail.com"        },
87         {"fr", L"Française",  L"Dodich Informatique", "Dodich@live.fr"           },
88         {"",   L"Française",  L"Sami Ghoul-Duclos",   "samgd14@live.ca"          },
89         {"hu", L"Magyarul",   L"ZityiSoft Team",      "zityisoft@gmail.com"      },
90         {"it", L"Italiano",   L"Roberto",             "Gulliver_69@libero.it"    },
91         {"",   L"",           L"Gianluca Papi",       "johnnyb.goode68@gmail.com"},
92         {"ja", L"日本語",        L"Maboroshin",          "pc.genkaku.in"            },
93         {"kr", L"한국어",        L"JaeHyung Lee",        "Kolanp@gmail.com"         },
94         {"pl", L"Polski",     L"Sir Daniel K",        "Sir.Daniel.K@gmail.com"   },
95         {"ru", L"Русский",    L"Neonailol",           "Neonailol@gmail.com"      },
96         {"",   L"",           L"Иван Митин",          "bardak@inbox.ru"          },
97         {"sv", L"Svenska",    L"Åke Engelbrektson",   "eson@svenskasprakfiler.se"},
98         {"tw", L"繁体中文",       L"456Vv",               "123@456vv.com"            },
99         {"uk", L"Українська", L"Arestarh",            "Arestarh@ukr.net"         },
100         {"zh", L"简体中文",       L"456Vv",               "123@456vv.com"            },
101         {"",   L"",           L"庄泓川",                 "kidneybean@pku.edu.cn"    },
102         {NULL, NULL, NULL, NULL}
103 };
104
105 //Special Thanks
106 static const struct
107 {
108         char* pcName;
109         char *pcAddress;
110 }
111 g_lamexp_specialThanks[] =
112 {
113         { "Doom9's Forum",         "http://forum.doom9.org/"          },
114         { "Gleitz | German Doom9", "http://forum.gleitz.info/"        },
115         { "Portable Freeware",     "http://www.portablefreeware.com/" },
116         { "Hydrogenaudio Forums",  "http://www.hydrogenaudio.org/"    },
117         { "RareWares",             "http://www.rarewares.org/"        },
118         { "GitHub",                "http://github.com/"               },
119         { "SourceForge",           "http://sourceforge.net/"          },
120         { "OSDN.net",              "http://osdn.net/"                 },
121         { "Marius Hudea",          "http://savedonthe.net/"           },
122         { "Qt Developer Network",  "http://www.qt.io/developers/"     },
123         { "Codecs.com",            "http://www.codecs.com/"           },
124         { "VideoHelp",             "http://www.videohelp.com/"        },
125         { NULL, NULL }
126 };
127
128 //Mirrors
129 static const struct
130 {
131         char* pcName;
132         char *pcAddress;
133 }
134 g_lamexp_mirrors[] =
135 {
136         { "GitHub.com",      "https://github.com/lordmulder/LameXP"             },
137         { "SourceForge.net", "http://sourceforge.net/p/lamexp/code/"            },
138     { "OSDN.net",        "https://osdn.net/projects/lamexp/scm/git/LameXP/" },
139         { "Bitbucket.org",   "https://bitbucket.org/muldersoft/lamexp"          },
140         { "GitLab.com"   ,   "https://gitlab.com/lamexp/lamexp"                 },
141         { "Assembla.com",    "https://www.assembla.com/spaces/lamexp/"          },
142         { "repo.or.cz",      "https://repo.or.cz/w/LameXP.git"                  },
143         { NULL, NULL }
144 };
145
146 ////////////////////////////////////////////////////////////
147 // Constructor
148 ////////////////////////////////////////////////////////////
149
150 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
151 :
152         QDialog(parent),
153         ui(new Ui::AboutDialog),
154         m_settings(settings),
155         m_initFlags(new QMap<QWidget*,bool>),
156         m_disque(NULL),
157         m_disqueTimer(NULL),
158         m_rotateNext(false),
159         m_lastTab(0),
160         m_firstStart(firstStart)
161 {
162         //Init the dialog, from the .ui file
163         ui->setupUi(this);
164         setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
165         setMinimumSize(this->size());
166
167         //Adjust size to DPI settings and re-center
168         MUtils::GUI::scale_widget(this);
169
170         //Disable "X" button
171         if(firstStart)
172         {
173                 MUtils::GUI::enable_close_button(this, false);
174         }
175
176         //Init tab widget
177         connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
178
179         //Make transparent
180         const type_info &styleType = typeid(*qApp->style());
181         if((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType))
182         {
183                 MAKE_TRANSPARENT(ui->infoScrollArea);
184                 MAKE_TRANSPARENT(ui->contributorsScrollArea);
185                 MAKE_TRANSPARENT(ui->softwareScrollArea);
186                 MAKE_TRANSPARENT(ui->licenseScrollArea);
187         }
188
189         //Show about dialog for the first time?
190         if(!firstStart)
191         {
192                 ui->acceptButton->hide();
193                 ui->declineButton->hide();
194                 ui->aboutQtButton->show();
195                 ui->closeButton->show();
196
197                 QPixmap disque(":/images/Disque.png");
198                 m_disque.reset(new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
199                 m_disque->resize(disque.size());
200                 m_disque->setStyleSheet("background:transparent;");
201                 m_disque->setAttribute(Qt::WA_TranslucentBackground);
202                 m_disque->setPixmap(disque);
203                 m_disque->setCursor(QCursor(Qt::PointingHandCursor));
204                 m_disque->installEventFilter(this);
205
206                 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(geometryUpdated()));
207                 geometryUpdated();
208
209                 m_discOpacity = 0.01;
210                 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());
211                 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());
212                 m_disqueFlags[0] = (MUtils::next_rand_u32() > (UINT_MAX/2));
213                 m_disqueFlags[1] = (MUtils::next_rand_u32() > (UINT_MAX/2));
214                 m_disque->move(m_disquePos);
215                 m_disque->setWindowOpacity(m_discOpacity);
216
217                 m_disqueTimer.reset(new QTimer());
218
219                 connect(m_disqueTimer.data(), SIGNAL(timeout()), this, SLOT(moveDisque()));
220                 connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
221         }
222         else
223         {
224                 ui->acceptButton->show();
225                 ui->declineButton->show();
226                 ui->aboutQtButton->hide();
227                 ui->closeButton->hide();
228         }
229
230         //Activate "show license" button
231         ui->showLicenseButton->show();
232         connect(ui->showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
233 }
234
235 AboutDialog::~AboutDialog(void)
236 {
237         if(m_disque)
238         {
239                 m_disque->close();
240         }
241         if(m_disqueTimer)
242         {
243                 m_disqueTimer->stop();
244         }
245         MUTILS_DELETE(ui);
246 }
247
248 ////////////////////////////////////////////////////////////
249 // Public Functions
250 ////////////////////////////////////////////////////////////
251
252 int AboutDialog::exec()
253 {
254         if(m_firstStart)
255         {
256                 if (m_settings->soundsEnabled())
257                 {
258                         if (!MUtils::Sound::play_sound_file("imageres.dll", 5080, true))
259                         {
260                                 MUtils::Sound::play_system_sound("WindowsLogon", true);
261                         }
262                 }
263         }
264         else
265         {
266                 PLAY_SOUND_OPTIONAL("slunk", true);
267         }
268         
269         switch(QDialog::exec())
270         {
271         case 1:
272                 return 1;
273                 break;
274         case 2:
275                 return -1;
276                 break;
277         default:
278                 return 0;
279                 break;
280         }
281 }
282
283 ////////////////////////////////////////////////////////////
284 // Slots
285 ////////////////////////////////////////////////////////////
286
287 #define TEMP_HIDE_DISQUE(CMD) do \
288 { \
289         bool _tmp = (m_disque) ? m_disque->isVisible() : false; \
290         if(_tmp) m_disque->hide(); \
291         { CMD } \
292         if(_tmp) \
293         { \
294                 m_discOpacity = 0.01; \
295                 m_disque->setWindowOpacity(m_discOpacity); \
296                 m_disque->show(); \
297         } \
298 } \
299 while(0)
300
301 void AboutDialog::tabChanged(int index, const bool silent)
302 {
303         bool bInitialized = m_initFlags->value(ui->tabWidget->widget(index), false);
304
305         if(!bInitialized)
306         {
307                 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
308
309                 if(QWidget *tab = ui->tabWidget->widget(index))
310                 {
311                         bool ok = false;
312
313                         if(tab == ui->infoTab) { initInformationTab(); ok = true; }
314                         if(tab == ui->contributorsTab) { initContributorsTab(); ok = true; }
315                         if(tab == ui->softwareTab) { initSoftwareTab(); ok = true; }
316                         if(tab == ui->licenseTab) { initLicenseTab(); ok = true; }
317
318                         if(ok)
319                         {
320                                 m_initFlags->insert(tab, true);
321                         }
322                         else
323                         {
324                                 qWarning("Unknown tab %p encountered, cannot initialize !!!", tab);
325                         }
326                         
327                 }
328
329                 ui->tabWidget->widget(index)->update();
330                 qApp->processEvents();
331                 qApp->restoreOverrideCursor();
332         }
333
334         //Play tick sound, unless silent
335         if (!silent)
336         {
337                 PLAY_SOUND_OPTIONAL("tick", true);
338         }
339
340         //Scroll to the top
341         if(QWidget *tab = ui->tabWidget->widget(index))
342         {
343                 if(tab == ui->infoTab) ui->infoScrollArea->verticalScrollBar()->setSliderPosition(0);
344                 if(tab == ui->contributorsTab) ui->contributorsScrollArea->verticalScrollBar()->setSliderPosition(0);
345                 if(tab == ui->softwareTab) ui->softwareScrollArea->verticalScrollBar()->setSliderPosition(0);
346                 if(tab == ui->licenseTab) ui->licenseScrollArea->verticalScrollBar()->setSliderPosition(0);
347         }
348
349         //Update license button
350         ui->showLicenseButton->setChecked(ui->tabWidget->widget(index) == ui->licenseTab);
351         if(ui->tabWidget->widget(index) != ui->licenseTab) m_lastTab = index;
352 }
353
354 void AboutDialog::enableButtons(void)
355 {
356         ui->acceptButton->setEnabled(true);
357         ui->declineButton->setEnabled(true);
358         setCursor(QCursor(Qt::ArrowCursor));
359 }
360
361 void AboutDialog::openURL(const QString &url)
362 {
363         if(!QDesktopServices::openUrl(QUrl(url)))
364         {
365                 MUtils::OS::shell_open(this, url);
366         }
367 }
368
369 void AboutDialog::showAboutQt(void)
370 {
371         TEMP_HIDE_DISQUE
372         (
373                 QMessageBox::aboutQt(this);
374         );
375 }
376
377 void AboutDialog::gotoLicenseTab(void)
378 {
379         ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->showLicenseButton->isChecked() ? ui->licenseTab : ui->tabWidget->widget(m_lastTab)));
380 }
381
382 void AboutDialog::moveDisque(void)
383 {
384         int delta = 2;
385         QElapsedTimer elapsedTimer;
386         elapsedTimer.start();
387
388         if((!m_disqueDelay.isNull()) && m_disqueDelay->isValid())
389         {
390                 const qint64 delay = m_disqueDelay->restart();
391                 delta = qBound(1, static_cast<int>(ceil(static_cast<double>(delay) / 5.12)), 128);
392         }
393         else
394         {
395                 m_disqueDelay.reset(new QElapsedTimer());
396                 m_disqueDelay->start();
397         }
398
399         if(m_disque)
400         {
401                 if(m_disquePos.x() <= m_disqueBound.left())   { m_disqueFlags[0] = true;  m_rotateNext = true; }
402                 if(m_disquePos.x() >= m_disqueBound.right())  { m_disqueFlags[0] = false; m_rotateNext = true; }
403                 if(m_disquePos.y() <= m_disqueBound.top())    { m_disqueFlags[1] = true;  m_rotateNext = true; }
404                 if(m_disquePos.y() >= m_disqueBound.bottom()) { m_disqueFlags[1] = false; m_rotateNext = true; }
405                 
406                 m_disquePos.setX(m_disqueFlags[0] ? (m_disquePos.x() + delta) : (m_disquePos.x() - delta));
407                 m_disquePos.setY(m_disqueFlags[1] ? (m_disquePos.y() + delta) : (m_disquePos.y() - delta));
408
409                 m_disque->move(m_disquePos);
410                 
411                 if(m_rotateNext)
412                 {
413                         const QPixmap *const cartoon = m_cartoon[m_disqueFlags[0] ? (m_disqueFlags[1] ? 1 : 0): (m_disqueFlags[1] ? 2 : 3)].data();
414                         if(cartoon)
415                         {
416                                 m_disque->setPixmap(*cartoon);
417                                 if(m_disque->size() != cartoon->size())
418                                 {
419                                         m_disque->resize(cartoon->size());
420                                         geometryUpdated();
421                                 }
422                         }
423                         m_rotateNext = false;
424                 }
425
426                 if(m_discOpacity != 1.0)
427                 {
428                         m_discOpacity = m_discOpacity + 0.01;
429                         if(qFuzzyCompare(m_discOpacity, 1.0) || (m_discOpacity > 1.0))
430                         {
431                                 m_discOpacity = 1.0;
432                         }
433                         m_disque->setWindowOpacity(m_discOpacity);
434                         m_disque->update();
435                 }
436         }
437 }
438
439 void AboutDialog::geometryUpdated(void)
440 {
441         if(m_disque)
442         {
443                 QRect screenGeometry = QApplication::desktop()->availableGeometry();
444                 m_disqueBound.setLeft(screenGeometry.left());
445                 m_disqueBound.setRight(screenGeometry.width() - m_disque->width() + screenGeometry.left());
446                 m_disqueBound.setTop(screenGeometry.top());
447                 m_disqueBound.setBottom(screenGeometry.height() - m_disque->height() + screenGeometry.top());
448         }
449         else
450         {
451                 m_disqueBound = QApplication::desktop()->availableGeometry();
452         }
453 }
454
455 void AboutDialog::adjustSize(void)
456 {
457         const int maxH = QApplication::desktop()->availableGeometry().height();
458         const int maxW = QApplication::desktop()->availableGeometry().width();
459
460         const int deltaH = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
461         const int deltaW = ui->infoScrollArea->widget()->width()  - ui->infoScrollArea->viewport()->width();
462
463         if(deltaH > 0)
464         {
465                 this->resize(this->width(), qMin(this->height() + deltaH, maxH));
466                 this->move(this->x(), this->y() - (deltaH / 2));
467                 this->setMinimumHeight(qMax(this->minimumHeight(), this->height()));
468         }
469
470         if(deltaW > 0)
471         {
472                 this->resize(qMin(this->width() + deltaW, maxW), this->height());
473                 this->move(this->x() - (deltaW / 2), this->y());
474                 this->setMinimumWidth(qMax(this->minimumWidth(), this->width()));
475         }
476 }
477
478 ////////////////////////////////////////////////////////////
479 // Protected Functions
480 ////////////////////////////////////////////////////////////
481
482 void AboutDialog::showEvent(QShowEvent *e)
483 {
484         QDialog::showEvent(e);
485         
486         ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
487         tabChanged(m_lastTab = ui->tabWidget->currentIndex(), true);
488         
489         if(m_firstStart)
490         {
491                 ui->acceptButton->setEnabled(false);
492                 ui->declineButton->setEnabled(false);
493                 QTimer::singleShot(5000, this, SLOT(enableButtons()));
494                 setCursor(QCursor(Qt::WaitCursor));
495         }
496
497         if (!(m_disque.isNull() || m_disqueTimer.isNull()))
498         {
499                 m_disque->show();
500                 m_disqueTimer->start(10);
501         }
502
503         QTimer::singleShot(0, this, SLOT(adjustSize()));
504 }
505
506 void AboutDialog::closeEvent(QCloseEvent *e)
507 {
508         if (m_firstStart)
509         {
510                 e->ignore();
511         }
512 }
513
514 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
515 {
516         if((!m_disque.isNull()) && (obj == m_disque.data()) && (event->type() == QEvent::MouseButtonPress))
517         {
518                 PLAY_SOUND_OPTIONAL("chicken", true);
519                 if (!m_cartoon[0])
520                 {
521                         QPixmap cartoon(":/images/Cartoon.png");
522                         for(int i = 0; i < 4; i++)
523                         {
524                                 m_cartoon[i].reset(new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation)));
525                                 m_rotateNext = true;
526                         }
527                 }
528                 QDesktopServices::openUrl(QUrl(disqueUrl));
529         }
530
531         return false;
532 }
533
534 ////////////////////////////////////////////////////////////
535 // Private Functions
536 ////////////////////////////////////////////////////////////
537
538 void AboutDialog::initInformationTab(void)
539 {
540         const QDate versionDate = MUtils::Version::app_build_date();
541         const QTime versionTime = MUtils::Version::app_build_time();
542
543         const QString versionStr = QString("Version %1 %2, Build %3 [%4] [%5]").arg
544         (
545                 QString().sprintf("%u.%02u", lamexp_version_major(), lamexp_version_minor()),
546                 QString::fromLatin1(lamexp_version_release()),
547                 QString::number(lamexp_version_build()),
548                 versionDate.toString(Qt::ISODate),
549                 versionTime.toString(Qt::ISODate)
550         );
551
552         const QString platformStr = QString("%1 [%2], MUtilities %3 [%4] [%5], Qt Framework v%6 [%7]").arg
553         (
554                 QString::fromLatin1(MUtils::Version::compiler_version()),
555                 QString::fromLatin1(MUtils::Version::compiler_arch()),
556                 QString().sprintf("%u.%02u", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor()),
557                 MUtils::Version::lib_build_date().toString(Qt::ISODate).toLatin1().constData(),
558                 MUtils::Version::lib_build_time().toString(Qt::ISODate).toLatin1().constData(),
559                 QString::fromLatin1(qVersion()),
560                 QLibraryInfo::buildDate().toString(Qt::ISODate)
561         );
562
563         const QString copyrightStr = QString().sprintf
564         (
565                 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
566                 qMax(versionDate.year(), MUtils::OS::current_date().year())
567         );
568
569         QString aboutText;
570
571         aboutText += QString("<h2>%1</h2>").arg(tr("LameXP - Audio Encoder Front-end"));
572         aboutText += QString("<b>%1</b><br>").arg(copyrightStr);
573         aboutText += QString("<b>%1</b><br>").arg(versionStr);
574         aboutText += QString("<b>%1</b><br><br>").arg(platformStr);
575         aboutText += QString("%1<br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
576
577 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
578         const QDate currentDate = MUtils::OS::current_date();
579         if(MUTILS_DEBUG)
580         {
581                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
582                 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft)));
583         }
584         else if(lamexp_version_test())
585         {
586                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
587                 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(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)));
588         }
589 #else
590         const QDate currentDate = lamexp_current_date_safe();
591         if(LAMEXP_DEBUG)
592         {
593                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
594                 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft)));
595         }
596         else if(lamexp_version_demo())
597         {
598                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
599                 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(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)));
600         }
601 #endif
602
603         aboutText += "<hr><br>";
604         
605         aboutText += "<tt>This program is free software; you can redistribute it and/or modify<br>";
606         aboutText += "it under the terms of the GNU GENERAL PUBLIC LICENSE as published by<br>";
607         aboutText += "the Free Software Foundation; either version 2 of the License, or<br>";
608         aboutText += "(at your option) any later version; always including the non-optional<br>";
609         aboutText += "refinements defined in the \"License.txt\" file (see \"License\" tab).<br><br>";
610         aboutText += "This program is distributed in the hope that it will be useful,<br>";
611         aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
612         aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>";
613         aboutText += "GNU General Public License for more details.<br><br>";
614         aboutText += "You should have received a copy of the GNU General Public License<br>";
615         aboutText += "along with this program; if not, write to the Free Software<br>";
616         aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110&minus;1301, USA.</tt><br>";
617         aboutText += "<hr><table style=\"margin-top:4px\"><tr>";
618         aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
619         aboutText += QString("<td style='white-space:normal'><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 !!!"));
620         aboutText += "</tr></table>";
621
622         ui->infoLabel->setText(NOBREAK(aboutText));
623         ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
624         connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
625 }
626
627 void AboutDialog::initContributorsTab(void)
628 {
629         const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
630         const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
631         
632         QString contributorsAboutText;
633         contributorsAboutText += QString("<h3>%1</h3>").arg(tr("The following people have contributed to LameXP:"));
634         contributorsAboutText += "<table style=\"margin-top:12px;white-space:nowrap\">";
635         
636         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Programmers:"), extraVSpace);
637         QString icon = QString("<img src=\":/icons/%1.png\">").arg("user_gray");
638         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(icon, spaces);
639         contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(tr("Project Leader"), spaces);
640         contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td><a href=\"mailto:%3?subject=LameXP\">&lt;%3&gt;</a></td></tr>").arg(L1S("LoRd_MuldeR"), spaces, L1S("MuldeR2@GMX.de"));
641         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
642
643         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Translators:"), extraVSpace);
644         for(int i = 0; g_lamexp_translators[i].pcName; i++)
645         {
646                 const QString flagIcon = (strlen(g_lamexp_translators[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(QString::fromLatin1(g_lamexp_translators[i].pcFlag)) : QString();
647                 const QString contactAddr = QString::fromLatin1(g_lamexp_translators[i].pcContactAddr);
648                 const QString linkUrl = QString(contactAddr.contains('@') ? "mailto:%1?subject=LameXP" : "http://%1").arg(contactAddr);
649                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(flagIcon, spaces);
650                 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(MUTILS_QSTR(g_lamexp_translators[i].pcLanguage), spaces);
651                 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td><a href=\"%3\">&lt;%4&gt;</a></td></tr>").arg(MUTILS_QSTR(g_lamexp_translators[i].pcName), spaces, linkUrl, contactAddr);
652         }
653
654         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
655         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Special thanks to:"), extraVSpace);
656
657         QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
658         for(int i = 0; g_lamexp_specialThanks[i].pcName; i++)
659         {
660                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
661                 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));
662         }
663
664         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
665         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Official Mirrors:"), extraVSpace);
666
667         QString serverIcon = QString("<img src=\":/icons/%1.png\">").arg("server_database");
668         for(int i = 0; g_lamexp_mirrors[i].pcName; i++)
669         {
670                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(serverIcon, spaces);
671                 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));
672         }
673
674         contributorsAboutText += "</table><br><br><br>";
675         contributorsAboutText += QString("<i>%1</i><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
676
677         ui->contributorsLabel->setText(NOBREAK(contributorsAboutText));
678         ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
679         connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
680 }
681
682 void AboutDialog::initSoftwareTab(void)
683 {
684         QString moreAboutText;
685
686         moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
687         moreAboutText += "<ul style='margin-left:-25px'>"; //;font-size:7pt
688         
689         moreAboutText += makeToolText
690         (
691                 tr("LAME - OpenSource mp3 Encoder"),
692                 "lame.exe", "v?.???, #-?",
693                 tr("Released under the terms of the GNU Lesser General Public License."),
694                 "http://lame.sourceforge.net/"
695         );
696         moreAboutText += makeToolText
697         (
698                 tr("OggEnc - Vorbis Encoder"),
699                 "oggenc2.exe", "v?.??, libvorbis v?.?? + aoTuV b?.??_#",
700                 tr("Completely open and patent-free audio encoding technology."),
701                 "http://www.rarewares.org/ogg-oggenc.php"
702         );
703         moreAboutText += makeToolText
704         (
705                 tr("Nero AAC Reference MPEG-4 Encoder"),
706                 "neroAacEnc.exe", "v?.?.?.?",
707                 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
708                 neroAacUrl,
709                 tr("Available from vendor web-site as free download:")
710         );
711         moreAboutText += makeToolText
712         (
713                 tr("Aften - A/52 audio encoder"),
714                 "aften.exe", "v?.?.?",
715                 tr("Released under the terms of the GNU Lesser General Public License."),
716                 "http://aften.sourceforge.net/"
717         );
718         moreAboutText += makeToolText
719         (
720                 tr("FLAC - Free Lossless Audio Codec"),
721                 "flac.exe", "v?.?.?",
722                 tr("Open and patent-free lossless audio compression technology."),
723                 "http://flac.sourceforge.net/"
724         );
725         moreAboutText += makeToolText
726         (
727                 tr("Opus Audio Codec"),
728                 "opusenc.exe", "#, ????-??-??",
729                 tr("Totally open, royalty-free, highly versatile audio codec."),
730                 "http://www.opus-codec.org/"
731         );
732         moreAboutText += makeToolText
733         (
734                 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
735                 "mpg123.exe", "v?.??.??",
736                 tr("Released under the terms of the GNU Lesser General Public License."),
737                 "http://www.mpg123.de/"
738         );
739         moreAboutText += makeToolText
740         (
741                 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
742                 "faad.exe", "v?.?.?",
743                 tr("Released under the terms of the GNU General Public License."),
744                 "https://sourceforge.net/projects/faac/"        //"http://www.audiocoding.com/"
745         );
746         moreAboutText += makeToolText
747         (
748                 tr("OggDec - Vorbis Decoder"),
749                 "oggdec.exe", "v?.??.?",
750                 tr("Command line Ogg Vorbis decoder created by John33."),
751                 "http://www.rarewares.org/ogg-oggdec.php"
752         );
753         moreAboutText += makeToolText
754         (
755                 tr("Valdec from AC3Filter Tools - AC3/DTS Decoder"),
756                 "valdec.exe", "v?.??#",
757                 tr("Released under the terms of the GNU Lesser General Public License."),
758                 "http://www.ac3filter.net/projects/tools"
759         );
760         moreAboutText += makeToolText
761                 (
762                 tr("WavPack - Hybrid Lossless Compression"),
763                 "wvunpack.exe", "v?.??.?",
764                 tr("Completely open audio compression format."),
765                 "http://www.wavpack.com/"
766         );
767         moreAboutText += makeToolText
768                 (
769                 tr("Musepack - Living Audio Compression"),
770                 "mpcdec.exe", "r???",
771                 tr("Released under the terms of the GNU Lesser General Public License."),
772                 "http://www.musepack.net/"
773         );
774         moreAboutText += makeToolText
775         (
776                 tr("Monkey's Audio - Lossless Audio Compressor"),
777                 "mac.exe", "v?.??",
778                 tr("Freely available source code, simple SDK and non-restrictive licensing."),
779                 "http://www.monkeysaudio.com/"
780         );
781         moreAboutText += makeToolText
782         (
783                 tr("Shorten - Lossless Audio Compressor"),
784                 "shorten.exe", "v?.?.?",
785                 tr("Released under the terms of the GNU Lesser General Public License."),
786                 "http://etree.org/shnutils/shorten/"
787         );
788         moreAboutText += makeToolText
789         (
790                 tr("Speex - Free Codec For Free Speech"),
791                 "speexdec.exe", "v?.?",
792                 tr("Open Source patent-free audio format designed for speech."),
793                 "http://www.speex.org/"
794         );
795         moreAboutText += makeToolText
796         (
797                 tr("The True Audio - Lossless Audio Codec"),
798                 "tta.exe", "v?.?",
799                 tr("Released under the terms of the GNU Lesser General Public License."),
800                 "http://tta.sourceforge.net/"
801         );
802         moreAboutText += makeToolText
803         (
804                 tr("refalac - Win32 command line ALAC encoder/decoder"),
805                 "refalac.exe", "v?.??",
806                 tr("The ALAC reference implementation by Apple is available under the Apache license."),
807                 "http://alac.macosforge.org/"
808         );
809         moreAboutText += makeToolText
810         (
811                 tr("wma2wav - Dump WMA files to Wave Audio"),
812                 "wma2wav.exe", "????-??-??",
813                 tr("Copyright (c) 2011 LoRd_MuldeR &lt;mulder2@gmx.de&gt;. Some rights reserved."),
814                 "http://forum.doom9.org/showthread.php?t=140273"
815         );
816         moreAboutText += makeToolText
817         (
818                 tr("avs2wav - Avisynth to Wave Audio converter"),
819                 "avs2wav.exe", "v?.?",
820                 tr("By Jory Stone &lt;jcsston@toughguy.net&gt; and LoRd_MuldeR &lt;mulder2@gmx.de&gt;."),
821                 "http://forum.doom9.org/showthread.php?t=70882"
822         );
823         moreAboutText += makeToolText
824         (
825                 tr("dcaenc"),
826                 "dcaenc.exe", "????-??-??",
827                 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
828                 "https://gitlab.com/patrakov/dcaenc"
829         );
830         moreAboutText += makeToolText
831         (
832                 tr("MediaInfo - Media File Analysis Tool"),
833                 "mediainfo.exe", "v??.??.?",
834                 tr("Released under the terms of the GNU Lesser General Public License."),
835                 "http://mediainfo.sourceforge.net/"
836         );
837         moreAboutText += makeToolText
838         (
839                 tr("SoX - Sound eXchange"),
840                 "sox.exe", "v??.?.?",
841                 tr("Released under the terms of the GNU Lesser General Public License."),
842                 "http://sox.sourceforge.net/"
843         );
844         moreAboutText += makeToolText
845         (
846                 tr("GnuPG - The GNU Privacy Guard"),
847                 "gpgv.exe", "v?.?.??",
848                 tr("Released under the terms of the GNU Lesser General Public License."),
849                 "http://www.gnupg.org/"
850         );
851         moreAboutText += makeToolText
852         (
853                 tr("cURL - Curl URL Request Library"),
854                 "curl.exe", "v?.??.?",
855                 tr("By Daniel Stenberg, released under the terms of the MIT/X Derivate License."),
856                 "https://curl.haxx.se/"
857         );
858         moreAboutText += makeToolText
859         (
860                 tr("UPX - The Ultimate Packer for eXecutables"),
861                 QString(), "v3.09",
862                 tr("Released under the terms of the GNU Lesser General Public License."),
863                 "http://upx.sourceforge.net/"
864         );
865         moreAboutText += makeToolText
866         (
867                 tr("Silk Icons - Over 700 icons in PNG format"),
868                 QString(), "v1.3",
869                 tr("By Mark James, released under the Creative Commons 'BY' License."),
870                 "http://www.famfamfam.com/lab/icons/silk/"
871         );
872         moreAboutText += makeToolText
873         (
874                 tr("Angry Chicken and Ghost Scream sound"),
875                 QString(), "v1.0",
876                 tr("By Alexander, released under the Creative Commons 'BY' License."),
877                 "http://www.orangefreesounds.com/"
878         );
879         moreAboutText += QString("</ul><br><i>%1</i><br>").arg
880         (
881                 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.")
882         );
883
884         ui->softwareLabel->setText(NOBREAK(moreAboutText));
885         ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
886         connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
887 }
888
889 void AboutDialog::initLicenseTab(void)
890 {
891         int headerCount = 0;
892         QRegExp header("^(\\s*)((?:\\w+\\s+)?GNU GENERAL PUBLIC LICENSE(?:\\s+\\w+)?)(\\s*)$");
893
894         QString licenseText;
895         licenseText += ("<tt>");
896
897         QFile file(":/License.txt");
898         if(file.open(QIODevice::ReadOnly))
899         {
900                 QTextStream stream(&file);
901                 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
902                 {
903                         QString line = stream.readLine();
904                         line.replace('<', "&lt;").replace('>', "&gt;");
905                         if((headerCount < 2) && (header.indexIn(line) >= 0))
906                         {
907                                 line.replace(header, "\\1<b>\\2</b>\\3");
908                                 ++headerCount;
909                         }
910                         TRIM_RIGHT(line);
911                         licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
912                 }
913                 licenseText += QString("<br>");
914                 stream.device()->close();
915         }
916         else
917         {
918                 licenseText += QString("<font color=\"darkred\">Oups, failed to load license text. Please refer to:</font><br>");
919                 licenseText += LINK("http://www.gnu.org/licenses/gpl-2.0.html");
920         }
921
922         licenseText += ("</tt>");
923
924         ui->licenseLabel->setText(licenseText);
925         ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
926         connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
927 }
928
929 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
930 {
931         QString toolText, toolTag, verStr(toolVerFmt);
932
933         if(!toolBin.isEmpty())
934         {
935                 const unsigned int version = lamexp_tools_version(toolBin, &toolTag);
936                 verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), toolTag);
937         }
938
939         toolText += QString("<li>%1<br>").arg(QString("<b>%1 (%2)</b>").arg(toolName, verStr));
940         toolText += QString("%1<br>").arg(toolLicense);
941         if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(extraInfo);
942         toolText += LINK(toolWebsite);
943         toolText += QString("<font style=\"font-size:9px\"><br>&nbsp;</font>");
944
945         return toolText;
946 }