diff options
Diffstat (limited to 'src/mainwindow/widgets/navigationbar.h')
-rw-r--r-- | src/mainwindow/widgets/navigationbar.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mainwindow/widgets/navigationbar.h b/src/mainwindow/widgets/navigationbar.h new file mode 100644 index 0000000..15a9c7b --- /dev/null +++ b/src/mainwindow/widgets/navigationbar.h @@ -0,0 +1,55 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: git://neueland.iserlohn-fortress.net/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + +/* + * Why is this class a QObject and not a QWidget, and why don't we add the + * NavigationBar itself to the toolbar? + * That was the original idea: make a NavBar class, friend it from MainWindow + * to gain access to the config, but there's a couple of issues: + * - adding QToolButtons to a widget that's inside a toolbar makes the buttons + * look absolutely hideous: they're smaller and have a border for some reason + * - if you stylesheet the border away (which is a pain), they're still not + * the same size + * And so we ended up having this class only exist to contain all of the logic + * for the nav buttons (which cuts down the code in MainWindow). + */ + +#ifndef NAVIGATIONBAR_H +#define NAVIGATIONBAR_H + +#include <QObject> + +class QStyle; +class QToolBar; +class QToolButton; +class MainWindow; +class WebView; +class NavigationBar : public QObject +{ + Q_OBJECT +public: + explicit NavigationBar(MainWindow *parent = nullptr); + + void addWidgetsTo(QToolBar *toolBar); + void connectWebView(WebView *view); + +private slots: + void update_loadStarted(); + void update_loadFinished(); + +private: + QStyle *qStyle; + WebView *m_view; + QToolButton *backButton, *forwardButton; + QToolButton *stopReloadButton; + QToolButton *homeButton; + + QMetaObject::Connection loadStartedConnection, loadFinishedConnection; +}; + +#endif //NAVIGATIONBAR_H |