From 53a1bf6e38f23b04803e1eaa0d2a58584ddbfb8f Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 29 Nov 2010 20:36:27 +0100 Subject: [PATCH] Implement update reminder + added options to disable the update reminder and/or the sound effects + improved installer --- etc/NSIS/setup.nsi | 37 ++++++++-- gui/MainWindow.ui | 30 ++++++++ gui/UpdateDialog.ui | 23 +++++++ src/Config.h | 2 +- src/Dialog_About.cpp | 12 +++- src/Dialog_About.h | 6 +- src/Dialog_MainWindow.cpp | 140 ++++++++++++++++++++++++++++++-------- src/Dialog_MainWindow.h | 2 + src/Dialog_Processing.cpp | 6 +- src/Dialog_Update.cpp | 61 ++++++++++++----- src/Dialog_Update.h | 10 ++- src/Main.cpp | 6 -- src/Model_Settings.cpp | 10 ++- src/Model_Settings.h | 3 + 14 files changed, 278 insertions(+), 70 deletions(-) diff --git a/etc/NSIS/setup.nsi b/etc/NSIS/setup.nsi index 40a3baaa..434b7759 100644 --- a/etc/NSIS/setup.nsi +++ b/etc/NSIS/setup.nsi @@ -1,13 +1,38 @@ +; /////////////////////////////////////////////////////////////////////////////// +; // LameXP - Audio Encoder Front-End +; // Copyright (C) 2004-2010 LoRd_MuldeR +; // +; // This program is free software; you can redistribute it and/or modify +; // it under the terms of the GNU General Public License as published by +; // the Free Software Foundation; either version 2 of the License, or +; // (at your option) any later version. +; // +; // This program is distributed in the hope that it will be useful, +; // but WITHOUT ANY WARRANTY; without even the implied warranty of +; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; // GNU General Public License for more details. +; // +; // You should have received a copy of the GNU General Public License along +; // with this program; if not, write to the Free Software Foundation, Inc., +; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +; // +; // http://www.gnu.org/licenses/gpl-2.0.txt +; /////////////////////////////////////////////////////////////////////////////// + +RequestExecutionLevel user +BrandingText `Date created: ${LAMEXP_DATE}` +ShowInstDetails show + !define ZIP2EXE_NAME `LameXP v${LAMEXP_VERSION} ${LAMEXP_SUFFIX} [Build #${LAMEXP_BUILD}]` !define ZIP2EXE_OUTFILE `${LAMEXP_OUTPUT_FILE}` !define ZIP2EXE_COMPRESSOR_LZMA !define ZIP2EXE_COMPRESSOR_SOLID !define ZIP2EXE_INSTALLDIR `$PROGRAMFILES\${ZIP2EXE_NAME}` -RequestExecutionLevel user -BrandingText `Date created: ${LAMEXP_DATE}` -ShowInstDetails show - +!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" +!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp" +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp" !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate !include `UAC.nsh` @@ -23,10 +48,10 @@ Function .onInit ${IfThen} $1 = 1 ${|} Quit ${|} ${IfThen} $3 <> 0 ${|} ${Break} ${|} ${If} $1 = 3 - MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "This installer requires admin access, please try again!" /SD IDNO IDOK UAC_TryAgain IDNO 0 + MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin access, please try again!" /SD IDCANCEL IDOK UAC_TryAgain ${EndIf} ${Case} 1223 - MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "This installer requires admin privileges, please try again!" /SD IDNO IDOK UAC_TryAgain IDNO 0 + MessageBox MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND|MB_OKCANCEL "This installer requires admin privileges, please try again!" /SD IDCANCEL IDOK UAC_TryAgain Quit ${Case} 1062 MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Logon service not running, aborting!" diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 2ce47738..fb3e9c36 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -1133,8 +1133,16 @@ + + + Tools + + + + + @@ -1286,6 +1294,22 @@ Windows XP ("Luna") + + + true + + + Disable Update Reminder + + + + + true + + + Disable Sound Effects + + @@ -1361,6 +1385,12 @@ + + + + + + diff --git a/gui/UpdateDialog.ui b/gui/UpdateDialog.ui index a0937d3f..e83802d0 100644 --- a/gui/UpdateDialog.ui +++ b/gui/UpdateDialog.ui @@ -13,6 +13,10 @@ LameXP Update Manager + + + :/icons/transmit_blue.png:/icons/transmit_blue.png + 0 @@ -335,6 +339,23 @@ + + + + + 100 + 0 + + + + Show Log + + + + :/icons/application_view_list.png:/icons/application_view_list.png + + + @@ -484,6 +505,8 @@ + + diff --git a/src/Config.h b/src/Config.h index 3378b896..84d1d0fc 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 99 +#define VER_LAMEXP_BUILD 103 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index 15358bda..f086918e 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -23,6 +23,7 @@ #include "Global.h" #include "Resource.h" +#include "Model_Settings.h" //Qt includes #include @@ -46,8 +47,10 @@ const char *AboutDialog::neroAacUrl = "http://www.nero.com/eng/technologies-aac- // Constructor //////////////////////////////////////////////////////////// -AboutDialog::AboutDialog(QWidget *parent, bool firstStart) - : QMessageBox(parent) +AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart) +: + QMessageBox(parent), + m_settings(settings) { QString aboutText; @@ -125,7 +128,10 @@ AboutDialog::~AboutDialog(void) int AboutDialog::exec() { - PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); + if(m_settings->soundsEnabled()) + { + PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); + } switch(QMessageBox::exec()) { diff --git a/src/Dialog_About.h b/src/Dialog_About.h index 8595ff0e..852cd8a1 100644 --- a/src/Dialog_About.h +++ b/src/Dialog_About.h @@ -20,14 +20,17 @@ /////////////////////////////////////////////////////////////////////////////// #pragma once + #include +class SettingsModel; + class AboutDialog : public QMessageBox { Q_OBJECT public: - AboutDialog(QWidget *parent = 0, bool firstStart = false); + AboutDialog(SettingsModel *settings, QWidget *parent = 0, bool firstStart = false); ~AboutDialog(void); static const char *neroAacUrl; @@ -44,4 +47,5 @@ protected: private: bool m_firstShow; + SettingsModel *m_settings; }; diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index b37d5921..a4cfc1e2 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -240,6 +240,12 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*))); styleActionActivated(NULL); + //Activate tools menu actions + actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled()); + actionDisableSounds->setChecked(!m_settings->soundsEnabled()); + connect(actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool))); + connect(actionDisableSounds, SIGNAL(triggered(bool)), this, SLOT(disableSoundsActionTriggered(bool))); + //Activate help menu actions connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated())); connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated())); @@ -435,13 +441,14 @@ void MainWindow::windowShown(void) { QStringList arguments = QApplication::arguments(); + //Check license if(m_settings->licenseAccepted() <= 0) { int iAccepted = -1; if(m_settings->licenseAccepted() == 0) { - AboutDialog *about = new AboutDialog(this, true); + AboutDialog *about = new AboutDialog(m_settings, this, true); iAccepted = about->exec(); LAMEXP_DELETE(about); } @@ -457,6 +464,48 @@ void MainWindow::windowShown(void) m_settings->licenseAccepted(1); } + //Check for expiration + if(lamexp_version_demo()) + { + QDate expireDate = lamexp_version_date().addDays(14); + if(QDate::currentDate() >= expireDate) + { + qWarning("Binary has expired !!!"); + if(QMessageBox::warning(this, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), "Check for Updates", "Exit Program") == 0) + { + checkUpdatesActionActivated(); + } + QApplication::quit(); + return; + } + } + + //Update reminder + if(QDate::currentDate() >= lamexp_version_date().addYears(1)) + { + qWarning("Binary is more than a year old, time to update!"); + if(QMessageBox::warning(this, "Urgent Update", "Your version of LameXP is more than a year old. Time for an update!", "Check for Updates", "Exit Program") == 0) + { + checkUpdatesActionActivated(); + } + else + { + QApplication::quit(); + return; + } + } + else if(m_settings->autoUpdateEnabled()) + { + QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate); + if(!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14)) + { + if(QMessageBox::information(this, "Update Reminer", "Your last update check was more than 14 days ago. Check for updates now?", "Check for Updates", "Defer") == 0) + { + checkUpdatesActionActivated(); + } + } + } + //Check for AAC support if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")) { @@ -504,7 +553,7 @@ void MainWindow::windowShown(void) void MainWindow::aboutButtonClicked(void) { ABORT_IF_BUSY; - AboutDialog *aboutBox = new AboutDialog(this); + AboutDialog *aboutBox = new AboutDialog(m_settings, this); aboutBox->exec(); LAMEXP_DELETE(aboutBox); } @@ -855,36 +904,15 @@ void MainWindow::checkUpdatesActionActivated(void) { ABORT_IF_BUSY; - UpdateDialog *updateDialog = new UpdateDialog(this); + UpdateDialog *updateDialog = new UpdateDialog(m_settings, this); + updateDialog->exec(); + if(updateDialog->getSuccess()) + { + m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate)); + } + LAMEXP_DELETE(updateDialog); - - //m_banner->show("Checking for updates, please be patient..."); - // - //for(int i = 0; i < 300; i++) - //{ - // QApplication::processEvents(); - // Sleep(5); - //} - // - //QNetworkAccessManager networkMgr; - //QNetworkReply *reply = networkMgr.get(QNetworkRequest(QUrl( "http://mulder.dummwiedeutsch.de/update.ver"))); - - //QEventLoop loop; - //connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit())); - //connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit())); - //connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - - //while(!reply->isFinished()) - //{ - // loop.exec(QEventLoop::ExcludeUserInputEvents); - // QByteArray buffer = reply->readAll(); - // qDebug("%s", buffer.constData()); - //} - - //m_banner->close(); - // - //QMessageBox::information(this, "Update Check", "Your version of LameXP is still up-to-date. There are no updates available.\nPlease remember to check for updates at regular intervals!"); } /* @@ -1247,3 +1275,55 @@ void MainWindow::findFileContextActionTriggered(void) QProcess::execute("explorer.exe", QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath())); } } + +/* + * Disable update reminder action + */ +void MainWindow::disableUpdateReminderActionTriggered(bool checked) +{ + if(checked) + { + if(QMessageBox::Yes == QMessageBox::question(this, "Disable Update Reminder", "Do you really want to disable the update reminder?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + { + QMessageBox::information(this, "Update Reminder", "The update reminder has been disabled.
Please remember to check for updates at regular intervals!"); + m_settings->autoUpdateEnabled(false); + } + else + { + m_settings->autoUpdateEnabled(true); + } + } + else + { + QMessageBox::information(this, "Update Reminder", "The update reminder has been re-enabled."); + m_settings->autoUpdateEnabled(true); + } + + actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled()); +} + +/* + * Disable sound effects action + */ +void MainWindow::disableSoundsActionTriggered(bool checked) +{ + if(checked) + { + if(QMessageBox::Yes == QMessageBox::question(this, "Disable Sound Effects", "Do you really want to disable all sound effects?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + { + QMessageBox::information(this, "Sound Effects", "All sound effects have been disabled."); + m_settings->soundsEnabled(false); + } + else + { + m_settings->soundsEnabled(true); + } + } + else + { + QMessageBox::information(this, "Sound Effects", "The sound effects have been re-enabled."); + m_settings->soundsEnabled(true); + } + + actionDisableSounds->setChecked(!m_settings->soundsEnabled()); +} diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 454b7a4d..8f5f2067 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -83,6 +83,8 @@ private slots: void sourceFilesContextMenu(const QPoint &pos); void previewContextActionTriggered(void); void findFileContextActionTriggered(void); + void disableUpdateReminderActionTriggered(bool checked); + void disableSoundsActionTriggered(bool checked); protected: void showEvent(QShowEvent *event); diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 0cbe6278..2a49ba08 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -269,7 +269,7 @@ void ProcessingDialog::doneEncoding(void) { label_progress->setText((m_succeededFiles > 0) ? QString("Process was aborted by the user after %1 file(s)!").arg(QString::number(m_succeededFiles)) : "Process was aborted prematurely by the user!"); QApplication::processEvents(); - PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); + if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABORTED), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); } else { @@ -277,13 +277,13 @@ void ProcessingDialog::doneEncoding(void) { label_progress->setText(QString("Error: %1 of %2 files failed. Double-click failed items for detailed information!").arg(QString::number(m_failedFiles), QString::number(m_failedFiles + m_succeededFiles))); QApplication::processEvents(); - PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); + if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); } else { label_progress->setText("Alle files completed successfully."); QApplication::processEvents(); - PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); + if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_SUCCESS), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); } } diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp index e9ccf998..949064e5 100644 --- a/src/Dialog_Update.cpp +++ b/src/Dialog_Update.cpp @@ -23,6 +23,8 @@ #include "Global.h" #include "Resource.h" +#include "Dialog_LogView.h" +#include "Model_Settings.h" #include #include @@ -79,14 +81,17 @@ public: /////////////////////////////////////////////////////////////////////////////// -UpdateDialog::UpdateDialog(QWidget *parent) +UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent) : QDialog(parent), m_binaryWGet(lamexp_lookup_tool("wget.exe")), m_binaryGnuPG(lamexp_lookup_tool("gpgv.exe")), m_binaryUpdater(lamexp_lookup_tool("wupdate.exe")), m_binaryKeys(lamexp_lookup_tool("gpgv.gpg")), - m_updateInfo(NULL) + m_updateInfo(NULL), + m_settings(settings), + m_logFile(new QStringList()), + m_success(false) { if(m_binaryWGet.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryUpdater.isEmpty() || m_binaryKeys.isEmpty()) { @@ -105,11 +110,13 @@ UpdateDialog::UpdateDialog(QWidget *parent) connect(retryButton, SIGNAL(clicked()), this, SLOT(checkForUpdates())); connect(installButton, SIGNAL(clicked()), this, SLOT(applyUpdate())); connect(infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString))); + connect(logButton, SIGNAL(clicked()), this, SLOT(logButtonClicked())); } UpdateDialog::~UpdateDialog(void) { LAMEXP_DELETE(m_updateInfo); + LAMEXP_DELETE(m_logFile); } void UpdateDialog::showEvent(QShowEvent *event) @@ -124,7 +131,9 @@ void UpdateDialog::showEvent(QShowEvent *event) installButton->setEnabled(false); closeButton->setEnabled(false); retryButton->setEnabled(false); + logButton->setEnabled(false); retryButton->hide(); + logButton->hide(); infoLabel->hide(); for(int i = 0; mirrors[i]; i++) @@ -157,11 +166,15 @@ void UpdateDialog::checkForUpdates(void) installButton->setEnabled(false); closeButton->setEnabled(false); retryButton->setEnabled(false); + logButton->setEnabled(false); if(infoLabel->isVisible()) infoLabel->hide(); QApplication::processEvents(); QApplication::setOverrideCursor(Qt::WaitCursor); + m_logFile->clear(); + m_logFile->append("Checking for updates online..."); + for(int i = 0; mirrors[i]; i++) { progressBar->setValue(i+1); @@ -177,15 +190,17 @@ void UpdateDialog::checkForUpdates(void) if(!success) { if(!retryButton->isVisible()) retryButton->show(); + if(!logButton->isVisible()) logButton->show(); closeButton->setEnabled(true); retryButton->setEnabled(true); - statusLabel->setText("Failed to fetch update information. Check internet connection!"); + logButton->setEnabled(true); + statusLabel->setText("Failed to fetch update information. Check your internet connection!"); progressBar->setValue(progressBar->maximum()); LAMEXP_DELETE(m_updateInfo); - PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); + if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); return; } - + labelVersionLatest->setText(QString("Build %1 (%2)").arg(QString::number(m_updateInfo->m_buildNo), m_updateInfo->m_buildDate.toString(Qt::ISODate))); infoLabel->show(); infoLabel->setText(QString("More information available at:
%1").arg(m_updateInfo->m_downloadSite)); @@ -210,39 +225,43 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); if(retryButton->isVisible()) retryButton->hide(); + if(logButton->isVisible()) logButton->hide(); progressBar->setValue(progressBar->maximum()); + + m_success = true; } bool UpdateDialog::tryUpdateMirror(UpdateInfo *updateInfo, const QString &url) { bool success = false; + m_logFile->append(QStringList() << "" << "Trying mirror:" << url); QUuid uuid = QUuid::createUuid(); QString outFileVersionInfo = QString("%1/%2.ver").arg(QDir::tempPath(), uuid.toString()); QString outFileSignature = QString("%1/%2.sig").arg(QDir::tempPath(), uuid.toString()); - qDebug("\nDownloading update info:"); + m_logFile->append(QStringList() << "" << "Downloading update info:"); bool ok1 = getFile(QString("%1%2").arg(url,mirror_url_postfix), outFileVersionInfo); - qDebug("\nDownloading signature file:"); + m_logFile->append(QStringList() << "" << "Downloading signature:"); bool ok2 = getFile(QString("%1%2.sig").arg(url,mirror_url_postfix), outFileSignature); if(ok1 && ok2) { - qDebug("\nDownload okay, checking signature:"); + m_logFile->append(QStringList() << "" << "Download okay, checking signature:"); if(checkSignature(outFileVersionInfo, outFileSignature)) { - qDebug("\nSignature okay, parsing info:"); + m_logFile->append(QStringList() << "" << "Signature okay, parsing info:"); success = parseVersionInfo(outFileVersionInfo, updateInfo); } else { - qDebug("\nBad signature, take care!"); + m_logFile->append(QStringList() << "" << "Bad signature, take care!"); } } else { - qDebug("\nDownload has failed!"); + m_logFile->append(QStringList() << "" << "Download has failed!"); } QFile::remove(outFileVersionInfo); @@ -286,11 +305,11 @@ bool UpdateDialog::getFile(const QString &url, const QString &outFile) loop.exec(); while(process.canReadLine()) { - qDebug("WGet: %s", QString::fromLatin1(process.readLine()).simplified().toLatin1().constData()); + m_logFile->append(QString::fromLatin1(process.readLine()).simplified()); } } - qDebug("WGet: Exited with code %d", process.exitCode()); + m_logFile->append(QString().sprintf("Exited with code %d", process.exitCode())); return (process.exitCode() == 0) && output.exists() && output.isFile(); } @@ -317,11 +336,11 @@ bool UpdateDialog::checkSignature(const QString &file, const QString &signature) loop.exec(); while(process.canReadLine()) { - qDebug("GnuPG: %s", QString::fromLatin1(process.readLine()).simplified().toLatin1().constData()); + m_logFile->append(QString::fromLatin1(process.readLine()).simplified()); } } - qDebug("GnuPG: Exited with code %d", process.exitCode()); + m_logFile->append(QString().sprintf("Exited with code %d", process.exitCode())); return (process.exitCode() == 0); } @@ -345,13 +364,13 @@ bool UpdateDialog::parseVersionInfo(const QString &file, UpdateInfo *updateInfo) QString line = QString::fromLatin1(data.readLine()).trimmed(); if(section.indexIn(line) >= 0) { - qDebug("Section: '%s'", section.cap(1).toLatin1().constData()); + m_logFile->append(QString("[%1]").arg(section.cap(1))); inSection = (section.cap(1).compare(section_id, Qt::CaseInsensitive) == 0); continue; } if(inSection && value.indexIn(line) >= 0) { - qDebug("Value: '%s' ==> '%s'", value.cap(1).toLatin1().constData(), value.cap(2).toLatin1().constData()); + m_logFile->append(QString("'%1' ==> '%2").arg(value.cap(1), value.cap(2))); if(value.cap(1).compare("BuildNo", Qt::CaseInsensitive) == 0) { bool ok = false; @@ -432,6 +451,7 @@ void UpdateDialog::applyUpdate(void) { statusLabel->setText("Update ready to install. Applicaion will quit..."); QApplication::quit(); + accept(); } else { @@ -442,3 +462,10 @@ void UpdateDialog::applyUpdate(void) installButton->setEnabled(true); closeButton->setEnabled(true); } + +void UpdateDialog::logButtonClicked(void) +{ + LogViewDialog *logView = new LogViewDialog(this); + logView->exec(*m_logFile); + LAMEXP_DELETE(logView); +} diff --git a/src/Dialog_Update.h b/src/Dialog_Update.h index 7b200d80..56633689 100644 --- a/src/Dialog_Update.h +++ b/src/Dialog_Update.h @@ -26,20 +26,24 @@ #include class UpdateInfo; +class SettingsModel; class UpdateDialog : public QDialog, private Ui::UpdateDialog { Q_OBJECT public: - UpdateDialog(QWidget *parent = 0); + UpdateDialog(SettingsModel *settings, QWidget *parent = 0); ~UpdateDialog(void); + bool getSuccess(void) { return m_success; } + private slots: void updateInit(void); void checkForUpdates(void); void linkActivated(const QString &link); void applyUpdate(void); + void logButtonClicked(void); protected: void showEvent(QShowEvent *event); @@ -52,9 +56,13 @@ private: bool parseVersionInfo(const QString &file, UpdateInfo *updateInfo); UpdateInfo *m_updateInfo; + QStringList *m_logFile; + SettingsModel *m_settings; const QString m_binaryWGet; const QString m_binaryGnuPG; const QString m_binaryUpdater; const QString m_binaryKeys; + + bool m_success; }; diff --git a/src/Main.cpp b/src/Main.cpp index a3c0b336..b3c88a08 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -80,12 +80,6 @@ int lamexp_main(int argc, char* argv[]) { QDate expireDate = lamexp_version_date().addDays(14); qWarning(QString("Note: This demo (pre-release) version of LameXP will expire at %1.\n").arg(expireDate.toString(Qt::ISODate)).toLatin1().constData()); - if(QDate::currentDate() >= expireDate) - { - qWarning("Binary has expired !!!"); - QMessageBox::warning(NULL, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString()), "Exit Program"); - return 0; - } } //Check for multiple instances of LameXP diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 489717ba..6e45fa97 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -38,8 +38,11 @@ static const char *g_settingsId_compressionRCMode = "Compression/RCMode"; static const char *g_settingsId_compressionBitrate = "Compression/Bitrate"; static const char *g_settingsId_outputDir = "OutputDirectory/SelectedPath"; static const char *g_settingsId_outputToSourceDir = "OutputDirectory/OutputToSourceFolder"; -static const char *g_settingsId_writeMetaTags = "WriteMetaTags"; -static const char *g_settingsId_createPlaylist = "AutoCreatePlaylist"; +static const char *g_settingsId_writeMetaTags = "Flags/WriteMetaTags"; +static const char *g_settingsId_createPlaylist = "Flags/AutoCreatePlaylist"; +static const char *g_settingsId_autoUpdateLastCheck = "AutoUpdate/LastCheck"; +static const char *g_settingsId_autoUpdateEnabled = "AutoUpdate/Enabled"; +static const char *g_settingsId_soundsEnabled = "Flags/EnableSounds"; //Macros #define MAKE_OPTION1(OPT,DEF) \ @@ -116,3 +119,6 @@ MAKE_OPTION2(outputDir, QString()) MAKE_OPTION3(outputToSourceDir, false) MAKE_OPTION3(writeMetaTags, true) MAKE_OPTION3(createPlaylist, true) +MAKE_OPTION2(autoUpdateLastCheck, "Never") +MAKE_OPTION3(autoUpdateEnabled, true) +MAKE_OPTION3(soundsEnabled, true) diff --git a/src/Model_Settings.h b/src/Model_Settings.h index 89fadf83..749a254c 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -71,6 +71,9 @@ public: MAKE_OPTION_DEC3(outputToSourceDir); MAKE_OPTION_DEC3(writeMetaTags); MAKE_OPTION_DEC3(createPlaylist); + MAKE_OPTION_DEC2(autoUpdateLastCheck); + MAKE_OPTION_DEC3(autoUpdateEnabled); + MAKE_OPTION_DEC3(soundsEnabled); //Misc void validate(void);