1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
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.
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"
26 #include "Model_Settings.h"
29 #include <QApplication>
31 #include <QPushButton>
32 #include <QDesktopServices>
37 #include <QDesktopWidget>
43 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
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*/
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 ////////////////////////////////////////////////////////////
73 ////////////////////////////////////////////////////////////
75 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
82 const QString versionStr = QString().sprintf
84 "Version %d.%02d %s, Build %d [%s], %s, Qt v%s",
85 lamexp_version_major(),
86 lamexp_version_minor(),
87 lamexp_version_release(),
88 lamexp_version_build(),
89 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
90 lamexp_version_compiler(),
96 aboutText += QString("<h2>%1</h2>").arg(tr("LameXP − Audio Encoder Front-end"));
97 aboutText += QString("<b>Copyright (C) 2004-%1 LoRd_MuldeR <MuldeR2@GMX.de>. Some rights reserved.</b><br>").arg(max(lamexp_version_date().year(), QDate::currentDate().year()));
98 aboutText += QString("<b>%1</b><br><br>").arg(versionStr);
99 aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
103 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
104 aboutText += QString("<hr><nobr><font color=\"crimson\">!!! %3 DEBUG BUILD %3 Expires at: %1 %3 Days left: %2 %3 DEBUG BUILD %3 !!!</font></nobr>").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft), "−−−");
106 else if(lamexp_version_demo())
108 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
109 aboutText += QString("<hr><nobr><font color=\"crimson\">%1</font></nobr>").arg(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft)));
112 aboutText += "<hr><br>";
113 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
114 aboutText += "modify it under the terms of the GNU General Public License<br>";
115 aboutText += "as published by the Free Software Foundation; either version 2<br>";
116 aboutText += "of the License, or (at your option) any later version.<br><br>";
117 aboutText += "This program is distributed in the hope that it will be useful,<br>";
118 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
119 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
120 aboutText += "GNU General Public License for more details.<br><br>";
121 aboutText += "You should have received a copy of the GNU General Public License<br>";
122 aboutText += "along with this program; if not, write to the Free Software<br>";
123 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
124 aboutText += "<hr><table><tr>";
125 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td> </td>";
126 aboutText += QString("<td><font color=\"darkred\">%1</font></td>").arg(tr("Note: LameXP is free software. Do <b>not</b> pay money to obtain or use LameXP! If some third-party website tries to make you pay for downloading LameXP, you should <b>not</b> respond to the offer !!!"));
127 aboutText += "</tr></table><hr><br>";
128 aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
131 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
132 setWindowTitle(tr("About LameXP"));
136 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
137 firstButton->setIcon(QIcon(":/icons/script.png"));
138 firstButton->setIconSize(QSize(16, 16));
139 firstButton->setMinimumWidth(135);
140 firstButton->disconnect();
141 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
143 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
144 secondButton->setIcon(QIcon(":/icons/accept.png"));
145 secondButton->setIconSize(QSize(16, 16));
146 secondButton->setMinimumWidth(120);
148 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
149 thirdButton->setIcon(QIcon(":/icons/delete.png"));
150 thirdButton->setIconSize(QSize(16, 16));
151 thirdButton->setMinimumWidth(120);
152 thirdButton->setEnabled(false);
156 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
157 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
158 firstButton->setIconSize(QSize(16, 16));
159 firstButton->setMinimumWidth(120);
160 firstButton->disconnect();
161 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
163 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
164 secondButton->setIcon(QIcon(":icons/user_suit.png"));
165 secondButton->setIconSize(QSize(16, 16));
166 secondButton->setMinimumWidth(120);
167 secondButton->disconnect();
168 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
170 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
171 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
172 thirdButton->setIconSize(QSize(16, 16));
173 thirdButton->setMinimumWidth(120);
174 thirdButton->disconnect();
175 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
177 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
178 fourthButton->setIcon(QIcon(":/icons/cross.png"));
179 fourthButton->setIconSize(QSize(16, 16));
180 fourthButton->setMinimumWidth(90);
182 QPixmap disque(":/images/Disque.png");
183 m_screenGeometry = QApplication::desktop()->availableGeometry();
184 m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
185 m_disque->installEventFilter(this);
186 m_disque->setStyleSheet("background:transparent;");
187 m_disque->setAttribute(Qt::WA_TranslucentBackground);
188 m_disque->setGeometry(qrand() % (m_screenGeometry.width() - disque.width()), qrand() % (m_screenGeometry.height() - disque.height()), disque.width(), disque.height());
189 m_disque->setPixmap(disque);
190 m_disque->setWindowOpacity(0.01);
192 m_disqueTimer = new QTimer;
193 connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
194 m_disqueTimer->setInterval(10);
195 m_disqueTimer->start();
196 m_disqueFlags[0] = true;
197 m_disqueFlags[1] = true;
200 m_firstShow = firstStart;
203 AboutDialog::~AboutDialog(void)
208 LAMEXP_DELETE(m_disque);
212 m_disqueTimer->stop();
213 LAMEXP_DELETE(m_disqueTimer);
218 ////////////////////////////////////////////////////////////
220 ////////////////////////////////////////////////////////////
222 int AboutDialog::exec()
224 if(m_settings->soundsEnabled())
228 if(!playResoureSound("imageres.dll", 5080, true))
230 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
235 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
239 switch(QMessageBox::exec())
253 ////////////////////////////////////////////////////////////
255 ////////////////////////////////////////////////////////////
257 void AboutDialog::enableButtons(void)
259 const QList<QAbstractButton*> buttonList = buttons();
261 for(int i = 0; i < buttonList.count(); i++)
263 buttonList.at(i)->setEnabled(true);
266 setCursor(QCursor(Qt::ArrowCursor));
269 void AboutDialog::openLicenseText(void)
271 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
274 void AboutDialog::showAboutQt(void)
276 QMessageBox::aboutQt(this);
279 void AboutDialog::showAboutContributors(void)
281 QString contributorsAboutText;
283 contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
284 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
285 contributorsAboutText += "<table style=\"margin-top:5px\">";
286 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
288 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
289 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td> </td>").arg(flagIcon);
290 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td> </td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
291 contributorsAboutText += QString("<td valign=\"middle\">%3</td><td> </td><td><%4></td></tr>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcName), g_lamexp_contributors[i].pcMail);
293 contributorsAboutText += "</table>";
294 contributorsAboutText += "<br><br>";
295 contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
297 QMessageBox *contributorsAboutBox = new QMessageBox(this);
298 contributorsAboutBox->setText(contributorsAboutText);
299 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
301 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
302 closeButton->setIcon(QIcon(":/icons/cross.png"));
303 closeButton->setMinimumWidth(90);
305 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
306 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
307 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
308 contributorsAboutBox->exec();
310 LAMEXP_DELETE(contributorsAboutBox);
313 void AboutDialog::showMoreAbout(void)
315 QString moreAboutText;
317 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
318 moreAboutText += "<div style=\"margin-left:-25px;font-size:8pt;white-space:nowrap\"><table><tr><td><ul>";
320 moreAboutText += makeToolText
322 tr("LAME − OpenSource mp3 Encoder"),
323 "lame.exe", "v?.??, Beta-?",
324 tr("Released under the terms of the GNU Lesser General Public License."),
325 "http://lame.sourceforge.net/"
327 moreAboutText += makeToolText
329 tr("OggEnc − Ogg Vorbis Encoder"),
330 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
331 tr("Completely open and patent-free audio encoding technology."),
332 "http://www.vorbis.com/"
334 moreAboutText += makeToolText
336 tr("Nero AAC Reference MPEG-4 Encoder"),
337 "neroAacEnc.exe", "v?.?.?.?",
338 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
340 tr("Available from vendor web-site as free download:")
342 moreAboutText += makeToolText
344 tr("FLAC − Free Lossless Audio Codec"),
345 "flac.exe", "v?.?.?",
346 tr("Open and patent-free lossless audio compression technology."),
347 "http://flac.sourceforge.net/"
349 moreAboutText += makeToolText
351 tr("mpg123 − Fast Console MPEG Audio Player/Decoder"),
352 "mpg123.exe", "v?.??.?",
353 tr("Released under the terms of the GNU Lesser General Public License."),
354 "http://www.mpg123.de/"
356 moreAboutText += makeToolText
358 tr("FAAD − OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
360 tr("Released under the terms of the GNU General Public License."),
361 "http://www.audiocoding.com/"
363 moreAboutText += makeToolText
365 tr("AC3Filter Tools − AC3/DTS Decoder"),
366 "valdec.exe", "v?.??",
367 tr("Released under the terms of the GNU Lesser General Public License."),
368 "http://www.ac3filter.net/projects/tools"
370 moreAboutText += makeToolText
372 tr("WavPack − Hybrid Lossless Compression"),
373 "wvunpack.exe", "v?.??.?",
374 tr("Completely open audio compression format."),
375 "http://www.wavpack.com/"
377 moreAboutText += makeToolText
379 tr("Musepack − Living Audio Compression"),
380 "mpcdec.exe", "r???",
381 tr("Released under the terms of the GNU Lesser General Public License."),
382 "http://www.musepack.net/"
384 moreAboutText += QString
388 moreAboutText += makeToolText
390 tr("Monkey's Audio − Lossless Audio Compressor"),
392 tr("Freely available source code, simple SDK and non-restrictive licensing."),
393 "http://www.monkeysaudio.com/"
395 moreAboutText += makeToolText
397 tr("Shorten − Lossless Audio Compressor"),
398 "shorten.exe", "v?.?.?",
399 tr("Released under the terms of the GNU Lesser General Public License."),
400 "http://etree.org/shnutils/shorten/"
402 moreAboutText += makeToolText
404 tr("Speex − Free Codec For Free Speech"),
405 "speexdec.exe", "v?.?",
406 tr("Open Source patent-free audio format designed for speech."),
407 "http://www.speex.org/"
409 moreAboutText += makeToolText
411 tr("The True Audio − Lossless Audio Codec"),
413 tr("Released under the terms of the GNU Lesser General Public License."),
414 "http://tta.sourceforge.net/"
416 moreAboutText += makeToolText
418 tr("MediaInfo − Media File Analysis Tool"),
419 "mediainfo.exe", "v?.?.??",
420 tr("Released under the terms of the GNU Lesser General Public License."),
421 "http://mediainfo.sourceforge.net/"
423 moreAboutText += makeToolText
425 tr("SoX − Sound eXchange"),
426 "sox.exe", "v??.?.?",
427 tr("Released under the terms of the GNU Lesser General Public License."),
428 "http://sox.sourceforge.net/"
430 moreAboutText += makeToolText
432 tr("GnuPG − The GNU Privacy Guard"),
433 "gpgv.exe", "v?.?.??",
434 tr("Released under the terms of the GNU Lesser General Public License."),
435 "http://www.gnupg.org/"
439 moreAboutText += makeToolText
441 tr("GNU Wget − Software for retrieving files using HTTP"),
442 "wget.exe", "v?.??.?",
443 tr("Released under the terms of the GNU Lesser General Public License."),
444 "http://www.gnu.org/software/wget/"
448 moreAboutText += makeToolText
450 tr("Silk Icons − Over 700 icons in PNG format"),
452 tr("By Mark James, released under the Creative Commons 'by' License."),
453 "http://www.famfamfam.com/lab/icons/silk/"
455 moreAboutText += QString("</ul></td><td> </td></tr></table></div><i>%1</i><br>").arg
457 tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of thrird-party software used in LameXP belongs to the individual authors.")
460 QMessageBox *moreAboutBox = new QMessageBox(this);
461 moreAboutBox->setText(moreAboutText);
462 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
464 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
465 closeButton->setIcon(QIcon(":/icons/cross.png"));
466 closeButton->setMinimumWidth(90);
468 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
469 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
470 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
471 moreAboutBox->exec();
473 LAMEXP_DELETE(moreAboutBox);
476 void AboutDialog::moveDisque(void)
478 static const int delta = 2;
482 QPoint pos = m_disque->pos();
483 pos.setX(m_disqueFlags[0] ? pos.x() + delta : pos.x() - delta);
484 pos.setY(m_disqueFlags[1] ? pos.y() + delta : pos.y() - delta);
489 m_disqueFlags[0] = true;
491 else if(pos.x() >= m_screenGeometry.width() - m_disque->width())
493 m_disqueFlags[0] = false;
498 m_disqueFlags[1] = true;
500 else if(pos.y() >= m_screenGeometry.height()- m_disque->height())
502 m_disqueFlags[1] = false;
505 if(m_disque->windowOpacity() < 0.9)
507 m_disque->setWindowOpacity(m_disque->windowOpacity() + 0.01);
511 ////////////////////////////////////////////////////////////
512 // Protected Functions
513 ////////////////////////////////////////////////////////////
515 void AboutDialog::showEvent(QShowEvent *e)
517 QDialog::showEvent(e);
520 const QList<QAbstractButton*> buttonList = buttons();
522 for(int i = 1; i < buttonList.count(); i++)
524 buttonList.at(i)->setEnabled(false);
527 QTimer::singleShot(5000, this, SLOT(enableButtons()));
528 setCursor(QCursor(Qt::WaitCursor));
532 bool AboutDialog::eventFilter(QObject *obj, QEvent *event)
534 if((obj == m_disque) && (event->type() == QEvent::MouseButtonPress))
537 QDesktopServices::openUrl(QUrl(disqueUrl));
543 ////////////////////////////////////////////////////////////
545 ////////////////////////////////////////////////////////////
547 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
549 QString toolText, verStr(toolVerFmt);
551 if(!toolBin.isEmpty())
553 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
556 toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
557 toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
558 if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
559 toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
560 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
566 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
569 DWORD flags = SND_RESOURCE;
572 QFileInfo libraryFile(library);
573 if(!libraryFile.isAbsolute())
575 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
576 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
577 unsigned int result = GetSystemDirectory(buffer, buffSize);
578 if(result > 0 && result < buffSize)
580 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
594 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
598 result = PlaySound((LPCTSTR) soundId, module, flags);