diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index b8cdf5d5..c351502b 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -1,614 +1,614 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2018 David Rosca * * 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 . * ============================================================ */ #include "navigationbar.h" #include "toolbutton.h" #include "browserwindow.h" #include "mainapplication.h" #include "iconprovider.h" #include "websearchbar.h" #include "reloadstopbutton.h" #include "enhancedmenu.h" #include "tabwidget.h" #include "tabbedwebview.h" #include "webpage.h" #include "qzsettings.h" #include "qztools.h" #include "abstractbuttoninterface.h" #include "navigationbartoolbutton.h" #include "navigationbarconfigdialog.h" #include #include #include #include #include #include #include static QString titleForUrl(QString title, const QUrl &url) { if (title.isEmpty()) { title = url.toString(QUrl::RemoveFragment); } if (title.isEmpty()) { return NavigationBar::tr("Empty Page"); } return QzTools::truncatedText(title, 40); } static QIcon iconForPage(const QUrl &url, const QIcon &sIcon) { QIcon icon; icon.addPixmap(url.scheme() == QL1S("qupzilla") ? QIcon(QSL(":icons/qupzilla.png")).pixmap(16) : IconProvider::iconForUrl(url).pixmap(16)); icon.addPixmap(sIcon.pixmap(16), QIcon::Active); return icon; } NavigationBar::NavigationBar(BrowserWindow* window) : QWidget(window) , m_window(window) { setObjectName(QSL("navigationbar")); m_layout = new QHBoxLayout(this); m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this) + style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this)); m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this)); setLayout(m_layout); m_buttonBack = new ToolButton(this); m_buttonBack->setObjectName("navigation-button-back"); m_buttonBack->setToolTip(tr("Back")); m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly); m_buttonBack->setToolbarButtonLook(true); m_buttonBack->setShowMenuOnRightClick(true); m_buttonBack->setAutoRaise(true); m_buttonBack->setEnabled(false); m_buttonBack->setFocusPolicy(Qt::NoFocus); m_buttonForward = new ToolButton(this); m_buttonForward->setObjectName("navigation-button-next"); m_buttonForward->setToolTip(tr("Forward")); m_buttonForward->setToolButtonStyle(Qt::ToolButtonIconOnly); m_buttonForward->setToolbarButtonLook(true); m_buttonForward->setShowMenuOnRightClick(true); m_buttonForward->setAutoRaise(true); m_buttonForward->setEnabled(false); m_buttonForward->setFocusPolicy(Qt::NoFocus); QHBoxLayout* backNextLayout = new QHBoxLayout(); backNextLayout->setContentsMargins(0, 0, 0, 0); backNextLayout->setSpacing(0); backNextLayout->addWidget(m_buttonBack); backNextLayout->addWidget(m_buttonForward); QWidget *backNextWidget = new QWidget(this); backNextWidget->setLayout(backNextLayout); m_reloadStop = new ReloadStopButton(this); ToolButton *buttonHome = new ToolButton(this); buttonHome->setObjectName("navigation-button-home"); buttonHome->setToolTip(tr("Home")); buttonHome->setToolButtonStyle(Qt::ToolButtonIconOnly); buttonHome->setToolbarButtonLook(true); buttonHome->setAutoRaise(true); buttonHome->setFocusPolicy(Qt::NoFocus); ToolButton *buttonAddTab = new ToolButton(this); buttonAddTab->setObjectName("navigation-button-addtab"); buttonAddTab->setToolTip(tr("New Tab")); buttonAddTab->setToolButtonStyle(Qt::ToolButtonIconOnly); buttonAddTab->setToolbarButtonLook(true); buttonAddTab->setAutoRaise(true); buttonAddTab->setFocusPolicy(Qt::NoFocus); m_menuBack = new Menu(this); m_menuBack->setCloseOnMiddleClick(true); m_buttonBack->setMenu(m_menuBack); connect(m_buttonBack, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryBackMenu())); m_menuForward = new Menu(this); m_menuForward->setCloseOnMiddleClick(true); m_buttonForward->setMenu(m_menuForward); connect(m_buttonForward, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryNextMenu())); ToolButton *buttonTools = new ToolButton(this); buttonTools->setObjectName("navigation-button-tools"); buttonTools->setPopupMode(QToolButton::InstantPopup); buttonTools->setToolbarButtonLook(true); buttonTools->setToolTip(tr("Tools")); buttonTools->setAutoRaise(true); buttonTools->setFocusPolicy(Qt::NoFocus); buttonTools->setShowMenuInside(true); m_menuTools = new Menu(this); buttonTools->setMenu(m_menuTools); connect(buttonTools, &ToolButton::aboutToShowMenu, this, &NavigationBar::aboutToShowToolsMenu); m_supMenu = new ToolButton(this); m_supMenu->setObjectName("navigation-button-supermenu"); m_supMenu->setPopupMode(QToolButton::InstantPopup); m_supMenu->setToolbarButtonLook(true); m_supMenu->setToolTip(tr("Main Menu")); m_supMenu->setAutoRaise(true); m_supMenu->setFocusPolicy(Qt::NoFocus); m_supMenu->setMenu(m_window->superMenu()); m_supMenu->setShowMenuInside(true); m_searchLine = new WebSearchBar(m_window); m_navigationSplitter = new QSplitter(this); m_navigationSplitter->addWidget(m_window->tabWidget()->locationBars()); m_navigationSplitter->addWidget(m_searchLine); m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); m_navigationSplitter->setCollapsible(0, false); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack())); connect(m_buttonBack, SIGNAL(middleMouseClicked()), this, SLOT(goBackInNewTab())); connect(m_buttonBack, SIGNAL(controlClicked()), this, SLOT(goBackInNewTab())); connect(m_buttonForward, SIGNAL(clicked()), this, SLOT(goForward())); connect(m_buttonForward, SIGNAL(middleMouseClicked()), this, SLOT(goForwardInNewTab())); connect(m_buttonForward, SIGNAL(controlClicked()), this, SLOT(goForwardInNewTab())); connect(m_reloadStop, SIGNAL(stopClicked()), this, SLOT(stop())); connect(m_reloadStop, SIGNAL(reloadClicked()), this, SLOT(reload())); connect(buttonHome, SIGNAL(clicked()), m_window, SLOT(goHome())); connect(buttonHome, SIGNAL(middleMouseClicked()), m_window, SLOT(goHomeInNewTab())); connect(buttonHome, SIGNAL(controlClicked()), m_window, SLOT(goHomeInNewTab())); connect(buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab())); connect(buttonAddTab, SIGNAL(middleMouseClicked()), m_window->tabWidget(), SLOT(addTabFromClipboard())); connect(mApp, &MainApplication::settingsReloaded, this, &NavigationBar::loadSettings); addWidget(backNextWidget, QSL("button-backforward"), tr("Back and Forward buttons")); addWidget(m_reloadStop, QSL("button-reloadstop"), tr("Reload button")); addWidget(buttonHome, QSL("button-home"), tr("Home button")); addWidget(buttonAddTab, QSL("button-addtab"), tr("Add tab button")); addWidget(m_navigationSplitter, QSL("locationbar"), tr("Address and Search bar")); addWidget(buttonTools, QSL("button-tools"), tr("Tools button")); loadSettings(); } void NavigationBar::setSplitterSizes(int locationBar, int websearchBar) { QList sizes; if (locationBar == 0) { int splitterWidth = m_navigationSplitter->width(); sizes << (int)((double)splitterWidth * .80) << (int)((double)splitterWidth * .20); } else { sizes << locationBar << websearchBar; } m_navigationSplitter->setSizes(sizes); } void NavigationBar::setCurrentView(TabbedWebView *view) { for (const WidgetData &data : qAsConst(m_widgets)) { if (data.button) { data.button->setWebPage(view->page()); } } } void NavigationBar::showReloadButton() { m_reloadStop->showReloadButton(); } void NavigationBar::showStopButton() { m_reloadStop->showStopButton(); } void NavigationBar::setSuperMenuVisible(bool visible) { m_supMenu->setVisible(visible); } int NavigationBar::layoutMargin() const { return m_layout->margin(); } void NavigationBar::setLayoutMargin(int margin) { m_layout->setMargin(margin); } int NavigationBar::layoutSpacing() const { return m_layout->spacing(); } void NavigationBar::setLayoutSpacing(int spacing) { m_layout->setSpacing(spacing); } void NavigationBar::addWidget(QWidget *widget, const QString &id, const QString &name) { if (!widget || id.isEmpty() || name.isEmpty()) { return; } WidgetData data; data.id = id; data.name = name; data.widget = widget; m_widgets[id] = data; reloadLayout(); } void NavigationBar::removeWidget(const QString &id) { if (!m_widgets.contains(id)) { return; } m_widgets.remove(id); reloadLayout(); } void NavigationBar::addToolButton(AbstractButtonInterface *button) { if (!button || !button->isValid()) { return; } WidgetData data; data.id = button->id(); data.name = button->name(); data.widget = new NavigationBarToolButton(button, this); data.button = button; m_widgets[data.id] = data; if (m_window->weView()) { data.button->setWebPage(m_window->weView()->page()); } reloadLayout(); } void NavigationBar::removeToolButton(AbstractButtonInterface *button) { if (!button || !m_widgets.contains(button->id())) { return; } delete m_widgets.take(button->id()).widget; } void NavigationBar::aboutToShowHistoryBackMenu() { if (!m_menuBack || !m_window->weView()) { return; } m_menuBack->clear(); QWebEngineHistory* history = m_window->weView()->history(); int curindex = history->currentItemIndex(); int count = 0; for (int i = curindex - 1; i >= 0; i--) { QWebEngineHistoryItem item = history->itemAt(i); if (item.isValid()) { QString title = titleForUrl(item.title(), item.url()); const QIcon icon = iconForPage(item.url(), IconProvider::standardIcon(QStyle::SP_ArrowBack)); Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(loadHistoryIndex())); connect(act, SIGNAL(ctrlTriggered()), this, SLOT(loadHistoryIndexInNewTab())); m_menuBack->addAction(act); } count++; if (count == 20) { break; } } m_menuBack->addSeparator(); m_menuBack->addAction(tr("Clear history"), this, SLOT(clearHistory())); } void NavigationBar::aboutToShowHistoryNextMenu() { if (!m_menuForward || !m_window->weView()) { return; } m_menuForward->clear(); QWebEngineHistory* history = m_window->weView()->history(); int curindex = history->currentItemIndex(); int count = 0; for (int i = curindex + 1; i < history->count(); i++) { QWebEngineHistoryItem item = history->itemAt(i); if (item.isValid()) { QString title = titleForUrl(item.title(), item.url()); const QIcon icon = iconForPage(item.url(), IconProvider::standardIcon(QStyle::SP_ArrowForward)); Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(loadHistoryIndex())); connect(act, SIGNAL(ctrlTriggered()), this, SLOT(loadHistoryIndexInNewTab())); m_menuForward->addAction(act); } count++; if (count == 20) { break; } } m_menuForward->addSeparator(); m_menuForward->addAction(tr("Clear history"), this, SLOT(clearHistory())); } void NavigationBar::aboutToShowToolsMenu() { m_menuTools->clear(); m_window->createToolbarsMenu(m_menuTools->addMenu(tr("Toolbars"))); m_window->createSidebarsMenu(m_menuTools->addMenu(tr("Sidebars"))); m_menuTools->addSeparator(); for (const WidgetData &data : qAsConst(m_widgets)) { AbstractButtonInterface *button = data.button; if (button && !m_layoutIds.contains(data.id)) { QString title = button->title(); - if (!button->badgeLabelText().isEmpty()) { - title.append(QSL(" (%1)").arg(button->badgeLabelText())); + if (!button->badgeText().isEmpty()) { + title.append(QSL(" (%1)").arg(button->badgeText())); } m_menuTools->addAction(button->icon(), title, this, &NavigationBar::toolActionActivated)->setData(data.id); } } m_menuTools->addSeparator(); m_menuTools->addAction(IconProvider::settingsIcon(), tr("Configure Toolbar"), this, SLOT(openConfigurationDialog())); } void NavigationBar::clearHistory() { QWebEngineHistory* history = m_window->weView()->page()->history(); history->clear(); refreshHistory(); } void NavigationBar::contextMenuRequested(const QPoint &pos) { QMenu menu; m_window->createToolbarsMenu(&menu); menu.addSeparator(); menu.addAction(IconProvider::settingsIcon(), tr("Configure Toolbar"), this, SLOT(openConfigurationDialog())); menu.exec(mapToGlobal(pos)); } void NavigationBar::openConfigurationDialog() { NavigationBarConfigDialog *dialog = new NavigationBarConfigDialog(this); dialog->show(); } void NavigationBar::toolActionActivated() { QAction *act = qobject_cast(sender()); if (!act) { return; } const QString id = act->data().toString(); if (!m_widgets.contains(id)) { return; } WidgetData data = m_widgets.value(id); if (!data.button) { return; } ToolButton *buttonTools = qobject_cast(m_widgets.value(QSL("button-tools")).widget); if (!buttonTools) { return; } AbstractButtonInterface::ClickController c; c.visualParent = buttonTools; c.popupPosition = [=](const QSize &size) { QPoint pos = buttonTools->mapToGlobal(buttonTools->rect().bottomRight()); if (QApplication::isRightToLeft()) { pos.setX(pos.x() - buttonTools->rect().width()); } else { pos.setX(pos.x() - size.width()); } return pos; }; buttonTools->setDown(true); emit data.button->clicked(&c); buttonTools->setDown(false); } void NavigationBar::loadSettings() { const QStringList defaultIds = { QSL("button-backforward"), QSL("button-reloadstop"), QSL("button-home"), QSL("locationbar"), QSL("button-tools") }; Settings settings; settings.beginGroup(QSL("NavigationBar")); m_layoutIds = settings.value(QSL("Layout"), defaultIds).toStringList(); m_searchLine->setVisible(settings.value(QSL("ShowSearchBar"), true).toBool()); settings.endGroup(); m_layoutIds.removeDuplicates(); if (!m_layoutIds.contains(QSL("locationbar"))) { m_layoutIds.append(QSL("locationbar")); } reloadLayout(); } void NavigationBar::reloadLayout() { if (m_widgets.isEmpty()) { return; } setUpdatesEnabled(false); // Clear layout while (m_layout->count() != 0) { QLayoutItem *item = m_layout->takeAt(0); if (!item) { continue; } QWidget *widget = item->widget(); if (!widget) { continue; } widget->setParent(nullptr); } // Hide all widgets for (const WidgetData &data : m_widgets) { data.widget->hide(); } // Add widgets to layout for (const QString &id : qAsConst(m_layoutIds)) { const WidgetData data = m_widgets.value(id); if (data.widget) { m_layout->addWidget(data.widget); data.widget->show(); } } m_layout->addWidget(m_supMenu); setUpdatesEnabled(true); } void NavigationBar::loadHistoryIndex() { QWebEngineHistory* history = m_window->weView()->page()->history(); if (QAction* action = qobject_cast(sender())) { loadHistoryItem(history->itemAt(action->data().toInt())); } } void NavigationBar::loadHistoryIndexInNewTab(int index) { if (QAction* action = qobject_cast(sender())) { index = action->data().toInt(); } if (index == -1) { return; } QWebEngineHistory* history = m_window->weView()->page()->history(); loadHistoryItemInNewTab(history->itemAt(index)); } void NavigationBar::refreshHistory() { if (mApp->isClosing() || !m_window->weView()) { return; } QWebEngineHistory* history = m_window->weView()->page()->history(); m_buttonBack->setEnabled(history->canGoBack()); m_buttonForward->setEnabled(history->canGoForward()); } void NavigationBar::stop() { m_window->action(QSL("View/Stop"))->trigger(); } void NavigationBar::reload() { m_window->action(QSL("View/Reload"))->trigger(); } void NavigationBar::goBack() { QWebEngineHistory* history = m_window->weView()->page()->history(); history->back(); } void NavigationBar::goBackInNewTab() { QWebEngineHistory* history = m_window->weView()->page()->history(); if (!history->canGoBack()) { return; } loadHistoryItemInNewTab(history->backItem()); } void NavigationBar::goForward() { QWebEngineHistory* history = m_window->weView()->page()->history(); history->forward(); } void NavigationBar::goForwardInNewTab() { QWebEngineHistory* history = m_window->weView()->page()->history(); if (!history->canGoForward()) { return; } loadHistoryItemInNewTab(history->forwardItem()); } void NavigationBar::loadHistoryItem(const QWebEngineHistoryItem &item) { m_window->weView()->page()->history()->goToItem(item); refreshHistory(); } void NavigationBar::loadHistoryItemInNewTab(const QWebEngineHistoryItem &item) { TabWidget* tabWidget = m_window->tabWidget(); int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex()); QWebEngineHistory* history = m_window->weView(tabIndex)->page()->history(); history->goToItem(item); if (qzSettings->newTabPosition == Qz::NT_SelectedTab) { tabWidget->setCurrentIndex(tabIndex); } } diff --git a/src/lib/navigation/navigationbartoolbutton.cpp b/src/lib/navigation/navigationbartoolbutton.cpp index ee928c19..c5457fe5 100644 --- a/src/lib/navigation/navigationbartoolbutton.cpp +++ b/src/lib/navigation/navigationbartoolbutton.cpp @@ -1,85 +1,85 @@ /* ============================================================ * QupZilla - Qt web browser * Copyright (C) 2018 David Rosca * * 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 . * ============================================================ */ #include "navigationbartoolbutton.h" #include "abstractbuttoninterface.h" #include #include NavigationBarToolButton::NavigationBarToolButton(AbstractButtonInterface *button, QWidget *parent) : ToolButton(parent) , m_button(button) { setAutoRaise(true); setToolbarButtonLook(true); setFocusPolicy(Qt::NoFocus); m_badgeLabel = new QLabel(this); m_badgeLabel->setObjectName(QSL("navigation-toolbutton-badge")); QFont f = m_badgeLabel->font(); f.setPixelSize(m_badgeLabel->height() / 2.5); m_badgeLabel->setFont(f); m_badgeLabel->hide(); setToolTip(button->toolTip()); updateIcon(); updateBadge(); connect(button, &AbstractButtonInterface::iconChanged, this, &NavigationBarToolButton::updateIcon); connect(button, &AbstractButtonInterface::activeChanged, this, &NavigationBarToolButton::updateIcon); connect(button, &AbstractButtonInterface::toolTipChanged, this, &NavigationBarToolButton::setToolTip); - connect(button, &AbstractButtonInterface::badgeLabelTextChanged, this, &NavigationBarToolButton::updateBadge); + connect(button, &AbstractButtonInterface::badgeTextChanged, this, &NavigationBarToolButton::updateBadge); connect(this, &ToolButton::clicked, this, &NavigationBarToolButton::clicked); } void NavigationBarToolButton::clicked() { AbstractButtonInterface::ClickController c; c.visualParent = this; c.popupPosition = [this](const QSize &size) { QPoint pos = mapToGlobal(rect().bottomRight()); if (QApplication::isRightToLeft()) { pos.setX(pos.x() - rect().width()); } else { pos.setX(pos.x() - size.width()); } return pos; }; setDown(true); emit m_button->clicked(&c); setDown(false); } void NavigationBarToolButton::updateIcon() { const QIcon::Mode mode = m_button->isActive() ? QIcon::Normal : QIcon::Disabled; const QImage img = m_button->icon().pixmap(iconSize(), mode).toImage(); setIcon(QPixmap::fromImage(img, Qt::MonoOnly)); } void NavigationBarToolButton::updateBadge() { - if (m_button->badgeLabelText().isEmpty()) { + if (m_button->badgeText().isEmpty()) { m_badgeLabel->hide(); } else { - m_badgeLabel->setText(m_button->badgeLabelText()); + m_badgeLabel->setText(m_button->badgeText()); m_badgeLabel->resize(m_badgeLabel->sizeHint()); m_badgeLabel->move(width() - m_badgeLabel->width(), 0); m_badgeLabel->show(); } } diff --git a/src/lib/tools/abstractbuttoninterface.cpp b/src/lib/tools/abstractbuttoninterface.cpp index f8e59a19..2171a6ff 100644 --- a/src/lib/tools/abstractbuttoninterface.cpp +++ b/src/lib/tools/abstractbuttoninterface.cpp @@ -1,114 +1,114 @@ /* ============================================================ * QupZilla - Qt web browser * Copyright (C) 2018 David Rosca * * 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 . * ============================================================ */ #include "abstractbuttoninterface.h" AbstractButtonInterface::AbstractButtonInterface(QObject *parent) : QObject(parent) { } bool AbstractButtonInterface::isValid() const { return !id().isEmpty() && !name().isEmpty(); } bool AbstractButtonInterface::isActive() const { return m_active; } void AbstractButtonInterface::setActive(bool active) { if (m_active == active) { return; } m_active = active; emit activeChanged(m_active); } QString AbstractButtonInterface::title() const { return m_title; } void AbstractButtonInterface::setTitle(const QString &title) { if (m_title == title) { return; } m_title = title; emit titleChanged(m_title); } QString AbstractButtonInterface::toolTip() const { return m_toolTip; } void AbstractButtonInterface::setToolTip(const QString &toolTip) { if (m_toolTip == toolTip) { return; } m_toolTip = toolTip; emit toolTipChanged(m_toolTip); } QIcon AbstractButtonInterface::icon() const { return m_icon; } void AbstractButtonInterface::setIcon(const QIcon &icon) { m_icon = icon; emit iconChanged(icon); } -QString AbstractButtonInterface::badgeLabelText() const +QString AbstractButtonInterface::badgeText() const { - return m_badgeLabelText; + return m_badgeText; } -void AbstractButtonInterface::setBadgeLabelText(const QString &badgeLabelText) +void AbstractButtonInterface::setBadgeText(const QString &badgeText) { - if (m_badgeLabelText == badgeLabelText) { + if (m_badgeText == badgeText) { return; } - m_badgeLabelText = badgeLabelText; - emit badgeLabelTextChanged(m_badgeLabelText); + m_badgeText = badgeText; + emit badgeTextChanged(m_badgeText); } WebPage *AbstractButtonInterface::webPage() const { return m_page; } void AbstractButtonInterface::setWebPage(WebPage *page) { if (m_page == page) { return; } m_page = page; emit webPageChanged(m_page); } diff --git a/src/lib/tools/abstractbuttoninterface.h b/src/lib/tools/abstractbuttoninterface.h index 1bcb444e..0a589ac6 100644 --- a/src/lib/tools/abstractbuttoninterface.h +++ b/src/lib/tools/abstractbuttoninterface.h @@ -1,80 +1,80 @@ /* ============================================================ * QupZilla - Qt web browser * Copyright (C) 2018 David Rosca * * 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 . * ============================================================ */ #pragma once #include #include #include #include "qzcommon.h" class WebPage; class QUPZILLA_EXPORT AbstractButtonInterface : public QObject { Q_OBJECT public: struct ClickController { QWidget *visualParent; std::function popupPosition; }; 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); QString title() const; void setTitle(const QString &text); QString toolTip() const; void setToolTip(const QString &toolTip); QIcon icon() const; void setIcon(const QIcon &icon); - QString badgeLabelText() const; - void setBadgeLabelText(const QString &badgeLabelText); + QString badgeText() const; + void setBadgeText(const QString &badgeText); WebPage *webPage() const; void setWebPage(WebPage *page); signals: void activeChanged(bool active); void titleChanged(const QString &title); void toolTipChanged(const QString &toolTip); void iconChanged(const QIcon &icon); - void badgeLabelTextChanged(const QString &badgeLabelText); + void badgeTextChanged(const QString &badgeText); void webPageChanged(WebPage *page); void clicked(ClickController *controller); private: bool m_active = true; QString m_title; QString m_toolTip; QIcon m_icon; - QString m_badgeLabelText; + QString m_badgeText; WebPage *m_page = nullptr; };