OSDN Git Service

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