From e3e0ec36aa9ac108c9d99ad8968da2888441c42f Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sat, 13 Nov 2010 02:11:15 +0100 Subject: [PATCH] Implemented support for adding directories via Drag&Drop and CLI --- LameXP.vcproj | 8 ++--- src/Dialog_MainWindow.cpp | 58 ++++++++++++++++++++++++---------- src/Global.h | 5 +++ src/Main.cpp | 2 +- src/Thread_MessageProducer.cpp | 3 +- 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/LameXP.vcproj b/LameXP.vcproj index 67815874..21699844 100644 --- a/LameXP.vcproj +++ b/LameXP.vcproj @@ -128,7 +128,6 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="true" - WholeProgramOptimization="true" AdditionalIncludeDirectories=""$(QTDIR)\include";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui"" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;QT_LARGEFILE_SUPPORT;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_NO_DEBUG" MinimalRebuild="false" @@ -161,7 +160,6 @@ GenerateMapFile="false" MapExports="false" SubSystem="2" - LinkTimeCodeGeneration="1" TargetMachine="1" /> @@ -386,7 +384,7 @@ @@ -396,7 +394,7 @@ diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 8e981e38..c2e4df52 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -293,12 +293,9 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event) { QStringList formats = event->mimeData()->formats(); - for(int i = 0; i < formats.count(); i++) + if(formats.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive) && formats.contains("text/uri-list", Qt::CaseInsensitive)) { - if(formats[i].indexOf("FileNameW") >= 0) - { - event->acceptProposedAction(); - } + event->acceptProposedAction(); } } @@ -311,7 +308,24 @@ void MainWindow::dropEvent(QDropEvent *event) for(int i = 0; i < urls.count(); i++) { - droppedFiles << QFileInfo(urls.at(i).toLocalFile()).absoluteFilePath(); + QFileInfo file(urls.at(i).toLocalFile()); + if(!file.exists()) + { + continue; + } + if(file.isFile()) + { + droppedFiles << file.canonicalFilePath(); + continue; + } + if(file.isDir()) + { + QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files); + for(int j = 0; j < list.count(); j++) + { + droppedFiles << list.at(j).absoluteFilePath(); + } + } } addFiles(droppedFiles); @@ -381,15 +395,8 @@ void MainWindow::windowShown(void) if(!arguments[i].compare("--add", Qt::CaseInsensitive)) { QFileInfo currentFile(arguments[++i].trimmed()); - qDebug("Adding file from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData()); - if(currentFile.exists()) - { - m_delayedFileList->append(currentFile.absoluteFilePath()); - } - else - { - qWarning("File doesn't exist: %s", currentFile.absoluteFilePath().toUtf8().constData()); - } + qDebug("Adding file from CLI: %s", currentFile.canonicalFilePath().toUtf8().constData()); + m_delayedFileList->append(currentFile.canonicalFilePath()); } } @@ -445,7 +452,7 @@ void MainWindow::openFolderActionActivated(void) while(!fileInfoList.isEmpty()) { - fileList << fileInfoList.takeFirst().absoluteFilePath(); + fileList << fileInfoList.takeFirst().canonicalFilePath(); } addFiles(fileList); @@ -771,7 +778,24 @@ void MainWindow::handleDelayedFiles(void) while(!m_delayedFileList->isEmpty()) { - selectedFiles << QFileInfo(m_delayedFileList->takeFirst()).absoluteFilePath(); + QFileInfo currentFile = QFileInfo(m_delayedFileList->takeFirst()); + if(!currentFile.exists()) + { + continue; + } + if(currentFile.isFile()) + { + selectedFiles << currentFile.canonicalFilePath(); + continue; + } + if(currentFile.isDir()) + { + QList list = QDir(currentFile.canonicalFilePath()).entryInfoList(QDir::Files); + for(int j = 0; j < list.count(); j++) + { + selectedFiles << list.at(j).absoluteFilePath(); + } + } } addFiles(selectedFiles); diff --git a/src/Global.h b/src/Global.h index 48265c5b..dc7713dd 100644 --- a/src/Global.h +++ b/src/Global.h @@ -98,3 +98,8 @@ SIZE_T lamexp_dbg_private_bytes(void); #else #define LAMEXP_MEMORY_CHECK(CMD) CMD #endif + +//Check for CPU-compatibility options +#if _M_IX86_FP != 0 +#error We should not enabled SSE or SSE2 in release builds! +#endif diff --git a/src/Main.cpp b/src/Main.cpp index 6e040ef5..81b8c59a 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -52,7 +52,7 @@ int lamexp_main(int argc, char* argv[]) qDebug("This program is free software: you can redistribute it and/or modify"); qDebug("it under the terms of the GNU General Public License ."); qDebug("This program comes with ABSOLUTELY NO WARRANTY.\n"); - + //Print warning, if this is a "debug" build LAMEXP_CHECK_DEBUG_BUILD; diff --git a/src/Thread_MessageProducer.cpp b/src/Thread_MessageProducer.cpp index 7f4fe182..51fc53c4 100644 --- a/src/Thread_MessageProducer.cpp +++ b/src/Thread_MessageProducer.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -64,7 +65,7 @@ void MessageProducerThread::run() { if(!arguments[i].compare("--add", Qt::CaseInsensitive)) { - lamexp_ipc_send(1, arguments[++i].toUtf8().constData()); + lamexp_ipc_send(1, QFileInfo(arguments[++i]).canonicalFilePath().toUtf8().constData()); bSentFiles = true; } }