Falkon Develop
Cross-platform Qt-based web browser
qmlbrowseraction.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
20#include "mainapplication.h"
21#include <QQmlComponent>
22#include <QQmlParserStatus>
23
25
29class QmlBrowserAction : public QObject, public QQmlParserStatus
30{
31 Q_OBJECT
32 Q_INTERFACES(QQmlParserStatus)
33
34
37 Q_PROPERTY(QString identity READ identity WRITE setIdentity NOTIFY identityChanged)
38
39
42 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
43
44
47 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
48
49
52 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged)
53
54
67 Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
68
69
72 Q_PROPERTY(QString badgeText READ badgeText WRITE setBadgeText NOTIFY badgeTextChanged)
73
74
77 Q_PROPERTY(QQmlComponent* popup READ popup WRITE setPopup NOTIFY popupChanged)
78
79
82 Q_PROPERTY(Locations location READ location WRITE setLocation NOTIFY locationChanged)
83
84public:
88 enum Location {
90 StatusBar = 0x2
91 };
92 Q_DECLARE_FLAGS(Locations, Location)
93 Q_ENUM(Locations)
94
95 explicit QmlBrowserAction(QObject *parent = nullptr);
96 ~QmlBrowserAction() override;
97 void classBegin() override {}
98 void componentComplete() override;
100 Locations location() const;
101
102Q_SIGNALS:
107 void identityChanged(const QString &identity);
108
113 void nameChanged(const QString &name);
114
119 void titleChanged(const QString &title);
120
125 void toolTipChanged(const QString &toolTip);
126
131 void iconChanged(const QString &icon);
132
137 void badgeTextChanged(const QString &badgeText);
138
143 void popupChanged(QQmlComponent *popup);
144
149 void locationChanged(const Locations &locations);
150
154 void clicked();
155
156private:
157 QString m_identity;
158 QString m_name;
159 QString m_title;
160 QString m_toolTip;
161 QString m_icon;
162 QString m_badgeText;
163 QQmlComponent *m_popup = nullptr;
164 Locations m_locations = NavigationToolBar;
165 QmlBrowserActionButton *m_button = nullptr;
166
167 QString identity() const;
168 void setIdentity(const QString &identity);
169 QString name() const;
170 void setName(const QString &name);
171 QString title() const;
172 void setTitle(const QString &title);
173 QString toolTip() const;
174 void setToolTip(const QString &toolTip);
175 QString icon() const;
176 void setIcon(const QString &icon);
177 QString badgeText() const;
178 void setBadgeText(const QString &badgeText);
179 QQmlComponent *popup() const;
180 void setPopup(QQmlComponent *popup);
181 void setLocation(const Locations &locations);
182
183 void addButton(BrowserWindow *window);
184 void removeButton(BrowserWindow *window);
185};
186
188{
189 Q_OBJECT
190public:
191 explicit QmlBrowserActionButton(QObject *parent = nullptr);
192 QString id() const override;
193 void setId(const QString &id);
194 QString name() const override;
195 void setName(const QString &name);
196 void setTitle(const QString &title);
197 void setToolTip(const QString &toolTip);
198 void setIcon(const QString &icon);
199 void setBadgeText(const QString &badgeText);
200 void setPopup(QQmlComponent *popup);
201
202 void positionPopup(ClickController *clickController);
203
204private:
205 QString m_id;
206 QString m_name;
207 QString m_iconUrl;
208 QQmlComponent *m_popup = nullptr;
209};
210
211Q_DECLARE_OPERATORS_FOR_FLAGS(QmlBrowserAction::Locations)
QString id() const override
QString name() const override
void setName(const QString &name)
void setToolTip(const QString &toolTip)
void setTitle(const QString &title)
void setIcon(const QString &icon)
QmlBrowserActionButton(QObject *parent=nullptr)
void setPopup(QQmlComponent *popup)
void positionPopup(ClickController *clickController)
void setBadgeText(const QString &badgeText)
void setId(const QString &id)
The class exposing BrowserAction API to QML.
QString identity
identity for the button. This is a required property.
Location
The Location enum.
@ NavigationToolBar
to add the button in navigation tool bar
QQmlComponent * popup
the popup shown when the button is clicked. This must be a QML Window.
void badgeTextChanged(const QString &badgeText)
This signal is emitted when the badgeText property is changed.
QString title
title of the button.
void classBegin() override
QString icon
icon path of button
QString name
name of the button. This is a required property.
void identityChanged(const QString &identity)
This signal is emitted when identity property is changed.
void titleChanged(const QString &title)
This signal is emitted when title property is changed.
void toolTipChanged(const QString &toolTip)
This signal is emitted when the toolTip property is changed.
QmlBrowserActionButton * button() const
~QmlBrowserAction() override
QString toolTip
tool tip of the button.
void nameChanged(const QString &name)
This signal is emitted when name property is changed.
void iconChanged(const QString &icon)
This signal is emitted when the icon property is changed.
void locationChanged(const Locations &locations)
This signal is emitted when the locations property is changed.
QString badgeText
badge text of the button
void clicked()
This signal is emitted when the button is clicked.
void componentComplete() override
Locations location
represents locations where the button is to be added.
QmlBrowserAction(QObject *parent=nullptr)
void popupChanged(QQmlComponent *popup)
This signal is emitted when the popup property is changed.