Updated avs2wav tool.
[LameXP.git] / src / Dialog_About.cpp
blobce87c899ab835eccb839f7595ff6f665c91b1948
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.
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.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Dialog_About.h"
24 #include "Global.h"
25 #include "Resource.h"
26 #include "Model_Settings.h"
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>
40 #include <MMSystem.h>
42 //Helper macros
43 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
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*/
49 //Contributors
50 static const struct
52 char *pcFlag;
53 wchar_t *pcLanguage;
54 wchar_t *pcName;
55 char *pcMail;
57 g_lamexp_contributors[] =
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}
71 ////////////////////////////////////////////////////////////
72 // Constructor
73 ////////////////////////////////////////////////////////////
75 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
77 QMessageBox(parent),
78 m_settings(settings),
79 m_disque(NULL),
80 m_disqueTimer(NULL),
81 m_rotateNext(false),
82 m_disqueDelay(_I64_MAX)
84 QString versionStr = QString().sprintf
86 "Version %d.%02d %s, Build %d [%s], %s, Qt v%s",
87 lamexp_version_major(),
88 lamexp_version_minor(),
89 lamexp_version_release(),
90 lamexp_version_build(),
91 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
92 lamexp_version_compiler(),
93 qVersion()
96 for(int i = 0; i < 4; i++)
98 m_cartoon[i] = NULL;
101 QString aboutText;
103 aboutText += QString("<h2>%1</h2>").arg(tr("LameXP &minus; Audio Encoder Front-end"));
104 aboutText += QString("<nobr><b>Copyright (C) 2004-%1 LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.</b></nobr><br>").arg(max(lamexp_version_date().year(), QDate::currentDate().year())).replace("-", "&minus;");
105 aboutText += QString("<nobr><b>%1</b></nobr><br><br>").arg(versionStr).replace("-", "&minus;");
106 aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
108 if(LAMEXP_DEBUG)
110 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
111 aboutText += QString("<hr><nobr><font color=\"crimson\">!!! %3 DEBUG BUILD %3 Expires at: %1 %3 Days left: %2 %3 DEBUG BUILD %3 !!!</font></nobr>").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft), "&minus;&minus;&minus;");
113 else if(lamexp_version_demo())
115 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
116 aboutText += QString("<hr><nobr><font color=\"crimson\">%1</font></nobr>").arg(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))).replace("-", "&minus;");
119 aboutText += "<hr><br>";
120 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
121 aboutText += "modify it under the terms of the GNU General Public License<br>";
122 aboutText += "as published by the Free Software Foundation; either version 2<br>";
123 aboutText += "of the License, or (at your option) any later version.<br><br>";
124 aboutText += "This program is distributed in the hope that it will be useful,<br>";
125 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
126 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
127 aboutText += "GNU General Public License for more details.<br><br>";
128 aboutText += "You should have received a copy of the GNU General Public License<br>";
129 aboutText += "along with this program; if not, write to the Free Software<br>";
130 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110&minus;1301, USA.</tt></nobr><br>";
131 aboutText += "<hr><table><tr>";
132 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
133 aboutText += QString("<td><font color=\"darkred\">%1</font></td>").arg(tr("Note: LameXP is free software. Do <b>not</b> pay money to obtain or use LameXP! If some third-party website tries to make you pay for downloading LameXP, you should <b>not</b> respond to the offer !!!"));
134 aboutText += "</tr></table><hr><br>";
135 aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
137 setText(aboutText);
138 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
139 setWindowTitle(tr("About LameXP"));
141 if(firstStart)
143 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
144 firstButton->setIcon(QIcon(":/icons/script.png"));
145 firstButton->setIconSize(QSize(16, 16));
146 firstButton->setMinimumWidth(135);
147 firstButton->disconnect();
148 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
150 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
151 secondButton->setIcon(QIcon(":/icons/accept.png"));
152 secondButton->setIconSize(QSize(16, 16));
153 secondButton->setMinimumWidth(120);
155 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
156 thirdButton->setIcon(QIcon(":/icons/delete.png"));
157 thirdButton->setIconSize(QSize(16, 16));
158 thirdButton->setMinimumWidth(120);
159 thirdButton->setEnabled(false);
161 else
163 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
164 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
165 firstButton->setIconSize(QSize(16, 16));
166 firstButton->setMinimumWidth(120);
167 firstButton->disconnect();
168 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
170 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
171 secondButton->setIcon(QIcon(":icons/user_suit.png"));
172 secondButton->setIconSize(QSize(16, 16));
173 secondButton->setMinimumWidth(120);
174 secondButton->disconnect();
175 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
177 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
178 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
179 thirdButton->setIconSize(QSize(16, 16));
180 thirdButton->setMinimumWidth(120);
181 thirdButton->disconnect();
182 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
184 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
185 fourthButton->setIcon(QIcon(":/icons/cross.png"));
186 fourthButton->setIconSize(QSize(16, 16));
187 fourthButton->setMinimumWidth(90);
189 QPixmap disque(":/images/Disque.png");
190 QRect screenGeometry = QApplication::desktop()->availableGeometry();
191 m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
192 m_disque->installEventFilter(this);
193 m_disque->setStyleSheet("background:transparent;");
194 m_disque->setAttribute(Qt::WA_TranslucentBackground);
195 m_disque->setGeometry(qrand() % (screenGeometry.width() - disque.width()), qrand() % (screenGeometry.height() - disque.height()), disque.width(), disque.height());
196 m_disque->setPixmap(disque);
197 m_disque->setWindowOpacity(0.01);
198 m_disque->show();
199 m_disqueFlags[0] = (qrand() > (RAND_MAX/2));
200 m_disqueFlags[1] = (qrand() > (RAND_MAX/2));
201 m_disqueTimer = new QTimer;
202 connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
203 m_disqueTimer->setInterval(10);
204 m_disqueTimer->start();
207 m_firstShow = firstStart;
210 AboutDialog::~AboutDialog(void)
212 if(m_disque)
214 m_disque->close();
215 LAMEXP_DELETE(m_disque);
217 if(m_disqueTimer)
219 m_disqueTimer->stop();
220 LAMEXP_DELETE(m_disqueTimer);
222 for(int i = 0; i < 4; i++)
224 LAMEXP_DELETE(m_cartoon[i]);
229 ////////////////////////////////////////////////////////////
230 // Public Functions
231 ////////////////////////////////////////////////////////////
233 int AboutDialog::exec()
235 if(m_settings->soundsEnabled())
237 if(m_firstShow)
239 if(!playResoureSound("imageres.dll", 5080, true))
241 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
244 else
246 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
250 switch(QMessageBox::exec())
252 case 1:
253 return 1;
254 break;
255 case 2:
256 return -1;
257 break;
258 default:
259 return 0;
260 break;
264 ////////////////////////////////////////////////////////////
265 // Slots
266 ////////////////////////////////////////////////////////////
268 void AboutDialog::enableButtons(void)
270 const QList<QAbstractButton*> buttonList = buttons();
272 for(int i = 0; i < buttonList.count(); i++)
274 buttonList.at(i)->setEnabled(true);
277 setCursor(QCursor(Qt::ArrowCursor));
280 void AboutDialog::openLicenseText(void)
282 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
285 void AboutDialog::showAboutQt(void)
287 QMessageBox::aboutQt(this);
290 void AboutDialog::showAboutContributors(void)
292 QString contributorsAboutText;
294 contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
295 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
296 contributorsAboutText += "<table style=\"margin-top:5px\">";
297 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
299 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
300 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(flagIcon);
301 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td>&nbsp;&nbsp;</td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
302 contributorsAboutText += QString("<td valign=\"middle\">%3</td><td>&nbsp;&nbsp;</td><td>&lt;%4&gt;</td></tr>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcName), g_lamexp_contributors[i].pcMail);
304 contributorsAboutText += "</table>";
305 contributorsAboutText += "<br><br>";
306 contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
308 QMessageBox *contributorsAboutBox = new QMessageBox(this);
309 contributorsAboutBox->setText(contributorsAboutText);
310 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
312 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
313 closeButton->setIcon(QIcon(":/icons/cross.png"));
314 closeButton->setMinimumWidth(90);
316 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
317 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
318 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
319 contributorsAboutBox->exec();
321 LAMEXP_DELETE(contributorsAboutBox);
324 void AboutDialog::showMoreAbout(void)
326 QString moreAboutText;
328 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
329 moreAboutText += "<div style=\"margin-left:-25px;font-size:7pt;white-space:nowrap\"><table><tr><td><ul>";
331 moreAboutText += makeToolText
333 tr("LAME &minus; OpenSource mp3 Encoder"),
334 "lame.exe", "v?.??, Beta-?",
335 tr("Released under the terms of the GNU Lesser General Public License."),
336 "http://lame.sourceforge.net/"
338 moreAboutText += makeToolText
340 tr("OggEnc &minus; Ogg Vorbis Encoder"),
341 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
342 tr("Completely open and patent-free audio encoding technology."),
343 "http://www.vorbis.com/"
345 moreAboutText += makeToolText
347 tr("Nero AAC Reference MPEG-4 Encoder"),
348 "neroAacEnc.exe", "v?.?.?.?",
349 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
350 neroAacUrl,
351 tr("Available from vendor web-site as free download:")
353 moreAboutText += makeToolText
355 tr("Aften &minus; A/52 audio encoder"),
356 "aften.exe", "v?.?.?",
357 tr("Released under the terms of the GNU Lesser General Public License."),
358 "http://aften.sourceforge.net/"
360 moreAboutText += makeToolText
362 tr("FLAC &minus; Free Lossless Audio Codec"),
363 "flac.exe", "v?.?.?",
364 tr("Open and patent-free lossless audio compression technology."),
365 "http://flac.sourceforge.net/"
367 moreAboutText += makeToolText
369 tr("mpg123 &minus; Fast Console MPEG Audio Player/Decoder"),
370 "mpg123.exe", "v?.??.?",
371 tr("Released under the terms of the GNU Lesser General Public License."),
372 "http://www.mpg123.de/"
374 moreAboutText += makeToolText
376 tr("FAAD &minus; OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
377 "faad.exe", "v?.?",
378 tr("Released under the terms of the GNU General Public License."),
379 "http://www.audiocoding.com/"
381 moreAboutText += makeToolText
383 tr("AC3Filter Tools &minus; AC3/DTS Decoder"),
384 "valdec.exe", "v?.??",
385 tr("Released under the terms of the GNU Lesser General Public License."),
386 "http://www.ac3filter.net/projects/tools"
388 moreAboutText += makeToolText
390 tr("WavPack &minus; Hybrid Lossless Compression"),
391 "wvunpack.exe", "v?.??.?",
392 tr("Completely open audio compression format."),
393 "http://www.wavpack.com/"
395 moreAboutText += makeToolText
397 tr("Musepack &minus; Living Audio Compression"),
398 "mpcdec.exe", "r???",
399 tr("Released under the terms of the GNU Lesser General Public License."),
400 "http://www.musepack.net/"
402 moreAboutText += QString
404 "</ul></td><td><ul>"
406 moreAboutText += makeToolText
408 tr("Monkey's Audio &minus; Lossless Audio Compressor"),
409 "mac.exe", "v?.??",
410 tr("Freely available source code, simple SDK and non-restrictive licensing."),
411 "http://www.monkeysaudio.com/"
413 moreAboutText += makeToolText
415 tr("Shorten &minus; Lossless Audio Compressor"),
416 "shorten.exe", "v?.?.?",
417 tr("Released under the terms of the GNU Lesser General Public License."),
418 "http://etree.org/shnutils/shorten/"
420 moreAboutText += makeToolText
422 tr("Speex &minus; Free Codec For Free Speech"),
423 "speexdec.exe", "v?.?",
424 tr("Open Source patent-free audio format designed for speech."),
425 "http://www.speex.org/"
427 moreAboutText += makeToolText
429 tr("The True Audio &minus; Lossless Audio Codec"),
430 "tta.exe", "v?.?",
431 tr("Released under the terms of the GNU Lesser General Public License."),
432 "http://tta.sourceforge.net/"
434 moreAboutText += makeToolText
436 tr("ALAC Decoder"),
437 "alac.exe", "v?.?.?",
438 tr("Copyright (c) 2004 David Hammerton. Contributions by Cody Brocious."),
439 "http://craz.net/programs/itunes/alac.html"
441 moreAboutText += makeToolText
443 tr("MediaInfo &minus; Media File Analysis Tool"),
444 "mediainfo.exe", "v?.?.??",
445 tr("Released under the terms of the GNU Lesser General Public License."),
446 "http://mediainfo.sourceforge.net/"
448 moreAboutText += makeToolText
450 tr("SoX &minus; Sound eXchange"),
451 "sox.exe", "v??.?.?",
452 tr("Released under the terms of the GNU Lesser General Public License."),
453 "http://sox.sourceforge.net/"
455 moreAboutText += makeToolText
457 tr("GnuPG &minus; The GNU Privacy Guard"),
458 "gpgv.exe", "v?.?.??",
459 tr("Released under the terms of the GNU Lesser General Public License."),
460 "http://www.gnupg.org/"
462 moreAboutText += makeToolText
464 tr("GNU Wget &minus; Software for retrieving files using HTTP"),
465 "wget.exe", "v?.??.?",
466 tr("Released under the terms of the GNU Lesser General Public License."),
467 "http://www.gnu.org/software/wget/"
469 moreAboutText += makeToolText
471 tr("Silk Icons &minus; Over 700 icons in PNG format"),
472 QString(), "v1.3",
473 tr("By Mark James, released under the Creative Commons 'by' License."),
474 "http://www.famfamfam.com/lab/icons/silk/"
476 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i><nobr>%1</nobr></i><br>").arg
478 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;")
481 QMessageBox *moreAboutBox = new QMessageBox(this);
482 moreAboutBox->setText(moreAboutText);
483 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
485 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
486 closeButton->setIcon(QIcon(":/icons/cross.png"));
487 closeButton->setMinimumWidth(90);
489 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
490 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
491 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
492 moreAboutBox->exec();
494 LAMEXP_DELETE(moreAboutBox);
497 void AboutDialog::moveDisque(void)
499 int delta = 2;
500 LARGE_INTEGER perfCount, perfFrequ;
502 if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount))
504 if(m_disqueDelay != _I64_MAX)
506 const double delay = static_cast<double>(perfCount.QuadPart) - static_cast<double>(m_disqueDelay);
507 delta = max(1, min(128, static_cast<int>(ceil(delay / static_cast<double>(perfFrequ.QuadPart) / 0.00512))));
509 m_disqueDelay = perfCount.QuadPart;
512 if(m_disque)
514 QRect screenGeometry = QApplication::desktop()->availableGeometry();
515 const int minX = screenGeometry.left();
516 const int maxX = screenGeometry.width() - m_disque->width() + screenGeometry.left();
517 const int minY = screenGeometry.top();
518 const int maxY = screenGeometry.height() - m_disque->height() + screenGeometry.top();
520 QPoint pos = m_disque->pos();
521 pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta);
522 pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta);
524 if(pos.x() <= minX)
526 m_disqueFlags[0] = true;
527 pos.setX(minX);
528 m_rotateNext = true;
530 else if(pos.x() >= maxX)
532 m_disqueFlags[0] = false;
533 pos.setX(maxX);
534 m_rotateNext = true;
536 if(pos.y() <= minY)
538 m_disqueFlags[1] = true;
539 pos.setY(minY);
540 m_rotateNext = true;
542 else if(pos.y() >= maxY)
544 m_disqueFlags[1] = false;
545 pos.setY(maxY);
546 m_rotateNext = true;
549 m_disque->move(pos);
551 if(m_rotateNext)
553 QPixmap *cartoon = NULL;
554 if(m_disqueFlags[0] == true && m_disqueFlags[1] != true) cartoon = m_cartoon[0];
555 if(m_disqueFlags[0] == true && m_disqueFlags[1] == true) cartoon = m_cartoon[1];
556 if(m_disqueFlags[0] != true && m_disqueFlags[1] == true) cartoon = m_cartoon[2];
557 if(m_disqueFlags[0] != true && m_disqueFlags[1] != true) cartoon = m_cartoon[3];
558 if(cartoon)
560 m_disque->setPixmap(*cartoon);
561 m_disque->resize(cartoon->size());
563 m_rotateNext = false;
566 if(m_disque->windowOpacity() < 0.9)
568 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
572 ////////////////////////////////////////////////////////////
573 // Protected Functions
574 ////////////////////////////////////////////////////////////
576 void AboutDialog::showEvent(QShowEvent *e)
578 QDialog::showEvent(e);
579 if(m_firstShow)
581 const QList<QAbstractButton*> buttonList = buttons();
583 for(int i = 1; i < buttonList.count(); i++)
585 buttonList.at(i)->setEnabled(false);
588 QTimer::singleShot(5000, this, SLOT(enableButtons()));
589 setCursor(QCursor(Qt::WaitCursor));
593 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
595 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
597 QPixmap cartoon(":/images/Cartoon.png");
598 for(int i = 0; i < 4; i++)
600 if(!m_cartoon[i])
602 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
603 m_rotateNext = true;
606 QDesktopServices::openUrl(QUrl(disqueUrl));
609 return false;
612 ////////////////////////////////////////////////////////////
613 // Private Functions
614 ////////////////////////////////////////////////////////////
616 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
618 QString toolText, verStr(toolVerFmt);
620 if(!toolBin.isEmpty())
622 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
625 toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
626 toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
627 if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
628 toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
629 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
631 return toolText;
635 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
637 HMODULE module = 0;
638 DWORD flags = SND_RESOURCE;
639 bool result = false;
641 QFileInfo libraryFile(library);
642 if(!libraryFile.isAbsolute())
644 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
645 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
646 unsigned int result = GetSystemDirectory(buffer, buffSize);
647 if(result > 0 && result < buffSize)
649 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
651 _freea(buffer);
654 if(async)
656 flags |= SND_ASYNC;
658 else
660 flags |= SND_SYNC;
663 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
665 if(module)
667 result = PlaySound((LPCTSTR) soundId, module, flags);
668 FreeLibrary(module);
671 return result;