OSDN Git Service

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