aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 3bc5597..29b7e66 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -32,7 +32,7 @@
#include <QWebEngineDownloadItem>
#include <QStatusBar>
-MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
+MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
downloadManager(new DownloadDialog(this)),
blocklistManager(new BlockerDialog(this)),
@@ -44,11 +44,10 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
urlLineEdit(new UrlLineEdit(navigationToolBar)),
progressBar(new LoadingBar(this))
{
- browserInstance = instance;
Settings settings;
// Load profile and connect its signals
- loadProfile(settings.value("defaults/profile").toString());
+ loadProfile(settings.value("profile").toString());
ui->setupUi(this);
resize(settings.value("window/width", 800).toInt(), settings.value("window/height", 600).toInt());
@@ -57,7 +56,7 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
QMenu *browserMenu = new QMenu(qApp->applicationName(), ui->menuBar);
ui->menuBar->addMenu(browserMenu);
browserMenu->addAction(tr("New Window"), this, SLOT(handleNewWindow()), QKeySequence(tr("Ctrl+N")));
- browserMenu->addAction(tr("New Tab"), this, SLOT(createNewTab()), QKeySequence(tr("Ctrl+T")));
+ browserMenu->addAction(tr("New Tab"), this, SLOT(addNewTab()), QKeySequence(tr("Ctrl+T")));
browserMenu->addSeparator();
browserMenu->addAction(tr("About"), this, SLOT(about()), QKeySequence(tr("F1")));
browserMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
@@ -91,9 +90,17 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) :
ui->statusBar->addPermanentWidget(progressBar);
if(!defaultUrl.isEmpty()) {
- createNewTab(defaultUrl);
+ addNewTab(defaultUrl);
} else {
- createNewTab(settings.value("defaults/url", QUrl("http://duckduckgo.com")).toUrl());
+ addNewTab(settings.value("homepage", QUrl("about:blank")).toUrl());
+ }
+}
+
+MainWindow::MainWindow(const QStringList urlList, QWidget *parent) :
+ MainWindow(QUrl(""), parent)
+{
+ for(QString url : urlList) {
+ addNewTab(QUrl::fromUserInput(url));
}
}
@@ -102,9 +109,14 @@ MainWindow::~MainWindow()
delete ui;
}
-void MainWindow::createNewTab(const QUrl &url)
+void MainWindow::addNewTab(const QUrl &url)
{
- tabBar->addTab(profile, url);
+ if(!url.isEmpty()) {
+ tabBar->addTab(profile, url);
+ } else {
+ Settings settings;
+ tabBar->addTab(profile, settings.value("newtab").toUrl());
+ }
}
void MainWindow::closeEvent(QCloseEvent *event)
@@ -163,7 +175,7 @@ void MainWindow::loadProfileGUI()
void MainWindow::handleNewWindow(const QUrl &url)
{
- browserInstance->addWindow(new MainWindow(browserInstance, url));
+ Browser::instance()->addWindow(new MainWindow(url));
}
void MainWindow::handleTabChanged(WebView *view)
@@ -199,7 +211,9 @@ void MainWindow::handleTitleUpdated(const QString &title)
{
// For some reason, the long dash gets garbled if read from the settings
//setWindowTitle(title + settings.value("window/title").toString());
- setWindowTitle(title + tr(" — smolbote"));
+
+ Settings settings;
+ setWindowTitle(settings.value("window/title").toString().replace("$title", title).replace("$profile", profileName));
}
void MainWindow::execProfileEditor()