From 444884bee9e335d7a4b9cc4fa9dc2b2963db609e Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 24 Jan 2018 19:18:58 +0100 Subject: [PATCH] Rename StatusBarMessage -> StatusBar --- src/lib/CMakeLists.txt | 2 +- src/lib/app/browserwindow.cpp | 30 +++++------ src/lib/app/browserwindow.h | 6 +-- src/lib/app/mainmenu.cpp | 2 +- .../{statusbarmessage.cpp => statusbar.cpp} | 54 +++++++++---------- .../other/{statusbarmessage.h => statusbar.h} | 19 +++---- src/lib/popupwindow/popupstatusbarmessage.cpp | 3 +- src/lib/popupwindow/popupstatusbarmessage.h | 3 +- src/lib/webtab/tabbedwebview.cpp | 6 +-- src/plugins/FlashCookieManager/fcm_plugin.cpp | 6 +-- .../StatusBarIcons/sbi_iconsmanager.cpp | 4 +- .../TabManager/tabmanagerwidgetcontroller.cpp | 5 +- 12 files changed, 69 insertions(+), 71 deletions(-) rename src/lib/other/{statusbarmessage.cpp => statusbar.cpp} (66%) rename src/lib/other/{statusbarmessage.h => statusbar.h} (77%) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index d2438da94..de7b36ad6 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -151,7 +151,7 @@ set(SRCS ${SRCS} other/qzsettings.cpp other/siteinfo.cpp other/siteinfowidget.cpp - other/statusbarmessage.cpp + other/statusbar.cpp other/updater.cpp other/useragentmanager.cpp plugins/pluginproxy.cpp diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 78b39089c..0f00bcc4a 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -38,7 +38,7 @@ #include "iconprovider.h" #include "progressbar.h" #include "closedwindowsmanager.h" -#include "statusbarmessage.h" +#include "statusbar.h" #include "browsinglibrary.h" #include "navigationbar.h" #include "bookmarksimport/bookmarksimportdialog.h" @@ -60,7 +60,6 @@ #include #include -#include #include #include #include @@ -190,7 +189,6 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl) , m_startTab(0) , m_startPage(0) , m_sideBarManager(new SideBarManager(this)) - , m_statusBarMessage(new StatusBarMessage(this)) , m_isHtmlFullScreen(false) , m_hideNavigationTimer(0) { @@ -375,15 +373,17 @@ void BrowserWindow::setupUi() m_mainLayout->addWidget(m_navigationContainer); m_mainLayout->addWidget(m_mainSplitter); - statusBar()->setObjectName("mainwindow-statusbar"); - statusBar()->setCursor(Qt::ArrowCursor); - m_progressBar = new ProgressBar(statusBar()); + m_statusBar = new StatusBar(this); + m_statusBar->setObjectName("mainwindow-statusbar"); + m_statusBar->setCursor(Qt::ArrowCursor); + setStatusBar(m_statusBar); + m_progressBar = new ProgressBar(m_statusBar); m_ipLabel = new QLabel(this); m_ipLabel->setObjectName("statusbar-ip-label"); m_ipLabel->setToolTip(tr("IP Address of current page")); - statusBar()->addPermanentWidget(m_progressBar); - statusBar()->addPermanentWidget(m_ipLabel); + m_statusBar->addPermanentWidget(m_progressBar); + m_statusBar->addPermanentWidget(m_ipLabel); m_navigationToolbar->addToolButton(new DownloadsButton(this)); @@ -668,9 +668,9 @@ BookmarksToolbar* BrowserWindow::bookmarksToolbar() const return m_bookmarksToolbar; } -StatusBarMessage* BrowserWindow::statusBarMessage() const +StatusBar* BrowserWindow::statusBar() const { - return m_statusBarMessage; + return m_statusBar; } NavigationBar* BrowserWindow::navigationBar() const @@ -861,11 +861,11 @@ void BrowserWindow::toggleShowStatusBar() { setUpdatesEnabled(false); - statusBar()->setVisible(!statusBar()->isVisible()); + m_statusBar->setVisible(!m_statusBar->isVisible()); setUpdatesEnabled(true); - Settings().setValue("Browser-View-Settings/showStatusBar", statusBar()->isVisible()); + Settings().setValue("Browser-View-Settings/showStatusBar", m_statusBar->isVisible()); } @@ -1197,19 +1197,19 @@ bool BrowserWindow::event(QEvent *event) QWindowStateChangeEvent *e = static_cast(event); if (!(e->oldState() & Qt::WindowFullScreen) && windowState() & Qt::WindowFullScreen) { // Enter fullscreen - m_statusBarVisible = statusBar()->isVisible(); + m_statusBarVisible = m_statusBar->isVisible(); #ifndef Q_OS_MACOS m_menuBarVisible = menuBar()->isVisible(); menuBar()->hide(); #endif - statusBar()->hide(); + m_statusBar->hide(); m_navigationContainer->hide(); m_navigationToolbar->enterFullScreen(); } else if (e->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) { // Leave fullscreen - statusBar()->setVisible(m_statusBarVisible); + m_statusBar->setVisible(m_statusBarVisible); #ifndef Q_OS_MACOS menuBar()->setVisible(m_menuBarVisible); #endif diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h index 1784936c2..1943ac2c0 100644 --- a/src/lib/app/browserwindow.h +++ b/src/lib/app/browserwindow.h @@ -46,7 +46,7 @@ class WebPage; class SideBar; class SideBarManager; class ProgressBar; -class StatusBarMessage; +class StatusBar; class NavigationBar; class NavigationContainer; class ClickableLabel; @@ -110,7 +110,7 @@ public: LocationBar* locationBar() const; TabWidget* tabWidget() const; BookmarksToolbar* bookmarksToolbar() const; - StatusBarMessage* statusBarMessage() const; + StatusBar* statusBar() const; NavigationBar* navigationBar() const; SideBarManager* sideBarManager() const; QLabel* ipLabel() const; @@ -202,7 +202,7 @@ private: TabWidget* m_tabWidget; QPointer m_sideBar; SideBarManager* m_sideBarManager; - StatusBarMessage* m_statusBarMessage; + StatusBar* m_statusBar; NavigationContainer* m_navigationContainer; NavigationBar* m_navigationToolbar; diff --git a/src/lib/app/mainmenu.cpp b/src/lib/app/mainmenu.cpp index b63f1c12d..6fd990e84 100644 --- a/src/lib/app/mainmenu.cpp +++ b/src/lib/app/mainmenu.cpp @@ -33,10 +33,10 @@ #include "pluginproxy.h" #include "webinspector.h" #include "sessionmanager.h" +#include "statusbar.h" #include #include -#include #include #include #include diff --git a/src/lib/other/statusbarmessage.cpp b/src/lib/other/statusbar.cpp similarity index 66% rename from src/lib/other/statusbarmessage.cpp rename to src/lib/other/statusbar.cpp index 6cdcf20d9..58c084c3f 100644 --- a/src/lib/other/statusbarmessage.cpp +++ b/src/lib/other/statusbar.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2017 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 @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#include "statusbarmessage.h" +#include "statusbar.h" #include "browserwindow.h" #include "tabwidget.h" #include "tabbedwebview.h" @@ -107,46 +107,46 @@ bool TipLabel::eventFilter(QObject* o, QEvent* e) return false; } -StatusBarMessage::StatusBarMessage(BrowserWindow* window) +StatusBar::StatusBar(BrowserWindow* window) : m_window(window) , m_statusBarText(new TipLabel(window)) { } -void StatusBarMessage::showMessage(const QString &message) +void StatusBar::showMessage(const QString &message, int timeout) { - if (m_window->statusBar()->isVisible()) { + if (isVisible()) { const static QChar LRE(0x202a); - m_window->statusBar()->showMessage(message.isRightToLeft() ? message : (LRE + message)); + QStatusBar::showMessage(message.isRightToLeft() ? message : (LRE + message), timeout); + return; } - else if (mApp->activeWindow() == m_window) { - WebView* view = m_window->weView(); - const int verticalScrollSize = view->scrollBarGeometry(Qt::Vertical).width();; - const int horizontalScrollSize = view->scrollBarGeometry(Qt::Horizontal).height(); + if (mApp->activeWindow() != m_window) { + return; + } + + WebView* view = m_window->weView(); - m_statusBarText->setText(message); - m_statusBarText->setMaximumWidth(view->width() - verticalScrollSize); - m_statusBarText->resize(m_statusBarText->sizeHint()); + const int verticalScrollSize = view->scrollBarGeometry(Qt::Vertical).width();; + const int horizontalScrollSize = view->scrollBarGeometry(Qt::Horizontal).height(); - QPoint position(0, view->height() - horizontalScrollSize - m_statusBarText->height()); - const QRect statusRect = QRect(view->mapToGlobal(QPoint(0, position.y())), m_statusBarText->size()); + m_statusBarText->setText(message); + m_statusBarText->setMaximumWidth(view->width() - verticalScrollSize); + m_statusBarText->resize(m_statusBarText->sizeHint()); - if (statusRect.contains(QCursor::pos())) { - position.setY(position.y() - m_statusBarText->height()); - } + QPoint position(0, view->height() - horizontalScrollSize - m_statusBarText->height()); + const QRect statusRect = QRect(view->mapToGlobal(QPoint(0, position.y())), m_statusBarText->size()); - m_statusBarText->move(view->mapToGlobal(position)); - m_statusBarText->show(view); + if (statusRect.contains(QCursor::pos())) { + position.setY(position.y() - m_statusBarText->height()); } + + m_statusBarText->move(view->mapToGlobal(position)); + m_statusBarText->show(view); } -void StatusBarMessage::clearMessage() +void StatusBar::clearMessage() { - if (m_window->statusBar()->isVisible()) { - m_window->statusBar()->showMessage(QString()); - } - else { - m_statusBarText->hideDelayed(); - } + QStatusBar::clearMessage(); + m_statusBarText->hideDelayed(); } diff --git a/src/lib/other/statusbarmessage.h b/src/lib/other/statusbar.h similarity index 77% rename from src/lib/other/statusbarmessage.h rename to src/lib/other/statusbar.h index bed1f3047..bd095404d 100644 --- a/src/lib/other/statusbarmessage.h +++ b/src/lib/other/statusbar.h @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2014 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 @@ -15,14 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#ifndef STATUSBARMESSAGE_H -#define STATUSBARMESSAGE_H +#pragma once #include +#include #include "qzcommon.h" #include "squeezelabelv1.h" -#include "animatedwidget.h" class QTimer; @@ -45,17 +44,15 @@ private: QTimer* m_timer; }; -class FALKON_EXPORT StatusBarMessage +class FALKON_EXPORT StatusBar : public QStatusBar { public: - explicit StatusBarMessage(BrowserWindow* window); + explicit StatusBar(BrowserWindow *window); - void showMessage(const QString &message); + void showMessage(const QString &message, int timeout = 0); void clearMessage(); private: - BrowserWindow* m_window; - TipLabel* m_statusBarText; + BrowserWindow *m_window; + TipLabel *m_statusBarText; }; - -#endif // STATUSBARMESSAGE_H diff --git a/src/lib/popupwindow/popupstatusbarmessage.cpp b/src/lib/popupwindow/popupstatusbarmessage.cpp index ef0114829..90fed8f59 100644 --- a/src/lib/popupwindow/popupstatusbarmessage.cpp +++ b/src/lib/popupwindow/popupstatusbarmessage.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2014 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 @@ -19,7 +19,6 @@ #include "popupwindow.h" #include "popupwebview.h" #include "webpage.h" -#include "statusbarmessage.h" #include "mainapplication.h" #include diff --git a/src/lib/popupwindow/popupstatusbarmessage.h b/src/lib/popupwindow/popupstatusbarmessage.h index 05cc947f1..76c66f71e 100644 --- a/src/lib/popupwindow/popupstatusbarmessage.h +++ b/src/lib/popupwindow/popupstatusbarmessage.h @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2014 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 @@ -19,6 +19,7 @@ #define POPUPSTATUSBARMESSAGE_H #include "qzcommon.h" +#include "statusbar.h" class PopupWindow; class TipLabel; diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp index 654fecc38..87ef521d8 100644 --- a/src/lib/webtab/tabbedwebview.cpp +++ b/src/lib/webtab/tabbedwebview.cpp @@ -22,7 +22,7 @@ #include "mainapplication.h" #include "tabbar.h" #include "webtab.h" -#include "statusbarmessage.h" +#include "statusbar.h" #include "progressbar.h" #include "navigationbar.h" #include "iconprovider.h" @@ -139,10 +139,10 @@ void TabbedWebView::linkHovered(const QString &link) { if (m_webTab->isCurrentTab() && m_window) { if (link.isEmpty()) { - m_window->statusBarMessage()->clearMessage(); + m_window->statusBar()->clearMessage(); } else { - m_window->statusBarMessage()->showMessage(link); + m_window->statusBar()->showMessage(link); } } } diff --git a/src/plugins/FlashCookieManager/fcm_plugin.cpp b/src/plugins/FlashCookieManager/fcm_plugin.cpp index f586c90cc..ab6f7283b 100644 --- a/src/plugins/FlashCookieManager/fcm_plugin.cpp +++ b/src/plugins/FlashCookieManager/fcm_plugin.cpp @@ -1,7 +1,7 @@ /* ============================================================ * FlashCookieManager plugin for Falkon -* Copyright (C) 2014 S. Razi Alavizadeh -* Copyright (C) 2017 David Rosca +* Copyright (C) 2014-2018 S. Razi Alavizadeh +* Copyright (C) 2017-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 @@ -26,8 +26,8 @@ #include "fcm_notification.h" #include "datapaths.h" #include "../config.h" +#include "statusbar.h" -#include #include #include #include diff --git a/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp b/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp index 82b1db6d2..c1bd04109 100644 --- a/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp +++ b/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp @@ -1,6 +1,6 @@ /* ============================================================ * StatusBarIcons - Extra icons in statusbar for Falkon -* Copyright (C) 2013-2014 David Rosca +* 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 @@ -22,9 +22,9 @@ #include "sbi_networkicon.h" #include "sbi_networkmanager.h" #include "browserwindow.h" +#include "statusbar.h" #include -#include SBI_IconsManager::SBI_IconsManager(const QString &settingsPath, QObject* parent) : QObject(parent) diff --git a/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp b/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp index db1227a97..e3c33cabc 100644 --- a/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp +++ b/src/plugins/TabManager/tabmanagerwidgetcontroller.cpp @@ -1,6 +1,7 @@ /* ============================================================ * TabManager plugin for Falkon -* Copyright (C) 2013-2017 S. Razi Alavizadeh +* Copyright (C) 2013-2018 S. Razi Alavizadeh +* Copyright (C) 2017-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 @@ -22,9 +23,9 @@ #include "tabwidget.h" #include "mainapplication.h" #include "tabbar.h" +#include "statusbar.h" #include -#include #include #include