tageditor/gui/mainwindow.h

153 lines
3.8 KiB
C
Raw Normal View History

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>
QT_BEGIN_NAMESPACE
class QLineEdit;
class QComboBox;
class QSpinBox;
class QPlainTextEdit;
class QGraphicsScene;
class QFileSystemModel;
class QFileSystemWatcher;
#ifdef TAGEDITOR_USE_WEBENGINE
class QWebEngineView;
#else
class QWebView;
#endif
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);
public slots:
2015-07-27 23:29:30 +02:00
// opened file: load, save, delete, close
bool startParsing(const QString &path, bool forceRefresh = false);
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:
virtual void closeEvent(QCloseEvent *);
2015-05-05 23:08:49 +02:00
virtual 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
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();
void showSavingResult(bool sucess);
// misc
void showAboutDlg();
void showSettingsDlg();
void showRenameFilesDlg();
void updateInfoWebView();
void showInfoWebViewContextMenu(const QPoint &);
void copyInfoWebViewSelection();
2015-04-22 19:33:53 +02:00
private:
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;
#ifdef TAGEDITOR_USE_WEBENGINE
QWebEngineView *m_infoWebView;
#else
QWebView *m_infoWebView;
#endif
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;
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