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

Fix show action for project info view

parent 61491799
Pipeline #218356 passed with stage
in 5 minutes and 38 seconds
......@@ -13,6 +13,7 @@
#include <KPluginFactory>
#include <KSharedConfig>
#include <kde_terminal_interface.h>
#include <ktexteditor_utils.h>
#include <QTabWidget>
......@@ -29,6 +30,8 @@ KateProjectInfoViewTerminal::KateProjectInfoViewTerminal(KateProjectPluginView *
m_layout = new QVBoxLayout(this);
m_layout->setSpacing(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_showProjectInfoViewAction = Utils::toolviewShowAction(pluginView, QStringLiteral("kateprojectinfo"));
}
KateProjectInfoViewTerminal::~KateProjectInfoViewTerminal()
......@@ -110,8 +113,18 @@ void KateProjectInfoViewTerminal::loadTerminal()
// clang-format on
}
void KateProjectInfoViewTerminal::overrideShortcut(QKeyEvent *, bool &override)
void KateProjectInfoViewTerminal::overrideShortcut(QKeyEvent *keyEvent, bool &override)
{
if (m_showProjectInfoViewAction && !m_showProjectInfoViewAction->shortcut().isEmpty()) {
int modifiers = keyEvent->modifiers();
int key = keyEvent->key();
QKeySequence k(modifiers | key);
if (m_showProjectInfoViewAction->shortcut().matches(k)) {
override = false;
return;
}
}
/**
* let konsole handle all shortcuts
*/
......
......@@ -13,6 +13,7 @@
#include <kparts/readonlypart.h>
#include <QPointer>
#include <QWidget>
class KateProjectPluginView;
......@@ -63,7 +64,7 @@ private Q_SLOTS:
/**
* Handle that shortcuts are not eaten by console
*/
static void overrideShortcut(QKeyEvent *event, bool &override);
void overrideShortcut(QKeyEvent *event, bool &override);
protected:
/**
......@@ -105,6 +106,8 @@ private:
* konsole part
*/
KParts::ReadOnlyPart *m_konsolePart;
QPointer<QAction> m_showProjectInfoViewAction;
};
#endif
......@@ -6,6 +6,8 @@
#include "ktexteditor_utils.h"
#include <KActionCollection>
#include <KXMLGUIFactory>
#include <QMimeDatabase>
namespace Utils
......@@ -31,4 +33,33 @@ QIcon iconForDocument(KTextEditor::Document *doc)
return icon;
}
QAction *toolviewShowAction(KXMLGUIClient *client, const QString &toolviewName)
{
if (!client) {
qWarning() << Q_FUNC_INFO << "invalid null client, toolviewName: " << toolviewName;
Q_ASSERT(false);
return nullptr;
}
static const QString prefix = QStringLiteral("kate_mdi_toolview_");
if (client->componentName() == QStringLiteral("toolviewmanager")) {
return client->actionCollection()->action(prefix + toolviewName);
}
KXMLGUIClient *toolviewmanager = nullptr;
const auto clients = client->factory()->clients();
for (auto client : clients) {
if (client->componentName() == QStringLiteral("toolviewmanager")) {
toolviewmanager = client;
break;
}
}
if (!toolviewmanager) {
qWarning() << Q_FUNC_INFO << "Unexpected unable to find toolviewmanager KXMLGUIClient, toolviewName: " << toolviewName;
return nullptr;
}
return toolviewmanager->actionCollection()->action(prefix + toolviewName);
}
}
......@@ -89,4 +89,6 @@ inline QFont viewFont(KTextEditor::View *view)
* @return icon, always valid
*/
KATE_PRIVATE_EXPORT QIcon iconForDocument(KTextEditor::Document *doc);
KATE_PRIVATE_EXPORT QAction *toolviewShowAction(KXMLGUIClient *client, const QString &toolviewName);
}
Supports Markdown
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