OSDN Git Service

Added options to disable the notifications for the Nero AAC encoder and the WMA Decod...
authorlordmulder <mulder2@gmx.de>
Sun, 19 Dec 2010 20:23:43 +0000 (21:23 +0100)
committerlordmulder <mulder2@gmx.de>
Sun, 19 Dec 2010 20:23:43 +0000 (21:23 +0100)
gui/MainWindow.ui
src/Config.h
src/Dialog_About.cpp
src/Dialog_MainWindow.cpp
src/Dialog_MainWindow.h
src/Encoder_Wave.cpp
src/Global.cpp
src/Global.h
src/Model_Settings.cpp
src/Model_Settings.h

index fa2e5f3..bc53f5b 100644 (file)
      </property>
      <addaction name="actionDisableSounds"/>
      <addaction name="actionDisableUpdateReminder"/>
+     <addaction name="actionDisableWmaDecoderNotifications"/>
+     <addaction name="actionDisableNeroAacNotifications"/>
     </widget>
     <addaction name="menuConfiguration"/>
     <addaction name="actionInstallWMADecoder"/>
     <string>Install WMA Decoder</string>
    </property>
   </action>
+  <action name="actionDisableNeroAacNotifications">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Disable Nero AAC Notifications</string>
+   </property>
+  </action>
+  <action name="actionDisableWmaDecoderNotifications">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Disable WMA Decoder Notifications</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../res/Icons.qrc"/>
   <include location="../res/Images.qrc"/>
   <include location="../res/Icons.qrc"/>
   <include location="../res/Images.qrc"/>
+  <include location="../res/Icons.qrc"/>
+  <include location="../res/Images.qrc"/>
+  <include location="../res/Icons.qrc"/>
+  <include location="../res/Images.qrc"/>
  </resources>
  <connections>
   <connection>
