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"
30 #include <QApplication>
32 #include <QPushButton>
33 #include <QDesktopServices>
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";
56 g_lamexp_contributors[] =
58 {"en", L"Englisch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
59 {"de", L"Deutsch", L"LoRd_MuldeR", "MuldeR2@GMX.de" },
60 {"", L"", L"Bodo Thevissen", "Bodo@thevissen.de" },
61 {"fr", L"Française", L"Dodich Informatique", "Dodich@live.fr" },
62 {"it", L"Italiano", L"Roberto", "Gulliver_69@libero.it"},
63 {"es", L"Español", L"Rub3nCT", "Rub3nCT@gmail.com" },
64 {"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" },
65 {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
66 {NULL, NULL, NULL, NULL}
69 ////////////////////////////////////////////////////////////
71 ////////////////////////////////////////////////////////////
73 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
78 const QString versionStr = QString().sprintf
80 "Version %d.%02d %s, Build %d [%s], %s, Qt v%s",
81 lamexp_version_major(),
82 lamexp_version_minor(),
83 lamexp_version_release(),
84 lamexp_version_build(),
85 lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
86 lamexp_version_compiler(),
92 aboutText += QString("<h2>%1</h2>").arg(tr("LameXP − Audio Encoder Front-end"));
93 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()));
94 aboutText += QString("<b>%1</b><br><br>").arg(versionStr);
95 aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
96 aboutText += lamexp_version_demo() ? QString("<nobr><font color=\"darkred\">%1</font></nobr><br>").arg(tr("Note: This demo (pre-release) version of LameXP will expire at %1.").arg(lamexp_version_expires().toString(Qt::ISODate))) : QString();
97 aboutText += "<hr><br>";
98 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
99 aboutText += "modify it under the terms of the GNU General Public License<br>";
100 aboutText += "as published by the Free Software Foundation; either version 2<br>";
101 aboutText += "of the License, or (at your option) any later version.<br><br>";
102 aboutText += "This program is distributed in the hope that it will be useful,<br>";
103 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
104 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
105 aboutText += "GNU General Public License for more details.<br><br>";
106 aboutText += "You should have received a copy of the GNU General Public License<br>";
107 aboutText += "along with this program; if not, write to the Free Software<br>";
108 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
109 aboutText += "<hr><table><tr>";
110 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td> </td>";
111 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 !!!"));
112 aboutText += "</tr></table><hr><br>";
113 aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
116 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
117 setWindowTitle(tr("About LameXP"));
121 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
122 firstButton->setIcon(QIcon(":/icons/script.png"));
123 firstButton->setIconSize(QSize(16, 16));
124 firstButton->setMinimumWidth(135);
125 firstButton->disconnect();
126 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
128 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
129 secondButton->setIcon(QIcon(":/icons/accept.png"));
130 secondButton->setIconSize(QSize(16, 16));
131 secondButton->setMinimumWidth(120);
133 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
134 thirdButton->setIcon(QIcon(":/icons/delete.png"));
135 thirdButton->setIconSize(QSize(16, 16));
136 thirdButton->setMinimumWidth(120);
137 thirdButton->setEnabled(false);
141 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
142 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
143 firstButton->setIconSize(QSize(16, 16));
144 firstButton->setMinimumWidth(120);
145 firstButton->disconnect();
146 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
148 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
149 secondButton->setIcon(QIcon(":icons/user_suit.png"));
150 secondButton->setIconSize(QSize(16, 16));
151 secondButton->setMinimumWidth(120);
152 secondButton->disconnect();
153 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
155 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
156 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
157 thirdButton->setIconSize(QSize(16, 16));
158 thirdButton->setMinimumWidth(120);
159 thirdButton->disconnect();
160 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
162 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
163 fourthButton->setIcon(QIcon(":/icons/cross.png"));
164 fourthButton->setIconSize(QSize(16, 16));
165 fourthButton->setMinimumWidth(90);
168 m_firstShow = firstStart;
171 AboutDialog::~AboutDialog(void)
175 ////////////////////////////////////////////////////////////
177 ////////////////////////////////////////////////////////////
179 int AboutDialog::exec()
181 if(m_settings->soundsEnabled())
185 if(!playResoureSound("imageres.dll", 5080, true))
187 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
192 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
196 switch(QMessageBox::exec())
210 ////////////////////////////////////////////////////////////
212 ////////////////////////////////////////////////////////////
214 void AboutDialog::enableButtons(void)
216 const QList<QAbstractButton*> buttonList = buttons();
218 for(int i = 0; i < buttonList.count(); i++)
220 buttonList.at(i)->setEnabled(true);
223 setCursor(QCursor(Qt::ArrowCursor));
226 void AboutDialog::openLicenseText(void)
228 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
231 void AboutDialog::showAboutQt(void)
233 QMessageBox::aboutQt(this);
236 void AboutDialog::showAboutContributors(void)
238 QString contributorsAboutText;
240 contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
241 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
242 contributorsAboutText += "<table style=\"margin-top:5px\">";
243 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
245 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
246 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td> </td>").arg(flagIcon);
247 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td> </td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
248 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);
250 contributorsAboutText += "</table>";
251 contributorsAboutText += "<br><br>";
252 contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
254 QMessageBox *contributorsAboutBox = new QMessageBox(this);
255 contributorsAboutBox->setText(contributorsAboutText);
256 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
258 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
259 closeButton->setIcon(QIcon(":/icons/cross.png"));
260 closeButton->setMinimumWidth(90);
262 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
263 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
264 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
265 contributorsAboutBox->exec();
267 LAMEXP_DELETE(contributorsAboutBox);
270 void AboutDialog::showMoreAbout(void)
272 QString moreAboutText;
274 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
275 moreAboutText += "<div style=\"margin-left:-25px;font-size:8pt;white-space:nowrap\"><table><tr><td><ul>";
277 moreAboutText += makeToolText
279 tr("LAME − OpenSource mp3 Encoder"),
280 "lame.exe", "v?.??, Alpha-??",
281 tr("Released under the terms of the GNU Lesser General Public License."),
282 "http://lame.sourceforge.net/"
284 moreAboutText += makeToolText
286 tr("OggEnc − Ogg Vorbis Encoder"),
287 "oggenc2_i386.exe", "v?.??, aoTuV Beta-?.??",
288 tr("Completely open and patent-free audio encoding technology."),
289 "http://www.vorbis.com/"
291 moreAboutText += makeToolText
293 tr("Nero AAC Reference MPEG-4 Encoder"),
294 "neroAacEnc.exe", "v?.?.?.?",
295 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
297 tr("Available from vendor web-site as free download:")
299 moreAboutText += makeToolText
301 tr("FLAC − Free Lossless Audio Codec"),
302 "flac.exe", "v?.?.?",
303 tr("Open and patent-free lossless audio compression technology."),
304 "http://flac.sourceforge.net/"
306 moreAboutText += makeToolText
308 tr("mpg123 − Fast Console MPEG Audio Player/Decoder"),
309 "mpg123.exe", "v?.??.?",
310 tr("Released under the terms of the GNU Lesser General Public License."),
311 "http://www.mpg123.de/"
313 moreAboutText += makeToolText
315 tr("FAAD − OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
317 tr("Released under the terms of the GNU General Public License."),
318 "http://www.audiocoding.com/"
320 moreAboutText += makeToolText
322 tr("AC3Filter Tools − AC3/DTS Decoder"),
323 "valdec.exe", "v?.??",
324 tr("Released under the terms of the GNU Lesser General Public License."),
325 "http://www.ac3filter.net/projects/tools"
327 moreAboutText += makeToolText
329 tr("WavPack − Hybrid Lossless Compression"),
330 "wvunpack.exe", "v?.??.?",
331 tr("Completely open audio compression format."),
332 "http://www.wavpack.com/"
334 moreAboutText += makeToolText
336 tr("Musepack − Living Audio Compression"),
337 "mpcdec.exe", "r???",
338 tr("Released under the terms of the GNU Lesser General Public License."),
339 "http://www.musepack.net/"
341 moreAboutText += QString
345 moreAboutText += makeToolText
347 tr("Monkey's Audio − Lossless Audio Compressor"),
349 tr("Freely available source code, simple SDK and non-restrictive licensing."),
350 "http://www.monkeysaudio.com/"
352 moreAboutText += makeToolText
354 tr("Shorten − Lossless Audio Compressor"),
355 "shorten.exe", "v?.?.?",
356 tr("Released under the terms of the GNU Lesser General Public License."),
357 "http://etree.org/shnutils/shorten/"
359 moreAboutText += makeToolText
361 tr("Speex − Free Codec For Free Speech"),
362 "speexdec.exe", "v?.?",
363 tr("Open Source patent-free audio format designed for speech."),
364 "http://www.speex.org/"
366 moreAboutText += makeToolText
368 tr("The True Audio − Lossless Audio Codec"),
370 tr("Released under the terms of the GNU Lesser General Public License."),
371 "http://tta.sourceforge.net/"
373 moreAboutText += makeToolText
375 tr("MediaInfo − Media File Analysis Tool"),
376 "mediainfo_i386.exe", "v?.?.??",
377 tr("Released under the terms of the GNU Lesser General Public License."),
378 "http://mediainfo.sourceforge.net/"
380 moreAboutText += makeToolText
382 tr("SoX − Sound eXchange"),
383 "sox.exe", "v??.?.?",
384 tr("Released under the terms of the GNU Lesser General Public License."),
385 "http://sox.sourceforge.net/"
387 moreAboutText += makeToolText
389 tr("GnuPG − The GNU Privacy Guard"),
390 "gpgv.exe", "v?.?.??",
391 tr("Released under the terms of the GNU Lesser General Public License."),
392 "http://www.gnupg.org/"
396 moreAboutText += makeToolText
398 tr("GNU Wget − Software for retrieving files using HTTP"),
399 "wget.exe", "v?.??.?",
400 tr("Released under the terms of the GNU Lesser General Public License."),
401 "http://www.gnu.org/software/wget/"
405 moreAboutText += makeToolText
407 tr("Silk Icons − Over 700 icons in PNG format"),
409 tr("By Mark James, released under the Creative Commons 'by' License."),
410 "http://www.famfamfam.com/lab/icons/silk/"
412 moreAboutText += QString("</ul></td><td> </td></tr></table></div><i>%1</i><br>").arg
414 tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of thrird-party software used in LameXP belongs to the individual authors.")
417 QMessageBox *moreAboutBox = new QMessageBox(this);
418 moreAboutBox->setText(moreAboutText);
419 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
421 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
422 closeButton->setIcon(QIcon(":/icons/cross.png"));
423 closeButton->setMinimumWidth(90);
425 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
426 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
427 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
428 moreAboutBox->exec();
430 LAMEXP_DELETE(moreAboutBox);
433 ////////////////////////////////////////////////////////////
434 // Protected Functions
435 ////////////////////////////////////////////////////////////
437 void AboutDialog::showEvent(QShowEvent *e)
439 QDialog::showEvent(e);
442 const QList<QAbstractButton*> buttonList = buttons();
444 for(int i = 1; i < buttonList.count(); i++)
446 buttonList.at(i)->setEnabled(false);
449 QTimer::singleShot(5000, this, SLOT(enableButtons()));
450 setCursor(QCursor(Qt::WaitCursor));
454 ////////////////////////////////////////////////////////////
456 ////////////////////////////////////////////////////////////
458 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
460 QString toolText, verStr(toolVerFmt);
462 if(!toolBin.isEmpty())
464 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
467 toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
468 toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
469 if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
470 toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
471 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
477 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
480 DWORD flags = SND_RESOURCE;
483 QFileInfo libraryFile(library);
484 if(!libraryFile.isAbsolute())
486 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
487 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
488 unsigned int result = GetSystemDirectory(buffer, buffSize);
489 if(result > 0 && result < buffSize)
491 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
505 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
509 result = PlaySound((LPCTSTR) soundId, module, flags);