From: lordmulder Date: Thu, 25 Nov 2010 19:41:59 +0000 (+0100) Subject: Addded context menu to "source file" view + make the "output folder" view update... X-Git-Tag: Release_400~182 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4fd8ec068e8859e49dcc58a28a093503e538f1aa;p=lamexp%2FLameXP.git Addded context menu to "source file" view + make the "output folder" view update the output path more frequently on selection change. --- diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 90d1c157..c0863ff2 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -252,6 +252,9 @@ + + QAbstractItemView::NoEditTriggers + true @@ -1350,6 +1353,8 @@ + + diff --git a/src/Config.h b/src/Config.h index 602d08c8..dd1aa749 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 80 +#define VER_LAMEXP_BUILD 82 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index eb286737..ffec4da1 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -54,6 +54,7 @@ #include #include #include +#include //Win32 includes #include @@ -64,7 +65,6 @@ #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define LINK(URL) QString("%2").arg(URL).arg(URL) - //Helper class class Index: public QObjectUserData { @@ -114,11 +114,17 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S sourceFileView->setModel(m_fileListModel); sourceFileView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); sourceFileView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu); m_dropNoteLabel = new QLabel(sourceFileView); m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); m_dropNoteLabel->setText("» You can drop in audio files here! «"); SET_FONT_BOLD(m_dropNoteLabel, true); 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(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked())); connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked())); @@ -128,7 +134,11 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S 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(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 m_fileSystemModel = new QFileSystemModelEx(); m_fileSystemModel->setRootPath(m_fileSystemModel->rootPath()); @@ -140,8 +150,12 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S outputFolderView->header()->hideSection(3); outputFolderView->setHeaderHidden(true); outputFolderView->setAnimated(true); + outputFolderView->installEventFilter(this); + outputFolderView->setMouseTracking(false); while(saveToSourceFolderCheckBox->isChecked() != m_settings->outputToSourceDir()) saveToSourceFolderCheckBox->click(); 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())); outputFolderViewClicked(outputFolderView->currentIndex()); connect(buttonMakeFolder, SIGNAL(clicked()), this, SLOT(makeFolderButtonClicked())); @@ -284,6 +298,7 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_metaInfoModel); 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)); QTimer::singleShot(250, this, SLOT(restoreCursor())); } - + else if(obj == outputFolderView && (event->type() == QEvent::KeyRelease || event->type() == QEvent::KeyPress)) + { + outputFolderViewClicked(outputFolderView->currentIndex()); + } return false; } @@ -1131,3 +1149,47 @@ void MainWindow::restoreCursor(void) { 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())); + } +} diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index cba8c17c..454b7a4d 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -33,6 +33,7 @@ class SettingsModel; class QButtonGroup; class FileListModel; class AbstractEncoder; +class QMenu; class MainWindow: public QMainWindow, private Ui::MainWindow { @@ -79,6 +80,9 @@ private slots: void playlistEnabledChanged(void); void saveToSourceFolderChanged(void); void restoreCursor(void); + void sourceFilesContextMenu(const QPoint &pos); + void previewContextActionTriggered(void); + void findFileContextActionTriggered(void); protected: void showEvent(QShowEvent *event); @@ -107,4 +111,5 @@ private: MetaInfoModel *m_metaInfoModel; SettingsModel *m_settings; QLabel *m_dropNoteLabel; + QMenu *m_sourceFilesContextMenu; }; diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 7e9bf3cf..68b45f48 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -254,6 +254,7 @@ void ProcessingDialog::doneEncoding(void) return; } + QApplication::setOverrideCursor(Qt::WaitCursor); qDebug("Running jobs: %u", m_runningThreads); if(!m_userAborted && m_settings->createPlaylist() && !m_settings->outputToSourceDir()) @@ -292,6 +293,8 @@ void ProcessingDialog::doneEncoding(void) view_log->scrollToBottom(); m_progressIndicator->stop(); progressBar->setValue(100); + + QApplication::restoreOverrideCursor(); } void ProcessingDialog::processFinished(const QUuid &jobId, const QString &outFileName, bool success)