Fixed compilation in Visual Studio 2008.
[LameXP.git] / src / Dialog_About.cpp
blob7ee70746fd1b40e2b4a455ddbc276f02e9bceb3b
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>
41 #include <math.h>
43 //Helper macros
44 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
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*/
50 //Contributors
51 static const struct
53 char *pcFlag;
54 wchar_t *pcLanguage;
55 wchar_t *pcName;
56 char *pcMail;
58 g_lamexp_contributors[] =
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}
72 ////////////////////////////////////////////////////////////
73 // Constructor
74 ////////////////////////////////////////////////////////////
76 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
78 QMessageBox(parent),
79 m_settings(settings),
80 m_disque(NULL),
81 m_disqueTimer(NULL),
82 m_rotateNext(false),
83 m_disqueDelay(_I64_MAX)
85 QString versionStr = QString().sprintf
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()
97 for(int i = 0; i < 4; i++)
99 m_cartoon[i] = NULL;
102 QString aboutText;
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())));
109 if(LAMEXP_DEBUG)
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;");
114 else if(lamexp_version_demo())
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;");
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/")));
138 setText(aboutText);
139 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
140 setWindowTitle(tr("About LameXP"));
142 if(firstStart)
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()));
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);
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);
162 else
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()));
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()));
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()));
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);
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();
208 m_firstShow = firstStart;
211 AboutDialog::~AboutDialog(void)
213 if(m_disque)
215 m_disque->close();
216 LAMEXP_DELETE(m_disque);
218 if(m_disqueTimer)
220 m_disqueTimer->stop();
221 LAMEXP_DELETE(m_disqueTimer);
223 for(int i = 0; i < 4; i++)
225 LAMEXP_DELETE(m_cartoon[i]);
230 ////////////////////////////////////////////////////////////
231 // Public Functions
232 ////////////////////////////////////////////////////////////
234 int AboutDialog::exec()
236 if(m_settings->soundsEnabled())
238 if(m_firstShow)
240 if(!playResoureSound("imageres.dll", 5080, true))
242 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
245 else
247 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
251 switch(QMessageBox::exec())
253 case 1:
254 return 1;
255 break;
256 case 2:
257 return -1;
258 break;
259 default:
260 return 0;
261 break;
265 ////////////////////////////////////////////////////////////
266 // Slots
267 ////////////////////////////////////////////////////////////
269 void AboutDialog::enableButtons(void)
271 const QList<QAbstractButton*> buttonList = buttons();
273 for(int i = 0; i < buttonList.count(); i++)
275 buttonList.at(i)->setEnabled(true);
278 setCursor(QCursor(Qt::ArrowCursor));
281 void AboutDialog::openLicenseText(void)
283 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
286 void AboutDialog::showAboutQt(void)
288 QMessageBox::aboutQt(this);
291 void AboutDialog::showAboutContributors(void)
293 QString contributorsAboutText;
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++)
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);
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!"));
309 QMessageBox *contributorsAboutBox = new QMessageBox(this);
310 contributorsAboutBox->setText(contributorsAboutText);
311 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
313 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
314 closeButton->setIcon(QIcon(":/icons/cross.png"));
315 closeButton->setMinimumWidth(90);
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();
322 LAMEXP_DELETE(contributorsAboutBox);
325 void AboutDialog::showMoreAbout(void)
327 QString moreAboutText;
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>";
332 moreAboutText += makeToolText
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/"
339 moreAboutText += makeToolText
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/"
346 moreAboutText += makeToolText
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:")
354 moreAboutText += makeToolText
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/"
361 moreAboutText += makeToolText
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/"
368 moreAboutText += makeToolText
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/"
375 moreAboutText += makeToolText
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/"
382 moreAboutText += makeToolText
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"
389 moreAboutText += makeToolText
391 tr("WavPack &minus; Hybrid Lossless Compression"),
392 "wvunpack.exe", "v?.??.?",
393 tr("Completely open audio compression format."),
394 "http://www.wavpack.com/"
396 moreAboutText += makeToolText
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/"
403 moreAboutText += QString
405 "</ul></td><td><ul>"
407 moreAboutText += makeToolText
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/"
414 moreAboutText += makeToolText
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/"
421 moreAboutText += makeToolText
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/"
428 moreAboutText += makeToolText
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/"
435 moreAboutText += makeToolText
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"
442 moreAboutText += makeToolText
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/"
449 moreAboutText += makeToolText
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/"
456 moreAboutText += makeToolText
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/"
463 moreAboutText += makeToolText
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/"
470 moreAboutText += makeToolText
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/"
477 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i><nobr>%1</nobr></i><br>").arg
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;")
482 QMessageBox *moreAboutBox = new QMessageBox(this);
483 moreAboutBox->setText(moreAboutText);
484 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
486 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
487 closeButton->setIcon(QIcon(":/icons/cross.png"));
488 closeButton->setMinimumWidth(90);
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();
495 LAMEXP_DELETE(moreAboutBox);
498 void AboutDialog::moveDisque(void)
500 int delta = 2;
501 LARGE_INTEGER perfCount, perfFrequ;
503 if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount))
505 if(m_disqueDelay != _I64_MAX)
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))));
510 m_disqueDelay = perfCount.QuadPart;
513 if(m_disque)
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();
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);
525 if(pos.x() <= minX)
527 m_disqueFlags[0] = true;
528 pos.setX(minX);
529 m_rotateNext = true;
531 else if(pos.x() >= maxX)
533 m_disqueFlags[0] = false;
534 pos.setX(maxX);
535 m_rotateNext = true;
537 if(pos.y() <= minY)
539 m_disqueFlags[1] = true;
540 pos.setY(minY);
541 m_rotateNext = true;
543 else if(pos.y() >= maxY)
545 m_disqueFlags[1] = false;
546 pos.setY(maxY);
547 m_rotateNext = true;
550 m_disque->move(pos);
552 if(m_rotateNext)
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)
561 m_disque->setPixmap(*cartoon);
562 m_disque->resize(cartoon->size());
564 m_rotateNext = false;
567 if(m_disque->windowOpacity() < 0.9)
569 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
573 ////////////////////////////////////////////////////////////
574 // Protected Functions
575 ////////////////////////////////////////////////////////////
577 void AboutDialog::showEvent(QShowEvent *e)
579 QDialog::showEvent(e);
580 if(m_firstShow)
582 const QList<QAbstractButton*> buttonList = buttons();
584 for(int i = 1; i < buttonList.count(); i++)
586 buttonList.at(i)->setEnabled(false);
589 QTimer::singleShot(5000, this, SLOT(enableButtons()));
590 setCursor(QCursor(Qt::WaitCursor));
594 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
596 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
598 QPixmap cartoon(":/images/Cartoon.png");
599 for(int i = 0; i < 4; i++)
601 if(!m_cartoon[i])
603 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
604 m_rotateNext = true;
607 QDesktopServices::openUrl(QUrl(disqueUrl));
610 return false;
613 ////////////////////////////////////////////////////////////
614 // Private Functions
615 ////////////////////////////////////////////////////////////
617 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
619 QString toolText, verStr(toolVerFmt);
621 if(!toolBin.isEmpty())
623 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
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>");
632 return toolText;
636 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
638 HMODULE module = 0;
639 DWORD flags = SND_RESOURCE;
640 bool result = false;
642 QFileInfo libraryFile(library);
643 if(!libraryFile.isAbsolute())
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)
650 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
652 _freea(buffer);
655 if(async)
657 flags |= SND_ASYNC;
659 else
661 flags |= SND_SYNC;
664 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
666 if(module)
668 result = PlaySound((LPCTSTR) soundId, module, flags);
669 FreeLibrary(module);
672 return result;