mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:57:35 +00:00
SQLStudio: Reset status bar and menu actions when closing a tab
This commit is contained in:
parent
abc150085f
commit
355911c44e
1 changed files with 18 additions and 4 deletions
|
@ -183,6 +183,7 @@ MainWidget::MainWidget()
|
||||||
if (close_attempt.release_value()) {
|
if (close_attempt.release_value()) {
|
||||||
m_tab_widget->remove_tab(widget);
|
m_tab_widget->remove_tab(widget);
|
||||||
update_title();
|
update_title();
|
||||||
|
on_editor_change();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,14 +352,18 @@ void MainWidget::update_title()
|
||||||
void MainWidget::on_editor_change()
|
void MainWidget::on_editor_change()
|
||||||
{
|
{
|
||||||
auto editor = dynamic_cast<ScriptEditor*>(m_tab_widget->active_widget());
|
auto editor = dynamic_cast<ScriptEditor*>(m_tab_widget->active_widget());
|
||||||
if (editor) {
|
update_statusbar(editor);
|
||||||
update_statusbar(editor);
|
update_editor_actions(editor);
|
||||||
update_editor_actions(editor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::update_statusbar(ScriptEditor* editor)
|
void MainWidget::update_statusbar(ScriptEditor* editor)
|
||||||
{
|
{
|
||||||
|
if (!editor) {
|
||||||
|
m_statusbar->set_text(1, "");
|
||||||
|
m_statusbar->set_text(2, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (editor->has_selection()) {
|
if (editor->has_selection()) {
|
||||||
auto character_count = editor->selected_text().length();
|
auto character_count = editor->selected_text().length();
|
||||||
auto word_count = editor->number_of_selected_words();
|
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)
|
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_copy_action->set_enabled(editor->copy_action().is_enabled());
|
||||||
m_cut_action->set_enabled(editor->cut_action().is_enabled());
|
m_cut_action->set_enabled(editor->cut_action().is_enabled());
|
||||||
m_paste_action->set_enabled(editor->paste_action().is_enabled());
|
m_paste_action->set_enabled(editor->paste_action().is_enabled());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue