aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
- }
}
/**