From d6101a83cad797e80ade602662878378ee0f2306 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 30 Jan 2017 15:37:30 +0100 Subject: Added UrlLineEdit class Address bar should highlight the host name WebView widget should now be focused on startup instead of the address bar Added names to the toolbars to make their context menu useful Tabs now have a set width of 200 --- src/mainwindow.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8413b18..0369d17 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -36,10 +36,10 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) : downloadManager(new DownloadDialog(this)), blocklistManager(new BlockerDialog(this)), ui(new Ui::MainWindow), - navigationToolBar(new QToolBar(this)), - tabToolBar(new QToolBar(this)), + navigationToolBar(new QToolBar(tr("Navigation"), this)), + tabToolBar(new QToolBar(tr("Tab bar"), this)), tabBar(new WebViewTabBar(this)), - urlLineEdit(new QLineEdit(navigationToolBar)) + urlLineEdit(new UrlLineEdit(navigationToolBar)) { browserInstance = instance; Settings settings; @@ -164,10 +164,12 @@ void MainWindow::handleTabChanged(QWebEngineView *view) centralWidget()->setParent(0); disconnect(centralWidget()); setCentralWidget(view); - connect(view, SIGNAL(urlChanged(QUrl)), this, SLOT(handleUrlUpdated(QUrl))); + connect(view, SIGNAL(urlChanged(QUrl)), urlLineEdit, SLOT(setUrl(QUrl))); connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString))); - this->handleUrlUpdated(view->url()); + urlLineEdit->setUrl(view->url()); this->handleTitleUpdated(view->title()); + + centralWidget()->setFocus(); } void MainWindow::handleUrlChanged() @@ -175,11 +177,6 @@ void MainWindow::handleUrlChanged() tabBar->currentView()->load(QUrl::fromUserInput(urlLineEdit->text())); } -void MainWindow::handleUrlUpdated(const QUrl &url) -{ - urlLineEdit->setText(url.toString()); -} - void MainWindow::handleTitleUpdated(const QString &title) { // For some reason, the long dash gets garbled if read from the settings -- cgit v1.2.1