aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/mainwindow.h
blob: 30d217846c539ca7b73a53574d6d682335a0e7f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * 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: https://neueland.iserlohn-fortress.net/smolbote.hg
 *
 * SPDX-License-Identifier: GPL-3.0
 */

#ifndef SMOLBOTE_MAINWINDOW_H
#define SMOLBOTE_MAINWINDOW_H

#include <QMainWindow>
#include <memory>
#include <QUrl>

class Browser;
class QMdiArea;
class Configuration;
class SubWindow;
class AddressBar;
class SearchForm;
class WebView;
class NavigationBar;
class MainWindow : public QMainWindow
{
    friend class Browser;

    Q_OBJECT

public:
    enum ActionLocation {
        ToolsMenu
    };

    explicit MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent = nullptr);
    Q_DISABLE_COPY(MainWindow)
    ~MainWindow() override;

    void createMenuBar();

    void addAction(ActionLocation where, QAction *action);
    void addDockWidget(Qt::DockWidgetArea area, QWidget *widget);
    void removeDockWidget(QWidget *widget);

    SubWindow *currentSubWindow() const;

public slots:
    void createTab(const QUrl &url);
    SubWindow *createSubWindow(const QString &url = QString());

    void setView(WebView *view);

protected:
    void closeEvent(QCloseEvent *event) override;

private:
    QAction *subWindowAction = nullptr;
    QMenu *toolsMenu = nullptr;

    NavigationBar *navigationToolBar = nullptr;
    AddressBar *addressBar = nullptr;
    SearchForm *searchBox = nullptr;

    QMdiArea *mdiArea;
    WebView *currentView = nullptr;

    std::shared_ptr<Configuration> m_config;

    QMetaObject::Connection viewChangedConnection;
    QMetaObject::Connection searchBoxConnection;
    QMetaObject::Connection statusBarConnection;
};

#endif // SMOLBOTE_MAINWINDOW_H