OSDN Git Service

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