QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
MainWindow Class Reference

Main application window orchestrating UI, user interactions, and external process handlers. More...

#include <mainwindow.h>

Inheritance diagram for MainWindow:
Collaboration diagram for MainWindow:

Public Slots

void deselect ()
 Clear the current tree view selection.
void messageAvailable (const QString &message)
 Handle an incoming inter-process message (single-instance mode).
void onProcessOutput (const QString &output, bool isError, Enums::PROCESS pid=Enums::INVALID)
 Handle generic process output for display in output panel.
void critical (const QString &title, const QString &msg)
 Display a critical error dialog.
void executeWrapperStarted ()
 Slot called when an external process wrapper has started.
void showStatusMessage (const QString &msg, int timeout=2000)
 Show a message in the status bar for the given duration.
void passShowHandler (const QString &output, const QString &file=QString())
 Render a decrypted entry: fields into the display panel, the rest into the text browser, and the password onto the clipboard when "Always copy" is set. Decrypts of any entry but the one the panel last asked to show (m_shownFile) are dropped.
void otpFromFileToClipboard (const QString &output, const QString &file)
 Generate a one-time password from decrypted content and copy it. Ignores decrypts of anything but the entry onOtp() asked for.
void passwordFromFileToClipboard (const QString &text, const QString &file)
 Copy the first line of a decrypted entry (Ctrl+C). Ignores decrypts of anything but the entry copyPasswordFromTreeview() asked for; an otpauth:// first line is refused.
void cancelOtpRequest ()
 Forget the pending OTP and copy requests.
void onOperationError ()
 An operation ended in an error before or instead of a result: forget the pending requests and what the panel was about to show.
void dropStaleToolsAreaPalettes ()
 Drop a style-imposed menu bar or toolbar palette that belongs to the other theme (Breeze header palette after a light/dark switch).
void onGrepFinished (const QList< QPair< QString, QStringList > > &results)
 Handle results from a completed grep search.
void onPush ()
 Trigger a git push operation.
void on_treeView_clicked (const QModelIndex &index)
 Handle a click on an item in the tree view.
void startReencryptPath ()
 Begin a re-encryption pass on the current path.
void reencryptProgress (int current, int total)
 Update the re-encryption progress dialog.
void endReencryptPath ()
 Finish a re-encryption pass on the current path.

Public Member Functions

 MainWindow (const QString &searchText=QString(), QWidget *parent=nullptr)
 Construct the main window.
 ~MainWindow () override
 Save the window state (a quit from the tray menu or a SIGTERM never delivers closeEvent()) and delete the QtPass glue.
void restoreWindow ()
 Restore window geometry and state from saved settings.
auto config () -> bool
 Open the configuration dialog.
void setUiElementsEnabled (bool state)
 Enable or disable the main UI elements.
void flashText (const QString &text, const bool isError, const bool isHtml=false)
 Display a transient message in the text panel.
auto getCurrentTreeViewIndex () -> QModelIndex
 Return the currently selected index in the tree view.
auto initSucceeded () const -> bool
 Return whether startup configuration succeeded.

Protected Member Functions

void closeEvent (QCloseEvent *event) override
 Save window state and geometry on close.
void keyPressEvent (QKeyEvent *event) override
 Handle keyboard shortcuts.
void changeEvent (QEvent *event) override
 React to language or window state changes.
auto event (QEvent *event) -> bool override
 Notice an application palette change, the theme switch that makes a style-imposed bar palette suspect; see dropStaleToolsAreaPalettes().
void showEvent (QShowEvent *event) override
 First-show hook used to focus the search input once the window is actually mapped (avoids races with timers fired before show).
auto eventFilter (QObject *obj, QEvent *event) -> bool override
 Filter events from watched objects.

Private Slots

void updateProfileBox ()
 Fill the profile box from the settings, the active profile selected, without switching profiles while doing so.
void updateProfileBoxEnabled ()
 Enable the profile box only when there is more than one profile, the interface is enabled and the backend is idle.
void on_grepButton_toggled (bool checked)
 The content-search toggle changed: switch the search box between name filtering and regex content search, clearing the query, the tree filter and any results; leaving while a search runs cancels it.
void on_grepResultsList_itemClicked (QTreeWidgetItem *item, int column)
 A content-search result was clicked: select the entry in the tree, show it, and go back to the tree (clearing the results when content is hidden or the panel autoclears).
void addPassword ()
 Toolbar/context-menu "Add password": open PasswordDialog for a new entry in the current folder.
void addFolder ()
 Toolbar/context-menu "Add folder": ask for a name, create the folder under the current one (refusing paths that escape the store) and seed its .gpg-id from the parent when configured.
void onEdit ()
 Toolbar "Edit" or a double-click: editPassword() on the current entry.
