OSDN Git Service

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