QtPass 1.6.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// SPDX-FileCopyrightText: 2014 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;
51class MainWindow : public QMainWindow {
52 Q_OBJECT
53
54public:
55 explicit MainWindow(const QString &searchText = QString(),
56 QWidget *parent = nullptr);
57 ~MainWindow() override;
58
59 void restoreWindow();
60 void generateKeyPair(const QString &, QDialog *);
61 void userDialog(const QString & = "");
62 void config();
63
64 void setUiElementsEnabled(bool state);
65 void flashText(const QString &text, const bool isError,
66 const bool isHtml = false);
67
68 auto getCurrentTreeViewIndex() -> QModelIndex;
69
70 auto getKeygenDialog() -> QDialog * { return this->keygen; }
71 void cleanKeygenDialog();
72
73protected:
74 void closeEvent(QCloseEvent *event) override;
75 void keyPressEvent(QKeyEvent *event) override;
76 void changeEvent(QEvent *event) override;
77 auto eventFilter(QObject *obj, QEvent *event) -> bool override;
78
79signals:
80 void passShowHandlerFinished(const QString &output);
82 void generateGPGKeyPair(const QString &batch);
83
84public slots:
85 void deselect();
86
87 void messageAvailable(const QString &message);
88 void critical(const QString &, const QString &);
89
91 void showStatusMessage(const QString &msg, int timeout = 2000);
92 void passShowHandler(const QString &);
93 void passOtpHandler(const QString &);
94
95 void onPush();
96 void on_treeView_clicked(const QModelIndex &index);
97
98 void startReencryptPath();
99 void endReencryptPath();
100
101private slots:
102 void addPassword();
103 void addFolder();
104 void onEdit();
105 void onDelete();
106 void onOtp();
107 void onUpdate(bool block = false);
108 void onUsers();
109 void onConfig();
110 void on_treeView_doubleClicked(const QModelIndex &index);
111 void clearPanel(bool notify = true);
112 void on_lineEdit_textChanged(const QString &arg1);
113 void on_lineEdit_returnPressed();
114#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
115 void on_profileBox_currentIndexChanged(QString);
116#else
117 void on_profileBox_currentTextChanged(const QString &);
118#endif
119 void showContextMenu(const QPoint &pos);
120 void showBrowserContextMenu(const QPoint &pos);
121 void openFolder();
122 void renameFolder();
123 void editPassword(const QString &);
124 void renamePassword();
125 void focusInput();
126 void copyPasswordFromTreeview();
127 void passwordFromFileToClipboard(const QString &text);
128 void onTimeoutSearch();
129
130private:
131 QtPass *m_qtPass;
132 QScopedPointer<Ui::MainWindow> ui;
133 QFileSystemModel model;
134 StoreModel proxyModel;
135 QScopedPointer<QItemSelectionModel> selectionModel;
136 QTimer clearPanelTimer, searchTimer;
137 QDialog *keygen;
138 QString currentDir;
139 TrayIcon *tray;
140
141 void initToolBarButtons();
142 void initStatusBar();
143
144 void updateText();
145 void selectFirstFile();
146 auto firstFile(QModelIndex parentIndex) -> QModelIndex;
147 auto getFile(const QModelIndex &, bool) -> QString;
148 void setPassword(const QString &, bool isNew = true);
149
150 void updateProfileBox();
151 void initTrayIcon();
152 void destroyTrayIcon();
153 void clearTemplateWidgets();
154 void reencryptPath(QString dir);
155 void addToGridLayout(int position, const QString &field,
156 const QString &value);
157
158 void applyTextBrowserSettings();
159 void applyWindowFlagsSettings();
160
161 void updateGitButtonVisibility();
162 void updateOtpButtonVisibility();
163 void enableGitButtons(const bool &);
164};
165
166#endif // SRC_MAINWINDOW_H_
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition mainwindow.h:51
void startReencryptPath()
MainWindow::startReencryptPath disable ui elements and treeview.
void closeEvent(QCloseEvent *event) override
MainWindow::closeEvent hide or quit.
void passShowHandler(const QString &)
~MainWindow() override
void endReencryptPath()
MainWindow::endReencryptPath re-enable ui elements.
void executeWrapperStarted()
void generateKeyPair(const QString &, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
void passGitInitNeeded()
void changeEvent(QEvent *event) override
MainWindow::changeEvent sets focus to the search box.
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.
MainWindow(const QString &searchText=QString(), QWidget *parent=nullptr)
MainWindow::MainWindow handles all of the main functionality and also the main window.
void keyPressEvent(QKeyEvent *event) override
MainWindow::keyPressEvent did anyone press return, enter or escape?
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()
auto eventFilter(QObject *obj, QEvent *event) -> bool override
MainWindow::eventFilter filter out some events and focus the treeview.
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 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:70
void config()
QSortFilterProxyModel for filtering and displaying password store.
Definition storemodel.h:31
Handles the systemtray icon and menu.
Definition trayicon.h:51
#define SingleApplication
Definition mainwindow.h:17