OSDN Git Service

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