OSDN Git Service

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