Falkon Develop
Cross-platform Qt-based web browser
qmlmenu.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#pragma once
19
20#include "qmlaction.h"
21#include <QMenu>
22#include <QQmlEngine>
23
24class QmlEngine;
25
29class QmlMenu : public QObject
30{
31 Q_OBJECT
32public:
33 explicit QmlMenu(QMenu *menu, QQmlEngine *engine, QObject *parent = nullptr);
41 Q_INVOKABLE QmlAction *addAction(const QVariantMap &map);
48 Q_INVOKABLE QmlMenu *addMenu(const QVariantMap &map);
52 Q_INVOKABLE void addSeparator();
53
54Q_SIGNALS:
58 void triggered();
59
60private:
61 QMenu *m_menu = nullptr;
62 QString m_pluginPath;
63 QmlEngine *m_engine = nullptr;
64};
The class exposing Action API to QML.
Definition: qmlaction.h:30
The class exposing WebView contextmenu to QML as Menu API.
Definition: qmlmenu.h:30
QmlMenu(QMenu *menu, QQmlEngine *engine, QObject *parent=nullptr)
Definition: qmlmenu.cpp:24
void triggered()
This signal is emitted when the menu is triggred.
Q_INVOKABLE void addSeparator()
Adds a separator to menu.
Definition: qmlmenu.cpp:71
Q_INVOKABLE QmlAction * addAction(const QVariantMap &map)
Adds action to menu.
Definition: qmlmenu.cpp:35
Q_INVOKABLE QmlMenu * addMenu(const QVariantMap &map)
Adds sub-menu to menu.
Definition: qmlmenu.cpp:49