passwordmanager/gui/mainwindow.h

139 lines
3.6 KiB
C
Raw Normal View History

2015-04-22 19:30:09 +02:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
2015-09-06 20:33:09 +02:00
#include "./passwordgeneratordialog.h"
2015-04-22 19:30:09 +02:00
#include <passwordfile/io/passwordfile.h>
#include <c++utilities/io/binaryreader.h>
#include <c++utilities/io/binarywriter.h>
#include <QMainWindow>
#include <QMap>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QCloseEvent)
QT_FORWARD_DECLARE_CLASS(QTreeWidgetItem)
QT_FORWARD_DECLARE_CLASS(QUndoStack)
QT_FORWARD_DECLARE_CLASS(QUndoView)
2016-08-16 00:37:17 +02:00
QT_FORWARD_DECLARE_CLASS(QSettings)
2015-04-22 19:30:09 +02:00
namespace Io {
2016-07-11 22:10:16 +02:00
DECLARE_ENUM_CLASS(EntryType, int);
DECLARE_ENUM_CLASS(FieldType, int);
2015-04-22 19:30:09 +02:00
}
namespace MiscUtils {
class RecentMenuManager;
}
2016-07-04 23:29:49 +02:00
namespace Dialogs {
class AboutDialog;
2016-08-16 00:37:17 +02:00
class SettingsDialog;
class QtSettings;
2016-07-04 23:29:49 +02:00
}
2015-04-22 19:30:09 +02:00
namespace QtGui {
class FieldModel;
class EntryModel;
class EntryFilterModel;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
2016-08-16 00:37:17 +02:00
explicit MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings = nullptr, QWidget *parent = nullptr);
2015-04-22 19:30:09 +02:00
~MainWindow();
2016-04-26 19:37:47 +02:00
public slots:
2015-04-22 19:30:09 +02:00
// file management
bool openFile(const QString &path);
void createFile(const QString &path, const QString &password);
void createFile(const QString &path);
bool createFile();
void changePassword();
bool saveFile();
void exportFile();
bool closeFile();
2016-08-16 00:37:17 +02:00
// show dialogs
void showOpenFileDialog();
void showSaveFileDialog();
void showSettingsDialog();
void showAboutDialog();
void showPassowrdGeneratorDialog();
void showUndoView();
2015-04-22 19:30:09 +02:00
protected:
bool eventFilter(QObject *obj, QEvent *event);
void closeEvent(QCloseEvent *event);
void timerEvent(QTimerEvent *event);
2016-04-26 19:37:47 +02:00
private slots:
2015-04-22 19:30:09 +02:00
// file management
bool showFile();
// account/categories management
void addAccount();
void addCategory();
void addEntry(Io::EntryType type);
void removeEntry();
void applyFilter(const QString &filterText);
// row management
void accountSelected(const QModelIndex &selected, const QModelIndex &);
void insertRow();
void removeRows();
void markAsPasswordField();
void markAsNormalField();
void setFieldType(Io::FieldType fieldType);
void setPasswordVisibility(QAction *selectedAction);
2015-04-22 19:30:09 +02:00
QString selectedFieldsString() const;
void insertFields(const QString &fieldsString);
void copyFieldsForXMilliSeconds(int x = 5000);
void copyFields();
void insertFieldsFromClipboard();
// showing context menus
void showTreeViewContextMenu();
void showTableViewContextMenu();
// other
void showContainingDirectory();
void clearClipboard();
void setSomethingChanged();
void setSomethingChanged(bool somethingChanged);
2015-04-22 19:30:09 +02:00
private:
// showing conditional messages/prompts
bool askForCreatingFile();
bool showNoFileOpened();
bool showNoAccount();
// other
void updateUiStatus();
void updateWindowTitle();
2015-04-22 19:30:09 +02:00
void applyDefaultExpanding(const QModelIndex &parent);
std::unique_ptr<Ui::MainWindow> m_ui;
Io::PasswordFile m_file;
FieldModel *m_fieldModel;
EntryModel *m_entryModel;
EntryFilterModel *m_entryFilterModel;
QUndoStack *m_undoStack;
QUndoView *m_undoView;
bool m_somethingChanged;
bool m_dontUpdateSelection;
int m_clearClipboardTimer;
MiscUtils::RecentMenuManager *m_recentMgr;
2016-07-04 23:29:49 +02:00
Dialogs::AboutDialog *m_aboutDlg;
2016-08-16 00:37:17 +02:00
QSettings &m_settings;
Dialogs::QtSettings *m_qtSettings;
Dialogs::SettingsDialog *m_settingsDlg;
2015-04-22 19:30:09 +02:00
};
}
#endif // MAINWINDOW_H