OSDN Git Service

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