OSDN Git Service

Updated Spanish translation. Thanks to Rub3nCT <Rub3nCT@gmail.com>.
[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 //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>
38
39 //Win32 includes
40 #include <Windows.h>
41
42 //Helper macros
43 #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
44
45 //Constants
46 const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac-codec.html";
47
48 //Contributors
49 static const struct 
50 {
51         char *pcFlag;
52         wchar_t *pcLanguage;
53         wchar_t *pcName;
54         char *pcMail;
55 }
56 g_lamexp_contributors[] =
57 {
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}
67 };
68
69 ////////////////////////////////////////////////////////////
70 // Constructor
71 ////////////////////////////////////////////////////////////
72
73 AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
74 :
75         QMessageBox(parent),
76         m_settings(settings)
77 {
78         const QString versionStr = QString().sprintf("Version %d.%02d %s, Build %d [%s]", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
79
80         QString aboutText;
81
82         aboutText += QString("<h2>%1</h2>").arg(tr("LameXP &minus; Audio Encoder Front-end"));
83         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()));
84         aboutText += lamexp_version_demo() ? QString("<b>%1, %2</b><br><br>").arg(versionStr, tr("DEMO VERSION")) : QString("<b>%1</b><br><br>").arg(versionStr);
85         aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
86         aboutText += "<hr><br>";
87         aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
88         aboutText += "modify it under the terms of the GNU General Public License<br>";
89         aboutText += "as published by the Free Software Foundation; either version 2<br>";
90         aboutText += "of the License, or (at your option) any later version.<br><br>";
91         aboutText += "This program is distributed in the hope that it will be useful,<br>";
92         aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
93         aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>";
94         aboutText += "GNU General Public License for more details.<br><br>";
95         aboutText += "You should have received a copy of the GNU General Public License<br>";
96         aboutText += "along with this program; if not, write to the Free Software<br>";
97         aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</tt></nobr><br>";
98         aboutText += "<hr><table><tr>";
99         aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
100         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 !!!"));
101         aboutText += "</tr></table><hr><br>";
102         aboutText += QString("%1<br>").arg(tr("Special thanks go out to \"John33\" from %1 for his continuous support.").arg(LINK("http://www.rarewares.org/")));
103         
104         setText(aboutText);
105         setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
106         setWindowTitle(tr("About LameXP"));
107
108         if(firstStart)
109         {
110                 QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
111                 firstButton->setIcon(QIcon(":/icons/script.png"));
112                 firstButton->setIconSize(QSize(16, 16));
113                 firstButton->setMinimumWidth(135);
114                 firstButton->disconnect();
115                 connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));
116
117                 QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
118                 secondButton->setIcon(QIcon(":/icons/accept.png"));
119                 secondButton->setIconSize(QSize(16, 16));
120                 secondButton->setMinimumWidth(120);
121
122                 QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
123                 thirdButton->setIcon(QIcon(":/icons/delete.png"));
124                 thirdButton->setIconSize(QSize(16, 16));
125                 thirdButton->setMinimumWidth(120);
126                 thirdButton->setEnabled(false);
127         }
128         else
129         {
130                 QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
131                 firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
132                 firstButton->setIconSize(QSize(16, 16));
133                 firstButton->setMinimumWidth(120);
134                 firstButton->disconnect();
135                 connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));
136
137                 QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
138                 secondButton->setIcon(QIcon(":icons/user_suit.png"));
139                 secondButton->setIconSize(QSize(16, 16));
140                 secondButton->setMinimumWidth(120);
141                 secondButton->disconnect();
142                 connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));
143
144                 QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
145                 thirdButton->setIcon(QIcon(":/images/Qt.svg"));
146                 thirdButton->setIconSize(QSize(16, 16));
147                 thirdButton->setMinimumWidth(120);
148                 thirdButton->disconnect();
149                 connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
150
151                 QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
152                 fourthButton->setIcon(QIcon(":/icons/cross.png"));
153                 fourthButton->setIconSize(QSize(16, 16));
154                 fourthButton->setMinimumWidth(90);
155         }
156
157         m_firstShow = firstStart;
158 }
159
160 AboutDialog::~AboutDialog(void)
161 {
162 }
163
164 ////////////////////////////////////////////////////////////
165 // Public Functions
166 ////////////////////////////////////////////////////////////
167
168 int AboutDialog::exec()
169 {
170         if(m_settings->soundsEnabled())
171         {
172                 if(m_firstShow)
173                 {
174                         if(!playResoureSound("imageres.dll", 5080, true))
175                         {
176                                 PlaySound(TEXT("SystemStart"), NULL, SND_ALIAS | SND_ASYNC);
177                         }
178                 }
179                 else
180                 {
181                         PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
182                 }
183         }
184         
185         switch(QMessageBox::exec())
186         {
187         case 1:
188                 return 1;
189                 break;
190         case 2:
191                 return -1;
192                 break;
193         default:
194                 return 0;
195                 break;
196         }
197 }
198
199 ////////////////////////////////////////////////////////////
200 // Slots
201 ////////////////////////////////////////////////////////////
202
203 void AboutDialog::enableButtons(void)
204 {
205         const QList<QAbstractButton*> buttonList = buttons();
206         
207         for(int i = 0; i < buttonList.count(); i++)
208         {
209                 buttonList.at(i)->setEnabled(true);
210         }
211
212         setCursor(QCursor(Qt::ArrowCursor));
213 }
214
215 void AboutDialog::openLicenseText(void)
216 {
217         QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt"));
218 }
219
220 void AboutDialog::showAboutQt(void)
221 {
222         QMessageBox::aboutQt(this);
223 }
224
225 void AboutDialog::showAboutContributors(void)
226 {
227         QString contributorsAboutText;
228
229         contributorsAboutText += QString("<h3><nobr>%1</nobr></h3>").arg(tr("The following people have contributed to LameXP:"));
230         contributorsAboutText += QString("<b>%1</b>").arg(tr("Translators:"));
231         contributorsAboutText += "<table style=\"margin-top:5px\">";
232         for(int i = 0; g_lamexp_contributors[i].pcName; i++)
233         {
234                 QString flagIcon = (strlen(g_lamexp_contributors[i].pcFlag) > 0) ? QString("<img src=\":/flags/%1.png\">").arg(g_lamexp_contributors[i].pcFlag) : QString();
235                 contributorsAboutText += QString("<tr><td valign=\"middle\">%1</td><td>&nbsp;&nbsp;</td>").arg(flagIcon);
236                 contributorsAboutText += QString("<td valign=\"middle\">%2</td><td>&nbsp;&nbsp;</td>").arg(WCHAR2QSTR(g_lamexp_contributors[i].pcLanguage));
237                 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);
238         }
239         contributorsAboutText += "</table>";
240         contributorsAboutText += "<br><br>";
241         contributorsAboutText += QString("<nobr><i>%1</i></nobr><br>").arg(tr("If you are willing to contribute a LameXP translation, feel free to contact us!"));
242
243         QMessageBox *contributorsAboutBox = new QMessageBox(this);
244         contributorsAboutBox->setText(contributorsAboutText);
245         contributorsAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
246
247         QPushButton *closeButton = contributorsAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
248         closeButton->setIcon(QIcon(":/icons/cross.png"));
249         closeButton->setMinimumWidth(90);
250
251         contributorsAboutBox->setWindowTitle(tr("About Contributors"));
252         contributorsAboutBox->setIconPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(64,74)));
253         contributorsAboutBox->setWindowIcon(QIcon(":/icons/user_suit.png"));
254         contributorsAboutBox->exec();
255                                 
256         LAMEXP_DELETE(contributorsAboutBox);
257 }
258
259 void AboutDialog::showMoreAbout(void)
260 {
261         QString moreAboutText;
262
263         moreAboutText += QString("<h3>%1</h3>").arg(tr("The following third-party software is used in LameXP:"));
264         moreAboutText += "<div style=\"margin-left:-25px;font-size:8pt;white-space:nowrap\"><table><tr><td><ul>";
265         
266         moreAboutText += makeToolText
267         (
268                 tr("LAME &minus; OpenSource mp3 Encoder"),
269                 "lame.exe", "v?.??, Alpha-??",
270                 tr("Released under the terms of the GNU Lesser General Public License."),
271                 "http://lame.sourceforge.net/"
272         );
273         moreAboutText += makeToolText
274         (
275                 tr("OggEnc &minus; Ogg Vorbis Encoder"),
276                 "oggenc2_i386.exe", "v?.??, aoTuV Beta-?.??",
277                 tr("Completely open and patent-free audio encoding technology."),
278                 "http://www.vorbis.com/"
279         );
280         moreAboutText += makeToolText
281         (
282                 tr("Nero AAC Reference MPEG-4 Encoder"),
283                 "neroAacEnc.exe", "v?.?.?.?",
284                 tr("Freeware state-of-the-art HE-AAC encoder with 2-Pass support."),
285                 neroAacUrl,
286                 tr("Available from vendor web-site as free download:")
287         );
288         moreAboutText += makeToolText
289         (
290                 tr("FLAC &minus; Free Lossless Audio Codec"),
291                 "flac.exe", "v?.?.?",
292                 tr("Open and patent-free lossless audio compression technology."),
293                 "http://flac.sourceforge.net/"
294         );
295         moreAboutText += makeToolText
296         (
297                 tr("mpg123 &minus; Fast Console MPEG Audio Player/Decoder"),
298                 "mpg123.exe", "v?.??.?",
299                 tr("Released under the terms of the GNU Lesser General Public License."),
300                 "http://www.mpg123.de/"
301         );
302         moreAboutText += makeToolText
303         (
304                 tr("FAAD &minus; OpenSource MPEG-4 and MPEG-2 AAC Decoder"),
305                 "faad.exe", "v?.?",
306                 tr("Released under the terms of the GNU General Public License."),
307                 "http://www.audiocoding.com/"
308         );
309         moreAboutText += makeToolText
310         (
311                 tr("AC3Filter Tools &minus; AC3/DTS Decoder"),
312                 "valdec.exe", "v?.??",
313                 tr("Released under the terms of the GNU Lesser General Public License."),
314                 "http://www.ac3filter.net/projects/tools"
315         );
316         moreAboutText += makeToolText
317                 (
318                 tr("WavPack &minus; Hybrid Lossless Compression"),
319                 "wvunpack.exe", "v?.??.?",
320                 tr("Completely open audio compression format."),
321                 "http://www.wavpack.com/"
322         );
323         moreAboutText += makeToolText
324                 (
325                 tr("Musepack &minus; Living Audio Compression"),
326                 "mpcdec.exe", "r???",
327                 tr("Released under the terms of the GNU Lesser General Public License."),
328                 "http://www.musepack.net/"
329         );
330         moreAboutText += QString
331         (
332                 "</ul></td><td><ul>"
333         );
334         moreAboutText += makeToolText
335         (
336                 tr("Monkey's Audio &minus; Lossless Audio Compressor"),
337                 "mac.exe", "v?.??",
338                 tr("Freely available source code, simple SDK and non-restrictive licensing."),
339                 "http://www.monkeysaudio.com/"
340         );
341         moreAboutText += makeToolText
342         (
343                 tr("Shorten &minus; Lossless Audio Compressor"),
344                 "shorten.exe", "v?.?.?",
345                 tr("Released under the terms of the GNU Lesser General Public License."),
346                 "http://etree.org/shnutils/shorten/"
347         );
348         moreAboutText += makeToolText
349         (
350                 tr("Speex &minus; Free Codec For Free Speech"),
351                 "speexdec.exe", "v?.?",
352                 tr("Open Source patent-free audio format designed for speech."),
353                 "http://www.speex.org/"
354         );
355         moreAboutText += makeToolText
356         (
357                 tr("The True Audio &minus; Lossless Audio Codec"),
358                 "tta.exe", "v?.?",
359                 tr("Released under the terms of the GNU Lesser General Public License."),
360                 "http://tta.sourceforge.net/"
361         );
362         moreAboutText += makeToolText
363         (
364                 tr("MediaInfo &minus; Media File Analysis Tool"),
365                 "mediainfo_i386.exe", "v?.?.??",
366                 tr("Released under the terms of the GNU Lesser General Public License."),
367                 "http://mediainfo.sourceforge.net/"
368         );
369         moreAboutText += makeToolText
370         (
371                 tr("SoX &minus; Sound eXchange"),
372                 "sox.exe", "v??.?.?",
373                 tr("Released under the terms of the GNU Lesser General Public License."),
374                 "http://sox.sourceforge.net/"
375         );
376         moreAboutText += makeToolText
377         (
378                 tr("GnuPG &minus; The GNU Privacy Guard"),
379                 "gpgv.exe", "v?.?.??",
380                 tr("Released under the terms of the GNU Lesser General Public License."),
381                 "http://www.gnupg.org/"
382         );
383
384
385         moreAboutText += makeToolText
386         (
387                 tr("GNU Wget &minus; Software for retrieving files using HTTP"),
388                 "wget.exe", "v?.??.?",
389                 tr("Released under the terms of the GNU Lesser General Public License."),
390                 "http://www.gnu.org/software/wget/"
391         );
392
393
394         moreAboutText += makeToolText
395         (
396                 tr("Silk Icons &minus; Over 700  icons in PNG format"),
397                 QString(), "v1.3",
398                 tr("By Mark James, released under the Creative Commons 'by' License."),
399                 "http://www.famfamfam.com/lab/icons/silk/"
400         );
401         moreAboutText += QString("</ul></td><td>&nbsp;</td></tr></table></div><i>%1</i><br>").arg
402         (
403                 tr("LameXP as a whole is copyrighted by LoRd_MuldeR. The copyright of thrird-party software used in LameXP belongs to the individual authors.")
404         );
405
406         QMessageBox *moreAboutBox = new QMessageBox(this);
407         moreAboutBox->setText(moreAboutText);
408         moreAboutBox->setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
409
410         QPushButton *closeButton = moreAboutBox->addButton(tr("Discard"), QMessageBox::AcceptRole);
411         closeButton->setIcon(QIcon(":/icons/cross.png"));
412         closeButton->setMinimumWidth(90);
413
414         moreAboutBox->setWindowTitle(tr("About Third-party Software"));
415         moreAboutBox->setIconPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(64,71)));
416         moreAboutBox->setWindowIcon(QIcon(":/icons/page_white_cplusplus.png"));
417         moreAboutBox->exec();
418                                 
419         LAMEXP_DELETE(moreAboutBox);
420 }
421
422 ////////////////////////////////////////////////////////////
423 // Protected Functions
424 ////////////////////////////////////////////////////////////
425
426 void AboutDialog::showEvent(QShowEvent *e)
427 {
428         QDialog::showEvent(e);
429         if(m_firstShow)
430         {
431                 const QList<QAbstractButton*> buttonList = buttons();
432
433                 for(int i = 1; i < buttonList.count(); i++)
434                 {
435                         buttonList.at(i)->setEnabled(false);
436                 }
437
438                 QTimer::singleShot(5000, this, SLOT(enableButtons()));
439                 setCursor(QCursor(Qt::WaitCursor));
440         }
441 }
442
443 ////////////////////////////////////////////////////////////
444 // Private Functions
445 ////////////////////////////////////////////////////////////
446
447 QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBin, const QString &toolVerFmt, const QString &toolLicense, const QString &toolWebsite, const QString &extraInfo)
448 {
449         QString toolText, verStr(toolVerFmt);
450
451         if(!toolBin.isEmpty())
452         {
453                 verStr = lamexp_version2string(toolVerFmt, lamexp_tool_version(toolBin), tr("n/a"));
454         }
455
456         toolText += QString("<li><nobr><b>%1 (%2)</b></nobr><br>").arg(toolName, verStr);
457         toolText += QString("<nobr>%1</nobr><br>").arg(toolLicense);
458         if(!extraInfo.isEmpty()) toolText += QString("<nobr><i>%1</i></nobr><br>").arg(extraInfo);
459         toolText += QString("<a href=\"%1\">%1</a>").arg(toolWebsite);
460         toolText += QString("<div style=\"font-size:1pt\"><br></div>");
461
462         return toolText;
463 }
464
465
466 bool AboutDialog::playResoureSound(const QString &library, const unsigned long soundId, const bool async)
467 {
468         HMODULE module = 0;
469         DWORD flags = SND_RESOURCE;
470         bool result = false;
471
472         QFileInfo libraryFile(library);
473         if(!libraryFile.isAbsolute())
474         {
475                 unsigned int buffSize = GetSystemDirectoryW(NULL, NULL) + 1;
476                 wchar_t *buffer = (wchar_t*) _malloca(buffSize * sizeof(wchar_t));
477                 unsigned int result = GetSystemDirectory(buffer, buffSize);
478                 if(result > 0 && result < buffSize)
479                 {
480                         libraryFile.setFile(QString("%1/%2").arg(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(buffer))), library));
481                 }
482                 _freea(buffer);
483         }
484
485         if(async)
486         {
487                 flags |= SND_ASYNC;
488         }
489         else
490         {
491                 flags |= SND_SYNC;
492         }
493
494         module = LoadLibraryW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(libraryFile.absoluteFilePath()).utf16()));
495
496         if(module)
497         {
498                 result = PlaySound((LPCTSTR) soundId, module, flags);
499                 FreeLibrary(module);
500         }
501
502         return result;
503 }