2016-02-29 23:59:46 +01:00
|
|
|
#ifndef TAGEDITORWIDGET_H
|
|
|
|
#define TAGEDITORWIDGET_H
|
|
|
|
|
|
|
|
#include "./previousvaluehandling.h"
|
|
|
|
|
|
|
|
#include <tagparser/mediafileinfo.h>
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QByteArray>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#if defined(TAGEDITOR_NO_WEBVIEW)
|
|
|
|
#elif defined(TAGEDITOR_USE_WEBENGINE)
|
|
|
|
# define WEB_VIEW_PROVIDER QWebEngineView
|
2016-04-21 23:55:22 +02:00
|
|
|
#elif defined(TAGEDITOR_USE_WEBKIT)
|
2016-02-29 23:59:46 +01:00
|
|
|
# define WEB_VIEW_PROVIDER QWebView
|
2016-04-21 23:55:22 +02:00
|
|
|
#else
|
|
|
|
# error "Macro for WebView provider not specified."
|
2016-02-29 23:59:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QMenu)
|
2016-04-24 21:07:36 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QTreeView)
|
2016-02-29 23:59:46 +01:00
|
|
|
#ifndef TAGEDITOR_NO_WEBVIEW
|
|
|
|
QT_FORWARD_DECLARE_CLASS(WEB_VIEW_PROVIDER)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Media {
|
2016-07-11 21:34:05 +02:00
|
|
|
DECLARE_ENUM_CLASS(TagType, unsigned int);
|
2016-02-29 23:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class TagEditorWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TagEdit;
|
2016-04-24 21:07:36 +02:00
|
|
|
class FileInfoModel;
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
class TagEditorWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-08-07 19:59:33 +02:00
|
|
|
Q_PROPERTY(QString currentPath READ currentPath NOTIFY currentPathChanged)
|
2016-11-18 17:59:53 +01:00
|
|
|
Q_PROPERTY(QString currentDir READ currentDir)
|
2016-09-25 23:59:04 +02:00
|
|
|
Q_PROPERTY(bool tagEditShown READ isTagEditShown)
|
2016-02-29 23:59:46 +01:00
|
|
|
Q_PROPERTY(QByteArray fileInfoHtml READ fileInfoHtml)
|
|
|
|
Q_PROPERTY(bool fileNameVisible READ isFileNameVisible WRITE setFileNameVisible)
|
|
|
|
Q_PROPERTY(bool buttonsVisible READ areButtonsVisible WRITE setButtonVisible)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit TagEditorWidget(QWidget *parent = nullptr);
|
2016-05-26 02:15:41 +02:00
|
|
|
~TagEditorWidget();
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
public:
|
2016-11-23 21:46:33 +01:00
|
|
|
bool fileOperationOngoing() const;
|
2016-02-29 23:59:46 +01:00
|
|
|
const QString ¤tPath() const;
|
2016-11-18 17:59:53 +01:00
|
|
|
const QString ¤tDir() const;
|
2016-02-29 23:59:46 +01:00
|
|
|
Media::MediaFileInfo &fileInfo();
|
2016-04-21 23:55:22 +02:00
|
|
|
Media::NotificationList &originalNotifications();
|
2016-03-03 22:21:15 +01:00
|
|
|
bool isTagEditShown() const;
|
2016-02-29 23:59:46 +01:00
|
|
|
const QByteArray &fileInfoHtml() const;
|
|
|
|
bool isFileNameVisible() const;
|
|
|
|
void setFileNameVisible(bool visible);
|
|
|
|
bool areButtonsVisible() const;
|
|
|
|
void setButtonVisible(bool visible);
|
2016-03-03 22:21:15 +01:00
|
|
|
void foreachTagEdit(const std::function<void (TagEdit *)> &function);
|
|
|
|
TagEdit *activeTagEdit();
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
// operations with the currently opened file: load, save, delete, close
|
|
|
|
bool startParsing(const QString &path, bool forceRefresh = false);
|
|
|
|
bool startSaving();
|
|
|
|
void saveAndShowNextFile();
|
|
|
|
bool reparseFile();
|
|
|
|
bool applyEntriesAndSaveChangings();
|
|
|
|
bool deleteAllTagsAndSave();
|
|
|
|
void closeFile();
|
2016-04-24 21:07:36 +02:00
|
|
|
// misc
|
|
|
|
void applySettingsFromDialog();
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
signals:
|
2016-08-07 19:59:33 +02:00
|
|
|
/// \brief Emitted when loading the next file has been triggered.
|
2016-02-29 23:59:46 +01:00
|
|
|
void nextFileSelected();
|
2016-08-07 19:59:33 +02:00
|
|
|
/// \brief Emitted to show a status message.
|
2016-02-29 23:59:46 +01:00
|
|
|
void statusMessage(const QString &message, int timeout = 0);
|
2016-12-01 22:23:01 +01:00
|
|
|
/// \brief Emitted when the file status (opened/closed) has changed.
|
2016-08-07 19:59:33 +02:00
|
|
|
void fileStatusChanged(bool opened, bool hasTag);
|
|
|
|
/// \brief Emitted when the current path has changed; always emitted a saving.
|
|
|
|
void currentPathChanged(const QString &newPath);
|
2016-12-01 22:23:01 +01:00
|
|
|
/// \brief Emitted when all tag values have been parsed and loaded into tag edits.
|
|
|
|
/// \remarks In particular, this is emitted *before* any additional data is inserted (like title from file name).
|
|
|
|
void tagValuesLoaded();
|
|
|
|
/// \brief Emitted when a file has been shown (file is parsed and all widgets have been updated accordingly).
|
|
|
|
/// \remarks In particular, this is emitted *after* additional data (like title from file name) might have been inserted.
|
|
|
|
void fileShown();
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool event(QEvent *event);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
// editor
|
|
|
|
void fileChangedOnDisk(const QString &path);
|
|
|
|
void showFile(char result);
|
|
|
|
void handleReturnPressed();
|
|
|
|
void handleKeepPreviousValuesActionTriggered(QAction *action);
|
|
|
|
void addTag(const std::function<Media::Tag *(Media::MediaFileInfo &)> &createTag);
|
|
|
|
void removeTag(Media::Tag *tag);
|
|
|
|
void changeTarget(Media::Tag *tag);
|
|
|
|
|
|
|
|
// saving
|
|
|
|
void showSavingResult(bool processingError, bool ioError);
|
|
|
|
|
2016-04-21 23:55:22 +02:00
|
|
|
// info (web) view
|
|
|
|
void initInfoView();
|
|
|
|
void updateInfoView();
|
2016-04-24 22:08:41 +02:00
|
|
|
void showInfoTreeViewContextMenu(const QPoint &);
|
2016-04-21 23:55:22 +02:00
|
|
|
#ifndef TAGEDITOR_NO_WEBVIEW
|
2016-02-29 23:59:46 +01:00
|
|
|
void showInfoWebViewContextMenu(const QPoint &);
|
2016-04-21 23:55:22 +02:00
|
|
|
#endif
|
2016-02-29 23:59:46 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateDocumentTitleEdits();
|
|
|
|
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
|
|
|
void updateTagSelectionComboBox();
|
|
|
|
void updateFileStatusStatus();
|
|
|
|
void updateTagManagementMenu();
|
|
|
|
void insertTitleFromFilename();
|
|
|
|
bool confirmCreationOfId3TagForUnsupportedFile();
|
|
|
|
|
|
|
|
// UI
|
|
|
|
std::unique_ptr<Ui::TagEditorWidget> m_ui;
|
|
|
|
QMenu *m_keepPreviousValuesMenu;
|
|
|
|
QMenu *m_tagOptionsMenu;
|
|
|
|
QMenu *m_addTagMenu;
|
|
|
|
QMenu *m_removeTagMenu;
|
|
|
|
QMenu *m_changeTargetMenu;
|
2016-04-21 23:55:22 +02:00
|
|
|
#ifndef TAGEDITOR_NO_WEBVIEW
|
2016-02-29 23:59:46 +01:00
|
|
|
WEB_VIEW_PROVIDER *m_infoWebView;
|
2016-04-21 23:55:22 +02:00
|
|
|
#endif
|
2016-04-24 21:07:36 +02:00
|
|
|
FileInfoModel *m_infoModel;
|
|
|
|
QTreeView *m_infoTreeView;
|
2016-02-29 23:59:46 +01:00
|
|
|
// tag, file, directory management
|
|
|
|
QString m_currentPath;
|
|
|
|
QFileSystemWatcher *m_fileWatcher;
|
|
|
|
bool m_fileChangedOnDisk;
|
|
|
|
Media::MediaFileInfo m_fileInfo;
|
|
|
|
std::vector<Media::Tag *> m_tags;
|
|
|
|
QByteArray m_fileInfoHtml;
|
2016-12-01 22:23:01 +01:00
|
|
|
QString m_fileName;
|
2016-02-29 23:59:46 +01:00
|
|
|
QString m_currentDir;
|
|
|
|
QString m_lastDir;
|
2016-05-01 20:07:04 +02:00
|
|
|
QString m_saveFilePath;
|
2016-02-29 23:59:46 +01:00
|
|
|
// status
|
|
|
|
bool m_nextFileAfterSaving;
|
|
|
|
bool m_makingResultsAvailable;
|
|
|
|
Media::NotificationList m_originalNotifications;
|
|
|
|
bool m_abortClicked;
|
2016-11-23 21:46:33 +01:00
|
|
|
bool m_fileOperationOngoing;
|
2016-02-29 23:59:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the mutex which is internally used for thread-synchronization.
|
|
|
|
*/
|
2016-11-23 21:46:33 +01:00
|
|
|
inline bool TagEditorWidget::fileOperationOngoing() const
|
2016-02-29 23:59:46 +01:00
|
|
|
{
|
2016-11-23 21:46:33 +01:00
|
|
|
return m_fileOperationOngoing;
|
2016-02-29 23:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2016-12-01 22:23:01 +01:00
|
|
|
* \brief Returns the path of the currently opened file including filename.
|
2016-02-29 23:59:46 +01:00
|
|
|
*/
|
|
|
|
inline const QString &TagEditorWidget::currentPath() const
|
|
|
|
{
|
|
|
|
return m_currentPath;
|
|
|
|
}
|
|
|
|
|
2016-11-18 17:59:53 +01:00
|
|
|
/*!
|
2016-12-01 22:23:01 +01:00
|
|
|
* \brief Returns the path of the currently opened file excluding filename.
|
|
|
|
* \remarks This is the actual directory of the opened file which may differ from the directory selected in the tree view of the main window.
|
2016-11-18 17:59:53 +01:00
|
|
|
*/
|
|
|
|
inline const QString &TagEditorWidget::currentDir() const
|
|
|
|
{
|
|
|
|
return m_currentDir;
|
|
|
|
}
|
|
|
|
|
2016-02-29 23:59:46 +01:00
|
|
|
/*!
|
|
|
|
* \brief Return file info.
|
|
|
|
*/
|
|
|
|
inline Media::MediaFileInfo &TagEditorWidget::fileInfo()
|
|
|
|
{
|
|
|
|
return m_fileInfo;
|
|
|
|
}
|
|
|
|
|
2016-04-21 23:55:22 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns the original notifications.
|
|
|
|
*/
|
|
|
|
inline Media::NotificationList &TagEditorWidget::originalNotifications()
|
|
|
|
{
|
|
|
|
return m_originalNotifications;
|
|
|
|
}
|
|
|
|
|
2016-02-29 23:59:46 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns the HTML source of the info website.
|
|
|
|
*/
|
|
|
|
inline const QByteArray &TagEditorWidget::fileInfoHtml() const
|
|
|
|
{
|
|
|
|
return m_fileInfoHtml;
|
|
|
|
}
|
|
|
|
|
2016-03-03 22:21:15 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns whether currently a tag edit is shown.
|
|
|
|
*/
|
|
|
|
inline bool TagEditorWidget::isTagEditShown() const
|
|
|
|
{
|
|
|
|
return !m_tags.empty();
|
|
|
|
}
|
|
|
|
|
2016-02-29 23:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TAGEDITORWIDGET_H
|