OSDN Git Service

Now each tool can also have a "tag" in addition to the version number.
[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
58 //Constants
59 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
60 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
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                 QPoint pos = m_disque->pos();
343                 pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta);
344                 pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta);
345
346                 if(pos.x() <= minX)
347                 {
348                         m_disqueFlags[0] = true;
349                         pos.setX(minX);
350                         m_rotateNext = true;
351                 }
352                 else if(pos.x() >= maxX)
353                 {
354                         m_disqueFlags[0] = false;
355                         pos.setX(maxX);
356                         m_rotateNext = true;
357                 }
358                 if(pos.y() <= minY)
359                 {
360                         m_disqueFlags[1] = true;
361                         pos.setY(minY);
362                         m_rotateNext = true;
363                 }
364                 else if(pos.y() >= maxY)
365                 {
366                         m_disqueFlags[1] = false;
367                         pos.setY(maxY);
368                         m_rotateNext = true;
369                 }
370
371                 m_disque->move(pos);
372
373                 if(m_rotateNext)
374                 {
375                         QPixmap *cartoon = NULL;
376                         if(m_disqueFlags[0] == true && m_disqueFlags[1] != true) cartoon = m_cartoon[0];
377                         if(m_disqueFlags[0] == true && m_disqueFlags[1] == true) cartoon = m_cartoon[1];
378                         if(m_disqueFlags[0] != true && m_disqueFlags[1] == true) cartoon = m_cartoon[2];
379                         if(m_disqueFlags[0] != true && m_disqueFlags[1] != true) cartoon = m_cartoon[3];
380                         if(cartoon)
381                         {
382                                 m_disque->setPixmap(*cartoon);
383                                 m_disque->resize(cartoon->size());
384                         }
385                         m_rotateNext = false;
386                 }
387
388                 if(m_disque->windowOpacity() < 0.9)
389                 {
390                         m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
391                 }
392         }
393 }
394
395 void AboutDialog::adjustSize(void)
396 {
397         int maximumHeight = QApplication::desktop()->availableGeometry().height();
398
399         int delta = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
400         if(delta > 0)
401         {
402                 this->resize(this->width(), qMin(this->height() + delta, maximumHeight));
403                 this->move(this->x(), this->y() - (delta/2));
404                 this->setMinimumHeight(qMax(this->minimumHeight(), this->height()));
405         }
406 }
407
408 ////////////////////////////////////////////////////////////
409 // Protected Functions
410 ////////////////////////////////////////////////////////////
411
412 void AboutDialog::showEvent(QShowEvent *e)
413 {
414         QDialog::showEvent(e);
415         
416         ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
417         tabChanged(m_lastTab = ui->tabWidget->currentIndex());
418         
419         if(m_firstShow)
420         {
421                 ui->acceptButton->setEnabled(false);
422                 ui->declineButton->setEnabled(false);
423                 QTimer::singleShot(5000, this, SLOT(enableButtons()));
424                 setCursor(QCursor(Qt::WaitCursor));
425         }
426
427         QTimer::singleShot(0, this, SLOT(adjustSize()));
428 }
429
430 void AboutDialog::closeEvent(QCloseEvent *e)
431 {
432         if(m_firstShow) e->ignore();
433 }
434
435 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
436 {
437         if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
438         {
439                 QPixmap cartoon(":/images/Cartoon.png");
440                 for(int i = 0; i < 4; i++)
441                 {
442                         if(!m_cartoon[i])
443                         {
444                                 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
445                                 m_rotateNext = true;
446                         }
447                 }
448                 QDesktopServices::openUrl(QUrl(disqueUrl));
449         }
450
451         return false;
452 }
453
454 ////////////////////////////////////////////////////////////
455 // Private Functions
456 ////////////////////////////////////////////////////////////
457
458 void AboutDialog::initInformationTab(void)
459 {
460         const QString versionStr = QString().sprintf
461         (
462                 "Version %d.%02d %s, Build %d [%s], %s %s, Qt v%s",
463                 lamexp_version_major(),
464                 lamexp_version_minor(),
465                 lamexp_version_release(),
466                 lamexp_version_build(),
467                 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
468                 lamexp_version_compiler(),
469                 lamexp_version_arch(),
470                 qVersion()
471         );
472
473         const QString copyrightStr = QString().sprintf
474         (
475                 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
476                 qMax(lamexp_version_date().year(), lamexp_current_date_safe().year())
477         );
478
479         QString aboutText;
480
481         aboutText += QString("<h2>%1</h2>").arg(NOBR(tr("LameXP - Audio Encoder Front-end")));
482         aboutText += QString("<b>%1</b><br>").arg(NOBR(copyrightStr));
483         aboutText += QString("<b>%1</b><br><br>").arg(NOBR(versionStr));
484         aboutText += QString("%1<br>").arg(NOBR(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url()))));
485
486 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
487         const QDate currentDate = lamexp_current_date_safe();
488         if(LAMEXP_DEBUG)
489         {
490                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
491                 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))));
492         }
493         else if(lamexp_version_demo())
494         {
495                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0);
496                 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))));
497         }
498 #else
499         const QDate currentDate = lamexp_current_date_safe();
500         if(LAMEXP_DEBUG)
501         {
502                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
503                 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))));
504         }
505         else if(lamexp_version_demo())
506         {
507                 int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0i64);
508                 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))));
509         }
510 #endif
511
512         aboutText += "<hr><br>";
513         aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
514         aboutText += "modify it under the terms of the GNU General Public License<br>";
515         aboutText += "as published by the Free Software Foundation; either version 2<br>";
516         aboutText += "of the License, or (at your option) any later version.<br><br>";
517         aboutText += "This program is distributed in the hope that it will be useful,<br>";
518         aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
519         aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>";
520         aboutText += "GNU General Public License for more details.<br><br>";
521         aboutText += "You should have received a copy of the GNU General Public License<br>";
522         aboutText += "along with this program; if not, write to the Free Software<br>";
523         aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110&minus;1301, USA.</tt></nobr><br>";
524         aboutText += "<hr><table style=\"margin-top:4px\"><tr>";
525         aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
526         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 !!!"));
527         aboutText += "</tr></table>";
528         //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/")));
529
530         ui->infoLabel->setText(aboutText);
531         ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
532         connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
533 }
534
535 void AboutDialog::initContributorsTab(void)
536 {
537         const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
538         const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
539         
540         QString contributorsAboutText;
541         contributorsAboutText += QString("<h3>%1</h3>").arg(NOBR(tr("The following people have contributed to LameXP:")));
542         contributorsAboutText += "<table style=\"margin-top:12px;white-space:nowrap\">";
543         
544         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Programmers:"), extraVSpace);
545         QString icon = QString("<img src=\":/icons/%1.png\">").arg("user_gray");
546         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(icon, spaces);
547         contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(tr("Project Leader"), spaces);
548         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");
549         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
550
551         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Translators:"), extraVSpace);
552         for(int i = 0; g_lamexp_translators[i].pcName; i++)
553         {
554                 QString flagIcon = (strlen(g_lamexp_translators[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_translators[i].pcFlag) : QString();
555                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(flagIcon, spaces);
556                 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(WCHAR2QSTR(g_lamexp_translators[i].pcLanguage), spaces);
557                 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);
558         }
559
560         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
561         contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Special thanks to:"), extraVSpace);
562
563         QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
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("Doom9's Forum"), spaces, "http://forum.doom9.org/");
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("Gleitz | German Doom9"), spaces, "http://forum.gleitz.info/");
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("Hydrogenaudio Forums"), spaces, "http://www.hydrogenaudio.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("RareWares"), spaces, "http://www.rarewares.org/");
572         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
573         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/");
574         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
575         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/");
576         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
577         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/");
578         contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
579         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/");
580
581         contributorsAboutText += "</table><br><br><br>";
582         contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
583
584         ui->contributorsLabel->setText(contributorsAboutText);
585         ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
586         connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
587 }
588
589 void AboutDialog::initSoftwareTab(void)
590 {
591         QString moreAboutText;
592
593         moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
594         moreAboutText += "<div style=\"margin-left:-25px;white-space:nowrap\"><table><tr><td><ul>"; //;font-size:7pt
595         
596         moreAboutText += makeToolText
597         (
598                 tr("LAME - OpenSource mp3 Encoder"),
599                 "lame.exe", "v?.??, #-?",
600                 tr("Released under the terms of the GNU Lesser General Public License."),
601                 "http://lame.sourceforge.net/"
602         );
603         moreAboutText += makeToolText
604         (
605                 tr("OggEnc - Ogg Vorbis Encoder"),
606                 "oggenc2.exe", "v?.??, aoTuV #-?.??",
607                 tr("Completely open and patent-free audio encoding technology."),
608                 "http://www.vorbis.com/"
609         );
610         moreAboutText += makeToolText
611         (
612                 tr("Nero AAC Reference MPEG-4 Encoder"),
613                 "neroAacEnc.exe", "v?.?.?.?",
614                 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
615                 neroAacUrl,
616                 tr("Available from vendor web-site as free download:")
617         );
618         moreAboutText += makeToolText
619         (
620                 tr("Aften - A/52 audio encoder"),
621                 "aften.exe", "v?.?.?",
622                 tr("Released under the terms of the GNU Lesser General Public License."),
623                 "http://aften.sourceforge.net/"
624         );
625         moreAboutText += makeToolText
626         (
627                 tr("FLAC - Free Lossless Audio Codec"),
628                 "flac.exe", "v?.?.?",
629                 tr("Open and patent-free lossless audio compression technology."),
630                 "http://flac.sourceforge.net/"
631         );
632         moreAboutText += makeToolText
633         (
634                 tr("Opus Audio Codec"),
635                 "opusenc.exe", "????-??-??",
636                 tr("Totally open, royalty-free, highly versatile audio codec."),
637                 "http://www.opus-codec.org/"
638         );
639         moreAboutText += makeToolText
640         (
641                 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
642                 "mpg123.exe", "v?.??.?",
643                 tr("Released under the terms of the GNU Lesser General Public License."),
644                 "http://www.mpg123.de/"
645         );
646         moreAboutText += makeToolText
647         (
648                 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
649                 "faad.exe", "v?.?",
650                 tr("Released under the terms of the GNU General Public License."),
651                 "http://www.audiocoding.com/"
652         );
653         moreAboutText += makeToolText
654         (
655                 tr("Valdec from AC3Filter Tools - AC3/DTS Decoder"),
656                 "valdec.exe", "v?.?.?#",
657                 tr("Released under the terms of the GNU Lesser General Public License."),
658                 "http://www.ac3filter.net/projects/tools"
659         );
660         moreAboutText += makeToolText
661                 (
662                 tr("WavPack - Hybrid Lossless Compression"),
663                 "wvunpack.exe", "v?.??.?",
664                 tr("Completely open audio compression format."),
665                 "http://www.wavpack.com/"
666         );
667         moreAboutText += makeToolText
668                 (
669                 tr("Musepack - Living Audio Compression"),
670                 "mpcdec.exe", "r???",
671                 tr("Released under the terms of the GNU Lesser General Public License."),
672                 "http://www.musepack.net/"
673         );
674         moreAboutText += makeToolText
675         (
676                 tr("Monkey's Audio - Lossless Audio Compressor"),
677                 "mac.exe", "v?.??",
678                 tr("Freely available source code, simple SDK and non-restrictive licensing."),
679                 "http://www.monkeysaudio.com/"
680         );
681         moreAboutText += makeToolText
682         (
683                 tr("Shorten - Lossless Audio Compressor"),
684                 "shorten.exe", "v?.?.?",
685                 tr("Released under the terms of the GNU Lesser General Public License."),
686                 "http://etree.org/shnutils/shorten/"
687         );
688         moreAboutText += makeToolText
689         (
690                 tr("Speex - Free Codec For Free Speech"),
691                 "speexdec.exe", "v?.?",
692                 tr("Open Source patent-free audio format designed for speech."),
693                 "http://www.speex.org/"
694         );
695         moreAboutText += makeToolText
696         (
697                 tr("The True Audio - Lossless Audio Codec"),
698                 "tta.exe", "v?.?",
699                 tr("Released under the terms of the GNU Lesser General Public License."),
700                 "http://tta.sourceforge.net/"
701         );
702         //moreAboutText += makeToolText
703         //(
704         //      tr("ALAC Decoder"),
705         //      "alac.exe", "v?.?.?",
706         //      tr("Copyright (c) 2004 David Hammerton. Contributions by Cody Brocious."),
707         //      "http://craz.net/programs/itunes/alac.html"
708         //);
709         moreAboutText += makeToolText
710         (
711                 tr("refalac - Win32 command line ALAC encoder/decoder"),
712                 "refalac.exe", "v?.??",
713                 tr("The ALAC reference implementation by Apple is available under the Apache license."),
714                 "http://alac.macosforge.org/"
715         );
716         moreAboutText += makeToolText
717         (
718                 tr("wma2wav - Dump WMA files to Wave Audio"),
719                 "wma2wav.exe", "????-??-??",
720                 tr("Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved."),
721                 "http://forum.doom9.org/showthread.php?t=140273"
722         );
723         moreAboutText += makeToolText
724         (
725                 tr("avs2wav - Avisynth to Wave Audio converter"),
726                 "avs2wav.exe", "v?.?",
727                 tr("By Jory Stone <jcsston@toughguy.net> and LoRd_MuldeR <mulder2@gmx.de>."),
728                 "http://forum.doom9.org/showthread.php?t=70882"
729         );
730         moreAboutText += makeToolText
731         (
732                 tr("dcaenc"),
733                 "dcaenc.exe", "????-??-??",
734                 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
735                 "http://gitorious.org/dtsenc/dtsenc/trees/master"
736         );
737         moreAboutText += makeToolText
738         (
739                 tr("MediaInfo - Media File Analysis Tool"),
740                 "mediainfo.exe", "v?.?.??",
741                 tr("Released under the terms of the GNU Lesser General Public License."),
742                 "http://mediainfo.sourceforge.net/"
743         );
744         moreAboutText += makeToolText
745         (
746                 tr("SoX - Sound eXchange"),
747                 "sox.exe", "v??.?.?",
748                 tr("Released under the terms of the GNU Lesser General Public License."),
749                 "http://sox.sourceforge.net/"
750         );
751         moreAboutText += makeToolText
752         (
753                 tr("GnuPG - The GNU Privacy Guard"),
754                 "gpgv.exe", "v?.?.??",
755                 tr("Released under the terms of the GNU Lesser General Public License."),
756                 "http://www.gnupg.org/"
757         );
758         moreAboutText += makeToolText
759         (
760                 tr("GNU Wget - Software for retrieving files using HTTP"),
761                 "wget.exe", "v?.??.?",
762                 tr("Released under the terms of the GNU Lesser General Public License."),
763                 "http://www.gnu.org/software/wget/"
764         );
765         moreAboutText += makeToolText
766         (
767                 tr("UPX - The Ultimate Packer for eXecutables"),
768                 QString(), "v3.08",
769                 tr("Released under the terms of the GNU Lesser General Public License."),
770                 "http://upx.sourceforge.net/"
771         );
772         moreAboutText += makeToolText
773         (
774                 tr("Silk Icons - Over 700  icons in PNG format"),
775                 QString(), "v1.3",
776                 tr("By Mark James, released under the Creative Commons 'by' License."),
777                 "http://www.famfamfam.com/lab/icons/silk/"
778         );
779         moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><br><i>%1</i><br>").arg
780         (
781                 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.")
782         );
783
784         ui->softwareLabel->setText(moreAboutText);
785         ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
786         connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
787 }
788
789 void AboutDialog::initLicenseTab(void)
790 {
791         QString licenseText;
792         licenseText += ("<tt>");
793
794         QFile file(":/License.txt");
795         if(file.open(QIODevice::ReadOnly))
796         {
797                 QTextStream stream(&file);
798                 unsigned int counter = 0;
799                 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
800                 {
801                         QString line = stream.readLine();
802                         const bool bIsBlank = line.trimmed().isEmpty();
803                         line.replace('<', "&lt;").replace('>', "&gt;");
804
805                         switch(counter)
806                         {
807                         case 0:
808                                 if(!bIsBlank) licenseText += QString("<font size=\"+2\">%1</font><br>").arg(line.simplified());
809                                 break;
810                         case 1:
811                                 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"));
812                                 break;
813                         default:
814                                 TRIM_RIGHT(line);
815                                 licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
816                                 break;
817                         }
818
819                         if(!bIsBlank) counter++;
820                 }
821                 licenseText += QString("<br>");
822                 stream.device()->close();
823         }
824         else
825         {
826                 licenseText += QString("<font color=\"darkred\">Oups, failed to load license text. Please refer to:</font><br>");
827                 licenseText += LINK("http://www.gnu.org/licenses/gpl-2.0.html");
828         }
829
830         licenseText += ("</tt>");
831
832         ui->licenseLabel->setText(licenseText);
833         ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
834         connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
835 }
836
837
838 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
839 {
840         QString toolText, toolTag, verStr(toolVerFmt);
841
842         if(!toolBin.isEmpty())
843         {
844                 const unsigned int version = lamexp_tool_version(toolBin, &toolTag);
845                 verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), &toolTag);
846         }
847
848         toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));
849         toolText += QString("%1<br>").arg(NOBR(toolLicense));
850         if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(NOBR(extraInfo));
851         toolText += QString("<nobr>%1</nobr>").arg(LINK(toolWebsite));
852         toolText += QString("<font style=\"font-size:9px\"><br>&nbsp;</font>");
853
854         return toolText;
855 }
856
857
858 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
859 {
860         HMODULE module = 0;
861         DWORD flags = SND_RESOURCE;
862         bool result = false;
863
864         QFileInfo libraryFile(library);
865         if(!libraryFile.isAbsolute())
866         {
867                 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
868                 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
869                 unsigned int result = GetSystemDirectory(buffer, buffSize);
870                 if(result > 0 && result < buffSize)
871                 {
872                         libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
873                 }
874                 _freea(buffer);
875         }
876
877         if(async)
878         {
879                 flags |= SND_ASYNC;
880         }
881         else
882         {
883                 flags |= SND_SYNC;
884         }
885
886         module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
887
888         if(module)
889         {
890                 result = PlaySound((LPCTSTR) soundId, module, flags);
891                 FreeLibrary(module);
892         }
893
894         return result;
895 }