diff --git a/autotests/databaseencryptedpasswordbackendtest.h b/autotests/databaseencryptedpasswordbackendtest.h index 2095daca..2862ab9d 100644 --- a/autotests/databaseencryptedpasswordbackendtest.h +++ b/autotests/databaseencryptedpasswordbackendtest.h @@ -1,34 +1,34 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-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 "passwordbackendtest.h" #include "passwordbackends/databaseencryptedpasswordbackend.h" class DatabaseEncryptedPasswordBackendTest : public PasswordBackendTest { Q_OBJECT private: QByteArray m_testMasterPassword; protected: - void reloadBackend(); - void init(); - void cleanup(); + void reloadBackend() override; + void init() override; + void cleanup() override; }; diff --git a/autotests/databasepasswordbackendtest.h b/autotests/databasepasswordbackendtest.h index c083712d..8948b1c3 100644 --- a/autotests/databasepasswordbackendtest.h +++ b/autotests/databasepasswordbackendtest.h @@ -1,31 +1,31 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-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 "passwordbackendtest.h" #include "passwordbackends/databasepasswordbackend.h" class DatabasePasswordBackendTest : public PasswordBackendTest { Q_OBJECT protected: - void reloadBackend(); - void init(); - void cleanup(); + void reloadBackend() override; + void init() override; + void cleanup() override; }; diff --git a/src/lib/3rdparty/fancytabwidget.cpp b/src/lib/3rdparty/fancytabwidget.cpp index de27bbbb..1816ea18 100644 --- a/src/lib/3rdparty/fancytabwidget.cpp +++ b/src/lib/3rdparty/fancytabwidget.cpp @@ -1,747 +1,747 @@ /************************************************************************** ** ** This file is part of Qt Creator ** ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). ** ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** Commercial Usage ** ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://qt.nokia.com/contact. ** **************************************************************************/ #include "fancytabwidget.h" #include "stylehelper.h" #include #include #include #include #include #include #include #include #include #include #include #include #include //#include using namespace Core; using namespace Internal; const int FancyTabBar::m_rounding = 22; const int FancyTabBar::m_textPadding = 4; void FancyTabProxyStyle::drawControl( ControlElement element, const QStyleOption* option, QPainter* p, const QWidget* widget) const { const QStyleOptionTab* v_opt = qstyleoption_cast(option); if (element != CE_TabBarTab || !v_opt) { QProxyStyle::drawControl(element, option, p, widget); return; } const QRect rect = v_opt->rect; const bool selected = v_opt->state & State_Selected; const bool vertical_tabs = v_opt->shape == QTabBar::RoundedWest; const QString text = v_opt->text; if (selected) { //background p->save(); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, QColor(255, 255, 255, 140)); grad.setColorAt(1, QColor(255, 255, 255, 210)); p->fillRect(rect.adjusted(0, 0, 0, -1), grad); p->restore(); //shadows p->setPen(QColor(0, 0, 0, 110)); p->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1)); p->drawLine(rect.bottomLeft(), rect.bottomRight()); p->setPen(QColor(0, 0, 0, 40)); p->drawLine(rect.topLeft(), rect.bottomLeft()); //highlights p->setPen(QColor(255, 255, 255, 50)); p->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2)); p->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1)); p->setPen(QColor(255, 255, 255, 40)); p->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight()); p->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); p->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1)); } QTransform m; if (vertical_tabs) { m = QTransform::fromTranslate(rect.left(), rect.bottom()); m.rotate(-90); } else { m = QTransform::fromTranslate(rect.left(), rect.top()); } const QRect draw_rect(QPoint(0, 0), m.mapRect(rect).size()); p->save(); p->setTransform(m); QRect icon_rect(QPoint(8, 0), v_opt->iconSize); QRect text_rect(icon_rect.topRight() + QPoint(4, 0), draw_rect.size()); text_rect.setRight(draw_rect.width()); icon_rect.translate(0, (draw_rect.height() - icon_rect.height()) / 2); QFont boldFont(p->font()); boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); boldFont.setBold(true); p->setFont(boldFont); p->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); int textFlags = Qt::AlignHCenter | Qt::AlignVCenter; p->drawText(text_rect, textFlags, text); p->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); if (widget) { const QString fader_key = QSL("tab_") + text + QSL("_fader"); const QString animation_key = QSL("tab_") + text + QSL("_animation"); const QString tab_hover = widget->property("tab_hover").toString(); int fader = widget->property(fader_key.toUtf8().constData()).toInt(); QPropertyAnimation* animation = widget->property(animation_key.toUtf8().constData()).value(); if (!animation) { QWidget* mut_widget = const_cast(widget); fader = 0; mut_widget->setProperty(fader_key.toUtf8().constData(), fader); animation = new QPropertyAnimation(mut_widget, fader_key.toUtf8(), mut_widget); connect(animation, SIGNAL(valueChanged(QVariant)), mut_widget, SLOT(update())); mut_widget->setProperty(animation_key.toUtf8().constData(), QVariant::fromValue(animation)); } if (text == tab_hover) { if (animation->state() != QAbstractAnimation::Running && fader != 40) { animation->stop(); animation->setDuration(80); animation->setEndValue(40); animation->start(); } } else { if (animation->state() != QAbstractAnimation::Running && fader != 0) { animation->stop(); animation->setDuration(160); animation->setEndValue(0); animation->start(); } } if (!selected) { p->save(); p->fillRect(draw_rect, QColor(255, 255, 255, fader)); p->setPen(QPen(QColor(255, 255, 255, fader), 1.0)); p->drawLine(draw_rect.topLeft(), vertical_tabs ? draw_rect.bottomLeft() : draw_rect.topRight()); p->drawLine(draw_rect.bottomRight(), vertical_tabs ? draw_rect.topRight() : draw_rect.bottomLeft()); p->restore(); } } Utils::StyleHelper::drawIconWithShadow(v_opt->icon, icon_rect, p, selected ? QIcon::Selected : QIcon::Normal); p->drawText(text_rect.translated(0, -1), textFlags, text); p->restore(); } void FancyTabProxyStyle::polish(QWidget* widget) { if (QString::fromLatin1(widget->metaObject()->className()) == QLatin1String("QTabBar")) { widget->setMouseTracking(true); widget->installEventFilter(this); } QProxyStyle::polish(widget); } void FancyTabProxyStyle::polish(QApplication* app) { QProxyStyle::polish(app); } void FancyTabProxyStyle::polish(QPalette &palette) { QProxyStyle::polish(palette); } bool FancyTabProxyStyle::eventFilter(QObject* o, QEvent* e) { QTabBar* bar = qobject_cast(o); if (bar && (e->type() == QEvent::MouseMove || e->type() == QEvent::Leave)) { QMouseEvent* event = static_cast(e); const QString old_hovered_tab = bar->property("tab_hover").toString(); const QString hovered_tab = e->type() == QEvent::Leave ? QString() : bar->tabText(bar->tabAt(event->pos())); bar->setProperty("tab_hover", hovered_tab); if (old_hovered_tab != hovered_tab) { bar->update(); } } return false; } FancyTab::FancyTab(QWidget* tabbar) : QWidget(tabbar), tabbar(tabbar), m_fader(0) { animator.setPropertyName("fader"); animator.setTargetObject(this); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); } void FancyTab::fadeIn() { animator.stop(); animator.setDuration(80); animator.setEndValue(40); animator.start(); } void FancyTab::fadeOut() { animator.stop(); animator.setDuration(160); animator.setEndValue(0); animator.start(); } void FancyTab::setFader(float value) { m_fader = value; tabbar->update(); } FancyTabBar::FancyTabBar(QWidget* parent) : QWidget(parent) , m_currentIndex(-1) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); //setStyle(new QWindowsStyle); setMinimumWidth(qMax(2 * m_rounding, 40)); setAttribute(Qt::WA_Hover, true); setFocusPolicy(Qt::NoFocus); setMouseTracking(true); // Needed for hover events m_triggerTimer.setSingleShot(true); QVBoxLayout* layout = new QVBoxLayout; layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding)); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); // We use a zerotimer to keep the sidebar responsive connect(&m_triggerTimer, &QTimer::timeout, this, &FancyTabBar::emitCurrentIndex); } FancyTabBar::~FancyTabBar() { delete style(); } QSize FancyTab::sizeHint() const { QFont boldFont(font()); boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); boldFont.setBold(true); QFontMetrics fm(boldFont); int spacing = 8; int width = 60 + spacing + 2; int iconHeight = 32; QSize ret(width, iconHeight + spacing + fm.height()); return ret; } QSize FancyTabBar::tabSizeHint(bool minimum) const { QFont boldFont(font()); boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); boldFont.setBold(true); QFontMetrics fm(boldFont); int spacing = 8; int width = 60 + spacing + 2; int iconHeight = minimum ? 0 : 32; return QSize(width, iconHeight + spacing + fm.height()); } void FancyTabBar::paintEvent(QPaintEvent* event) { Q_UNUSED(event) QPainter p(this); for (int i = 0; i < count(); ++i) if (i != currentIndex()) { paintTab(&p, i); } // paint active tab last, since it overlaps the neighbors if (currentIndex() != -1) { paintTab(&p, currentIndex()); } } void FancyTab::enterEvent(QEvent*) { fadeIn(); } void FancyTab::leaveEvent(QEvent*) { fadeOut(); } QSize FancyTabBar::sizeHint() const { QSize sh = tabSizeHint(); return QSize(sh.width(), sh.height() * m_tabs.count()); } QSize FancyTabBar::minimumSizeHint() const { QSize sh = tabSizeHint(true); return QSize(sh.width(), sh.height() * m_tabs.count()); } QRect FancyTabBar::tabRect(int index) const { return m_tabs[index]->geometry(); } QString FancyTabBar::tabToolTip(int index) const { return m_tabs[index]->toolTip(); } void FancyTabBar::setTabToolTip(int index, const QString &toolTip) { m_tabs[index]->setToolTip(toolTip); } // This keeps the sidebar responsive since // we get a repaint before loading the // mode itself void FancyTabBar::emitCurrentIndex() { emit currentChanged(m_currentIndex); } void FancyTabBar::mousePressEvent(QMouseEvent* e) { e->accept(); for (int index = 0; index < m_tabs.count(); ++index) { if (tabRect(index).contains(e->pos())) { m_currentIndex = index; update(); m_triggerTimer.start(0); break; } } } void FancyTabBar::addTab(const QIcon &icon, const QString &label) { FancyTab* tab = new FancyTab(this); tab->icon = icon; tab->text = label; m_tabs.append(tab); qobject_cast(layout())->insertWidget(layout()->count() - 1, tab); } void FancyTabBar::addSpacer(int size) { qobject_cast(layout())->insertSpacerItem(layout()->count() - 1, new QSpacerItem(0, size, QSizePolicy::Fixed, QSizePolicy::Maximum)); } void FancyTabBar::paintTab(QPainter* painter, int tabIndex) const { if (!validIndex(tabIndex)) { qWarning("invalid index"); return; } painter->save(); QRect rect = tabRect(tabIndex); bool selected = (tabIndex == m_currentIndex); if (selected) { //background painter->save(); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, QColor(255, 255, 255, 140)); grad.setColorAt(1, QColor(255, 255, 255, 210)); painter->fillRect(rect.adjusted(0, 0, 0, -1), grad); painter->restore(); //shadows painter->setPen(QColor(0, 0, 0, 110)); painter->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1)); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->setPen(QColor(0, 0, 0, 40)); painter->drawLine(rect.topLeft(), rect.bottomLeft()); //highlights painter->setPen(QColor(255, 255, 255, 50)); painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2)); painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1)); painter->setPen(QColor(255, 255, 255, 40)); painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight()); painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); painter->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1)); } // QString tabText(painter->fontMetrics().elidedText(this->tabText(tabIndex), Qt::ElideMiddle, width())); QRect tabTextRect(tabRect(tabIndex)); QRect tabIconRect(tabTextRect); tabIconRect.adjust(+4, +4, -4, -4); tabTextRect.translate(0, -2); QFont boldFont(painter->font()); boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); boldFont.setBold(true); painter->setFont(boldFont); painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); // int textFlags = Qt::AlignCenter | Qt::AlignBottom; // painter->drawText(tabTextRect, textFlags, tabText); painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); #ifndef Q_OS_MACOS if (!selected) { painter->save(); int fader = int(m_tabs[tabIndex]->fader()); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, Qt::transparent); grad.setColorAt(0.5, QColor(255, 255, 255, fader)); grad.setColorAt(1, Qt::transparent); // painter->fillRect(rect, grad); // painter->setPen(QPen(grad, 1.0)); painter->fillRect(rect, QColor(255, 255, 255, fader)); painter->setPen(QPen(QColor(255, 255, 255, fader), 1.0)); painter->drawLine(rect.topLeft(), rect.topRight()); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); painter->restore(); } #endif // const int textHeight = painter->fontMetrics().height(); tabIconRect.adjust(0, 6, 0, -6); Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, selected ? QIcon::Selected : QIcon::Normal); painter->translate(0, -1); // painter->drawText(tabTextRect, textFlags, tabText); painter->restore(); } void FancyTabBar::setCurrentIndex(int index) { m_currentIndex = index; update(); emit currentChanged(m_currentIndex); } ////// // FancyColorButton ////// class FALKON_EXPORT FancyColorButton : public QWidget { public: FancyColorButton(QWidget* parent) : m_parent(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); } - void mousePressEvent(QMouseEvent* ev) { + void mousePressEvent(QMouseEvent* ev) override { if (ev->modifiers() & Qt::ShiftModifier) { Utils::StyleHelper::setBaseColor(QColorDialog::getColor(Utils::StyleHelper::requestedBaseColor(), m_parent)); } } private: QWidget* m_parent; }; ////// // FancyTabWidget ////// FancyTabWidget::FancyTabWidget(QWidget* parent) : QWidget(parent), mode_(Mode_None), tab_bar_(nullptr), stack_(new QStackedLayout), side_widget_(new QWidget), side_layout_(new QVBoxLayout), top_layout_(new QVBoxLayout), use_background_(false), menu_(nullptr), proxy_style_(new FancyTabProxyStyle) { side_layout_->setSpacing(0); side_layout_->setContentsMargins(0, 0, 0, 0); side_layout_->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding)); side_widget_->setLayout(side_layout_); side_widget_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); top_layout_->setContentsMargins(0, 0, 0, 0); top_layout_->setSpacing(0); top_layout_->addLayout(stack_); QHBoxLayout* main_layout = new QHBoxLayout; main_layout->setContentsMargins(0, 0, 0, 0); main_layout->setSpacing(1); main_layout->addWidget(side_widget_); main_layout->addLayout(top_layout_); setLayout(main_layout); } void FancyTabWidget::AddTab(QWidget* tab, const QIcon &icon, const QString &label) { stack_->addWidget(tab); items_ << Item(icon, label); } void FancyTabWidget::AddSpacer(int size) { items_ << Item(size); } void FancyTabWidget::SetBackgroundPixmap(const QPixmap &pixmap) { background_pixmap_ = pixmap; update(); } void FancyTabWidget::paintEvent(QPaintEvent*) { if (!use_background_) { return; } QPainter painter(this); QRect rect = side_widget_->rect().adjusted(0, 0, 1, 0); rect = style()->visualRect(layoutDirection(), geometry(), rect); Utils::StyleHelper::verticalGradient(&painter, rect, rect); if (!background_pixmap_.isNull()) { QRect pixmap_rect(background_pixmap_.rect()); pixmap_rect.moveTo(rect.topLeft()); while (pixmap_rect.top() < rect.bottom()) { QRect source_rect(pixmap_rect.intersected(rect)); source_rect.moveTo(0, 0); painter.drawPixmap(pixmap_rect.topLeft(), background_pixmap_, source_rect); pixmap_rect.moveTop(pixmap_rect.bottom() - 10); } } painter.setPen(Utils::StyleHelper::borderColor()); painter.drawLine(rect.topRight(), rect.bottomRight()); QColor light = Utils::StyleHelper::sidebarHighlight(); painter.setPen(light); painter.drawLine(rect.bottomLeft(), rect.bottomRight()); } int FancyTabWidget::current_index() const { return stack_->currentIndex(); } void FancyTabWidget::SetCurrentIndex(int index) { if (FancyTabBar* bar = qobject_cast(tab_bar_)) { bar->setCurrentIndex(index); } else if (QTabBar* bar = qobject_cast(tab_bar_)) { bar->setCurrentIndex(index); } else { stack_->setCurrentIndex(index); } } void FancyTabWidget::ShowWidget(int index) { stack_->setCurrentIndex(index); emit CurrentChanged(index); } void FancyTabWidget::AddBottomWidget(QWidget* widget) { top_layout_->addWidget(widget); } void FancyTabWidget::SetMode(Mode mode) { // Remove previous tab bar delete tab_bar_; tab_bar_ = nullptr; use_background_ = false; // Create new tab bar switch (mode) { case Mode_None: default: qDebug() << "Unknown fancy tab mode" << mode; // fallthrough case Mode_LargeSidebar: { FancyTabBar* bar = new FancyTabBar(this); side_layout_->insertWidget(0, bar); tab_bar_ = bar; foreach (const Item &item, items_) { if (item.type_ == Item::Type_Spacer) { bar->addSpacer(item.spacer_size_); } else { bar->addTab(item.tab_icon_, item.tab_label_); } } bar->setCurrentIndex(stack_->currentIndex()); connect(bar, &FancyTabBar::currentChanged, this, &FancyTabWidget::ShowWidget); use_background_ = true; break; } case Mode_Tabs: MakeTabBar(QTabBar::RoundedNorth, true, false, false); break; case Mode_IconOnlyTabs: MakeTabBar(QTabBar::RoundedNorth, false, true, false); break; case Mode_SmallSidebar: MakeTabBar(QTabBar::RoundedWest, true, true, true); use_background_ = true; break; case Mode_PlainSidebar: MakeTabBar(QTabBar::RoundedWest, true, true, false); break; } tab_bar_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); mode_ = mode; emit ModeChanged(mode); update(); } void FancyTabWidget::contextMenuEvent(QContextMenuEvent* e) { Q_UNUSED(e) // if (!menu_) { // menu_ = new QMenu(this); // QSignalMapper* mapper = new QSignalMapper(this); // QActionGroup* group = new QActionGroup(this); // AddMenuItem(mapper, group, tr("Large sidebar"), Mode_LargeSidebar); // AddMenuItem(mapper, group, tr("Small sidebar"), Mode_SmallSidebar); // AddMenuItem(mapper, group, tr("Plain sidebar"), Mode_PlainSidebar); // AddMenuItem(mapper, group, tr("Tabs on top"), Mode_Tabs); // AddMenuItem(mapper, group, tr("Icons on top"), Mode_IconOnlyTabs); // menu_->addActions(group->actions()); // connect(mapper, SIGNAL(mapped(int)), SLOT(SetMode(int))); // } // menu_->popup(e->globalPos()); } void FancyTabWidget::AddMenuItem(QSignalMapper* mapper, QActionGroup* group, const QString &text, Mode mode) { QAction* action = group->addAction(text); action->setCheckable(true); mapper->setMapping(action, mode); connect(action, SIGNAL(triggered()), mapper, SLOT(map())); if (mode == mode_) { action->setChecked(true); } } void FancyTabWidget::MakeTabBar(QTabBar::Shape shape, bool text, bool icons, bool fancy) { QTabBar* bar = new QTabBar(this); bar->setShape(shape); bar->setDocumentMode(true); bar->setUsesScrollButtons(true); if (shape == QTabBar::RoundedWest) { bar->setIconSize(QSize(22, 22)); } if (fancy) { bar->setStyle(proxy_style_); } if (shape == QTabBar::RoundedNorth) { top_layout_->insertWidget(0, bar); } else { side_layout_->insertWidget(0, bar); } foreach (const Item &item, items_) { if (item.type_ != Item::Type_Tab) { continue; } QString label = item.tab_label_; if (shape == QTabBar::RoundedWest) { label = QFontMetrics(font()).elidedText(label, Qt::ElideMiddle, 100); } int tab_id = -1; if (icons && text) { tab_id = bar->addTab(item.tab_icon_, label); } else if (icons) { tab_id = bar->addTab(item.tab_icon_, QString()); } else if (text) { tab_id = bar->addTab(label); } bar->setTabToolTip(tab_id, item.tab_label_); } bar->setCurrentIndex(stack_->currentIndex()); connect(bar, &QTabBar::currentChanged, this, &FancyTabWidget::ShowWidget); tab_bar_ = bar; } diff --git a/src/lib/3rdparty/lineedit.h b/src/lib/3rdparty/lineedit.h index fc8d35d0..7f19ada8 100644 --- a/src/lib/3rdparty/lineedit.h +++ b/src/lib/3rdparty/lineedit.h @@ -1,162 +1,162 @@ #ifndef LINEEDIT_H #define LINEEDIT_H /** * Copyright (c) 2008 - 2009, Benjamin C. Meyer * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Benjamin Meyer nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2017 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 #include #include "qzcommon.h" class QHBoxLayout; /* LineEdit is a subclass of QLineEdit that provides an easy and simple way to add widgets on the left or right hand side of the text. The layout of the widgets on either side are handled by a QHBoxLayout. You can set the spacing around the widgets with setWidgetSpacing(). As widgets are added to the class they are inserted from the outside into the center of the widget. */ class SideWidget; class FALKON_EXPORT LineEdit : public QLineEdit { Q_OBJECT Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize) Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin) Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth) Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight) Q_PROPERTY(int minHeight READ minHeight WRITE setMinHeight) public: typedef QList TextFormat; enum WidgetPosition { LeftSide, RightSide }; enum EditAction { Undo = 0, Redo = 1, Cut = 2, Copy = 3, Paste = 4, PasteAndGo = 5, Delete = 6, ClearAll = 7, SelectAll = 8 }; LineEdit(QWidget* parent = 0); void addWidget(QWidget* widget, WidgetPosition position); void removeWidget(QWidget* widget); void setWidgetSpacing(int spacing); int widgetSpacing() const; int leftMargin() const; void setTextFormat(const TextFormat &format); void clearTextFormat(); int minHeight() const; void setMinHeight(int height); QSize sizeHint() const override; QAction* editAction(EditAction action) const; public Q_SLOTS: void setLeftMargin(int margin); void updateTextMargins(); protected: void focusInEvent(QFocusEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; void mouseDoubleClickEvent(QMouseEvent* event) override; void resizeEvent(QResizeEvent *event) override; bool event(QEvent* event) override; QMenu* createContextMenu(); private Q_SLOTS: void updateActions(); void updatePasteActions(); void slotDelete(); private: void init(); SideWidget* m_leftWidget; SideWidget* m_rightWidget; QHBoxLayout* m_leftLayout; QHBoxLayout* m_rightLayout; QHBoxLayout* mainLayout; QAction* m_editActions[9]; int m_minHeight; int m_leftMargin; bool m_ignoreMousePress; }; class FALKON_EXPORT SideWidget : public QWidget { Q_OBJECT Q_SIGNALS: void sizeHintChanged(); public: SideWidget(QWidget* parent = 0); protected: - bool event(QEvent* event); + bool event(QEvent* event) override; }; #endif // LINEEDIT_H diff --git a/src/lib/3rdparty/qtsingleapplication/qtlockedfile.h b/src/lib/3rdparty/qtsingleapplication/qtlockedfile.h index 84c18e5c..c7f51f4f 100644 --- a/src/lib/3rdparty/qtsingleapplication/qtlockedfile.h +++ b/src/lib/3rdparty/qtsingleapplication/qtlockedfile.h @@ -1,97 +1,97 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Solutions component. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QTLOCKEDFILE_H #define QTLOCKEDFILE_H #include #ifdef Q_OS_WIN #include #endif #if defined(Q_OS_WIN) # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) # define QT_QTLOCKEDFILE_EXPORT # elif defined(QT_QTLOCKEDFILE_IMPORT) # if defined(QT_QTLOCKEDFILE_EXPORT) # undef QT_QTLOCKEDFILE_EXPORT # endif # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) # elif defined(QT_QTLOCKEDFILE_EXPORT) # undef QT_QTLOCKEDFILE_EXPORT # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) # endif #else # define QT_QTLOCKEDFILE_EXPORT #endif namespace QtLP_Private { class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { public: enum LockMode { NoLock = 0, ReadLock, WriteLock }; QtLockedFile(); QtLockedFile(const QString &name); ~QtLockedFile(); - bool open(OpenMode mode); + bool open(OpenMode mode) override; bool lock(LockMode mode, bool block = true); bool unlock(); bool isLocked() const; LockMode lockMode() const; private: #ifdef Q_OS_WIN Qt::HANDLE wmutex; Qt::HANDLE rmutex; QVector rmutexes; QString mutexname; Qt::HANDLE getMutexHandle(int idx, bool doCreate); bool waitMutex(Qt::HANDLE mutex, bool doBlock); #endif LockMode m_lock_mode; }; } #endif diff --git a/src/lib/adblock/adblocksubscription.h b/src/lib/adblock/adblocksubscription.h index c48931d7..9a235d86 100644 --- a/src/lib/adblock/adblocksubscription.h +++ b/src/lib/adblock/adblocksubscription.h @@ -1,136 +1,136 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2016 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 . * ============================================================ */ /** * Copyright (c) 2009, Benjamin C. Meyer * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Benjamin Meyer nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef ADBLOCKSUBSCRIPTION_H #define ADBLOCKSUBSCRIPTION_H #include #include #include "qzcommon.h" #include "adblockrule.h" #include "adblocksearchtree.h" class QUrl; class QNetworkReply; class FALKON_EXPORT AdBlockSubscription : public QObject { Q_OBJECT public: explicit AdBlockSubscription(const QString &title, QObject* parent = nullptr); ~AdBlockSubscription(); QString title() const; QString filePath() const; void setFilePath(const QString &path); QUrl url() const; void setUrl(const QUrl &url); virtual void loadSubscription(const QStringList &disabledRules); virtual void saveSubscription(); const AdBlockRule* rule(int offset) const; QVector allRules() const; const AdBlockRule* enableRule(int offset); const AdBlockRule* disableRule(int offset); virtual bool canEditRules() const; virtual bool canBeRemoved() const; virtual int addRule(AdBlockRule* rule); virtual bool removeRule(int offset); virtual const AdBlockRule* replaceRule(AdBlockRule* rule, int offset); public Q_SLOTS: void updateSubscription(); Q_SIGNALS: void subscriptionChanged(); void subscriptionUpdated(); void subscriptionError(const QString &message); protected Q_SLOTS: void subscriptionDownloaded(); protected: virtual bool saveDownloadedData(const QByteArray &data); QNetworkReply *m_reply; QVector m_rules; private: QString m_title; QString m_filePath; QUrl m_url; bool m_updated; }; class AdBlockCustomList : public AdBlockSubscription { Q_OBJECT public: explicit AdBlockCustomList(QObject* parent = nullptr); - void loadSubscription(const QStringList &disabledRules); - void saveSubscription(); + void loadSubscription(const QStringList &disabledRules) override; + void saveSubscription() override; - bool canEditRules() const; - bool canBeRemoved() const; + bool canEditRules() const override; + bool canBeRemoved() const override; bool containsFilter(const QString &filter) const; bool removeFilter(const QString &filter); - int addRule(AdBlockRule* rule); - bool removeRule(int offset); - const AdBlockRule* replaceRule(AdBlockRule* rule, int offset); + int addRule(AdBlockRule* rule) override; + bool removeRule(int offset) override; + const AdBlockRule* replaceRule(AdBlockRule* rule, int offset) override; }; #endif // ADBLOCKSUBSCRIPTION_H diff --git a/src/lib/adblock/adblocktreewidget.h b/src/lib/adblock/adblocktreewidget.h index 35fb2d54..a2c040a3 100644 --- a/src/lib/adblock/adblocktreewidget.h +++ b/src/lib/adblock/adblocktreewidget.h @@ -1,61 +1,61 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef ADBLOCKTREEWIDGET_H #define ADBLOCKTREEWIDGET_H #include "qzcommon.h" #include "treewidget.h" class AdBlockSubscription; class AdBlockRule; class FALKON_EXPORT AdBlockTreeWidget : public TreeWidget { Q_OBJECT public: explicit AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* parent = 0); AdBlockSubscription* subscription() const; void showRule(const AdBlockRule* rule); void refresh(); public Q_SLOTS: void addRule(); void removeRule(); private Q_SLOTS: void contextMenuRequested(const QPoint &pos); void itemChanged(QTreeWidgetItem* item); void copyFilter(); void subscriptionUpdated(); void subscriptionError(const QString &message); private: void adjustItemFeatures(QTreeWidgetItem* item, const AdBlockRule* rule); - void keyPressEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent* event) override; AdBlockSubscription* m_subscription; QTreeWidgetItem* m_topItem; QString m_ruleToBeSelected; bool m_itemChangingBlock; }; #endif // ADBLOCKTREEWIDGET_H diff --git a/src/lib/adblock/adblockurlinterceptor.h b/src/lib/adblock/adblockurlinterceptor.h index 9cc4b049..733040b5 100644 --- a/src/lib/adblock/adblockurlinterceptor.h +++ b/src/lib/adblock/adblockurlinterceptor.h @@ -1,44 +1,44 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2015-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 . * ============================================================ */ #ifndef ADBLOCKURLINTERCEPTOR_H #define ADBLOCKURLINTERCEPTOR_H #include "qzcommon.h" #include "urlinterceptor.h" #include "adblockmanager.h" class AdBlockManager; class FALKON_EXPORT AdBlockUrlInterceptor : public UrlInterceptor { Q_OBJECT public: explicit AdBlockUrlInterceptor(AdBlockManager *manager); - void interceptRequest(QWebEngineUrlRequestInfo &request); + void interceptRequest(QWebEngineUrlRequestInfo &request) override; Q_SIGNALS: void requestBlocked(const AdBlockedRequest &request); private: AdBlockManager *m_manager; }; #endif // ADBLOCKURLINTERCEPTOR_H diff --git a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.h b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.h index eae74ed9..202e54e1 100644 --- a/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.h +++ b/src/lib/autofill/passwordbackends/databaseencryptedpasswordbackend.h @@ -1,142 +1,142 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 S. Razi Alavizadeh * Copyright (C) 2013-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 . * ============================================================ */ #ifndef DATABASEENCRYPTEDPASSWORDBACKEND_H #define DATABASEENCRYPTEDPASSWORDBACKEND_H #include "passwordbackend.h" #include "qzcommon.h" #include class AesInterface; class MasterPasswordDialog; class FALKON_EXPORT DatabaseEncryptedPasswordBackend : public PasswordBackend { public: enum MasterPasswordState { PasswordIsSetted, PasswordIsNotSetted, UnKnownState = -1 }; explicit DatabaseEncryptedPasswordBackend(); ~DatabaseEncryptedPasswordBackend(); - QStringList getUsernames(const QUrl &url); - QVector getEntries(const QUrl &url); - QVector getAllEntries(); + QStringList getUsernames(const QUrl &url) override; + QVector getEntries(const QUrl &url) override; + QVector getAllEntries() override; - void setActive(bool active); + void setActive(bool active) override; - void addEntry(const PasswordEntry &entry); - bool updateEntry(const PasswordEntry &entry); - void updateLastUsed(PasswordEntry &entry); + void addEntry(const PasswordEntry &entry) override; + bool updateEntry(const PasswordEntry &entry) override; + void updateLastUsed(PasswordEntry &entry) override; - void removeEntry(const PasswordEntry &entry); - void removeAll(); + void removeEntry(const PasswordEntry &entry) override; + void removeAll() override; - QString name() const; + QString name() const override; - bool hasSettings() const; - void showSettings(QWidget* parent); + bool hasSettings() const override; + void showSettings(QWidget* parent) override; bool isMasterPasswordSetted(); QByteArray masterPassword() const; bool hasPermission(); bool isPasswordVerified(const QByteArray &password); bool decryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface); bool encryptPasswordEntry(PasswordEntry &entry, AesInterface* aesInterface); void tryToChangeMasterPassword(const QByteArray &newPassword); void removeMasterPassword(); void setAskMasterPasswordState(bool ask); void encryptDataBaseTableOnFly(const QByteArray &decryptorPassword, const QByteArray &encryptorPassword); void updateSampleData(const QByteArray &password); void showMasterPasswordDialog(); private: QByteArray someDataFromDatabase(); MasterPasswordState m_stateOfMasterPassword; QByteArray m_someDataStoredOnDataBase; bool m_askPasswordDialogVisible; bool m_askMasterPassword; QByteArray m_masterPassword; }; namespace Ui { class MasterPasswordDialog; } class MasterPasswordDialog : public QDialog { Q_OBJECT public: explicit MasterPasswordDialog(DatabaseEncryptedPasswordBackend* backend, QWidget* parent = 0); ~MasterPasswordDialog(); void delayedExec(); public Q_SLOTS: - void accept(); - void reject(); + void accept() override; + void reject() override; void showSettingPage(); void showSetMasterPasswordPage(); void clearMasterPasswordAndConvert(bool forcedAskPass = true); bool samePasswordEntry(const PasswordEntry &entry1, const PasswordEntry &entry2); private: Ui::MasterPasswordDialog* ui; DatabaseEncryptedPasswordBackend* m_backend; }; class QDialogButtonBox; class QLineEdit; class QLabel; class AskMasterPassword : public QDialog { Q_OBJECT public: explicit AskMasterPassword(DatabaseEncryptedPasswordBackend* backend, QWidget* parent = 0); private Q_SLOTS: void verifyPassword(); private: DatabaseEncryptedPasswordBackend* m_backend; QDialogButtonBox* m_buttonBox; QLineEdit* m_lineEdit; QLabel* m_labelWarning; }; #endif // DATABASEENCRYPTEDPASSWORDBACKEND_H diff --git a/src/lib/autofill/passwordbackends/databasepasswordbackend.h b/src/lib/autofill/passwordbackends/databasepasswordbackend.h index d651f7a9..7a3933a1 100644 --- a/src/lib/autofill/passwordbackends/databasepasswordbackend.h +++ b/src/lib/autofill/passwordbackends/databasepasswordbackend.h @@ -1,42 +1,42 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 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 . * ============================================================ */ #ifndef DATABASEPASSWORDBACKEND_H #define DATABASEPASSWORDBACKEND_H #include "passwordbackend.h" #include "qzcommon.h" class FALKON_EXPORT DatabasePasswordBackend : public PasswordBackend { public: explicit DatabasePasswordBackend(); - QString name() const; + QString name() const override; - QVector getEntries(const QUrl &url); - QVector getAllEntries(); + QVector getEntries(const QUrl &url) override; + QVector getAllEntries() override; - void addEntry(const PasswordEntry &entry); - bool updateEntry(const PasswordEntry &entry); - void updateLastUsed(PasswordEntry &entry); + void addEntry(const PasswordEntry &entry) override; + bool updateEntry(const PasswordEntry &entry) override; + void updateLastUsed(PasswordEntry &entry) override; - void removeEntry(const PasswordEntry &entry); - void removeAll(); + void removeEntry(const PasswordEntry &entry) override; + void removeAll() override; }; #endif // DATABASEPASSWORDBACKEND_H diff --git a/src/lib/bookmarks/bookmarksexport/htmlexporter.h b/src/lib/bookmarks/bookmarksexport/htmlexporter.h index 3003ccac..99346c09 100644 --- a/src/lib/bookmarks/bookmarksexport/htmlexporter.h +++ b/src/lib/bookmarks/bookmarksexport/htmlexporter.h @@ -1,42 +1,42 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2014 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 . * ============================================================ */ #ifndef HTMLEXPORTER_H #define HTMLEXPORTER_H #include "bookmarksexporter.h" class QTextStream; class BookmarkItem; class HtmlExporter : public BookmarksExporter { public: explicit HtmlExporter(QObject* parent = 0); - QString name() const; - QString getPath(QWidget* parent); - bool exportBookmarks(BookmarkItem* root); + QString name() const override; + QString getPath(QWidget* parent) override; + bool exportBookmarks(BookmarkItem* root) override; private: void writeBookmark(BookmarkItem* item, QTextStream &stream, int level); QString m_path; }; #endif // HTMLEXPORTER_H diff --git a/src/lib/bookmarks/bookmarksimport/chromeimporter.h b/src/lib/bookmarks/bookmarksimport/chromeimporter.h index 1f5bfb74..0ad6a975 100644 --- a/src/lib/bookmarks/bookmarksimport/chromeimporter.h +++ b/src/lib/bookmarks/bookmarksimport/chromeimporter.h @@ -1,46 +1,46 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef CHROMEIMPORTER_H #define CHROMEIMPORTER_H #include #include #include "bookmarksimporter.h" class FALKON_EXPORT ChromeImporter : public BookmarksImporter { public: explicit ChromeImporter(QObject* parent = 0); - QString description() const; - QString standardPath() const; + QString description() const override; + QString standardPath() const override; - QString getPath(QWidget* parent); - bool prepareImport(); + QString getPath(QWidget* parent) override; + bool prepareImport() override; - BookmarkItem* importBookmarks(); + BookmarkItem* importBookmarks() override; private: void readBookmarks(const QVariantList &list, BookmarkItem* parent); QString m_path; QFile m_file; }; #endif // CHROMEIMPORTER_H diff --git a/src/lib/bookmarks/bookmarksimport/firefoximporter.h b/src/lib/bookmarks/bookmarksimport/firefoximporter.h index 376c9e22..42aa0368 100644 --- a/src/lib/bookmarks/bookmarksimport/firefoximporter.h +++ b/src/lib/bookmarks/bookmarksimport/firefoximporter.h @@ -1,62 +1,62 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef FIREFOXIMPORTER_H #define FIREFOXIMPORTER_H #include #include "bookmarksimporter.h" #include "bookmarkitem.h" class FALKON_EXPORT FirefoxImporter : public BookmarksImporter { public: explicit FirefoxImporter(QObject* parent = 0); ~FirefoxImporter(); - QString description() const; - QString standardPath() const; + QString description() const override; + QString standardPath() const override; - QString getPath(QWidget* parent); - bool prepareImport(); + QString getPath(QWidget* parent) override; + bool prepareImport() override; - BookmarkItem* importBookmarks(); + BookmarkItem* importBookmarks() override; private: enum Type { Url, Folder, Separator, Invalid }; struct Item { int id; int parent; BookmarkItem::Type type; QString title; QUrl url; }; BookmarkItem::Type typeFromValue(int value); QString m_path; }; #endif // FIREFOXIMPORTER_H diff --git a/src/lib/bookmarks/bookmarksimport/htmlimporter.h b/src/lib/bookmarks/bookmarksimport/htmlimporter.h index 1ce0ffe0..41c7cf7b 100644 --- a/src/lib/bookmarks/bookmarksimport/htmlimporter.h +++ b/src/lib/bookmarks/bookmarksimport/htmlimporter.h @@ -1,43 +1,43 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef HTMLIMPORTER_H #define HTMLIMPORTER_H #include #include "bookmarksimporter.h" class FALKON_EXPORT HtmlImporter : public BookmarksImporter { public: explicit HtmlImporter(QObject* parent = 0); - QString description() const; - QString standardPath() const; + QString description() const override; + QString standardPath() const override; - QString getPath(QWidget* parent); - bool prepareImport(); + QString getPath(QWidget* parent) override; + bool prepareImport() override; - BookmarkItem* importBookmarks(); + BookmarkItem* importBookmarks() override; private: QString m_path; QFile m_file; }; #endif // HTMLIMPORTER_H diff --git a/src/lib/bookmarks/bookmarksimport/ieimporter.h b/src/lib/bookmarks/bookmarksimport/ieimporter.h index 2991baca..eae9aef5 100644 --- a/src/lib/bookmarks/bookmarksimport/ieimporter.h +++ b/src/lib/bookmarks/bookmarksimport/ieimporter.h @@ -1,44 +1,44 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 Mattias Cibien * * 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 . * ============================================================ */ #ifndef IEIMPORTER_H #define IEIMPORTER_H #include #include "bookmarksimporter.h" class IeImporter : public BookmarksImporter { public: explicit IeImporter(QObject* parent = 0); - QString description() const; - QString standardPath() const; + QString description() const override; + QString standardPath() const override; - QString getPath(QWidget* parent); - bool prepareImport(); + QString getPath(QWidget* parent) override; + bool prepareImport() override; - BookmarkItem* importBookmarks(); + BookmarkItem* importBookmarks() override; private: void readDir(const QDir &dir, BookmarkItem* parent); QString m_path; }; #endif // IEIMPORTER_H diff --git a/src/lib/bookmarks/bookmarksimport/operaimporter.h b/src/lib/bookmarks/bookmarksimport/operaimporter.h index bb5ca64b..0d0e2544 100644 --- a/src/lib/bookmarks/bookmarksimport/operaimporter.h +++ b/src/lib/bookmarks/bookmarksimport/operaimporter.h @@ -1,59 +1,59 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef OPERAIMPORTER_H #define OPERAIMPORTER_H #include #include #include "bookmarksimporter.h" class FALKON_EXPORT OperaImporter : public BookmarksImporter { public: explicit OperaImporter(QObject* parent = 0); - QString description() const; - QString standardPath() const; + QString description() const override; + QString standardPath() const override; - QString getPath(QWidget* parent); - bool prepareImport(); + QString getPath(QWidget* parent) override; + bool prepareImport() override; - BookmarkItem* importBookmarks(); + BookmarkItem* importBookmarks() override; private: enum Token { EmptyLine, StartFolder, EndFolder, StartUrl, StartSeparator, StartDeleted, KeyValuePair, Invalid }; Token parseLine(const QString &line); QString m_key; QString m_value; QString m_path; QFile m_file; QTextStream m_stream; }; #endif // OPERAIMPORTER_H diff --git a/src/lib/downloads/downloadmanager.cpp b/src/lib/downloads/downloadmanager.cpp index 683a6584..09eab397 100644 --- a/src/lib/downloads/downloadmanager.cpp +++ b/src/lib/downloads/downloadmanager.cpp @@ -1,516 +1,517 @@ /* ============================================================ * 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 "downloadmanager.h" #include "ui_downloadmanager.h" #include "browserwindow.h" #include "mainapplication.h" #include "downloadoptionsdialog.h" #include "downloaditem.h" #include "networkmanager.h" #include "desktopnotificationsfactory.h" #include "qztools.h" #include "webpage.h" #include "webview.h" #include "settings.h" #include "datapaths.h" #include "tabwidget.h" #include "tabbedwebview.h" #include "tabbar.h" #include "locationbar.h" #include #include #include #include #include #include #include #include #ifdef Q_OS_WIN #include #include #include #include #endif DownloadManager::DownloadManager(QWidget* parent) : QWidget(parent) , ui(new Ui::DownloadManager) , m_isClosing(false) , m_lastDownloadOption(NoOption) { setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint); ui->setupUi(this); #ifdef Q_OS_WIN if (QtWin::isCompositionEnabled()) { QtWin::extendFrameIntoClientArea(this, -1, -1, -1, -1); } #endif ui->clearButton->setIcon(QIcon::fromTheme("edit-clear")); QzTools::centerWidgetOnScreen(this); connect(ui->clearButton, &QAbstractButton::clicked, this, &DownloadManager::clearList); QShortcut* clearShortcut = new QShortcut(QKeySequence("CTRL+L"), this); connect(clearShortcut, &QShortcut::activated, this, &DownloadManager::clearList); loadSettings(); QzTools::setWmClass("Download Manager", this); } void DownloadManager::loadSettings() { Settings settings; settings.beginGroup("DownloadManager"); m_downloadPath = settings.value("defaultDownloadPath", QString()).toString(); m_lastDownloadPath = settings.value("lastDownloadPath", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)).toString(); m_closeOnFinish = settings.value("CloseManagerOnFinish", false).toBool(); m_useNativeDialog = settings.value("useNativeDialog", DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG).toBool(); m_useExternalManager = settings.value("UseExternalManager", false).toBool(); m_externalExecutable = settings.value("ExternalManagerExecutable", QString()).toString(); m_externalArguments = settings.value("ExternalManagerArguments", QString()).toString(); settings.endGroup(); if (!m_externalArguments.contains(QLatin1String("%d"))) { m_externalArguments.append(QLatin1String(" %d")); } } void DownloadManager::show() { m_timer.start(500, this); QWidget::show(); raise(); activateWindow(); } void DownloadManager::resizeEvent(QResizeEvent* e) { QWidget::resizeEvent(e); emit resized(size()); } void DownloadManager::keyPressEvent(QKeyEvent* e) { if (e->key() == Qt::Key_Escape || (e->key() == Qt::Key_W && e->modifiers() == Qt::ControlModifier)) { close(); } QWidget::keyPressEvent(e); } void DownloadManager::closeDownloadTab(QWebEngineDownloadItem *item) const { // Attempt to close empty tab that was opened only for loading the download url auto testWebView = [](TabbedWebView *view, const QUrl &url) { if (!view->webTab()->isRestored()) { return false; } if (view->browserWindow()->tabWidget()->tabBar()->normalTabsCount() < 2) { return false; } WebPage *page = view->page(); if (page->history()->count() != 0) { return false; } #if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0) + Q_UNUSED(url) return true; #else if (page->url() != QUrl()) { return false; } QUrl tabUrl = page->requestedUrl(); if (tabUrl.isEmpty()) { tabUrl = QUrl(view->webTab()->locationBar()->text()); } return tabUrl.host() == url.host(); #endif }; #if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0) if (!item->page()) { return; } WebPage *page = qobject_cast(item->page()); if (!page) { return; } TabbedWebView *view = qobject_cast(page->view()); if (!view) { return; } if (testWebView(view, QUrl())) { view->closeView(); } #else BrowserWindow* mainWindow = mApp->getWindow(); // If the main window was closed, there is no need to go further if (mainWindow == nullptr) { return; } if (testWebView(mainWindow->weView(), item->url())) { mainWindow->weView()->closeView(); return; } const auto windows = mApp->windows(); for (auto *window : windows) { const auto tabs = window->tabWidget()->allTabs(); for (auto *tab : tabs) { auto *view = tab->webView(); if (testWebView(view, item->url())) { view->closeView(); return; } } } #endif } QWinTaskbarButton *DownloadManager::taskbarButton() { #ifdef Q_OS_WIN if (!m_taskbarButton) { BrowserWindow *window = mApp->getWindow(); m_taskbarButton = new QWinTaskbarButton(window ? window->windowHandle() : windowHandle()); m_taskbarButton->progress()->setRange(0, 100); } return m_taskbarButton; #else return nullptr; #endif } void DownloadManager::startExternalManager(const QUrl &url) { QString arguments = m_externalArguments; arguments.replace(QLatin1String("%d"), url.toEncoded()); QzTools::startExternalProcess(m_externalExecutable, arguments); m_lastDownloadOption = ExternalManager; } void DownloadManager::timerEvent(QTimerEvent* e) { QVector remTimes; QVector progresses; QVector speeds; if (e->timerId() == m_timer.timerId()) { if (!ui->list->count()) { ui->speedLabel->clear(); setWindowTitle(tr("Download Manager")); #ifdef Q_OS_WIN taskbarButton()->progress()->hide(); #endif return; } for (int i = 0; i < ui->list->count(); i++) { DownloadItem* downItem = qobject_cast(ui->list->itemWidget(ui->list->item(i))); if (!downItem || downItem->isCancelled() || !downItem->isDownloading()) { continue; } progresses.append(downItem->progress()); remTimes.append(downItem->remainingTime()); speeds.append(downItem->currentSpeed()); } if (remTimes.isEmpty()) { return; } QTime remaining; foreach (const QTime &time, remTimes) { if (time > remaining) { remaining = time; } } int progress = 0; foreach (int prog, progresses) { progress += prog; } progress = progress / progresses.count(); double speed = 0.00; foreach (double spee, speeds) { speed += spee; } #ifndef Q_OS_WIN ui->speedLabel->setText(tr("%1% of %2 files (%3) %4 remaining").arg(QString::number(progress), QString::number(progresses.count()), DownloadItem::currentSpeedToString(speed), DownloadItem::remaingTimeToString(remaining))); #endif setWindowTitle(tr("%1% - Download Manager").arg(progress)); #ifdef Q_OS_WIN taskbarButton()->progress()->show(); taskbarButton()->progress()->setValue(progress); #endif } QWidget::timerEvent(e); } void DownloadManager::clearList() { QList items; for (int i = 0; i < ui->list->count(); i++) { DownloadItem* downItem = qobject_cast(ui->list->itemWidget(ui->list->item(i))); if (!downItem) { continue; } if (downItem->isDownloading()) { continue; } items.append(downItem); } qDeleteAll(items); emit downloadsCountChanged(); } void DownloadManager::download(QWebEngineDownloadItem *downloadItem) { QTime downloadTimer; downloadTimer.start(); closeDownloadTab(downloadItem); QString downloadPath; bool openFile = false; const QString fileName = QFileInfo(downloadItem->path()).fileName(); const bool forceAsk = downloadItem->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat || downloadItem->type() == QWebEngineDownloadItem::UserRequested; if (m_useExternalManager) { startExternalManager(downloadItem->url()); } else if (forceAsk || m_downloadPath.isEmpty()) { enum Result { Open = 1, Save = 2, ExternalManager = 3, SavePage = 4, Unknown = 0 }; Result result = Unknown; if (downloadItem->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat) { // Save Page requested result = SavePage; } else if (downloadItem->type() == QWebEngineDownloadItem::UserRequested) { // Save x as... requested result = Save; } else { // Ask what to do DownloadOptionsDialog optionsDialog(fileName, downloadItem, mApp->activeWindow()); optionsDialog.showExternalManagerOption(m_useExternalManager); optionsDialog.setLastDownloadOption(m_lastDownloadOption); result = Result(optionsDialog.exec()); } switch (result) { case Open: openFile = true; downloadPath = QzTools::ensureUniqueFilename(DataPaths::path(DataPaths::Temp) + QLatin1Char('/') + fileName); m_lastDownloadOption = OpenFile; break; case Save: downloadPath = QFileDialog::getSaveFileName(mApp->activeWindow(), tr("Save file as..."), m_lastDownloadPath + QLatin1Char('/') + fileName); if (!downloadPath.isEmpty()) { m_lastDownloadPath = QFileInfo(downloadPath).absolutePath(); Settings().setValue(QSL("DownloadManager/lastDownloadPath"), m_lastDownloadPath); m_lastDownloadOption = SaveFile; } break; case SavePage: { const QString mhtml = tr("MIME HTML Archive (*.mhtml)"); const QString htmlSingle = tr("HTML Page, single (*.html)"); const QString htmlComplete = tr("HTML Page, complete (*.html)"); const QString filter = QStringLiteral("%1;;%2;;%3").arg(mhtml, htmlSingle, htmlComplete); QString selectedFilter; downloadPath = QFileDialog::getSaveFileName(mApp->activeWindow(), tr("Save page as..."), m_lastDownloadPath + QLatin1Char('/') + fileName, filter, &selectedFilter); if (!downloadPath.isEmpty()) { m_lastDownloadPath = QFileInfo(downloadPath).absolutePath(); Settings().setValue(QSL("DownloadManager/lastDownloadPath"), m_lastDownloadPath); m_lastDownloadOption = SaveFile; QWebEngineDownloadItem::SavePageFormat format = QWebEngineDownloadItem::UnknownSaveFormat; if (selectedFilter == mhtml) { format = QWebEngineDownloadItem::MimeHtmlSaveFormat; } else if (selectedFilter == htmlSingle) { format = QWebEngineDownloadItem::SingleHtmlSaveFormat; } else if (selectedFilter == htmlComplete) { format = QWebEngineDownloadItem::CompleteHtmlSaveFormat; } if (format != QWebEngineDownloadItem::UnknownSaveFormat) { downloadItem->setSavePageFormat(format); } } break; } case ExternalManager: startExternalManager(downloadItem->url()); // fallthrough default: downloadItem->cancel(); return; } } else { downloadPath = QzTools::ensureUniqueFilename(m_downloadPath + QL1C('/') + fileName); } if (downloadPath.isEmpty()) { downloadItem->cancel(); return; } // Set download path and accept downloadItem->setPath(downloadPath); downloadItem->accept(); // Create download item QListWidgetItem* listItem = new QListWidgetItem(ui->list); DownloadItem* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), QFileInfo(downloadPath).fileName(), openFile, this); downItem->setDownTimer(downloadTimer); downItem->startDownloading(); connect(downItem, &DownloadItem::deleteItem, this, &DownloadManager::deleteItem); connect(downItem, &DownloadItem::downloadFinished, this, &DownloadManager::downloadFinished); ui->list->setItemWidget(listItem, downItem); listItem->setSizeHint(downItem->sizeHint()); downItem->show(); m_activeDownloadsCount++; emit downloadsCountChanged(); } int DownloadManager::downloadsCount() const { return ui->list->count(); } int DownloadManager::activeDownloadsCount() const { return m_activeDownloadsCount; } void DownloadManager::downloadFinished(bool success) { m_activeDownloadsCount = 0; bool downloadingAllFilesFinished = true; for (int i = 0; i < ui->list->count(); i++) { DownloadItem* downItem = qobject_cast(ui->list->itemWidget(ui->list->item(i))); if (!downItem) { continue; } if (downItem->isDownloading()) { m_activeDownloadsCount++; } if (downItem->isCancelled() || !downItem->isDownloading()) { continue; } downloadingAllFilesFinished = false; } emit downloadsCountChanged(); if (downloadingAllFilesFinished) { if (success && qApp->activeWindow() != this) { mApp->desktopNotifications()->showNotification(QIcon::fromTheme(QSL("download"), QIcon(QSL(":icons/other/download.svg"))).pixmap(48), tr("Falkon: Download Finished"), tr("All files have been successfully downloaded.")); if (!m_closeOnFinish) { raise(); activateWindow(); } } ui->speedLabel->clear(); setWindowTitle(tr("Download Manager")); #ifdef Q_OS_WIN taskbarButton()->progress()->hide(); #endif if (m_closeOnFinish) { close(); } } } void DownloadManager::deleteItem(DownloadItem* item) { if (item && !item->isDownloading()) { delete item; } } bool DownloadManager::canClose() { if (m_isClosing) { return true; } bool isDownloading = false; for (int i = 0; i < ui->list->count(); i++) { DownloadItem* downItem = qobject_cast(ui->list->itemWidget(ui->list->item(i))); if (!downItem) { continue; } if (downItem->isDownloading()) { isDownloading = true; break; } } return !isDownloading; } bool DownloadManager::useExternalManager() const { return m_useExternalManager; } void DownloadManager::closeEvent(QCloseEvent* e) { if (mApp->windowCount() == 0) { // No main windows -> we are going to quit if (!canClose()) { QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Warning"), tr("Are you sure you want to quit? All uncompleted downloads will be cancelled!"), QMessageBox::Yes | QMessageBox::No); if (button != QMessageBox::Yes) { e->ignore(); return; } m_isClosing = true; } mApp->quitApplication(); } e->accept(); } DownloadManager::~DownloadManager() { delete ui; } diff --git a/src/lib/downloads/downloadoptionsdialog.h b/src/lib/downloads/downloadoptionsdialog.h index 3e2e4734..bce57afe 100644 --- a/src/lib/downloads/downloadoptionsdialog.h +++ b/src/lib/downloads/downloadoptionsdialog.h @@ -1,63 +1,63 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2017 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 . * ============================================================ */ #ifndef DOWNLOADOPTIONSDIALOG_H #define DOWNLOADOPTIONSDIALOG_H #include #include #include "qzcommon.h" #include "downloadmanager.h" namespace Ui { class DownloadOptionsDialog; } class QWebEngineDownloadItem; class FALKON_EXPORT DownloadOptionsDialog : public QDialog { Q_OBJECT public: explicit DownloadOptionsDialog(const QString &fileName, QWebEngineDownloadItem *downloadItem, QWidget* parent = 0); ~DownloadOptionsDialog(); void showExternalManagerOption(bool show); void showFromLine(bool show); void setLastDownloadOption(const DownloadManager::DownloadOption &option); - int exec(); + int exec() override; private Q_SLOTS: void copyDownloadLink(); void emitDialogFinished(int status); Q_SIGNALS: void dialogFinished(int); private: Ui::DownloadOptionsDialog* ui; QWebEngineDownloadItem *m_downloadItem; bool m_signalEmited; }; #endif // DOWNLOADOPTIONSDIALOG_H diff --git a/src/lib/navigation/completer/locationcompleterdelegate.h b/src/lib/navigation/completer/locationcompleterdelegate.h index 7ab6d655..a0e1aa82 100644 --- a/src/lib/navigation/completer/locationcompleterdelegate.h +++ b/src/lib/navigation/completer/locationcompleterdelegate.h @@ -1,45 +1,45 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef LOCATIONCOMPLETERDELEGATE_H #define LOCATIONCOMPLETERDELEGATE_H #include #include "qzcommon.h" class FALKON_EXPORT LocationCompleterDelegate : public QStyledItemDelegate { public: explicit LocationCompleterDelegate(QObject *parent = 0); - void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; void setForceVisitItem(bool enable); private: int viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect, const QString &text, const QColor &color, const QString &searchText = QString()) const; mutable int m_rowHeight; mutable int m_padding; bool m_forceVisitItem = false; }; #endif // LOCATIONCOMPLETERDELEGATE_H diff --git a/src/lib/navigation/completer/locationcompleterview.h b/src/lib/navigation/completer/locationcompleterview.h index cdcfb8f7..ebe1de4e 100644 --- a/src/lib/navigation/completer/locationcompleterview.h +++ b/src/lib/navigation/completer/locationcompleterview.h @@ -1,74 +1,74 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef LOCATIONCOMPLETERVIEW_H #define LOCATIONCOMPLETERVIEW_H #include #include "qzcommon.h" class LoadRequest; class LocationCompleterDelegate; class QTimer; class QHBoxLayout; class FALKON_EXPORT LocationCompleterView : public QWidget { Q_OBJECT public: explicit LocationCompleterView(); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); QItemSelectionModel *selectionModel() const; QModelIndex currentIndex() const; void setCurrentIndex(const QModelIndex &index); void adjustSize(); - bool eventFilter(QObject* object, QEvent* event); + bool eventFilter(QObject* object, QEvent* event) override; Q_SIGNALS: void closed(); void searchEnginesDialogRequested(); void loadRequested(const LoadRequest &request); void indexActivated(const QModelIndex &index); void indexCtrlActivated(const QModelIndex &index); void indexShiftActivated(const QModelIndex &index); void indexDeleteRequested(const QModelIndex &index); public Q_SLOTS: void close(); private: void setupSearchEngines(); void openSearchEnginesDialog(); QListView *m_view; LocationCompleterDelegate *m_delegate; QHBoxLayout *m_searchEnginesLayout; int m_resizeHeight = -1; QTimer *m_resizeTimer = nullptr; bool m_forceResize = true; }; #endif // LOCATIONCOMPLETERVIEW_H diff --git a/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.h b/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.h index 5917c5dd..0f314561 100644 --- a/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.h +++ b/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.h @@ -1,211 +1,211 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * 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 "abstractbuttoninterface.h" #include "mainapplication.h" #include #include class QmlBrowserActionButton; /** * @brief The class exposing BrowserAction API to QML */ class QmlBrowserAction : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) /** * @brief identity for the button. This is a required property. */ Q_PROPERTY(QString identity READ identity WRITE setIdentity NOTIFY identityChanged) /** * @brief name of the button. This is a required property. */ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) /** * @brief title of the button. */ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) /** * @brief tool tip of the button. */ Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged) /** * @brief icon path of button * * The icon path will be search in the following order * - Theme icon: if the icon is found as a theme icon, then it will * be used even if the icon file with same name is present * in the plugin directory * - Falkon resource: for the icons starting with ":", they are searched in * falkon resource file * - Files in plugin directory: All other paths will be resolved relative to * the plugin directory. If the icon path is outside the * plugin directory, then it will be resolved as empty path. */ Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) /** * @brief badge text of the button */ Q_PROPERTY(QString badgeText READ badgeText WRITE setBadgeText NOTIFY badgeTextChanged) /** * @brief the popup shown when the button is clicked. This must be a QML Window. */ Q_PROPERTY(QQmlComponent* popup READ popup WRITE setPopup NOTIFY popupChanged) /** * @brief represents locations where the button is to be added. */ Q_PROPERTY(Locations location READ location WRITE setLocation NOTIFY locationChanged) public: /** * @brief The Location enum */ enum Location { NavigationToolBar = 0x1, //!< to add the button in navigation tool bar StatusBar = 0x2 //!< to add the button in status bar }; Q_DECLARE_FLAGS(Locations, Location) Q_ENUM(Locations) explicit QmlBrowserAction(QObject *parent = nullptr); ~QmlBrowserAction() override; void classBegin() override {} void componentComplete() override; QmlBrowserActionButton *button() const; Locations location() const; Q_SIGNALS: /** * @brief This signal is emitted when identity property is changed * @param QString representing identity */ void identityChanged(const QString &identity); /** * @brief This signal is emitted when name property is changed * @param QString representing name */ void nameChanged(const QString &name); /** * @brief This signal is emitted when title property is changed * @param QString representing title */ void titleChanged(const QString &title); /** * @brief This signal is emitted when the toolTip property is changed * @param QString representing toolTip */ void toolTipChanged(const QString &toolTip); /** * @brief This signal is emitted when the icon property is changed * @param QString representing icon */ void iconChanged(const QString &icon); /** * @brief This signal is emitted when the badgeText property is changed * @param QString representing badgeText */ void badgeTextChanged(const QString &badgeText); /** * @brief This signal is emitted when the popup property is changed * @param QQmComponent representing popup */ void popupChanged(QQmlComponent *popup); /** * @brief This signal is emitted when the locations property is changed * @param locations */ void locationChanged(const Locations &locations); /** * @brief This signal is emitted when the button is clicked */ void clicked(); private: QString m_identity; QString m_name; QString m_title; QString m_toolTip; QString m_icon; QString m_badgeText; QQmlComponent *m_popup = nullptr; Locations m_locations = NavigationToolBar; QmlBrowserActionButton *m_button = nullptr; QString identity() const; void setIdentity(const QString &identity); QString name() const; void setName(const QString &name); QString title() const; void setTitle(const QString &title); QString toolTip() const; void setToolTip(const QString &toolTip); QString icon() const; void setIcon(const QString &icon); QString badgeText() const; void setBadgeText(const QString &badgeText); QQmlComponent *popup() const; void setPopup(QQmlComponent *popup); void setLocation(const Locations &locations); void addButton(BrowserWindow *window); void removeButton(BrowserWindow *window); }; class QmlBrowserActionButton : public AbstractButtonInterface { Q_OBJECT public: explicit QmlBrowserActionButton(QObject *parent = nullptr); - QString id() const; + QString id() const override; void setId(const QString &id); - QString name() const; + QString name() const override; void setName(const QString &name); void setTitle(const QString &title); void setToolTip(const QString &toolTip); void setIcon(const QString &icon); void setBadgeText(const QString &badgeText); void setPopup(QQmlComponent *popup); void positionPopup(ClickController *clickController); private: QString m_id; QString m_name; QString m_iconUrl; QQmlComponent *m_popup = nullptr; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QmlBrowserAction::Locations) diff --git a/src/lib/plugins/qml/api/extensionscheme/qmlextensionscheme.h b/src/lib/plugins/qml/api/extensionscheme/qmlextensionscheme.h index c39e65e8..286b011b 100644 --- a/src/lib/plugins/qml/api/extensionscheme/qmlextensionscheme.h +++ b/src/lib/plugins/qml/api/extensionscheme/qmlextensionscheme.h @@ -1,63 +1,63 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * 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 "schemehandlers/extensionschemehandler.h" #include "qmlwebengineurlrequestjob.h" #include #include class QmlExtensionSchemeHandler; /** * @brief The QmlExtensionScheme class, exposed to QML as ExtensionScheme */ class QmlExtensionScheme : public QObject, public QQmlParserStatus { Q_OBJECT /** * @brief extension scheme handle name */ Q_PROPERTY(QString name READ name WRITE setName) public: explicit QmlExtensionScheme(QObject *parent = nullptr); ~QmlExtensionScheme() override; void classBegin() override {} void componentComplete() override; Q_SIGNALS: /** * @brief The signal emitted when the request to the scheme handle is started * @param request of the type [QmlWebEngineUrlRequestJob](@ref QmlWebEngineUrlRequestJob) */ void requestStarted(const QJSValue &request); private: QString m_name; QmlExtensionSchemeHandler *m_schemeHandler = nullptr; QString name() const; void setName(const QString &name); }; class QmlExtensionSchemeHandler : public ExtensionSchemeHandler { Q_OBJECT public: - void requestStarted(QWebEngineUrlRequestJob *job); + void requestStarted(QWebEngineUrlRequestJob *job) override; Q_SIGNALS: void _requestStarted(QWebEngineUrlRequestJob *job); }; diff --git a/src/lib/plugins/qml/api/sidebar/qmlsidebar.h b/src/lib/plugins/qml/api/sidebar/qmlsidebar.h index de998179..5aff57eb 100644 --- a/src/lib/plugins/qml/api/sidebar/qmlsidebar.h +++ b/src/lib/plugins/qml/api/sidebar/qmlsidebar.h @@ -1,159 +1,159 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * 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 "sidebarinterface.h" #include #include class QmlSideBarHelper; /** * @brief The class exposing SideBar API to QML */ class QmlSideBar : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) /** * @brief name of the sidebar. This is required property. */ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) /** * @brief title of the sidebar action. */ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) /** * @brief icon path of the sidebar action. * * The icon path will be search in the following order * - Theme icon: if the icon is found as a theme icon, then it will * be used even if the icon file with same name is present * in the plugin directory * - Falkon resource: for the icons starting with ":", they are searched in * falkon resource file * - Files in plugin directory: All other paths will be resolved relative to * the plugin directory. If the icon path is outside the * plugin directory, then it will be resolved as empty path. */ Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) /** * @brief shortcut for the sidebar action. */ Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) /** * @brief represents whether the sidebar action is checkable */ Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged) /** * @brief the GUI of the sidebar. This must be provided as QML Window. * This is a default property. */ Q_PROPERTY(QQmlComponent* item READ item WRITE setItem NOTIFY itemChanged) Q_CLASSINFO("DefaultProperty", "item") public: explicit QmlSideBar(QObject *parent = nullptr); ~QmlSideBar() override; void classBegin() override {} void componentComplete() override; QString name() const; SideBarInterface *sideBar() const; Q_SIGNALS: /** * @brief This signal is emitted when name property is changed. * @param QString represening name */ void nameChanged(const QString &name); /** * @brief This signal is emitted when title property is changed * @param QString representing title */ void titleChanged(const QString &title); /** * @brief This signal is emitted when icon property is changed * @param QString representing icon path url */ void iconChanged(const QString &icon); /** * @brief This signal is emitted when shortcut property is changed * @param QString representing shortcut */ void shortcutChanged(const QString &shortcut); /** * @brief This signal is emitted when checkable property is changed * @param checkable */ void checkableChanged(bool checkable); void itemChanged(QQmlComponent *item); private: QString m_name; QString m_title; QString m_iconUrl; QString m_shortcut; bool m_checkable = false; QQmlComponent *m_item = nullptr; QmlSideBarHelper *m_sideBarHelper = nullptr; void setName(const QString &name); QString title() const; void setTitle(const QString &title); QString icon() const; void setIcon(const QString &icon); QString shortcut() const; void setShortcut(const QString &shortcut); bool checkable(); void setCheckable(bool checkable); QQmlComponent *item() const; void setItem(QQmlComponent *item); }; class QmlSideBarHelper : public SideBarInterface { Q_OBJECT public: explicit QmlSideBarHelper(QObject *parent = nullptr); - QString title() const; - QAction *createMenuAction(); - QWidget *createSideBarWidget(BrowserWindow *mainWindow); + QString title() const override; + QAction *createMenuAction() override; + QWidget *createSideBarWidget(BrowserWindow *mainWindow) override; void setTitle(const QString &title); void setIcon(const QString &icon); void setShortcut(const QString &shortcut); void setCheckable(bool checkable); void setItem(QQmlComponent *item); private: QString m_title; QString m_iconUrl; QString m_shortcut; bool m_checkable = false; QQmlComponent *m_item = nullptr; }; diff --git a/src/lib/popupwindow/popuplocationbar.cpp b/src/lib/popupwindow/popuplocationbar.cpp index 93a72fa0..b4b67ce4 100644 --- a/src/lib/popupwindow/popuplocationbar.cpp +++ b/src/lib/popupwindow/popuplocationbar.cpp @@ -1,119 +1,119 @@ /* ============================================================ * 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 "popuplocationbar.h" #include "popupwebview.h" #include "toolbutton.h" #include "qztools.h" #include "iconprovider.h" #include "bookmarksicon.h" #include "autofillicon.h" #include "webpage.h" class FALKON_EXPORT PopupSiteIcon : public QWidget { public: explicit PopupSiteIcon(QWidget* parent = 0) : QWidget(parent) { } void setIcon(const QIcon &icon) { m_icon = QIcon(icon.pixmap(16)); update(); } private: QIcon m_icon; - void paintEvent(QPaintEvent*) { + void paintEvent(QPaintEvent*) override { QPainter p(this); m_icon.paint(&p, rect()); } }; PopupLocationBar::PopupLocationBar(QWidget* parent) : LineEdit(parent) , m_view(0) { m_siteIcon = new PopupSiteIcon(this); m_siteIcon->setIcon(IconProvider::emptyWebIcon()); m_siteIcon->setFixedSize(26, 26); m_bookmarkIcon = new BookmarksIcon(this); m_autofillIcon = new AutoFillIcon(this); QWidget* rightSpacer = new QWidget(this); rightSpacer->setFixedWidth(3); addWidget(m_siteIcon, LineEdit::LeftSide); addWidget(m_autofillIcon, LineEdit::RightSide); addWidget(m_bookmarkIcon, LineEdit::RightSide); addWidget(rightSpacer, LineEdit::RightSide); setLeftMargin(24); setFixedHeight(26); setReadOnly(true); // Hide icons by default m_autofillIcon->hide(); } void PopupLocationBar::setView(PopupWebView* view) { m_view = view; m_bookmarkIcon->setWebView(m_view); m_autofillIcon->setWebView(m_view); } void PopupLocationBar::startLoading() { m_autofillIcon->hide(); updateTextMargins(); } void PopupLocationBar::stopLoading() { m_bookmarkIcon->checkBookmark(m_view->url()); WebPage* page = qobject_cast(m_view->page()); if (page && !page->autoFillUsernames().isEmpty()) { m_autofillIcon->setUsernames(page->autoFillUsernames()); m_autofillIcon->show(); } updateTextMargins(); } void PopupLocationBar::showUrl(const QUrl &url) { setText(QzTools::urlEncodeQueryString(url)); setCursorPosition(0); } void PopupLocationBar::showSiteIcon() { QIcon icon = IconProvider::emptyWebIcon(); if (property("secured").toBool()) { icon = QIcon::fromTheme(QSL("document-encrypted"), icon); } m_siteIcon->setIcon(QIcon(icon.pixmap(16))); } void PopupLocationBar::setPrivacyState(bool state) { setProperty("secured", QVariant(state)); } diff --git a/src/lib/popupwindow/popupwebview.h b/src/lib/popupwindow/popupwebview.h index 87bd62e4..f06b0312 100644 --- a/src/lib/popupwindow/popupwebview.h +++ b/src/lib/popupwindow/popupwebview.h @@ -1,53 +1,53 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2015 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 . * ============================================================ */ #ifndef POPUPWEBVIEW_H #define POPUPWEBVIEW_H #include #include "qzcommon.h" #include "webview.h" class Menu; class LoadRequest; class WebInspector; class FALKON_EXPORT PopupWebView : public WebView { Q_OBJECT public: explicit PopupWebView(QWidget* parent = 0); - QWidget* overlayWidget() Q_DECL_OVERRIDE; - void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE; + QWidget* overlayWidget() override; + void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) override; - void closeView() Q_DECL_OVERRIDE; - bool isFullScreen() Q_DECL_OVERRIDE; - void requestFullScreen(bool enable) Q_DECL_OVERRIDE; + void closeView() override; + bool isFullScreen() override; + void requestFullScreen(bool enable) override; public Q_SLOTS: void inspectElement(); private: - void _contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; + void _contextMenuEvent(QContextMenuEvent *event) override; Menu* m_menu; QPointer m_inspector; }; #endif // POPUPWEBVIEW_H diff --git a/src/lib/preferences/acceptlanguage.h b/src/lib/preferences/acceptlanguage.h index 27e2ae81..2bae62ed 100644 --- a/src/lib/preferences/acceptlanguage.h +++ b/src/lib/preferences/acceptlanguage.h @@ -1,57 +1,57 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef ACCEPTLANGUAGE_H #define ACCEPTLANGUAGE_H #include #include #include "qzcommon.h" namespace Ui { class AcceptLanguage; } class FALKON_EXPORT AcceptLanguage : public QDialog { Q_OBJECT public: explicit AcceptLanguage(QWidget* parent = 0); ~AcceptLanguage(); static QStringList defaultLanguage(); static QByteArray generateHeader(const QStringList &langs); public Q_SLOTS: - void accept(); + void accept() override; private Q_SLOTS: void addLanguage(); void removeLanguage(); void upLanguage(); void downLanguage(); private: QStringList expand(const QLocale::Language &language); Ui::AcceptLanguage* ui; }; #endif // ACCEPTLANGUAGE_H diff --git a/src/lib/preferences/jsoptions.h b/src/lib/preferences/jsoptions.h index 8f715a8d..3593086d 100644 --- a/src/lib/preferences/jsoptions.h +++ b/src/lib/preferences/jsoptions.h @@ -1,46 +1,46 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 David Rosca 2013-2014 Mladen Pejaković * * 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 . * ============================================================ */ #ifndef JSOPTIONS_H #define JSOPTIONS_H #include #include "qzcommon.h" namespace Ui { class JsOptions; } class FALKON_EXPORT JsOptions : public QDialog { Q_OBJECT public: explicit JsOptions(QWidget* parent = 0); ~JsOptions(); public Q_SLOTS: - void accept(); + void accept() override; private: Ui::JsOptions* ui; }; #endif // JSOPTIONS_H diff --git a/src/lib/preferences/pluginlistdelegate.h b/src/lib/preferences/pluginlistdelegate.h index f5d37a04..639163dc 100644 --- a/src/lib/preferences/pluginlistdelegate.h +++ b/src/lib/preferences/pluginlistdelegate.h @@ -1,40 +1,40 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef PLUGINLISTDELEGATE_H #define PLUGINLISTDELEGATE_H #include #include "qzcommon.h" class QListWidget; class FALKON_EXPORT PluginListDelegate : public QStyledItemDelegate { public: explicit PluginListDelegate(QListWidget* parent); - void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: mutable int m_rowHeight; mutable int m_padding; }; #endif // PLUGINLISTDELEGATE_H diff --git a/src/lib/preferences/preferences.h b/src/lib/preferences/preferences.h index a183488a..332bb152 100644 --- a/src/lib/preferences/preferences.h +++ b/src/lib/preferences/preferences.h @@ -1,109 +1,109 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef PREFERENCES_H #define PREFERENCES_H #include #include #include #include "qzcommon.h" namespace Ui { class Preferences; } class QAbstractButton; class QListWidgetItem; class AutoFillManager; class BrowserWindow; class PluginsManager; class DesktopNotification; class ThemeManager; class FALKON_EXPORT Preferences : public QDialog { Q_OBJECT public: explicit Preferences(BrowserWindow* window); ~Preferences(); private Q_SLOTS: void saveSettings(); void buttonClicked(QAbstractButton* button); void showStackedPage(QListWidgetItem* item); void chooseDownPath(); void showCookieManager(); void showHtml5Permissions(); void useActualHomepage(); void useActualNewTab(); void showAcceptLanguage(); void chooseUserStyleClicked(); void deleteHtml5storage(); void chooseExternalDownloadManager(); void openUserAgentManager(); void openJsOptions(); void openSearchEnginesManager(); void searchFromAddressBarChanged(bool state); void saveHistoryChanged(bool state); void allowHtml5storageChanged(bool state); void downLocChanged(bool state); void allowCacheChanged(bool state); void setManualProxyConfigurationEnabled(bool state); void useExternalDownManagerChanged(bool state); void changeCachePathClicked(); void newTabChanged(int value); void afterLaunchChanged(int value); void createProfile(); void deleteProfile(); void startProfileIndexChanged(int index); void setProgressBarColorIcon(QColor col = QColor()); void selectCustomProgressBarColor(); void showNotificationPreview(); void makeFalkonDefault(); private: - void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; Ui::Preferences* ui; BrowserWindow* m_window; AutoFillManager* m_autoFillManager; PluginsManager* m_pluginsList; ThemeManager* m_themesManager; QPointer m_notification; QUrl m_homepage; QUrl m_newTabUrl; QString m_actProfileName; int m_afterLaunch; int m_onNewTab; QPoint m_notifPosition; }; #endif // PREFERENCES_H diff --git a/src/lib/preferences/useragentdialog.h b/src/lib/preferences/useragentdialog.h index 9968e15c..3125a948 100644 --- a/src/lib/preferences/useragentdialog.h +++ b/src/lib/preferences/useragentdialog.h @@ -1,60 +1,60 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef USERAGENTDIALOG_H #define USERAGENTDIALOG_H #include #include #include "qzcommon.h" class UserAgentManager; namespace Ui { class UserAgentDialog; } class FALKON_EXPORT UserAgentDialog : public QDialog { Q_OBJECT public: explicit UserAgentDialog(QWidget* parent = 0); ~UserAgentDialog(); private Q_SLOTS: void addSite(); void removeSite(); void editSite(); - void accept(); + void accept() override; void enableGlobalComboBox(bool enable); void enablePerSiteFrame(bool enable); private: bool showEditDialog(const QString &title, QString* rSite, QString* rUserAgent); Ui::UserAgentDialog* ui; UserAgentManager* m_manager; QStringList m_knownUserAgents; }; #endif // USERAGENTDIALOG_H diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index 48914097..885cca29 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -1,371 +1,371 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 S. Razi Alavizadeh * Copyright (C) 2014-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 . * ============================================================ */ #ifndef COMBOTABBAR_H #define COMBOTABBAR_H #include "qzcommon.h" #include "wheelhelper.h" #include #include #include #include #include class QScrollArea; class QPropertyAnimation; class QHBoxLayout; class TabBarScrollWidget; class TabBarHelper; class ToolButton; class FALKON_EXPORT ComboTabBar : public QWidget { Q_OBJECT Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) Q_PROPERTY(int count READ count) public: enum SizeType { PinnedTabWidth, ActiveTabMinimumWidth, NormalTabMinimumWidth, NormalTabMaximumWidth, OverflowedTabWidth, ExtraReservedWidth }; enum DropIndicatorPosition { BeforeTab, AfterTab }; explicit ComboTabBar(QWidget* parent = 0); int addTab(const QString &text); int addTab(const QIcon &icon, const QString &text); int insertTab(int index, const QString &text); int insertTab(int index, const QIcon &icon, const QString &text, bool pinned = false); void removeTab(int index); void moveTab(int from, int to); bool isTabEnabled(int index) const; void setTabEnabled(int index, bool enabled); QColor tabTextColor(int index) const; void setTabTextColor(int index, const QColor &color); QRect tabRect(int index) const; QRect draggedTabRect() const; QPixmap tabPixmap(int index) const; // Returns tab index at pos, or -1 int tabAt(const QPoint &pos) const; // Returns true if there is an empty area at pos // (returns false if there are buttons or other widgets on the pos) bool emptyArea(const QPoint &pos) const; int mainTabBarCurrentIndex() const; int currentIndex() const; int count() const; void setDrawBase(bool drawTheBase); bool drawBase() const; Qt::TextElideMode elideMode() const; void setElideMode(Qt::TextElideMode elide); QString tabText(int index) const; void setTabText(int index, const QString &text); void setTabToolTip(int index, const QString &tip); QString tabToolTip(int index) const; bool tabsClosable() const; void setTabsClosable(bool closable); void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget); QWidget* tabButton(int index, QTabBar::ButtonPosition position) const; QTabBar::SelectionBehavior selectionBehaviorOnRemove() const; void setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior); bool expanding() const; void setExpanding(bool enabled); bool isMovable() const; void setMovable(bool movable); bool documentMode() const; void setDocumentMode(bool set); int pinnedTabsCount() const; int normalTabsCount() const; bool isPinned(int index) const; void setFocusPolicy(Qt::FocusPolicy policy); void setObjectName(const QString &name); void setMouseTracking(bool enable); void insertCloseButton(int index); void setCloseButtonsToolTip(const QString &tip); QTabBar::ButtonPosition iconButtonPosition() const; QTabBar::ButtonPosition closeButtonPosition() const; QSize iconButtonSize() const; QSize closeButtonSize() const; bool validIndex(int index) const; void setCurrentNextEnabledIndex(int offset); bool usesScrollButtons() const; void setUsesScrollButtons(bool useButtons); void showDropIndicator(int index, DropIndicatorPosition position); void clearDropIndicator(); bool isDragInProgress() const; bool isScrollInProgress() const; bool isMainBarOverflowed() const; // Width of all widgets in the corner int cornerWidth(Qt::Corner corner) const; // Add widget to the left/right corner void addCornerWidget(QWidget* widget, Qt::Corner corner); // Duration of tab slide animation when releasing dragged tab static int slideAnimationDuration(); public Q_SLOTS: void setUpLayout(); void ensureVisible(int index = -1, int xmargin = -1); void setCurrentIndex(int index); Q_SIGNALS: void overFlowChanged(bool overFlow); void currentChanged(int index); void tabCloseRequested(int index); void tabMoved(int from, int to); void scrollBarValueChanged(int value); private Q_SLOTS: void setMinimumWidths(); void slotCurrentChanged(int index); void slotTabCloseRequested(int index); void slotTabMoved(int from, int to); void closeTabFromButton(); void updateTabBars(); void emitOverFlowChanged(); protected: int mainTabBarWidth() const; int pinTabBarWidth() const; - bool event(QEvent *event); - void wheelEvent(QWheelEvent* event); - bool eventFilter(QObject* obj, QEvent* ev); - void paintEvent(QPaintEvent* ev); + bool event(QEvent *event) override; + void wheelEvent(QWheelEvent* event) override; + bool eventFilter(QObject* obj, QEvent* ev) override; + void paintEvent(QPaintEvent* ev) override; virtual int comboTabBarPixelMetric(SizeType sizeType) const; virtual QSize tabSizeHint(int index, bool fast = false) const; virtual void tabInserted(int index); virtual void tabRemoved(int index); private: TabBarHelper* mainTabBar() const; TabBarHelper* localTabBar(int index = -1) const; int toLocalIndex(int globalIndex) const; QRect mapFromLocalTabRect(const QRect &rect, QWidget *tabBar) const; void updatePinnedTabBarVisibility(); QHBoxLayout* m_mainLayout; QHBoxLayout* m_leftLayout; QHBoxLayout* m_rightLayout; QWidget* m_leftContainer; QWidget* m_rightContainer; TabBarHelper* m_mainTabBar; TabBarHelper* m_pinnedTabBar; TabBarScrollWidget* m_mainTabBarWidget; TabBarScrollWidget* m_pinnedTabBarWidget; QString m_closeButtonsToolTip; bool m_mainBarOverFlowed; bool m_lastAppliedOverflow; bool m_usesScrollButtons; bool m_blockCurrentChangedSignal; WheelHelper m_wheelHelper; friend class TabBarHelper; friend class TabStackedWidget; }; class FALKON_EXPORT TabBarHelper : public QTabBar { Q_OBJECT Q_PROPERTY(int tabPadding READ tabPadding WRITE setTabPadding) Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor) public: explicit TabBarHelper(bool isPinnedTabBar, ComboTabBar* comboTabBar); int tabPadding() const; void setTabPadding(int padding); QColor baseColor() const; void setBaseColor(const QColor &color); void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget); - QSize tabSizeHint(int index) const; + QSize tabSizeHint(int index) const override; QSize baseClassTabSizeHint(int index) const; QRect draggedTabRect() const; QPixmap tabPixmap(int index) const; bool isActiveTabBar(); void setActiveTabBar(bool activate); void removeTab(int index); void setScrollArea(QScrollArea* scrollArea); void useFastTabSizeHint(bool enabled); void showDropIndicator(int index, ComboTabBar::DropIndicatorPosition position); void clearDropIndicator(); bool isDisplayedOnViewPort(int globalLeft, int globalRight); bool isDragInProgress() const; static void initStyleBaseOption(QStyleOptionTabBarBase* optTabBase, QTabBar* tabbar, QSize size); public Q_SLOTS: void setCurrentIndex(int index); private: - bool event(QEvent* ev); - void paintEvent(QPaintEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent* event); + bool event(QEvent* ev) override; + void paintEvent(QPaintEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent* event) override; int dragOffset(QStyleOptionTab *option, int tabIndex) const; void initStyleOption(QStyleOptionTab* option, int tabIndex) const; ComboTabBar* m_comboTabBar; QScrollArea* m_scrollArea; int m_tabPadding = -1; QColor m_baseColor; int m_pressedIndex; bool m_dragInProgress; QPoint m_dragStartPosition; class QMovableTabWidget *m_movingTab = nullptr; bool m_activeTabBar; bool m_isPinnedTabBar; bool m_useFastTabSizeHint; int m_dropIndicatorIndex = -1; ComboTabBar::DropIndicatorPosition m_dropIndicatorPosition; }; class FALKON_EXPORT TabScrollBar : public QScrollBar { Q_OBJECT public: explicit TabScrollBar(QWidget* parent = 0); ~TabScrollBar(); bool isScrolling() const; void animateToValue(int to, QEasingCurve::Type type = QEasingCurve::OutQuad); private: QPropertyAnimation* m_animation; }; class FALKON_EXPORT TabBarScrollWidget : public QWidget { Q_OBJECT public: explicit TabBarScrollWidget(QTabBar* tabBar, QWidget* parent = 0); QTabBar* tabBar(); QScrollArea* scrollArea(); TabScrollBar* scrollBar(); void scrollByWheel(QWheelEvent* event); int scrollButtonsWidth() const; bool usesScrollButtons() const; void setUsesScrollButtons(bool useButtons); bool isOverflowed() const; int tabAt(const QPoint &pos) const; public Q_SLOTS: void ensureVisible(int index = -1, int xmargin = 132); void scrollToLeft(int n = 5, QEasingCurve::Type type = QEasingCurve::OutQuad); void scrollToRight(int n = 5, QEasingCurve::Type type = QEasingCurve::OutQuad); void scrollToLeftEdge(); void scrollToRightEdge(); void setUpLayout(); private Q_SLOTS: void overFlowChanged(bool overflowed); void scrollStart(); void updateScrollButtonsState(); private: - void mouseMoveEvent(QMouseEvent* event); - void resizeEvent(QResizeEvent* event); + void mouseMoveEvent(QMouseEvent* event) override; + void resizeEvent(QResizeEvent* event) override; QTabBar* m_tabBar; QScrollArea* m_scrollArea; TabScrollBar* m_scrollBar; ToolButton* m_rightScrollButton; ToolButton* m_leftScrollButton; bool m_usesScrollButtons; int m_totalDeltas; }; // Class for close button on tabs // * taken from qtabbar.cpp class CloseButton : public QAbstractButton { Q_OBJECT public: CloseButton(QWidget *parent = nullptr); QSize sizeHint() const override; void enterEvent(QEvent *event) override; void leaveEvent(QEvent *event) override; void paintEvent(QPaintEvent *event) override; }; #endif // COMBOTABBAR_H diff --git a/src/lib/tabwidget/tabbar.h b/src/lib/tabwidget/tabbar.h index a55f2665..84c6ca5e 100644 --- a/src/lib/tabwidget/tabbar.h +++ b/src/lib/tabwidget/tabbar.h @@ -1,95 +1,95 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef TABBAR_H #define TABBAR_H #include #include "combotabbar.h" #include "qzcommon.h" class BrowserWindow; class TabWidget; class WebTab; class FALKON_EXPORT TabBar : public ComboTabBar { Q_OBJECT public: explicit TabBar(BrowserWindow* window, TabWidget* tabWidget); void loadSettings(); TabWidget* tabWidget() const; - void setVisible(bool visible); + void setVisible(bool visible) override; void setForceHidden(bool hidden); void setTabText(int index, const QString &text); - void wheelEvent(QWheelEvent* event); + void wheelEvent(QWheelEvent* event) override; Q_SIGNALS: void moveAddTabButton(int posX); private Q_SLOTS: void currentTabChanged(int index); void overflowChanged(bool overflowed); void closeTabFromButton(); private: inline bool validIndex(int index) const { return index >= 0 && index < count(); } - void tabInserted(int index); - void tabRemoved(int index); + void tabInserted(int index) override; + void tabRemoved(int index) override; void hideCloseButton(int index); void showCloseButton(int index); void updatePinnedTabCloseButton(int index); - void contextMenuEvent(QContextMenuEvent* event); - void mouseDoubleClickEvent(QMouseEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); + void contextMenuEvent(QContextMenuEvent* event) override; + void mouseDoubleClickEvent(QMouseEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent *event); - void dragLeaveEvent(QDragLeaveEvent *event); - void dropEvent(QDropEvent* event); + void dragEnterEvent(QDragEnterEvent* event) override; + void dragMoveEvent(QDragMoveEvent *event) override; + void dragLeaveEvent(QDragLeaveEvent *event) override; + void dropEvent(QDropEvent* event) override; - QSize tabSizeHint(int index, bool fast) const; - int comboTabBarPixelMetric(ComboTabBar::SizeType sizeType) const; + QSize tabSizeHint(int index, bool fast) const override; + int comboTabBarPixelMetric(ComboTabBar::SizeType sizeType) const override; WebTab* webTab(int index = -1) const; BrowserWindow* m_window; TabWidget* m_tabWidget; bool m_hideTabBarWithOneTab; int m_showCloseOnInactive; mutable int m_normalTabWidth; mutable int m_activeTabWidth; QPoint m_dragStartPosition; bool m_forceHidden; QPointer m_lastTab; }; #endif // TABBAR_H diff --git a/src/lib/tabwidget/tabstackedwidget.h b/src/lib/tabwidget/tabstackedwidget.h index e42d3c32..e2cc6f99 100644 --- a/src/lib/tabwidget/tabstackedwidget.h +++ b/src/lib/tabwidget/tabstackedwidget.h @@ -1,97 +1,97 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 S. Razi Alavizadeh * 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 . * ============================================================ */ #ifndef TABSTACKEDWIDGET_H #define TABSTACKEDWIDGET_H #include "qzcommon.h" #include class ComboTabBar; class QStackedWidget; class QVBoxLayout; class FALKON_EXPORT TabStackedWidget : public QWidget { Q_OBJECT public: explicit TabStackedWidget(QWidget* parent = 0); ~TabStackedWidget(); ComboTabBar* tabBar(); void setTabBar(ComboTabBar* tb); bool documentMode() const; void setDocumentMode(bool enabled); int addTab(QWidget* widget, const QString &label, bool pinned = false); int insertTab(int index, QWidget* widget, const QString &label, bool pinned = false); QString tabText(int index) const; void setTabText(int index, const QString &label); QString tabToolTip(int index) const; void setTabToolTip(int index, const QString &tip); int pinUnPinTab(int index, const QString &title = QString()); void removeTab(int index); void moveTab(int from, int to); int currentIndex() const; QWidget* currentWidget() const; QWidget* widget(int index) const; int indexOf(QWidget* widget) const; int count() const; Q_SIGNALS: void currentChanged(int index); void tabCloseRequested(int index); void pinStateChanged(int index, bool pinned); public Q_SLOTS: void setCurrentIndex(int index); void setCurrentWidget(QWidget* widget); void setUpLayout(); private Q_SLOTS: void showTab(int index); void tabWasMoved(int from, int to); void tabWasRemoved(int index); protected: - bool eventFilter(QObject* obj, QEvent* event); - void keyPressEvent(QKeyEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; + void keyPressEvent(QKeyEvent* event) override; private: bool validIndex(int index) const; void selectTabOnRemove(); QStackedWidget* m_stack; ComboTabBar* m_tabBar; QVBoxLayout* m_mainLayout; bool m_dirtyTabBar; int m_currentIndex; int m_previousIndex; }; #endif // TABSTACKEDWIDGET_H diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index fb8772a4..698c9a85 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -1,185 +1,185 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef TABWIDGET_H #define TABWIDGET_H #include #include #include "tabstackedwidget.h" #include "toolbutton.h" #include "loadrequest.h" #include "webtab.h" #include "qzcommon.h" class QMenu; class TabBar; class TabIcon; class TabWidget; class BrowserWindow; class TabbedWebView; class ClosedTabsManager; class FALKON_EXPORT AddTabButton : public ToolButton { public: explicit AddTabButton(TabWidget* tabWidget, TabBar* tabBar); private: - void wheelEvent(QWheelEvent* event); - void mouseReleaseEvent(QMouseEvent* event); + void wheelEvent(QWheelEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; TabBar* m_tabBar; TabWidget* m_tabWidget; }; class FALKON_EXPORT MenuTabs : public QMenu { Q_OBJECT public: explicit MenuTabs(QWidget* parent = 0) : QMenu(parent) {} Q_SIGNALS: void closeTab(int); private: - void mouseReleaseEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event) override; }; class FALKON_EXPORT TabWidget : public TabStackedWidget { Q_OBJECT public: explicit TabWidget(BrowserWindow *window, QWidget *parent = nullptr); ~TabWidget(); BrowserWindow *browserWindow() const; bool restoreState(const QVector &tabs, int currentTab); void setCurrentIndex(int index); void nextTab(); void previousTab(); void currentTabChanged(int index); int normalTabsCount() const; int pinnedTabsCount() const; int extraReservedWidth() const; WebTab *webTab(int index = -1) const; TabBar* tabBar() const; ClosedTabsManager* closedTabsManager() const; QList allTabs(bool withPinned = true); bool canRestoreTab() const; bool isCurrentTabFresh() const; void setCurrentTabFresh(bool currentTabFresh); QStackedWidget* locationBars() const; ToolButton* buttonClosedTabs() const; AddTabButton* buttonAddTab() const; void moveTab(int from, int to); int pinUnPinTab(int index, const QString &title = QString()); void detachTab(WebTab* tab); public Q_SLOTS: int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false); int addView(const LoadRequest &req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1, bool pinned = false); int addView(WebTab *tab, const Qz::NewTabPositionFlags &openFlags); int insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags &openFlags); void addTabFromClipboard(); int duplicateTab(int index); // Force close tab void closeTab(int index = -1); // Request close tab (may be rejected) void requestCloseTab(int index = -1); void reloadTab(int index); void reloadAllTabs(); void stopTab(int index); void closeAllButCurrent(int index); void closeToRight(int index); void closeToLeft(int index); void detachTab(int index); void loadTab(int index); void unloadTab(int index); void restoreClosedTab(QObject* obj = 0); void restoreAllClosedTabs(); void clearClosedTabsList(); void moveAddTabButton(int posX); void tabBarOverFlowChanged(bool overflowed); Q_SIGNALS: void changed(); void tabInserted(int index); void tabRemoved(int index); void tabMoved(int from, int to); private Q_SLOTS: void loadSettings(); void aboutToShowTabsMenu(); void aboutToShowClosedTabsMenu(); void actionChangeIndex(); void tabWasMoved(int before, int after); private: WebTab* weTab() const; WebTab* weTab(int index) const; TabIcon* tabIcon(int index) const; bool validIndex(int index) const; void updateClosedTabsButton(); void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; BrowserWindow* m_window; TabBar* m_tabBar; QStackedWidget* m_locationBars; ClosedTabsManager* m_closedTabsManager; MenuTabs* m_menuTabs; ToolButton* m_buttonListTabs; QMenu* m_menuClosedTabs; ToolButton* m_buttonClosedTabs; AddTabButton* m_buttonAddTab; AddTabButton* m_buttonAddTab2; QPointer m_lastBackgroundTab; bool m_dontCloseWithOneTab; bool m_showClosedTabsButton; bool m_newTabAfterActive; bool m_newEmptyTabAfterActive; QUrl m_urlOnNewTab; bool m_currentTabFresh; bool m_blockTabMovedSignal = false; }; #endif // TABWIDGET_H diff --git a/src/lib/tools/animatedwidget.h b/src/lib/tools/animatedwidget.h index f5142600..1c67845d 100644 --- a/src/lib/tools/animatedwidget.h +++ b/src/lib/tools/animatedwidget.h @@ -1,56 +1,56 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef NOTIFICATION_H #define NOTIFICATION_H #include #include #include "qzcommon.h" class FALKON_EXPORT AnimatedWidget : public QWidget { Q_OBJECT public: enum Direction { Down, Up }; explicit AnimatedWidget(const Direction &direction = Down, int duration = 300, QWidget* parent = 0); QWidget* widget() { return m_widget; } public Q_SLOTS: void hide(); void startAnimation(); private Q_SLOTS: void animateFrame(int frame); private: - void resizeEvent(QResizeEvent* e); + void resizeEvent(QResizeEvent* e) override; Direction m_direction; QTimeLine m_timeLine; qreal m_stepHeight; qreal m_stepY; int m_startY; QWidget* m_widget; }; #endif // NOTIFICATION_H diff --git a/src/lib/tools/buttonwithmenu.h b/src/lib/tools/buttonwithmenu.h index 14c25d4e..6b1ab91f 100644 --- a/src/lib/tools/buttonwithmenu.h +++ b/src/lib/tools/buttonwithmenu.h @@ -1,99 +1,99 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2017 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 . * ============================================================ */ #ifndef BUTTONWITHMENU_H #define BUTTONWITHMENU_H #include #include "toolbutton.h" #include "wheelhelper.h" // Only to be used in WebSearchBar class ButtonWithMenu : public ToolButton { Q_OBJECT public: struct Item { QString text; QIcon icon; QVariant userData; Item(const QString &a = QString(), const QIcon &b = QIcon()) { text = a; icon = b; } bool operator==(const Item &a) { return (a.text == text) && (a.icon.pixmap(16).toImage() == icon.pixmap(16).toImage()); } bool isEmpty() { return (text.isEmpty() && icon.isNull()); } void clear() { text = QString(); icon = QIcon(); userData = QVariant(); } }; explicit ButtonWithMenu(QWidget* parent = 0); ~ButtonWithMenu(); void addItem(const Item &item); void addItems(const QVector &items); void removeItem(const Item &item); void setCurrentItem(const Item &item, bool emitSignal = true); void setCurrentIndex(int index, bool emitSignal = true); Item currentItem(); QVector allItems() { return m_items; } QMenu* menu() const; Q_SIGNALS: void activeItemChanged(const ButtonWithMenu::Item &item); void itemAdded(const ButtonWithMenu::Item &item); void itemRemoved(const ButtonWithMenu::Item &item); public Q_SLOTS: void clearItems(); void selectNextItem(); void selectPreviousItem(); private Q_SLOTS: void setCurrentItem(); void generateMenu(); private: - void mousePressEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent* event); + void mousePressEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent* event) override; QMenu* m_menu; QVector m_items; Item m_currentItem; WheelHelper m_wheelHelper; }; // Hint to QVector to use std::realloc on item moving Q_DECLARE_TYPEINFO(ButtonWithMenu::Item, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(ButtonWithMenu::Item) #endif // BUTTONWITHMENU_H diff --git a/src/lib/tools/clickablelabel.h b/src/lib/tools/clickablelabel.h index b2434c37..1db10bc0 100644 --- a/src/lib/tools/clickablelabel.h +++ b/src/lib/tools/clickablelabel.h @@ -1,61 +1,61 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef CLICKABLELABEL_H #define CLICKABLELABEL_H #include #include #include "qzcommon.h" class QMouseEvent; class FALKON_EXPORT ClickableLabel : public QLabel { Q_OBJECT Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize) Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth) Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight) Q_PROPERTY(QString themeIcon READ themeIcon WRITE setThemeIcon) Q_PROPERTY(QIcon fallbackIcon READ fallbackIcon WRITE setFallbackIcon) public: explicit ClickableLabel(QWidget* parent = 0); QString themeIcon() const; void setThemeIcon(const QString &name); QIcon fallbackIcon() const; void setFallbackIcon(const QIcon &fallbackIcon); Q_SIGNALS: void clicked(QPoint); void middleClicked(QPoint); private: void updateIcon(); - void resizeEvent(QResizeEvent *ev); - void mouseReleaseEvent(QMouseEvent* ev); + void resizeEvent(QResizeEvent *ev) override; + void mouseReleaseEvent(QMouseEvent* ev) override; QString m_themeIcon; QIcon m_fallbackIcon; }; #endif // CLICKABLELABEL_H diff --git a/src/lib/tools/enhancedmenu.h b/src/lib/tools/enhancedmenu.h index d079c612..9b64792a 100644 --- a/src/lib/tools/enhancedmenu.h +++ b/src/lib/tools/enhancedmenu.h @@ -1,71 +1,71 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef ENHANCEDMENU_H #define ENHANCEDMENU_H #include #include "qzcommon.h" class Action; class FALKON_EXPORT Menu : public QMenu { Q_OBJECT public: explicit Menu(QWidget* parent = 0); explicit Menu(const QString &title, QWidget* parent = 0); // Default is false, menu will NOT be closed on middle click bool closeOnMiddleClick() const; void setCloseOnMiddleClick(bool close); Q_SIGNALS: void menuMiddleClicked(Menu*); public Q_SLOTS: private: - void mouseReleaseEvent(QMouseEvent* e); - void keyPressEvent(QKeyEvent* e); + void mouseReleaseEvent(QMouseEvent* e) override; + void keyPressEvent(QKeyEvent* e) override; void closeAllMenus(); bool m_closeOnMiddleClick; }; class FALKON_EXPORT Action : public QAction { Q_OBJECT public: explicit Action(QObject* parent = 0); explicit Action(const QString &text, QObject* parent = 0); explicit Action(const QIcon &icon, const QString &text, QObject* parent = 0); Q_SIGNALS: void ctrlTriggered(); void shiftTriggered(); public Q_SLOTS: void emitCtrlTriggered(); void emitShiftTriggered(); }; #endif // ENHANCEDMENU_H diff --git a/src/lib/tools/focusselectlineedit.h b/src/lib/tools/focusselectlineedit.h index b00b5d2b..e387e88e 100644 --- a/src/lib/tools/focusselectlineedit.h +++ b/src/lib/tools/focusselectlineedit.h @@ -1,42 +1,42 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef FOCUSSELECTLINEEDIT_H #define FOCUSSELECTLINEEDIT_H #include #include "qzcommon.h" class FALKON_EXPORT FocusSelectLineEdit : public QLineEdit { Q_OBJECT public: explicit FocusSelectLineEdit(QWidget* parent = 0); public Q_SLOTS: void setFocus(); protected: - void focusInEvent(QFocusEvent* event); - void mousePressEvent(QMouseEvent* event); + void focusInEvent(QFocusEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; bool m_mouseFocusReason; }; #endif // FOCUSSELECTLINEEDIT_H diff --git a/src/lib/tools/headerview.h b/src/lib/tools/headerview.h index 87ec2aa1..f5595ed5 100644 --- a/src/lib/tools/headerview.h +++ b/src/lib/tools/headerview.h @@ -1,53 +1,53 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef HEADERVIEW_H #define HEADERVIEW_H #include class QContextMenuEvent; #include "qzcommon.h" class FALKON_EXPORT HeaderView : public QHeaderView { Q_OBJECT public: explicit HeaderView(QAbstractItemView* parent); void setDefaultSectionSizes(const QList &sizes); QList defaultSectionSizes() const; bool restoreState(const QByteArray &state); private Q_SLOTS: void toggleSectionVisibility(); private: - void showEvent(QShowEvent* event); - void contextMenuEvent(QContextMenuEvent* event); + void showEvent(QShowEvent* event) override; + void contextMenuEvent(QContextMenuEvent* event) override; QAbstractItemView* m_parent; QMenu* m_menu; bool m_resizeOnShow; QList m_sectionSizes; QByteArray m_restoreData; }; #endif // HEADERVIEW_H diff --git a/src/lib/tools/horizontallistwidget.h b/src/lib/tools/horizontallistwidget.h index ddf2089d..0ccfe475 100644 --- a/src/lib/tools/horizontallistwidget.h +++ b/src/lib/tools/horizontallistwidget.h @@ -1,37 +1,37 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2013-2014 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 . * ============================================================ */ #ifndef HORIZONTALLISTWIDGET_H #define HORIZONTALLISTWIDGET_H #include class HorizontalListWidget : public QListWidget { public: explicit HorizontalListWidget(QWidget* parent = 0); private: - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent* event); + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; + void wheelEvent(QWheelEvent* event) override; bool m_mouseDown; }; #endif // HORIZONTALLISTWIDGET_H diff --git a/src/lib/tools/listitemdelegate.h b/src/lib/tools/listitemdelegate.h index 393c62ec..c4b9923f 100644 --- a/src/lib/tools/listitemdelegate.h +++ b/src/lib/tools/listitemdelegate.h @@ -1,48 +1,48 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef LISTITEMDELEGATE_H #define LISTITEMDELEGATE_H #include #include "qzcommon.h" class FALKON_EXPORT ListItemDelegate : public QStyledItemDelegate { public: explicit ListItemDelegate(int iconSize, QWidget* parent); void setUpdateParentHeight(bool update); void setUniformItemSizes(bool uniform); int itemHeight() const; - void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: int m_iconSize; bool m_updateParentHeight; bool m_uniformItemSizes; mutable int m_itemHeight; mutable int m_itemWidth; mutable int m_padding; }; #endif // LISTITEMDELEGATE_H diff --git a/src/lib/tools/progressbar.h b/src/lib/tools/progressbar.h index 6bc29c42..66a8412b 100644 --- a/src/lib/tools/progressbar.h +++ b/src/lib/tools/progressbar.h @@ -1,45 +1,45 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef PROGRESSBAR_H #define PROGRESSBAR_H #include #include "qzcommon.h" class QStyleOptionProgressBar; class FALKON_EXPORT ProgressBar : public QWidget { Q_OBJECT public: explicit ProgressBar(QWidget* parent = 0); public Q_SLOTS: void setValue(int value); protected: - void paintEvent(QPaintEvent* e); + void paintEvent(QPaintEvent* e) override; void initStyleOption(QStyleOptionProgressBar* option); private: int m_value; int m_lastPaintedValue; }; #endif // PROGRESSBAR_H diff --git a/src/lib/tools/toolbutton.h b/src/lib/tools/toolbutton.h index 6ab01769..fe0e2d8f 100644 --- a/src/lib/tools/toolbutton.h +++ b/src/lib/tools/toolbutton.h @@ -1,113 +1,113 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef TOOLBUTTON_H #define TOOLBUTTON_H #include #include #include "qzcommon.h" class FALKON_EXPORT ToolButton : public QToolButton { Q_OBJECT Q_PROPERTY(QSize fixedsize READ size WRITE setFixedSize) Q_PROPERTY(int fixedwidth READ width WRITE setFixedWidth) Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight) Q_PROPERTY(QImage multiIcon READ multiIcon WRITE setMultiIcon) Q_PROPERTY(QIcon icon READ icon WRITE setIcon) Q_PROPERTY(QString themeIcon READ themeIcon WRITE setThemeIcon) Q_PROPERTY(QIcon fallbackIcon READ fallbackIcon WRITE setFallbackIcon) public: explicit ToolButton(QWidget* parent = 0); // MultiIcon - Image containing pixmaps for all button states QImage multiIcon() const; void setMultiIcon(const QImage &image); // ThemeIcon - Standard QToolButton with theme icon QString themeIcon() const; void setThemeIcon(const QString &icon); // FallbackIcon - In case theme doesn't contain ThemeIcon QIcon fallbackIcon() const; void setFallbackIcon(const QIcon &fallbackIcon); // Icon - Standard QToolButton with icon QIcon icon() const; void setIcon(const QIcon &icon); // Menu - Menu is handled in ToolButton and is not passed to QToolButton // There won't be menu indicator shown in the button // QToolButton::MenuButtonPopup is not supported QMenu* menu() const; void setMenu(QMenu* menu); // Align the right corner of menu to the right corner of button bool showMenuInside() const; void setShowMenuInside(bool enable); // Show button menu on right click bool showMenuOnRightClick() const; void setShowMenuOnRightClick(bool enable); // Set the button to look as it was in toolbar // (it now only sets the correct icon size) bool toolbarButtonLook() const; void setToolbarButtonLook(bool enable); Q_SIGNALS: void middleMouseClicked(); void controlClicked(); void doubleClicked(); // It is needed to use these signals with ShowMenuInside void aboutToShowMenu(); void aboutToHideMenu(); private Q_SLOTS: void menuAboutToHide(); void showMenu(); protected: - void mousePressEvent(QMouseEvent* e); - void mouseReleaseEvent(QMouseEvent* e); - void mouseDoubleClickEvent(QMouseEvent* e); - void contextMenuEvent(QContextMenuEvent *e); - void paintEvent(QPaintEvent* e); + void mousePressEvent(QMouseEvent* e) override; + void mouseReleaseEvent(QMouseEvent* e) override; + void mouseDoubleClickEvent(QMouseEvent* e) override; + void contextMenuEvent(QContextMenuEvent *e) override; + void paintEvent(QPaintEvent* e) override; private: QImage m_multiIcon; QString m_themeIcon; QTimer m_pressTimer; QMenu* m_menu; enum Options { MultiIconOption = 1, ShowMenuInsideOption = 2, ToolBarLookOption = 4, ShowMenuOnRightClick = 8 }; Q_DECLARE_FLAGS(OptionsFlags, Options) OptionsFlags m_options; }; #endif // TOOLBUTTON_H diff --git a/src/lib/tools/treewidget.h b/src/lib/tools/treewidget.h index 1d2cfadb..ad9b5081 100644 --- a/src/lib/tools/treewidget.h +++ b/src/lib/tools/treewidget.h @@ -1,68 +1,68 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 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 . * ============================================================ */ #ifndef BOOKMARKSTREEWIDGET_H #define BOOKMARKSTREEWIDGET_H #include "qzcommon.h" #include class FALKON_EXPORT TreeWidget : public QTreeWidget { Q_OBJECT public: explicit TreeWidget(QWidget* parent = 0); enum ItemShowMode { ItemsCollapsed = 0, ItemsExpanded = 1 }; ItemShowMode defaultItemShowMode() { return m_showMode; } void setDefaultItemShowMode(ItemShowMode mode) { m_showMode = mode; } QList allItems(); bool appendToParentItem(const QString &parentText, QTreeWidgetItem* item); bool appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item); bool prependToParentItem(const QString &parentText, QTreeWidgetItem* item); bool prependToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item); void addTopLevelItem(QTreeWidgetItem* item); void addTopLevelItems(const QList &items); void insertTopLevelItem(int index, QTreeWidgetItem* item); void insertTopLevelItems(int index, const QList &items); void deleteItem(QTreeWidgetItem* item); void deleteItems(const QList &items); Q_SIGNALS: void itemControlClicked(QTreeWidgetItem* item); void itemMiddleButtonClicked(QTreeWidgetItem* item); public Q_SLOTS: void filterString(const QString &string); void clear(); private Q_SLOTS: void sheduleRefresh(); private: - void mousePressEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event) override; void iterateAllItems(QTreeWidgetItem* parent); bool m_refreshAllItemsNeeded; QList m_allTreeItems; ItemShowMode m_showMode; }; #endif // BOOKMARKSTREEWIDGET_H diff --git a/src/lib/webengine/webinspector.h b/src/lib/webengine/webinspector.h index 830415c4..67b5c30b 100644 --- a/src/lib/webengine/webinspector.h +++ b/src/lib/webengine/webinspector.h @@ -1,57 +1,57 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2017 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 "qzcommon.h" class WebView; class FALKON_EXPORT WebInspector : public QWebEngineView { Q_OBJECT public: explicit WebInspector(QWidget *parent = Q_NULLPTR); ~WebInspector(); void setView(WebView *view); void inspectElement(); QSize sizeHint() const override; static bool isEnabled(); static void pushView(QWebEngineView *view); static void registerView(QWebEngineView *view); static void unregisterView(QWebEngineView *view); private Q_SLOTS: void loadFinished(); private: - void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; static QList s_views; int m_height; QSize m_windowSize; bool m_inspectElement = false; WebView *m_view; }; diff --git a/src/lib/webengine/webpage.h b/src/lib/webengine/webpage.h index 0b1aa894..80061184 100644 --- a/src/lib/webengine/webpage.h +++ b/src/lib/webengine/webpage.h @@ -1,124 +1,124 @@ /* ============================================================ * 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 . * ============================================================ */ #ifndef WEBPAGE_H #define WEBPAGE_H #include #include #include #include #include "qzcommon.h" class QEventLoop; class QWebEngineDownloadItem; class QWebEngineRegisterProtocolHandlerRequest; class WebView; class WebHitTestResult; class DelayedFileWatcher; class FALKON_EXPORT WebPage : public QWebEnginePage { Q_OBJECT public: enum JsWorld { UnsafeJsWorld = QWebEngineScript::MainWorld, SafeJsWorld = QWebEngineScript::ApplicationWorld }; explicit WebPage(QObject* parent = 0); ~WebPage(); WebView *view() const; bool execPrintPage(QPrinter *printer, int timeout = 1000); QVariant execJavaScript(const QString &scriptSource, quint32 worldId = UnsafeJsWorld, int timeout = 500); QPointF mapToViewport(const QPointF &pos) const; WebHitTestResult hitTestContent(const QPoint &pos) const; void scroll(int x, int y); void setScrollPosition(const QPointF &pos); - bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) Q_DECL_OVERRIDE; - bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE; - void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) Q_DECL_OVERRIDE; + bool javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString* result) override; + bool javaScriptConfirm(const QUrl &securityOrigin, const QString &msg) override; + void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) override; void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override; QStringList autoFillUsernames() const; QUrl registerProtocolHandlerRequestUrl() const; QString registerProtocolHandlerRequestScheme() const; bool isRunningLoop(); bool isLoading() const; static QStringList internalSchemes(); static QStringList supportedSchemes(); static void addSupportedScheme(const QString &scheme); static void removeSupportedScheme(const QString &scheme); Q_SIGNALS: void privacyChanged(bool status); void printRequested(); void navigationRequestAccepted(const QUrl &url, NavigationType type, bool isMainFrame); protected Q_SLOTS: void progress(int prog); void finished(); private Q_SLOTS: void urlChanged(const QUrl &url); void watchedFileChanged(const QString &file); void windowCloseRequested(); void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature); void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode); private: - bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) Q_DECL_OVERRIDE; - bool certificateError(const QWebEngineCertificateError &error) Q_DECL_OVERRIDE; - QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE; - QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) Q_DECL_OVERRIDE; + bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override; + bool certificateError(const QWebEngineCertificateError &error) override; + QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes) override; + QWebEnginePage* createWindow(QWebEnginePage::WebWindowType type) override; void handleUnknownProtocol(const QUrl &url); void desktopServicesOpen(const QUrl &url); static QString s_lastUploadLocation; static QUrl s_lastUnsupportedUrl; static QTime s_lastUnsupportedUrlTime; DelayedFileWatcher* m_fileWatcher; QEventLoop* m_runningLoop; QStringList m_autoFillUsernames; QWebEngineRegisterProtocolHandlerRequest *m_registerProtocolHandlerRequest = nullptr; int m_loadProgress; bool m_blockAlerts; bool m_secureStatus; QMetaObject::Connection m_contentsResizedConnection; friend class WebView; }; #endif // WEBPAGE_H diff --git a/src/lib/webtab/searchtoolbar.h b/src/lib/webtab/searchtoolbar.h index 6abf78cc..d018c74c 100644 --- a/src/lib/webtab/searchtoolbar.h +++ b/src/lib/webtab/searchtoolbar.h @@ -1,66 +1,66 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2017 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 . * ============================================================ */ #ifndef SEARCHTOOLBAR_H #define SEARCHTOOLBAR_H #include #include "qzcommon.h" namespace Ui { class SearchToolbar; } class QLineEdit; class WebView; class LineEdit; class FALKON_EXPORT SearchToolBar : public QWidget { Q_OBJECT public: explicit SearchToolBar(WebView* view, QWidget* parent = 0); ~SearchToolBar(); void showMinimalInPopupWindow(); void focusSearchLine(); - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; public Q_SLOTS: void setText(const QString &text); void searchText(const QString &text); void updateFindFlags(); void caseSensitivityChanged(); void findNext(); void findPrevious(); void close(); private: Ui::SearchToolbar* ui; WebView* m_view; QWebEnginePage::FindFlags m_findFlags; int m_searchRequests = 0; }; #endif // SEARCHTOOLBAR_H diff --git a/src/lib/webtab/tabbedwebview.h b/src/lib/webtab/tabbedwebview.h index 8e896487..09a8c22e 100644 --- a/src/lib/webtab/tabbedwebview.h +++ b/src/lib/webtab/tabbedwebview.h @@ -1,86 +1,86 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2015 David Rosca * 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 . * ============================================================ */ #ifndef TABBEDWEBVIEW_H #define TABBEDWEBVIEW_H #include "qzcommon.h" #include "webview.h" class QLabel; class QHostInfo; class BrowserWindow; class TabWidget; class WebPage; class WebTab; class Menu; class FALKON_EXPORT TabbedWebView : public WebView { Q_OBJECT public: explicit TabbedWebView(WebTab* webTab); void setPage(WebPage* page); // BrowserWindow can be null! BrowserWindow* browserWindow() const; void setBrowserWindow(BrowserWindow* window); WebTab* webTab() const; QString getIp() const; int tabIndex() const; - QWidget* overlayWidget() Q_DECL_OVERRIDE; - void closeView() Q_DECL_OVERRIDE; - void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) Q_DECL_OVERRIDE; + QWidget* overlayWidget() override; + void closeView() override; + void loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position) override; - bool isFullScreen() Q_DECL_OVERRIDE; - void requestFullScreen(bool enable) Q_DECL_OVERRIDE; + bool isFullScreen() override; + void requestFullScreen(bool enable) override; Q_SIGNALS: void wantsCloseTab(int); void ipChanged(const QString&); public Q_SLOTS: void setAsCurrentTab(); void userLoadAction(const LoadRequest &req); private Q_SLOTS: void slotLoadStarted(); void slotLoadFinished(); void slotLoadProgress(int prog); void linkHovered(const QString &link); void setIp(const QHostInfo &info); void inspectElement(); private: - void _contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; - void _mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void _contextMenuEvent(QContextMenuEvent *event) override; + void _mouseMoveEvent(QMouseEvent *event) override; BrowserWindow* m_window; WebTab* m_webTab; Menu* m_menu; QString m_currentIp; }; #endif // TABBEDWEBVIEW_H diff --git a/src/plugins/AutoScroll/autoscroller.h b/src/plugins/AutoScroll/autoscroller.h index b6326227..d0a396bc 100644 --- a/src/plugins/AutoScroll/autoscroller.h +++ b/src/plugins/AutoScroll/autoscroller.h @@ -1,74 +1,74 @@ /* ============================================================ * AutoScroll - Autoscroll for Falkon * Copyright (C) 2014-2017 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 . * ============================================================ */ #ifndef AUTOSCROLLER_H #define AUTOSCROLLER_H #include #include class QMouseEvent; class QWheelEvent; class QRect; class WebView; class FrameScroller; class ScrollIndicator : public QLabel { public: explicit ScrollIndicator(QWidget *parent = nullptr); Qt::Orientations orientations() const; void setOrientations(Qt::Orientations orientations); private: void paintEvent(QPaintEvent *event) override; Qt::Orientations m_orientations; }; class AutoScroller : public QObject { Q_OBJECT public: explicit AutoScroller(const QString &settingsFile, QObject* parent = 0); ~AutoScroller(); bool mouseMove(QObject* obj, QMouseEvent* event); bool mousePress(QObject* obj, QMouseEvent* event); bool mouseRelease(QObject* obj, QMouseEvent* event); bool wheel(QObject* obj, QWheelEvent *event); double scrollDivider() const; void setScrollDivider(double divider); private: - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; bool showIndicator(WebView* view, const QPoint &pos); void stopScrolling(); QRect indicatorGlobalRect() const; WebView* m_view; ScrollIndicator* m_indicator; FrameScroller* m_frameScroller; QString m_settingsFile; }; #endif // AUTOSCROLLER_H diff --git a/src/plugins/FlashCookieManager/fcm_dialog.h b/src/plugins/FlashCookieManager/fcm_dialog.h index 5400290c..7b36dec4 100644 --- a/src/plugins/FlashCookieManager/fcm_dialog.h +++ b/src/plugins/FlashCookieManager/fcm_dialog.h @@ -1,80 +1,80 @@ /* ============================================================ * FlashCookieManager plugin for Falkon * Copyright (C) 2014 S. Razi Alavizadeh * Copyright (C) 2010-2014 David Rosca * * some codes and ideas are taken from cookiemanager.cpp and cookiemanager.ui * * 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 . * ============================================================ */ #ifndef FCM_DIALOG_H #define FCM_DIALOG_H #include namespace Ui { class FCM_Dialog; } class QTreeWidgetItem; class BrowserWindow; class FCM_Plugin; class FCM_Dialog : public QDialog { Q_OBJECT public: explicit FCM_Dialog(FCM_Plugin* manager, QWidget* parent = 0); ~FCM_Dialog(); void refreshView(bool forceReload = false); void showPage(int index); private Q_SLOTS: void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent); void removeCookie(); void removeAll(); void refreshFlashCookiesTree(); void refreshFilters(); void addWhitelist(); void addWhitelist(const QString &origin); void removeWhitelist(); void addBlacklist(); void addBlacklist(const QString &origin); void removeBlacklist(); void deletePressed(); void autoModeChanged(bool state); void filterString(const QString &string); void reloadFromDisk(); void cookieTreeContextMenuRequested(const QPoint &pos); private: - void closeEvent(QCloseEvent* e); - void keyPressEvent(QKeyEvent* e); + void closeEvent(QCloseEvent* e) override; + void keyPressEvent(QKeyEvent* e) override; Ui::FCM_Dialog* ui; FCM_Plugin* m_manager; }; #endif // FCM_DIALOG_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h index c5a50ced..bbecc61c 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistdelegate.h @@ -1,41 +1,41 @@ /* ============================================================ * GreaseMonkey plugin for Falkon * Copyright (C) 2012 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 . * ============================================================ */ #ifndef GM_SETTINGSLISTDELEGATE_H #define GM_SETTINGSLISTDELEGATE_H #include class GM_SettingsListDelegate : public QStyledItemDelegate { public: explicit GM_SettingsListDelegate(QObject* parent = 0); int padding() const; - void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: QPixmap m_removePixmap; QIcon m_updateIcon; mutable int m_rowHeight; mutable int m_padding; }; #endif // GM_SETTINGSLISTDELEGATE_H diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h index 0c38b2ac..8c6f1cdb 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.h @@ -1,48 +1,48 @@ /* ============================================================ * GreaseMonkey plugin for Falkon * Copyright (C) 2012 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 . * ============================================================ */ #ifndef GM_SETTINGSLISTWIDGET_H #define GM_SETTINGSLISTWIDGET_H #include class GM_SettingsListDelegate; class GM_SettingsListWidget : public QListWidget { Q_OBJECT public: explicit GM_SettingsListWidget(QWidget* parent = 0); Q_SIGNALS: void removeItemRequested(QListWidgetItem* item); void updateItemRequested(QListWidgetItem* item); public Q_SLOTS: private: bool containsRemoveIcon(const QPoint &pos) const; bool containsUpdateIcon(const QPoint &pos) const; - void mousePressEvent(QMouseEvent* event); - void mouseDoubleClickEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event) override; + void mouseDoubleClickEvent(QMouseEvent* event) override; GM_SettingsListDelegate* m_delegate; }; #endif // GM_SETTINGSLISTWIDGET_H diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp index 345fa265..b9ec4d85 100644 --- a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp @@ -1,233 +1,233 @@ /* * This file is part of the mouse gesture package. * Copyright (C) 2006 Johan Thelin * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the * following conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * - Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or * other materials provided with the distribution. * - The names of its contributors may be used to endorse * or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include "QjtMouseGestureFilter.h" #include "QjtMouseGesture.h" #include #include #include #include "mousegesturerecognizer.h" /* * Internal support class to bridge the * toolkit independent mouse gesture * recognizer and the Qt specific * implementation. */ class GestureCallbackToSignal : public Gesture::MouseGestureCallback { public: GestureCallbackToSignal(QjtMouseGesture* object) { m_object = object; } - void callback() { + void callback() override { m_object->emitGestured(); } private: QjtMouseGesture* m_object; }; typedef QList GestureList; typedef QList BridgeList; /* * Private members of the QjtMouseGestureFilter class */ class QjtMouseGestureFilter::Private { public: Qt::MouseButton gestureButton; bool tracing; Gesture::MouseGestureRecognizer* mgr; QPixmap px; GestureList gestures; BridgeList bridges; }; /**********************************************************/ QjtMouseGestureFilter::QjtMouseGestureFilter(bool allowDiagonals, Qt::MouseButton gestureButton, int minimumMovement, double minimumMatch, QObject* parent) : QObject(parent) { d = new Private; d->gestureButton = gestureButton; d->tracing = false; d->mgr = new Gesture::MouseGestureRecognizer(minimumMovement, minimumMatch, allowDiagonals); } QjtMouseGestureFilter::~QjtMouseGestureFilter() { delete d->mgr; delete d; } /* * Converts the DirectionList to a Gesture::DirecionList, * creates a bridge and adds the gesture to the recognizer. */ void QjtMouseGestureFilter::addGesture(QjtMouseGesture* gesture) { Gesture::DirectionList dl; for (DirectionList::const_iterator source = gesture->directions().constBegin(); source != gesture->directions().end(); ++source) { dl.push_back(*source); } d->bridges.append(GestureCallbackToSignal(gesture)); d->gestures.append(gesture); d->mgr->addGestureDefinition(Gesture::GestureDefinition(dl, &(d->bridges[ d->bridges.size() - 1 ]))); } void QjtMouseGestureFilter::clearGestures(bool deleteGestures) { if (deleteGestures) for (GestureList::const_iterator i = d->gestures.constBegin(); i != d->gestures.constEnd(); ++i) { delete *i; } d->gestures.clear(); d->bridges.clear(); d->mgr->clearGestureDefinitions(); } bool QjtMouseGestureFilter::eventFilter(QObject* obj, QEvent* event) { switch (event->type()) { case QEvent::MouseButtonPress: if (mouseButtonPressEvent(static_cast(event), obj)) { return true; } break; case QEvent::MouseButtonRelease: if (mouseButtonReleaseEvent(static_cast(event), obj)) { return true; } break; case QEvent::MouseMove: if (mouseMoveEvent(static_cast(event), obj)) { return true; } break; case QEvent::Paint: if (paintEvent(obj, static_cast(event))) { return true; } default: break; } return QObject::eventFilter(obj, event); } bool QjtMouseGestureFilter::mouseButtonPressEvent(QMouseEvent* event, QObject* obj) { Q_UNUSED(obj) if (event->button() == d->gestureButton) { // d->px = QPixmap::grabWidget(static_cast(obj)); d->mgr->startGesture(event->pos().x(), event->pos().y()); d->tracing = true; } return false; } bool QjtMouseGestureFilter::mouseButtonReleaseEvent(QMouseEvent* event, QObject* obj) { Q_UNUSED(obj) if (d->tracing && event->button() == d->gestureButton) { d->tracing = false; return d->mgr->endGesture(event->pos().x(), event->pos().y()); // d->px = QPixmap(); // static_cast(obj)->update(); } return false; } bool QjtMouseGestureFilter::mouseMoveEvent(QMouseEvent* event, QObject* obj) { Q_UNUSED(obj) if (d->tracing) { d->mgr->addPoint(event->pos().x(), event->pos().y()); // static_cast(obj)->update(); } return false; } bool QjtMouseGestureFilter::paintEvent(QObject* obj, QPaintEvent* event) { Q_UNUSED(event) if (d->tracing) { QWidget* wid = static_cast(obj); QPainter painter(wid); painter.drawPixmap(0, 0, d->px); const Gesture::PosList points = d->mgr->currentPath(); painter.save(); QPen pe; pe.setColor(Qt::red); pe.setWidth(2); painter.setPen(pe); QVector pointPairs; for (Gesture::PosList::const_iterator iter = points.begin(); iter != points.end(); ++iter) { pointPairs << QPoint(iter->x, iter->y); } painter.setRenderHint(QPainter::Antialiasing, true); painter.drawPolyline(&pointPairs[0], pointPairs.count()); painter.restore(); painter.end(); return true; } else { return false; } } diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h index 5cfb7a0f..cf5ee1c2 100644 --- a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.h @@ -1,94 +1,94 @@ /* * This file is part of the mouse gesture package. * Copyright (C) 2006 Johan Thelin * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the * following conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * - Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or * other materials provided with the distribution. * - The names of its contributors may be used to endorse * or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #ifndef QJTMOUSEGESTUREFILTER_H #define QJTMOUSEGESTUREFILTER_H #include #include #include class QjtMouseGesture; /* * The QjtMouseGestureFilter class is a mouse * gesture recognizing event filter. * * Use it by creating it, install it as a filter * for the affected widget and add QjtMouseGesture * instances to it. * */ class QjtMouseGestureFilter : public QObject { public: /* * The gestureButton controls which mouse button * that has to be pressed during the mouse gesture. * Notice that this all events for this button are * swallowed by the filter. */ QjtMouseGestureFilter(bool allowDiagonals = false, Qt::MouseButton gestureButton = Qt::RightButton, int minimumMovement = 5, double minimumMatch = 0.9, QObject* parent = 0); ~QjtMouseGestureFilter(); /* * Adds a gesture to the filter. */ void addGesture(QjtMouseGesture* gesture); /* * Clears the filter from gestures. * * If deleteGestures is true, the QjtMouseGesture objects are deleted. */ void clearGestures(bool deleteGestures = false); bool mouseButtonPressEvent(QMouseEvent* event, QObject* obj = 0); bool mouseButtonReleaseEvent(QMouseEvent* event, QObject* obj = 0); bool mouseMoveEvent(QMouseEvent* event, QObject* obj = 0); protected: - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; private: bool paintEvent(QObject* obj, QPaintEvent* event); class Private; Private* d; }; #endif // QJTMOUSEGESTUREFILTER_H diff --git a/src/plugins/StatusBarIcons/sbi_networkicon.h b/src/plugins/StatusBarIcons/sbi_networkicon.h index 710df445..cbe9d8c0 100644 --- a/src/plugins/StatusBarIcons/sbi_networkicon.h +++ b/src/plugins/StatusBarIcons/sbi_networkicon.h @@ -1,48 +1,48 @@ /* ============================================================ * StatusBarIcons - Extra icons in statusbar for Falkon * Copyright (C) 2013-2014 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 . * ============================================================ */ #ifndef SBI_NETWORKICON_H #define SBI_NETWORKICON_H #include #include "sbi_icon.h" class QNetworkConfigurationManager; class SBI_NetworkIcon : public SBI_Icon { Q_OBJECT public: explicit SBI_NetworkIcon(BrowserWindow* window); private Q_SLOTS: void onlineStateChanged(bool online); void showDialog(); void showMenu(const QPoint &pos); void useProxy(); private: void updateToolTip(); - void enterEvent(QEvent* event); + void enterEvent(QEvent* event) override; QNetworkConfigurationManager* m_networkConfiguration; }; #endif // SBI_NETWORKICON_H diff --git a/src/plugins/TabManager/tabmanagerdelegate.h b/src/plugins/TabManager/tabmanagerdelegate.h index f8a08bce..24e76a88 100644 --- a/src/plugins/TabManager/tabmanagerdelegate.h +++ b/src/plugins/TabManager/tabmanagerdelegate.h @@ -1,39 +1,39 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2016-2017 S. Razi Alavizadeh * * 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 . * ============================================================ */ #ifndef TABMANAGERDELEGATE_H #define TABMANAGERDELEGATE_H #include class TabManagerDelegate : public QStyledItemDelegate { public: explicit TabManagerDelegate(QObject* parent = 0); - void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter* painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect, const QString &text, const QColor &color, const QString &searchText = QString()) const; QString m_filterText; }; #endif // TABMANAGERDELEGATE_H diff --git a/src/plugins/TabManager/tabmanagersettings.h b/src/plugins/TabManager/tabmanagersettings.h index caf2c32c..a4b39aae 100644 --- a/src/plugins/TabManager/tabmanagersettings.h +++ b/src/plugins/TabManager/tabmanagersettings.h @@ -1,27 +1,27 @@ #ifndef TABMANAGERSETTINGS_H #define TABMANAGERSETTINGS_H #include namespace Ui { class TabManagerSettings; } class TabManagerPlugin; class TabManagerSettings : public QDialog { Q_OBJECT public: explicit TabManagerSettings(TabManagerPlugin* plugin, QWidget *parent = 0); ~TabManagerSettings(); public Q_SLOTS: - void accept(); + void accept() override; private: Ui::TabManagerSettings* ui; TabManagerPlugin* m_plugin; }; #endif // TABMANAGERSETTINGS_H diff --git a/src/plugins/TabManager/tabmanagerwidget.cpp b/src/plugins/TabManager/tabmanagerwidget.cpp index 23d972d7..516e84d9 100644 --- a/src/plugins/TabManager/tabmanagerwidget.cpp +++ b/src/plugins/TabManager/tabmanagerwidget.cpp @@ -1,975 +1,975 @@ /* ============================================================ * TabManager plugin for Falkon * Copyright (C) 2013-2017 S. Razi Alavizadeh * 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 "tabmanagerwidget.h" #include "ui_tabmanagerwidget.h" #include "mainapplication.h" #include "browserwindow.h" #include "webtab.h" #include "webpage.h" #include "tabbedwebview.h" #include "tabwidget.h" #include "locationbar.h" #include "bookmarkstools.h" #include "bookmarkitem.h" #include "bookmarks.h" #include "tabmanagerplugin.h" #include "tldextractor/tldextractor.h" #include "tabmanagerdelegate.h" #include "tabcontextmenu.h" #include "tabbar.h" #include #include #include #include #include #include #include TLDExtractor* TabManagerWidget::s_tldExtractor = 0; TabManagerWidget::TabManagerWidget(BrowserWindow* mainClass, QWidget* parent, bool defaultWidget) : QWidget(parent) , ui(new Ui::TabManagerWidget) , m_window(mainClass) , m_webPage(0) , m_isRefreshing(false) , m_refreshBlocked(false) , m_waitForRefresh(false) , m_isDefaultWidget(defaultWidget) { if(s_tldExtractor == 0) { s_tldExtractor = TLDExtractor::instance(); s_tldExtractor->setDataSearchPaths(QStringList() << TabManagerPlugin::settingsPath()); } ui->setupUi(this); ui->treeWidget->setSelectionMode(QTreeWidget::SingleSelection); ui->treeWidget->setUniformRowHeights(true); ui->treeWidget->setColumnCount(2); ui->treeWidget->header()->hide(); ui->treeWidget->header()->setStretchLastSection(false); ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch); ui->treeWidget->header()->setSectionResizeMode(1, QHeaderView::Fixed); ui->treeWidget->header()->resizeSection(1, 16); ui->treeWidget->setExpandsOnDoubleClick(false); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->treeWidget->installEventFilter(this); ui->filterBar->installEventFilter(this); QPushButton* closeButton = new QPushButton(ui->filterBar); closeButton->setFlat(true); closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); ui->filterBar->addWidget(closeButton, LineEdit::RightSide); ui->filterBar->hide(); ui->treeWidget->setItemDelegate(new TabManagerDelegate(ui->treeWidget)); connect(closeButton, &QAbstractButton::clicked, this, &TabManagerWidget::filterBarClosed); connect(ui->filterBar, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &TabManagerWidget::onItemActivated); connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint))); connect(ui->treeWidget, SIGNAL(requestRefreshTree()), this, SLOT(delayedRefreshTree())); } TabManagerWidget::~TabManagerWidget() { delete ui; } void TabManagerWidget::setGroupType(GroupType type) { m_groupType = type; } QString TabManagerWidget::domainFromUrl(const QUrl &url, bool useHostName) { QString appendString = QL1S(":"); QString urlString = url.toString(); if (url.scheme() == "file") { return tr("Local File System:"); } else if (url.scheme() == "falkon" || urlString.isEmpty()) { return tr("Falkon:"); } else if (url.scheme() == "ftp") { appendString.prepend(tr(" [FTP]")); } QString host = url.host(); if (host.isEmpty()) { return urlString.append(appendString); } if (useHostName || host.contains(QRegExp("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$"))) { if (host.startsWith("www.", Qt::CaseInsensitive)) { host.remove(0, 4); } return host.append(appendString); } else { const QString registeredDomain = s_tldExtractor->registrableDomain(host); if (!registeredDomain.isEmpty()) { host = registeredDomain; } return host.append(appendString); } } void TabManagerWidget::delayedRefreshTree(WebPage* p) { if (m_refreshBlocked || m_waitForRefresh) { return; } if (m_isRefreshing && !p) { return; } m_webPage = p; m_waitForRefresh = true; QTimer::singleShot(50, this, &TabManagerWidget::refreshTree); } void TabManagerWidget::refreshTree() { if (m_refreshBlocked) { return; } if (m_isRefreshing && !m_webPage) { return; } // store selected items QList selectedTabs; for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); if (winItem->checkState(0) == Qt::Unchecked) { continue; } for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast(winItem->child(j)); if (!tabItem || tabItem->checkState(0) == Qt::Unchecked) { continue; } selectedTabs << tabItem->webTab(); } } ui->treeWidget->clear(); ui->treeWidget->setEnableDragTabs(m_groupType == GroupByWindow); QTreeWidgetItem* currentTabItem = nullptr; if (m_groupType == GroupByHost) { currentTabItem = groupByDomainName(true); } else if (m_groupType == GroupByDomain) { currentTabItem = groupByDomainName(); } else { // fallback to GroupByWindow m_groupType = GroupByWindow; currentTabItem = groupByWindow(); } // restore selected items for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast(winItem->child(j)); if (tabItem && selectedTabs.contains(tabItem->webTab())) { tabItem->setCheckState(0, Qt::Checked); } } } filterChanged(m_filterText, true); ui->treeWidget->expandAll(); if (currentTabItem) ui->treeWidget->scrollToItem(currentTabItem, QAbstractItemView::EnsureVisible); m_isRefreshing = false; m_waitForRefresh = false; } void TabManagerWidget::onItemActivated(QTreeWidgetItem* item, int column) { TabItem* tabItem = static_cast(item); if (!tabItem) { return; } BrowserWindow* mainWindow = tabItem->window(); QWidget* tabWidget = tabItem->webTab(); if (column == 1) { if (item->childCount() > 0) QMetaObject::invokeMethod(mainWindow ? mainWindow : mApp->getWindow(), "addTab"); else if (tabWidget && mainWindow) mainWindow->tabWidget()->requestCloseTab(mainWindow->tabWidget()->indexOf(tabWidget)); return; } if (!mainWindow) { return; } if (mainWindow->isMinimized()) { mainWindow->showNormal(); } else { mainWindow->show(); } mainWindow->activateWindow(); mainWindow->raise(); mainWindow->weView()->setFocus(); if (tabWidget && tabWidget != mainWindow->tabWidget()->currentWidget()) { mainWindow->tabWidget()->setCurrentIndex(mainWindow->tabWidget()->indexOf(tabWidget)); } } bool TabManagerWidget::isTabSelected() { bool selected = false; for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); if (parentItem->checkState(0) != Qt::Unchecked) { selected = true; break; } } return selected; } void TabManagerWidget::customContextMenuRequested(const QPoint &pos) { QMenu* menu = nullptr; TabItem* item = static_cast(ui->treeWidget->itemAt(pos)); if (item) { BrowserWindow* mainWindow = item->window(); QWidget* tabWidget = item->webTab(); if (mainWindow && tabWidget) { int index = mainWindow->tabWidget()->indexOf(tabWidget); // if items are not grouped by Window then actions "Close Other Tabs", // "Close Tabs To The Bottom" and "Close Tabs To The Top" // are ambiguous and should be hidden. TabContextMenu::Options options = TabContextMenu::VerticalTabs; if (m_groupType == GroupByWindow) { options |= TabContextMenu::ShowCloseOtherTabsActions; } menu = new TabContextMenu(index, mainWindow, options); menu->addSeparator(); } } if (!menu) menu = new QMenu; menu->setAttribute(Qt::WA_DeleteOnClose); QAction* action; QMenu groupTypeSubmenu(tr("Group by")); action = groupTypeSubmenu.addAction(tr("&Window"), this, &TabManagerWidget::changeGroupType); action->setData(GroupByWindow); action->setCheckable(true); action->setChecked(m_groupType == GroupByWindow); action = groupTypeSubmenu.addAction(tr("&Domain"), this, &TabManagerWidget::changeGroupType); action->setData(GroupByDomain); action->setCheckable(true); action->setChecked(m_groupType == GroupByDomain); action = groupTypeSubmenu.addAction(tr("&Host"), this, &TabManagerWidget::changeGroupType); action->setData(GroupByHost); action->setCheckable(true); action->setChecked(m_groupType == GroupByHost); menu->addMenu(&groupTypeSubmenu); if (m_isDefaultWidget) { menu->addAction(QIcon(":/tabmanager/data/side-by-side.png"), tr("&Show side by side"), this, &TabManagerWidget::showSideBySide)->setObjectName("sideBySide"); } menu->addSeparator(); if (isTabSelected()) { menu->addAction(QIcon(":/tabmanager/data/tab-detach.png"), tr("&Detach checked tabs"), this, &TabManagerWidget::processActions)->setObjectName("detachSelection"); menu->addAction(QIcon(":/tabmanager/data/tab-bookmark.png"), tr("Book&mark checked tabs"), this, &TabManagerWidget::processActions)->setObjectName("bookmarkSelection"); menu->addAction(QIcon(":/tabmanager/data/tab-close.png"), tr("&Close checked tabs"), this, &TabManagerWidget::processActions)->setObjectName("closeSelection"); menu->addAction(tr("&Unload checked tabs"), this, &TabManagerWidget::processActions)->setObjectName("unloadSelection"); } menu->exec(ui->treeWidget->viewport()->mapToGlobal(pos)); } void TabManagerWidget::filterChanged(const QString &filter, bool force) { if (force || filter != m_filterText) { m_filterText = filter.simplified(); ui->treeWidget->itemDelegate()->setProperty("filterText", m_filterText); if (m_filterText.isEmpty()) { for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); for (int j = 0; j < parentItem->childCount(); ++j) { QTreeWidgetItem* childItem = parentItem->child(j); childItem->setHidden(false); } parentItem->setHidden(false); parentItem->setExpanded(true); } return; } const QRegularExpression filterRegExp(filter.simplified().replace(QChar(' '), QLatin1String(".*")) .append(QLatin1String(".*")).prepend(QLatin1String(".*")), QRegularExpression::CaseInsensitiveOption); for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* parentItem = ui->treeWidget->topLevelItem(i); int visibleChildCount = 0; for (int j = 0; j < parentItem->childCount(); ++j) { TabItem* childItem = static_cast(parentItem->child(j)); if (!childItem) { continue; } if (childItem->text(0).contains(filterRegExp) || childItem->webTab()->url().toString().simplified().contains(filterRegExp)) { ++visibleChildCount; childItem->setHidden(false); } else { childItem->setHidden(true); } } if (visibleChildCount == 0) { parentItem->setHidden(true); } else { parentItem->setHidden(false); parentItem->setExpanded(true); } } } } void TabManagerWidget::filterBarClosed() { ui->filterBar->clear(); ui->filterBar->hide(); ui->treeWidget->setFocusProxy(0); ui->treeWidget->setFocus(); } bool TabManagerWidget::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); const QString text = keyEvent->text().simplified(); if (obj == ui->treeWidget) { // switch to tab/window on enter if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { onItemActivated(ui->treeWidget->currentItem(), 0); return QObject::eventFilter(obj, event); } if (!text.isEmpty() || ((keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() == Qt::Key_F)) { ui->filterBar->show(); ui->treeWidget->setFocusProxy(ui->filterBar); ui->filterBar->setFocus(); if (!text.isEmpty() && text.at(0).isPrint()) { ui->filterBar->setText(ui->filterBar->text() + text); } return true; } } else if (obj == ui->filterBar) { bool isNavigationOrActionKey = keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || keyEvent->key() == Qt::Key_PageDown || keyEvent->key() == Qt::Key_PageUp || keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return; // send scroll or action press key to treeWidget if (isNavigationOrActionKey) { QKeyEvent ev(QKeyEvent::KeyPress, keyEvent->key(), keyEvent->modifiers()); QApplication::sendEvent(ui->treeWidget, &ev); return false; } } } if (obj == ui->treeWidget && (event->type() == QEvent::Resize || event->type() == QEvent::Show)) ui->treeWidget->setColumnHidden(1, ui->treeWidget->viewport()->width() < 150); return QObject::eventFilter(obj, event); } void TabManagerWidget::processActions() { if (!sender()) { return; } m_refreshBlocked = true; QHash selectedTabs; const QString &command = sender()->objectName(); for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i); if (winItem->checkState(0) == Qt::Unchecked) { continue; } for (int j = 0; j < winItem->childCount(); ++j) { TabItem* tabItem = static_cast(winItem->child(j)); if (!tabItem || tabItem->checkState(0) == Qt::Unchecked) { continue; } BrowserWindow* mainWindow = tabItem->window(); WebTab* webTab = tabItem->webTab(); // current supported actions are not applied to pinned tabs if (webTab->isPinned()) { tabItem->setCheckState(0, Qt::Unchecked); continue; } selectedTabs.insertMulti(mainWindow, webTab); } winItem->setCheckState(0, Qt::Unchecked); } if (!selectedTabs.isEmpty()) { if (command == "closeSelection") { closeSelectedTabs(selectedTabs); } else if (command == "detachSelection") { detachSelectedTabs(selectedTabs); } else if (command == "bookmarkSelection") { bookmarkSelectedTabs(selectedTabs); } else if (command == "unloadSelection") { unloadSelectedTabs(selectedTabs); } } m_refreshBlocked = false; delayedRefreshTree(); } void TabManagerWidget::changeGroupType() { QAction* action = qobject_cast(sender()); if (action) { int type = action->data().toInt(); if (m_groupType != GroupType(type)) { m_groupType = GroupType(type); delayedRefreshTree(); emit groupTypeChanged(m_groupType); } } } void TabManagerWidget::closeSelectedTabs(const QHash &tabsHash) { if (tabsHash.isEmpty()) { return; } const QList &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { QList tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->requestCloseTab(webTab->tabIndex()); } } } static void detachTabsTo(BrowserWindow* targetWindow, const QHash &tabsHash) { const QList &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { const QList &tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->detachTab(webTab); if (mainWindow && mainWindow->tabCount() == 0) { mainWindow->close(); mainWindow = 0; } targetWindow->tabWidget()->addView(webTab, Qz::NT_NotSelectedTab); } } } void TabManagerWidget::detachSelectedTabs(const QHash &tabsHash) { if (tabsHash.isEmpty() || (tabsHash.uniqueKeys().size() == 1 && tabsHash.size() == tabsHash.keys().at(0)->tabCount())) { return; } BrowserWindow* newWindow = mApp->createWindow(Qz::BW_OtherRestoredWindow); newWindow->move(mApp->desktop()->availableGeometry(this).topLeft() + QPoint(30, 30)); detachTabsTo(newWindow, tabsHash); } bool TabManagerWidget::bookmarkSelectedTabs(const QHash &tabsHash) { QDialog* dialog = new QDialog(getWindow(), Qt::WindowStaysOnTopHint | Qt::MSWindowsFixedSizeDialogHint); QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, dialog); QLabel* label = new QLabel(dialog); BookmarksFoldersButton* folderButton = new BookmarksFoldersButton(dialog); QDialogButtonBox* box = new QDialogButtonBox(dialog); box->addButton(QDialogButtonBox::Ok); box->addButton(QDialogButtonBox::Cancel); QObject::connect(box, &QDialogButtonBox::rejected, dialog, &QDialog::reject); QObject::connect(box, &QDialogButtonBox::accepted, dialog, &QDialog::accept); layout->addWidget(label); layout->addWidget(folderButton); layout->addWidget(box); label->setText(tr("Choose folder for bookmarks:")); dialog->setWindowTitle(tr("Bookmark Selected Tabs")); QSize size = dialog->size(); size.setWidth(350); dialog->resize(size); dialog->exec(); if (dialog->result() == QDialog::Rejected) { return false; } foreach (WebTab* tab, tabsHash) { if (!tab->url().isEmpty()) { BookmarkItem* bookmark = new BookmarkItem(BookmarkItem::Url); bookmark->setTitle(tab->title()); bookmark->setUrl(tab->url()); mApp->bookmarks()->addBookmark(folderButton->selectedFolder(), bookmark); } } delete dialog; return true; } void TabManagerWidget::unloadSelectedTabs(const QHash &tabsHash) { if (tabsHash.isEmpty()) { return; } const QList &windows = tabsHash.uniqueKeys(); foreach (BrowserWindow* mainWindow, windows) { QList tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { mainWindow->tabWidget()->unloadTab(webTab->tabIndex()); } } } QTreeWidgetItem* TabManagerWidget::groupByDomainName(bool useHostName) { QTreeWidgetItem* currentTabItem = nullptr; QList windows = mApp->windows(); int currentWindowIdx = windows.indexOf(getWindow()); if (currentWindowIdx == -1) { // getWindow() instance is closing return nullptr; } QMap tabsGroupedByDomain; for (int win = 0; win < windows.count(); ++win) { BrowserWindow* mainWin = windows.at(win); QList tabs = mainWin->tabWidget()->allTabs(); for (int tab = 0; tab < tabs.count(); ++tab) { WebTab* webTab = tabs.at(tab); if (webTab->webView() && m_webPage == webTab->webView()->page()) { m_webPage = 0; continue; } QString domain = domainFromUrl(webTab->url(), useHostName); if (!tabsGroupedByDomain.contains(domain)) { TabItem* groupItem = new TabItem(ui->treeWidget, false, false, 0, false); groupItem->setTitle(domain); groupItem->setIsActiveOrCaption(true); tabsGroupedByDomain.insert(domain, groupItem); } QTreeWidgetItem* groupItem = tabsGroupedByDomain.value(domain); TabItem* tabItem = new TabItem(ui->treeWidget, false, true, groupItem); tabItem->setBrowserWindow(mainWin); tabItem->setWebTab(webTab); if (webTab == mainWin->weView()->webTab()) { tabItem->setIsActiveOrCaption(true); if (mainWin == getWindow()) currentTabItem = tabItem; } tabItem->updateIcon(); tabItem->setTitle(webTab->title()); } } ui->treeWidget->insertTopLevelItems(0, tabsGroupedByDomain.values()); return currentTabItem; } QTreeWidgetItem* TabManagerWidget::groupByWindow() { QTreeWidgetItem* currentTabItem = nullptr; QList windows = mApp->windows(); int currentWindowIdx = windows.indexOf(getWindow()); if (currentWindowIdx == -1) { return nullptr; } m_isRefreshing = true; if (!m_isDefaultWidget) { windows.move(currentWindowIdx, 0); currentWindowIdx = 0; } for (int win = 0; win < windows.count(); ++win) { BrowserWindow* mainWin = windows.at(win); TabItem* winItem = new TabItem(ui->treeWidget, true, false); winItem->setBrowserWindow(mainWin); winItem->setText(0, tr("Window %1").arg(QString::number(win + 1))); winItem->setToolTip(0, tr("Double click to switch")); winItem->setIsActiveOrCaption(win == currentWindowIdx); QList tabs = mainWin->tabWidget()->allTabs(); for (int tab = 0; tab < tabs.count(); ++tab) { WebTab* webTab = tabs.at(tab); if (webTab->webView() && m_webPage == webTab->webView()->page()) { m_webPage = 0; continue; } TabItem* tabItem = new TabItem(ui->treeWidget, true, true, winItem); tabItem->setBrowserWindow(mainWin); tabItem->setWebTab(webTab); if (webTab == mainWin->weView()->webTab()) { tabItem->setIsActiveOrCaption(true); if (mainWin == getWindow()) currentTabItem = tabItem; } tabItem->updateIcon(); tabItem->setTitle(webTab->title()); } } return currentTabItem; } BrowserWindow* TabManagerWidget::getWindow() { if (m_isDefaultWidget || !m_window) { return mApp->getWindow(); } else { return m_window.data(); } } TabItem::TabItem(QTreeWidget* treeWidget, bool supportDrag, bool isTab, QTreeWidgetItem* parent, bool addToTree) : QObject() , QTreeWidgetItem(addToTree ? (parent ? parent : treeWidget->invisibleRootItem()) : 0, 1) , m_treeWidget(treeWidget) , m_window(0) , m_webTab(0) , m_isTab(isTab) { Qt::ItemFlags flgs = flags() | (parent ? Qt::ItemIsUserCheckable : Qt::ItemIsUserCheckable | Qt::ItemIsTristate); if (supportDrag) { if (isTab) { flgs |= Qt::ItemIsDragEnabled | Qt::ItemNeverHasChildren; flgs &= ~Qt::ItemIsDropEnabled; } else { flgs |= Qt::ItemIsDropEnabled; flgs &= ~Qt::ItemIsDragEnabled; } } setFlags(flgs); setCheckState(0, Qt::Unchecked); } BrowserWindow* TabItem::window() const { return m_window; } void TabItem::setBrowserWindow(BrowserWindow* window) { m_window = window; } WebTab* TabItem::webTab() const { return m_webTab; } void TabItem::setWebTab(WebTab* webTab) { m_webTab = webTab; if (m_webTab->isRestored()) setIsActiveOrCaption(m_webTab->isCurrentTab()); else setIsSavedTab(true); connect(m_webTab->webView(), &QWebEngineView::titleChanged, this, &TabItem::setTitle); connect(m_webTab->webView(), &QWebEngineView::iconChanged, this, &TabItem::updateIcon); auto pageChanged = [this](WebPage *page) { connect(page, &WebPage::audioMutedChanged, this, &TabItem::updateIcon); connect(page, &WebPage::loadFinished, this, &TabItem::updateIcon); connect(page, &WebPage::loadStarted, this, &TabItem::updateIcon); }; pageChanged(m_webTab->webView()->page()); connect(m_webTab->webView(), &WebView::pageChanged, this, pageChanged); } void TabItem::updateIcon() { if (!m_webTab) return; if (!m_webTab->isLoading()) { if (!m_webTab->isPinned()) { if (m_webTab->isMuted()) { setIcon(0, QIcon::fromTheme(QSL("audio-volume-muted"), QIcon(QSL(":icons/other/audiomuted.svg")))); } else if (!m_webTab->isMuted() && m_webTab->webView()->page()->recentlyAudible()) { setIcon(0, QIcon::fromTheme(QSL("audio-volume-high"), QIcon(QSL(":icons/other/audioplaying.svg")))); } else { setIcon(0, m_webTab->icon()); } } else { setIcon(0, QIcon(":tabmanager/data/tab-pinned.png")); } if (m_webTab->isRestored()) setIsActiveOrCaption(m_webTab->isCurrentTab()); else setIsSavedTab(true); } else { setIcon(0, QIcon(":tabmanager/data/tab-loading.png")); setIsActiveOrCaption(m_webTab->isCurrentTab()); } } void TabItem::setTitle(const QString &title) { setText(0, title); setToolTip(0, title); } void TabItem::setIsActiveOrCaption(bool yes) { setData(0, ActiveOrCaptionRole, yes ? QVariant(true) : QVariant()); setIsSavedTab(false); } void TabItem::setIsSavedTab(bool yes) { setData(0, SavedRole, yes ? QVariant(true) : QVariant()); } bool TabItem::isTab() const { return m_isTab; } TabTreeWidget::TabTreeWidget(QWidget *parent) : QTreeWidget(parent) { invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled); } Qt::DropActions TabTreeWidget::supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } #define MIMETYPE QLatin1String("application/falkon.tabs") QStringList TabTreeWidget::mimeTypes() const { QStringList types; types.append(MIMETYPE); return types; } -QMimeData *TabTreeWidget::mimeData(const QList &items) const +QMimeData *TabTreeWidget::mimeData(const QList items) const { QMimeData* mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); if (items.size() > 0) { TabItem* tabItem = static_cast(items.at(0)); if (!tabItem || !tabItem->isTab()) return 0; stream << (quintptr) tabItem->window() << (quintptr) tabItem->webTab(); mimeData->setData(MIMETYPE, encodedData); return mimeData; } return 0; } bool TabTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) { if (action == Qt::IgnoreAction) { return true; } TabItem* parentItem = static_cast(parent); if (!data->hasFormat(MIMETYPE) || !parentItem) { return false; } Q_ASSERT(!parentItem->isTab()); BrowserWindow* targetWindow = parentItem->window(); QByteArray encodedData = data->data(MIMETYPE); QDataStream stream(&encodedData, QIODevice::ReadOnly); if (!stream.atEnd()) { quintptr webTabPtr; quintptr windowPtr; stream >> windowPtr >> webTabPtr; WebTab* webTab = (WebTab*) webTabPtr; BrowserWindow* window = (BrowserWindow*) windowPtr; if (window == targetWindow) { if (index > 0 && webTab->tabIndex() < index) --index; if (webTab->isPinned() && index >= targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount() - 1; if (!webTab->isPinned() && index < targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount(); if (index != webTab->tabIndex()) { targetWindow->tabWidget()->tabBar()->moveTab(webTab->tabIndex(), index); if (!webTab->isCurrentTab()) emit requestRefreshTree(); } else { return false; } } else if (!webTab->isPinned()) { QHash tabsHash; tabsHash.insert(window, webTab); detachTabsTo(targetWindow, tabsHash); if (index < targetWindow->tabWidget()->pinnedTabsCount()) index = targetWindow->tabWidget()->pinnedTabsCount(); targetWindow->tabWidget()->tabBar()->moveTab(webTab->tabIndex(), index); } } return true; } void TabTreeWidget::setEnableDragTabs(bool enable) { setDragEnabled(enable); setAcceptDrops(enable); viewport()->setAcceptDrops(enable); setDropIndicatorShown(enable); } diff --git a/src/plugins/TabManager/tabmanagerwidget.h b/src/plugins/TabManager/tabmanagerwidget.h index 2c5ce202..318416c9 100644 --- a/src/plugins/TabManager/tabmanagerwidget.h +++ b/src/plugins/TabManager/tabmanagerwidget.h @@ -1,153 +1,153 @@ /* ============================================================ * TabManager plugin for Falkon * Copyright (C) 2013-2017 S. Razi Alavizadeh * * 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 . * ============================================================ */ #ifndef TABMANAGERWIDGET_H #define TABMANAGERWIDGET_H #include #include #include #include namespace Ui { class TabManagerWidget; } class QUrl; class QTreeWidgetItem; class BrowserWindow; class WebPage; class WebTab; class WebView; class TLDExtractor; class TabTreeWidget : public QTreeWidget { Q_OBJECT public: TabTreeWidget(QWidget* parent = 0); - Qt::DropActions supportedDropActions() const; - QStringList mimeTypes() const; - QMimeData* mimeData(const QList &items) const; - bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); + Qt::DropActions supportedDropActions() const override; + QStringList mimeTypes() const override; + QMimeData* mimeData(const QList items) const override; + bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) override; void setEnableDragTabs(bool enable); Q_SIGNALS: void requestRefreshTree(); }; class TabManagerWidget : public QWidget { Q_OBJECT public: enum GroupType { GroupByWindow = 0, GroupByDomain = 1, GroupByHost = 2 }; explicit TabManagerWidget(BrowserWindow* mainClass, QWidget* parent = 0, bool defaultWidget = false); ~TabManagerWidget(); void closeSelectedTabs(const QHash &tabsHash); void detachSelectedTabs(const QHash &tabsHash); bool bookmarkSelectedTabs(const QHash &tabsHash); void unloadSelectedTabs(const QHash &tabsHash); void setGroupType(GroupType type); static QString domainFromUrl(const QUrl &url, bool useHostName = false); public Q_SLOTS: void delayedRefreshTree(WebPage* p = 0); void changeGroupType(); private: QTreeWidgetItem* groupByDomainName(bool useHostName = false); QTreeWidgetItem* groupByWindow(); BrowserWindow* getWindow(); Ui::TabManagerWidget* ui; QPointer m_window; WebPage* m_webPage; bool m_isRefreshing; bool m_refreshBlocked; bool m_waitForRefresh; bool m_isDefaultWidget; GroupType m_groupType; QString m_filterText; static TLDExtractor* s_tldExtractor; private Q_SLOTS: void refreshTree(); void processActions(); void onItemActivated(QTreeWidgetItem* item, int column); bool isTabSelected(); void customContextMenuRequested(const QPoint &pos); void filterChanged(const QString &filter, bool force = false); void filterBarClosed(); protected: - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; Q_SIGNALS: void showSideBySide(); void groupTypeChanged(TabManagerWidget::GroupType); }; class TabItem : public QObject, public QTreeWidgetItem { Q_OBJECT public: enum StateRole { ActiveOrCaptionRole = Qt::UserRole + 1, SavedRole = Qt::UserRole + 2 }; TabItem(QTreeWidget* treeWidget, bool supportDrag = true, bool isTab = true, QTreeWidgetItem* parent = 0, bool addToTree = true); BrowserWindow* window() const; void setBrowserWindow(BrowserWindow* window); WebTab* webTab() const; void setWebTab(WebTab* webTab); bool isTab() const; public Q_SLOTS: void updateIcon(); void setTitle(const QString& title); void setIsActiveOrCaption(bool yes); void setIsSavedTab(bool yes); private: QTreeWidget* m_treeWidget; BrowserWindow* m_window; WebTab* m_webTab; bool m_isTab; }; #endif // TABMANAGERWIDGET_H diff --git a/src/plugins/TabManager/tabmanagerwidgetcontroller.h b/src/plugins/TabManager/tabmanagerwidgetcontroller.h index 4f7ada95..66e3eea2 100644 --- a/src/plugins/TabManager/tabmanagerwidgetcontroller.h +++ b/src/plugins/TabManager/tabmanagerwidgetcontroller.h @@ -1,67 +1,67 @@ /* ============================================================ * TabManager plugin for Falkon * Copyright (C) 2013-2017 S. Razi Alavizadeh * 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 . * ============================================================ */ #ifndef TABMANAGERWIDGETCONTROLLER_H #define TABMANAGERWIDGETCONTROLLER_H #include "sidebarinterface.h" #include "tabmanagerwidget.h" class WebPage; class AbstractButtonInterface; class TabManagerWidgetController : public SideBarInterface { Q_OBJECT public: explicit TabManagerWidgetController(QObject* parent = 0); ~TabManagerWidgetController(); - QString title() const; - QAction* createMenuAction(); - QWidget* createSideBarWidget(BrowserWindow* mainWindow); + QString title() const override; + QAction* createMenuAction() override; + QWidget* createSideBarWidget(BrowserWindow* mainWindow) override; AbstractButtonInterface* createStatusBarIcon(BrowserWindow* mainWindow); TabManagerWidget::GroupType groupType(); TabManagerWidget* createTabManagerWidget(BrowserWindow* mainClass, QWidget* parent = 0, bool defaultWidget = false); TabManagerWidget* defaultTabManager(); void addStatusBarIcon(BrowserWindow* window); void removeStatusBarIcon(BrowserWindow* window); public Q_SLOTS: void setGroupType(TabManagerWidget::GroupType type); void mainWindowDeleted(BrowserWindow* window); void raiseTabManager(); void showSideBySide(); void emitRefreshTree(); private: TabManagerWidget* m_defaultTabManager; TabManagerWidget::GroupType m_groupType; QHash m_statusBarIcons; QHash m_actions; Q_SIGNALS: void requestRefreshTree(WebPage* p = 0); }; #endif // TABMANAGERWIDGETCONTROLLER_H