Fix typos.
[LameXP.git] / src / Dialog_About.cpp
blobadcb91368bb58ce020f79cb346f355c6606a9500
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 //Qt includes
29 #include <QDate>
30 #include <QApplication>
31 #include <QIcon>
32 #include <QPushButton>
33 #include <QDesktopServices>
34 #include <QUrl>
35 #include <QTimer>
36 #include <QFileInfo>
37 #include <QDir>
39 //Win32 includes
40 #include <Windows.h>
42 //Helper macros
43 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
45 //Constants
46 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
48 //Contributors
49 static const struct
51 char *pcFlag;
52 char *pcLanguage;
53 char *pcName;
54 char *pcMail;
56 g_lamexp_contributors[] =
58 {"en", "Englisch", "LoRd_MuldeR", "MuldeR2@GMX.de" },
59 {"de", "Deutsch", "LoRd_MuldeR", "MuldeR2@GMX.de" },
60 {"fr", "Française", "Dodich Informatique", "Dodich@live.fr" },
61 {"it", "Italiano", "Roberto", "Gulliver_69@libero.it"},
62 {"es", "Español", "Rub3nCT", "Rub3nCT@gmail.com" },
63 {NULL, NULL, NULL, NULL}
66 ////////////////////////////////////////////////////////////
67 // Constructor
68 ////////////////////////////////////////////////////////////
70 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
72 QMessageBox(parent),
73 m_settings(settings)
75 QString aboutText;
77 aboutText += QString("<h2>%1</h2>").arg(tr("LameXP &minus; Audio Encoder Front-end"));
78 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()));
79 aboutText += QString().sprintf("<b>Version %d.%02d %s, Build %d [%s]</b><br><br>", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
80 aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK("http://forum.doom9.org/showthread.php?t=157726")));
81 aboutText += "<hr><br>";
82 aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
83 aboutText += "modify it under the terms of the GNU General Public License<br>";
84 aboutText += "as published by the Free Software Foundation; either version 2<br>";
85 aboutText += "of the License, or (at your option) any later version.<br><br>";
86 aboutText += "This program is distributed in the hope that it will be useful,<br>";
87 aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
88 aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>";
89 aboutText += "GNU General Public License for more details.<br><br>";
90 aboutText += "You should have received a copy of the GNU General Public License<br>";
91 aboutText += "along with this program; if not, write to the Free Software<br>";
92 aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</tt></nobr><br>";
93 aboutText += "<hr><table><tr>";
94 aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
95 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 !!!"));
96 aboutText += "</tr></table><hr><br>";
97 aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
99 setText(aboutText);
100 setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
101 setWindowTitle(tr("About LameXP"));
103 if(firstStart)
105 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
106 firstButton->setIcon(QIcon(":/icons/script.png"));
107 firstButton->setIconSize(QSize(16, 16));
108 firstButton->setMinimumWidth(135);
109 firstButton->disconnect();
110 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
112 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
113 secondButton->setIcon(QIcon(":/icons/accept.png"));
114 secondButton->setIconSize(QSize(16, 16));
115 secondButton->setMinimumWidth(120);
117 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
118 thirdButton->setIcon(QIcon(":/icons/delete.png"));
119 thirdButton->setIconSize(QSize(16, 16));
120 thirdButton->setMinimumWidth(120);
121 thirdButton->setEnabled(false);
123 else
125 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
126 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
127 firstButton->setIconSize(QSize(16, 16));
128 firstButton->setMinimumWidth(120);
129 firstButton->disconnect();
130 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
132 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
133 secondButton->setIcon(QIcon(":icons/user_suit.png"));
134 secondButton->setIconSize(QSize(16, 16));
135 secondButton->setMinimumWidth(120);
136 secondButton->disconnect();
137 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
139 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
140 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
141 thirdButton->setIconSize(QSize(16, 16));
142 thirdButton->setMinimumWidth(120);
143 thirdButton->disconnect();
144 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
146 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
147 fourthButton->setIcon(QIcon(":/icons/cross.png"));
148 fourthButton->setIconSize(QSize(16, 16));
149 fourthButton->setMinimumWidth(90);
152 m_firstShow = firstStart;
155 AboutDialog::~AboutDialog(void)
159 ////////////////////////////////////////////////////////////
160 // Public Functions
161 ////////////////////////////////////////////////////////////
163 int AboutDialog::exec()
165 if(m_settings->soundsEnabled())
167 if(m_firstShow)
169 if(!playResoureSound("imageres.dll", 5080, true))
171 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
174 else
176 PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
180 switch(QMessageBox::exec())
182 case 1:
183 return 1;
184 break;
185 case 2:
186 return -1;
187 break;
188 default:
189 return 0;
190 break;
194 ////////////////////////////////////////////////////////////
195 // Slots
196 ////////////////////////////////////////////////////////////
198 void AboutDialog::enableButtons(void)
200 const QList<QAbstractButton*> buttonList = buttons();
202 for(int i = 0; i < buttonList.count(); i++)
204 buttonList.at(i)->setEnabled(true);
207 setCursor(QCursor(Qt::ArrowCursor));
210 void AboutDialog::openLicenseText(void)
212 QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
215 void AboutDialog::showAboutQt(void)
217 QMessageBox::aboutQt(this);
220 void AboutDialog::showAboutContributors(void)
222 QString contributorsAboutText;
224 contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
225 contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
226 contributorsAboutText += "<table style=\"margin-top:5px\">";
227 for(int i = 0; g_lamexp_contributors[i].pcName; i++)
229 contributorsAboutText += QString("<tr><td valign=\"middle\"><img src=\":/flags/%1.png\"></td><td>&nbsp;&nbsp;</td>").arg(g_lamexp_contributors[i].pcFlag);
230 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td>&nbsp;&nbsp;</td>").arg(g_lamexp_contributors[i].pcLanguage);
231 contributorsAboutText += QString("<td valign=\"middle\">%3</td><td>&nbsp;&nbsp;</td><td>&lt;%4&gt;</td></tr>").arg(g_lamexp_contributors[i].pcName, g_lamexp_contributors[i].pcMail);
233 contributorsAboutText += "</table>";
234 contributorsAboutText += "<br><br>";
235 contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
237 QMessageBox *contributorsAboutBox = new QMessageBox(this);
238 contributorsAboutBox->setText(contributorsAboutText);
239 contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
241 QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
242 closeButton->setIcon(QIcon(":/icons/cross.png"));
243 closeButton->setMinimumWidth(90);
245 contributorsAboutBox->setWindowTitle(tr("About Contributors"));
246 contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
247 contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
248 contributorsAboutBox->exec();
250 LAMEXP_DELETE(contributorsAboutBox);
253 void AboutDialog::showMoreAbout(void)
255 QString moreAboutText;
257 moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
258 moreAboutText += "<div style=\"margin-left:-25px;font-size:8pt;white-space:nowrap\"><table><tr><td><ul>";
260 moreAboutText += makeToolText
262 tr("LAME &minus; OpenSource mp3 Encoder"),
263 "lame.exe", "v?.?? a??",
264 tr("Released under the terms of the GNU Lesser General Public License."),
265 "http://lame.sourceforge.net/"
267 moreAboutText += makeToolText
269 tr("OggEnc &minus; Ogg Vorbis Encoder"),
270 "oggenc2_i386.exe", "v?.??",
271 tr("Completely open and patent-free audio encoding technology."),
272 "http://www.vorbis.com/"
274 moreAboutText += makeToolText
276 tr("Nero AAC Reference MPEG-4 Encoder"),
277 "neroAacEnc.exe", "v?.?.?.?",
278 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
279 neroAacUrl,
280 tr("Available from vendor web-site as free download:")
282 moreAboutText += makeToolText
284 tr("FLAC &minus; Free Lossless Audio Codec"),
285 "flac.exe", "v?.?.?",
286 tr("Open and patent-free lossless audio compression technology."),
287 "http://flac.sourceforge.net/"
289 moreAboutText += makeToolText
291 tr("mpg123 &minus; Fast Console MPEG Audio Player/Decoder"),
292 "mpg123.exe", "v?.??.?",
293 tr("Released under the terms of the GNU Lesser General Public License."),
294 "http://www.mpg123.de/"
296 moreAboutText += makeToolText
298 tr("FAAD &minus; OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
299 "faad.exe", "v?.?",
300 tr("Released under the terms of the GNU General Public License."),
301 "http://www.audiocoding.com/"
303 moreAboutText += makeToolText
305 tr("AC3Filter Tools &minus; AC3/DTS Decoder"),
306 "valdec.exe", "v?.??",
307 tr("Released under the terms of the GNU Lesser General Public License."),
308 "http://www.ac3filter.net/projects/tools"
310 moreAboutText += makeToolText
312 tr("WavPack &minus; Hybrid Lossless Compression"),
313 "wvunpack.exe", "v?.??.?",
314 tr("Completely open audio compression format."),
315 "http://www.wavpack.com/"
317 moreAboutText += makeToolText
319 tr("Musepack &minus; Living Audio Compression"),
320 "mpcdec.exe", "r???",
321 tr("Released under the terms of the GNU Lesser General Public License."),
322 "http://www.musepack.net/"
324 moreAboutText += QString
326 "</ul></td><td><ul>"
328 moreAboutText += makeToolText
330 tr("Monkey's Audio &minus; Lossless Audio Compressor"),
331 "mac.exe", "v?.??",
332 tr("Freely available source code, simple SDK and non-restrictive licensing."),
333 "http://www.monkeysaudio.com/"
335 moreAboutText += makeToolText
337 tr("Shorten &minus; Lossless Audio Compressor"),
338 "shorten.exe", "v?.?.?",
339 tr("Released under the terms of the GNU Lesser General Public License."),
340 "http://etree.org/shnutils/shorten/"
342 moreAboutText += makeToolText
344 tr("Speex &minus; Free Codec For Free Speech"),
345 "speexdec.exe", "v?.?",
346 tr("Open Source patent-free audio format designed for speech."),
347 "http://www.speex.org/"
349 moreAboutText += makeToolText
351 tr("The True Audio &minus; Lossless Audio Codec"),
352 "ttaenc.exe", "v?.?.?",
353 tr("Released under the terms of the GNU Lesser General Public License."),
354 "http://tta.sourceforge.net/"
356 moreAboutText += makeToolText
358 tr("MediaInfo &minus; Media File Analysis Tool"),
359 "mediainfo_i386.exe", "v?.?.??",
360 tr("Released under the terms of the GNU Lesser General Public License."),
361 "http://mediainfo.sourceforge.net/"
363 moreAboutText += makeToolText
365 tr("SoX &minus; Sound eXchange"),
366 "sox.exe", "v??.?.?",
367 tr("Released under the terms of the GNU Lesser General Public License."),
368 "http://sox.sourceforge.net/"
370 moreAboutText += makeToolText
372 tr("GnuPG &minus; The GNU Privacy Guard"),
373 "gpgv.exe", "v?.?.??",
374 tr("Released under the terms of the GNU Lesser General Public License."),
375 "http://www.gnupg.org/"
379 moreAboutText += makeToolText
381 tr("GNU Wget &minus; Software for retrieving files using HTTP"),
382 "wget.exe", "v?.??.?",
383 tr("Released under the terms of the GNU Lesser General Public License."),
384 "http://www.gnu.org/software/wget/"
388 moreAboutText += makeToolText
390 tr("Silk Icons &minus; Over 700 icons in PNG format"),
391 QString(), "v1.3",
392 tr("By Mark James, released under the Creative Commons 'by' License."),
393 "http://www.famfamfam.com/lab/icons/silk/"
395 moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
397 tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of thrird-party software used in LameXP belongs to the individual authors.")
400 QMessageBox *moreAboutBox = new QMessageBox(this);
401 moreAboutBox->setText(moreAboutText);
402 moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
404 QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
405 closeButton->setIcon(QIcon(":/icons/cross.png"));
406 closeButton->setMinimumWidth(90);
408 moreAboutBox->setWindowTitle(tr("About Third-party Software"));
409 moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
410 moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
411 moreAboutBox->exec();
413 LAMEXP_DELETE(moreAboutBox);
416 ////////////////////////////////////////////////////////////
417 // Protected Functions
418 ////////////////////////////////////////////////////////////
420 void AboutDialog::showEvent(QShowEvent *e)
422 QDialog::showEvent(e);
423 if(m_firstShow)
425 const QList<QAbstractButton*> buttonList = buttons();
427 for(int i = 1; i < buttonList.count(); i++)
429 buttonList.at(i)->setEnabled(false);
432 QTimer::singleShot(5000, this, SLOT(enableButtons()));
433 setCursor(QCursor(Qt::WaitCursor));
437 ////////////////////////////////////////////////////////////
438 // Private Functions
439 ////////////////////////////////////////////////////////////
441 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
443 QString toolText, verStr(toolVerFmt);
445 if(!toolBin.isEmpty())
447 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
450 toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
451 toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
452 if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
453 toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
454 toolText += QString("<div style=\"font-size:1pt\"><br></div>");
456 return toolText;
460 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
462 HMODULE module = 0;
463 DWORD flags = SND_RESOURCE;
464 bool result = false;
466 QFileInfo libraryFile(library);
467 if(!libraryFile.isAbsolute())
469 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
470 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
471 unsigned int result = GetSystemDirectory(buffer, buffSize);
472 if(result > 0 && result < buffSize)
474 libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
476 _freea(buffer);
479 if(async)
481 flags |= SND_ASYNC;
483 else
485 flags |= SND_SYNC;
488 module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
490 if(module)
492 result = PlaySound((LPCTSTR) soundId, module, flags);
493 FreeLibrary(module);
496 return result;