OSDN Git Service

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