OSDN Git Service

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