void onDelete ()
 Toolbar "Delete" or the Delete key: confirm, then remove the current entry or folder. Nothing selected is a no-op (#556); a linked folder only loses its link, a folder behind a link is refused.
void onOtp ()
 Toolbar "OTP": copy the current entry's one-time code. Uses the code the panel already shows for this entry; otherwise decrypts once and lets otpFromFileToClipboard() finish.
void onUpdate (bool block=false)
 Toolbar "Update": git pull.
void onUsers ()
 Toolbar/context-menu "Users": open UsersDialog for the current folder, unless it lies behind a link.
void onConfig ()
 Toolbar "Config": config(), ignoring its result.
void showAbout ()
 Show the About box: version, project link, licence.
void on_treeView_doubleClicked (const QModelIndex &index)
 A double-click on a tree entry opens it for editing; folders are left to the view.
void clearPanel (bool notify=true)
 Empty the display panel and the text browser, and leave content search if its results were showing. Runs on the autoclear timer.
void on_lineEdit_textChanged (const QString &arg1)
 The search box changed (name filtering only): drop the pending decrypt and the panel, expand the tree and restart searchTimer.
void on_lineEdit_returnPressed ()
 Enter in the search box: in content-search mode start (or, for an empty query, cancel) the grep; otherwise select and show the first matching entry.
void on_profileBox_currentTextChanged (const QString &name)
 The user picked another profile: save its store, key and Git flags as the active settings, re-root the tree and clear the selection. Ignored during the fresh start and reverted while an operation runs.
void showContextMenu (const QPoint &pos)
 Build and show the tree's context menu for the item under the cursor: folder actions (open, add, users, rename, Share) or entry actions (edit, rename), plus Delete.
void addShareMenu (QMenu &contextMenu, const AppSettings &s)
 Add the Share submenu for the folder under the cursor: the entries are enabled only where a recipient list and a usable gpg or pass make them work.
auto confirmDeletion (const QString &file, bool isDir) -> bool
 Ask before deleting an entry or a folder, naming what goes and warning when the folder holds anything but entries.
auto confirmLinkRemoval (const QString &file) -> bool
 Ask before removing a folder that is a link, which takes the link and leaves what it points to.
void showBrowserContextMenu (const QPoint &pos)
 Show the text browser's standard context menu, reparented to the window so the browser's stylesheet does not bleed into it.
void openFolder ()
 Context menu "Open folder with file manager" on the current folder.
void renameFolder ()
 Context menu "Rename folder": ask for a new name and Move the current folder, refusing a target outside the store.
void editPassword (const QString &file)
 Open PasswordDialog on an existing entry, after a blocking pull when auto-pull is on. Releases the panel's claim on the next decrypt so the dialog's own Show does not repaint or copy.
void renamePassword ()
 Context menu "Rename password": ask for a new name and Move the current entry within its folder, refusing a target outside the store.
void focusInput ()
 Select-all and focus the search box once the window is visible; sets m_firstShowCompleted only on success so showEvent() retries. Looks the widget up by name because setWindowFlags() can rebuild it under ui->lineEdit (Qt 6.11).
void copyPasswordFromTreeview ()
 Ctrl+C on the tree: decrypt the current entry and let passwordFromFileToClipboard() copy its first line. The newest request wins (m_copyRequestFile).
void onTimeoutSearch ()
 searchTimer fired: filter the tree on the typed words (matched literally, in order, case-insensitively) and select the first match; an empty query collapses the tree and deselects.

Private Member Functions

void initToolBarButtons ()
void initStatusBar ()
 Welcome message and the permanent logo in the status bar.
void connectBackends ()
void initTextBrowser ()
 Font, wrapping and link handling of the text browser, per the settings.
void initDisplayPanel ()
 The grid of decrypted fields and what its buttons ask for.
void initTimers ()
void initProcessOutput ()
void connectPassSignals (Pass *pass)
 Connect the signals of one backend that the window answers itself: errors, critical messages, wrapper start, idle, status, finishedShow (panel, OTP and Ctrl+C handlers) and finishedGrep.
void selectFirstFile ()
 Make the first entry (depth first) under the store root current.
auto firstFile (QModelIndex parentIndex) -> QModelIndex
 Depth-first search for the first entry under a folder.
auto getFile (const QModelIndex &index, bool forPass) -> QString
 StoreTree::fileFor() on the tree.
void setPassword (const QString &file, bool isNew=true)
 Run PasswordDialog for a new or existing entry. For a new one the dialog gets the store's real folders (current one preselected) and the .templates, if any.
auto confirmPathInStore (const QString &candidate) -> bool
 Guard the input dialogs (create, move, rename) against names like ../../etc/passwd or absolute paths escaping the store root; warns the user when refusing.
void initTrayIcon ()
 Create m_tray and add the menu bar toggle to its menu; gives up (m_tray stays null) when no system tray is available.
void destroyTrayIcon ()
 Delete m_tray and reset it to null.
void reencryptPath (const QString &dir)
 Share menu "Re-encrypt all passwords": confirm, lock the UI via startReencryptPath() and have ImitatePass rewrite every entry under dir for the recipients in its .gpg-id.
void exportPublicKey ()
 Share menu "Export my public key": run gpg --armor --export for the configured signing key and show the result in ExportPublicKeyDialog; explains what to do when no key is set.
void addRecipient (const QString &dir)
 Share menu "Add recipient": open UsersDialog for dir (keys already in the keyring only).
auto refuseLinkedFolder (const QString &dir) -> bool
 Refuse, with a message, a tree-picked folder that is or lies behind a symlink or junction: what it points to is not part of the store. The store root itself may be a link.
void showShareHelp ()
 Share menu "What is this?": the explanation of sharing with GPG.
void applyTextBrowserSettings ()
void applyWindowFlagsSettings ()
void saveWindowState ()
void updateGitButtonVisibility (bool uiEnabled=true)
 Show Push and Pull only when Git is in use; enable them only while the interface is.
void updateOtpButtonVisibility (bool uiEnabled=true)
 Refresh the OTP toolbar action from settings.
void updateGrepButtonVisibility ()
void enableGitButtons (const bool &state)
 Enable or disable the Push and Pull actions together.
void updateProcessOutputVisibility ()

Private Attributes

QtPass * m_qtPass
 The UI-neutral glue to the backends (output, status, clipboard, QR codes); created in the constructor, deleted in the destructor.
QScopedPointer< Ui::MainWindow > ui
 The widgets generated from mainwindow.ui.
GrepSearchController m_grep
 Mode/busy/cancelled state of the content search.
PasswordDisplayPanel * m_displayPanel = nullptr
 Renders decrypted fields into the grid; created in initDisplayPanel(), parented to this window.
bool m_firstShowCompleted = false
 Set once focusInput() has actually focused the search box, so later show events leave the focus alone.
bool m_themeSwitched = false
QString m_shownFile
QString m_otpRequestFile
QString m_copyRequestFile
ProcessOutputPanel * m_processOutput = nullptr
StoreTree * m_tree = nullptr
 The store as shown in the tree: models, view setup, path mapping.
QTimer clearPanelTimer
QTimer searchTimer
QTimer m_uiWatchdog
QPointer< QProgressDialog > m_reencryptProgress
bool m_reencryptRunning = false
bool m_uiEnabled = true
TrayIcon * m_tray {}
bool m_initSucceeded = false
bool m_freshStart = true

Static Private Attributes

static constexpr int UiWatchdogMs = 30000
 Interval of m_uiWatchdog in milliseconds.

Detailed Description

Main application window orchestrating UI, user interactions, and external process handlers.

Provides the central interface for managing items, folders, passwords, and OTPs; coordinates UI components (toolbars, panels, dialogs, status/tray), selection and navigation in the underlying file/store models, and lifecycle interactions with external handlers (e.g., pass, Git, GPG key generation, OTP).

Definition at line 59 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( const QString & searchText = QString(),
QWidget * parent = nullptr )
explicit

Construct the main window.

Parameters
searchTextInitial search text to populate the search field.
parentOptional parent widget.

Definition at line 64 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Save the window state (a quit from the tray menu or a SIGTERM never delivers closeEvent()) and delete the QtPass glue.

Definition at line 260 of file mainwindow.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addFolder

void MainWindow::addFolder ( )
privateslot

Toolbar/context-menu "Add folder": ask for a name, create the folder under the current one (refusing paths that escape the store) and seed its .gpg-id from the parent when configured.

Definition at line 1516 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPassword

void MainWindow::addPassword ( )
privateslot

Toolbar/context-menu "Add password": open PasswordDialog for a new entry in the current folder.

Definition at line 1087 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addRecipient()

void MainWindow::addRecipient ( const QString & dir)
private

Share menu "Add recipient": open UsersDialog for dir (keys already in the keyring only).

Parameters
dirAbsolute folder; refused when behind a link.

Definition at line 1768 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addShareMenu

void MainWindow::addShareMenu ( QMenu & contextMenu,
const AppSettings & s )
privateslot

Add the Share submenu for the folder under the cursor: the entries are enabled only where a recipient list and a usable gpg or pass make them work.

Parameters
contextMenuThe menu being built, which owns the submenu.
sThe settings the executables and the store come from.

Definition at line 1421 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyTextBrowserSettings()

void MainWindow::applyTextBrowserSettings ( )
private

Re-apply the monospace and line-wrapping settings to the text browser after the configuration dialog.

Definition at line 449 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyWindowFlagsSettings()

void MainWindow::applyWindowFlagsSettings ( )
private

Toggle Qt::WindowStaysOnTopHint to match the "always on top" setting, skipping the native-window rebuild when nothing changes.

Definition at line 466 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancelOtpRequest

void MainWindow::cancelOtpRequest ( )
slot

Forget the pending OTP and copy requests.

A failed decrypt never emits Pass::finishedShow; without this a later decrypt of the same entry (the user retrying) would be taken as the answer to a request the user has long given up on.

Definition at line 1156 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ changeEvent()

void MainWindow::changeEvent ( QEvent * event)
overrideprotected

React to language or window state changes.

Parameters
eventThe change event.

Definition at line 323 of file mainwindow.cpp.

Here is the call graph for this function:

◆ clearPanel

void MainWindow::clearPanel ( bool notify = true)
privateslot

Empty the display panel and the text browser, and leave content search if its results were showing. Runs on the autoclear timer.

Parameters
notifytrue to show "Password and content hidden" in the browser, false to leave it blank.

Definition at line 716 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent * event)
overrideprotected

