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 QDialog;
37 class QtPass;
38 class TrayIcon;
39 class MainWindow : public QMainWindow {
40  Q_OBJECT
41 
42 public:
43  explicit MainWindow(const QString &searchText = QString(),
44  QWidget *parent = nullptr);
45  ~MainWindow();
46 
47  void restoreWindow();
48  void generateKeyPair(QString, QDialog *);
49  void userDialog(QString = "");
50  void config();
51 
52  void setTextTextBrowser(const QString &text);
53  void setUiElementsEnabled(bool state);
54  void flashText(const QString &text, const bool isError,
55  const bool isHtml = false);
56 
57  const QModelIndex getCurrentTreeViewIndex();
58 
59  QDialog *getKeygenDialog() { return this->keygen; }
60  void cleanKeygenDialog();
61 
62 protected:
63  void closeEvent(QCloseEvent *event);
64  void keyPressEvent(QKeyEvent *event);
65  void changeEvent(QEvent *event);
66  bool eventFilter(QObject *obj, QEvent *event);
67 
68 signals:
69  void uiEnabled(bool state);
70  void passShowHandlerFinished(QString output);
71  void passGitInitNeeded();
72  void generateGPGKeyPair(QString batch);
73 
74 public slots:
75  void deselect();
76 
77  void messageAvailable(QString message);
78  void critical(QString, QString);
79 
80  void executeWrapperStarted();
81  void showStatusMessage(QString msg, int timeout = 2000);
82  void passShowHandler(const QString &);
83  void passOtpHandler(const QString &);
84 
85  void onPush();
86  void on_treeView_clicked(const QModelIndex &index);
87 
88  void startReencryptPath();
89  void endReencryptPath();
90 
91 private slots:
92  void addPassword();
93  void addFolder();
94  void onEdit();
95  void onDelete();
96  void onOtp();
97  void onUpdate(bool block = false);
98  void onUsers();
99  void onConfig();
100  void on_treeView_doubleClicked(const QModelIndex &index);
101  void clearPanel(bool notify = true);
102  void on_lineEdit_textChanged(const QString &arg1);
103  void on_lineEdit_returnPressed();
104  void on_profileBox_currentIndexChanged(QString);
105  void showContextMenu(const QPoint &pos);
106  void showBrowserContextMenu(const QPoint &pos);
107  void openFolder();
108  void editPassword(const QString &);
109  void focusInput();
110  void copyPasswordFromTreeview();
111  void passwordFromFileToClipboard(const QString &text);
112  void onTimeoutSearch();
113 
114 private:
115  QtPass *m_qtPass;
116  QScopedPointer<Ui::MainWindow> ui;
117  QFileSystemModel model;
118  StoreModel proxyModel;
119  QScopedPointer<QItemSelectionModel> selectionModel;
120  QTimer clearPanelTimer, searchTimer;
121  QDialog *keygen;
122  QString currentDir;
123  TrayIcon *tray;
124 
125  void initToolBarButtons();
126  void initStatusBar();
127 
128  void updateText();
129  void selectFirstFile();
130  QModelIndex firstFile(QModelIndex parentIndex);
131  QString getFile(const QModelIndex &, bool);
132  void setPassword(QString, bool isNew = true);
133 
134  void updateProfileBox();
135  void initTrayIcon();
136  void destroyTrayIcon();
137  void clearTemplateWidgets();
138  void reencryptPath(QString dir);
139  void addToGridLayout(int position, const QString &field,
140  const QString &value);
141 
142  void updateGitButtonVisibility();
143  void updateOtpButtonVisibility();
144  void enableGitButtons(const bool &);
145 };
146 
147 #endif // MAINWINDOW_H_
void passGitInitNeeded()
const QModelIndex getCurrentTreeViewIndex()
Definition: mainwindow.cpp:197
void generateGPGKeyPair(QString batch)
void on_treeView_clicked(const QModelIndex &index)
MainWindow::on_treeView_clicked read the selected password file.
Definition: mainwindow.cpp:319
void critical(QString, QString)
MainWindow::critical critical message popup wrapper.
void setTextTextBrowser(const QString &text)
Definition: mainwindow.cpp:206
Definition: configdialog.h:9
void passShowHandlerFinished(QString output)
QDialog * getKeygenDialog()
Definition: mainwindow.h:59
void uiEnabled(bool state)
void restoreWindow()
Definition: mainwindow.cpp:465
void passShowHandler(const QString &)
Definition: mainwindow.cpp:372
void setUiElementsEnabled(bool state)
MainWindow::setUiElementsEnabled enable or disable the relevant UI elements.
Definition: mainwindow.cpp:449
bool eventFilter(QObject *obj, QEvent *event)
MainWindow::eventFilter filter out some events and focus the treeview.
Definition: mainwindow.cpp:836
void config()
MainWindow::config pops up the configuration screen and handles all inter-window communication.
Definition: mainwindow.cpp:230
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:684
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
Definition: mainwindow.cpp:811
MainWindow(const QString &searchText=QString(), QWidget *parent=nullptr)
MainWindow::MainWindow handles all of the main functionality and also the main window.
Definition: mainwindow.cpp:36
void flashText(const QString &text, const bool isError, const bool isHtml=false)
Definition: mainwindow.cpp:210
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
Definition: mainwindow.cpp:141
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?
Definition: mainwindow.cpp:850
void cleanKeygenDialog()
Definition: mainwindow.cpp:201
void messageAvailable(QString message)
MainWindow::messageAvailable we have some text/message/search to do.
Definition: mainwindow.cpp:709
The SingleApplication class is used for commandline intergration.
Definition: qtpass.h:10
void endReencryptPath()
MainWindow::endReencryptPath re-enable ui elements.
void onPush()
MainWindow::onPush do a git push.
Definition: mainwindow.cpp:289
void passOtpHandler(const QString &)
Definition: mainwindow.cpp:416
void startReencryptPath()
MainWindow::startReencryptPath disable ui elements and treeview.
void showStatusMessage(QString msg, int timeout=2000)
Displays message in status bar.
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
Definition: mainwindow.cpp:353
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:726
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more...
Definition: mainwindow.h:39
void executeWrapperStarted()
Definition: mainwindow.cpp:365