Skip to content

Commit 75ddc9c

Browse files
committed
refactor(ui): standardize widget method naming
* Renames several UI helper/slot methods to a consistent lowercase style for improved readability and convention alignment * Updates signal/slot hookups and call sites to match the new names * Keeps behavior unchanged while reducing naming inconsistencies across common widgets
1 parent b12ef94 commit 75ddc9c

10 files changed

Lines changed: 87 additions & 84 deletions

File tree

src/ui/widgets/FilePage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
135135
: QWidget(parent),
136136
ui_(GpgFrontend::SecureCreateSharedObject<Ui_FilePage>()) {
137137
ui_->setupUi(this);
138-
InitUIStyle();
138+
init_ui_style();
139139

140140
connect(ui_->upPathButton, &QToolButton::clicked, ui_->treeView,
141141
&FileTreeView::SlotUpLevel);
@@ -161,7 +161,7 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
161161
&FilePage::SlotGoPath);
162162

163163
connect(ui_->pathEdit, &QLineEdit::textEdited, this,
164-
[this](const QString& text) { UpdatePathCompletion(text); });
164+
[this](const QString& text) { update_path_completion(text); });
165165

166166
connect(path_edit_completer_,
167167
QOverload<const QString&>::of(&QCompleter::activated), this,
@@ -255,7 +255,7 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
255255
QTimer::singleShot(200, this, &FilePage::update_harddisk_menu_periodic);
256256
}
257257

