OSDN Git Service

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