Skip to content

Commit 2fc92fd

Browse files
committed
docs(ui): clarify file browser page behavior
* Expand API docs to explain responsibilities, signals, and path-handling behavior for the file browser page * Add clearer parameter/return descriptions to improve maintainability * Remove an unnecessary path-completer activation handler to rely on default completion behavior
1 parent 75ddc9c commit 2fc92fd

2 files changed

Lines changed: 106 additions & 79 deletions

File tree

src/ui/widgets/FilePage.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
163163
connect(ui_->pathEdit, &QLineEdit::textEdited, this,
164164
[this](const QString& text) { update_path_completion(text); });
165165

166-
connect(path_edit_completer_,
167-
QOverload<const QString&>::of(&QCompleter::activated), this,
168-
[this](const QString& path) {
169-
ui_->pathEdit->setText(path);
170-
ui_->pathEdit->setCursorPosition(path.size());
171-
});
172-
173166
connect(ui_->pathEdit, &QLineEdit::returnPressed, this,
174167
&FilePage::SlotGoPath);
175168

src/ui/widgets/FilePage.h

Lines changed: 106 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
/**
2-
* Copyright (C) 2021-2024 Saturneric <eric@bktus.com>
3-
*
4-
* This file is part of GpgFrontend.
5-
*
6-
* GpgFrontend is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* GpgFrontend is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
18-
*
19-
* The initial version of the source code is inherited from
20-
* the gpg4usb project, which is under GPL-3.0-or-later.
21-
*
22-
* All the source code of GpgFrontend was modified and released by
23-
* Saturneric <eric@bktus.com> starting on May 12, 2021.
24-
*
25-
* SPDX-License-Identifier: GPL-3.0-or-later
26-
*
27-
*/
28-
291
#pragma once
302

