OSDN Git Service

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