aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-05 12:55:15 +0000
committersaturneric <[email protected]>2024-01-05 12:55:15 +0000
commit644aa4397b03dbef73f8bfedc13925b51cad836b (patch)
tree7788d1cd2f0687dd8e576b111d9990c580092e7a /src/ui/widgets
parentfix: slove some known issues (diff)
downloadGpgFrontend-644aa4397b03dbef73f8bfedc13925b51cad836b.tar.gz
GpgFrontend-644aa4397b03dbef73f8bfedc13925b51cad836b.zip
feat: integrate logging api to core
Diffstat (limited to 'src/ui/widgets')
-rw-r--r--src/ui/widgets/FilePage.cpp2
-rw-r--r--src/ui/widgets/FileTreeView.cpp21
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp4
-rw-r--r--src/ui/widgets/KeyList.cpp20
-rw-r--r--src/ui/widgets/PlainTextEditorPage.cpp4
-rw-r--r--src/ui/widgets/TextEdit.cpp18
6 files changed, 35 insertions, 34 deletions
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index 8823eb96..71961c25 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -167,7 +167,7 @@ void FilePage::SlotGoPath() {
}
void FilePage::keyPressEvent(QKeyEvent* event) {
- SPDLOG_DEBUG("file page notices key press by user: {}", event->key());
+ GF_UI_LOG_DEBUG("file page notices key press by user: {}", event->key());
if (ui_->pathEdit->hasFocus() &&
(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) {
SlotGoPath();
diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp
index 9fc8aec4..79db51ac 100644
--- a/src/ui/widgets/FileTreeView.cpp
+++ b/src/ui/widgets/FileTreeView.cpp
@@ -58,8 +58,8 @@ void FileTreeView::selectionChanged(const QItemSelection& selected,
if (!selected.indexes().empty()) {
selected_path_ = dir_model_->fileInfo(selected.indexes().first())
.filesystemAbsoluteFilePath();
- SPDLOG_DEBUG("file tree view selected target path: {}",
- selected_path_.u8string());
+ GF_UI_LOG_DEBUG("file tree view selected target path: {}",
+ selected_path_.u8string());
emit SignalSelectedChanged(QString::fromStdString(selected_path_));
} else {
selected_path_ = std::filesystem::path{};
@@ -70,8 +70,8 @@ void FileTreeView::SlotGoPath(const std::filesystem::path& target_path) {
auto file_info = QFileInfo(target_path);
if (file_info.isDir() && file_info.isReadable() && file_info.isExecutable()) {
current_path_ = file_info.filesystemAbsoluteFilePath();
- SPDLOG_DEBUG("file tree view set target path: {}",
- current_path_.u8string());
+ GF_UI_LOG_DEBUG("file tree view set target path: {}",
+ current_path_.u8string());
this->setRootIndex(dir_model_->index(file_info.filePath()));
dir_model_->setRootPath(file_info.filePath());
for (int i = 1; i < dir_model_->columnCount(); ++i) {
@@ -107,7 +107,8 @@ void FileTreeView::SlotUpLevel() {
dir_model_->fileInfo(current_root).filesystemAbsoluteFilePath();
if (target_path.has_parent_path() && !target_path.parent_path().empty()) {
target_path = target_path.parent_path();
- SPDLOG_DEBUG("file tree view go parent path: {}", target_path.u8string());
+ GF_UI_LOG_DEBUG("file tree view go parent path: {}",
+ target_path.u8string());
this->SlotGoPath(target_path);
}
current_path_ = target_path;
@@ -140,7 +141,7 @@ auto FileTreeView::GetPathByClickPoint(const QPoint& point)
}
auto index_path = dir_model_->fileInfo(index).filesystemAbsoluteFilePath();
- SPDLOG_DEBUG("file tree view right click on: {}", index_path.string());
+ GF_UI_LOG_DEBUG("file tree view right click on: {}", index_path.string());
return index_path;
}
@@ -158,7 +159,7 @@ auto FileTreeView::SlotDeleteSelectedItem() -> void {
if (ret == QMessageBox::Cancel) return;
- SPDLOG_DEBUG("delete item: {}", data.toString().toStdString());
+ GF_UI_LOG_DEBUG("delete item: {}", data.toString().toStdString());
if (!dir_model_->remove(index)) {
QMessageBox::critical(this, _("Error"),
@@ -278,14 +279,14 @@ void FileTreeView::SlotRenameSelectedItem() {
#else
auto new_name_path = selected_path_.parent_path() / text.toStdString();
#endif
- SPDLOG_DEBUG("new name path: {}", new_name_path.u8string());
+ GF_UI_LOG_DEBUG("new name path: {}", new_name_path.u8string());
std::filesystem::rename(selected_path_, new_name_path);
// refresh
SlotGoPath(current_path_);
} catch (...) {
- SPDLOG_ERROR("file tree view rename error: {}",
- selected_path_.u8string());
+ GF_UI_LOG_ERROR("file tree view rename error: {}",
+ selected_path_.u8string());
QMessageBox::critical(this, _("Error"),
_("Unable to rename the file or folder."));
}
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index c3369ff8..b2ac0119 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -116,7 +116,7 @@ void InfoBoardWidget::AssociateTabWidget(QTabWidget* tab) {
void InfoBoardWidget::AddOptionalAction(const QString& name,
const std::function<void()>& action) {
- SPDLOG_DEBUG("add option: {}", name.toStdString());
+ GF_UI_LOG_DEBUG("add option: {}", name.toStdString());
auto actionButton = new QPushButton(name);
auto layout = new QHBoxLayout();
layout->setContentsMargins(5, 0, 5, 0);
@@ -165,7 +165,7 @@ void InfoBoardWidget::slot_copy() {
void InfoBoardWidget::slot_save() {
auto file_path = QFileDialog::getSaveFileName(
this, _("Save Information Board's Content"), {}, tr("Text (*.txt)"));
- SPDLOG_DEBUG("file path: {}", file_path.toStdString());
+ GF_UI_LOG_DEBUG("file path: {}", file_path.toStdString());
if (file_path.isEmpty()) return;
QFile file(file_path);
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 0e4bba5e..04c184b0 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -116,7 +116,7 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id,
KeyListRow::KeyType selectType,
KeyListColumn::InfoType infoType,
const KeyTable::KeyTableFilter filter) {
- SPDLOG_DEBUG("add tab: {}", name.toStdString());
+ GF_UI_LOG_DEBUG("add tab: {}", name.toStdString());
auto key_list = new QTableWidget(this);
if (m_key_list_ == nullptr) {
@@ -176,7 +176,7 @@ void KeyList::AddListGroupTab(const QString& name, const QString& id,
}
void KeyList::SlotRefresh() {
- SPDLOG_DEBUG("refresh, address: {}", static_cast<void*>(this));
+ GF_UI_LOG_DEBUG("refresh, address: {}", static_cast<void*>(this));
ui_->refreshKeyListButton->setDisabled(true);
ui_->syncButton->setDisabled(true);
@@ -187,7 +187,7 @@ void KeyList::SlotRefresh() {
}
void KeyList::SlotRefreshUI() {
- SPDLOG_DEBUG("refresh, address: {}", static_cast<void*>(this));
+ GF_UI_LOG_DEBUG("refresh, address: {}", static_cast<void*>(this));
this->slot_refresh_ui();
}
@@ -315,8 +315,8 @@ void KeyList::contextMenuEvent(QContextMenuEvent* event) {
QString current_tab_widget_obj_name =
ui_->keyGroupTab->widget(ui_->keyGroupTab->currentIndex())->objectName();
- SPDLOG_DEBUG("current tab widget object name: {}",
- current_tab_widget_obj_name.toStdString());
+ GF_UI_LOG_DEBUG("current tab widget object name: {}",
+ current_tab_widget_obj_name.toStdString());
if (current_tab_widget_obj_name == "favourite") {
QList<QAction*> actions = popup_menu_->actions();
for (QAction* action : actions) {
@@ -401,7 +401,7 @@ void KeyList::dropEvent(QDropEvent* event) {
QFile file;
file.setFileName(tmp.toLocalFile());
if (!file.open(QIODevice::ReadOnly)) {
- SPDLOG_ERROR("couldn't open file: {}", tmp.toString().toStdString());
+ GF_UI_LOG_ERROR("couldn't open file: {}", tmp.toString().toStdString());
}
QByteArray inBuffer = file.readAll();
this->import_keys(inBuffer);
@@ -463,7 +463,7 @@ std::string KeyList::GetSelectedKey() {
}
void KeyList::slot_refresh_ui() {
- SPDLOG_DEBUG("refresh: {}", static_cast<void*>(buffered_keys_list_.get()));
+ GF_UI_LOG_DEBUG("refresh: {}", static_cast<void*>(buffered_keys_list_.get()));
if (buffered_keys_list_ != nullptr) {
std::lock_guard<std::mutex> guard(buffered_key_list_mutex_);
@@ -496,8 +496,8 @@ void KeyList::slot_sync_with_key_server() {
CommonUtils::SlotImportKeyFromKeyServer(
key_ids, [=](const std::string& key_id, const std::string& status,
size_t current_index, size_t all_index) {
- SPDLOG_DEBUG("import key: {} {} {} {}", key_id, status, current_index,
- all_index);
+ GF_UI_LOG_DEBUG("import key: {} {} {} {}", key_id, status,
+ current_index, all_index);
auto key = GpgKeyGetter::GetInstance().GetKey(key_id);
boost::format status_str = boost::format(_("Sync [%1%/%2%] %3% %4%")) %
@@ -518,7 +518,7 @@ void KeyList::filter_by_keyword() {
auto keyword = ui_->searchBarEdit->text();
keyword = keyword.trimmed();
- SPDLOG_DEBUG("get new keyword of search bar: {}", keyword.toStdString());
+ GF_UI_LOG_DEBUG("get new keyword of search bar: {}", keyword.toStdString());
for (auto& table : m_key_tables_) {
// refresh arguments
table.SetFilterKeyword(keyword.toLower().toStdString());
diff --git a/src/ui/widgets/PlainTextEditorPage.cpp b/src/ui/widgets/PlainTextEditorPage.cpp
index 2037689e..d5094dd3 100644
--- a/src/ui/widgets/PlainTextEditorPage.cpp
+++ b/src/ui/widgets/PlainTextEditorPage.cpp
@@ -182,7 +182,7 @@ void PlainTextEditorPage::ReadFile() {
&FileReadTask::SignalFileBytesReadNext, Qt::QueuedConnection);
connect(read_task, &FileReadTask::SignalTaskShouldEnd, this,
- []() { SPDLOG_DEBUG("read thread closed"); });
+ []() { GF_UI_LOG_DEBUG("read thread closed"); });
connect(this, &PlainTextEditorPage::close, read_task,
[=]() { read_task->SignalTaskShouldEnd(0); });
connect(read_task, &FileReadTask::SignalFileBytesReadEnd, this, [=]() {
@@ -210,7 +210,7 @@ auto BinaryToString(const std::string &source) -> std::string {
void PlainTextEditorPage::slot_insert_text(QByteArray bytes_data) {
std::string data = bytes_data.toStdString();
- SPDLOG_TRACE("inserting data read to editor, data size: {}", data.size());
+ GF_UI_LOG_TRACE("inserting data read to editor, data size: {}", data.size());
read_bytes_ += data.size();
// If binary format is detected, the entire file is converted to binary
// format for display.
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index 5ec44230..079a8496 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -118,8 +118,8 @@ void TextEdit::SlotNewFileTab() const {
void TextEdit::SlotOpenFile(const QString& path) {
QFile file(path);
- SPDLOG_DEBUG("main window editor is opening file at path: {}",
- path.toStdString());
+ GF_UI_LOG_DEBUG("main window editor is opening file at path: {}",
+ path.toStdString());
auto result = file.open(QIODevice::ReadOnly | QIODevice::Text);
if (result) {
auto* page = new PlainTextEditorPage(path);
@@ -541,7 +541,7 @@ QHash<int, QString> TextEdit::UnsavedDocuments() const {
if (ep != nullptr && ep->ReadDone() &&
ep->GetTextPage()->document()->isModified()) {
QString doc_name = tab_widget_->tabText(i);
- SPDLOG_DEBUG("unsaved: {}", doc_name.toStdString());
+ GF_UI_LOG_DEBUG("unsaved: {}", doc_name.toStdString());
// remove * before name of modified doc
doc_name.remove(0, 2);
@@ -642,16 +642,16 @@ void TextEdit::slot_save_status_to_cache_for_revovery() {
restore_text_editor_page =
settings.lookup("general.restore_text_editor_page");
} catch (...) {
- SPDLOG_ERROR("setting operation error: restore_text_editor_page");
+ GF_UI_LOG_ERROR("setting operation error: restore_text_editor_page");
}
if (!restore_text_editor_page) {
- SPDLOG_DEBUG("restore_text_editor_page is false, ignoring...");
+ GF_UI_LOG_DEBUG("restore_text_editor_page is false, ignoring...");
return;
}
int tab_count = tab_widget_->count();
- SPDLOG_DEBUG(
+ GF_UI_LOG_DEBUG(
"restore_text_editor_page is true, pan to save pages, current tabs "
"count: "
"{}",
@@ -676,8 +676,8 @@ void TextEdit::slot_save_status_to_cache_for_revovery() {
}
auto raw_text = document->toRawText().toStdString();
- SPDLOG_DEBUG("unsaved page index: {}, tab title: {} tab content: {}", i,
- tab_title, raw_text.size());
+ GF_UI_LOG_DEBUG("unsaved page index: {}, tab title: {} tab content: {}", i,
+ tab_title, raw_text.size());
unsaved_pages.push_back({i, tab_title, raw_text});
}
@@ -691,7 +691,7 @@ void TextEdit::slot_save_status_to_cache_for_revovery() {
unsaved_page_array.push_back(page_json);
}
- SPDLOG_DEBUG("unsaved page json array: {}", unsaved_page_array.dump());
+ GF_UI_LOG_DEBUG("unsaved page json array: {}", unsaved_page_array.dump());
CacheManager::GetInstance().SaveCache("editor_unsaved_pages",
unsaved_page_array);
}