OSDN Git Service

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