Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f8c1d8fe authored by Thomas Schöps's avatar Thomas Schöps

Snippets: Make snippet shortcuts work also if the snippets tool view is...

Snippets: Make snippet shortcuts work also if the snippets tool view is minimized, by adding the QActions to the main window instead of the tool view

Summary: The keyboard shortcut for snippets did not work while the snippets tool view was minimized. This seems to be because the snippet QActions must be added to a visible(?) widget to be considered. Thus, this change makes the snippets plugin add its actions to the main window instead of its tool view such that they remain active when the snippets tool view is minimized to the side.

Test Plan: I tested it manually. Note for testing: There seems to be another bug that sometimes prevents the shortcuts for new snippets from working (a restart of the application should make them work). I think that this is unrelated to this change and will try to address it next.

Reviewers: #kate, cullmann

Reviewed By: #kate, cullmann

Subscribers: cullmann, kwrite-devel

Tags: #kate

Differential Revision: https://phabricator.kde.org/D22308
parent 9c10ba8c
......@@ -64,9 +64,9 @@ KateSnippetsPluginView::KateSnippetsPluginView(KateSnippetsPlugin *plugin, KText
i18n("Snippets"));
// add snippets widget
m_snippets = new SnippetView(KateSnippetGlobal::self(), m_toolView.data());
m_snippets = new SnippetView(KateSnippetGlobal::self(), mainWindow, m_toolView.data());
m_toolView->layout()->addWidget(m_snippets);
m_snippets->setupActionsForWindow(m_toolView);
m_snippets->setupActionsForWindow(mainWindow->window());
m_toolView->addActions(m_snippets->actions());
// create actions
......
......@@ -81,7 +81,7 @@ void SnippetView::setupActionsForWindow(QWidget* widget)
}
}
SnippetView::SnippetView(KateSnippetGlobal* plugin, QWidget* parent)
SnippetView::SnippetView(KateSnippetGlobal* plugin, KTextEditor::MainWindow *mainWindow, QWidget* parent)
: QWidget(parent), Ui::SnippetViewBase(), m_plugin(plugin)
{
Ui::SnippetViewBase::setupUi(this);
......@@ -143,7 +143,7 @@ SnippetView::SnippetView(KateSnippetGlobal* plugin, QWidget* parent)
connect(snippetTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &SnippetView::validateActions);
validateActions();
connect(snippetTree->model(), &QAbstractItemModel::rowsInserted, this, [this]() { setupActionsForWindow(this); });
connect(snippetTree->model(), &QAbstractItemModel::rowsInserted, this, [this, mainWindow]() { setupActionsForWindow(mainWindow->window()); });
m_proxy->setDynamicSortFilter(true);
m_proxy->sort(0, Qt::AscendingOrder);
......
......@@ -25,6 +25,8 @@
#ifndef SNIPPETVIEW_H
#define SNIPPETVIEW_H
#include <KTextEditor/MainWindow>
#include "ui_snippetview.h"
class QStandardItem;
......@@ -45,7 +47,7 @@ class SnippetView : public QWidget, public Ui::SnippetViewBase
Q_OBJECT
public:
explicit SnippetView(KateSnippetGlobal* plugin, QWidget* parent = nullptr);
explicit SnippetView(KateSnippetGlobal* plugin, KTextEditor::MainWindow *mainWindow, QWidget* parent = nullptr);
public:
void setupActionsForWindow(QWidget* widget);
......
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