Save window state and geometry on close.

Parameters
eventThe close event.

Definition at line 1335 of file mainwindow.cpp.

Here is the call graph for this function:

◆ config()

auto MainWindow::config ( ) -> bool

Open the configuration dialog.

On a fresh start the first-run wizard runs before the dialog is shown. Accepting the dialog does not guarantee a usable configuration: the OK button is not gated on Util::configIsValid(), so QtPass::init() uses the return value to decide whether to ask again or to give up.

Returns
true when the dialog was accepted, false when it was cancelled.

Definition at line 485 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ confirmDeletion

auto MainWindow::confirmDeletion ( const QString & file,
bool isDir ) -> bool
privateslot

Ask before deleting an entry or a folder, naming what goes and warning when the folder holds anything but entries.

Parameters
fileStore-relative path being deleted.
isDirWhether it is a folder.
Returns
Whether the user said yes.

Definition at line 1089 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ confirmLinkRemoval

auto MainWindow::confirmLinkRemoval ( const QString & file) -> bool
privateslot

Ask before removing a folder that is a link, which takes the link and leaves what it points to.

Parameters
fileStore-relative path of the link.
Returns
Whether the user said yes.

Definition at line 1120 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ confirmPathInStore()

auto MainWindow::confirmPathInStore ( const QString & candidate) -> bool
private

