QtPass  1.2.3
Multi-platform GUI for pass, the standard unix password manager.
mainwindow.h
Go to the documentation of this file.
1 #ifndef MAINWINDOW_H_
2 #define MAINWINDOW_H_
3 
4 #include "storemodel.h"
5 
6 #include <QFileSystemModel>
7 #include <QItemSelectionModel>
8 #include <QMainWindow>
9 #include <QProcess>
10 #include <QTimer>
11 
12 #if SINGLE_APP
13 class SingleApplication;
14 #else
15 #define SingleApplication QApplication
16 #endif
17 
18 #ifdef __APPLE__
19 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
20 // http://doc.qt.io/qt-5/qkeysequence.html#qt_set_sequence_auto_mnemonic
21 void qt_set_sequence_auto_mnemonic(bool b);
22 #endif
23 #endif
24 
25 namespace Ui {
26 class MainWindow;
27 }
28 
36 class Pass;
37 class TrayIcon;
38 class MainWindow : public QMainWindow {
39  Q_OBJECT
40 
41 public:
42  explicit MainWindow(const QString &searchText = QString(),
43  QWidget *parent = nullptr);
44  ~MainWindow();
45  bool checkConfig();
46  QStringList getSecretKeys();
47  void generateKeyPair(QString, QDialog *);
48  void userDialog(QString = "");
49  void config();
50  void executePassGitInit();
51 
52 protected:
53  void closeEvent(QCloseEvent *event);
54  void keyPressEvent(QKeyEvent *event);
55  void changeEvent(QEvent *event);
56  bool eventFilter(QObject *obj, QEvent *event);
57 
58 public slots:
59  void deselect();
60 
61 private slots:
62  void addPassword();
63  void addFolder();
64  void onEdit();
65  void onDelete();
66  void onOtp();
67  void onPush();
68  void onUpdate(bool block = false);
69  void onUsers();
70  void onConfig();
71  void on_treeView_clicked(const QModelIndex &index);
72  void on_treeView_doubleClicked(const QModelIndex &index);
73  void processFinished(const QString &, const QString &);
74  void processError(QProcess::ProcessError);
75  void clearClipboard();
76  void clearPanel(bool notify = true);
77  void on_lineEdit_textChanged(const QString &arg1);
78  void on_lineEdit_returnPressed();
79  void messageAvailable(QString message);
80  void on_profileBox_currentIndexChanged(QString);
81  void showContextMenu(const QPoint &pos);
82  void showBrowserContextMenu(const QPoint &pos);
83  void openFolder();
84  void editPassword(const QString &);
85  void focusInput();
86  void copyTextToClipboard(const QString &text);
87  void copyPasswordFromTreeview();
88  void passwordFromFileToClipboard(const QString &text);
89 
90  void executeWrapperStarted();
91  void showStatusMessage(QString msg, int timeout);
92  void startReencryptPath();
93  void endReencryptPath();
94  void critical(QString, QString);
95  void passShowHandler(const QString &);
96  void passOtpHandler(const QString &);
97  void passStoreChanged(const QString &, const QString &);
98  void doGitPush();
99 
100  void processErrorExit(int exitCode, const QString &);
101 
102  void finishedInsert(const QString &, const QString &);
103  void keyGenerationComplete(const QString &p_output, const QString &p_errout);
104 
105 private:
106  QScopedPointer<Ui::MainWindow> ui;
107  QFileSystemModel model;
108  StoreModel proxyModel;
109  QScopedPointer<QItemSelectionModel> selectionModel;
110  QProcess fusedav;
111  QString clippedText;
112  QTimer clearPanelTimer;
113  QTimer clearClipboardTimer;
114  bool freshStart;
115  QDialog *keygen;
116  QString currentDir;
117  bool startupPhase;
118  TrayIcon *tray;
119 
120  void initToolBarButtons();
121  void initStatusBar();
122 
123  void updateText();
124  void enableUiElements(bool state);
125  void restoreWindow();
126  void selectFirstFile();
127  QModelIndex firstFile(QModelIndex parentIndex);
128  QString getFile(const QModelIndex &, bool);
129  void setPassword(QString, bool isNew = true);
130 
131  void mountWebDav();
132  void updateProfileBox();
133  void initTrayIcon();
134  void destroyTrayIcon();
135  void clearTemplateWidgets();
136  void reencryptPath(QString dir);
137  void addToGridLayout(int position, const QString &field,
138  const QString &value);
139  void DisplayInTextBrowser(QString toShow, QString prefix = QString(),
140  QString postfix = QString());
141  void connectPassSignalHandlers(Pass *pass);
142 
143  void updateGitButtonVisibility();
144  void updateOtpButtonVisibility();
145  void enableGitButtons(const bool &);
146 };
147 
148 #endif // MAINWINDOW_H_
Definition: configdialog.h:9
~MainWindow()
MainWindow::~MainWindow destroy!
Definition: mainwindow.cpp:154
bool eventFilter(QObject *obj, QEvent *event)
MainWindow::eventFilter filter out some events and focus the treeview.
void config()
MainWindow::config pops up the configuration screen and handles all inter-window communication.
Definition: mainwindow.cpp:393
Acts as an abstraction for pass or pass imitation.
Definition: pass.h:25
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:958
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
MainWindow(const QString &searchText=QString(), QWidget *parent=nullptr)
MainWindow::MainWindow handles all of the main functionality and also the main window.
Definition: mainwindow.cpp:39
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
Definition: mainwindow.cpp:171
The QSortFilterProxyModel for handling filesystem searches.
Definition: storemodel.h:12
Handles the systemtray icon and menu.
Definition: trayicon.h:14
void keyPressEvent(QKeyEvent *event)
MainWindow::keyPressEvent did anyone press return, enter or escape?
void executePassGitInit()
MainWindow::executePassGitInit git init wrapper.
Definition: mainwindow.cpp:525
The SingleApplication class is used for commandline intergration.
bool checkConfig()
MainWindow::checkConfig make sure we are ready to go as soon as possible.
Definition: mainwindow.cpp:281
QStringList getSecretKeys()
MainWindow::getSecretKeys get list of secret/private keys.
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
Definition: mainwindow.cpp:515
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more...
Definition: mainwindow.h:38