Addded context menu to "source file" view + make the "output folder" view update the output path more frequently on selection change.

This commit is contained in:
LoRd_MuldeR 2010-11-25 20:41:59 +01:00
parent 09bac5a0ea
commit 4fd8ec068e
5 changed files with 79 additions and 4 deletions

View File

@ -252,6 +252,9 @@
</item> </item>
<item> <item>
<widget class="QTreeView" name="outputFolderView"> <widget class="QTreeView" name="outputFolderView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1350,6 +1353,8 @@
<include location="../res/Images.qrc"/> <include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/> <include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/> <include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0 #define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 80 #define VER_LAMEXP_BUILD 82
#define VER_LAMEXP_SUFFIX TechPreview #define VER_LAMEXP_SUFFIX TechPreview
/* /*

View File

@ -54,6 +54,7 @@
#include <QWindowsMime> #include <QWindowsMime>
#include <QProcess> #include <QProcess>
#include <QUuid> #include <QUuid>
#include <QProcessEnvironment>
//Win32 includes //Win32 includes
#include <Windows.h> #include <Windows.h>
@ -64,7 +65,6 @@
#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL) #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(URL)
//Helper class //Helper class
class Index: public QObjectUserData class Index: public QObjectUserData
{ {
@ -114,11 +114,17 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
sourceFileView->setModel(m_fileListModel); sourceFileView->setModel(m_fileListModel);
sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu);
m_dropNoteLabel = new QLabel(sourceFileView); m_dropNoteLabel = new QLabel(sourceFileView);
m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_dropNoteLabel->setText("» You can drop in audio files here! «"); m_dropNoteLabel->setText("» You can drop in audio files here! «");
SET_FONT_BOLD(m_dropNoteLabel, true); SET_FONT_BOLD(m_dropNoteLabel, true);
SET_TEXT_COLOR(m_dropNoteLabel, Qt::darkGray); SET_TEXT_COLOR(m_dropNoteLabel, Qt::darkGray);
m_sourceFilesContextMenu = new QMenu();
QAction *showDetailsContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/zoom.png"), "Show Details");
QAction *previewContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/sound.png"), "Open File in External Application");
QAction *findFileContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_go.png"), "Browse File Location");
SET_FONT_BOLD(showDetailsContextAction, true);
connect(buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked())); connect(buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked()));
connect(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked())); connect(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked()));
connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked())); connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked()));
@ -128,6 +134,10 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sourceModelChanged()));
connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged()));
connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged())); connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged()));
connect(sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint)));
connect(showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked()));
connect(previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered()));
connect(findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered()));
//Setup "Output" tab //Setup "Output" tab
m_fileSystemModel = new QFileSystemModelEx(); m_fileSystemModel = new QFileSystemModelEx();
@ -140,8 +150,12 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
outputFolderView->header()->hideSection(3); outputFolderView->header()->hideSection(3);
outputFolderView->setHeaderHidden(true); outputFolderView->setHeaderHidden(true);
outputFolderView->setAnimated(true); outputFolderView->setAnimated(true);
outputFolderView->installEventFilter(this);
outputFolderView->setMouseTracking(false);
while(saveToSourceFolderCheckBox->isChecked() != m_settings->outputToSourceDir()) saveToSourceFolderCheckBox->click(); while(saveToSourceFolderCheckBox->isChecked() != m_settings->outputToSourceDir()) saveToSourceFolderCheckBox->click();
connect(outputFolderView, SIGNAL(clicked(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex))); connect(outputFolderView, SIGNAL(clicked(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
connect(outputFolderView, SIGNAL(activated(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
connect(outputFolderView, SIGNAL(entered(QModelIndex)), this, SLOT(outputFolderViewClicked(QModelIndex)));
outputFolderView->setCurrentIndex(m_fileSystemModel->index(m_settings->outputDir())); outputFolderView->setCurrentIndex(m_fileSystemModel->index(m_settings->outputDir()));
outputFolderViewClicked(outputFolderView->currentIndex()); outputFolderViewClicked(outputFolderView->currentIndex());
connect(buttonMakeFolder, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked())); connect(buttonMakeFolder, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked()));
@ -284,6 +298,7 @@ MainWindow::~MainWindow(void)
LAMEXP_DELETE(m_metaInfoModel); LAMEXP_DELETE(m_metaInfoModel);
LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_encoderButtonGroup);
LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_encoderButtonGroup);
LAMEXP_DELETE(m_sourceFilesContextMenu);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -401,7 +416,10 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QTimer::singleShot(250, this, SLOT(restoreCursor())); QTimer::singleShot(250, this, SLOT(restoreCursor()));
} }
else if(obj == outputFolderView && (event->type() == QEvent::KeyRelease || event->type() == QEvent::KeyPress))
{
outputFolderViewClicked(outputFolderView->currentIndex());
}
return false; return false;
} }
@ -1131,3 +1149,47 @@ void MainWindow::restoreCursor(void)
{ {
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
/*
* Show context menu for source files
*/
void MainWindow::sourceFilesContextMenu(const QPoint &pos)
{
m_sourceFilesContextMenu->popup(sourceFileView->mapToGlobal(pos));
}
/*
* Open selected file in external player
*/
void MainWindow::previewContextActionTriggered(void)
{
QModelIndex index = sourceFileView->currentIndex();
if(index.isValid())
{
QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath()));
}
}
/*
* Find selected file in explorer
*/
void MainWindow::findFileContextActionTriggered(void)
{
QModelIndex index = sourceFileView->currentIndex();
if(index.isValid())
{
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
QString systemRootPath = procEnv.value("SystemRoot", procEnv.value("windir"));
if(!systemRootPath.isEmpty())
{
QFileInfo explorer(QString("%1/explorer.exe").arg(systemRootPath));
if(explorer.exists() && explorer.isFile())
{
QProcess::execute(explorer.canonicalFilePath(), QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
return;
}
}
qWarning("SystemRoot directory could not be detected!");
QProcess::execute("explorer.exe", QStringList() << "/select," << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath()));
}
}

