aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp60
1 files changed, 9 insertions, 51 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 537c04f..79552d6 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -20,11 +20,9 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
-#include <QMenu>
-#include <QMenuBar>
+#include "widgets/mainwindowmenubar.h"
#include <QMessageBox>
#include "browser.h"
-#include <QInputDialog>
#include <QWebEngineDownloadItem>
#include <QStatusBar>
#include "forms/aboutdialog.h"
@@ -54,39 +52,9 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::North);
// Main menu
- QMenuBar *menuBar = new QMenuBar(this);
+ MainWindowMenuBar *menuBar = new MainWindowMenuBar(this);
menuBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
- // Browser menu
- QMenu *browserMenu = new QMenu(qApp->applicationName(), menuBar);
- menuBar->addMenu(browserMenu);
- browserMenu->addAction(tr("New Window"), this, SLOT(handleNewWindow()), QKeySequence::fromString(sSettings->value("window.shortcuts.windowNew").toString()));
- browserMenu->addAction(tr("New Tab"), this, SLOT(addNewTab()), QKeySequence::fromString(sSettings->value("window.shortcuts.tabNew").toString()));
- browserMenu->addSeparator();
- browserMenu->addAction(tr("About"), this, SLOT(about()), QKeySequence(tr("F1")));
- browserMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
- browserMenu->addAction(tr("Quit"), qApp, SLOT(quit()), QKeySequence::fromString(sSettings->value("window.shortcuts.windowClose").toString()));
-
- // Tools menu
- QMenu *toolsMenu = new QMenu(tr("Tools"), menuBar);
- menuBar->addMenu(toolsMenu);
- QAction *downloadsAction = toolsMenu->addAction(tr("Downloads"), Browser::instance()->downloads(), SLOT(show()));
- downloadsAction->setParent(this);
- downloadsAction->setShortcut(QKeySequence::fromString(sSettings->value("downloads.dialogShortcut").toString()));
- QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks"), Browser::instance()->bookmarks(), SLOT(show()));
- bookmarksAction->setParent(this);
- bookmarksAction->setShortcut(QKeySequence(sSettings->value("bookmarks.dialogShortcut").toString()));
- toolsMenu->addSeparator();
- toolsMenu->addAction(tr("Blocker"), qApp->blocklists(), SLOT(show()), QKeySequence::fromString(sSettings->value("blocker.shortcut").toString()));
-
- // Profile menu
- QMenu *profileMenu = new QMenu(tr("Profile"), menuBar);
- menuBar->addMenu(profileMenu);
- profileMenu->addAction(tr("View profile"), this, SLOT(profileAction()));
- profileMenu->addAction(tr("Load profile"), this, SLOT(loadProfile()));
- //profileMenu->addAction(tr("Settings"));
- profileMenu->addAction(tr("Cookies"), this, SLOT(cookiesAction()));
-
// Add the toolbars
// tabToolBar: main menu and tab list
tabToolBar->setMovable(sSettings->value("window.ui.tabtoolbarMovable", true).toBool());
@@ -134,9 +102,9 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
addAction(focusAddressAction);
if(!defaultUrl.isEmpty()) {
- addNewTab(defaultUrl);
+ newTab(defaultUrl);
} else {
- addNewTab(sSettings->value("general.homepage", QUrl("about:blank")).toUrl());
+ newTab(sSettings->value("general.homepage", QUrl("about:blank")).toUrl());
}
resize(sSettings->value("window.width", 800).toInt(), sSettings->value("window.height", 600).toInt());
@@ -150,7 +118,7 @@ MainWindow::MainWindow(const QStringList urlList, QWidget *parent) :
{
QStringList::const_iterator i;
for(i = urlList.constBegin(); i != urlList.constEnd(); ++i) {
- addNewTab(QUrl::fromUserInput(*i));
+ newTab(QUrl::fromUserInput(*i));
}
}
@@ -177,7 +145,7 @@ void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QDockWidget *widget)
}
}
-void MainWindow::addNewTab(const QUrl &url)
+void MainWindow::newTab(const QUrl &url)
{
if(!url.isEmpty()) {
tabBar->addTab(m_profile, url);
@@ -210,19 +178,9 @@ void MainWindow::about()
dlg->exec();
}
-void MainWindow::loadProfile(const QString name)
+void MainWindow::setProfile(WebEngineProfile *profile)
{
- if(name.isEmpty()) {
- bool ok;
- QString _name = QInputDialog::getText(this, tr("Load Profile"), tr("Enter Profile name"), QLineEdit::Normal, QString(""), &ok);
- if(ok) {
- m_profile = qApp->profile(_name);
- } else {
- return;
- }
- } else {
- m_profile = qApp->profile(name);
- }
+ m_profile = profile;
tabBar->setProfile(m_profile);
}
@@ -235,7 +193,7 @@ void MainWindow::toggleFullscreen()
}
}
-void MainWindow::handleNewWindow(const QUrl &url)
+void MainWindow::newWindow(const QUrl &url)
{
Browser::instance()->addWindow(new MainWindow(url));
}