QtPass 1.4.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
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
14#else
15#define SingleApplication QApplication
16#endif
17
18#ifdef __APPLE__
19// http://doc.qt.io/qt-5/qkeysequence.html#qt_set_sequence_auto_mnemonic
20void qt_set_sequence_auto_mnemonic(bool b);
21#endif
22
23namespace Ui {
24class MainWindow;
25}
26
34class QDialog;
35class QtPass;
36class TrayIcon;
37class MainWindow : public QMainWindow {
38 Q_OBJECT
39
40public:
41 explicit MainWindow(const QString &searchText = QString(),
42 QWidget *parent = nullptr);
44
45 void restoreWindow();
46 void generateKeyPair(QString, QDialog *);
47 void userDialog(QString = "");
48 void config();
49
50 void setUiElementsEnabled(bool state);
51 void flashText(const QString &text, const bool isError,
52 const bool isHtml = false);
53
54 const QModelIndex getCurrentTreeViewIndex();
55
56 QDialog *getKeygenDialog() { return this->keygen; }
57 void cleanKeygenDialog();
58
59protected:
60 void closeEvent(QCloseEvent *event);
61 void keyPressEvent(QKeyEvent *event);
62 void changeEvent(QEvent *event);
63 bool eventFilter(QObject *obj, QEvent *event);
64
65signals:
66 void passShowHandlerFinished(QString output);
68 void generateGPGKeyPair(QString batch);
69
70public slots:
71 void deselect();
72
73 void messageAvailable(QString message);
74 void critical(QString, QString);
75
77 void showStatusMessage(QString msg, int timeout = 2000);
78 void passShowHandler(const QString &);
79 void passOtpHandler(const QString &);
80
81 void onPush();
82 void on_treeView_clicked(const QModelIndex &index);
83
84 void startReencryptPath();
85 void endReencryptPath();
86
87private slots:
88 void addPassword();
89 void addFolder();
90 void onEdit();
91 void onDelete();
92 void onOtp();
93 void onUpdate(bool block = false);
94 void onUsers();
95 void onConfig();
96 void on_treeView_doubleClicked(const QModelIndex &index);
97 void clearPanel(bool notify = true);
98 void on_lineEdit_textChanged(const QString &arg1);
99 void on_lineEdit_returnPressed();
100 void on_profileBox_currentIndexChanged(QString);
101 void showContextMenu(const QPoint &pos);
102 void showBrowserContextMenu(const QPoint &pos);
103 void openFolder();
104 void renameFolder();
105 void editPassword(const QString &);
106 void renamePassword();
107 void focusInput();
108 void copyPasswordFromTreeview();
109 void passwordFromFileToClipboard(const QString &text);
110 void onTimeoutSearch();
111
112private:
113 QtPass *m_qtPass;
114 QScopedPointer<Ui::MainWindow> ui;
115 QFileSystemModel model;
116 StoreModel proxyModel;
117 QScopedPointer<QItemSelectionModel> selectionModel;
118 QTimer clearPanelTimer, searchTimer;
119 QDialog *keygen;
120 QString currentDir;
121 TrayIcon *tray;
122
123 void initToolBarButtons();
124 void initStatusBar();
125
126 void updateText();
127 void selectFirstFile();
128 QModelIndex firstFile(QModelIndex parentIndex);
129 QString getFile(const QModelIndex &, bool);
130 void setPassword(QString, bool isNew = true);
131
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
140 void updateGitButtonVisibility();
141 void updateOtpButtonVisibility();
142 void enableGitButtons(const bool &);
143};
144
145#endif // MAINWINDOW_H_
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition: mainwindow.h:37
void startReencryptPath()
MainWindow::startReencryptPath disable ui elements and treeview.
void passShowHandler(const QString &)
Definition: mainwindow.cpp:383
void endReencryptPath()
MainWindow::endReencryptPath re-enable ui elements.
void executeWrapperStarted()
Definition: mainwindow.cpp:376
void showStatusMessage(QString msg, int timeout=2000)
Displays message in status bar.
void passGitInitNeeded()
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
Definition: mainwindow.cpp:846
void onPush()
MainWindow::onPush do a git push.
Definition: mainwindow.cpp:302
void critical(QString, QString)
MainWindow::critical critical message popup wrapper.
void generateGPGKeyPair(QString batch)
void passOtpHandler(const QString &)
Definition: mainwindow.cpp:429
void restoreWindow()
Definition: mainwindow.cpp:478
void keyPressEvent(QKeyEvent *event)
MainWindow::keyPressEvent did anyone press return, enter or escape?
Definition: mainwindow.cpp:885
QDialog * getKeygenDialog()
Definition: mainwindow.h:56
bool eventFilter(QObject *obj, QEvent *event)
MainWindow::eventFilter filter out some events and focus the treeview.
Definition: mainwindow.cpp:871
const QModelIndex getCurrentTreeViewIndex()
Definition: mainwindow.cpp:201
void flashText(const QString &text, const bool isError, const bool isHtml=false)
Definition: mainwindow.cpp:210
void setUiElementsEnabled(bool state)
MainWindow::setUiElementsEnabled enable or disable the relevant UI elements.
Definition: mainwindow.cpp:462
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
Definition: mainwindow.cpp:145
void cleanKeygenDialog()
Definition: mainwindow.cpp:205
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
Definition: mainwindow.cpp:366
void on_treeView_clicked(const QModelIndex &index)
MainWindow::on_treeView_clicked read the selected password file.
Definition: mainwindow.cpp:332
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:753
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:709
void config()
MainWindow::config pops up the configuration screen and handles all inter-window communication.
Definition: mainwindow.cpp:230
void messageAvailable(QString message)
MainWindow::messageAvailable we have some text/message/search to do.
Definition: mainwindow.cpp:736
void passShowHandlerFinished(QString output)
Definition: qtpass.h:10
The SingleApplication class is used for commandline intergration.
The QSortFilterProxyModel for handling filesystem searches.
Definition: storemodel.h:11
Handles the systemtray icon and menu.
Definition: trayicon.h:14
Definition: configdialog.h:9