File indexing completed on 2024-05-12 04:58:09

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #ifndef NAVIGATIONBAR_H
0019 #define NAVIGATIONBAR_H
0020 
0021 #include <QWidget>
0022 
0023 #include "qzcommon.h"
0024 
0025 class QUrl;
0026 class QHBoxLayout;
0027 class QSplitter;
0028 class QWebEngineHistoryItem;
0029 
0030 class ToolButton;
0031 class WebSearchBar;
0032 class BrowserWindow;
0033 class ReloadStopButton;
0034 class Menu;
0035 class AbstractButtonInterface;
0036 class TabbedWebView;
0037 
0038 class FALKON_EXPORT NavigationBar : public QWidget
0039 {
0040     Q_OBJECT
0041     Q_PROPERTY(int layoutMargin READ layoutMargin WRITE setLayoutMargin)
0042     Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
0043 
0044 public:
0045     explicit NavigationBar(BrowserWindow* window);
0046     ~NavigationBar();
0047 
0048     void setSplitterSizes(int locationBar, int websearchBar);
0049 
0050     void setCurrentView(TabbedWebView *view);
0051 
0052     void showReloadButton();
0053     void showStopButton();
0054 
0055     void enterFullScreen();
0056     void leaveFullScreen();
0057 
0058     WebSearchBar* webSearchBar() { return m_searchLine; }
0059     QSplitter* splitter() { return m_navigationSplitter; }
0060 
0061     void setSuperMenuVisible(bool visible);
0062 
0063     int layoutMargin() const;
0064     void setLayoutMargin(int margin);
0065 
0066     int layoutSpacing() const;
0067     void setLayoutSpacing(int spacing);
0068 
0069     void addWidget(QWidget *widget, const QString &id, const QString &name);
0070     void removeWidget(const QString &id);
0071 
0072     void addToolButton(AbstractButtonInterface *button);
0073     void removeToolButton(AbstractButtonInterface *button);
0074 
0075 public Q_SLOTS:
0076     void stop();
0077     void reload();
0078     void goBack();
0079     void goBackInNewTab();
0080     void goForward();
0081     void goForwardInNewTab();
0082 
0083 private Q_SLOTS:
0084     void aboutToShowHistoryNextMenu();
0085     void aboutToShowHistoryBackMenu();
0086     void aboutToShowToolsMenu();
0087 
0088     void loadHistoryIndex();
0089     void loadHistoryIndexInNewTab(int index = -1);
0090 
0091     void clearHistory();
0092     void contextMenuRequested(const QPoint &pos);
0093     void openConfigurationDialog();
0094     void toolActionActivated();
0095 
0096 private:
0097     void loadSettings();
0098     void reloadLayout();
0099     void loadHistoryItem(const QWebEngineHistoryItem &item);
0100     void loadHistoryItemInNewTab(const QWebEngineHistoryItem &item);
0101 
0102     BrowserWindow* m_window;
0103     QHBoxLayout* m_layout;
0104     QSplitter* m_navigationSplitter;
0105     WebSearchBar* m_searchLine;
0106 
0107     Menu* m_menuBack;
0108     Menu* m_menuForward;
0109     ToolButton* m_buttonBack;
0110     ToolButton* m_buttonForward;
0111     ReloadStopButton* m_reloadStop;
0112     Menu *m_menuTools;
0113     ToolButton* m_supMenu;
0114     ToolButton *m_exitFullscreen;
0115     QMetaObject::Connection m_backConnection;
0116     QMetaObject::Connection m_forwardConnection;
0117 
0118     struct WidgetData {
0119         QString id;
0120         QString name;
0121         QWidget *widget = nullptr;
0122         AbstractButtonInterface *button = nullptr;
0123     };
0124 
0125     QStringList m_layoutIds;
0126     QHash<QString, WidgetData> m_widgets;
0127 
0128     friend class NavigationBarConfigDialog;
0129 };
0130 
0131 #endif // NAVIGATIONBAR_H