Guard the input dialogs (create, move, rename) against names like ../../etc/passwd or absolute paths escaping the store root; warns the user when refusing.

Parameters
candidatePath the user asked for.
Returns
true when it resolves inside the store.

Definition at line 1037 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connectBackends()

void MainWindow::connectBackends ( )
private

Connect QtPass's and both backends' signals (the active backend can change through the configuration dialog without a restart).

Definition at line 135 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connectPassSignals()

void MainWindow::connectPassSignals ( Pass * pass)
private

Connect the signals of one backend that the window answers itself: errors, critical messages, wrapper start, idle, status, finishedShow (panel, OTP and Ctrl+C handlers) and finishedGrep.

Parameters
passThe backend; both are connected, see connectBackends().

Definition at line 268 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyPasswordFromTreeview

void MainWindow::copyPasswordFromTreeview ( )
privateslot

Ctrl+C on the tree: decrypt the current entry and let passwordFromFileToClipboard() copy its first line. The newest request wins (m_copyRequestFile).

Definition at line 1615 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ critical

void MainWindow::critical ( const QString & title,
const QString & msg )
slot

Display a critical error dialog.

Parameters
titleDialog title.
msgError message body.

Definition at line 1848 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deselect

void MainWindow::deselect ( )
slot

Clear the current tree view selection.

Definition at line 584 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyTrayIcon()

void MainWindow::destroyTrayIcon ( )
private

Delete m_tray and reset it to null.

Definition at line 1330 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ dropStaleToolsAreaPalettes

void MainWindow::dropStaleToolsAreaPalettes ( )
slot

Drop a style-imposed menu bar or toolbar palette that belongs to the other theme (Breeze header palette after a light/dark switch).

Definition at line 1372 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ editPassword

void MainWindow::editPassword ( const QString & file)
privateslot

Open PasswordDialog on an existing entry, after a blocking pull when auto-pull is on. Releases the panel's claim on the next decrypt so the dialog's own Show does not repaint or copy.

Parameters
fileStore-relative entry name; empty is a no-op.

Definition at line 1577 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableGitButtons()

void MainWindow::enableGitButtons ( const bool & state)
private

Enable or disable the Push and Pull actions together.

Parameters
statetrue to enable.

Definition at line 1843 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ endReencryptPath

void MainWindow::endReencryptPath ( )
slot

Finish a re-encryption pass on the current path.

Definition at line 1721 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ event()

auto MainWindow::event ( QEvent * event) -> bool
overrideprotected

Notice an application palette change, the theme switch that makes a style-imposed bar palette suspect; see dropStaleToolsAreaPalettes().

Parameters
eventThe event.
Returns
true if the event was consumed.

Definition at line 313 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

auto MainWindow::eventFilter ( QObject * obj,
QEvent * event ) -> bool
overrideprotected

Filter events from watched objects.

Parameters
objThe object that received the event.
eventThe event to filter.
Returns
true if the event was consumed.

Definition at line 1351 of file mainwindow.cpp.

Here is the call graph for this function:

◆ executeWrapperStarted

void MainWindow::executeWrapperStarted ( )
slot

Slot called when an external process wrapper has started.

Definition at line 595 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exportPublicKey()

void MainWindow::exportPublicKey ( )
private

Share menu "Export my public key": run gpg --armor --export for the configured signing key and show the result in ExportPublicKeyDialog; explains what to do when no key is set.

Definition at line 1731 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ firstFile()

auto MainWindow::firstFile ( QModelIndex parentIndex) -> QModelIndex
private

Depth-first search for the first entry under a folder.

Parameters
parentIndexProxy index of the folder to search.
Returns
Proxy index of the first file, or invalid when there is none.

Definition at line 1018 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flashText()

void MainWindow::flashText ( const QString & text,
const bool isError,
const bool isHtml = false )

Display a transient message in the text panel.

