diff --git a/LameXP.vcproj b/LameXP.vcproj index 2f77591e..67815874 100644 --- a/LameXP.vcproj +++ b/LameXP.vcproj @@ -337,6 +337,10 @@ RelativePath=".\src\Model_MetaInfo.cpp" > + + @@ -366,6 +370,36 @@ + + + + + + + + + + + @@ -737,6 +775,10 @@ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + + diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index 6cecd53e..15358bda 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //Win32 includes #include @@ -80,6 +81,8 @@ AboutDialog::AboutDialog(QWidget *parent, bool firstStart) QPushButton *firstButton = addButton("Show License Text", QMessageBox::AcceptRole); firstButton->setIcon(QIcon(":/icons/script_edit.png")); firstButton->setMinimumWidth(135); + firstButton->disconnect(); + connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText())); QPushButton *secondButton = addButton("Accept License", QMessageBox::AcceptRole); secondButton->setIcon(QIcon(":/icons/accept.png")); @@ -88,16 +91,21 @@ AboutDialog::AboutDialog(QWidget *parent, bool firstStart) QPushButton *thirdButton = addButton("Decline License", QMessageBox::AcceptRole); thirdButton->setIcon(QIcon(":/icons/delete.png")); thirdButton->setMinimumWidth(120); + thirdButton->setEnabled(false); } else { QPushButton *firstButton = addButton("More About...", QMessageBox::AcceptRole); firstButton->setIcon(QIcon(":/icons/information.png")); firstButton->setMinimumWidth(120); + firstButton->disconnect(); + connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout())); QPushButton *secondButton = addButton("About Qt...", QMessageBox::AcceptRole); secondButton->setIcon(QIcon(":/images/Qt.svg")); secondButton->setMinimumWidth(120); + secondButton->disconnect(); + connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutQt())); QPushButton *thirdButton = addButton("Discard", QMessageBox::AcceptRole); thirdButton->setIcon(QIcon(":/icons/cross.png")); @@ -119,49 +127,47 @@ int AboutDialog::exec() { PlaySound(MAKEINTRESOURCE(IDR_WAVE_ABOUT), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); - if(m_firstShow) + switch(QMessageBox::exec()) { - while(1) - { - switch(QMessageBox::exec()) - { - case 0: - QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt")); - break; - case 1: - return 1; - break; - default: - return -1; - } - } + case 1: + return 1; + break; + case 2: + return -1; + break; + default: + return 0; + break; } - else - { - while(1) - { - switch(QMessageBox::exec()) - { - case 0: - showMoreAbout(); - break; - case 1: - QMessageBox::aboutQt(dynamic_cast(this->parent())); - break; - default: - return 0; - } - } - } - - return 0; } //////////////////////////////////////////////////////////// -// Private Functions +// Slots //////////////////////////////////////////////////////////// -void AboutDialog::showMoreAbout() +void AboutDialog::enableButtons(void) +{ + const QList buttonList = buttons(); + + for(int i = 0; i < buttonList.count(); i++) + { + buttonList.at(i)->setEnabled(true); + } + + setCursor(QCursor(Qt::ArrowCursor)); +} + +void AboutDialog::openLicenseText(void) +{ + QDesktopServices::openUrl(QUrl("http://www.gnu.org/licenses/gpl-2.0.txt")); +} + +void AboutDialog::showAboutQt(void) +{ + QMessageBox::aboutQt(this); +} + +void AboutDialog::showMoreAbout(void) { QString moreAboutText; moreAboutText += "

The following third-party software is used in LameXP:

