mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
SQLStudio: Reset status bar and menu actions when closing a tab
This commit is contained in:
parent
abc150085f
commit
355911c44e
Notes:
sideshowbarker
2024-07-17 07:51:17 +09:00
Author: https://github.com/JsFlo Commit: https://github.com/SerenityOS/serenity/commit/355911c44e Pull-request: https://github.com/SerenityOS/serenity/pull/14865
1 changed files with 18 additions and 4 deletions
|
@ -183,6 +183,7 @@ MainWidget::MainWidget()
|
|||
if (close_attempt.release_value()) {
|
||||
m_tab_widget->remove_tab(widget);
|
||||
update_title();
|
||||
on_editor_change();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -351,14 +352,18 @@ void MainWidget::update_title()
|
|||
void MainWidget::on_editor_change()
|
||||
{
|
||||
auto editor = dynamic_cast<ScriptEditor*>(m_tab_widget->active_widget());
|
||||
if (editor) {
|
||||
update_statusbar(editor);
|
||||
update_editor_actions(editor);
|
||||
}
|
||||
update_statusbar(editor);
|
||||
update_editor_actions(editor);
|
||||
}
|
||||
|
||||
void MainWidget::update_statusbar(ScriptEditor* editor)
|
||||
{
|
||||
if (!editor) {
|
||||
m_statusbar->set_text(1, "");
|
||||
m_statusbar->set_text(2, "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor->has_selection()) {
|
||||
auto character_count = editor->selected_text().length();
|
||||
auto word_count = editor->number_of_selected_words();
|
||||
|
@ -374,6 +379,15 @@ void MainWidget::update_statusbar(ScriptEditor* editor)
|
|||
|
||||
void MainWidget::update_editor_actions(ScriptEditor* editor)
|
||||
{
|
||||
if (!editor) {
|
||||
m_copy_action->set_enabled(false);
|
||||
m_cut_action->set_enabled(false);
|
||||
m_paste_action->set_enabled(false);
|
||||
m_undo_action->set_enabled(false);
|
||||
m_redo_action->set_enabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_copy_action->set_enabled(editor->copy_action().is_enabled());
|
||||
m_cut_action->set_enabled(editor->cut_action().is_enabled());
|
||||
m_paste_action->set_enabled(editor->paste_action().is_enabled());
|
||||
|
|
Loading…
Reference in a new issue