OSDN Git Service

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