OSDN Git Service

Happy new year 2018!
[lamexp/LameXP.git] / src / Dialog_About.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2018 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 <QWindowsVistaStyle>
56 #include <QWindowsXPStyle>
57
58 //CRT
59 #include <math.h>
60
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)
65
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
69
70 //Contributors
71 static const struct 
72 {
73         char *pcFlag;
74         wchar_t *pcLanguage;
75         wchar_t *pcName;
76         char *pcMail;
77 }
78 g_lamexp_translators[] =
79 {
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}
99 };
100
101 //Special Thanks
102 static const struct
103 {
104         char* pcName;
105         char *pcAddress;
106 }
107 g_lamexp_specialThanks[] =
108 {
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 }
120 };
121
122 //Mirrors
123 static const struct
124 {
125         char* pcName;
126         char *pcAddress;
127 }
128 g_lamexp_mirrors[] =
129 {
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 }
137 };
138
139 ////////////////////////////////////////////////////////////
140 // Constructor
141 ////////////////////////////////////////////////////////////
142
143 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
144 :
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)
154 {
155         //Init the dialog, from the .ui file
156         ui->setupUi(this);
157         setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
158         setMinimumSize(this->size());
159
160         //Adjust size to DPI settings and re-center
161         MUtils::GUI::scale_widget(this);
162
163         //Disable "X" button
164         if(firstStart)
165         {
166                 MUtils::GUI::enable_close_button(this, false);
167         }
168
169         //Init tab widget
170         connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
171
172         //Make transparent
173         const type_info &styleType = typeid(*qApp->style());
174         if((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType))
175         {
176                 MAKE_TRANSPARENT(ui->infoScrollArea);
177                 MAKE_TRANSPARENT(ui->contributorsScrollArea);
178                 MAKE_TRANSPARENT(ui->softwareScrollArea);
179                 MAKE_TRANSPARENT(ui->licenseScrollArea);
180         }
181
182         //Show about dialog for the first time?
183         if(!firstStart)
184         {
185                 ui->acceptButton->hide();
186                 ui->declineButton->hide();
187                 ui->aboutQtButton->show();
188                 ui->closeButton->show();
189
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);
198
199                 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(geometryUpdated()));
200                 geometryUpdated();
201
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);
209
210                 m_disqueTimer.reset(new QTimer());
211
212                 connect(m_disqueTimer.data(), SIGNAL(timeout()), this, SLOT(moveDisque()));
213                 connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
214         }
215         else
216         {
217                 ui->acceptButton->show();
218                 ui->declineButton->show();
219                 ui->aboutQtButton->hide();
220                 ui->closeButton->hide();
221         }
222
223         //Activate "show license" button
224         ui->showLicenseButton->show();
225         connect(ui->showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
226 }
227
228 AboutDialog::~AboutDialog(void)
229 {
230         if(m_disque)
231         {
232                 m_disque->close();
233         }
234         if(m_disqueTimer)
235         {
236                 m_disqueTimer->stop();
237         }
238         MUTILS_DELETE(ui);
239 }
240
241 ////////////////////////////////////////////////////////////
242 // Public Functions
243 ////////////////////////////////////////////////////////////
244
245 int AboutDialog::exec()
246 {
247         if(m_settings->soundsEnabled())
248         {
249                 if(m_firstStart)
250                 {
251                         if(!MUtils::Sound::play_sound_file("imageres.dll", 5080, true))
252                         {
253                                 MUtils::Sound::play_system_sound("SystemStart", true);
254                         }
255                 }
256                 else
257                 {
258                         MUtils::Sound::play_sound("ghost", true);
259                 }
260         }
261         
262         switch(QDialog::exec())
263         {
264         case 1:
265                 return 1;
266                 break;
267         case 2:
268                 return -1;
269                 break;
270         default:
271                 return 0;
272                 break;
273         }
274 }
275
276 ////////////////////////////////////////////////////////////
277 // Slots
278 ////////////////////////////////////////////////////////////
279
280 #define TEMP_HIDE_DISQUE(CMD) do \
281 { \
282         bool _tmp = (m_disque) ? m_disque->isVisible() : false; \
283         if(_tmp) m_disque->hide(); \
284         { CMD } \
285         if(_tmp) \
286         { \
287                 m_discOpacity = 0.01; \
288                 m_disque->setWindowOpacity(m_discOpacity); \
289                 m_disque->show(); \
290         } \
291 } \
292 while(0)
293
294 void AboutDialog::tabChanged(int index, const bool silent)
295 {
296         bool bInitialized = m_initFlags->value(ui->tabWidget->widget(index), false);
297
298         if(!bInitialized)
299         {
300                 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
301
302                 if(QWidget *tab = ui->tabWidget->widget(index))
303                 {
304                         bool ok = false;
305
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; }
310
311                         if(ok)
312                         {
313                                 m_initFlags->insert(tab, true);
314                         }
315                         else
316                         {
317                                 qWarning("Unknown tab %p encountered, cannot initialize !!!", tab);
318                         }
319                         
320                 }
321
322                 ui->tabWidget->widget(index)->update();
323                 qApp->processEvents();
324                 qApp->restoreOverrideCursor();
325         }
326
327         //Play tick sound
328         if(m_settings->soundsEnabled() && (!silent))
329         {
330                 MUtils::Sound::play_sound("tick", true);
331         }
332
333         //Scroll to the top
334         if(QWidget *tab = ui->tabWidget->widget(index))
335         {
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);
340         }
341
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;
345 }
346
347 void AboutDialog::enableButtons(void)
348 {
349         ui->acceptButton->setEnabled(true);
350         ui->declineButton->setEnabled(true);
351         setCursor(QCursor(Qt::ArrowCursor));
352 }
353
354 void AboutDialog::openURL(const QString &url)
355 {
356         if(!QDesktopServices::openUrl(QUrl(url)))
357         {
358                 MUtils::OS::shell_open(this, url);
359         }
360 }
361
362 void AboutDialog::showAboutQt(void)
363 {
364         TEMP_HIDE_DISQUE
365         (
366                 QMessageBox::aboutQt(this);
367         );
368 }
369
370 void AboutDialog::gotoLicenseTab(void)
371 {
372         ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->showLicenseButton->isChecked() ? ui->licenseTab : ui->tabWidget->widget(m_lastTab)));
373 }
374
375 void AboutDialog::moveDisque(void)
376 {
377         int delta = 2;
378         QElapsedTimer elapsedTimer;
379         elapsedTimer.start();
380
381         if((!m_disqueDelay.isNull()) && m_disqueDelay->isValid())
382         {
383                 const qint64 delay = m_disqueDelay->restart();
384                 delta = qBound(1, static_cast<int>(ceil(static_cast<double>(delay) / 5.12)), 128);
385         }
386         else
387         {
388                 m_disqueDelay.reset(new QElapsedTimer());
389                 m_disqueDelay->start();
390         }
391
392         if(m_disque)
393         {
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; }
398                 
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));
401
402                 m_disque->move(m_disquePos);
403                 
404                 if(m_rotateNext)
405                 {
406                         const QPixmap *const cartoon = m_cartoon[m_disqueFlags[0] ? (m_disqueFlags[1] ? 1 : 0): (m_disqueFlags[1] ? 2 : 3)].data();
407                         if(cartoon)
408                         {
409                                 m_disque->setPixmap(*cartoon);
410                                 if(m_disque->size() != cartoon->size())
411                                 {
412                                         m_disque->resize(cartoon->size());
413                                         geometryUpdated();
414                                 }
415                         }
416                         m_rotateNext = false;
417                 }
418
419                 if(m_discOpacity != 1.0)
420                 {
421                         m_discOpacity = m_discOpacity + 0.01;
422                         if(qFuzzyCompare(m_discOpacity, 1.0) || (m_discOpacity > 1.0))
423                         {
424                                 m_discOpacity = 1.0;
425                         }
426                         m_disque->setWindowOpacity(m_discOpacity);
427                         m_disque->update();
428                 }
429         }
430 }
431
432 void AboutDialog::geometryUpdated(void)
433 {
434         if(m_disque)
435         {
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());
441         }
442         else
443         {
444                 m_disqueBound = QApplication::desktop()->availableGeometry();
445         }
446 }
447
448 void AboutDialog::adjustSize(void)
449 {
450         const int maxH = QApplication::desktop()->availableGeometry().height();
451         const int maxW = QApplication::desktop()->availableGeometry().width();
452
453         const int deltaH = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
454         const int deltaW = ui->infoScrollArea->widget()->width()  - ui->infoScrollArea->viewport()->width();
455
456         if(deltaH > 0)
457         {
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()));
461         }
462
463         if(deltaW > 0)
464         {
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()));
468         }
469 }
470
471 ////////////////////////////////////////////////////////////
472 // Protected Functions
473 ////////////////////////////////////////////////////////////
474
475 void AboutDialog::showEvent(QShowEvent *e)
476 {
477         QDialog::showEvent(e);
478         
479         ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
480         tabChanged(m_lastTab = ui->tabWidget->currentIndex(), true);
481         
482         if(m_firstStart)
483         {
484                 ui->acceptButton->setEnabled(false);
485                 ui->declineButton->setEnabled(false);
486                 QTimer::singleShot(5000, this, SLOT(enableButtons()));
487                 setCursor(QCursor(Qt::WaitCursor));
488         }
489
490         if (!(m_disque.isNull() || m_disqueTimer.isNull()))
491         {
492                 m_disque->show();
493                 m_disqueTimer->start(10);
494         }
495
496         QTimer::singleShot(0, this, SLOT(adjustSize()));
497 }
498
499 void AboutDialog::closeEvent(QCloseEvent *e)
500 {
501         if (m_firstStart)
502         {
503                 e->ignore();
504         }
505 }
506
507 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
508 {
509         if((!m_disque.isNull()) && (obj == m_disque.data()) && (event->type() == QEvent::MouseButtonPress))
510         {
511                 MUtils::Sound::play_sound("chicken", true);
512                 if (!m_cartoon[0])
513                 {
514                         QPixmap cartoon(":/images/Cartoon.png");
515                         for(int i = 0; i < 4; i++)
516                         {
517                                 m_cartoon[i].reset(new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation)));
518                                 m_rotateNext = true;
519                         }
520                 }
521                 QDesktopServices::openUrl(QUrl(disqueUrl));
522         }
523
524         return false;
525 }
526
527 ////////////////////////////////////////////////////////////
528 // Private Functions
529 ////////////////////////////////////////////////////////////
530
531 void AboutDialog::initInformationTab(void)
532 {
533         const QDate versionDate = MUtils::Version::app_build_date();
534
535         const QString versionStr = QString().sprintf
536         (
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()
546         );
547
548         const QString copyrightStr = QString().sprintf
549         (
550                 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
551                 qMax(versionDate.year(), MUtils::OS::current_date().year())
552         );
553
554         QString aboutText;
555
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()))));
560
561 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
562         const QDate currentDate = MUtils::OS::current_date();
563         if(MUTILS_DEBUG)
564         {
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))));
567         }
568         else if(lamexp_version_demo())
569         {
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))));
572         }
573 #else
574         const QDate currentDate = lamexp_current_date_safe();
575         if(LAMEXP_DEBUG)
576         {
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))));
579         }
580         else if(lamexp_version_demo())
581         {
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))));
584         }
585 #endif
586
587         aboutText += "<hr><br>";
588         
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>";
605
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)));
609 }
610
611 void AboutDialog::initContributorsTab(void)
612 {
613         const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
614         const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
615         
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\">";
619         
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>");
626
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++)
629         {
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);
634         }
635
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);
638
639         QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
640         for(int i = 0; g_lamexp_specialThanks[i].pcName; i++)
641         {
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));
644         }
645
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);
648
649         QString serverIcon = QString("<img src=\":/icons/%1.png\">").arg("server_database");
650         for(int i = 0; g_lamexp_mirrors[i].pcName; i++)
651         {
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));
654         }
655
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!")));
658
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)));
662 }
663
664 void AboutDialog::initSoftwareTab(void)
665 {
666         QString moreAboutText;
667
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
670         
671         moreAboutText += makeToolText
672         (
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/"
677         );
678         moreAboutText += makeToolText
679         (
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"
684         );
685         moreAboutText += makeToolText
686         (
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:")
692         );
693         moreAboutText += makeToolText
694         (
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/"
699         );
700         moreAboutText += makeToolText
701         (
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/"
706         );
707         moreAboutText += makeToolText
708         (
709                 tr("Opus Audio Codec"),
710                 "opusenc.exe", "#, ????-??-??",
711                 tr("Totally open, royalty-free, highly versatile audio codec."),
712                 "http://www.opus-codec.org/"
713         );
714         moreAboutText += makeToolText
715         (
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/"
720         );
721         moreAboutText += makeToolText
722         (
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                 "https://sourceforge.net/projects/faac/"        //"http://www.audiocoding.com/"
727         );
728         moreAboutText += makeToolText
729         (
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"
734         );
735         moreAboutText += makeToolText
736         (
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"
741         );
742         moreAboutText += makeToolText
743                 (
744                 tr("WavPack - Hybrid Lossless Compression"),
745                 "wvunpack.exe", "v?.??.?",
746                 tr("Completely open audio compression format."),
747                 "http://www.wavpack.com/"
748         );
749         moreAboutText += makeToolText
750                 (
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/"
755         );
756         moreAboutText += makeToolText
757         (
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/"
762         );
763         moreAboutText += makeToolText
764         (
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/"
769         );
770         moreAboutText += makeToolText
771         (
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/"
776         );
777         moreAboutText += makeToolText
778         (
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/"
783         );
784         moreAboutText += makeToolText
785         (
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/"
790         );
791         moreAboutText += makeToolText
792         (
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"
797         );
798         moreAboutText += makeToolText
799         (
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"
804         );
805         moreAboutText += makeToolText
806         (
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"
811         );
812         moreAboutText += makeToolText
813         (
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/"
818         );
819         moreAboutText += makeToolText
820         (
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/"
825         );
826         moreAboutText += makeToolText
827         (
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/"
832         );
833         moreAboutText += makeToolText
834         (
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/"
839         );
840         moreAboutText += makeToolText
841         (
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/"
846         );
847         moreAboutText += makeToolText
848         (
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/"
853         );
854         moreAboutText += makeToolText
855         (
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/"
860         );
861         moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><br><i>%1</i><br>").arg
862         (
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.")
864         );
865
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)));
869 }
870
871 void AboutDialog::initLicenseTab(void)
872 {
873         bool bFoundHeader = false;
874         QRegExp header("^(\\s*)(GNU GENERAL PUBLIC LICENSE)(\\s*)$");
875
876         QString licenseText;
877         licenseText += ("<tt>");
878
879         QFile file(":/License.txt");
880         if(file.open(QIODevice::ReadOnly))
881         {
882                 QTextStream stream(&file);
883                 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
884                 {
885                         QString line = stream.readLine();
886                         line.replace('<', "&lt;").replace('>', "&gt;");
887                         if((!bFoundHeader) && (header.indexIn(line) >= 0))
888                         {
889                                 line.replace(header, "\\1<b>\\2</b>\\3");
890                                 bFoundHeader = true;
891                         }
892                         TRIM_RIGHT(line);
893                         licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
894                 }
895                 licenseText += QString("<br>");
896                 stream.device()->close();
897         }
898         else
899         {
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");
902         }
903
904         licenseText += ("</tt>");
905
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)));
909 }
910
911
912 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
913 {
914         QString toolText, toolTag, verStr(toolVerFmt);
915
916         if(!toolBin.isEmpty())
917         {
918                 const unsigned int version = lamexp_tools_version(toolBin, &toolTag);
919                 verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), toolTag);
920         }
921
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>");
927
928         return toolText;
929 }