QtPass  1.2.1
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(QWidget *parent = 0);
43  ~MainWindow();
44  bool checkConfig();
45  void setApp(SingleApplication *app);
46  void setText(QString);
47  QStringList getSecretKeys();
48  void generateKeyPair(QString, QDialog *);
49  void userDialog(QString = "");
50  void config();
51  void executePassGitInit();
52 
53 protected:
54  void closeEvent(QCloseEvent *event);
55  void keyPressEvent(QKeyEvent *event);
56  void changeEvent(QEvent *event);
57  bool eventFilter(QObject *obj, QEvent *event);
58 
59 public slots:
60  void deselect();
61 
62 private slots:
63  void on_updateButton_clicked(bool block = false);
64  void on_pushButton_clicked();
65  void on_treeView_clicked(const QModelIndex &index);
66  void on_treeView_doubleClicked(const QModelIndex &index);
67  void on_configButton_clicked();
68  void processFinished(const QString &, const QString &);
69  void processError(QProcess::ProcessError);
70  void clearClipboard();
71  void clearPanel(bool notify = true);
72  void on_lineEdit_textChanged(const QString &arg1);
73  void on_lineEdit_returnPressed();
74  void on_addButton_clicked();
75  void on_deleteButton_clicked();
76  void on_editButton_clicked();
77  void on_usersButton_clicked();
78  void messageAvailable(QString message);
79  void on_profileBox_currentIndexChanged(QString);
80  void showContextMenu(const QPoint &pos);
81  void showBrowserContextMenu(const QPoint &pos);
82  void openFolder();
83  void addFolder();
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 passStoreChanged(const QString &, const QString &);
97  void doGitPush();
98 
99  void processErrorExit(int exitCode, const QString &);
100 
101  void finishedInsert(const QString &, const QString &);
102  void keyGenerationComplete(const QString &p_output, const QString &p_errout);
103 
104 private:
105  QScopedPointer<Ui::MainWindow> ui;
106  QFileSystemModel model;
107  StoreModel proxyModel;
108  QScopedPointer<QItemSelectionModel> selectionModel;
109  QProcess fusedav;
110  QString clippedText;
111  QTimer clearPanelTimer;
112  QTimer clearClipboardTimer;
113  bool freshStart;
114  QDialog *keygen;
115  QString currentDir;
116  bool startupPhase;
117  TrayIcon *tray;
118 
119  void initAddButton();
120  void updateText();
121  void enableUiElements(bool state);
122  void restoreWindow();
123  void selectFirstFile();
124  QModelIndex firstFile(QModelIndex parentIndex);
125  QString getFile(const QModelIndex &, bool);
126  void setPassword(QString, bool isNew = true);
127 
128  void mountWebDav();
129  void updateProfileBox();
130  void initTrayIcon();
131  void destroyTrayIcon();
132  void clearTemplateWidgets();
133  void reencryptPath(QString dir);
134  void addToGridLayout(int position, const QString &field,
135  const QString &value);
136  void DisplayInTextBrowser(QString toShow, QString prefix = QString(),
137  QString postfix = QString());
138  void connectPassSignalHandlers(Pass *pass);
139 
140  void updateGitButtonVisibility();
141  void hideGitButtons();
142  void showGitButtons();
143 };
144 
145 #endif // MAINWINDOW_H_
void setText(QString)
MainWindow::setText do a search from an external source (eg: commandline)
Definition: configdialog.h:9
~MainWindow()
MainWindow::~MainWindow destroy!
Definition: mainwindow.cpp:107
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:345
Acts as an abstraction for pass or pass imitation.
Definition: pass.h:25
void userDialog(QString="")
MainWindow::userDialog see MainWindow::on_usersButton_clicked()
Definition: mainwindow.cpp:996
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
Definition: mainwindow.cpp:124
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:544
void setApp(SingleApplication *app)
MainWindow::setApp make sure we know what/who/where we are.
The SingleApplication class is used for commandline intergration.
MainWindow(QWidget *parent=0)
MainWindow::MainWindow handles all of the main functionality and also the main window.
Definition: mainwindow.cpp:43
bool checkConfig()
MainWindow::checkConfig make sure we are ready to go as soon as possible.
Definition: mainwindow.cpp:235
QStringList getSecretKeys()
MainWindow::getSecretKeys get list of secret/private keys.
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
Definition: mainwindow.cpp:534
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