Updated MediaInfo binaries to v0.7.44 (2011-04-19), compiled with ICL 12.0.3 and...
[LameXP.git] / src / Dialog_About.cpp
blobb4b889ac55756f0e2927008bb09c5716af7140ed
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>
38 #include <MMSystem.h>
40 //Helper macros
41 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
43 //Constants
44 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
46 //Contributors
47 static const struct
49 char *pcFlag;
50 wchar_t *pcLanguage;
51 wchar_t *pcName;
52 char *pcMail;
54 g_lamexp_contributors[] =
56 {"en", L"Englisch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
57 {"de", L"Deutsch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
58 {"", L"", L"Bodo Thevissen", "Bodo@thevissen.de" },
59 {"es", L"Español", L"Rub3nCT", "Rub3nCT@gmail.com" },
60 {"fr", L"Française", L"Dodich Informatique", "Dodich@live.fr" },
61 {"it", L"Italiano", L"Roberto", "Gulliver_69@libero.it"},
62 {"kr", L"한국어", L"JaeHyung Lee", "Kolanp@gmail.com" },
63 {"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" },
64 {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
65 {NULL, NULL, NULL, NULL}
68 ////////////////////////////////////////////////////////////
69 // Constructor
70 ////////////////////////////////////////////////////////////
72 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
74 QMessageBox(parent),
75 m_settings(settings)
77 const QString versionStr = QString().sprintf
79 "Version %d.%02d %s, Build %d [%s], %s, Qt v%s",
80 lamexp_version_major(),
81 lamexp_version_minor(),
82 lamexp_version_release(),
83 lamexp_version_build(),
84 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
85 lamexp_version_compiler(),
86 qVersion()
89 QString aboutText;
91 aboutText += QString("<h2>%1</h2>").arg(tr("LameXP &minus; Audio Encoder Front-end"));
92 aboutText += QString("<b>Copyright (C) 2004-%1 LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.</b><br>").arg(max(lamexp_version_date().year(), QDate::currentDate().year()));
93 aboutText += QString("<b>%1</b><br><br>").arg(versionStr);
94 aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
96 if(LAMEXP_DEBUG)
98 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
99 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;");
101 else if(lamexp_version_demo())
103 int daysLeft = max(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
104 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)));
107 aboutText += "<hr><br>";
108 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
109 aboutText += "modify it under the terms of the GNU General Public License<br>";
110 aboutText += "as published by the Free Software Foundation; either version 2<br>";
111 aboutText += "of the License, or (at your option) any later version.<br><br>";
112 aboutText += "This program is distributed in the hope that it will be useful,<br>";
113 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
114 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
115 aboutText += "GNU General Public License for more details.<br><br>";
116 aboutText += "You should have received a copy of the GNU General Public License<br>";
117 aboutText += "along with this program; if not, write to the Free Software<br>";
118 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
119 aboutText += "<hr><table><tr>";
120 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
121 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 !!!"));
122 aboutText += "</tr></table><hr><br>";
123 aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
125 setText(aboutText);
126 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
127 setWindowTitle(tr("About LameXP"));
129 if(firstStart)
131 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
132 firstButton->setIcon(QIcon(":/icons/script.png"));
133 firstButton->setIconSize(QSize(16, 16));
134 firstButton->setMinimumWidth(135);
135 firstButton->disconnect();
136 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
138 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
139 secondButton->setIcon(QIcon(":/icons/accept.png"));
140 secondButton->setIconSize(QSize(16, 16));
141 secondButton->setMinimumWidth(120);
143 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
144 thirdButton->setIcon(QIcon(":/icons/delete.png"));
145 thirdButton->setIconSize(QSize(16, 16));
146 thirdButton->setMinimumWidth(120);
147 thirdButton->setEnabled(false);
149 else
151 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
152 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
153 firstButton->setIconSize(QSize(16, 16));
154 firstButton->setMinimumWidth(120);
155 firstButton->disconnect();
156 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
158 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
159 secondButton->setIcon(QIcon(":icons/user_suit.png"));
160 secondButton->setIconSize(QSize(16, 16));
161 secondButton->setMinimumWidth(120);
162 secondButton->disconnect();
163 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
165 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
166 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
167 thirdButton->setIconSize(QSize(16, 16));
168 thirdButton->setMinimumWidth(120);
169 thirdButton->disconnect();
170 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
172 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
173 fourthButton->setIcon(QIcon(":/icons/cross.png"));
174 fourthButton->setIconSize(QSize(16, 16));
175 fourthButton->setMinimumWidth(90);
178 m_firstShow = firstStart;
181 AboutDialog::~AboutDialog(void)
185 ////////////////////////////////////////////////////////////
186 // Public Functions
187 ////////////////////////////////////////////////////////////
189 int AboutDialog::exec()
191 if(m_settings->soundsEnabled())
193 if(m_firstShow)
195 if(!playResoureSound("imageres.dll", 5080, true))
197 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
200 else
202 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
206 switch(QMessageBox::exec())
208 case 1:
209 return 1;
210 break;
211 case 2:
212 return -1;
213 break;
214 default:
215 return 0;
216 break;
220 ////////////////////////////////////////////////////////////
221 // Slots
222 ////////////////////////////////////////////////////////////
224 void AboutDialog::enableButtons(void)
226 const QList<QAbstractButton*> buttonList = buttons();
228 for(int i = 0; i < buttonList.count(); i++)
230 buttonList.at(i)->setEnabled(true);
233 setCursor(QCursor(Qt::ArrowCursor));
236 void AboutDialog::openLicenseText(void)
238 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
241 void AboutDialog::showAboutQt(void)
243 QMessageBox::aboutQt(this);
246 void AboutDialog::showAboutContributors(void)
248 QString contributorsAboutText;
250 contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
251 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
252 contributorsAboutText += "<table style=\"margin-top:5px\">";
253 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
255 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
256 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(flagIcon);
257 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td>&nbsp;&nbsp;</td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
258 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);
260 contributorsAboutText += "</table>";
261 contributorsAboutText += "<br><br>";
262 contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
264 QMessageBox *contributorsAboutBox = new QMessageBox(this);
265 contributorsAboutBox->setText(contributorsAboutText);
266 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
268 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
269 closeButton->setIcon(QIcon(":/icons/cross.png"));
270 closeButton->setMinimumWidth(90);
272 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
273 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
274 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
275 contributorsAboutBox->exec();
277 LAMEXP_DELETE(contributorsAboutBox);
280 void AboutDialog::showMoreAbout(void)
282 QString moreAboutText;
284 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
285 moreAboutText += "<div style=\"margin-left:-25px;font-size:8pt;white-space:nowrap\"><table><tr><td><ul>";
287 moreAboutText += makeToolText
289 tr("LAME &minus; OpenSource mp3 Encoder"),
290 "lame.exe", "v?.??, Beta-?",
291 tr("Released under the terms of the GNU Lesser General Public License."),
292 "http://lame.sourceforge.net/"
294 moreAboutText += makeToolText
296 tr("OggEnc &minus; Ogg Vorbis Encoder"),
297 "oggenc2.exe", "v?.??, aoTuV Beta-?.??",
298 tr("Completely open and patent-free audio encoding technology."),
299 "http://www.vorbis.com/"
301 moreAboutText += makeToolText
303 tr("Nero AAC Reference MPEG-4 Encoder"),
304 "neroAacEnc.exe", "v?.?.?.?",
305 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
306 neroAacUrl,
307 tr("Available from vendor web-site as free download:")
309 moreAboutText += makeToolText
311 tr("FLAC &minus; Free Lossless Audio Codec"),
312 "flac.exe", "v?.?.?",
313 tr("Open and patent-free lossless audio compression technology."),
314 "http://flac.sourceforge.net/"
316 moreAboutText += makeToolText
318 tr("mpg123 &minus; Fast Console MPEG Audio Player/Decoder"),
319 "mpg123.exe", "v?.??.?",
320 tr("Released under the terms of the GNU Lesser General Public License."),
321 "http://www.mpg123.de/"
323 moreAboutText += makeToolText
325 tr("FAAD &minus; OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
326 "faad.exe", "v?.?",
327 tr("Released under the terms of the GNU General Public License."),
328 "http://www.audiocoding.com/"
330 moreAboutText += makeToolText
332 tr("AC3Filter Tools &minus; AC3/DTS Decoder"),
333 "valdec.exe", "v?.??",
334 tr("Released under the terms of the GNU Lesser General Public License."),
335 "http://www.ac3filter.net/projects/tools"
337 moreAboutText += makeToolText
339 tr("WavPack &minus; Hybrid Lossless Compression"),
340 "wvunpack.exe", "v?.??.?",
341 tr("Completely open audio compression format."),
342 "http://www.wavpack.com/"
344 moreAboutText += makeToolText
346 tr("Musepack &minus; Living Audio Compression"),
347 "mpcdec.exe", "r???",
348 tr("Released under the terms of the GNU Lesser General Public License."),
349 "http://www.musepack.net/"
351 moreAboutText += QString
353 "</ul></td><td><ul>"
355 moreAboutText += makeToolText
357 tr("Monkey's Audio &minus; Lossless Audio Compressor"),
358 "mac.exe", "v?.??",
359 tr("Freely available source code, simple SDK and non-restrictive licensing."),
360 "http://www.monkeysaudio.com/"
362 moreAboutText += makeToolText
364 tr("Shorten &minus; Lossless Audio Compressor"),
365 "shorten.exe", "v?.?.?",
366 tr("Released under the terms of the GNU Lesser General Public License."),
367 "http://etree.org/shnutils/shorten/"
369 moreAboutText += makeToolText
371 tr("Speex &minus; Free Codec For Free Speech"),
372 "speexdec.exe", "v?.?",
373 tr("Open Source patent-free audio format designed for speech."),
374 "http://www.speex.org/"
376 moreAboutText += makeToolText
378 tr("The True Audio &minus; Lossless Audio Codec"),
379 "tta.exe", "v?.?",
380 tr("Released under the terms of the GNU Lesser General Public License."),
381 "http://tta.sourceforge.net/"
383 moreAboutText += makeToolText
385 tr("MediaInfo &minus; Media File Analysis Tool"),
386 "mediainfo.exe", "v?.?.??",
387 tr("Released under the terms of the GNU Lesser General Public License."),
388 "http://mediainfo.sourceforge.net/"
390 moreAboutText += makeToolText
392 tr("SoX &minus; Sound eXchange"),
393 "sox.exe", "v??.?.?",
394 tr("Released under the terms of the GNU Lesser General Public License."),
395 "http://sox.sourceforge.net/"
397 moreAboutText += makeToolText
399 tr("GnuPG &minus; The GNU Privacy Guard"),
400 "gpgv.exe", "v?.?.??",
401 tr("Released under the terms of the GNU Lesser General Public License."),
402 "http://www.gnupg.org/"
406 moreAboutText += makeToolText
408 tr("GNU Wget &minus; Software for retrieving files using HTTP"),
409 "wget.exe", "v?.??.?",
410 tr("Released under the terms of the GNU Lesser General Public License."),
411 "http://www.gnu.org/software/wget/"
415 moreAboutText += makeToolText
417 tr("Silk Icons &minus; Over 700 icons in PNG format"),
418 QString(), "v1.3",
419 tr("By Mark James, released under the Creative Commons 'by' License."),
420 "http://www.famfamfam.com/lab/icons/silk/"
422 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
424 tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of thrird-party software used in LameXP belongs to the individual authors.")
427 QMessageBox *moreAboutBox = new QMessageBox(this);
428 moreAboutBox->setText(moreAboutText);
429 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
431 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
432 closeButton->setIcon(QIcon(":/icons/cross.png"));
433 closeButton->setMinimumWidth(90);
435 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
436 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
437 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
438 moreAboutBox->exec();
440 LAMEXP_DELETE(moreAboutBox);
443 ////////////////////////////////////////////////////////////
444 // Protected Functions
445 ////////////////////////////////////////////////////////////
447 void AboutDialog::showEvent(QShowEvent *e)
449 QDialog::showEvent(e);
450 if(m_firstShow)
452 const QList<QAbstractButton*> buttonList = buttons();
454 for(int i = 1; i < buttonList.count(); i++)
456 buttonList.at(i)->setEnabled(false);
459 QTimer::singleShot(5000, this, SLOT(enableButtons()));
460 setCursor(QCursor(Qt::WaitCursor));
464 ////////////////////////////////////////////////////////////
465 // Private Functions
466 ////////////////////////////////////////////////////////////
468 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
470 QString toolText, verStr(toolVerFmt);
472 if(!toolBin.isEmpty())
474 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
477 toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
478 toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
479 if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
480 toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
481 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
483 return toolText;
487 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
489 HMODULE module = 0;
490 DWORD flags = SND_RESOURCE;
491 bool result = false;
493 QFileInfo libraryFile(library);
494 if(!libraryFile.isAbsolute())
496 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
497 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
498 unsigned int result = GetSystemDirectory(buffer, buffSize);
499 if(result > 0 && result < buffSize)
501 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
503 _freea(buffer);
506 if(async)
508 flags |= SND_ASYNC;
510 else
512 flags |= SND_SYNC;
515 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
517 if(module)
519 result = PlaySound((LPCTSTR) soundId, module, flags);
520 FreeLibrary(module);
523 return result;