OSDN Git Service

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