2018-01-05 13:16:06 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - Qt web browser
|
|
|
|
* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include "qzcommon.h"
|
|
|
|
|
2018-01-07 09:53:01 +01:00
|
|
|
class WebView;
|
2018-01-05 13:16:06 +01:00
|
|
|
|
|
|
|
class QUPZILLA_EXPORT AbstractButtonInterface : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct ClickController {
|
|
|
|
QWidget *visualParent;
|
|
|
|
std::function<QPoint(QSize)> popupPosition;
|
2018-01-08 19:04:21 +01:00
|
|
|
bool popupOpened = false;
|
|
|
|
std::function<void()> popupClosed;
|
2018-01-05 13:16:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
explicit AbstractButtonInterface(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
virtual QString id() const = 0;
|
|
|
|
virtual QString name() const = 0;
|
|
|
|
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
bool isActive() const;
|
|
|
|
void setActive(bool active);
|
|
|
|
|
2018-01-08 19:31:12 +01:00
|
|
|
bool isVisible() const;
|
|
|
|
void setVisible(bool visible);
|
|
|
|
|
2018-01-05 13:16:06 +01:00
|
|
|
QString title() const;
|
|
|
|
void setTitle(const QString &text);
|
|
|
|
|
|
|
|
QString toolTip() const;
|
|
|
|
void setToolTip(const QString &toolTip);
|
|
|
|
|
|
|
|
QIcon icon() const;
|
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
|
2018-01-06 15:56:09 +01:00
|
|
|
QString badgeText() const;
|
|
|
|
void setBadgeText(const QString &badgeText);
|
2018-01-05 13:16:06 +01:00
|
|
|
|
2018-01-07 09:53:01 +01:00
|
|
|
WebView *webView() const;
|
|
|
|
void setWebView(WebView *view);
|
2018-01-05 13:16:06 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void activeChanged(bool active);
|
2018-01-08 19:31:12 +01:00
|
|
|
void visibleChanged(bool visible);
|
2018-01-05 13:16:06 +01:00
|
|
|
void titleChanged(const QString &title);
|
|
|
|
void toolTipChanged(const QString &toolTip);
|
|
|
|
void iconChanged(const QIcon &icon);
|
2018-01-06 15:56:09 +01:00
|
|
|
void badgeTextChanged(const QString &badgeText);
|
2018-01-07 09:53:01 +01:00
|
|
|
void webViewChanged(WebView *view);
|
2018-01-05 13:16:06 +01:00
|
|
|
void clicked(ClickController *controller);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_active = true;
|
2018-01-08 19:31:12 +01:00
|
|
|
bool m_visible = true;
|
2018-01-05 13:16:06 +01:00
|
|
|
QString m_title;
|
|
|
|
QString m_toolTip;
|
|
|
|
QIcon m_icon;
|
2018-01-06 15:56:09 +01:00
|
|
|
QString m_badgeText;
|
2018-01-07 09:53:01 +01:00
|
|
|
WebView *m_view = nullptr;
|
2018-01-05 13:16:06 +01:00
|
|
|
};
|