2015-04-22 19:33:53 +02:00
|
|
|
#ifndef TAGEDITORDIALOG_H
|
|
|
|
#define TAGEDITORDIALOG_H
|
|
|
|
|
2015-09-06 20:20:00 +02:00
|
|
|
#include "./filefilterproxymodel.h"
|
|
|
|
#include "./previousvaluehandling.h"
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
#include <tagparser/mediafileinfo.h>
|
|
|
|
#include <tagparser/tagvalue.h>
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QByteArray>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <mutex>
|
|
|
|
#include <functional>
|
|
|
|
|
2016-01-25 19:23:33 +01:00
|
|
|
#ifdef TAGEDITOR_USE_WEBENGINE
|
|
|
|
# define WEB_VIEW_PROVIDER QWebEngineView
|
|
|
|
#else
|
|
|
|
# define WEB_VIEW_PROVIDER QWebView
|
|
|
|
#endif
|
|
|
|
|
2015-04-22 19:33:53 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QLineEdit;
|
|
|
|
class QComboBox;
|
|
|
|
class QSpinBox;
|
|
|
|
class QPlainTextEdit;
|
|
|
|
class QGraphicsScene;
|
|
|
|
class QFileSystemModel;
|
2015-09-21 22:56:09 +02:00
|
|
|
class QFileSystemWatcher;
|
2016-01-25 19:23:33 +01:00
|
|
|
class WEB_VIEW_PROVIDER;
|
2015-04-22 19:33:53 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
DECLARE_ENUM(TagType, unsigned int)
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Dialogs {
|
|
|
|
class AboutDialog;
|
|
|
|
class SettingsDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TagEdit;
|
|
|
|
class RenameFilesDialog;
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
|
|
|
virtual ~MainWindow();
|
|
|
|
|
2015-07-27 23:29:30 +02:00
|
|
|
// file browser
|
2015-04-22 19:33:53 +02:00
|
|
|
QString currentDirectory();
|
|
|
|
void setCurrentDirectory(const QString &path);
|
|
|
|
|
2015-09-21 22:56:09 +02:00
|
|
|
public slots:
|
2015-07-27 23:29:30 +02:00
|
|
|
// opened file: load, save, delete, close
|
|
|
|
bool startParsing(const QString &path, bool forceRefresh = false);
|
2015-09-21 22:56:09 +02:00
|
|
|
bool reparseFile();
|
2015-07-27 23:29:30 +02:00
|
|
|
bool applyEntriesAndSaveChangings();
|
|
|
|
bool deleteAllTagsAndSave();
|
|
|
|
void closeFile();
|
|
|
|
|
2015-04-22 19:33:53 +02:00
|
|
|
protected:
|
2016-01-09 03:38:58 +01:00
|
|
|
bool event(QEvent *event);
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
// file selection
|
|
|
|
void pathEntered();
|
|
|
|
void fileSelected();
|
|
|
|
void saveAndShowNextFile();
|
|
|
|
void selectNextFile();
|
|
|
|
void showOpenFileDlg();
|
|
|
|
|
|
|
|
// editor
|
2015-09-21 22:56:09 +02:00
|
|
|
void fileChangedOnDisk(const QString &path);
|
2015-07-27 23:29:30 +02:00
|
|
|
void showFile(char result);
|
2015-04-22 19:33:53 +02:00
|
|
|
void saveFileInformation();
|
|
|
|
void handleReturnPressed();
|
|
|
|
void handleKeepPreviousValuesActionTriggered(QAction *action);
|
|
|
|
void applySettingsFromDialog();
|
|
|
|
void addTag(const std::function<Media::Tag *(Media::MediaFileInfo &)> &createTag);
|
|
|
|
void removeTag(Media::Tag *tag);
|
|
|
|
void changeTarget(Media::Tag *tag);
|
|
|
|
|
|
|
|
// saving
|
|
|
|
bool startSaving();
|
2015-11-07 21:27:17 +01:00
|
|
|
void showSavingResult(bool processingError, bool ioError);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
// misc
|
|
|
|
void showAboutDlg();
|
|
|
|
void showSettingsDlg();
|
|
|
|
void showRenameFilesDlg();
|
|
|
|
void updateInfoWebView();
|
2015-08-07 23:49:32 +02:00
|
|
|
void showInfoWebViewContextMenu(const QPoint &);
|
|
|
|
void copyInfoWebViewSelection();
|
2015-10-14 20:15:10 +02:00
|
|
|
void spawnExternalPlayer();
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
private:
|
2015-12-27 19:49:17 +01:00
|
|
|
void updateDocumentTitleEdits();
|
2015-04-22 19:33:53 +02:00
|
|
|
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
|
|
|
void updateTagSelectionComboBox();
|
|
|
|
void updateUiStatus();
|
|
|
|
void updateTagManagementMenu();
|
|
|
|
void insertTitleFromFilename();
|
|
|
|
void foreachTagEdit(const std::function<void (TagEdit *)> &function);
|
|
|
|
bool confirmCreationOfId3TagForUnsupportedFile();
|
|
|
|
|
|
|
|
// UI
|
|
|
|
std::unique_ptr<Ui::MainWindow> m_ui;
|
|
|
|
QMenu *m_keepPreviousValuesMenu;
|
|
|
|
QMenu *m_tagOptionsMenu;
|
|
|
|
QMenu *m_addTagMenu;
|
|
|
|
QMenu *m_removeTagMenu;
|
|
|
|
QMenu *m_changeTargetMenu;
|
2016-01-25 19:23:33 +01:00
|
|
|
WEB_VIEW_PROVIDER *m_infoWebView;
|
2015-04-22 19:33:53 +02:00
|
|
|
// models
|
|
|
|
QFileSystemModel *m_fileModel;
|
|
|
|
FileFilterProxyModel *m_fileFilterModel;
|
|
|
|
// tag, file, directory management
|
|
|
|
QString m_currentPath;
|
|
|
|
QString m_currentDir; // this is the actual direcotry of the opened file and may differ from the directory selected in the tree view
|
|
|
|
QString m_lastDir;
|
2015-09-21 22:56:09 +02:00
|
|
|
QFileSystemWatcher *m_fileWatcher;
|
|
|
|
bool m_fileChangedOnDisk;
|
2015-04-22 19:33:53 +02:00
|
|
|
Media::MediaFileInfo m_fileInfo;
|
|
|
|
QString m_nextFilePath;
|
|
|
|
std::vector<Media::Tag *> m_tags;
|
|
|
|
QByteArray m_fileInfoHtml;
|
|
|
|
// dialogs
|
|
|
|
Dialogs::AboutDialog *m_aboutDlg;
|
|
|
|
Dialogs::SettingsDialog *m_settingsDlg;
|
|
|
|
std::unique_ptr<RenameFilesDialog> m_renameFilesDlg;
|
|
|
|
// status
|
|
|
|
bool m_makingResultsAvailable;
|
|
|
|
Media::NotificationList m_originalNotifications;
|
|
|
|
bool m_abortClicked;
|
|
|
|
std::mutex m_fileOperationMutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TAGEDITORDIALOG_H
|