QtPass 1.7.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
mainwindow.h
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
15class SingleApplication;
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
29class QDialog;
30class QTreeWidgetItem;
31class QtPass;
32class TrayIcon;
33
45class MainWindow : public QMainWindow {
46 Q_OBJECT
47
48public:
54 explicit MainWindow(const QString &searchText = QString(),
55 QWidget *parent = nullptr);
56 ~MainWindow() override;
57
62
69 void generateKeyPair(const QString &batch, QDialog *dialog);
70
75 void userDialog(const QString &dir = "");
76
80 void config();
81
86 void setUiElementsEnabled(bool state);
87
94 void flashText(const QString &text, const bool isError,
95 const bool isHtml = false);
96
101 auto getCurrentTreeViewIndex() -> QModelIndex;
102
107 auto getKeygenDialog() -> QDialog * { return this->keygen; }
108
113
114protected:
119 void closeEvent(QCloseEvent *event) override;
124 void keyPressEvent(QKeyEvent *event) override;
129 void changeEvent(QEvent *event) override;
136 auto eventFilter(QObject *obj, QEvent *event) -> bool override;
137
138signals:
143 void passShowHandlerFinished(const QString &output);
152 void generateGPGKeyPair(const QString &batch);
153
154public slots:
158 void deselect();
159
164 void messageAvailable(const QString &message);
165
171 void critical(const QString &title, const QString &msg);
172
177
183 void showStatusMessage(const QString &msg, int timeout = 2000);
184
189 void passShowHandler(const QString &output);
190
195 void passOtpHandler(const QString &output);
196
201 void onGrepFinished(const QList<QPair<QString, QStringList>> &results);
202
206 void onPush();
207
212 void on_treeView_clicked(const QModelIndex &index);
213
218
223
224private slots:
225 void on_grepButton_toggled(bool checked);
226 void on_grepResultsList_itemClicked(QTreeWidgetItem *item, int column);
227 void addPassword();
228 void addFolder();
229 void onEdit();
230 void onDelete();
231 void onOtp();
232 void onUpdate(bool block = false);
233 void onUsers();
234 void onConfig();
235 void on_treeView_doubleClicked(const QModelIndex &index);
236 void clearPanel(bool notify = true);
237 void on_lineEdit_textChanged(const QString &arg1);
238 void on_lineEdit_returnPressed();
239#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
240 void on_profileBox_currentIndexChanged(QString);
241#else
242 void on_profileBox_currentTextChanged(const QString &);
243#endif
244 void showContextMenu(const QPoint &pos);
245 void showBrowserContextMenu(const QPoint &pos);
246 void openFolder();
247 void renameFolder();
248 void editPassword(const QString &);
249 void renamePassword();
250 void focusInput();
251 void copyPasswordFromTreeview();
252 void passwordFromFileToClipboard(const QString &text);
253 void onTimeoutSearch();
254
255private:
256 QtPass *m_qtPass;
257 QScopedPointer<Ui::MainWindow> ui;
258 bool m_grepMode = false;
259 bool m_grepBusy = false;
260 bool m_grepCancelled = false;
261 QFileSystemModel model;
262 StoreModel proxyModel;
263 QScopedPointer<QItemSelectionModel> selectionModel;
264 QTimer clearPanelTimer, searchTimer;
265 QDialog *keygen;
266 QString currentDir;
267 TrayIcon *tray;
268
269 void initToolBarButtons();
270 void initStatusBar();
271
272 void updateText();
273 void selectFirstFile();
274 auto firstFile(QModelIndex parentIndex) -> QModelIndex;
275 auto getFile(const QModelIndex &, bool) -> QString;
276 void setPassword(const QString &, bool isNew = true);
277
278 void updateProfileBox();
279 void initTrayIcon();
280 void destroyTrayIcon();
281 void clearTemplateWidgets();
282 void reencryptPath(const QString &dir);
283 void addToGridLayout(int position, const QString &field,
284 const QString &value);
285
286 void applyTextBrowserSettings();
287 void applyWindowFlagsSettings();
288
289 void updateGitButtonVisibility();
290 void updateOtpButtonVisibility();
291 void updateGrepButtonVisibility();
292 void enableGitButtons(const bool &);
293};
294
295#endif // SRC_MAINWINDOW_H_
void startReencryptPath()
Begin a re-encryption pass on the current path.
void userDialog(const QString &dir="")
Open the user/recipient management dialog.
void closeEvent(QCloseEvent *event) override
Save window state and geometry on close.
void endReencryptPath()
Finish a re-encryption pass on the current path.
void onGrepFinished(const QList< QPair< QString, QStringList > > &results)
Handle results from a completed grep search.
void executeWrapperStarted()
Slot called when an external process wrapper has started.
void passShowHandler(const QString &output)
Handle output from the pass show command.
void passGitInitNeeded()
Emitted when a Git init is required for the current store.
void changeEvent(QEvent *event) override
React to language or window state changes.
void messageAvailable(const QString &message)
Handle an incoming inter-process message (single-instance mode).
MainWindow(const QString &searchText=QString(), QWidget *parent=nullptr)
Construct the main window.
void keyPressEvent(QKeyEvent *event) override
Handle keyboard shortcuts.
void onPush()
Trigger a git push operation.
void showStatusMessage(const QString &msg, int timeout=2000)
Show a message in the status bar for the given duration.
void passShowHandlerFinished(const QString &output)
Emitted when the pass show handler has finished decrypting.
void generateGPGKeyPair(const QString &batch)
Emitted to trigger GPG key pair generation.
void critical(const QString &title, const QString &msg)
Display a critical error dialog.
void generateKeyPair(const QString &batch, QDialog *dialog)
Open the GPG key generation dialog.
void restoreWindow()
Restore window geometry and state from saved settings.
auto eventFilter(QObject *obj, QEvent *event) -> bool override
Filter events from watched objects.
void flashText(const QString &text, const bool isError, const bool isHtml=false)
Display a transient message in the text panel.
void setUiElementsEnabled(bool state)
Enable or disable the main UI elements.
auto getCurrentTreeViewIndex() -> QModelIndex
Return the currently selected index in the tree view.
void passOtpHandler(const QString &output)
Handle output from the pass OTP command.
void cleanKeygenDialog()
Destroy and clear the key generation dialog.
void deselect()
Clear the current tree view selection.
void on_treeView_clicked(const QModelIndex &index)
Handle a click on an item in the tree view.
auto getKeygenDialog() -> QDialog *
Return the active key generation dialog, if any.
Definition mainwindow.h:107
void config()
Open the configuration dialog.
Orchestrates clipboard management, pass signal handling, and application-level operations for the QtP...
Definition qtpass.h:38
QSortFilterProxyModel for filtering and displaying password store.
Definition storemodel.h:40
Handles the system tray icon and menu.
Definition trayicon.h:17