// This file is part of RSS Guard. // // Copyright (C) 2011-2016 by Martin Rotter // // RSS Guard 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. // // RSS Guard 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 RSS Guard. If not, see . #ifndef WEBBROWSER_H #define WEBBROWSER_H #include "gui/tabcontent.h" #include "core/messagesmodel.h" #include "network-web/webview.h" #include "gui/locationlineedit.h" #include "gui/discoverfeedsbutton.h" #include #include #include #include class QToolButton; class QVBoxLayout; class QHBoxLayout; class QProgressBar; class QMenu; class QLabel; class WebBrowserNetworkAccessManager; class TabWidget; class WebBrowser : public TabContent { Q_OBJECT public: // Constructors and destructors. explicit WebBrowser(QWidget *parent = 0); virtual ~WebBrowser(); // Reloads icons for all buttons. void setupIcons(); // Returns icon associated with currently loaded website. inline QIcon icon() const { return m_webView->icon(); } inline WebView *view() const { return m_webView; } // Sets this WebBrowser instance as focused. inline void setFocus(Qt::FocusReason reason) { m_txtLocation->setFocus(reason); } // Returns this instance. // NOTE: This is needed due to TabContent interface. inline WebBrowser *webBrowser() const { return const_cast(this); } // Returns global menu for this web browser. inline virtual QList globalMenu() const { QList browser_menu; // Add needed actions into the menu. browser_menu.append(m_actionZoom); return browser_menu; } // Returns list of all running web browsers. static inline QList runningWebBrowsers() { return m_runningWebBrowsers; } public slots: // Switches visibility of navigation bar. inline void setNavigationBarVisible(bool visible) { m_toolBar->setVisible(visible); } // Loads new url into the web browser. void navigateToUrl(const QString &url); void navigateToUrl(const QUrl &url); // Navigates to messages, used also as "newspaper" view. void navigateToMessages(const QList &messages); // Clears contents. inline void clear() { if (m_webView->url() != QUrl()) { m_webView->setHtml("", QUrl(INTERNAL_URL_EMPTY)); } } // Zoom manipulators. void increaseZoom(); void decreaseZoom(); void resetZoom(); protected: // Creates necessary connections. void createConnections(); // Initializes all buttons and widgets, which are needed for "Zoom" menu item. void initializeZoomWidget(); // Initializes layout. void initializeLayout(); protected slots: void onLoadingStarted(); void onLoadingProgress(int progress); void onLoadingFinished(bool success); // Updates zoom-related gui. void updateZoomGui(); // Updates url (for example on location text box). void updateUrl(const QUrl &url); // Title/icon is changed. void onTitleChanged(const QString &new_title); void onIconChanged(); signals: // User requests opening of new tab or clicks the link // with middle mouse button void newTabRequested(); void linkMiddleClicked(const QUrl &link_url); // Title/icon is changed. void iconChanged(int index, const QIcon &icon); void titleChanged(int index, const QString &title); private: QVBoxLayout *m_layout; QToolBar *m_toolBar; WebView *m_webView; LocationLineEdit *m_txtLocation; QWidget *m_zoomButtons; QToolButton *m_btnResetZoom; QWidget *m_loadingWidget; QHBoxLayout *m_loadingLayout; QProgressBar *m_loadingProgress; QLabel *m_lblProgress; DiscoverFeedsButton *m_btnDiscoverFeeds; QWidgetAction *m_actionZoom; QAction *m_actionBack; QAction *m_actionForward; QAction *m_actionReload; QAction *m_actionStop; static QList m_runningWebBrowsers; }; #endif // WEBBROWSER_H