QtPass 1.5.1
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
mainwindow.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_MAINWINDOW_H_
4#define SRC_MAINWINDOW_H_
5
6#include "storemodel.h"
7
8#include <QFileSystemModel>
9#include <QItemSelectionModel>
10#include <QMainWindow>
11#include <QProcess>
12#include <QTimer>
13
14#if SINGLE_APP
16#else
17#define SingleApplication QApplication
18#endif
19
20#ifdef __APPLE__
21// http://doc.qt.io/qt-5/qkeysequence.html#qt_set_sequence_auto_mnemonic
22void qt_set_sequence_auto_mnemonic(bool b);
23#endif
24
25namespace Ui {
26class MainWindow;
27}
28
36class QDialog;
37class QtPass;
38class TrayIcon;
39class MainWindow : public QMainWindow {
40 Q_OBJECT
41
42public:
43 explicit MainWindow(const QString &searchText = QString(),
44 QWidget *parent = nullptr);
46
47 void restoreWindow();
48 void generateKeyPair(const QString &, QDialog *);
49 void userDialog(const 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 auto getCurrentTreeViewIndex() -> QModelIndex;
57
58 auto getKeygenDialog() -> QDialog * { return this->keygen; }
59 void cleanKeygenDialog();
60
61protected:
62 void closeEvent(QCloseEvent *event);
63 void keyPressEvent(QKeyEvent *event);
64 void changeEvent(QEvent *event);
65 auto eventFilter(QObject *obj, QEvent *event) -> bool;
66
67signals:
68 void passShowHandlerFinished(const QString &output);
70 void generateGPGKeyPair(const QString &batch);
71
72public slots:
73 void deselect();
74
75 void messageAvailable(const QString &message);
76 void critical(const QString &, const QString &);
77
79 void showStatusMessage(const 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
89private 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#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
103 void on_profileBox_currentIndexChanged(QString);
104#else
105 void on_profileBox_currentTextChanged(const QString &);
106#endif
107 void showContextMenu(const QPoint &pos);
108 void showBrowserContextMenu(const QPoint &pos);
109 void openFolder();
110 void renameFolder();
111 void editPassword(const QString &);
112 void renamePassword();
113 void focusInput();
114 void copyPasswordFromTreeview();
115 void passwordFromFileToClipboard(const QString &text);
116 void onTimeoutSearch();
117
118private:
119 QtPass *m_qtPass;
120 QScopedPointer<Ui::MainWindow> ui;
121 QFileSystemModel model;
122 StoreModel proxyModel;
123 QScopedPointer<QItemSelectionModel> selectionModel;
124 QTimer clearPanelTimer, searchTimer;
125 QDialog *keygen;
126 QString currentDir;
127 TrayIcon *tray;
128
129 void initToolBarButtons();
130 void initStatusBar();
131
132 void updateText();
133 void selectFirstFile();
134 auto firstFile(QModelIndex parentIndex) -> QModelIndex;
135 auto getFile(const QModelIndex &, bool) -> QString;
136 void setPassword(const QString &, bool isNew = true);
137
138 void updateProfileBox();
139 void initTrayIcon();
140 void destroyTrayIcon();
141 void clearTemplateWidgets();
142 void reencryptPath(QString dir);
143 void addToGridLayout(int position, const QString &field,
144 const QString &value);
145
146 void updateGitButtonVisibility();
147 void updateOtpButtonVisibility();
148 void enableGitButtons(const bool &);
149};
150
151#endif // SRC_MAINWINDOW_H_
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition mainwindow.h:39
void startReencryptPath()
MainWindow::startReencryptPath disable ui elements and treeview.
void passShowHandler(const QString &)
void endReencryptPath()
MainWindow::endReencryptPath re-enable ui elements.
void executeWrapperStarted()
void generateKeyPair(const QString &, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
void passGitInitNeeded()
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent hide or quit.
void critical(const QString &, const QString &)
MainWindow::critical critical message popup wrapper.
void messageAvailable(const QString &message)
MainWindow::messageAvailable we have some text/message/search to do.
void onPush()
MainWindow::onPush do a git push.
void showStatusMessage(const QString &msg, int timeout=2000)
Displays message in status bar.
void passOtpHandler(const QString &)
void passShowHandlerFinished(const QString &output)
void generateGPGKeyPair(const QString &batch)
void restoreWindow()
void keyPressEvent(QKeyEvent *event)
MainWindow::keyPressEvent did anyone press return, enter or escape?
void flashText(const QString &text, const bool isError, const bool isHtml=false)
void userDialog(const QString &="")
MainWindow::userDialog see MainWindow::onUsers()
void setUiElementsEnabled(bool state)
MainWindow::setUiElementsEnabled enable or disable the relevant UI elements.
auto eventFilter(QObject *obj, QEvent *event) -> bool
MainWindow::eventFilter filter out some events and focus the treeview.
void changeEvent(QEvent *event)
MainWindow::changeEvent sets focus to the search box.
auto getCurrentTreeViewIndex() -> QModelIndex
void cleanKeygenDialog()
void deselect()
MainWindow::deselect clear the selection, password and copy buffer.
void on_treeView_clicked(const QModelIndex &index)
MainWindow::on_treeView_clicked read the selected password file.
auto getKeygenDialog() -> QDialog *
Definition mainwindow.h:58
void config()
MainWindow::config pops up the configuration screen and handles all inter-window communication.
The SingleApplication class is used for commandline intergration.
The QSortFilterProxyModel for handling filesystem searches.
Definition storemodel.h:13
Handles the systemtray icon and menu.
Definition trayicon.h:16