OSDN Git Service

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