diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7987a87..91d098f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,9 +1,9 @@ #include "mainwindow.h"
#include "ui_mainwindow.h"
-
+#include "settings.h"
#include <QMenu>
-MainWindow::MainWindow(QSettings *settings, QUrl defaultUrl, QWidget *parent) :
+MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
navigationToolBar(new QToolBar(this)),
@@ -11,10 +11,11 @@ MainWindow::MainWindow(QSettings *settings, QUrl defaultUrl, QWidget *parent) : tabBar(new WebViewTabBar(this)),
urlLineEdit(new QLineEdit(navigationToolBar))
{
- settings->beginGroup("defaults");
+ Settings settings;
+ settings.beginGroup("defaults");
ui->setupUi(this);
- resize(settings->value("width", 800).toInt(), settings->value("height", 600).toInt());
+ resize(settings.value("width", 800).toInt(), settings.value("height", 600).toInt());
// Populate the menu bar
// Browser menu - with new window, new tab, open and quit
@@ -39,9 +40,9 @@ MainWindow::MainWindow(QSettings *settings, QUrl defaultUrl, QWidget *parent) : if(!defaultUrl.isEmpty())
createNewTab(defaultUrl);
else
- createNewTab(settings->value("url", QUrl("http://duckduckgo.com")).toUrl());
+ createNewTab(settings.value("url", QUrl("http://duckduckgo.com")).toUrl());
- settings->endGroup(); // "defaults"
+ settings.endGroup(); // "defaults"
}
MainWindow::~MainWindow()
@@ -62,7 +63,9 @@ void MainWindow::handleTabChanged(QWebEngineView *view) disconnect(centralWidget());
setCentralWidget(view);
connect(view, SIGNAL(urlChanged(QUrl)), this, SLOT(handleUrlUpdated(QUrl)));
+ connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString)));
this->handleUrlUpdated(view->url());
+ this->handleTitleUpdated(view->title());
}
void MainWindow::handleUrlChanged()
@@ -74,3 +77,9 @@ void MainWindow::handleUrlUpdated(const QUrl &url) {
urlLineEdit->setText(url.toString());
}
+
+void MainWindow::handleTitleUpdated(const QString &title)
+{
+ Settings settings;
+ setWindowTitle(title + settings.value("defaults/title", "qtwebenginebrowser").toString());
+}
|