diff --git a/plugins/contextbrowser/contextbrowserview.h b/plugins/contextbrowser/contextbrowserview.h --- a/plugins/contextbrowser/contextbrowserview.h +++ b/plugins/contextbrowser/contextbrowserview.h @@ -37,6 +37,7 @@ class QCheckBox; class QMenu; class KComboBox; +class KToggleAction; namespace KDevelop { class IDocument; @@ -79,7 +80,6 @@ bool isLocked() const; private Q_SLOTS: - void updateLockIcon(bool); void declarationMenu(); void navigationContextChanged(bool wasInitial, bool isInitial); @@ -97,7 +97,7 @@ ContextBrowserPlugin* m_plugin; QVBoxLayout* m_layout; - QAction* m_lockAction; + KToggleAction* m_lockAction; QAction* m_declarationMenuAction; QHBoxLayout* m_buttons; diff --git a/plugins/contextbrowser/contextbrowserview.cpp b/plugins/contextbrowser/contextbrowserview.cpp --- a/plugins/contextbrowser/contextbrowserview.cpp +++ b/plugins/contextbrowser/contextbrowserview.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -101,10 +102,6 @@ } } -void ContextBrowserView::updateLockIcon(bool checked) { - m_lockAction->setIcon(QIcon::fromTheme(checked ? QStringLiteral("document-encrypt") : QStringLiteral("document-decrypt"))); -} - ContextBrowserView::ContextBrowserView( ContextBrowserPlugin* plugin, QWidget* parent ) : QWidget(parent), m_plugin(plugin), m_navigationWidget(new QTextBrowser()), m_autoLocked(false) { setWindowTitle(i18n("Code Browser")); setWindowIcon( QIcon::fromTheme(QStringLiteral("code-context"), windowIcon()) ); @@ -115,13 +112,11 @@ m_declarationMenuAction->setToolTip(i18n("Declaration menu")); connect(m_declarationMenuAction, &QAction::triggered, this, &ContextBrowserView::declarationMenu); addAction(m_declarationMenuAction); - m_lockAction = new QAction(this); - m_lockAction->setCheckable(true); - m_lockAction->setChecked(false); + m_lockAction = new KToggleAction(QIcon::fromTheme(QStringLiteral("object-unlocked")), i18n("Lock Current View"), this); m_lockAction->setToolTip(i18n("Lock current view")); + m_lockAction->setCheckedState(KGuiItem(i18n("Unlock Current View"), QIcon::fromTheme(QStringLiteral("object-locked")), i18n("Unlock current view"))); + m_lockAction->setChecked(false); addAction(m_lockAction); - updateLockIcon(m_lockAction->isChecked()); - connect(m_lockAction, &QAction::triggered, this, &ContextBrowserView::updateLockIcon); m_layout = new QVBoxLayout; m_layout->setSpacing(0);