aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
blob: 7ccd13a46088d50c6ad10d98f8f81c60bf2f2948 (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
#include "browser.h"
#include "mainwindow.h"
#include <QtWebEngine>

Browser::Browser(QString configPath, QObject *parent) : QObject(parent)
{
    // TODO Read Profile
    m_settings = new QSettings(configPath, QSettings::IniFormat, this);

    // TODO Restore previous session

    QtWebEngine::initialize();
}

Browser::~Browser()
{
    // TODO Save Profile
    m_settings->sync();

    // TODO Save session

    // cleanup
    qDeleteAll(m_windows);
    m_windows.clear();
}


QSettings* Browser::settings()
{
    return m_settings;
}

QVector<MainWindow*> Browser::windows()
{
    return m_windows;
}

void Browser::addWindow(MainWindow *window)
{
    if(m_windows.contains(window)) {
        return;
    }

    m_windows.append(window);
    connect(window, &QObject::destroyed, [this, window]() {
        this->removeWindow(window);
    });

    window->show();
}

void Browser::removeWindow(MainWindow *window)
{
    m_windows.removeOne(window);
}