aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-06-29 16:19:59 +0000
committersaturneric <[email protected]>2025-06-29 16:19:59 +0000
commit5ca4a5455ab78f827d75ff51137f5f15f309ad9f (patch)
treeb657d6bc73a3a52231c460c863589272090a7c60 /src/ui/widgets
parentchore: update qt6 version to 6.8.3 in release workflow (diff)
downloadgpgfrontend-5ca4a5455ab78f827d75ff51137f5f15f309ad9f.tar.gz
gpgfrontend-5ca4a5455ab78f827d75ff51137f5f15f309ad9f.zip
fix: simplify tab closing logic in TextEdit
- remove redundant focus setting after tab removal - consolidate tab index selection logic - ensure proper tab cleanup with deleteLater() - remove commented-out empty tab handling code
Diffstat (limited to 'src/ui/widgets')
-rw-r--r--src/ui/widgets/TextEdit.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index c70b1a83..f5941c8e 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -273,12 +273,7 @@ auto TextEdit::SlotSaveAsEML() -> bool {
return saveEMLFile(QFileDialog::getSaveFileName(this, tr("Save file"), path));
}
-void TextEdit::SlotCloseTab() {
- slot_remove_tab(tab_widget_->currentIndex());
- if (tab_widget_->count() != 0) {
- CurPageTextEdit()->GetTextPage()->setFocus();
- }
-}
+void TextEdit::SlotCloseTab() { slot_remove_tab(tab_widget_->currentIndex()); }
void TextEdit::slot_remove_tab(int index) {
// Do nothing, if no tab is opened
@@ -296,19 +291,16 @@ void TextEdit::slot_remove_tab(int index) {
auto* tab = tab_widget_->widget(index);
tab_widget_->removeTab(index);
- // close tab
- if (tab != nullptr) tab->close();
+ // if the tab was the last one, set the current index to the last tab
+ tab_widget_->setCurrentIndex(index >= last_index ? last_index
+ : last_index - 1);
- if (index >= last_index) {
- tab_widget_->setCurrentIndex(last_index);
- } else {
- tab_widget_->setCurrentIndex(last_index - 1);
+ // close and destroy tab
+ if (tab != nullptr) {
+ tab->close();
+ tab->deleteLater();
}
}
-
- if (tab_widget_->count() == 0) {
- // enableAction(false);
- }
}
/**