Some style-specific tweaks.
[LameXP.git] / src / Dialog_About.cpp
blobed26a412ed87278d7b795e3bf1e4c680f97f9233
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
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.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Dialog_About.h"
24 #include "../tmp/UIC_AboutDialog.h"
26 #include "Global.h"
27 #include "Resource.h"
28 #include "Model_Settings.h"
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>
48 #include <ShellAPI.h>
49 #include <MMSystem.h>
50 #include <math.h>
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)
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
62 //Contributors
63 static const struct
65 char *pcFlag;
66 wchar_t *pcLanguage;
67 wchar_t *pcName;
68 char *pcMail;
70 g_lamexp_translators[] =
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}
89 ////////////////////////////////////////////////////////////
90 // Constructor
91 ////////////////////////////////////////////////////////////
93 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
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)
105 //Init the dialog, from the .ui file
106 ui->setupUi(this);
107 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
108 resize(this->minimumSize());
110 //Disable "X" button
111 if(firstStart)
113 if(HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE))
115 EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
119 //Init images
120 for(int i = 0; i < 4; i++)
122 m_cartoon[i] = NULL;
125 //Init tab widget
126 connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
128 //Make transparent
129 const type_info &styleType = typeid(*qApp->style());
130 if((typeid(QWindowsVistaStyle) == styleType) || (typeid(QWindowsXPStyle) == styleType))
132 MAKE_TRANSPARENT(ui->infoScrollArea);
133 MAKE_TRANSPARENT(ui->contributorsScrollArea);
134 MAKE_TRANSPARENT(ui->softwareScrollArea);
135 MAKE_TRANSPARENT(ui->licenseScrollArea);
138 //Show about dialog for the first time?
139 if(!firstStart)
141 lamexp_seed_rand();
143 ui->acceptButton->hide();
144 ui->declineButton->hide();
145 ui->aboutQtButton->show();
146 ui->closeButton->show();
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();
165 connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
167 else
169 ui->acceptButton->show();
170 ui->declineButton->show();
171 ui->aboutQtButton->hide();
172 ui->closeButton->hide();
175 //Activate "show license" button
176 ui->showLicenseButton->show();
177 connect(ui->showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
179 m_firstShow = firstStart;
182 AboutDialog::~AboutDialog(void)
184 if(m_disque)
186 m_disque->close();
187 LAMEXP_DELETE(m_disque);
189 if(m_disqueTimer)
191 m_disqueTimer->stop();
192 LAMEXP_DELETE(m_disqueTimer);
194 for(int i = 0; i < 4; i++)
196 LAMEXP_DELETE(m_cartoon[i]);
198 LAMEXP_DELETE(m_initFlags);
199 LAMEXP_DELETE(ui);
202 ////////////////////////////////////////////////////////////
203 // Public Functions
204 ////////////////////////////////////////////////////////////
206 int AboutDialog::exec()
208 if(m_settings->soundsEnabled())
210 if(m_firstShow)
212 if(!playResoureSound("imageres.dll", 5080, true))
214 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
217 else
219 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
223 switch(QDialog::exec())
225 case 1:
226 return 1;
227 break;
228 case 2:
229 return -1;
230 break;
231 default:
232 return 0;
233 break;
237 ////////////////////////////////////////////////////////////
238 // Slots
239 ////////////////////////////////////////////////////////////
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}
244 void AboutDialog::tabChanged(int index)
246 bool bInitialized = m_initFlags->value(ui->tabWidget->widget(index), false);
248 if(!bInitialized)
250 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
252 if(QWidget *tab = ui->tabWidget->widget(index))
254 bool ok = false;
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; }
261 if(ok)
263 m_initFlags->insert(tab, true);
265 else
267 qWarning("Unknown tab %p encountered, cannot initialize !!!", tab);
272 ui->tabWidget->widget(index)->update();
273 qApp->processEvents();
274 qApp->restoreOverrideCursor();
277 //Scroll to the top
278 if(QWidget *tab = ui->tabWidget->widget(index))
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);
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;
291 void AboutDialog::enableButtons(void)
293 ui->acceptButton->setEnabled(true);
294 ui->declineButton->setEnabled(true);
295 setCursor(QCursor(Qt::ArrowCursor));
298 void AboutDialog::openURL(const QString &url)
300 if(!QDesktopServices::openUrl(QUrl(url)))
302 ShellExecuteW(this->winId(), L"open", QWCHAR(url), NULL, NULL, SW_SHOW);
306 void AboutDialog::showAboutQt(void)
308 TEMP_HIDE_DISQUE
310 QMessageBox::aboutQt(this);
314 void AboutDialog::gotoLicenseTab(void)
316 ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->showLicenseButton->isChecked() ? ui->licenseTab : ui->tabWidget->widget(m_lastTab)));
319 void AboutDialog::moveDisque(void)
321 int delta = 2;
322 LARGE_INTEGER perfCount, perfFrequ;
324 if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount))
326 if(m_disqueDelay != _I64_MAX)
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))));
331 m_disqueDelay = perfCount.QuadPart;
334 if(m_disque)
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();
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);
346 if(pos.x() <= minX)
348 m_disqueFlags[0] = true;
349 pos.setX(minX);
350 m_rotateNext = true;
352 else if(pos.x() >= maxX)
354 m_disqueFlags[0] = false;
355 pos.setX(maxX);
356 m_rotateNext = true;
358 if(pos.y() <= minY)
360 m_disqueFlags[1] = true;
361 pos.setY(minY);
362 m_rotateNext = true;
364 else if(pos.y() >= maxY)
366 m_disqueFlags[1] = false;
367 pos.setY(maxY);
368 m_rotateNext = true;
371 m_disque->move(pos);
373 if(m_rotateNext)
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)
382 m_disque->setPixmap(*cartoon);
383 m_disque->resize(cartoon->size());
385 m_rotateNext = false;
388 if(m_disque->windowOpacity() < 0.9)
390 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
395 void AboutDialog::adjustSize(void)
397 int maximumHeight = QApplication::desktop()->availableGeometry().height();
399 int delta = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
400 if(delta > 0)
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()));
408 ////////////////////////////////////////////////////////////
409 // Protected Functions
410 ////////////////////////////////////////////////////////////
412 void AboutDialog::showEvent(QShowEvent *e)
414 QDialog::showEvent(e);
416 ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
417 tabChanged(m_lastTab = ui->tabWidget->currentIndex());
419 if(m_firstShow)
421 ui->acceptButton->setEnabled(false);
422 ui->declineButton->setEnabled(false);
423 QTimer::singleShot(5000, this, SLOT(enableButtons()));
424 setCursor(QCursor(Qt::WaitCursor));
427 QTimer::singleShot(0, this, SLOT(adjustSize()));
430 void AboutDialog::closeEvent(QCloseEvent *e)
432 if(m_firstShow) e->ignore();
435 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
437 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
439 QPixmap cartoon(":/images/Cartoon.png");
440 for(int i = 0; i < 4; i++)
442 if(!m_cartoon[i])
444 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
445 m_rotateNext = true;
448 QDesktopServices::openUrl(QUrl(disqueUrl));
451 return false;
454 ////////////////////////////////////////////////////////////
455 // Private Functions
456 ////////////////////////////////////////////////////////////
458 void AboutDialog::initInformationTab(void)
460 const QString versionStr = QString().sprintf
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()
473 const QString copyrightStr = QString().sprintf
475 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
476 qMax(lamexp_version_date().year(), QDate::currentDate().year())
479 QString aboutText;
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()))));
486 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
487 if(LAMEXP_DEBUG)
489 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
490 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 else if(lamexp_version_demo())
494 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
495 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 #else
498 if(LAMEXP_DEBUG)
500 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0i64);
501 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))));
503 else if(lamexp_version_demo())
505 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0i64);
506 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))));
508 #endif
510 aboutText += "<hr><br>";
511 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
512 aboutText += "modify it under the terms of the GNU General Public License<br>";
513 aboutText += "as published by the Free Software Foundation; either version 2<br>";
514 aboutText += "of the License, or (at your option) any later version.<br><br>";
515 aboutText += "This program is distributed in the hope that it will be useful,<br>";
516 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
517 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
518 aboutText += "GNU General Public License for more details.<br><br>";
519 aboutText += "You should have received a copy of the GNU General Public License<br>";
520 aboutText += "along with this program; if not, write to the Free Software<br>";
521 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110&minus;1301, USA.</tt></nobr><br>";
522 aboutText += "<hr><table style=\"margin-top:4px\"><tr>";
523 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
524 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 !!!"));
525 aboutText += "</tr></table>";
526 //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/")));
528 ui->infoLabel->setText(aboutText);
529 ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
530 connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
533 void AboutDialog::initContributorsTab(void)
535 const QString spaces("&nbsp;&nbsp;&nbsp;&nbsp;");
536 const QString extraVSpace("<font style=\"font-size:7px\"><br>&nbsp;</font>");
538 QString contributorsAboutText;
539 contributorsAboutText += QString("<h3>%1</h3>").arg(NOBR(tr("The following people have contributed to LameXP:")));
540 contributorsAboutText += "<table style=\"margin-top:12px;white-space:nowrap\">";
542 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Programmers:"), extraVSpace);
543 QString icon = QString("<img src=\":/icons/%1.png\">").arg("user_gray");
544 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(icon, spaces);
545 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(tr("Project Leader"), spaces);
546 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");
547 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
549 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Translators:"), extraVSpace);
550 for(int i = 0; g_lamexp_translators[i].pcName; i++)
552 QString flagIcon = (strlen(g_lamexp_translators[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_translators[i].pcFlag) : QString();
553 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(flagIcon, spaces);
554 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td>").arg(WCHAR2QSTR(g_lamexp_translators[i].pcLanguage), spaces);
555 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 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>&nbsp;</b></td></tr>");
559 contributorsAboutText += QString("<tr><td colspan=\"7\"><b>%1</b>%2</td></tr>").arg(tr("Special thanks to:"), extraVSpace);
561 QString webIcon = QString("<img src=\":/icons/%1.png\">").arg("world");
562 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
563 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td valign=\"middle\" colspan=\"3\"><a href=\"%3\">%3</td></tr>").arg(tr("Doom9's Forum"), spaces, "http://forum.doom9.org/");
564 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>%2</td>").arg(webIcon, spaces);
565 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>%2</td><td valign=\"middle\" colspan=\"3\"><a href=\"%3\">%3</td></tr>").arg(tr("Gleitz | German Doom9"), spaces, "http://forum.gleitz.info/");
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("Hydrogenaudio Forums"), spaces, "http://www.hydrogenaudio.org/");
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("RareWares"), spaces, "http://www.rarewares.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("GitHub"), spaces, "http://github.com/");
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("SourceForge"), spaces, "http://sourceforge.net/");
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("Qt Developer Network"), spaces, "http://qt-project.org/");
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("Marius Hudea"), spaces, "http://savedonthe.net/");
579 contributorsAboutText += "</table><br><br><br>";
580 contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
582 ui->contributorsLabel->setText(contributorsAboutText);
583 ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
584 connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
587 void AboutDialog::initSoftwareTab(void)
589 QString moreAboutText;
591 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
592 moreAboutText += "<div style=\"margin-left:-25px;white-space:nowrap\"><table><tr><td><ul>"; //;font-size:7pt
594 moreAboutText += makeToolText
596 tr("LAME - OpenSource mp3 Encoder"),
597 "lame.exe", "v?.??, Final-?",
598 tr("Released under the terms of the GNU Lesser General Public License."),
599 "http://lame.sourceforge.net/"
601 moreAboutText += makeToolText
603 tr("OggEnc - Ogg Vorbis Encoder"),
604 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
605 tr("Completely open and patent-free audio encoding technology."),
606 "http://www.vorbis.com/"
608 moreAboutText += makeToolText
610 tr("Nero AAC Reference MPEG-4 Encoder"),
611 "neroAacEnc.exe", "v?.?.?.?",
612 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
613 neroAacUrl,
614 tr("Available from vendor web-site as free download:")
616 moreAboutText += makeToolText
618 tr("Aften - A/52 audio encoder"),
619 "aften.exe", "v?.?.?",
620 tr("Released under the terms of the GNU Lesser General Public License."),
621 "http://aften.sourceforge.net/"
623 moreAboutText += makeToolText
625 tr("FLAC - Free Lossless Audio Codec"),
626 "flac.exe", "v?.?.?",
627 tr("Open and patent-free lossless audio compression technology."),
628 "http://flac.sourceforge.net/"
630 moreAboutText += makeToolText
632 tr("Opus Audio Codec"),
633 "opusenc_std.exe", "????-??-??",
634 tr("Totally open, royalty-free, highly versatile audio codec."),
635 "http://www.opus-codec.org/"
637 moreAboutText += makeToolText
639 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
640 "mpg123.exe", "v?.??.?",
641 tr("Released under the terms of the GNU Lesser General Public License."),
642 "http://www.mpg123.de/"
644 moreAboutText += makeToolText
646 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
647 "faad.exe", "v?.?",
648 tr("Released under the terms of the GNU General Public License."),
649 "http://www.audiocoding.com/"
651 moreAboutText += makeToolText
653 tr("AC3Filter Tools - AC3/DTS Decoder"),
654 "valdec.exe", "v?.??",
655 tr("Released under the terms of the GNU Lesser General Public License."),
656 "http://www.ac3filter.net/projects/tools"
658 moreAboutText += makeToolText
660 tr("WavPack - Hybrid Lossless Compression"),
661 "wvunpack.exe", "v?.??.?",
662 tr("Completely open audio compression format."),
663 "http://www.wavpack.com/"
665 moreAboutText += makeToolText
667 tr("Musepack - Living Audio Compression"),
668 "mpcdec.exe", "r???",
669 tr("Released under the terms of the GNU Lesser General Public License."),
670 "http://www.musepack.net/"
672 moreAboutText += makeToolText
674 tr("Monkey's Audio - Lossless Audio Compressor"),
675 "mac.exe", "v?.??",
676 tr("Freely available source code, simple SDK and non-restrictive licensing."),
677 "http://www.monkeysaudio.com/"
679 moreAboutText += makeToolText
681 tr("Shorten - Lossless Audio Compressor"),
682 "shorten.exe", "v?.?.?",
683 tr("Released under the terms of the GNU Lesser General Public License."),
684 "http://etree.org/shnutils/shorten/"
686 moreAboutText += makeToolText
688 tr("Speex - Free Codec For Free Speech"),
689 "speexdec.exe", "v?.?",
690 tr("Open Source patent-free audio format designed for speech."),
691 "http://www.speex.org/"
693 moreAboutText += makeToolText
695 tr("The True Audio - Lossless Audio Codec"),
696 "tta.exe", "v?.?",
697 tr("Released under the terms of the GNU Lesser General Public License."),
698 "http://tta.sourceforge.net/"
700 //moreAboutText += makeToolText
702 // tr("ALAC Decoder"),
703 // "alac.exe", "v?.?.?",
704 // tr("Copyright (c) 2004 David Hammerton. Contributions by Cody Brocious."),
705 // "http://craz.net/programs/itunes/alac.html"
706 //);
707 moreAboutText += makeToolText
709 tr("refalac - Win32 command line ALAC encoder/decoder"),
710 "refalac.exe", "v?.??",
711 tr("The ALAC reference implementation by Apple is available under the Apache license."),
712 "http://alac.macosforge.org/"
714 moreAboutText += makeToolText
716 tr("wma2wav - Dump WMA files to Wave Audio"),
717 "wma2wav.exe", "????-??-??",
718 tr("Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved."),
719 "http://forum.doom9.org/showthread.php?t=140273"
721 moreAboutText += makeToolText
723 tr("avs2wav - Avisynth to Wave Audio converter"),
724 "avs2wav.exe", "v?.?",
725 tr("By Jory Stone <jcsston@toughguy.net> and LoRd_MuldeR <mulder2@gmx.de>."),
726 "http://forum.doom9.org/showthread.php?t=70882"
728 moreAboutText += makeToolText
730 tr("dcaenc"),
731 "dcaenc.exe", "????-??-??",
732 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
733 "http://gitorious.org/dtsenc/dtsenc/trees/master"
735 moreAboutText += makeToolText
737 tr("MediaInfo - Media File Analysis Tool"),
738 "mediainfo.exe", "v?.?.??",
739 tr("Released under the terms of the GNU Lesser General Public License."),
740 "http://mediainfo.sourceforge.net/"
742 moreAboutText += makeToolText
744 tr("SoX - Sound eXchange"),
745 "sox.exe", "v??.?.?",
746 tr("Released under the terms of the GNU Lesser General Public License."),
747 "http://sox.sourceforge.net/"
749 moreAboutText += makeToolText
751 tr("GnuPG - The GNU Privacy Guard"),
752 "gpgv.exe", "v?.?.??",
753 tr("Released under the terms of the GNU Lesser General Public License."),
754 "http://www.gnupg.org/"
756 moreAboutText += makeToolText
758 tr("GNU Wget - Software for retrieving files using HTTP"),
759 "wget.exe", "v?.??.?",
760 tr("Released under the terms of the GNU Lesser General Public License."),
761 "http://www.gnu.org/software/wget/"
763 moreAboutText += makeToolText
765 tr("UPX - The Ultimate Packer for eXecutables"),
766 QString(), "v3.08",
767 tr("Released under the terms of the GNU Lesser General Public License."),
768 "http://upx.sourceforge.net/"
770 moreAboutText += makeToolText
772 tr("Silk Icons - Over 700 icons in PNG format"),
773 QString(), "v1.3",
774 tr("By Mark James, released under the Creative Commons 'by' License."),
775 "http://www.famfamfam.com/lab/icons/silk/"
777 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><br><i>%1</i><br>").arg
779 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 ui->softwareLabel->setText(moreAboutText);
783 ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
784 connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
787 void AboutDialog::initLicenseTab(void)
789 QString licenseText;
790 licenseText += ("<tt>");
792 QFile file(":/License.txt");
793 if(file.open(QIODevice::ReadOnly))
795 QTextStream stream(&file);
796 unsigned int counter = 0;
797 while((!stream.atEnd()) && (stream.status() == QTextStream::Ok))
799 QString line = stream.readLine();
800 const bool bIsBlank = line.trimmed().isEmpty();
801 line.replace('<', "&lt;").replace('>', "&gt;");
803 switch(counter)
805 case 0:
806 if(!bIsBlank) licenseText += QString("<font size=\"+2\">%1</font><br>").arg(line.simplified());
807 break;
808 case 1:
809 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"));
810 break;
811 default:
812 TRIM_RIGHT(line);
813 licenseText += QString("<nobr>%1</nobr><br>").arg(line.replace(' ', "&nbsp;"));
814 break;
817 if(!bIsBlank) counter++;
819 licenseText += QString("<br>");
820 stream.device()->close();
822 else
824 licenseText += QString("<font color=\"darkred\">Oups, failed to load license text. Please refer to:</font><br>");
825 licenseText += LINK("http://www.gnu.org/licenses/gpl-2.0.html");
828 licenseText += ("</tt>");
830 ui->licenseLabel->setText(licenseText);
831 ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
832 connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
836 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
838 QString toolText, verStr(toolVerFmt);
840 if(!toolBin.isEmpty())
842 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
845 toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));
846 toolText += QString("%1<br>").arg(NOBR(toolLicense));
847 if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(NOBR(extraInfo));
848 toolText += QString("<nobr>%1</nobr>").arg(LINK(toolWebsite));
849 toolText += QString("<font style=\"font-size:9px\"><br>&nbsp;</font>");
851 return toolText;
855 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
857 HMODULE module = 0;
858 DWORD flags = SND_RESOURCE;
859 bool result = false;
861 QFileInfo libraryFile(library);
862 if(!libraryFile.isAbsolute())
864 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
865 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
866 unsigned int result = GetSystemDirectory(buffer, buffSize);
867 if(result > 0 && result < buffSize)
869 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
871 _freea(buffer);
874 if(async)
876 flags |= SND_ASYNC;
878 else
880 flags |= SND_SYNC;
883 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
885 if(module)
887 result = PlaySound((LPCTSTR) soundId, module, flags);
888 FreeLibrary(module);
891 return result;