diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 04bffc0..46caeb4 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #ifdef TAGEDITOR_USE_WEBENGINE #include #else @@ -171,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_ui->actionSave_file_information, &QAction::triggered, this, &MainWindow::saveFileInformation); connect(m_ui->actionClose, &QAction::triggered, this, &MainWindow::closeFile); connect(m_ui->actionReload, &QAction::triggered, this, &MainWindow::reparseFile); + connect(m_ui->actionExternalPlayer, &QAction::triggered, this, &MainWindow::spawnExternalPlayer); // menu: directory connect(m_ui->actionSelect_next_file, &QAction::triggered, this, &MainWindow::selectNextFile); connect(m_ui->actionSelect_next_file_and_save_current, &QAction::triggered, this, &MainWindow::saveAndShowNextFile); @@ -510,6 +512,7 @@ void MainWindow::updateUiStatus() m_ui->actionSave_file_information->setEnabled(opened); m_ui->actionClose->setEnabled(opened); m_ui->actionReload->setEnabled(opened); + m_ui->actionExternalPlayer->setEnabled(opened); m_ui->buttonsWidget->setEnabled(opened); // clear and restore buttons m_ui->clearEntriesPushButton->setEnabled(hasTag); @@ -660,6 +663,18 @@ void MainWindow::copyInfoWebViewSelection() QApplication::clipboard()->setText(m_infoWebView->selectedText()); } +/*! + * \brief Spawns an external player for the current file. + */ +void MainWindow::spawnExternalPlayer() +{ + if(!m_currentPath.isEmpty()) { + QDesktopServices::openUrl(QStringLiteral("file://") + m_currentPath); + } else { + m_ui->statusBar->showMessage(tr("No file opened.")); + } +} + /*! * \brief Calls the specified \a function for each of the currently present tag edits. */ @@ -756,12 +771,18 @@ bool MainWindow::startParsing(const QString &path, bool forceRefresh) */ bool MainWindow::reparseFile() { - if(m_fileInfo.isOpen() && !m_currentPath.isEmpty()) { - return startParsing(m_currentPath, true); - } else { - QMessageBox::warning(this, windowTitle(), tr("Currently is not file opened.")); + if(!m_fileOperationMutex.try_lock()) { + m_ui->statusBar->showMessage(tr("Unable to reload the file because the current process hasn't finished yet.")); return false; } + { + lock_guard guard(m_fileOperationMutex, adopt_lock); + if(!m_fileInfo.isOpen() || m_currentPath.isEmpty()) { + QMessageBox::warning(this, windowTitle(), tr("Currently is not file opened.")); + return false; + } + } + return startParsing(m_currentPath, true); } /*! diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 9a70e8e..592f2a8 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -101,6 +101,7 @@ private slots: void updateInfoWebView(); void showInfoWebViewContextMenu(const QPoint &); void copyInfoWebViewSelection(); + void spawnExternalPlayer(); private: void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 21446d0..d429edd 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -330,6 +330,7 @@ the file reverting all unsaved changings. + @@ -391,6 +392,9 @@ the file reverting all unsaved changings. &Delete all tags + + Ctrl+D + @@ -454,6 +458,9 @@ the file reverting all unsaved changings. &Save file information as HTML document + + Ctrl+H + @@ -465,7 +472,7 @@ the file reverting all unsaved changings. Select &next file and save current - F5 + F3 @@ -538,10 +545,31 @@ the file reverting all unsaved changings. false - + + + - Reload (reverts all changes!) + &Reload (reverts all changes!) + + + F5 + + + + + false + + + + + + + + &Play (external player) + + + Ctrl+E