aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/mainwindow.h
blob: 6ce61b54d3e1dd44dc3ebb1a293f4247062f9d80 (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
75
76
77
78
79
80
81
82
83
84
/*
 * 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/gitea/aqua/smolbote
 *
 * SPDX-License-Identifier: GPL-3.0
 */

#ifndef SMOLBOTE_MAINWINDOW_H
#define SMOLBOTE_MAINWINDOW_H

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

class Browser;
class QMdiArea;
class Configuration;
class SubWindow;
class AddressBar;
class SearchForm;
class WebView;
class NavigationBar;
class WebProfile;

namespace Ui
{
class MainWindow;
}

class MainWindow : public QMainWindow
{
    friend class Browser;

    Q_OBJECT

public:
    enum ActionLocation {
        ToolsMenu
    };

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

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

    const QVector<SubWindow *> subWindows() const;
    SubWindow *currentSubWindow() const;

signals:
    void createBookmark(const QString &title, const QString &url);

public slots:
    void createTab(const QUrl &url);
    SubWindow *createSubWindow(const std::unique_ptr<Configuration> &config, WebProfile *profile);

private slots:
    void setView(WebView *view);
    void updatePageLoadProfileMenu();

protected:
    void closeEvent(QCloseEvent *event) override;

private:
    Ui::MainWindow *ui;
    QMenu *toolsMenu = nullptr;
    QMenu *pageLoadProfileMenu = nullptr;

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

    QMdiArea *mdiArea;
    WebView *currentView = nullptr;

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

#endif // SMOLBOTE_MAINWINDOW_H