Falkon Develop
Cross-platform Qt-based web browser
abstractbuttoninterface.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 David Rosca <nowrep@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 <QIcon>
21#include <QObject>
22
23#include <functional>
24
25#include "qzcommon.h"
26
27class WebView;
28
30{
31 Q_OBJECT
32
33public:
35 QWidget *visualParent;
36 std::function<QPoint(QSize)> popupPosition;
37 bool popupOpened = false;
38 std::function<void()> popupClosed;
39
40 QPoint callPopupPosition(const QSize &size) const {
41 return popupPosition(size);
42 }
43
44 void callPopupClosed() const {
45 popupClosed();
46 }
47 };
48
49 explicit AbstractButtonInterface(QObject *parent = nullptr);
50
51 virtual QString id() const = 0;
52 virtual QString name() const = 0;
53
54 bool isValid() const;
55
56 bool isActive() const;
57 void setActive(bool active);
58
59 bool isVisible() const;
60 void setVisible(bool visible);
61
62 QString title() const;
63 void setTitle(const QString &text);
64
65 QString toolTip() const;
66 void setToolTip(const QString &toolTip);
67
68 QIcon icon() const;
69 void setIcon(const QIcon &icon);
70
71 QString badgeText() const;
72 void setBadgeText(const QString &badgeText);
73
74 WebView *webView() const;
75 void setWebView(WebView *view);
76
77Q_SIGNALS:
78 void activeChanged(bool active);
79 void visibleChanged(bool visible);
80 void titleChanged(const QString &title);
81 void toolTipChanged(const QString &toolTip);
82 void iconChanged(const QIcon &icon);
83 void badgeTextChanged(const QString &badgeText);
86
87private:
88 bool m_active = true;
89 bool m_visible = true;
90 QString m_title;
91 QString m_toolTip;
92 QIcon m_icon;
93 QString m_badgeText;
94 WebView *m_view = nullptr;
95};
void titleChanged(const QString &title)
void webViewChanged(WebView *view)
virtual QString id() const =0
void iconChanged(const QIcon &icon)
void clicked(AbstractButtonInterface::ClickController *controller)
void badgeTextChanged(const QString &badgeText)
void activeChanged(bool active)
virtual QString name() const =0
void visibleChanged(bool visible)
void toolTipChanged(const QString &toolTip)
#define FALKON_EXPORT
Definition: qzcommon.h:28
QPoint callPopupPosition(const QSize &size) const