OSDN Git Service

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