From f3a4607d6a722a862af0eb9747a15dcdf624b6fb Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 3 Nov 2019 00:18:10 +0200 Subject: Drop boost dependency - wrote not-invented-here config file parser and conf class - spent obscene amount of time plugging in said conf class --- src/mainwindow/mainwindow.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/mainwindow/mainwindow.cpp') diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 7fb7d9e..fa8b23a 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -9,7 +9,7 @@ #include "mainwindow.h" #include "addressbar.h" #include "browser.h" -#include "config.h" +#include "conf.hpp" #include "configuration.h" #include "menubar.h" #include "webprofilemanager.h" @@ -39,14 +39,11 @@ #include #endif -MainWindow::MainWindow(const std::unique_ptr &config, QWidget *parent) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) - , configuration(config.get()) , mdiArea(new QMdiArea(this)) { - Q_ASSERT(config); - - m_menuBar = new MenuBar(config.get(), this); + m_menuBar = new MenuBar(this); this->setMenuBar(m_menuBar); #ifdef CONFIG_PLASMA_BLUR @@ -54,10 +51,12 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa KWindowEffects::enableBlurBehind(this->winId(), true); #endif + Configuration config; + // create UI - setWindowTitle(config->value("mainwindow.title").value()); - resize(config->value("mainwindow.width").value(), config->value("mainwindow.height").value()); - if(config->value("mainwindow.maximized").value()) { + setWindowTitle(config.value("mainwindow.title").value()); + resize(config.value("mainwindow.width").value(), config.value("mainwindow.height").value()); + if(config.value("mainwindow.maximized").value_or(false)) { setWindowState(Qt::WindowMaximized); } show(); @@ -66,7 +65,7 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa { QAction *subwindowMenuAction = new QAction(this); QMainWindow::addAction(subwindowMenuAction); - config->setShortcut(subwindowMenuAction, "subwindow.shortcuts.menu"); + setShortcut(subwindowMenuAction, "shortcuts.subwindow.menu"); connect(subwindowMenuAction, &QAction::triggered, this, [this]() { QMdiSubWindow *window = mdiArea->currentSubWindow(); if(window != nullptr) { @@ -78,12 +77,12 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa }); } - navigationToolBar = new NavigationBar(config.get(), this); - navigationToolBar->setMovable(config->value("navigation.movable").value()); + navigationToolBar = new NavigationBar(this); + navigationToolBar->setMovable(config.value("navigation.movable").value_or(false)); addToolBar(Qt::TopToolBarArea, navigationToolBar); navigationToolBar->connectWebView(nullptr); - addressBar = new AddressBar(config->section("addressbar"), this); + addressBar = new AddressBar(this); navigationToolBar->addWidget(addressBar); mdiArea->setBackground(Qt::NoBrush); @@ -134,7 +133,7 @@ MainWindow::MainWindow(const std::unique_ptr &config, QWidget *pa // search box auto *searchAction = new QAction(this); - config->setShortcut(searchAction, "mainwindow.shortcuts.search"); + setShortcut(searchAction, "shortcuts.window.search"); connect(searchAction, &QAction::triggered, this, [=]() { /* QTBUG-18665 * When focusing out of the search box and hiding it, the first @@ -224,7 +223,7 @@ SubWindow *MainWindow::createSubWindow(WebProfile *profile, bool openProfileNewt shouldMaximize = currentWindow->isMaximized(); } - auto *w = new SubWindow(configuration, this); + auto *w = new SubWindow(this); m_menuBar->insertSubWindow(w); w->setProfile(profile); -- cgit v1.2.1