QtPass  1.3.2
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 setUiElementsEnabled(bool state);
53  void flashText(const QString &text, const bool isError,
54  const bool isHtml = false);
55 
56  const QModelIndex getCurrentTreeViewIndex();
57 
58  QDialog *getKeygenDialog() { return this->keygen; }
59  void cleanKeygenDialog();
60 
61 protected:
62  void closeEvent(QCloseEvent *event);
63  void keyPressEvent(QKeyEvent *event);
64  void changeEvent(QEvent *event);
65  bool eventFilter(QObject *obj, QEvent *event);
66 
67 signals:
68  void passShowHandlerFinished(QString output);
69  void passGitInitNeeded();
70  void generateGPGKeyPair(QString batch);
71 
72 public slots:
73  void deselect();
74 
75  void messageAvailable(QString message);
76  void critical(QString, QString);
77 
78  void executeWrapperStarted();
79  void showStatusMessage(QString msg, int timeout = 2000);
80  void passShowHandler(const QString &);
81  void passOtpHandler(const QString &);
82 
83  void onPush();
84  void on_treeView_clicked(const QModelIndex &index);
85 
86  void startReencryptPath();
87  void endReencryptPath();
88 
89 private slots:
90  void addPassword();
91  void addFolder();
92  void onEdit();
93  void onDelete();
94  void onOtp();
95  void onUpdate(bool block = false);
96  void onUsers();
97  void onConfig();
98  void on_treeView_doubleClicked(const QModelIndex &index);
99  void clearPanel(bool notify = true);
100  void on_lineEdit_textChanged(const QString &arg1);
101  void on_lineEdit_returnPressed();
102  void on_profileBox_currentIndexChanged(QString);
103  void showContextMenu(const QPoint &pos);
104  void showBrowserContextMenu(const QPoint &pos);
105  void openFolder();
106  void renameFolder();
107  void editPassword(const QString &);
108  void renamePassword();
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_
SingleApplication
The SingleApplication class is used for commandline intergration.
Definition: singleapplication.h:14
MainWindow::eventFilter
bool eventFilter(QObject *obj, QEvent *event)
MainWindow::eventFilter filter out some events and focus the treeview.
Definition: mainwindow.cpp:841
MainWindow::getCurrentTreeViewIndex
const QModelIndex getCurrentTreeViewIndex()
Definition: mainwindow.cpp:199
storemodel.h
MainWindow::userDialog
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:686
MainWindow::passShowHandler
void passShowHandler(const QString &)
Definition: mainwindow.cpp:370
MainWindow::deselect
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
Definition: mainwindow.cpp:351
MainWindow::MainWindow
MainWindow(const QString &searchText=QString(), QWidget *parent=nullptr)
MainWindow::MainWindow handles all of the main functionality and also the main window.
Definition: mainwindow.cpp:37
QtPass
Definition: qtpass.h:10
MainWindow::restoreWindow
void restoreWindow()
Definition: mainwindow.cpp:465
MainWindow::on_treeView_clicked
void on_treeView_clicked(const QModelIndex &index)
MainWindow::on_treeView_clicked read the selected password file.
Definition: mainwindow.cpp:317
MainWindow::critical
void critical(QString, QString)
MainWindow::critical critical message popup wrapper.
Definition: mainwindow.cpp:1183
MainWindow::generateGPGKeyPair
void generateGPGKeyPair(QString batch)
TrayIcon
Handles the systemtray icon and menu.
Definition: trayicon.h:14
MainWindow::config
void config()
MainWindow::config pops up the configuration screen and handles all inter-window communication.
Definition: mainwindow.cpp:228
MainWindow::setUiElementsEnabled
void setUiElementsEnabled(bool state)
MainWindow::setUiElementsEnabled enable or disable the relevant UI elements.
Definition: mainwindow.cpp:449
MainWindow::messageAvailable
void messageAvailable(QString message)
MainWindow::messageAvailable we have some text/message/search to do.
Definition: mainwindow.cpp:713
MainWindow::startReencryptPath
void startReencryptPath()
MainWindow::startReencryptPath disable ui elements and treeview.
Definition: mainwindow.cpp:1142
StoreModel
The QSortFilterProxyModel for handling filesystem searches.
Definition: storemodel.h:12
MainWindow::closeEvent
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
Definition: mainwindow.cpp:816
MainWindow::getKeygenDialog
QDialog * getKeygenDialog()
Definition: mainwindow.h:58
MainWindow::passShowHandlerFinished
void passShowHandlerFinished(QString output)
MainWindow::passOtpHandler
void passOtpHandler(const QString &)
Definition: mainwindow.cpp:416
MainWindow::onPush
void onPush()
MainWindow::onPush do a git push.
Definition: mainwindow.cpp:287
MainWindow::showStatusMessage
void showStatusMessage(QString msg, int timeout=2000)
Displays message in status bar.
Definition: mainwindow.cpp:1135
MainWindow::generateKeyPair
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:730
MainWindow::flashText
void flashText(const QString &text, const bool isError, const bool isHtml=false)
Definition: mainwindow.cpp:208
MainWindow::cleanKeygenDialog
void cleanKeygenDialog()
Definition: mainwindow.cpp:203
Ui
Definition: configdialog.h:9
MainWindow::executeWrapperStarted
void executeWrapperStarted()
Definition: mainwindow.cpp:363
MainWindow::keyPressEvent
void keyPressEvent(QKeyEvent *event)
MainWindow::keyPressEvent did anyone press return, enter or escape?
Definition: mainwindow.cpp:855
MainWindow::passGitInitNeeded
void passGitInitNeeded()
MainWindow::changeEvent
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
Definition: mainwindow.cpp:143
MainWindow
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition: mainwindow.h:39
MainWindow::endReencryptPath
void endReencryptPath()
MainWindow::endReencryptPath re-enable ui elements.
Definition: mainwindow.cpp:1150
MainWindow::~MainWindow
~MainWindow()
Definition: mainwindow.cpp:126