"; @@ -184,7 +190,7 @@ void AboutDialog::showMoreAbout() moreAboutText += LINK("http://mediainfo.sourceforge.net/"); moreAboutText += "
"; - QMessageBox *moreAboutBox = new QMessageBox(dynamic_cast(this->parent())); + QMessageBox *moreAboutBox = new QMessageBox(this); moreAboutBox->setText(moreAboutText); moreAboutBox->setIconPixmap(dynamic_cast(QApplication::instance())->windowIcon().pixmap(QSize(64,64))); @@ -197,3 +203,28 @@ void AboutDialog::showMoreAbout() LAMEXP_DELETE(moreAboutBox); } + +//////////////////////////////////////////////////////////// +// Protected Functions +//////////////////////////////////////////////////////////// + +void AboutDialog::showEvent(QShowEvent *e) +{ + QDialog::showEvent(e); + if(m_firstShow) + { + const QList buttonList = buttons(); + + for(int i = 1; i < buttonList.count(); i++) + { + buttonList.at(i)->setEnabled(false); + } + + QTimer::singleShot(5000, this, SLOT(enableButtons())); + setCursor(QCursor(Qt::WaitCursor)); + } +} + +//////////////////////////////////////////////////////////// +// Private Functions +//////////////////////////////////////////////////////////// diff --git a/src/Dialog_About.h b/src/Dialog_About.h index 976004d4..8595ff0e 100644 --- a/src/Dialog_About.h +++ b/src/Dialog_About.h @@ -24,15 +24,24 @@ class AboutDialog : public QMessageBox { + Q_OBJECT + public: AboutDialog(QWidget *parent = 0, bool firstStart = false); ~AboutDialog(void); -public slots: - int exec(); static const char *neroAacUrl; +public slots: + int exec(); + void enableButtons(void); + void openLicenseText(void); + void showMoreAbout(void); + void showAboutQt(void); + +protected: + void showEvent(QShowEvent *e); + private: - void AboutDialog::showMoreAbout(); bool m_firstShow; }; diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 327ea4e3..500f82c7 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -30,6 +30,7 @@ #include "Thread_FileAnalyzer.h" #include "Thread_MessageHandler.h" #include "Model_MetaInfo.h" +#include "Model_Settings.h" //Qt includes #include @@ -78,6 +79,9 @@ MainWindow::MainWindow(QWidget *parent) setWindowTitle(windowTitle().append(" [DEMO VERSION]")); } + //Load configuration + m_settings = new SettingsModel(); + //Enabled main buttons connect(buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked())); connect(buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked())); @@ -214,6 +218,7 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_delayedFileTimer); LAMEXP_DELETE(m_metaData); LAMEXP_DELETE(m_metaInfoModel); + LAMEXP_DELETE(m_settings); } //////////////////////////////////////////////////////////// @@ -269,14 +274,26 @@ void MainWindow::windowShown(void) { QStringList arguments = QApplication::arguments(); - AboutDialog *about = new AboutDialog(this, true); - int iAccepted = about->exec(); - LAMEXP_DELETE(about); - - if(iAccepted <= 0) + if(m_settings->licenseAccepted() <= 0) { - QApplication::quit(); - return; + int iAccepted = -1; + + if(m_settings->licenseAccepted() == 0) + { + AboutDialog *about = new AboutDialog(this, true); + iAccepted = about->exec(); + LAMEXP_DELETE(about); + } + + if(iAccepted <= 0) + { + m_settings->setLicenseAccepted(-1); + QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!"); + QApplication::quit(); + return; + } + + m_settings->setLicenseAccepted(1); } //Check for AAC support diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index ba14f3a9..7a0c08d5 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -31,6 +31,7 @@ class WorkingBanner; class MessageHandlerThread; class AudioFileModel; class MetaInfoModel; +class SettingsModel; class MainWindow: public QMainWindow, private Ui::MainWindow { @@ -84,4 +85,5 @@ private: QTimer *m_delayedFileTimer; AudioFileModel *m_metaData; MetaInfoModel *m_metaInfoModel; + SettingsModel *m_settings; }; diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp new file mode 100644 index 00000000..c3c01946 --- /dev/null +++ b/src/Model_Settings.cpp @@ -0,0 +1,60 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#include "Model_Settings.h" + +#include "Global.h" + +#include +#include +#include + +static const char *g_settingsVersionNumber = "VersionNumber"; +static const char *g_settingsLicenseAccepted = "LicenseAccepted"; + +//////////////////////////////////////////////////////////// +// Constructor +//////////////////////////////////////////////////////////// + +SettingsModel::SettingsModel(void) +{ + qDebug(QDesktopServices::storageLocation(QDesktopServices::DataLocation).toUtf8().constData()); + m_settings = new QSettings(QDesktopServices::storageLocation(QDesktopServices::DataLocation).append("/config.ini"), QSettings::IniFormat); + m_settings->beginGroup(QString().sprintf("LameXP_%u%02u%05u", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build())); + m_settings->setValue(g_settingsVersionNumber, QApplication::applicationVersion()); + m_settings->sync(); +} + +//////////////////////////////////////////////////////////// +// Destructor +//////////////////////////////////////////////////////////// + +SettingsModel::~SettingsModel(void) +{ + LAMEXP_DELETE(m_settings); +} + +//////////////////////////////////////////////////////////// +// Public Functions +//////////////////////////////////////////////////////////// + +int SettingsModel::licenseAccepted(void) { return m_settings->value(g_settingsLicenseAccepted, 0).toInt(); } +void SettingsModel::setLicenseAccepted(int value) { m_settings->setValue(g_settingsLicenseAccepted, value); } diff --git a/src/Model_Settings.h b/src/Model_Settings.h new file mode 100644 index 00000000..c4c20430 --- /dev/null +++ b/src/Model_Settings.h @@ -0,0 +1,40 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QSettings; + +class SettingsModel +{ +public: + SettingsModel(void); + ~SettingsModel(void); + + //Getters + int licenseAccepted(void); + + //Setters + void setLicenseAccepted(int value); + +private: + QSettings *m_settings; +};