Bump version.
[LameXP.git] / src / Dialog_About.cpp
blob8ef7fa4056e8d44450089b8353d772b8781f7e5b
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 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(QString(URL).replace("-", "&minus;"))
46 //Constants
47 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
48 const char *AboutDialog::disqueUrl = "http://mulder.brhack.net/?player_url=38X-MXOB014"; //http://mulder.brhack.net/?player_url=yF6W-w0iAMM; http://www.youtube.com/watch_popup?v=yF6W-w0iAMM&vq=large
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 {"pl", L"Polski", L"Sir Daniel K", "Sir.Daniel.K@gmail.com"},
68 {"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" },
69 {"", L"", L"Иван Митин", "bardak@inbox.ru" },
70 {"sv", L"Svenska", L"Åke Engelbrektson", "eson57@gmail.com" },
71 {"tw", L"繁体中文", L"456Vv", "123@456vv.com" },
72 {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
73 {"zh", L"简体中文", L"456Vv", "123@456vv.com" },
74 {NULL, NULL, NULL, NULL}
77 ////////////////////////////////////////////////////////////
78 // Constructor
79 ////////////////////////////////////////////////////////////
81 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
83 QMessageBox(parent),
84 m_settings(settings),
85 m_disque(NULL),
86 m_disqueTimer(NULL),
87 m_rotateNext(false),
88 m_disqueDelay(_I64_MAX)
90 const QString versionStr = QString().sprintf
92 "Version %d.%02d %s, Build %d [%s], %s %s, Qt v%s",
93 lamexp_version_major(),
94 lamexp_version_minor(),
95 lamexp_version_release(),
96 lamexp_version_build(),
97 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
98 lamexp_version_compiler(),
99 lamexp_version_arch(),
100 qVersion()
102 const QString copyrightStr = QString().sprintf
104 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
105 qMax(lamexp_version_date().year(), QDate::currentDate().year())
108 for(int i = 0; i < 4; i++)
110 m_cartoon[i] = NULL;
113 QString aboutText;
115 aboutText += QString("<h2>%1</h2>").arg(NOBR(tr("LameXP - Audio Encoder Front-end")));
116 aboutText += QString("<b>%1</b><br>").arg(NOBR(copyrightStr));
117 aboutText += QString("<b>%1</b><br><br>").arg(NOBR(versionStr));
118 aboutText += QString("%1<br>").arg(NOBR(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url()))));
120 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
121 if(LAMEXP_DEBUG)
123 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
124 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
126 else if(lamexp_version_demo())
128 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
129 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(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))));
131 #else
132 if(LAMEXP_DEBUG)
134 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0i64);
135 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
137 else if(lamexp_version_demo())
139 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0i64);
140 aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(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))));
142 #endif
144 aboutText += "<hr><br>";
145 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
146 aboutText += "modify it under the terms of the GNU General Public License<br>";
147 aboutText += "as published by the Free Software Foundation; either version 2<br>";
148 aboutText += "of the License, or (at your option) any later version.<br><br>";
149 aboutText += "This program is distributed in the hope that it will be useful,<br>";
150 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
151 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
152 aboutText += "GNU General Public License for more details.<br><br>";
153 aboutText += "You should have received a copy of the GNU General Public License<br>";
154 aboutText += "along with this program; if not, write to the Free Software<br>";
155 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110&minus;1301, USA.</tt></nobr><br>";
156 aboutText += "<hr><table><tr>";
157 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
158 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 !!!"));
159 aboutText += "</tr></table><hr><br>";
160 aboutText += QString("%1<br>").arg(NOBR(tr("Special thanks go out to \"John33\" from %1 for his continuous support.")).arg(LINK("http://www.rarewares.org/")));
162 setText(aboutText);
163 setIconPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
164 setWindowTitle(tr("About LameXP"));
166 if(firstStart)
168 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
169 firstButton->setIcon(QIcon(":/icons/script.png"));
170 firstButton->setIconSize(QSize(16, 16));
171 firstButton->setMinimumWidth(135);
172 firstButton->disconnect();
173 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
175 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
176 secondButton->setIcon(QIcon(":/icons/accept.png"));
177 secondButton->setIconSize(QSize(16, 16));
178 secondButton->setMinimumWidth(120);
180 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
181 thirdButton->setIcon(QIcon(":/icons/delete.png"));
182 thirdButton->setIconSize(QSize(16, 16));
183 thirdButton->setMinimumWidth(120);
184 thirdButton->setEnabled(false);
186 else
188 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
189 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
190 firstButton->setIconSize(QSize(16, 16));
191 firstButton->setMinimumWidth(120);
192 firstButton->disconnect();
193 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
195 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
196 secondButton->setIcon(QIcon(":/icons/user_suit.png"));
197 secondButton->setIconSize(QSize(16, 16));
198 secondButton->setMinimumWidth(120);
199 secondButton->disconnect();
200 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
202 static const bool isQt5 = (QT_VERSION >= QT_VERSION_CHECK(5,0,0));
203 QPushButton *thirdButton = addButton(isQt5 ? tr("About Qt5") : tr("About Qt4"), QMessageBox::AcceptRole);
204 thirdButton->setIcon(QIcon(":/icons/qt.png"));
205 thirdButton->setIconSize(QSize(16, 16));
206 thirdButton->setMinimumWidth(120);
207 thirdButton->disconnect();
208 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
210 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
211 fourthButton->setIcon(QIcon(":/icons/cross.png"));
212 fourthButton->setIconSize(QSize(16, 16));
213 fourthButton->setMinimumWidth(90);
215 QPixmap disque(":/images/Disque.png");
216 QRect screenGeometry = QApplication::desktop()->availableGeometry();
217 m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
218 m_disque->installEventFilter(this);
219 m_disque->setStyleSheet("background:transparent;");
220 m_disque->setAttribute(Qt::WA_TranslucentBackground);
221 m_disque->setGeometry(qrand() % (screenGeometry.width() - disque.width()), qrand() % (screenGeometry.height() - disque.height()), disque.width(), disque.height());
222 m_disque->setPixmap(disque);
223 m_disque->setWindowOpacity(0.01);
224 m_disque->show();
225 m_disqueFlags[0] = (qrand() > (RAND_MAX/2));
226 m_disqueFlags[1] = (qrand() > (RAND_MAX/2));
227 m_disqueTimer = new QTimer;
228 connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
229 m_disqueTimer->setInterval(10);
230 m_disqueTimer->start();
233 m_firstShow = firstStart;
236 AboutDialog::~AboutDialog(void)
238 if(m_disque)
240 m_disque->close();
241 LAMEXP_DELETE(m_disque);
243 if(m_disqueTimer)
245 m_disqueTimer->stop();
246 LAMEXP_DELETE(m_disqueTimer);
248 for(int i = 0; i < 4; i++)
250 LAMEXP_DELETE(m_cartoon[i]);
255 ////////////////////////////////////////////////////////////
256 // Public Functions
257 ////////////////////////////////////////////////////////////
259 int AboutDialog::exec()
261 if(m_settings->soundsEnabled())
263 if(m_firstShow)
265 if(!playResoureSound("imageres.dll", 5080, true))
267 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
270 else
272 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
276 switch(QMessageBox::exec())
278 case 1:
279 return 1;
280 break;
281 case 2:
282 return -1;
283 break;
284 default:
285 return 0;
286 break;
290 ////////////////////////////////////////////////////////////
291 // Slots
292 ////////////////////////////////////////////////////////////
294 #define TEMP_HIDE_DISQUE(CMD) \
295 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}
297 void AboutDialog::enableButtons(void)
299 const QList<QAbstractButton*> buttonList = buttons();
301 for(int i = 0; i < buttonList.count(); i++)
303 buttonList.at(i)->setEnabled(true);
306 setCursor(QCursor(Qt::ArrowCursor));
309 void AboutDialog::openLicenseText(void)
311 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
314 void AboutDialog::showAboutQt(void)
316 TEMP_HIDE_DISQUE
318 QMessageBox::aboutQt(this);
322 void AboutDialog::showAboutContributors(void)
324 TEMP_HIDE_DISQUE
326 QString contributorsAboutText;
328 contributorsAboutText += QString("<h3>%1</h3>").arg(NOBR(tr("The following people have contributed to LameXP:")));
329 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
330 contributorsAboutText += "<table style=\"margin-top:5px\">";
331 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
333 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
334 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(flagIcon);
335 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
336 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td><td><a href=\"mailto:%2\">&lt;%2&gt;</a></td></tr>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcName), g_lamexp_contributors[i].pcMail);
338 contributorsAboutText += "</table>";
339 contributorsAboutText += "<br><br>";
340 contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
342 QMessageBox *contributorsAboutBox = new QMessageBox(this);
343 contributorsAboutBox->setText(contributorsAboutText);
344 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
346 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
347 closeButton->setIcon(QIcon(":/icons/cross.png"));
348 closeButton->setMinimumWidth(90);
350 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
351 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
352 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
353 contributorsAboutBox->exec();
355 LAMEXP_DELETE(contributorsAboutBox);
359 void AboutDialog::showMoreAbout(void)
361 TEMP_HIDE_DISQUE
363 QString moreAboutText;
365 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
366 moreAboutText += "<div style=\"margin-left:-25px;font-size:7pt;white-space:nowrap\"><table><tr><td><ul>";
368 moreAboutText += makeToolText
370 tr("LAME - OpenSource mp3 Encoder"),
371 "lame.exe", "v?.??, Final-?",
372 tr("Released under the terms of the GNU Lesser General Public License."),
373 "http://lame.sourceforge.net/"
375 moreAboutText += makeToolText
377 tr("OggEnc - Ogg Vorbis Encoder"),
378 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
379 tr("Completely open and patent-free audio encoding technology."),
380 "http://www.vorbis.com/"
382 moreAboutText += makeToolText
384 tr("Nero AAC Reference MPEG-4 Encoder"),
385 "neroAacEnc.exe", "v?.?.?.?",
386 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
387 neroAacUrl,
388 tr("Available from vendor web-site as free download:")
390 moreAboutText += makeToolText
392 tr("Aften - A/52 audio encoder"),
393 "aften.exe", "v?.?.?",
394 tr("Released under the terms of the GNU Lesser General Public License."),
395 "http://aften.sourceforge.net/"
397 moreAboutText += makeToolText
399 tr("FLAC - Free Lossless Audio Codec"),
400 "flac.exe", "v?.?.?",
401 tr("Open and patent-free lossless audio compression technology."),
402 "http://flac.sourceforge.net/"
404 moreAboutText += makeToolText
406 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
407 "mpg123.exe", "v?.??.?",
408 tr("Released under the terms of the GNU Lesser General Public License."),
409 "http://www.mpg123.de/"
411 moreAboutText += makeToolText
413 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
414 "faad.exe", "v?.?",
415 tr("Released under the terms of the GNU General Public License."),
416 "http://www.audiocoding.com/"
418 moreAboutText += makeToolText
420 tr("AC3Filter Tools - AC3/DTS Decoder"),
421 "valdec.exe", "v?.??",
422 tr("Released under the terms of the GNU Lesser General Public License."),
423 "http://www.ac3filter.net/projects/tools"
425 moreAboutText += makeToolText
427 tr("WavPack - Hybrid Lossless Compression"),
428 "wvunpack.exe", "v?.??.?",
429 tr("Completely open audio compression format."),
430 "http://www.wavpack.com/"
432 moreAboutText += makeToolText
434 tr("Musepack - Living Audio Compression"),
435 "mpcdec.exe", "r???",
436 tr("Released under the terms of the GNU Lesser General Public License."),
437 "http://www.musepack.net/"
439 moreAboutText += makeToolText
441 tr("Monkey's Audio - Lossless Audio Compressor"),
442 "mac.exe", "v?.??",
443 tr("Freely available source code, simple SDK and non-restrictive licensing."),
444 "http://www.monkeysaudio.com/"
446 moreAboutText += QString
448 "</ul></td><td><ul>" /* ----------------------------------------- */
450 moreAboutText += makeToolText
452 tr("Shorten - Lossless Audio Compressor"),
453 "shorten.exe", "v?.?.?",
454 tr("Released under the terms of the GNU Lesser General Public License."),
455 "http://etree.org/shnutils/shorten/"
457 moreAboutText += makeToolText
459 tr("Speex - Free Codec For Free Speech"),
460 "speexdec.exe", "v?.?",
461 tr("Open Source patent-free audio format designed for speech."),
462 "http://www.speex.org/"
464 moreAboutText += makeToolText
466 tr("The True Audio - Lossless Audio Codec"),
467 "tta.exe", "v?.?",
468 tr("Released under the terms of the GNU Lesser General Public License."),
469 "http://tta.sourceforge.net/"
471 moreAboutText += makeToolText
473 tr("ALAC Decoder"),
474 "alac.exe", "v?.?.?",
475 tr("Copyright (c) 2004 David Hammerton. Contributions by Cody Brocious."),
476 "http://craz.net/programs/itunes/alac.html"
478 moreAboutText += makeToolText
480 tr("wma2wav - Dump WMA files to Wave Audio"),
481 "wma2wav.exe", "????-??-??",
482 tr("Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved."),
483 "http://forum.doom9.org/showthread.php?t=140273"
485 moreAboutText += makeToolText
487 tr("avs2wav - Avisynth to Wave Audio converter"),
488 "avs2wav.exe", "v?.?",
489 tr("By Jory Stone <jcsston@toughguy.net> and LoRd_MuldeR <mulder2@gmx.de>."),
490 "http://forum.doom9.org/showthread.php?t=70882"
492 moreAboutText += makeToolText
494 tr("dcaenc"),
495 "dcaenc.exe", "????-??-??",
496 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
497 "http://gitorious.org/dtsenc/dtsenc/trees/master"
499 moreAboutText += makeToolText
501 tr("MediaInfo - Media File Analysis Tool"),
502 "mediainfo.exe", "v?.?.??",
503 tr("Released under the terms of the GNU Lesser General Public License."),
504 "http://mediainfo.sourceforge.net/"
506 moreAboutText += makeToolText
508 tr("SoX - Sound eXchange"),
509 "sox.exe", "v??.?.?",
510 tr("Released under the terms of the GNU Lesser General Public License."),
511 "http://sox.sourceforge.net/"
513 moreAboutText += makeToolText
515 tr("GnuPG - The GNU Privacy Guard"),
516 "gpgv.exe", "v?.?.??",
517 tr("Released under the terms of the GNU Lesser General Public License."),
518 "http://www.gnupg.org/"
520 moreAboutText += makeToolText
522 tr("GNU Wget - Software for retrieving files using HTTP"),
523 "wget.exe", "v?.??.?",
524 tr("Released under the terms of the GNU Lesser General Public License."),
525 "http://www.gnu.org/software/wget/"
527 //moreAboutText += makeToolText
529 // tr("Silk Icons - Over 700 icons in PNG format"),
530 // QString(), "v1.3",
531 // tr("By Mark James, released under the Creative Commons 'by' License."),
532 // "http://www.famfamfam.com/lab/icons/silk/"
533 //);
534 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
536 NOBR(tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of third-party software used in LameXP belongs to the individual authors."))
539 QMessageBox *moreAboutBox = new QMessageBox(this);
540 moreAboutBox->setText(moreAboutText);
541 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
543 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
544 closeButton->setIcon(QIcon(":/icons/cross.png"));
545 closeButton->setMinimumWidth(90);
547 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
548 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
549 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
550 moreAboutBox->exec();
552 LAMEXP_DELETE(moreAboutBox);
556 void AboutDialog::moveDisque(void)
558 int delta = 2;
559 LARGE_INTEGER perfCount, perfFrequ;
561 if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount))
563 if(m_disqueDelay != _I64_MAX)
565 const double delay = static_cast<double>(perfCount.QuadPart) - static_cast<double>(m_disqueDelay);
566 delta = qMax(1, qMin(128, static_cast<int>(ceil(delay / static_cast<double>(perfFrequ.QuadPart) / 0.00512))));
568 m_disqueDelay = perfCount.QuadPart;
571 if(m_disque)
573 QRect screenGeometry = QApplication::desktop()->availableGeometry();
574 const int minX = screenGeometry.left();
575 const int maxX = screenGeometry.width() - m_disque->width() + screenGeometry.left();
576 const int minY = screenGeometry.top();
577 const int maxY = screenGeometry.height() - m_disque->height() + screenGeometry.top();
579 QPoint pos = m_disque->pos();
580 pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta);
581 pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta);
583 if(pos.x() <= minX)
585 m_disqueFlags[0] = true;
586 pos.setX(minX);
587 m_rotateNext = true;
589 else if(pos.x() >= maxX)
591 m_disqueFlags[0] = false;
592 pos.setX(maxX);
593 m_rotateNext = true;
595 if(pos.y() <= minY)
597 m_disqueFlags[1] = true;
598 pos.setY(minY);
599 m_rotateNext = true;
601 else if(pos.y() >= maxY)
603 m_disqueFlags[1] = false;
604 pos.setY(maxY);
605 m_rotateNext = true;
608 m_disque->move(pos);
610 if(m_rotateNext)
612 QPixmap *cartoon = NULL;
613 if(m_disqueFlags[0] == true && m_disqueFlags[1] != true) cartoon = m_cartoon[0];
614 if(m_disqueFlags[0] == true && m_disqueFlags[1] == true) cartoon = m_cartoon[1];
615 if(m_disqueFlags[0] != true && m_disqueFlags[1] == true) cartoon = m_cartoon[2];
616 if(m_disqueFlags[0] != true && m_disqueFlags[1] != true) cartoon = m_cartoon[3];
617 if(cartoon)
619 m_disque->setPixmap(*cartoon);
620 m_disque->resize(cartoon->size());
622 m_rotateNext = false;
625 if(m_disque->windowOpacity() < 0.9)
627 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
631 ////////////////////////////////////////////////////////////
632 // Protected Functions
633 ////////////////////////////////////////////////////////////
635 void AboutDialog::showEvent(QShowEvent *e)
637 QDialog::showEvent(e);
638 if(m_firstShow)
640 const QList<QAbstractButton*> buttonList = buttons();
642 for(int i = 1; i < buttonList.count(); i++)
644 buttonList.at(i)->setEnabled(false);
647 QTimer::singleShot(5000, this, SLOT(enableButtons()));
648 setCursor(QCursor(Qt::WaitCursor));
652 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
654 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
656 QPixmap cartoon(":/images/Cartoon.png");
657 for(int i = 0; i < 4; i++)
659 if(!m_cartoon[i])
661 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
662 m_rotateNext = true;
665 QDesktopServices::openUrl(QUrl(disqueUrl));
668 return false;
671 ////////////////////////////////////////////////////////////
672 // Private Functions
673 ////////////////////////////////////////////////////////////
675 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
677 QString toolText, verStr(toolVerFmt);
679 if(!toolBin.isEmpty())
681 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
684 toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));
685 toolText += QString("%1<br>").arg(NOBR(toolLicense));
686 if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(NOBR(extraInfo));
687 toolText += QString("<nobr>%1</nobr>").arg(LINK(toolWebsite));
688 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
690 return toolText;
694 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
696 HMODULE module = 0;
697 DWORD flags = SND_RESOURCE;
698 bool result = false;
700 QFileInfo libraryFile(library);
701 if(!libraryFile.isAbsolute())
703 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
704 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
705 unsigned int result = GetSystemDirectory(buffer, buffSize);
706 if(result > 0 && result < buffSize)
708 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
710 _freea(buffer);
713 if(async)
715 flags |= SND_ASYNC;
717 else
719 flags |= SND_SYNC;
722 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
724 if(module)
726 result = PlaySound((LPCTSTR) soundId, module, flags);
727 FreeLibrary(module);
730 return result;