From 6855a74ff888f57a491e22d6042a7437b91e312b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 26 Feb 2017 01:56:30 +0100 Subject: UI changes --- src/mainwindow.cpp | 56 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6870a65..30751d5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -22,11 +22,8 @@ #include "ui_mainwindow.h" #include #include -#include #include #include "browser.h" -#include "forms/profiledialog.h" -#include #include #include #include @@ -41,25 +38,25 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : urlLineEdit(new UrlLineEdit(navigationToolBar)), progressBar(new LoadingBar(this)) { - // Load profile and connect its signals - loadProfile(sSettings->value("general.profile").toString()); - + // set up UI ui->setupUi(this); - resize(sSettings->value("window.width", 800).toInt(), sSettings->value("window.height", 600).toInt()); + + QMenuBar *menuBar = new QMenuBar(this); + menuBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); // Browser menu - 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(addNewTab()), QKeySequence(tr("Ctrl+T"))); + 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(tr("Ctrl+Q"))); + browserMenu->addAction(tr("Quit"), qApp, SLOT(quit()), QKeySequence::fromString(sSettings->value("window.shortcuts.windowClose").toString())); // Tools menu - QMenu *toolsMenu = new QMenu(tr("Tools"), ui->menuBar); - ui->menuBar->addMenu(toolsMenu); + QMenu *toolsMenu = new QMenu(tr("Tools"), menuBar); + menuBar->addMenu(toolsMenu); QAction *downloadsAction = toolsMenu->addAction(tr("Downloads"), Browser::instance()->downloads(), SLOT(show())); downloadsAction->setShortcut(QKeySequence::fromString(sSettings->value("downloads.dialogShortcut").toString())); QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks"), Browser::instance()->bookmarks(), SLOT(show())); @@ -68,31 +65,39 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show())); // Profile menu - QMenu *profileMenu = new QMenu(tr("Profile"), ui->menuBar); - ui->menuBar->addMenu(profileMenu); + QMenu *profileMenu = new QMenu(tr("Profile"), menuBar); + menuBar->addMenu(profileMenu); profileMenu->addAction(tr("View profile"), this, SLOT(execProfileEditor())); profileMenu->addAction(tr("Load profile"), this, SLOT(loadProfileGUI())); //profileMenu->addAction(tr("Settings")); //profileMenu->addAction(tr("Cookies")); - navigationToolBar->setMovable(sSettings->value("ui.navtoolbarMovable", true).toBool()); - this->addToolBar(Qt::TopToolBarArea, navigationToolBar); - this->addToolBarBreak(Qt::TopToolBarArea); - tabToolBar->setMovable(sSettings->value("ui.tabtoolbarMovable", true).toBool()); + // Add the toolbars + // tabToolBar: main menu and tab list + tabToolBar->setMovable(sSettings->value("window.ui.tabtoolbarMovable", true).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", true).toBool()); navigationToolBar->addWidget(urlLineEdit); - connect(urlLineEdit, SIGNAL(returnPressed()), this, SLOT(handleUrlChanged())); + this->addToolBar(Qt::TopToolBarArea, navigationToolBar); - tabToolBar->addWidget(tabBar); + // connect signals + connect(urlLineEdit, SIGNAL(returnPressed()), this, SLOT(handleUrlChanged())); connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); + // Load profile + loadProfile(sSettings->value("general.profile").toString()); + // loading bar ui->statusBar->addPermanentWidget(progressBar); // shortcuts QAction *focusAddressAction = new QAction(this); - focusAddressAction->setShortcut(QKeySequence::fromString(sSettings->value("shortcuts.focusAddress").toString())); + focusAddressAction->setShortcut(QKeySequence::fromString(sSettings->value("window.shortcuts.focusAddress").toString())); connect(focusAddressAction, SIGNAL(triggered(bool)), this, SLOT(focusAddress())); addAction(focusAddressAction); @@ -101,6 +106,11 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : } else { addNewTab(sSettings->value("general.homepage", QUrl("about:blank")).toUrl()); } + + resize(sSettings->value("window.width", 800).toInt(), sSettings->value("window.height", 600).toInt()); + if(sSettings->value("window.maximized", false).toBool()) { + showMaximized(); + } } MainWindow::MainWindow(const QStringList urlList, QWidget *parent) : -- cgit v1.2.1