Parameters
textMessage text to display.
isErrortrue to style the message as an error.
isHtmltrue if text contains HTML markup.

Definition at line 425 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ focusInput

void MainWindow::focusInput ( )
privateslot

Select-all and focus the search box once the window is visible; sets m_firstShowCompleted only on success so showEvent() retries. Looks the widget up by name because setWindowFlags() can rebuild it under ui->lineEdit (Qt 6.11).

Definition at line 294 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ getCurrentTreeViewIndex()

auto MainWindow::getCurrentTreeViewIndex ( ) -> QModelIndex

Return the currently selected index in the tree view.

Returns
Current QModelIndex.

Definition at line 421 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ getFile()

auto MainWindow::getFile ( const QModelIndex & index,
bool forPass ) -> QString
private

StoreTree::fileFor() on the tree.

Parameters
indexProxy index.
forPasstrue for the store-relative entry name, false for the absolute .gpg path.
Returns
Entry name or path; empty for a folder or invalid index.

Definition at line 555 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ initDisplayPanel()

void MainWindow::initDisplayPanel ( )
private

The grid of decrypted fields and what its buttons ask for.

Definition at line 179 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initProcessOutput()

void MainWindow::initProcessOutput ( )
private

The Process Output dock, its Settings-menu toggle, and the feed of non-secret process output into it.

Definition at line 220 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initStatusBar()

void MainWindow::initStatusBar ( )
private

Welcome message and the permanent logo in the status bar.

Definition at line 411 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ initSucceeded()

auto MainWindow::initSucceeded ( ) const -> bool
inline

Return whether startup configuration succeeded.

Reflects the result of the initial configuration check performed in the constructor (QtPass::init()). When it is false the application cannot be used (e.g. the user cancelled the first-run wizard), and main() should exit before ever showing the window.

Returns
true when QtPass::init() reported a working configuration.

Definition at line 122 of file mainwindow.h.

Here is the caller graph for this function:

◆ initTextBrowser()

void MainWindow::initTextBrowser ( )
private

Font, wrapping and link handling of the text browser, per the settings.

Definition at line 160 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initTimers()

void MainWindow::initTimers ( )
private

The panel-clear and search timers, and the watchdog that re-enables the UI when an operation never signals its end.

Definition at line 198 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initToolBarButtons()

void MainWindow::initToolBarButtons ( )
private

Wire the toolbar and menu actions to their slots, set their icons, and set up the "Show menu bar" toggle with its MenuBarPeek (not on macOS).

Definition at line 352 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initTrayIcon()

void MainWindow::initTrayIcon ( )
private

Create m_tray and add the menu bar toggle to its menu; gives up (m_tray stays null) when no system tray is available.

Definition at line 1319 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keyPressEvent()

void MainWindow::keyPressEvent ( QKeyEvent * event)
overrideprotected

Handle keyboard shortcuts.

Parameters
eventThe key press event.

Definition at line 1402 of file mainwindow.cpp.

Here is the call graph for this function:

◆ messageAvailable

void MainWindow::messageAvailable ( const QString & message)
slot

Handle an incoming inter-process message (single-instance mode).

Parameters
messageMessage string received from another instance.

Definition at line 1222 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_grepButton_toggled

void MainWindow::on_grepButton_toggled ( bool checked)
privateslot

The content-search toggle changed: switch the search box between name filtering and regex content search, clearing the query, the tree filter and any results; leaving while a search runs cancels it.

Parameters
checkedtrue when content search was switched on.

Definition at line 892 of file mainwindow.cpp.

Here is the call graph for this function:

◆ on_grepResultsList_itemClicked

void MainWindow::on_grepResultsList_itemClicked ( QTreeWidgetItem * item,
int column )
privateslot

A content-search result was clicked: select the entry in the tree, show it, and go back to the tree (clearing the results when content is hidden or the panel autoclears).

Parameters
itemThe clicked entry or match line; its UserRole holds the entry name.
columnUnused.

Definition at line 992 of file mainwindow.cpp.

Here is the call graph for this function:

◆ on_lineEdit_returnPressed

void MainWindow::on_lineEdit_returnPressed ( )
privateslot

Enter in the search box: in content-search mode start (or, for an empty query, cancel) the grep; otherwise select and show the first matching entry.

Definition at line 862 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_lineEdit_textChanged

void MainWindow::on_lineEdit_textChanged ( const QString & arg1)
privateslot

The search box changed (name filtering only): drop the pending decrypt and the panel, expand the tree and restart searchTimer.

Parameters
arg1The new text.

Definition at line 817 of file mainwindow.cpp.

Here is the call graph for this function:

◆ on_profileBox_currentTextChanged

void MainWindow::on_profileBox_currentTextChanged ( const QString & name)
privateslot

The user picked another profile: save its store, key and Git flags as the active settings, re-root the tree and clear the selection. Ignored during the fresh start and reverted while an operation runs.

Parameters
nameThe chosen profile name.

Definition at line 1281 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_treeView_clicked

void MainWindow::on_treeView_clicked ( const QModelIndex & index)
slot

Handle a click on an item in the tree view.

Parameters
indexThe model index that was clicked.

