OSDN Git Service

Updated LAME binary to v3.99 Beta-0 (2011-04-16), compiled with ICL 12.0.3. Also...
[lamexp/LameXP.git] / src / Dialog_About.cpp
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.
14 //
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.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "Dialog_About.h"
23
24 #include "Global.h"
25 #include "Resource.h"
26 #include "Model_Settings.h"
27
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
38 #include <MMSystem.h>
39
40 //Helper macros
41 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
42
43 //Constants
44 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
45
46 //Contributors
47 static const struct 
48 {
49         char *pcFlag;
50         wchar_t *pcLanguage;
51         wchar_t *pcName;
52         char *pcMail;
53 }
54 g_lamexp_contributors[] =
55 {
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}
66 };
67
68 ////////////////////////////////////////////////////////////
69 // Constructor
70 ////////////////////////////////////////////////////////////
71
72 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
73 :
74         QMessageBox(parent),
75         m_settings(settings)
76 {
77         const QString versionStr = QString().sprintf
78         (
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()
87         );
88
89         QString aboutText;
90
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())));
95         
96         if(LAMEXP_DEBUG)
97         {
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;");
100         }
101         else if(lamexp_version_demo())
102         {
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)));
105         }
106         
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/")));
124
125         setText(aboutText);
126         setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
127         setWindowTitle(tr("About LameXP"));
128
129         if(firstStart)
130         {
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()));
137
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);
142
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);
148         }
149         else
150         {
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()));
157
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()));
164
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()));
171
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);
176         }
177
178         m_firstShow = firstStart;
179 }
180
181 AboutDialog::~AboutDialog(void)
182 {
183 }
184
185 ////////////////////////////////////////////////////////////
186 // Public Functions
187 ////////////////////////////////////////////////////////////
188
189 int AboutDialog::exec()
190 {
191         if(m_settings->soundsEnabled())
192         {
193                 if(m_firstShow)
194                 {
195                         if(!playResoureSound("imageres.dll", 5080, true))
196                         {
197                                 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
198                         }
199                 }
200                 else
201                 {
202                         PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
203                 }
204         }
205         
206         switch(QMessageBox::exec())
207         {
208         case 1:
209                 return 1;
210                 break;
211         case 2:
212                 return -1;
213                 break;
214         default:
215                 return 0;
216                 break;
217         }
218 }
219
220 ////////////////////////////////////////////////////////////
221 // Slots
222 ////////////////////////////////////////////////////////////
223
224 void AboutDialog::enableButtons(void)
225 {
226         const QList<QAbstractButton*> buttonList = buttons();
227         
228         for(int i = 0; i < buttonList.count(); i++)
229         {
230                 buttonList.at(i)->setEnabled(true);
231         }
232
233         setCursor(QCursor(Qt::ArrowCursor));
234 }
235
236 void AboutDialog::openLicenseText(void)
237 {
238         QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
239 }
240
241 void AboutDialog::showAboutQt(void)
242 {
243         QMessageBox::aboutQt(this);
244 }
245
246 void AboutDialog::showAboutContributors(void)
247 {
248         QString contributorsAboutText;
249
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++)
254         {
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);
259         }
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!"));
263
264         QMessageBox *contributorsAboutBox = new QMessageBox(this);
265         contributorsAboutBox->setText(contributorsAboutText);
266         contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
267
268         QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
269         closeButton->setIcon(QIcon(":/icons/cross.png"));
270         closeButton->setMinimumWidth(90);
271
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();
276                                 
277         LAMEXP_DELETE(contributorsAboutBox);
278 }
279
280 void AboutDialog::showMoreAbout(void)
281 {
282         QString moreAboutText;
283
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>";
286         
287         moreAboutText += makeToolText
288         (
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/"
293         );
294         moreAboutText += makeToolText
295         (
296                 tr("OggEnc &minus; Ogg Vorbis Encoder"),
297                 "oggenc2_i386.exe", "v?.??, aoTuV Beta-?.??",
298                 tr("Completely open and patent-free audio encoding technology."),
299                 "http://www.vorbis.com/"
300         );
301         moreAboutText += makeToolText
302         (
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:")
308         );
309         moreAboutText += makeToolText
310         (
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/"
315         );
316         moreAboutText += makeToolText
317         (
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/"
322         );
323         moreAboutText += makeToolText
324         (
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/"
329         );
330         moreAboutText += makeToolText
331         (
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"
336         );
337         moreAboutText += makeToolText
338                 (
339                 tr("WavPack &minus; Hybrid Lossless Compression"),
340                 "wvunpack.exe", "v?.??.?",
341                 tr("Completely open audio compression format."),
342                 "http://www.wavpack.com/"
343         );
344         moreAboutText += makeToolText
345                 (
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/"
350         );
351         moreAboutText += QString
352         (
353                 "</ul></td><td><ul>"
354         );
355         moreAboutText += makeToolText
356         (
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/"
361         );
362         moreAboutText += makeToolText
363         (
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/"
368         );
369         moreAboutText += makeToolText
370         (
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/"
375         );
376         moreAboutText += makeToolText
377         (
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/"
382         );
383         moreAboutText += makeToolText
384         (
385                 tr("MediaInfo &minus; Media File Analysis Tool"),
386                 "mediainfo_i386.exe", "v?.?.??",
387                 tr("Released under the terms of the GNU Lesser General Public License."),
388                 "http://mediainfo.sourceforge.net/"
389         );
390         moreAboutText += makeToolText
391         (
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/"
396         );
397         moreAboutText += makeToolText
398         (
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/"
403         );
404
405
406         moreAboutText += makeToolText
407         (
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/"
412         );
413
414
415         moreAboutText += makeToolText
416         (
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/"
421         );
422         moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
423         (
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.")
425         );
426
427         QMessageBox *moreAboutBox = new QMessageBox(this);
428         moreAboutBox->setText(moreAboutText);
429         moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
430
431         QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
432         closeButton->setIcon(QIcon(":/icons/cross.png"));
433         closeButton->setMinimumWidth(90);
434
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();
439                                 
440         LAMEXP_DELETE(moreAboutBox);
441 }
442
443 ////////////////////////////////////////////////////////////
444 // Protected Functions
445 ////////////////////////////////////////////////////////////
446
447 void AboutDialog::showEvent(QShowEvent *e)
448 {
449         QDialog::showEvent(e);
450         if(m_firstShow)
451         {
452                 const QList<QAbstractButton*> buttonList = buttons();
453
454                 for(int i = 1; i < buttonList.count(); i++)
455                 {
456                         buttonList.at(i)->setEnabled(false);
457                 }
458
459                 QTimer::singleShot(5000, this, SLOT(enableButtons()));
460                 setCursor(QCursor(Qt::WaitCursor));
461         }
462 }
463
464 ////////////////////////////////////////////////////////////
465 // Private Functions
466 ////////////////////////////////////////////////////////////
467
468 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
469 {
470         QString toolText, verStr(toolVerFmt);
471
472         if(!toolBin.isEmpty())
473         {
474                 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
475         }
476
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>");
482
483         return toolText;
484 }
485
486
487 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
488 {
489         HMODULE module = 0;
490         DWORD flags = SND_RESOURCE;
491         bool result = false;
492
493         QFileInfo libraryFile(library);
494         if(!libraryFile.isAbsolute())
495         {
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)
500                 {
501                         libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
502                 }
503                 _freea(buffer);
504         }
505
506         if(async)
507         {
508                 flags |= SND_ASYNC;
509         }
510         else
511         {
512                 flags |= SND_SYNC;
513         }
514
515         module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
516
517         if(module)
518         {
519                 result = PlaySound((LPCTSTR) soundId, module, flags);
520                 FreeLibrary(module);
521         }
522
523         return result;
524 }