index 5fa117f..2194f0e 100644 (file)
@@ -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                               167
+#define VER_LAMEXP_BUILD                               170
 #define VER_LAMEXP_SUFFIX                              TechPreview
 
 /*
index 6f812d0..7ddd00c 100644 (file)
@@ -61,8 +61,8 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
        aboutText += "<h2>LameXP - Audio Encoder Front-end</h2>";
        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()));
        aboutText += QString().sprintf("<b>Version %d.%02d %s, Build %d [%s]</b><br><br>", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
-       aboutText += "<nobr>Please visit the official web-site at ";
-       aboutText += LINK("http://mulder.dummwiedeutsch.de/") += " for news and updates!</nobr><br>";
+       aboutText += "<nobr>Please visit "; //the official web-site at
+       aboutText += LINK("http://forum.doom9.org/showthread.php?t=157726") += " for news and updates!</nobr><br>"; //LINK("http://mulder.dummwiedeutsch.de/")
        aboutText += "<hr><br>";
        aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
        aboutText += "modify it under the terms of the GNU General Public License<br>";
index 12ab457..2b0c0d4 100644 (file)
@@ -251,9 +251,13 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
        //Activate tools menu actions
        actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled());
        actionDisableSounds->setChecked(!m_settings->soundsEnabled());
+       actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
+       actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled());
        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)));
+       connect(actionDisableNeroAacNotifications, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool)));
+       connect(actionDisableWmaDecoderNotifications, SIGNAL(triggered(bool)), this, SLOT(disableWmaDecoderNotificationsActionTriggered(bool)));
                
        //Activate help menu actions
        connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
@@ -516,39 +520,45 @@ void MainWindow::windowShown(void)
        }
 
        //Check for AAC support
-       if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe"))
+       if(m_settings->neroAacNotificationsEnabled())
        {
-               if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
+               if(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe"))
                {
+                       if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
+                       {
+                               QString messageText;
+                               messageText += "<nobr>LameXP detected that your version of the Nero AAC encoder is outdated!<br>";
+                               messageText += "The current version available is " + lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac()) + " (or later), but you still have version " + lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe")) + " installed.<br><br>";
+                               messageText += "You can download the latest version of the Nero AAC encoder from the Nero website at:<br>";
+                               messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>";
+                               QMessageBox::information(this, "AAC Encoder Outdated", messageText);
+                       }
+               }
+               else
+               {
+                       radioButtonEncoderAAC->setEnabled(false);
                        QString messageText;
-                       messageText += "<nobr>LameXP detected that your version of the Nero AAC encoder is outdated!<br>";
-                       messageText += "The current version available is " + lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac()) + " (or later), but you still have version " + lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe")) + " installed.<br><br>";
-                       messageText += "You can download the latest version of the Nero AAC encoder from the Nero website at:<br>";
+                       messageText += "<nobr>The Nero AAC encoder could not be found. AAC encoding support will be disabled.<br>";
+                       messageText += "Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!<br><br>";
+                       messageText += "Your LameXP directory is as follows:<br>";
+                       messageText += "<i><nobr>" + QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "</nobr></i><br><br>";
+                       messageText += "You can download the Nero AAC encoder for free from the official Nero website at:<br>";
                        messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>";
-                       QMessageBox::information(this, "AAC Encoder Outdated", messageText);
+                       QMessageBox::information(this, "AAC Support Disabled", messageText);
                }
        }
-       else
-       {
-               radioButtonEncoderAAC->setEnabled(false);
-               QString messageText;
-               messageText += "<nobr>The Nero AAC encoder could not be found. AAC encoding support will be disabled.<br>";
-               messageText += "Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!<br><br>";
-               messageText += "Your LameXP directory is as follows:<br>";
-               messageText += "<i><nobr>" + QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "</nobr></i><br><br>";
-               messageText += "You can download the Nero AAC encoder for free from the official Nero website at:<br>";
-               messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>";
-               QMessageBox::information(this, "AAC Support Disabled", messageText);
-       }
        
        //Check for WMA support
-       if(!lamexp_check_tool("wmawav.exe"))
+       if(m_settings->wmaDecoderNotificationsEnabled())
        {
-               QString messageText;
-               messageText += "<nobr>LameXP has detected that the WMA File Decoder component is not currently installed on your system.<br>";
-               messageText += "You won't be able to process WMA files as input unless the WMA File Decoder component is installed!</nobr>";
-               QMessageBox::information(this, "WMA Decoder Missing", messageText);
-               installWMADecoderActionTriggered(rand() % 2);
+               if(!lamexp_check_tool("wmawav.exe"))
+               {
+                       QString messageText;
+                       messageText += "<nobr>LameXP has detected that the WMA File Decoder component is not currently installed on your system.<br>";
+                       messageText += "You won't be able to process WMA files as input unless the WMA File Decoder component is installed!</nobr>";
+                       QMessageBox::information(this, "WMA Decoder Missing", messageText);
+                       installWMADecoderActionTriggered(rand() % 2);
+               }
        }
 
        //Add files from the command-line
@@ -585,7 +595,7 @@ void MainWindow::aboutButtonClicked(void)
 void MainWindow::encodeButtonClicked(void)
 {
        static const __int64 oneGigabyte = 1073741824; 
-       static const __int64 minimumFreeDiskspaceMultiplier = 222;
+       static const __int64 minimumFreeDiskspaceMultiplier = 2;
        
        ABORT_IF_BUSY;
        
@@ -596,13 +606,22 @@ void MainWindow::encodeButtonClicked(void)
                return;
        }
        
-       if(lamexp_free_diskspace(lamexp_temp_folder()) < (oneGigabyte * minimumFreeDiskspaceMultiplier))
+       __int64 currentFreeDiskspace = lamexp_free_diskspace(lamexp_temp_folder());
+
+       if(currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier))
        {
-               QDir tempFolder(lamexp_temp_folder());
-               tempFolder.cdUp();
-               if(QMessageBox::warning(this, "Low Diskspace Warning", QString("<nobr>Warning: There are less than %1 GB of free diskspace available on your system's TEMP folder!</nobr><br><br>Your TEMP folder is located at:<br><i>%2</i>").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolder.path()), "Abort Process (Recommended)", "Ignore") != 1)
+               QStringList tempFolderParts = lamexp_temp_folder().split("/", QString::SkipEmptyParts, Qt::CaseInsensitive);
+               tempFolderParts.takeLast();
+               switch(QMessageBox::warning(this, "Low Diskspace Warning", QString("<nobr>There are less than %1 GB of free diskspace available on your system's TEMP folder.</nobr><br><nobr>It is highly recommend to free up more diskspace before proceeding with the encode!.</nobr><br><br>Your TEMP folder is located at:<br><nobr><i><a href=\"file:///%3\">%3</a></i></nobr><br>").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolderParts.join("\\")), "Abort Encoding Process", "Clean Disk Now", "Ignore"))
                {
+               case 1:
+                       QProcess::startDetached(QString("%1/cleanmgr.exe").arg(lamexp_known_folder(lamexp_folder_systemfolder)), QStringList() << "/D" << tempFolderParts.first());
+               case 0:
                        return;
+                       break;
+               default:
+                       QMessageBox::warning(this, "Low Diskspace", "You are proceeding with low diskspace. Problems might occur!");
+                       break;
                }
        }
 
@@ -1454,6 +1473,61 @@ void MainWindow::disableSoundsActionTriggered(bool checked)
        actionDisableSounds->setChecked(!m_settings->soundsEnabled());
 }
 
+/*
+ * Disable Nero AAC encoder action
+ */
+void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked)
+{
+       if(checked)
+       {
+               if(QMessageBox::Yes == QMessageBox::question(this, "Nero AAC Notifications", "Do you really want to disable all Nero AAC Encoder notifications?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
+               {
+                       QMessageBox::information(this, "Nero AAC Notifications", "All Nero AAC Encoder notifications have been disabled.");
+                       m_settings->neroAacNotificationsEnabled(false);
+               }
+               else
+               {
+                       m_settings->neroAacNotificationsEnabled(true);
+               }
+       }
+       else
+       {
+                       QMessageBox::information(this, "Nero AAC Notifications", "The Nero AAC Encoder notifications have been re-enabled.");
+                       m_settings->neroAacNotificationsEnabled(true);
+       }
+
+       actionDisableNeroAacNotifications->setChecked(!m_settings->neroAacNotificationsEnabled());
+}
+
+/*
+ * Disable WMA Decoder component action
+ */
+void MainWindow::disableWmaDecoderNotificationsActionTriggered(bool checked)
+{
+       if(checked)
+       {
+               if(QMessageBox::Yes == QMessageBox::question(this, "WMA Decoder Notifications", "Do you really want to disable all WMA Decoder notifications?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
+               {
+                       QMessageBox::information(this, "WMA Decoder Notifications", "All WMA Decoder notifications have been disabled.");
+                       m_settings->wmaDecoderNotificationsEnabled(false);
+               }
+               else
+               {
+                       m_settings->wmaDecoderNotificationsEnabled(true);
+               }
+       }
+       else
+       {
+                       QMessageBox::information(this, "WMA Decoder Notifications", "The WMA Decoder notifications have been re-enabled.");
+                       m_settings->wmaDecoderNotificationsEnabled(true);
+       }
+
+       actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled());
+}
+
+/*
+ * Download and install WMA Decoder component
+ */
 void MainWindow::installWMADecoderActionTriggered(bool checked)
 {
        static const char *download_url = "http://www.nch.com.au/components/wmawav.exe";
index 58cb71b..bdb684a 100644 (file)
@@ -89,6 +89,8 @@ private slots:
        void outputFolderContextMenu(const QPoint &pos);
        void showFolderContextActionTriggered(void);
        void installWMADecoderActionTriggered(bool checked);
+       void disableNeroAacNotificationsActionTriggered(bool checked);
+       void disableWmaDecoderNotificationsActionTriggered(bool checked);
 
 protected:
        void showEvent(QShowEvent *event);
index f4d834c..ea9ee65 100644 (file)
@@ -42,13 +42,23 @@ WaveEncoder::~WaveEncoder(void)
 
 bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag)
 {
-       emit messageLogged(QString("Moving file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
-       
        SHFILEOPSTRUCTW fileOperation;
        memset(&fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
-       fileOperation.wFunc = FO_MOVE;
        fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_FILESONLY;
 
+       if(lamexp_temp_folder().compare(QFileInfo(sourceFile).canonicalPath(), Qt::CaseInsensitive) == 0)
+       {
+               //If the source is in the TEMP folder take shortcut and move the file
+               emit messageLogged(QString("Moving file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
+               fileOperation.wFunc = FO_MOVE;
+       }
+       else
+       {
+               //...otherwise we actually copy the file in order to keep the source
+               emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
+               fileOperation.wFunc = FO_COPY;
+       }
+       
        size_t srcLen = wcslen(reinterpret_cast<const wchar_t*>(sourceFile.utf16())) + 3;
        wchar_t *srcBuffer = new wchar_t[srcLen];
        memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
index efcefc7..6e8b695 100644 (file)
@@ -832,9 +832,11 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
 
        static const int CSIDL_LOCAL_APPDATA = 0x001c;
        static const int CSIDL_PROGRAM_FILES = 0x0026;
+       static const int CSIDL_SYSTEM_FOLDER = 0x0025;
        static const GUID GUID_LOCAL_APPDATA = {0xF1B32785,0x6FBA,0x4FCF,{0x9D,0x55,0x7B,0x8E,0x7F,0x15,0x70,0x91}};
        static const GUID GUID_LOCAL_APPDATA_LOW = {0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
        static const GUID GUID_PROGRAM_FILES = {0x905e63b6,0xc1bf,0x494e,{0xb2,0x9c,0x65,0xb7,0x32,0xd3,0xd2,0x1a}};
+       static const GUID GUID_SYSTEM_FOLDER = {0x1AC14E77,0x02E7,0x4E5D,{0xB7,0x44,0x2E,0xB1,0xAE,0x51,0x98,0xB7}};
 
        static QLibrary *Kernel32Lib = NULL;
        static SHGetKnownFolderPathFun SHGetKnownFolderPathPtr = NULL;
@@ -860,6 +862,10 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
                folderCSIDL = CSIDL_PROGRAM_FILES;
                folderGUID = GUID_PROGRAM_FILES;
                break;
+       case lamexp_folder_systemfolder:
+               folderCSIDL = CSIDL_SYSTEM_FOLDER;
+               folderGUID = GUID_SYSTEM_FOLDER;
+               break;
        default:
                return QString();
                break;
index 6241beb..8184901 100644 (file)
@@ -60,7 +60,8 @@ lamexp_cpu_t;
 typedef enum
 {
        lamexp_folder_localappdata = 0,
-       lamexp_folder_programfiles = 1
+       lamexp_folder_programfiles = 2,
+       lamexp_folder_systemfolder = 3
 }
 lamexp_known_folder_t;
 
index deebff9..4e70b5d 100644 (file)
@@ -44,6 +44,8 @@ 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";
+static const char *g_settingsId_neroAacNotificationsEnabled = "Flags/EnableNeroAacNotifications";
+static const char *g_settingsId_wmaDecoderNotificationsEnabled = "Flags/EnableWmaDecoderNotifications";
 
 //Macros
 #define MAKE_OPTION1(OPT,DEF) \
@@ -128,3 +130,5 @@ MAKE_OPTION3(createPlaylist, true)
 MAKE_OPTION2(autoUpdateLastCheck, "Never")
 MAKE_OPTION3(autoUpdateEnabled, true)
 MAKE_OPTION3(soundsEnabled, true)
+MAKE_OPTION3(neroAacNotificationsEnabled, true)
+MAKE_OPTION3(wmaDecoderNotificationsEnabled, true)
index 51c1caf..962a85d 100644 (file)
@@ -75,6 +75,8 @@ public:
        MAKE_OPTION_DEC2(autoUpdateLastCheck);
        MAKE_OPTION_DEC3(autoUpdateEnabled);
        MAKE_OPTION_DEC3(soundsEnabled);
+       MAKE_OPTION_DEC3(neroAacNotificationsEnabled)
+       MAKE_OPTION_DEC3(wmaDecoderNotificationsEnabled)
 
        //Misc
        void validate(void);