258-
void FilePage::InitUIStyle() {
258+
void FilePage::init_ui_style() {
259259
setObjectName(QStringLiteral("FilePage"));
260260

261261
ui_->pathEdit->setClearButtonEnabled(true);
@@ -388,7 +388,7 @@ auto FilePage::IsBatchMode() const -> bool {
388388

389389
auto FilePage::IsASCIIMode() const -> bool { return ascii_mode_; }
390390

391-
void FilePage::UpdatePathCompletion(const QString& input) {
391+
void FilePage::update_path_completion(const QString& input) {
392392
if (input.trimmed().isEmpty()) {
393393
path_complete_model_->setStringList({});
394394
return;

src/ui/widgets/FilePage.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ class FilePage : public QWidget {
4848
*/
4949
explicit FilePage(QWidget* parent, const QString&);
5050

51-
/**
52-
* @brief
53-
*
54-
*/
55-
void InitUIStyle();
56-
5751
/**
5852
* @brief Get the Selected object
5953
*
@@ -77,13 +71,6 @@ class FilePage : public QWidget {
7771
*/
7872
[[nodiscard]] auto IsASCIIMode() const -> bool;
7973

80-
/**
81-
* @brief
82-
*
83-
* @param input
84-
*/
85-
void UpdatePathCompletion(const QString& input);
86-
8774
/**
8875
* @brief Get the Current Path object
8976
*
@@ -147,8 +134,6 @@ class FilePage : public QWidget {
147134

148135
QSet<QString> last_volume_keys_; ///<
149136

150-
private slots:
151-
152137
/**
153138
* @brief
154139
*
@@ -166,6 +151,19 @@ class FilePage : public QWidget {
166151
*
167152
*/
168153
void update_harddisk_menu_periodic();
154+
155+
/**
156+
* @brief
157+
*
158+
*/
159+
void init_ui_style();
160+
161+
/**
162+
* @brief
163+
*
164+
* @param input
165+
*/
166+
void update_path_completion(const QString& input);
169167
};
170168

171169
} // namespace GpgFrontend::UI

src/ui/widgets/FileTreeView.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void FileTreeView::SlotMkdir() {
334334
}
335335

336336
void FileTreeView::SlotMkdirBelowAtSelectedItem() {
337-
const auto target_dir = CurrentTargetDirectoryPath();
337+
const auto target_dir = current_target_directory_path();
338338
if (target_dir.isEmpty()) return;
339339

340340
CreateFileSystemItemDialog dialog(
@@ -374,7 +374,7 @@ void FileTreeView::SlotTouch() {
374374
}
375375

376376
void FileTreeView::SlotTouchBelowAtSelectedItem() {
377-
const auto target_dir = CurrentTargetDirectoryPath();
377+
const auto target_dir = current_target_directory_path();
378378
if (target_dir.isEmpty()) return;
379379

380380
CreateFileSystemItemDialog dialog(CreateFileSystemItemDialog::ItemType::kFILE,
@@ -783,7 +783,7 @@ void FileTreeView::SetPath(const QString& target_path) {
783783
}
784784
}
785785

786-
auto FileTreeView::CurrentTargetDirectoryIndex() const -> QModelIndex {
786+
auto FileTreeView::current_target_directory_index() const -> QModelIndex {
787787
auto index = currentIndex();
788788

789789
if (!index.isValid()) {
@@ -798,7 +798,7 @@ auto FileTreeView::CurrentTargetDirectoryIndex() const -> QModelIndex {
798798
return index.parent().isValid() ? index.parent() : rootIndex();
799799
}
800800

801-
auto FileTreeView::CurrentTargetDirectoryPath() const -> QString {
801+
auto FileTreeView::current_target_directory_path() const -> QString {
802802
auto index = currentIndex();
803803

804804
if (!index.isValid()) {

src/ui/widgets/FileTreeView.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ class FileTreeView : public QTreeView {
7777
*/
7878
auto GetMousePointGlobal(const QPoint& point) -> QPoint;
7979

80-
/**
81-
* @brief
82-
*
83-
* @return QModelIndex
84-
*/
85-
[[nodiscard]] auto CurrentTargetDirectoryIndex() const -> QModelIndex;
86-
87-
/**
88-
* @brief
89-
*
90-
* @return QString
91-
*/
92-
[[nodiscard]] auto CurrentTargetDirectoryPath() const -> QString;
93-
9480
protected:
9581
/**
9682
* @brief
@@ -373,5 +359,19 @@ class FileTreeView : public QTreeView {
373359
*/
374360
auto copy_directory_recursive(const QString& source_dir,
375361
const QString& target_dir) -> bool;
362+
363+
/**
364+
* @brief
365+
*
366+
* @return QModelIndex
367+
*/
368+
[[nodiscard]] auto current_target_directory_index() const -> QModelIndex;
369+
370+
/**
371+
* @brief
372+
*
373+
* @return QString
374+
*/
375+
[[nodiscard]] auto current_target_directory_path() const -> QString;
376376
};
377377
} // namespace GpgFrontend::UI

src/ui/widgets/KeyList.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ KeyList::KeyList(int channel, KeyMenuAbility menu_ability,
9595
init();
9696
}
9797

98-
auto KeyList::HasAbility(KeyMenuAbility ability) const -> bool {
98+
auto KeyList::has_ability(KeyMenuAbility ability) const -> bool {
9999
using T = std::underlying_type_t<KeyMenuAbility>;
100100

101101
return (static_cast<T>(menu_ability_) & static_cast<T>(ability)) !=
@@ -105,15 +105,15 @@ auto KeyList::HasAbility(KeyMenuAbility ability) const -> bool {
105105
void KeyList::init_ui_visibility() {
106106
ui_->menuWidget->setHidden(menu_ability_ == KeyMenuAbility::kNONE);
107107

108-
ui_->refreshKeyListButton->setHidden(!HasAbility(KeyMenuAbility::kREFRESH));
109-
ui_->syncButton->setHidden(!HasAbility(KeyMenuAbility::kSYNC_PUBLIC_KEY));
110-
ui_->checkALLButton->setHidden(!HasAbility(KeyMenuAbility::kCHECK_ALL));
111-
ui_->uncheckButton->setHidden(!HasAbility(KeyMenuAbility::kUNCHECK_ALL));
112-
ui_->columnTypeButton->setHidden(!HasAbility(KeyMenuAbility::kCOLUMN_FILTER));
113-
ui_->searchBarEdit->setHidden(!HasAbility(KeyMenuAbility::kSEARCH_BAR));
108+
ui_->refreshKeyListButton->setHidden(!has_ability(KeyMenuAbility::kREFRESH));
109+
ui_->syncButton->setHidden(!has_ability(KeyMenuAbility::kSYNC_PUBLIC_KEY));
110+
ui_->checkALLButton->setHidden(!has_ability(KeyMenuAbility::kCHECK_ALL));
111+
ui_->uncheckButton->setHidden(!has_ability(KeyMenuAbility::kUNCHECK_ALL));
112+
ui_->columnTypeButton->setHidden(!has_ability(KeyMenuAbility::kCOLUMN_FILTER));
113+
ui_->searchBarEdit->setHidden(!has_ability(KeyMenuAbility::kSEARCH_BAR));
114114
ui_->switchContextButton->setHidden(
115-
!HasAbility(KeyMenuAbility::kKEY_DATABASE));
116-
ui_->keyGroupButton->setHidden(!HasAbility(KeyMenuAbility::kKEY_GROUP));
115+
!has_ability(KeyMenuAbility::kKEY_DATABASE));
116+
ui_->keyGroupButton->setHidden(!has_ability(KeyMenuAbility::kKEY_GROUP));
117117
}
118118

119119
void KeyList::init_ui_style() {

src/ui/widgets/KeyList.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,6 @@ class KeyList : public QWidget {
235235
*/
236236
void RefreshKeyTable(int index);
237237

238-
/**
239-
* @brief
240-
*
241-
* @param ability
242-
* @return true
243-
* @return false
244-
*/
245-
[[nodiscard]] auto HasAbility(KeyMenuAbility ability) const -> bool;
246-
247238
public slots:
248239

249240
/**
@@ -427,6 +418,15 @@ class KeyList : public QWidget {
427418
*
428419
*/
429420
void update_action_state();
421+
422+
/**
423+
* @brief
424+
*
425+
* @param ability
426+
* @return true
427+
* @return false
428+
*/
429+
[[nodiscard]] auto has_ability(KeyMenuAbility ability) const -> bool;
430430
};
431431

432432
} // namespace GpgFrontend::UI

src/ui/widgets/KeyTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer<GpgKeyTableModel> model,
5656
proxy_model_(model_, select_type, column_filter, std::move(filter), this),
5757
column_filter_(column_filter) {
5858
setModel(&proxy_model_);
59-
InitTableStyle();
59+
init_table_style();
6060

6161
connect(CommonUtils::GetInstance(), &CommonUtils::SignalFavoritesChanged,
6262
&proxy_model_, &GpgKeyTableProxyModel::SignalFavoritesChanged);
@@ -87,7 +87,7 @@ KeyTable::KeyTable(QWidget* parent, QSharedPointer<GpgKeyTableModel> model,
8787
});
8888
}
8989

90-
void KeyTable::InitTableStyle() {
90+
void KeyTable::init_table_style() {
9191
setProperty("gfKeyTable", true);
9292

9393
verticalHeader()->hide();

src/ui/widgets/KeyTable.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ struct KeyTable : public QTableView {
5757
GpgKeyTableProxyModel::KeyFilter _filter =
5858
[](const GpgAbstractKey*) -> bool { return true; });
5959

60-
/**
61-
* @brief Construct a new Init Table Style object
62-
*
63-
*/
64-
void InitTableStyle();
65-
6660
/**
6761
* @brief
6862
*
@@ -179,6 +173,12 @@ struct KeyTable : public QTableView {
179173
GpgKeyTableProxyModel proxy_model_;
180174
GpgKeyTableColumn column_filter_;
181175
bool bulk_checking_ = false;
176+
177+
/**
178+
* @brief Construct a new Init Table Style object
179+
*
180+
*/
181+
void init_table_style();
182182
};
183183

184184
} // namespace GpgFrontend::UI

src/ui/widgets/KeyTreeView.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ KeyTreeView::KeyTreeView(int channel,
6161
init();
6262
}
6363

64-
void KeyTreeView::InitViewStyle() {
64+
void KeyTreeView::init_view_style() {
6565
setProperty("gfKeyTreeView", true);
6666

6767
setRootIsDecorated(true);
@@ -148,7 +148,7 @@ auto KeyTreeView::GetAllCheckedSubKey() -> QContainer<GpgSubKey> {
148148
void KeyTreeView::init() {
149149
setModel(&proxy_model_);
150150

151-
InitViewStyle();
151+
init_view_style();
152152

153153
connect(this, &QTreeView::doubleClicked, this,
154154
[this](const QModelIndex& index) {
@@ -163,15 +163,15 @@ void KeyTreeView::init() {
163163

164164
connect(UISignalStation::GetInstance(),
165165
&UISignalStation::SignalKeyDatabaseRefreshDone, this,
166-
&KeyTreeView::ResetModel);
166+
&KeyTreeView::reset_model);
167167

168168
connect(model_.get(), &GpgKeyTreeModel::SignalKeyCheckedChanged, this,
169169
[this](GpgAbstractKey*, bool) {
170170
emit SignalKeysChecked(GetAllCheckedKeys());
171171
});
172172
}
173173

174-
void KeyTreeView::ResetModel() {
174+
void KeyTreeView::reset_model() {
175175
init_ = false;
176176

177177
model_ = SecureCreateSharedObject<GpgKeyTreeModel>(
@@ -203,7 +203,7 @@ void KeyTreeView::SetChannel(int channel) {
203203
LOG_D() << "new channel for key tree view: " << channel;
204204

205205
channel_ = channel;
206-
ResetModel();
206+
reset_model();
207207
}
208208

209209
auto KeyTreeView::GetKeyByIndex(QModelIndex index) -> GpgAbstractKeyPtr {
@@ -221,7 +221,7 @@ auto KeyTreeView::GetKeyByIndex(QModelIndex index) -> GpgAbstractKeyPtr {
221221
return item->SharedKey();
222222
}
223223

224-
void KeyTreeView::Refresh() { ResetModel(); }
224+
void KeyTreeView::Refresh() { reset_model(); }
225225

226226
auto KeyTreeView::GetAllCheckedKeys() -> GpgAbstractKeyPtrList {
227227
return model_->GetAllCheckedKeys();

src/ui/widgets/KeyTreeView.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@ class KeyTreeView : public QTreeView {
6363
GpgKeyTreeProxyModel::KeyFilter filter,
6464
QWidget* parent = nullptr);
6565

66-
/**
67-
* @brief
68-
*
69-
*/
70-
void InitViewStyle();
71-
72-
/**
73-
* @brief
74-
*
75-
*/
76-
void ResetModel();
77-
7866
/**
7967
* @brief Get the Key By Index object
8068
*
@@ -142,20 +130,37 @@ class KeyTreeView : public QTreeView {
142130
private:
143131
bool init_ = false;
144132
int channel_ = kGpgFrontendDefaultChannel;
145-
146133
GpgKeyTreeModel::Detector checkable_detector_ = [](GpgAbstractKey*) -> bool {
147134
return false;
148135
};
149-
150136
GpgKeyTreeProxyModel::KeyFilter key_filter_ =
151137
[](const GpgAbstractKey*) -> bool { return true; };
152-
153138
QSharedPointer<GpgKeyTreeModel> model_;
154139
GpgKeyTreeProxyModel proxy_model_;
155140

141+
/**
142+
* @brief
143+
*
144+
*/
156145
void slot_adjust_column_widths();
157146

147+
/**
148+
* @brief
149+
*
150+
*/
158151
void init();
152+
153+
/**
154+
* @brief
155+
*
156+
*/
157+
void init_view_style();
158+
159+
/**
160+
* @brief
161+
*
162+
*/
163+
void reset_model();
159164
};
160165

161166
} // namespace GpgFrontend::UI

0 commit comments

Comments
 (0)