OSDN Git Service

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