added action to launch external player

This commit is contained in:
Martchus 2015-10-14 20:15:10 +02:00
parent a60bbe532a
commit 3a9e7db110
3 changed files with 57 additions and 7 deletions

View File

@ -41,6 +41,7 @@
#include <QMimeData>
#include <QTextStream>
#include <QFileSystemWatcher>
#include <QDesktopServices>
#ifdef TAGEDITOR_USE_WEBENGINE
#include <QWebEngineView>
#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<mutex> 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);
}
/*!

View File

@ -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);

View File

@ -330,6 +330,7 @@ the file reverting all unsaved changings.</string>
<addaction name="actionSave_file_information"/>
<addaction name="separator"/>
<addaction name="actionReload"/>
<addaction name="actionExternalPlayer"/>
<addaction name="actionSave"/>
<addaction name="actionDelete_all_tags"/>
<addaction name="separator"/>
@ -391,6 +392,9 @@ the file reverting all unsaved changings.</string>
<property name="text">
<string>&amp;Delete all tags</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="actionClose">
<property name="enabled">
@ -454,6 +458,9 @@ the file reverting all unsaved changings.</string>
<property name="text">
<string>&amp;Save file information as HTML document</string>
</property>
<property name="shortcut">
<string>Ctrl+H</string>
</property>
</action>
<action name="actionSelect_next_file_and_save_current">
<property name="icon">
@ -465,7 +472,7 @@ the file reverting all unsaved changings.</string>
<string>Select &amp;next file and save current</string>
</property>
<property name="shortcut">
<string>F5</string>
<string>F3</string>
</property>
</action>
<action name="actionAbout">
@ -538,10 +545,31 @@ the file reverting all unsaved changings.</string>
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="document-revert"/>
<iconset theme="document-revert">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Reload (reverts all changes!)</string>
<string>&amp;Reload (reverts all changes!)</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
</action>
<action name="actionExternalPlayer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="media-playback-start">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>&amp;Play (external player)</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
</property>
</action>
</widget>