313
#include "ui/widgets/InfoBoardWidget.h"
@@ -35,135 +7,197 @@ class Ui_FilePage;
357
namespace GpgFrontend::UI {
368

379
/**
38-
* @brief
10+
* @brief File browser page used by the main window.
11+
*
12+
* FilePage provides a file-system based operation page for GpgFrontend. It
13+
* wraps a FileTreeView together with a path editor, mounted-volume selector,
14+
* view options and batch-selection controls.
15+
*
16+
* The widget is responsible for:
3917
*
18+
* - displaying and changing the current directory;
19+
* - supporting user-entered paths, including "~" and relative paths;
20+
* - offering path completion for readable directories;
21+
* - tracking selected files and directories;
22+
* - updating the main window operation menu according to the current selection;
23+
* - exposing file-operation options such as batch mode and ASCII armor mode;
24+
* - maintaining the mounted-volume popup menu.
25+
*
26+
* The actual file operation execution is not performed by this widget. Instead,
27+
* FilePage emits signals and updates the main-window operation state according
28+
* to the selected paths.
4029
*/
4130
class FilePage : public QWidget {
4231
Q_OBJECT
32+
4333
public:
4434
/**
45-
* @brief Construct a new File Page object
35+
* @brief Constructs a file browser page.
4636
*
47-
* @param parent
37+
* @param parent Parent widget.
38+
* @param target_path Initial directory path shown by the file tree view.
4839
*/
49-
explicit FilePage(QWidget* parent, const QString&);
40+
explicit FilePage(QWidget* parent, const QString& target_path);
5041

5142
/**
52-
* @brief Get the Selected object
43+
* @brief Returns the currently selected file-system paths.
44+
*
45+
* In normal mode this usually contains at most one path. In batch mode it may
46+
* contain multiple selected files or directories.
5347
*
54-
* @return QString
48+
* @return List of selected absolute paths.
5549
*/
5650
[[nodiscard]] auto GetSelected() const -> QStringList;
5751

5852
/**
59-
* @brief
53+
* @brief Returns whether batch-selection mode is enabled.
6054
*
61-
* @return true
62-
* @return false
55+
* Batch mode allows the file tree view to select multiple items for one
56+
* operation.
57+
*
58+
* @return true if batch mode is enabled, otherwise false.
6359
*/
6460
[[nodiscard]] auto IsBatchMode() const -> bool;
6561

6662
/**
67-
* @brief
63+
* @brief Returns whether ASCII armored output is enabled for file operations.
64+
*
65+
* When enabled, file encryption/signing operations should prefer ASCII
66+
* armored output where supported.
6867
*
69-
* @return true
70-
* @return false
68+
* @return true if ASCII armor mode is enabled, otherwise false.
7169
*/
7270
[[nodiscard]] auto IsASCIIMode() const -> bool;
7371

7472
/**
75-
* @brief Get the Current Path object
73+
* @brief Returns the current directory shown by the file tree view.
7674
*
77-
* @return QString
75+
* @return Current absolute directory path.
7876
*/
7977
[[nodiscard]] auto GetCurrentPath() const -> QString;
8078

8179
public slots:
8280
/**
83-
* @brief
81+
* @brief Opens the path currently entered in the path editor.
82+
*
83+
* The input path is normalized before use. The method supports home-directory
84+
* shortcuts such as "~" and "~/...", and resolves relative paths against the
85+
* current directory.
8486
*
87+
* If the target path does not exist, is not a directory, or cannot be read,
88+
* the path editor shows an error tooltip and the current directory is kept
89+
* unchanged.
8590
*/
8691
void SlotGoPath();
8792

8893
/**
89-
* @brief
94+
* @brief Refreshes the file page state.
9095
*
96+
* This updates the mounted-volume menu and reloads the current path.
9197
*/
9298
void SlotRefreshState();
9399

94100
signals:
95-
96101
/**
97-
* @brief
102+
* @brief Emitted when the current directory path changes.
98103
*
99-
* @param path
104+
* @param path New current directory path.
100105
*/
101-
void SignalPathChanged(const QString&);
106+
void SignalPathChanged(const QString& path);
102107

103108
/**
104-
* @brief
109+
* @brief Requests the global information board to be refreshed.
105110
*
106-
* @param text
107-
* @param verify_label_status
111+
* @param text Text shown on the information board.
112+
* @param status Display status used by the information board.
108113
*/
109-
void SignalRefreshInfoBoard(const QString&, InfoBoardStatus);
114+
void SignalRefreshInfoBoard(const QString& text, InfoBoardStatus status);
110115

111116
/**
112-
* @brief
117+
* @brief Emitted when the current tab becomes active.
113118
*
119+
* This signal is used to refresh the main-window operation menu based on the
120+
* current file selection.
114121
*/
115122
void SignalCurrentTabChanged();
116123

117124
/**
118-
* @brief
125+
* @brief Requests the main window to update its basic operation menu.
126+
*
127+
* The value is a bit mask of MainWindow::OperationMenu::OperationType values.
128+
* It indicates which operations are currently available for the selected
129+
* paths, for example encryption, decryption, signing or verification.
119130
*
120-
* @param int
131+
* @param operation_type Available operation bit mask.
121132
*/
122-
void SignalMainWindowUpdateBasicOperaMenu(unsigned int);
133+
void SignalMainWindowUpdateBasicOperaMenu(unsigned int operation_type);
123134

124135
private:
125-
QSharedPointer<Ui_FilePage> ui_; ///<
136+
QSharedPointer<Ui_FilePage> ui_; ///< Generated UI object.
137+
138+
QCompleter* path_edit_completer_ = nullptr; ///< Completer for path input.
139+
QStringListModel* path_complete_model_ =
140+
nullptr; ///< Model used by the path completer.
126141

127-
QCompleter* path_edit_completer_ = nullptr;
128-
QStringListModel* path_complete_model_ = nullptr;
142+
QMenu* popup_menu_{}; ///< Reserved popup menu pointer.
143+
QMenu* option_popup_menu_{}; ///< File-view option popup menu.
144+
QMenu* harddisk_popup_menu_{}; ///< Mounted-volume popup menu.
129145

130-
QMenu* popup_menu_{}; ///<
131-
QMenu* option_popup_menu_{}; ///<
132-
QMenu* harddisk_popup_menu_{}; ///<
133-
bool ascii_mode_;
146+
bool ascii_mode_; ///< Whether ASCII armored output is enabled.
134147

135-
QSet<QString> last_volume_keys_; ///<
148+
QSet<QString> last_volume_keys_; ///< Cached mounted-volume keys.
136149

137150
/**
138-
* @brief
151+
* @brief Updates the available main-window file operations.
139152
*
153+
* The selected paths are inspected and converted into an operation bit mask.
154+
* For example:
155+
*
156+
* - regular non-OpenPGP files can be encrypted or signed;
157+
* - OpenPGP message files can be decrypted or verified;
158+
* - detached signature files can be verified;
159+
* - directories can be encrypted where supported.
160+
*
161+
* @param selected_paths Currently selected file-system paths.
140162
*/
141-
void update_main_basic_opera_menu(const QStringList&);
163+
void update_main_basic_opera_menu(const QStringList& selected_paths);
142164

143165
/**
144-
* @brief
166+
* @brief Rebuilds the mounted-volume popup menu.
145167
*
168+
* The menu is updated only when the mounted-volume set has changed. Each menu
169+
* item stores the corresponding root path and navigates the file page to that
170+
* path when triggered.
146171
*/
147172
void update_harddisk_menu();
148173

149174
/**
150-
* @brief
175+
* @brief Periodically refreshes the mounted-volume menu.
151176
*
177+
* This method schedules itself again after a short delay, allowing removable
178+
* drives and other mounted volumes to appear or disappear in the UI.
152179
*/
153180
void update_harddisk_menu_periodic();
154181

155182
/**
156-
* @brief
183+
* @brief Initializes visual style and basic widget behavior.
157184
*
185+
* This configures tool buttons, path editor behavior, popup modes and tree
186+
* view display options.
158187
*/
159188
void init_ui_style();
160189

161190
/**
162-
* @brief
191+
* @brief Updates path-completion candidates for the path editor.
192+
*
193+
* The input is normalized against the current directory. Completion
194+
* candidates are generated from readable subdirectories of the resolved base
195+
* directory. Displayed candidates preserve the user's input style where
196+
* possible, such as "~" paths or relative paths.
163197
*
164-
* @param input
198+
* @param input Current text entered by the user.
165199
*/
166200
void update_path_completion(const QString& input);
167201
};
168202

169-
} // namespace GpgFrontend::UI
203+
} // namespace GpgFrontend::UI

0 commit comments

Comments
 (0)