diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 29a5c8f..4146e8a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -34,7 +34,7 @@ #include <QWebEngineHistory> -MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), navigationToolBar(new QToolBar(tr("Navigation"), this)), @@ -49,7 +49,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : // set up UI ui->setupUi(this); QAction *fullscreenAction = new QAction(this); - fullscreenAction->setShortcut(QKeySequence::fromString(sSettings->value("window.shortcuts.fullscreen").toString())); + fullscreenAction->setShortcut(QKeySequence::fromString(browser->settings()->value("window.shortcuts.fullscreen").toString())); connect(fullscreenAction, SIGNAL(triggered(bool)), this, SLOT(toggleFullscreen())); addAction(fullscreenAction); @@ -69,29 +69,30 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : // Add the toolbars // tabToolBar: main menu and tab list - tabToolBar->setMovable(sSettings->value("window.ui.tabtoolbarMovable").toBool()); + tabToolBar->setMovable(browser->settings()->value("window.ui.tabtoolbarMovable").toBool()); tabToolBar->addWidget(menuBar); tabToolBar->addWidget(tabBar); this->addToolBar(Qt::TopToolBarArea, tabToolBar); this->addToolBarBreak(Qt::TopToolBarArea); // navigationToolBar: address bar - navigationToolBar->setMovable(sSettings->value("window.ui.navtoolbarMovable").toBool()); + navigationToolBar->setMovable(browser->settings()->value("window.ui.navtoolbarMovable").toBool()); // page actions - backButton = new NavigationButton(NavigationButton::BackButton, this); +m: + m_backButton = new NavigationButton(NavigationButton::BackButton, this); - forwardButton = new NavigationButton(NavigationButton::ForwardButton, this); + m_forwardButton = new NavigationButton(NavigationButton::ForwardButton, this); - reloadButton = new NavigationButton(NavigationButton::ReloadButton, this); + m_reloadButton = new NavigationButton(NavigationButton::ReloadButton, this); QToolButton *homepageButton = new QToolButton(this); homepageButton->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon)); connect(homepageButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map())); tabBar->signalMapper()->setMapping(homepageButton, WebViewTabBar::Homepage); - navigationToolBar->addWidget(backButton); - navigationToolBar->addWidget(forwardButton); - navigationToolBar->addWidget(reloadButton); + navigationToolBar->addWidget(m_backButton); + navigationToolBar->addWidget(m_forwardButton); + navigationToolBar->addWidget(m_reloadButton); navigationToolBar->addWidget(homepageButton); navigationToolBar->addWidget(m_addressBar); this->addToolBar(Qt::TopToolBarArea, navigationToolBar); @@ -103,49 +104,34 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : connect(m_addressBar, &AddressBar::searchTermEntered, this, [&](const QString &string) { QString term = string.mid(1); term.replace(' ', '+'); - tabBar->currentView()->load(QUrl::fromUserInput(qApp->settings()->value("general.search").toString().replace("$term", term))); + tabBar->currentView()->load(QUrl::fromUserInput(browser->settings()->value("general.search").toString().replace("$term", term))); }); connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); - connect(qApp->bookmarks(), &BookmarksWidget::openUrl, this, [&](const QUrl &url) { + connect(browser->bookmarks(), &BookmarksWidget::openUrl, this, [&](const QUrl &url) { if(this->isActiveWindow()) { this->newTab(url); } }); // Load profile - tabBar->setProfile(qApp->profile(sSettings->value("browser.profile.default").toString())); + tabBar->setProfile(browser->profile(browser->settings()->value("browser.profile.default").toString())); // loading bar ui->statusBar->addPermanentWidget(m_progressBar); // shortcuts QAction *focusAddressAction = new QAction(this); - focusAddressAction->setShortcut(QKeySequence::fromString(sSettings->value("window.shortcuts.focusAddress").toString())); + focusAddressAction->setShortcut(QKeySequence::fromString(browser->settings()->value("window.shortcuts.focusAddress").toString())); connect(focusAddressAction, SIGNAL(triggered(bool)), this, SLOT(focusAddress())); addAction(focusAddressAction); - if(!defaultUrl.isEmpty()) { - newTab(defaultUrl); - } else { - newTab(tabBar->profile()->homepage()); - } - - resize(sSettings->value("window.width").toInt(), sSettings->value("window.height").toInt()); - if(sSettings->value("window.maximized").toBool()) { + resize(browser->settings()->value("window.width").toInt(), browser->settings()->value("window.height").toInt()); + if(browser->settings()->value("window.maximized").toBool()) { showMaximized(); } } -MainWindow::MainWindow(const QStringList urlList, QWidget *parent) : - MainWindow(QUrl(""), parent) -{ - QStringList::const_iterator i; - for(i = urlList.constBegin(); i != urlList.constEnd(); ++i) { - newTab(QUrl::fromUserInput(*i)); - } -} - MainWindow::~MainWindow() { delete ui; @@ -218,7 +204,9 @@ void MainWindow::toggleFullscreen() void MainWindow::newWindow(const QUrl &url) { - Browser::instance()->addWindow(new MainWindow(url)); + QHash<QString, QVariant> options; + options.insert("urls", url); + browser->createWindow(options); } void MainWindow::handleTabChanged(WebView *view) @@ -240,9 +228,10 @@ void MainWindow::handleTabChanged(WebView *view) setCentralWidget(view); // connect signals - backButton->setView(view); - forwardButton->setView(view); - reloadButton->setView(view); +m: + m_backButton->setView(view); + m_forwardButton->setView(view); + m_reloadButton->setView(view); m_addressBar->setWebView(view); connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString))); connect(view, SIGNAL(linkHovered(QString)), ui->statusBar, SLOT(showMessage(QString))); @@ -256,5 +245,5 @@ void MainWindow::handleTabChanged(WebView *view) void MainWindow::handleTitleUpdated(const QString &title) { - setWindowTitle(sSettings->value("window.title").toString().replace("title", title).replace("profile", tabBar->profile()->name())); + setWindowTitle(browser->settings()->value("window.title").toString().replace("title", title).replace("profile", tabBar->profile()->name())); } |