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