OSDN Git Service

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