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

Browser::Browser(QString configPath, QObject *parent) : QObject(parent)
{
    Settings::setFilepath(configPath);

    // TODO Restore previous session

    QtWebEngine::initialize();
}

Browser::~Browser()
{
    // TODO Save session

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

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);
}