Commit 9c9cde04 authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Tomaz Canabrava
Browse files

New method to modify the menus of a Session: setupMenu(QMenu)

Some KDE Apis consume a QMenu and do not return a QAction :(
parent ad4e77d5
......@@ -32,6 +32,7 @@
#include <QString>
#include <QTextStream>
#include <QUrl>
#include <QMenu>
// KDE
#include <KLocalizedString>
......@@ -250,6 +251,11 @@ QList<QAction *> Filter::HotSpot::actions()
return {};
}
void Filter::HotSpot::setupMenu(QMenu *)
{
}
int Filter::HotSpot::startLine() const
{
return _startLine;
......@@ -543,3 +549,8 @@ QList<QAction *> FileFilter::HotSpot::actions()
QObject::connect(openAction, &QAction::triggered, this, [this ]{ activate(); });
return {openAction};
}
void FileFilter::HotSpot::setupMenu(QMenu *menu)
{
menu->addAction(QStringLiteral("Teste"));
}
......@@ -35,6 +35,7 @@
#include "Character.h"
class QAction;
class QMenu;
namespace Konsole {
class Session;
......@@ -123,6 +124,10 @@ public:
*/
virtual QList<QAction *> actions();
/**
* Setups a menu with actions for the hotspot.
*/
virtual void setupMenu(QMenu *menu);
protected:
/** Sets the type of a hotspot. This should only be set once */
void setType(Type type);
......@@ -307,7 +312,7 @@ public:
* Opens kate for editing the file.
*/
void activate(QObject *object = nullptr) override;
void setupMenu(QMenu *menu) override;
private:
QString _filePath;
};
......
......@@ -1721,7 +1721,7 @@ void SessionController::showDisplayContextMenu(const QPoint& position)
QSharedPointer<Filter::HotSpot> hotSpot = _view->filterActions(position);
if (hotSpot != nullptr) {
popup->insertActions(popup->actions().value(0, nullptr), hotSpot->actions() << contentSeparator );
hotSpot->setupMenu(popup.data());
}
// always update this submenu before showing the context menu,
......
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