View File

@ -33,6 +33,7 @@ class SettingsModel;
class QButtonGroup; class QButtonGroup;
class FileListModel; class FileListModel;
class AbstractEncoder; class AbstractEncoder;
class QMenu;
class MainWindow: public QMainWindow, private Ui::MainWindow class MainWindow: public QMainWindow, private Ui::MainWindow
{ {
@ -79,6 +80,9 @@ private slots:
void playlistEnabledChanged(void); void playlistEnabledChanged(void);
void saveToSourceFolderChanged(void); void saveToSourceFolderChanged(void);
void restoreCursor(void); void restoreCursor(void);
void sourceFilesContextMenu(const QPoint &pos);
void previewContextActionTriggered(void);
void findFileContextActionTriggered(void);
protected: protected:
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
@ -107,4 +111,5 @@ private:
MetaInfoModel *m_metaInfoModel; MetaInfoModel *m_metaInfoModel;
SettingsModel *m_settings; SettingsModel *m_settings;
QLabel *m_dropNoteLabel; QLabel *m_dropNoteLabel;
QMenu *m_sourceFilesContextMenu;
}; };

View File

@ -254,6 +254,7 @@ void ProcessingDialog::doneEncoding(void)
return; return;
} }
QApplication::setOverrideCursor(Qt::WaitCursor);
qDebug("Running jobs: %u", m_runningThreads); qDebug("Running jobs: %u", m_runningThreads);
if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir()) if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir())
@ -292,6 +293,8 @@ void ProcessingDialog::doneEncoding(void)
view_log->scrollToBottom(); view_log->scrollToBottom();
m_progressIndicator->stop(); m_progressIndicator->stop();
progressBar->setValue(100); progressBar->setValue(100);
QApplication::restoreOverrideCursor();
} }
void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success) void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)