Definition at line 559 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_treeView_doubleClicked

void MainWindow::on_treeView_doubleClicked ( const QModelIndex & index)
privateslot

A double-click on a tree entry opens it for editing; folders are left to the view.

Parameters
indexThe double-clicked proxy index.

Definition at line 576 of file mainwindow.cpp.

Here is the call graph for this function:

◆ onConfig

void MainWindow::onConfig ( )
privateslot

Toolbar "Config": config(), ignoring its result.

Definition at line 798 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onDelete

void MainWindow::onDelete ( )
privateslot

Toolbar "Delete" or the Delete key: confirm, then remove the current entry or folder. Nothing selected is a no-op (#556); a linked folder only loses its link, a folder behind a link is refused.

Definition at line 1130 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onEdit

void MainWindow::onEdit ( )
privateslot

Toolbar "Edit" or a double-click: editPassword() on the current entry.

Definition at line 1205 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onGrepFinished

void MainWindow::onGrepFinished ( const QList< QPair< QString, QStringList > > & results)
slot

Handle results from a completed grep search.

Parameters
resultsList of file/match pairs from the grep operation.

Definition at line 923 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onOperationError

void MainWindow::onOperationError ( )
slot

An operation ended in an error before or instead of a result: forget the pending requests and what the panel was about to show.

Connected to Pass::processErrorExit. A Show that never ran (a linked entry refused at the store boundary) leaves the previous entry's fields on the panel under the new name otherwise, and onOtp()'s fast path would take that entry's code for the refused one.

Definition at line 1161 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onOtp

void MainWindow::onOtp ( )
privateslot

Toolbar "OTP": copy the current entry's one-time code. Uses the code the panel already shows for this entry; otherwise decrypts once and lets otpFromFileToClipboard() finish.

Definition at line 1171 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onProcessOutput

void MainWindow::onProcessOutput ( const QString & output,
bool isError,
Enums::PROCESS pid = Enums::INVALID )
slot

Handle generic process output for display in output panel.

Parameters
outputProcess output text.
isErrortrue if output should be styled as error (red).
pidIdentifier of the originating subprocess (for the label prefix); defaults to Enums::INVALID for unlabelled output.

Definition at line 1853 of file mainwindow.cpp.

Here is the call graph for this function:

◆ onPush

void MainWindow::onPush ( )
slot

Trigger a git push operation.

Definition at line 548 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onTimeoutSearch

void MainWindow::onTimeoutSearch ( )
privateslot

searchTimer fired: filter the tree on the typed words (matched literally, in order, case-insensitively) and select the first match; an empty query collapses the tree and deselects.

Definition at line 834 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onUpdate

void MainWindow::onUpdate ( bool block = false)
privateslot

Toolbar "Update": git pull.

Parameters
blocktrue to pull synchronously (before opening an edit dialog with auto-pull on).

Definition at line 539 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onUsers

void MainWindow::onUsers ( )
privateslot

Toolbar/context-menu "Users": open UsersDialog for the current folder, unless it lies behind a link.

Definition at line 1210 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openFolder

void MainWindow::openFolder ( )
privateslot

Context menu "Open folder with file manager" on the current folder.

Definition at line 1509 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ otpFromFileToClipboard

void MainWindow::otpFromFileToClipboard ( const QString & output,
const QString & file )
slot

Generate a one-time password from decrypted content and copy it. Ignores decrypts of anything but the entry onOtp() asked for.

Parameters
outputDecrypted entry content.
fileEntry the content belongs to.

Definition at line 669 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ passShowHandler

void MainWindow::passShowHandler ( const QString & output,
const QString & file = QString() )
slot

Render a decrypted entry: fields into the display panel, the rest into the text browser, and the password onto the clipboard when "Always copy" is set. Decrypts of any entry but the one the panel last asked to show (m_shownFile) are dropped.

Parameters
outputDecrypted password file content.
fileEntry the content belongs to; empty for legacy callers that do not name it, which always repaints.

Definition at line 605 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ passwordFromFileToClipboard

void MainWindow::passwordFromFileToClipboard ( const QString & text,
const QString & file )
slot

Copy the first line of a decrypted entry (Ctrl+C). Ignores decrypts of anything but the entry copyPasswordFromTreeview() asked for; an otpauth:// first line is refused.

Parameters
textDecrypted entry content.
fileEntry the content belongs to.

Definition at line 1629 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptPath()

void MainWindow::reencryptPath ( const QString & dir)
private

Share menu "Re-encrypt all passwords": confirm, lock the UI via startReencryptPath() and have ImitatePass rewrite every entry under dir for the recipients in its .gpg-id.

Parameters
dirAbsolute folder; refused when missing or behind a link.

Definition at line 1652 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reencryptProgress

void MainWindow::reencryptProgress ( int current,
int total )
slot

Update the re-encryption progress dialog.

Parameters
currentFiles checked so far.
totalFiles found under the re-encrypted folder.

Definition at line 1710 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ refuseLinkedFolder()

auto MainWindow::refuseLinkedFolder ( const QString & dir) -> bool
private

Refuse, with a message, a tree-picked folder that is or lies behind a symlink or junction: what it points to is not part of the store. The store root itself may be a link.

Parameters
dirAbsolute folder path.
Returns
true when the folder was refused and the caller must stop.

Definition at line 1779 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renameFolder

void MainWindow::renameFolder ( )
privateslot

Context menu "Rename folder": ask for a new name and Move the current folder, refusing a target outside the store.

Definition at line 1559 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renamePassword

void MainWindow::renamePassword ( )
privateslot

Context menu "Rename password": ask for a new name and Move the current entry within its folder, refusing a target outside the store.

Definition at line 1593 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restoreWindow()

void MainWindow::restoreWindow ( )

Restore window geometry and state from saved settings.

Definition at line 775 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveWindowState()

void MainWindow::saveWindowState ( )
private

Store geometry and dock/toolbar state in the settings; idempotent, called from closeEvent() and the destructor.

Definition at line 289 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectFirstFile()

void MainWindow::selectFirstFile ( )
private

Make the first entry (depth first) under the store root current.

Definition at line 1013 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPassword()

void MainWindow::setPassword ( const QString & file,
bool isNew = true )
private

Run PasswordDialog for a new or existing entry. For a new one the dialog gets the store's real folders (current one preselected) and the .templates, if any.

Parameters
fileStore-relative entry name; empty when creating.
isNewtrue to create, false to edit file.

Definition at line 1047 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUiElementsEnabled()

void MainWindow::setUiElementsEnabled ( bool state)

Enable or disable the main UI elements.

Parameters
statetrue to enable, false to disable.

Definition at line 742 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showAbout

void MainWindow::showAbout ( )
privateslot

Show the About box: version, project link, licence.

Definition at line 800 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ showBrowserContextMenu

void MainWindow::showBrowserContextMenu ( const QPoint & pos)
privateslot

Show the text browser's standard context menu, reparented to the window so the browser's stylesheet does not bleed into it.

Parameters
posViewport position of the right-click.

Definition at line 1498 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ showContextMenu

void MainWindow::showContextMenu ( const QPoint & pos)
privateslot

Build and show the tree's context menu for the item under the cursor: folder actions (open, add, users, rename, Share) or entry actions (edit, rename), plus Delete.

Parameters
posViewport position of the right-click.

Definition at line 1451 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showEvent()

void MainWindow::showEvent ( QShowEvent * event)
overrideprotected

First-show hook used to focus the search input once the window is actually mapped (avoids races with timers fired before show).

Parameters
eventThe show event.

Definition at line 340 of file mainwindow.cpp.

Here is the call graph for this function:

◆ showShareHelp()

void MainWindow::showShareHelp ( )
private

Share menu "What is this?": the explanation of sharing with GPG.

Definition at line 1791 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ showStatusMessage

void MainWindow::showStatusMessage ( const QString & msg,
int timeout = 2000 )
slot

Show a message in the status bar for the given duration.

Parameters
msgMessage to display.
timeoutDuration in milliseconds (default 2000).

Definition at line 1648 of file mainwindow.cpp.

Here is the caller graph for this function:

◆ startReencryptPath

void MainWindow::startReencryptPath ( )
slot

Begin a re-encryption pass on the current path.

Disables the UI, shows a cancellable progress dialog and keeps both in place until endReencryptPath(): while the worker runs, unrelated completions must not re-enable the interface (see setUiElementsEnabled).

Definition at line 1686 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGitButtonVisibility()

void MainWindow::updateGitButtonVisibility ( bool uiEnabled = true)
private

Show Push and Pull only when Git is in use; enable them only while the interface is.

Parameters
uiEnabledfalse while an operation runs

Definition at line 1808 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGrepButtonVisibility()

void MainWindow::updateGrepButtonVisibility ( )
private

Show the content-search buttons only when the setting is on; turning it off while in content-search mode leaves that mode.

Definition at line 1834 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateOtpButtonVisibility()

void MainWindow::updateOtpButtonVisibility ( bool uiEnabled = true)
private

Refresh the OTP toolbar action from settings.

Parameters
uiEnabledfalse while a backend operation is in flight, so the action is disabled along with the rest of the UI.

Definition at line 1825 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateProcessOutputVisibility()

void MainWindow::updateProcessOutputVisibility ( )
private

Sync the Process Output dock and its menu toggle with the setting after the configuration dialog.

Definition at line 1862 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateProfileBox

void MainWindow::updateProfileBox ( )
privateslot

Fill the profile box from the settings, the active profile selected, without switching profiles while doing so.

Definition at line 1234 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateProfileBoxEnabled

void MainWindow::updateProfileBoxEnabled ( )
privateslot

Enable the profile box only when there is more than one profile, the interface is enabled and the backend is idle.

Definition at line 1269 of file mainwindow.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ clearPanelTimer

QTimer MainWindow::clearPanelTimer
private

Single-shot timer that runs clearPanel() "Autoclear panel" seconds after an entry was shown.

Definition at line 523 of file mainwindow.h.

◆ m_copyRequestFile

QString MainWindow::m_copyRequestFile
private

Entry the in-flight Ctrl+C request asked for; empty when none. Each finishedShow is matched to it by file, so a second Ctrl+C on another entry just replaces the request instead of racing it.

Definition at line 511 of file mainwindow.h.

◆ m_displayPanel

PasswordDisplayPanel* MainWindow::m_displayPanel = nullptr
private

Renders decrypted fields into the grid; created in initDisplayPanel(), parented to this window.

Definition at line 488 of file mainwindow.h.

◆ m_firstShowCompleted

bool MainWindow::m_firstShowCompleted = false
private

Set once focusInput() has actually focused the search box, so later show events leave the focus alone.

Definition at line 493 of file mainwindow.h.

◆ m_freshStart

bool MainWindow::m_freshStart = true
private

No usable configuration has been accepted yet: config() runs the first-run wizard and defaults to pass when it is installed.

Definition at line 553 of file mainwindow.h.

◆ m_grep

GrepSearchController MainWindow::m_grep
private

Mode/busy/cancelled state of the content search.

Definition at line 483 of file mainwindow.h.

◆ m_initSucceeded

bool MainWindow::m_initSucceeded = false
private

Whether the constructor ended with a usable configuration; main() consults it via initSucceeded() to decide whether the application should start at all.

Definition at line 550 of file mainwindow.h.

◆ m_otpRequestFile

QString MainWindow::m_otpRequestFile
private

Entry the in-flight OTP request asked for; empty when none. finishedShow names its file, so otpFromFileToClipboard() simply ignores everything else and passShowHandler() skips the password copy for this one.

Definition at line 507 of file mainwindow.h.

◆ m_processOutput

ProcessOutputPanel* MainWindow::m_processOutput = nullptr
private

The process output console, a QDockWidget at the bottom dock area created in initProcessOutput(). It isn't part of the .ui because uic places its QMainWindow children in centralWidget / statusBar / menuBar / toolBars / dock-widget slots only — a sibling widget at the QMainWindow level isn't laid out and ends up obscuring the centralWidget. See #1192 for the symptom.

Definition at line 518 of file mainwindow.h.

◆ m_qtPass

QtPass* MainWindow::m_qtPass
private

The UI-neutral glue to the backends (output, status, clipboard, QR codes); created in the constructor, deleted in the destructor.

Definition at line 479 of file mainwindow.h.

◆ m_reencryptProgress

QPointer<QProgressDialog> MainWindow::m_reencryptProgress
private

Progress/cancel dialog shown between startReencryptPath() and endReencryptPath(); QPointer so a closed dialog reads back as null.

Definition at line 534 of file mainwindow.h.

◆ m_reencryptRunning

bool MainWindow::m_reencryptRunning = false
private

True between startReencryptPath() and endReencryptPath(). While set, setUiElementsEnabled(true) is ignored so the git completions queued by Init/Move/Copy (or the UI watchdog) cannot re-enable the interface while the re-encryption worker is still rewriting files.

Definition at line 539 of file mainwindow.h.

◆ m_shownFile

QString MainWindow::m_shownFile
private

Entry the display panel is currently rendering. The tree's currentIndex can move without a repaint (arrow keys and right-click do not emit QTreeView::clicked), so onOtp() must not assume the visible code belongs to the selected entry.

Definition at line 503 of file mainwindow.h.

◆ m_themeSwitched

bool MainWindow::m_themeSwitched = false
private

Whether the application palette changed in this window's lifetime. A header palette a style stamps on the bars is only suspect after that: at startup the style's colours are fresh, however far from the window colour a scheme puts its header.

Definition at line 498 of file mainwindow.h.

◆ m_tray

TrayIcon* MainWindow::m_tray {}
private

The system tray icon; null until initTrayIcon() creates it when the setting is on, deleted again by destroyTrayIcon() when it is turned off or no tray is available.

Definition at line 546 of file mainwindow.h.

◆ m_tree

StoreTree* MainWindow::m_tree = nullptr
private

The store as shown in the tree: models, view setup, path mapping.

Definition at line 520 of file mainwindow.h.

◆ m_uiEnabled

bool MainWindow::m_uiEnabled = true
private

What setUiElementsEnabled() last set: updateProfileBox() keeps the profile box disabled while an operation runs.

Definition at line 542 of file mainwindow.h.

◆ m_uiWatchdog

QTimer MainWindow::m_uiWatchdog
private

Re-enables the UI if a backend operation disables it but never reports completion (see setUiElementsEnabled); armed whenever the UI is disabled, stopped when it is enabled again.

Definition at line 529 of file mainwindow.h.

◆ searchTimer

QTimer MainWindow::searchTimer
private

searchTimer: single-shot 350 ms debounce between typing in the search box and onTimeoutSearch().

Definition at line 523 of file mainwindow.h.

◆ ui

QScopedPointer<Ui::MainWindow> MainWindow::ui
private

The widgets generated from mainwindow.ui.

Definition at line 481 of file mainwindow.h.

◆ UiWatchdogMs

int MainWindow::UiWatchdogMs = 30000
staticconstexprprivate

Interval of m_uiWatchdog in milliseconds.

Definition at line 531 of file mainwindow.h.


The documentation for this class was generated from the following files: