OSDN Git Service

Some improvements to the deployment script.
[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@pku.edu.cn"    },
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         const QTime versionTime = MUtils::Version::app_build_time();
535
536         const QString versionStr = QString("Version %1 %2, Build %3 [%4] [%5]").arg
537         (
538                 QString().sprintf("%u.%02u", lamexp_version_major(), lamexp_version_minor()),
539                 QString::fromLatin1(lamexp_version_release()),
540                 QString::number(lamexp_version_build()),
541                 versionDate.toString(Qt::ISODate),
542                 versionTime.toString(Qt::ISODate)
543         );
544
545         const QString platformStr = QString("%1 [%2], MUtilities %3 [%4] [%5], Qt Framework v%6 [%7]").arg
546         (
547                 QString::fromLatin1(MUtils::Version::compiler_version()),
548                 QString::fromLatin1(MUtils::Version::compiler_arch()),
549                 QString().sprintf("%u.%02u", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor()),
550                 MUtils::Version::lib_build_date().toString(Qt::ISODate).toLatin1().constData(),
551                 MUtils::Version::lib_build_time().toString(Qt::ISODate).toLatin1().constData(),
552                 QString::fromLatin1(qVersion()),
553                 QString::fromLatin1(QT_PACKAGEDATE_STR)
554         );
555
556         const QString copyrightStr = QString().sprintf
557         (
558                 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
559                 qMax(versionDate.year(), MUtils::OS::current_date().year())
560         );
561
562         QString aboutText;
563
564         aboutText += QString("<h2>%1</h2>").arg(tr("LameXP - Audio Encoder Front-end"));
565         aboutText += QString("<b>%1</b><br>").arg(copyrightStr);
566         aboutText += QString("<b>%1</b><br>").arg(versionStr);
567         aboutText += QString("<b>%1</b><br><br>").arg(platformStr);
568         aboutText += QString("%1<br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
569
570 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
571         const QDate currentDate = MUtils::OS::current_date();
572         if(MUTILS_DEBUG)
573         {
574                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
575                 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)));
576         }
577         else if(lamexp_version_demo())
578         {
579                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
580                 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)));
581         }
582 #else
583         const QDate currentDate = lamexp_current_date_safe();
584         if(LAMEXP_DEBUG)
585         {
586                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
587                 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)));
588         }
589         else if(lamexp_version_demo())
590         {
591                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
592                 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)));
593         }
594 #endif
595
596         aboutText += "<hr><br>";
597         
598         aboutText += "<tt>This program is free software; you can redistribute it and/or modify<br>";
599         aboutText += "it under the terms of the GNU General Public License as published by<br>";
600         aboutText += "the Free Software Foundation; either version 2 of the License, or<br>";
601         aboutText += "(at your option) any later version, but always including the *additional*<br>";
602         aboutText += "restrictions defined in the \"License.txt\" file (see \"License\" tab).<br><br>";
603         aboutText += "This program is distributed in the hope that it will be useful,<br>";
604         aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
605         aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>";
606         aboutText += "GNU General Public License for more details.<br><br>";
607         aboutText += "You should have received a copy of the GNU General Public License<br>";
608         aboutText += "along with this program; if not, write to the Free Software<br>";
609         aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110&minus;1301, USA.</tt><br>";
610         aboutText += "<hr><table style=\"margin-top:4px\"><tr>";
611         aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
612         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 !!!"));
613         aboutText += "</tr></table>";
614
615         ui->infoLabel->setText(NOBREAK(aboutText));
616         ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
617         connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
618 }
619
620 void AboutDialog::initContributorsTab(void)
621 {
622         const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
623         const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
624         
625         QString contributorsAboutText;
626         contributorsAboutText += QString("<h3>%1</h3>").arg(tr("The following people have contributed to LameXP:"));
627         contributorsAboutText += "<table style=\"margin-top:12px;white-space:nowrap\">";
628         
629         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Programmers:"), extraVSpace);
630         QString icon = QString("<img src=\":/icons/%1.png\">").arg("user_gray");
631         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(icon, spaces);
632         contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(tr("Project Leader"), spaces);
633         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");
634         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
635
636         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Translators:"), extraVSpace);
637         for(int i = 0; g_lamexp_translators[i].pcName; i++)
638         {
639                 QString flagIcon = (strlen(g_lamexp_translators[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_translators[i].pcFlag) : QString();
640                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(flagIcon, spaces);
641                 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(MUTILS_QSTR(g_lamexp_translators[i].pcLanguage), spaces);
642                 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);
643         }
644
645         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
646         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Special thanks to:"), extraVSpace);
647
648         QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
649         for(int i = 0; g_lamexp_specialThanks[i].pcName; i++)
650         {
651                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
652                 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));
653         }
654
655         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
656         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Official Mirrors:"), extraVSpace);
657
658         QString serverIcon = QString("<img src=\":/icons/%1.png\">").arg("server_database");
659         for(int i = 0; g_lamexp_mirrors[i].pcName; i++)
660         {
661                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(serverIcon, spaces);
662                 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));
663         }
664
665         contributorsAboutText += "</table><br><br><br>";
666         contributorsAboutText += QString("<i>%1</i><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
667
668         ui->contributorsLabel->setText(NOBREAK(contributorsAboutText));
669         ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
670         connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
671 }
672
673 void AboutDialog::initSoftwareTab(void)
674 {
675         QString moreAboutText;
676
677         moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
678         moreAboutText += "<ul style='margin-left:-25px'>"; //;font-size:7pt
679         
680         moreAboutText += makeToolText
681         (
682                 tr("LAME - OpenSource mp3 Encoder"),
683                 "lame.exe", "v?.???, #-?",
684                 tr("Released under the terms of the GNU Lesser General Public License."),
685                 "http://lame.sourceforge.net/"
686         );
687         moreAboutText += makeToolText
688         (
689                 tr("OggEnc - Vorbis Encoder"),
690                 "oggenc2.exe", "v?.??, libvorbis v?.?? + aoTuV b?.??_#",
691                 tr("Completely open and patent-free audio encoding technology."),
692                 "http://www.rarewares.org/ogg-oggenc.php"
693         );
694         moreAboutText += makeToolText
695         (
696                 tr("Nero AAC Reference MPEG-4 Encoder"),
697                 "neroAacEnc.exe", "v?.?.?.?",
698                 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
699                 neroAacUrl,
700                 tr("Available from vendor web-site as free download:")
701         );
702         moreAboutText += makeToolText
703         (
704                 tr("Aften - A/52 audio encoder"),
705                 "aften.exe", "v?.?.?",
706                 tr("Released under the terms of the GNU Lesser General Public License."),
707                 "http://aften.sourceforge.net/"
708         );
709         moreAboutText += makeToolText
710         (
711                 tr("FLAC - Free Lossless Audio Codec"),
712                 "flac.exe", "v?.?.?",
713                 tr("Open and patent-free lossless audio compression technology."),
714                 "http://flac.sourceforge.net/"
715         );
716         moreAboutText += makeToolText
717         (
718                 tr("Opus Audio Codec"),
719                 "opusenc.exe", "#, ????-??-??",
720                 tr("Totally open, royalty-free, highly versatile audio codec."),
721                 "http://www.opus-codec.org/"
722         );
723         moreAboutText += makeToolText
724         (
725                 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
726                 "mpg123.exe", "v?.??.??",
727                 tr("Released under the terms of the GNU Lesser General Public License."),
728                 "http://www.mpg123.de/"
729         );
730         moreAboutText += makeToolText
731         (
732                 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
733                 "faad.exe", "v?.?.?",
734                 tr("Released under the terms of the GNU General Public License."),
735                 "https://sourceforge.net/projects/faac/"        //"http://www.audiocoding.com/"
736         );
737         moreAboutText += makeToolText
738         (
739                 tr("OggDec - Vorbis Decoder"),
740                 "oggdec.exe", "v?.??.?",
741                 tr("Command line Ogg Vorbis decoder created by John33."),
742                 "http://www.rarewares.org/ogg-oggdec.php"
743         );
744         moreAboutText += makeToolText
745         (
746                 tr("Valdec from AC3Filter Tools - AC3/DTS Decoder"),
747                 "valdec.exe", "v?.??#",
748                 tr("Released under the terms of the GNU Lesser General Public License."),
749                 "http://www.ac3filter.net/projects/tools"
750         );
751         moreAboutText += makeToolText
752                 (
753                 tr("WavPack - Hybrid Lossless Compression"),
754                 "wvunpack.exe", "v?.??.?",
755                 tr("Completely open audio compression format."),
756                 "http://www.wavpack.com/"
757         );
758         moreAboutText += makeToolText
759                 (
760                 tr("Musepack - Living Audio Compression"),
761                 "mpcdec.exe", "r???",
762                 tr("Released under the terms of the GNU Lesser General Public License."),
763                 "http://www.musepack.net/"
764         );
765         moreAboutText += makeToolText
766         (
767                 tr("Monkey's Audio - Lossless Audio Compressor"),
768                 "mac.exe", "v?.??",
769                 tr("Freely available source code, simple SDK and non-restrictive licensing."),
770                 "http://www.monkeysaudio.com/"
771         );
772         moreAboutText += makeToolText
773         (
774                 tr("Shorten - Lossless Audio Compressor"),
775                 "shorten.exe", "v?.?.?",
776                 tr("Released under the terms of the GNU Lesser General Public License."),
777                 "http://etree.org/shnutils/shorten/"
778         );
779         moreAboutText += makeToolText
780         (
781                 tr("Speex - Free Codec For Free Speech"),
782                 "speexdec.exe", "v?.?",
783                 tr("Open Source patent-free audio format designed for speech."),
784                 "http://www.speex.org/"
785         );
786         moreAboutText += makeToolText
787         (
788                 tr("The True Audio - Lossless Audio Codec"),
789                 "tta.exe", "v?.?",
790                 tr("Released under the terms of the GNU Lesser General Public License."),
791                 "http://tta.sourceforge.net/"
792         );
793         moreAboutText += makeToolText
794         (
795                 tr("refalac - Win32 command line ALAC encoder/decoder"),
796                 "refalac.exe", "v?.??",
797                 tr("The ALAC reference implementation by Apple is available under the Apache license."),
798                 "http://alac.macosforge.org/"
799         );
800         moreAboutText += makeToolText
801         (
802                 tr("wma2wav - Dump WMA files to Wave Audio"),
803                 "wma2wav.exe", "????-??-??",
804                 tr("Copyright (c) 2011 LoRd_MuldeR &lt;mulder2@gmx.de&gt;. Some rights reserved."),
805                 "http://forum.doom9.org/showthread.php?t=140273"
806         );
807         moreAboutText += makeToolText
808         (
809                 tr("avs2wav - Avisynth to Wave Audio converter"),
810                 "avs2wav.exe", "v?.?",
811                 tr("By Jory Stone &lt;jcsston@toughguy.net&gt; and LoRd_MuldeR &lt;mulder2@gmx.de&gt;."),
812                 "http://forum.doom9.org/showthread.php?t=70882"
813         );
814         moreAboutText += makeToolText
815         (
816                 tr("dcaenc"),
817                 "dcaenc.exe", "????-??-??",
818                 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
819                 "https://gitlab.com/patrakov/dcaenc"
820         );
821         moreAboutText += makeToolText
822         (
823                 tr("MediaInfo - Media File Analysis Tool"),
824                 "mediainfo.exe", "v??.??.?",
825                 tr("Released under the terms of the GNU Lesser General Public License."),
826                 "http://mediainfo.sourceforge.net/"
827         );
828         moreAboutText += makeToolText
829         (
830                 tr("SoX - Sound eXchange"),
831                 "sox.exe", "v??.?.?",
832                 tr("Released under the terms of the GNU Lesser General Public License."),
833                 "http://sox.sourceforge.net/"
834         );
835         moreAboutText += makeToolText
836         (
837                 tr("GnuPG - The GNU Privacy Guard"),
838                 "gpgv.exe", "v?.?.??",
839                 tr("Released under the terms of the GNU Lesser General Public License."),
840                 "http://www.gnupg.org/"
841         );
842         moreAboutText += makeToolText
843         (
844                 tr("GNU Wget - Software for retrieving files using HTTP"),
845                 "wget.exe", "v?.??.?",
846                 tr("Released under the terms of the GNU Lesser General Public License."),
847                 "http://www.gnu.org/software/wget/"
848         );
849         moreAboutText += makeToolText
850         (
851                 tr("UPX - The Ultimate Packer for eXecutables"),
852                 QString(), "v3.09",
853                 tr("Released under the terms of the GNU Lesser General Public License."),
854                 "http://upx.sourceforge.net/"
855         );
856         moreAboutText += makeToolText
857         (
858                 tr("Silk Icons - Over 700 icons in PNG format"),
859                 QString(), "v1.3",
860                 tr("By Mark James, released under the Creative Commons 'BY' License."),
861                 "http://www.famfamfam.com/lab/icons/silk/"
862         );
863         moreAboutText += makeToolText
864         (
865                 tr("Angry Chicken and Ghost Scream sound"),
866                 QString(), "v1.0",
867                 tr("By Alexander, released under the Creative Commons 'BY' License."),
868                 "http://www.orangefreesounds.com/"
869         );
870         moreAboutText += QString("</ul><br><i>%1</i><br>").arg
871         (
872                 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.")
873         );
874
875         ui->softwareLabel->setText(NOBREAK(moreAboutText));
876         ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
877         connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
878 }
879
880 void AboutDialog::initLicenseTab(void)
881 {
882         bool bFoundHeader = false;
883         QRegExp header("^(\\s*)(GNU GENERAL PUBLIC LICENSE)(\\s*)$");
884
885         QString licenseText;
886         licenseText += ("<tt>");
887
888         QFile file(":/License.txt");
889         if(file.open(QIODevice::ReadOnly))
890         {
891                 QTextStream stream(&file);
892                 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
893                 {
894                         QString line = stream.readLine();
895                         line.replace('<', "&lt;").replace('>', "&gt;");
896                         if((!bFoundHeader) && (header.indexIn(line) >= 0))
897                         {
898                                 line.replace(header, "\\1<b>\\2</b>\\3");
899                                 bFoundHeader = true;
900                         }
901                         TRIM_RIGHT(line);
902                         licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
903                 }
904                 licenseText += QString("<br>");
905                 stream.device()->close();
906         }
907         else
908         {
909                 licenseText += QString("<font color=\"darkred\">Oups, failed to load license text. Please refer to:</font><br>");
910                 licenseText += LINK("http://www.gnu.org/licenses/gpl-2.0.html");
911         }
912
913         licenseText += ("</tt>");
914
915         ui->licenseLabel->setText(licenseText);
916         ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
917         connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
918 }
919
920 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
921 {
922         QString toolText, toolTag, verStr(toolVerFmt);
923
924         if(!toolBin.isEmpty())
925         {
926                 const unsigned int version = lamexp_tools_version(toolBin, &toolTag);
927                 verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), toolTag);
928         }
929
930         toolText += QString("<li>%1<br>").arg(QString("<b>%1 (%2)</b>").arg(toolName, verStr));
931         toolText += QString("%1<br>").arg(toolLicense);
932         if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(extraInfo);
933         toolText += LINK(toolWebsite);
934         toolText += QString("<font style=\"font-size:9px\"><br>&nbsp;</font>");
935
936         return toolText;
937 }