Bump version.
[LameXP.git] / src / Dialog_About.cpp
blobab3a3e27af79e73226cd89621585679a3e8e2de5
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 {"tw", L"繁体中文", L"456Vv", "123@456vv.com" },
71 {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
72 {"zh", L"简体中文", L"456Vv", "123@456vv.com" },
73 {NULL, NULL, NULL, NULL}
76 ////////////////////////////////////////////////////////////
77 // Constructor
78 ////////////////////////////////////////////////////////////
80 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
82 QMessageBox(parent),
83 m_settings(settings),
84 m_disque(NULL),
85 m_disqueTimer(NULL),
86 m_rotateNext(false),
87 m_disqueDelay(_I64_MAX)
89 const QString versionStr = QString().sprintf
91 "Version %d.%02d %s, Build %d [%s], %s %s, Qt v%s",
92 lamexp_version_major(),
93 lamexp_version_minor(),
94 lamexp_version_release(),
95 lamexp_version_build(),
96 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
97 lamexp_version_compiler(),
98 lamexp_version_arch(),
99 qVersion()
101 const QString copyrightStr = QString().sprintf
103 "Copyright (C) 2004-%04d LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.",
104 qMax(lamexp_version_date().year(), QDate::currentDate().year())
107 for(int i = 0; i < 4; i++)
109 m_cartoon[i] = NULL;
112 QString aboutText;
114 aboutText += QString("<h2>%1</h2>").arg(NOBR(tr("LameXP - Audio Encoder Front-end")));
115 aboutText += QString("<b>%1</b><br>").arg(NOBR(copyrightStr));
116 aboutText += QString("<b>%1</b><br><br>").arg(NOBR(versionStr));
117 aboutText += QString("%1<br>").arg(NOBR(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url()))));
119 if(LAMEXP_DEBUG)
121 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
122 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))));
124 else if(lamexp_version_demo())
126 int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
127 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))));
130 aboutText += "<hr><br>";
131 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
132 aboutText += "modify it under the terms of the GNU General Public License<br>";
133 aboutText += "as published by the Free Software Foundation; either version 2<br>";
134 aboutText += "of the License, or (at your option) any later version.<br><br>";
135 aboutText += "This program is distributed in the hope that it will be useful,<br>";
136 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
137 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
138 aboutText += "GNU General Public License for more details.<br><br>";
139 aboutText += "You should have received a copy of the GNU General Public License<br>";
140 aboutText += "along with this program; if not, write to the Free Software<br>";
141 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110&minus;1301, USA.</tt></nobr><br>";
142 aboutText += "<hr><table><tr>";
143 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
144 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 !!!"));
145 aboutText += "</tr></table><hr><br>";
146 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/")));
148 setText(aboutText);
149 setIconPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
150 setWindowTitle(tr("About LameXP"));
152 if(firstStart)
154 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
155 firstButton->setIcon(QIcon(":/icons/script.png"));
156 firstButton->setIconSize(QSize(16, 16));
157 firstButton->setMinimumWidth(135);
158 firstButton->disconnect();
159 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
161 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
162 secondButton->setIcon(QIcon(":/icons/accept.png"));
163 secondButton->setIconSize(QSize(16, 16));
164 secondButton->setMinimumWidth(120);
166 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
167 thirdButton->setIcon(QIcon(":/icons/delete.png"));
168 thirdButton->setIconSize(QSize(16, 16));
169 thirdButton->setMinimumWidth(120);
170 thirdButton->setEnabled(false);
172 else
174 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
175 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
176 firstButton->setIconSize(QSize(16, 16));
177 firstButton->setMinimumWidth(120);
178 firstButton->disconnect();
179 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
181 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
182 secondButton->setIcon(QIcon(":icons/user_suit.png"));
183 secondButton->setIconSize(QSize(16, 16));
184 secondButton->setMinimumWidth(120);
185 secondButton->disconnect();
186 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
188 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
189 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
190 thirdButton->setIconSize(QSize(16, 16));
191 thirdButton->setMinimumWidth(120);
192 thirdButton->disconnect();
193 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
195 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
196 fourthButton->setIcon(QIcon(":/icons/cross.png"));
197 fourthButton->setIconSize(QSize(16, 16));
198 fourthButton->setMinimumWidth(90);
200 QPixmap disque(":/images/Disque.png");
201 QRect screenGeometry = QApplication::desktop()->availableGeometry();
202 m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
203 m_disque->installEventFilter(this);
204 m_disque->setStyleSheet("background:transparent;");
205 m_disque->setAttribute(Qt::WA_TranslucentBackground);
206 m_disque->setGeometry(qrand() % (screenGeometry.width() - disque.width()), qrand() % (screenGeometry.height() - disque.height()), disque.width(), disque.height());
207 m_disque->setPixmap(disque);
208 m_disque->setWindowOpacity(0.01);
209 m_disque->show();
210 m_disqueFlags[0] = (qrand() > (RAND_MAX/2));
211 m_disqueFlags[1] = (qrand() > (RAND_MAX/2));
212 m_disqueTimer = new QTimer;
213 connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
214 m_disqueTimer->setInterval(10);
215 m_disqueTimer->start();
218 m_firstShow = firstStart;
221 AboutDialog::~AboutDialog(void)
223 if(m_disque)
225 m_disque->close();
226 LAMEXP_DELETE(m_disque);
228 if(m_disqueTimer)
230 m_disqueTimer->stop();
231 LAMEXP_DELETE(m_disqueTimer);
233 for(int i = 0; i < 4; i++)
235 LAMEXP_DELETE(m_cartoon[i]);
240 ////////////////////////////////////////////////////////////
241 // Public Functions
242 ////////////////////////////////////////////////////////////
244 int AboutDialog::exec()
246 if(m_settings->soundsEnabled())
248 if(m_firstShow)
250 if(!playResoureSound("imageres.dll", 5080, true))
252 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
255 else
257 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
261 switch(QMessageBox::exec())
263 case 1:
264 return 1;
265 break;
266 case 2:
267 return -1;
268 break;
269 default:
270 return 0;
271 break;
275 ////////////////////////////////////////////////////////////
276 // Slots
277 ////////////////////////////////////////////////////////////
279 #define TEMP_HIDE_DISQUE(CMD) \
280 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}
282 void AboutDialog::enableButtons(void)
284 const QList<QAbstractButton*> buttonList = buttons();
286 for(int i = 0; i < buttonList.count(); i++)
288 buttonList.at(i)->setEnabled(true);
291 setCursor(QCursor(Qt::ArrowCursor));
294 void AboutDialog::openLicenseText(void)
296 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
299 void AboutDialog::showAboutQt(void)
301 TEMP_HIDE_DISQUE
303 QMessageBox::aboutQt(this);
307 void AboutDialog::showAboutContributors(void)
309 TEMP_HIDE_DISQUE
311 QString contributorsAboutText;
313 contributorsAboutText += QString("<h3>%1</h3>").arg(NOBR(tr("The following people have contributed to LameXP:")));
314 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
315 contributorsAboutText += "<table style=\"margin-top:5px\">";
316 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
318 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
319 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(flagIcon);
320 contributorsAboutText += QString("<td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
321 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);
323 contributorsAboutText += "</table>";
324 contributorsAboutText += "<br><br>";
325 contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
327 QMessageBox *contributorsAboutBox = new QMessageBox(this);
328 contributorsAboutBox->setText(contributorsAboutText);
329 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
331 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
332 closeButton->setIcon(QIcon(":/icons/cross.png"));
333 closeButton->setMinimumWidth(90);
335 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
336 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
337 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
338 contributorsAboutBox->exec();
340 LAMEXP_DELETE(contributorsAboutBox);
344 void AboutDialog::showMoreAbout(void)
346 TEMP_HIDE_DISQUE
348 QString moreAboutText;
350 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
351 moreAboutText += "<div style=\"margin-left:-25px;font-size:7pt;white-space:nowrap\"><table><tr><td><ul>";
353 moreAboutText += makeToolText
355 tr("LAME - OpenSource mp3 Encoder"),
356 "lame.exe", "v?.??, Final-?",
357 tr("Released under the terms of the GNU Lesser General Public License."),
358 "http://lame.sourceforge.net/"
360 moreAboutText += makeToolText
362 tr("OggEnc - Ogg Vorbis Encoder"),
363 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
364 tr("Completely open and patent-free audio encoding technology."),
365 "http://www.vorbis.com/"
367 moreAboutText += makeToolText
369 tr("Nero AAC Reference MPEG-4 Encoder"),
370 "neroAacEnc.exe", "v?.?.?.?",
371 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
372 neroAacUrl,
373 tr("Available from vendor web-site as free download:")
375 moreAboutText += makeToolText
377 tr("Aften - A/52 audio encoder"),
378 "aften.exe", "v?.?.?",
379 tr("Released under the terms of the GNU Lesser General Public License."),
380 "http://aften.sourceforge.net/"
382 moreAboutText += makeToolText
384 tr("FLAC - Free Lossless Audio Codec"),
385 "flac.exe", "v?.?.?",
386 tr("Open and patent-free lossless audio compression technology."),
387 "http://flac.sourceforge.net/"
389 moreAboutText += makeToolText
391 tr("mpg123 - Fast Console MPEG Audio Player/Decoder"),
392 "mpg123.exe", "v?.??.?",
393 tr("Released under the terms of the GNU Lesser General Public License."),
394 "http://www.mpg123.de/"
396 moreAboutText += makeToolText
398 tr("FAAD - OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
399 "faad.exe", "v?.?",
400 tr("Released under the terms of the GNU General Public License."),
401 "http://www.audiocoding.com/"
403 moreAboutText += makeToolText
405 tr("AC3Filter Tools - AC3/DTS Decoder"),
406 "valdec.exe", "v?.??",
407 tr("Released under the terms of the GNU Lesser General Public License."),
408 "http://www.ac3filter.net/projects/tools"
410 moreAboutText += makeToolText
412 tr("WavPack - Hybrid Lossless Compression"),
413 "wvunpack.exe", "v?.??.?",
414 tr("Completely open audio compression format."),
415 "http://www.wavpack.com/"
417 moreAboutText += makeToolText
419 tr("Musepack - Living Audio Compression"),
420 "mpcdec.exe", "r???",
421 tr("Released under the terms of the GNU Lesser General Public License."),
422 "http://www.musepack.net/"
424 moreAboutText += makeToolText
426 tr("Monkey's Audio - Lossless Audio Compressor"),
427 "mac.exe", "v?.??",
428 tr("Freely available source code, simple SDK and non-restrictive licensing."),
429 "http://www.monkeysaudio.com/"
431 moreAboutText += QString
433 "</ul></td><td><ul>" /* ----------------------------------------- */
435 moreAboutText += makeToolText
437 tr("Shorten - Lossless Audio Compressor"),
438 "shorten.exe", "v?.?.?",
439 tr("Released under the terms of the GNU Lesser General Public License."),
440 "http://etree.org/shnutils/shorten/"
442 moreAboutText += makeToolText
444 tr("Speex - Free Codec For Free Speech"),
445 "speexdec.exe", "v?.?",
446 tr("Open Source patent-free audio format designed for speech."),
447 "http://www.speex.org/"
449 moreAboutText += makeToolText
451 tr("The True Audio - Lossless Audio Codec"),
452 "tta.exe", "v?.?",
453 tr("Released under the terms of the GNU Lesser General Public License."),
454 "http://tta.sourceforge.net/"
456 moreAboutText += makeToolText
458 tr("ALAC Decoder"),
459 "alac.exe", "v?.?.?",
460 tr("Copyright (c) 2004 David Hammerton. Contributions by Cody Brocious."),
461 "http://craz.net/programs/itunes/alac.html"
463 moreAboutText += makeToolText
465 tr("wma2wav - Dump WMA files to Wave Audio"),
466 "wma2wav.exe", "????-??-??",
467 tr("Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved."),
468 "http://forum.doom9.org/showthread.php?t=140273"
470 moreAboutText += makeToolText
472 tr("avs2wav - Avisynth to Wave Audio converter"),
473 "avs2wav.exe", "v?.?",
474 tr("By Jory Stone <jcsston@toughguy.net> and LoRd_MuldeR <mulder2@gmx.de>."),
475 "http://forum.doom9.org/showthread.php?t=70882"
477 moreAboutText += makeToolText
479 tr("dcaenc"),
480 "dcaenc.exe", "????-??-??",
481 tr("Copyright (c) 2008-2011 Alexander E. Patrakov. Distributed under the LGPL."),
482 "http://gitorious.org/dtsenc/dtsenc/trees/master"
484 moreAboutText += makeToolText
486 tr("MediaInfo - Media File Analysis Tool"),
487 "mediainfo.exe", "v?.?.??",
488 tr("Released under the terms of the GNU Lesser General Public License."),
489 "http://mediainfo.sourceforge.net/"
491 moreAboutText += makeToolText
493 tr("SoX - Sound eXchange"),
494 "sox.exe", "v??.?.?",
495 tr("Released under the terms of the GNU Lesser General Public License."),
496 "http://sox.sourceforge.net/"
498 moreAboutText += makeToolText
500 tr("GnuPG - The GNU Privacy Guard"),
501 "gpgv.exe", "v?.?.??",
502 tr("Released under the terms of the GNU Lesser General Public License."),
503 "http://www.gnupg.org/"
505 moreAboutText += makeToolText
507 tr("GNU Wget - Software for retrieving files using HTTP"),
508 "wget.exe", "v?.??.?",
509 tr("Released under the terms of the GNU Lesser General Public License."),
510 "http://www.gnu.org/software/wget/"
512 //moreAboutText += makeToolText
514 // tr("Silk Icons - Over 700 icons in PNG format"),
515 // QString(), "v1.3",
516 // tr("By Mark James, released under the Creative Commons 'by' License."),
517 // "http://www.famfamfam.com/lab/icons/silk/"
518 //);
519 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
521 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."))
524 QMessageBox *moreAboutBox = new QMessageBox(this);
525 moreAboutBox->setText(moreAboutText);
526 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
528 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
529 closeButton->setIcon(QIcon(":/icons/cross.png"));
530 closeButton->setMinimumWidth(90);
532 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
533 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
534 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
535 moreAboutBox->exec();
537 LAMEXP_DELETE(moreAboutBox);
541 void AboutDialog::moveDisque(void)
543 int delta = 2;
544 LARGE_INTEGER perfCount, perfFrequ;
546 if(QueryPerformanceFrequency(&perfFrequ) && QueryPerformanceCounter(&perfCount))
548 if(m_disqueDelay != _I64_MAX)
550 const double delay = static_cast<double>(perfCount.QuadPart) - static_cast<double>(m_disqueDelay);
551 delta = qMax(1, qMin(128, static_cast<int>(ceil(delay / static_cast<double>(perfFrequ.QuadPart) / 0.00512))));
553 m_disqueDelay = perfCount.QuadPart;
556 if(m_disque)
558 QRect screenGeometry = QApplication::desktop()->availableGeometry();
559 const int minX = screenGeometry.left();
560 const int maxX = screenGeometry.width() - m_disque->width() + screenGeometry.left();
561 const int minY = screenGeometry.top();
562 const int maxY = screenGeometry.height() - m_disque->height() + screenGeometry.top();
564 QPoint pos = m_disque->pos();
565 pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta);
566 pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta);
568 if(pos.x() <= minX)
570 m_disqueFlags[0] = true;
571 pos.setX(minX);
572 m_rotateNext = true;
574 else if(pos.x() >= maxX)
576 m_disqueFlags[0] = false;
577 pos.setX(maxX);
578 m_rotateNext = true;
580 if(pos.y() <= minY)
582 m_disqueFlags[1] = true;
583 pos.setY(minY);
584 m_rotateNext = true;
586 else if(pos.y() >= maxY)
588 m_disqueFlags[1] = false;
589 pos.setY(maxY);
590 m_rotateNext = true;
593 m_disque->move(pos);
595 if(m_rotateNext)
597 QPixmap *cartoon = NULL;
598 if(m_disqueFlags[0] == true && m_disqueFlags[1] != true) cartoon = m_cartoon[0];
599 if(m_disqueFlags[0] == true && m_disqueFlags[1] == true) cartoon = m_cartoon[1];
600 if(m_disqueFlags[0] != true && m_disqueFlags[1] == true) cartoon = m_cartoon[2];
601 if(m_disqueFlags[0] != true && m_disqueFlags[1] != true) cartoon = m_cartoon[3];
602 if(cartoon)
604 m_disque->setPixmap(*cartoon);
605 m_disque->resize(cartoon->size());
607 m_rotateNext = false;
610 if(m_disque->windowOpacity() < 0.9)
612 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
616 ////////////////////////////////////////////////////////////
617 // Protected Functions
618 ////////////////////////////////////////////////////////////
620 void AboutDialog::showEvent(QShowEvent *e)
622 QDialog::showEvent(e);
623 if(m_firstShow)
625 const QList<QAbstractButton*> buttonList = buttons();
627 for(int i = 1; i < buttonList.count(); i++)
629 buttonList.at(i)->setEnabled(false);
632 QTimer::singleShot(5000, this, SLOT(enableButtons()));
633 setCursor(QCursor(Qt::WaitCursor));
637 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
639 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
641 QPixmap cartoon(":/images/Cartoon.png");
642 for(int i = 0; i < 4; i++)
644 if(!m_cartoon[i])
646 m_cartoon[i] = new QPixmap(cartoon.transformed(QMatrix().rotate(static_cast<double>(i*90) + 45.0), Qt::SmoothTransformation));
647 m_rotateNext = true;
650 QDesktopServices::openUrl(QUrl(disqueUrl));
653 return false;
656 ////////////////////////////////////////////////////////////
657 // Private Functions
658 ////////////////////////////////////////////////////////////
660 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
662 QString toolText, verStr(toolVerFmt);
664 if(!toolBin.isEmpty())
666 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
669 toolText += QString("<li>%1<br>").arg(NOBR(QString("<b>%1 (%2)</b>").arg(toolName, verStr)));
670 toolText += QString("%1<br>").arg(NOBR(toolLicense));
671 if(!extraInfo.isEmpty()) toolText += QString("<i>%1</i><br>").arg(NOBR(extraInfo));
672 toolText += QString("<nobr>%1</nobr>").arg(LINK(toolWebsite));
673 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
675 return toolText;
679 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
681 HMODULE module = 0;
682 DWORD flags = SND_RESOURCE;
683 bool result = false;
685 QFileInfo libraryFile(library);
686 if(!libraryFile.isAbsolute())
688 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
689 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
690 unsigned int result = GetSystemDirectory(buffer, buffSize);
691 if(result > 0 && result < buffSize)
693 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
695 _freea(buffer);
698 if(async)
700 flags |= SND_ASYNC;
702 else
704 flags |= SND_SYNC;
707 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
709 if(module)
711 result = PlaySound((LPCTSTR) soundId, module, flags);
712 FreeLibrary(module);
715 return result;