Added two new command-line switches: "--add-folder <path>" to add a single folder and "--add-recursive <path>" to add a folder recursively.

This commit is contained in:
LoRd_MuldeR 2011-06-11 17:18:30 +02:00
parent 63b9bac56a
commit f8f5707529
7 changed files with 115 additions and 33 deletions

View File

@ -24,6 +24,7 @@ a:visited { color: #0000EE; }
<li>Added Avisynth input (audio only!) using 'avs2wav' tool, partly based on code by Jory Stone
<li>Added a method to use custom tools instead of the "built-in" ones (see <a href="FAQ.html#3d6684e9" target="_blank">FAQ doc</a> for details)
<li>Added an option to copy all meta information of a single file over to the "meta information" tab
<li>Added two new command-line switches: "--add-folder &lt;path&gt;" and "--add-recursive &lt;path&gt;"
<li>Added one new translation: Korean
<li>Updated Qt runtime libraries to v4.7.3
<li>Updated LAME encoder to v3.99.1.0 (2011-04-15), compiled with ICL 12.0.3 and MSVC 10.0 (<a href="http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/history.html?revision=1.127" target="_blank">details</a>)

View File

@ -29,8 +29,8 @@
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 2
#define VER_LAMEXP_TYPE RC
#define VER_LAMEXP_PATCH 1
#define VER_LAMEXP_BUILD 570
#define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 572
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -381,6 +381,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
m_delayedFileTimer->setInterval(5000);
connect(m_messageHandler, SIGNAL(otherInstanceDetected()), this, SLOT(notifyOtherInstance()), Qt::QueuedConnection);
connect(m_messageHandler, SIGNAL(fileReceived(QString)), this, SLOT(addFileDelayed(QString)), Qt::QueuedConnection);
connect(m_messageHandler, SIGNAL(folderReceived(QString, bool)), this, SLOT(addFolderDelayed(QString, bool)), Qt::QueuedConnection);
connect(m_messageHandler, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection);
connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
m_messageHandler->start();
@ -490,7 +491,7 @@ void MainWindow::addFiles(const QStringList &files)
/*
* Add folder to source list
*/
void MainWindow::addFolder(const QString &path, bool recursive)
void MainWindow::addFolder(const QString &path, bool recursive, bool delayed)
{
QFileInfoList folderInfoList;
folderInfoList << QFileInfo(path);
@ -533,7 +534,14 @@ void MainWindow::addFolder(const QString &path, bool recursive)
if(!fileList.isEmpty())
{
addFiles(fileList);
if(delayed)
{
addFilesDelayed(fileList);
}
else
{
addFiles(fileList);
}
}
}
@ -776,8 +784,7 @@ void MainWindow::dropEvent(QDropEvent *event)
if(!droppedFiles.isEmpty())
{
m_delayedFileList->append(droppedFiles);
QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
addFilesDelayed(droppedFiles, true);
}
}
@ -999,18 +1006,34 @@ void MainWindow::windowShown(void)
//Add files from the command-line
for(int i = 0; i < arguments.count() - 1; i++)
{
QStringList addedFiles;
if(!arguments[i].compare("--add", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
qDebug("Adding file from CLI: %s", currentFile.canonicalFilePath().toUtf8().constData());
m_delayedFileList->append(currentFile.canonicalFilePath());
qDebug("Adding file from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
addedFiles.append(currentFile.absoluteFilePath());
}
if(!addedFiles.isEmpty())
{
addFilesDelayed(addedFiles);
}
}
//Start delayed files timer
if(!m_delayedFileList->isEmpty() && !m_delayedFileTimer->isActive())
//Add folders from the command-line
for(int i = 0; i < arguments.count() - 1; i++)
{
m_delayedFileTimer->start(5000);
if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
qDebug("Adding folder from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
addFolder(currentFile.absoluteFilePath(), false, true);
}
if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive))
{
QFileInfo currentFile(arguments[++i].trimmed());
qDebug("Adding folder recursively from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData());
addFolder(currentFile.absoluteFilePath(), true, true);
}
}
//Enable shell integration
@ -1885,14 +1908,16 @@ void MainWindow::findFileContextActionTriggered(void)
*/
void MainWindow::handleDelayedFiles(void)
{
if(m_banner->isVisible())
m_delayedFileTimer->stop();
if(m_delayedFileList->isEmpty())
{
return;
}
m_delayedFileTimer->stop();
if(m_delayedFileList->isEmpty())
if(m_banner->isVisible())
{
m_delayedFileTimer->start(5000);
return;
}
@ -1902,23 +1927,11 @@ void MainWindow::handleDelayedFiles(void)
while(!m_delayedFileList->isEmpty())
{
QFileInfo currentFile = QFileInfo(m_delayedFileList->takeFirst());
if(!currentFile.exists())
if(!currentFile.exists() || !currentFile.isFile())
{
continue;
}
if(currentFile.isFile())
{
selectedFiles << currentFile.canonicalFilePath();
continue;
}
if(currentFile.isDir())
{
QList<QFileInfo> list = QDir(currentFile.canonicalFilePath()).entryInfoList(QDir::Files);
for(int j = 0; j < list.count(); j++)
{
selectedFiles << list.at(j).canonicalFilePath();
}
}
selectedFiles << currentFile.canonicalFilePath();
}
addFiles(selectedFiles);
@ -2745,14 +2758,50 @@ void MainWindow::notifyOtherInstance(void)
/*
* Add file from another instance
*/
void MainWindow::addFileDelayed(const QString &filePath)
void MainWindow::addFileDelayed(const QString &filePath, bool tryASAP)
{
if(tryASAP && !m_delayedFileTimer->isActive())
{
qDebug("Received file: %s", filePath.toUtf8().constData());
m_delayedFileList->append(filePath);
QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
}
m_delayedFileTimer->stop();
qDebug("Received file: %s", filePath.toUtf8().constData());
m_delayedFileList->append(filePath);
m_delayedFileTimer->start(5000);
}
/*
* Add files from another instance
*/
void MainWindow::addFilesDelayed(const QStringList &filePaths, bool tryASAP)
{
if(tryASAP && !m_delayedFileTimer->isActive())
{
qDebug("Received %d files.", filePaths.count());
m_delayedFileList->append(filePaths);
QTimer::singleShot(0, this, SLOT(handleDelayedFiles()));
}
m_delayedFileTimer->stop();
qDebug("Received %d files.", filePaths.count());
m_delayedFileList->append(filePaths);
m_delayedFileTimer->start(5000);
}
/*
* Add folder from another instance
*/
void MainWindow::addFolderDelayed(const QString &folderPath, bool recursive)
{
if(!m_banner->isVisible())
{
addFolder(folderPath, recursive, true);
}
}
// =========================================================
// Misc slots
// =========================================================

View File

@ -48,8 +48,10 @@ public:
private slots:
void aboutButtonClicked(void);
void addFileDelayed(const QString &filePath);
void addFileDelayed(const QString &filePath, bool tryASAP = false);
void addFilesButtonClicked(void);
void addFilesDelayed(const QStringList &filePaths, bool tryASAP = false);
void addFolderDelayed(const QString &folderPath, bool recursive);
void aftenCodingModeChanged(int value);
void aftenDRCModeChanged(int value);
void aftenFastAllocationChanged(bool checked);
@ -137,7 +139,7 @@ protected:
private:
void addFiles(const QStringList &files);
void addFolder(const QString &path, bool recursive = false);
void addFolder(const QString &path, bool recursive = false, bool delayed = false);
bool checkForUpdates(void);
bool installWMADecoder(void);

View File

@ -60,6 +60,12 @@ void MessageHandlerThread::run()
case 1:
emit fileReceived(QString::fromUtf8(m_parameter));
break;
case 2:
emit folderReceived(QString::fromUtf8(m_parameter), false);
break;
case 3:
emit folderReceived(QString::fromUtf8(m_parameter), true);
break;
case 666:
if(!_stricmp(m_parameter, "Force!"))
{

View File

@ -40,5 +40,6 @@ private:
signals:
void otherInstanceDetected(void);
void fileReceived(const QString &filePath);
void folderReceived(const QString &filePath, bool recursive);
void killSignalReceived(void);
};

View File

@ -26,6 +26,7 @@
#include <QStringList>
#include <QApplication>
#include <QFileInfo>
#include <QDir>
#include <limits.h>
@ -65,7 +66,29 @@ void MessageProducerThread::run()
{
if(!arguments[i].compare("--add", Qt::CaseInsensitive))
{
lamexp_ipc_send(1, QFileInfo(arguments[++i]).canonicalFilePath().toUtf8().constData());
QFileInfo file = QFileInfo(arguments[++i]);
if(file.exists() && file.isFile())
{
lamexp_ipc_send(1, file.canonicalFilePath().toUtf8().constData());
}
bSentFiles = true;
}
if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive))
{
QDir dir = QDir(arguments[++i]);
if(dir.exists())
{
lamexp_ipc_send(2, dir.canonicalPath().toUtf8().constData());
}
bSentFiles = true;
}
if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive))
{
QDir dir = QDir(arguments[++i]);
if(dir.exists())
{
lamexp_ipc_send(3, dir.canonicalPath().toUtf8().constData());
}
bSentFiles = true;
}
}