OSDN Git Service

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