diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index e5c773f6..fcc2c07f 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -1159,8 +1159,19 @@ Tools - - + + + Configuration + + + + :/icons/wrench.png:/icons/wrench.png + + + + + + @@ -1332,6 +1343,15 @@ Disable Sound Effects + + + + :/icons/wma.png:/icons/wma.png + + + Install WMA Decoder + + @@ -1421,6 +1441,8 @@ + + diff --git a/res/Icons.qrc b/res/Icons.qrc index 4533d892..716ddfe8 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -64,7 +64,9 @@ icons/transmit_blue.png icons/user.png icons/user_suit.png + icons/wma.png icons/world.png + icons/wrench.png icons/zoom.png diff --git a/res/Tools.qrc b/res/Tools.qrc index 0154dfe6..424fe01c 100644 --- a/res/Tools.qrc +++ b/res/Tools.qrc @@ -2,6 +2,7 @@ tools/alac.exe + tools/elevator.exe tools/faad.exe tools/flac.exe tools/gpgv.exe diff --git a/res/icons/wma.png b/res/icons/wma.png new file mode 100644 index 00000000..6913582a Binary files /dev/null and b/res/icons/wma.png differ diff --git a/res/tools/elevator.exe b/res/tools/elevator.exe new file mode 100644 index 00000000..a5a4324e Binary files /dev/null and b/res/tools/elevator.exe differ diff --git a/src/Config.h b/src/Config.h index 8df50358..afb16131 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 142 +#define VER_LAMEXP_BUILD 144 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 1d84f473..bcd36cbb 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -250,6 +250,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S actionDisableSounds->setChecked(!m_settings->soundsEnabled()); connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool))); connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool))); + connect(actionInstallWMADecoder, SIGNAL(triggered(bool)), this, SLOT(installWMADecoderActionTriggered(bool))); //Activate help menu actions connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated())); @@ -1399,3 +1400,49 @@ void MainWindow::disableSoundsActionTriggered(bool checked) actionDisableSounds->setChecked(!m_settings->soundsEnabled()); } + +void MainWindow::installWMADecoderActionTriggered(bool checked) +{ + static const char *download_url = "http://www.nch.com.au/components/wmawav.exe"; + + if(QMessageBox::question(this, "Install WMA Decoder", "Do you want to download and install the WMA File Deocder now?", "Download && Install", "Cancel") != 0) + { + return; + } + + QString binaryWGet = lamexp_lookup_tool("wget.exe"); + QString binaryElevator = lamexp_lookup_tool("elevator.exe"); + + if(binaryWGet.isEmpty() || binaryElevator.isEmpty()) + { + throw "Required binary is not available!"; + } + + QString setupFile = QString("%1/%2.exe").arg(lamexp_temp_folder(), lamexp_rand_str()); + + QProcess process; + process.setWorkingDirectory(QFileInfo(setupFile).absolutePath()); + + QEventLoop loop; + connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit())); + connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit())); + + process.start(binaryWGet, QStringList() << "-O" << QFileInfo(setupFile).fileName() << download_url); + m_banner->show("Downloading WMA Decoder Setup, please wait...", &loop); + + if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240) + { + QFile::remove(setupFile); + QMessageBox::critical(this, "Download Failed", "Failed to download the WMA Decoder. Check your internet connection!"); + return; + } + + QApplication::setOverrideCursor(Qt::WaitCursor); + process.start(binaryElevator, QStringList() << QString("/exec=%1").arg(setupFile)); + loop.exec(QEventLoop::ExcludeUserInputEvents); + QFile::remove(setupFile); + QApplication::restoreOverrideCursor(); + + QMessageBox::information(this, "WMA Decoder", "The WMA Decoder has been installed. Please restart LameXP now!"); +} + diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index ed0679d5..fd6580cb 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -87,6 +87,7 @@ private slots: void disableSoundsActionTriggered(bool checked); void outputFolderContextMenu(const QPoint &pos); void showFolderContextActionTriggered(void); + void installWMADecoderActionTriggered(bool checked); protected: void showEvent(QShowEvent *event); diff --git a/src/Dialog_WorkingBanner.cpp b/src/Dialog_WorkingBanner.cpp index af92bbc5..1ddddab2 100644 --- a/src/Dialog_WorkingBanner.cpp +++ b/src/Dialog_WorkingBanner.cpp @@ -114,6 +114,26 @@ void WorkingBanner::show(const QString &text, QThread *thread) this->close(); } +void WorkingBanner::show(const QString &text, QEventLoop *loop) +{ + //Show splash + this->show(text); + + //Set taskbar state + WinSevenTaskbar::setOverlayIcon(dynamic_cast(this->parent()), &QIcon(":/icons/hourglass.png")); + WinSevenTaskbar::setTaskbarState(dynamic_cast(this->parent()), WinSevenTaskbar::WinSevenTaskbarIndeterminateState); + + //Loop while thread is running + loop->exec(QEventLoop::ExcludeUserInputEvents); + + //Set taskbar state + WinSevenTaskbar::setTaskbarState(dynamic_cast(this->parent()), WinSevenTaskbar::WinSevenTaskbarNoState); + WinSevenTaskbar::setOverlayIcon(dynamic_cast(this->parent()), NULL); + + //Hide splash + this->close(); +} + //////////////////////////////////////////////////////////// // EVENTS //////////////////////////////////////////////////////////// diff --git a/src/Dialog_WorkingBanner.h b/src/Dialog_WorkingBanner.h index d5200167..bd2ca526 100644 --- a/src/Dialog_WorkingBanner.h +++ b/src/Dialog_WorkingBanner.h @@ -37,6 +37,7 @@ public: void show(const QString &text); void show(const QString &text, QThread *thread); + void show(const QString &text, QEventLoop *loop); void close(void); private: diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 3a8e34d1..dcf3fbf7 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include //////////////////////////////////////////////////////////// // TOOLS @@ -41,6 +43,7 @@ struct lamexp_tool_t static const struct lamexp_tool_t g_lamexp_tools[] = { {"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"}, + {"4ecc017a66fe43092110f11494f384e57d99280d", "elevator.exe"}, {"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"}, {"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"}, {"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"}, @@ -85,19 +88,34 @@ void InitializationThread::run() m_bSuccess = false; delay(); - //Extract all files + QMap checksum; + + //Init checksums for(int i = 0; i < INT_MAX; i++) { - if(!g_lamexp_tools[i].pcName || !g_lamexp_tools[i].pcHash) + if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash) { - break; + checksum.insert(QString::fromLatin1(g_lamexp_tools[i].pcName), QString::fromLatin1(g_lamexp_tools[i].pcHash)); + continue; } + break; + } + QDir toolsDir(":/tools/"); + QList toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name); + + //Extract all files + for(int i = 0; i < toolsList.count(); i++) + { try { qDebug("Extracting file: %s", g_lamexp_tools[i].pcName); - QString toolName = QString::fromLatin1(g_lamexp_tools[i].pcName); - QByteArray toolHash = QString::fromLatin1(g_lamexp_tools[i].pcHash).toLatin1(); + QString toolName = toolsList.at(i).fileName(); + QByteArray toolHash = checksum.take(toolName).toLatin1(); + if(toolHash.size() != 40) + { + throw "The required checksum is missing, take care!"; + } LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString(lamexp_temp_folder()).append(QString("/tool_%1").arg(toolName)), toolHash); lamexp_register_tool(toolName, lockedFile); } @@ -108,6 +126,12 @@ void InitializationThread::run() } } + if(!checksum.isEmpty()) + { + qFatal("At least one required tool could not be found:\n%s", toolsDir.filePath(checksum.keys().first()).toLatin1().constData()); + return; + } + qDebug("All extracted.\n"); //Look for Nero encoder