swift
Loading...
Searching...
No Matches
menudelegate.h
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#ifndef SWIFT_GUI_MENUS_MENUDELEGATE_H
5#define SWIFT_GUI_MENUS_MENUDELEGATE_H
6
7#include <QMenu>
8#include <QObject>
9
10#include "gui/menus/menuaction.h"
11#include "misc/logcategories.h"
12
13class QWidget;
14
15namespace swift::gui::menus
16{
20 class IMenuDelegate : public QObject
21 {
23
24 public:
26 virtual void customMenu(CMenuActions &menuActions) = 0;
27
29 void setNestedDelegate(IMenuDelegate *nestedDelegate) { m_nestedDelegate = nestedDelegate; }
30
33
35 ~IMenuDelegate() override = default;
36
39 {
41 return cats;
42 }
43
44 protected:
47
49 void nestedCustomMenu(CMenuActions &menuActions) const
50 {
52 {
53 return;
54 }
55 m_nestedDelegate->customMenu(menuActions);
56 }
57
59 bool previousMenuItemContains(const QString &str, const QMenu &menu,
61 {
62 if (menu.isEmpty() || str.isEmpty())
63 {
64 return false;
65 }
66 const QString t(menu.actions().last()->text());
67 return t.contains(str, cs);
68 }
69
71 };
72} // namespace swift::gui::menus
73
74#endif // SWIFT_GUI_MENUS_MENUDELEGATE_H
Bunch of CMenuAction objects.
Definition menuaction.h:384
const QStringList & getLogCategories()
Log categories.
~IMenuDelegate()=default
Destructor.
virtual void customMenu(CMenuActions &menuActions)=0
Display custom menu.
IMenuDelegate * getNestedDelegate() const
Nested delegate.
bool previousMenuItemContains(const QString &str, const QMenu &menu, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Does the previous (menu) item contain string?
void nestedCustomMenu(CMenuActions &menuActions) const
Delegate down one level.
IMenuDelegate(QWidget *parent=nullptr)
Constructor.
void setNestedDelegate(IMenuDelegate *nestedDelegate)
Set nested delegate.
IMenuDelegate * m_nestedDelegate
nested delegate if any
static const QString & guiComponent()
GUI components.
T & last()
bool isEmpty() const const
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
CaseSensitivity
QList< QAction * > actions() const const