Commit d883d750 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Fix terminal focus action text when focusing/defocusing

BUG: 409813
parent 4c41f819
Pipeline #124406 passed with stage
in 6 minutes and 48 seconds
......@@ -168,6 +168,8 @@ KateConsole::KateConsole(KateKonsolePlugin *plugin, KTextEditor::MainWindow *mw,
m_mw->guiFactory()->addClient(this);
readConfig();
connect(qApp, &QApplication::focusChanged, this, &KateConsole::focusChanged);
}
KateConsole::~KateConsole()
......@@ -452,24 +454,27 @@ void KateConsole::slotToggleVisibility()
}
}
void KateConsole::slotToggleFocus()
void KateConsole::focusChanged(QWidget *, QWidget *now)
{
QAction *action = actionCollection()->action(QStringLiteral("katekonsole_tools_toggle_focus"));
if (!m_part) {
m_mw->showToolView(parentWidget());
if (m_part && m_part->widget()->isAncestorOf(now)) {
action->setText(i18n("Defocus Terminal Panel"));
return; // this shows and focuses the konsole
} else if (action->text() != i18n("Focus Terminal Panel")) {
action->setText(i18n("Focus Terminal Panel"));
}
}
void KateConsole::slotToggleFocus()
{
if (!m_part) {
return;
m_mw->showToolView(parentWidget());
return; // this shows and focuses the konsole
}
if (m_part->widget()->hasFocus()) {
if (m_mw->activeView()) {
m_mw->activeView()->setFocus();
}
action->setText(i18n("Focus Terminal Panel"));
} else {
// show the view if it is hidden
if (parentWidget()->isHidden()) {
......@@ -477,7 +482,6 @@ void KateConsole::slotToggleFocus()
} else { // should focus the widget too!
m_part->widget()->setFocus(Qt::OtherFocusReason);
}
action->setText(i18n("Defocus Terminal Panel"));
}
}
......
......@@ -172,6 +172,11 @@ private Q_SLOTS:
*/
void slotToggleFocus();
/**
* changes the menu actions text based on focus
*/
void focusChanged(QWidget *, QWidget *now);
/**
* Handle that shortcuts are not eaten by console
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment