aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-12-16 12:49:09 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-12-16 12:49:09 +0100
commitc8854d193231736e9c609bc2f6eb169cf83579af (patch)
treef51e379204b8cb6c3242930938d71b375d7b4fd8
parentWebView pageMenu implementation (diff)
downloadsmolbote-c8854d193231736e9c609bc2f6eb169cf83579af.tar.xz
Moved MainWindow toolbars to mainwindow.ui
-rw-r--r--src/mainwindow.cpp34
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/mainwindow.ui28
-rw-r--r--src/widgets/mainwindowmenubar.cpp2
4 files changed, 43 insertions, 25 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 732bc70..297b571 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -27,8 +27,6 @@
#include <QToolButton>
#include <QStyle>
-#include <QFileDialog>
-
#include <QWebEngineHistory>
#include <QDockWidget>
@@ -46,10 +44,9 @@
MainWindow::MainWindow(std::shared_ptr<Configuration> config, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
- navigationToolBar(new QToolBar(tr("Navigation"), this)),
- tabToolBar(new QToolBar(tr("Tab bar"), this)),
tabBar(new WebViewTabBar(nullptr, this)),
- m_addressBar(new UrlLineEdit(navigationToolBar)),
+ menuBar(new MainWindowMenuBar(config, this)),
+ m_addressBar(new UrlLineEdit(this)),
m_progressBar(new LoadingBar(this))
{
Q_ASSERT(config);
@@ -60,6 +57,7 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> config, QWidget *parent) :
// set up UI
ui->setupUi(this);
+
QAction *fullscreenAction = new QAction(this);
fullscreenAction->setShortcut(QKeySequence(QString::fromStdString(m_config->value<std::string>("browser.shortcuts.fullscreen").value())));
connect(fullscreenAction, &QAction::triggered, this, &MainWindow::toggleFullscreen);
@@ -70,20 +68,15 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> config, QWidget *parent) :
setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::North);
- // Main menu
- menuBar = new MainWindowMenuBar(config, this);
- menuBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
-
// Add the toolbars
// tabToolBar: main menu and tab list
- tabToolBar->setMovable(m_config->value<bool>("browser.ui.tabtoolbarMovable").value());
- tabToolBar->addWidget(menuBar);
+ ui->mainToolBar->setMovable(m_config->value<bool>("browser.ui.tabtoolbarMovable").value());
+ ui->mainToolBar->addWidget(menuBar);
//tabToolBar->addWidget(tabBar);
- this->addToolBar(Qt::TopToolBarArea, tabToolBar);
- this->addToolBarBreak(Qt::TopToolBarArea);
// navigationToolBar: address bar
- navigationToolBar->setMovable(m_config->value<bool>("browser.ui.navtoolbarMovable").value());
+ ui->navigationToolBar->setMovable(m_config->value<bool>("browser.ui.navtoolbarMovable").value());
+ insertToolBarBreak(ui->navigationToolBar);
// page actions
m_backButton = new NavigationButton(NavigationButton::BackButton, this);
@@ -98,12 +91,11 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> config, QWidget *parent) :
tabBar->currentView()->load(tabBar->profile()->homepage());
});
- navigationToolBar->addWidget(m_backButton);
- navigationToolBar->addWidget(m_forwardButton);
- navigationToolBar->addWidget(m_reloadButton);
- navigationToolBar->addWidget(homepageButton);
- navigationToolBar->addWidget(m_addressBar);
- this->addToolBar(Qt::TopToolBarArea, navigationToolBar);
+ ui->navigationToolBar->addWidget(m_backButton);
+ ui->navigationToolBar->addWidget(m_forwardButton);
+ ui->navigationToolBar->addWidget(m_reloadButton);
+ ui->navigationToolBar->addWidget(homepageButton);
+ ui->navigationToolBar->addWidget(m_addressBar);
// connect signals
connect(m_addressBar, &UrlLineEdit::addressEntered, this, [&](const QUrl &url) {
@@ -180,7 +172,7 @@ void MainWindow::newTab(const QUrl &url)
{
if(!m_tabBarAdded) {
m_tabBarAdded = true;
- tabToolBar->addWidget(tabBar);
+ ui->mainToolBar->addWidget(tabBar);
}
tabBar->addTab(url);
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 2b94699..d0fb139 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -22,9 +22,6 @@
#define MAINWINDOW_H
#include <QMainWindow>
-#include <QToolBar>
-
-
#include "webengine/webengineprofile.h"
#include <QUrl>
#include "widgets/webviewtabbar.h"
@@ -80,7 +77,6 @@ private:
Q_DISABLE_COPY(MainWindow)
Ui::MainWindow *ui;
- QToolBar *navigationToolBar, *tabToolBar;
WebViewTabBar *tabBar;
WebView *m_currentView;
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 13c5f8f..12a3a6c 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -28,6 +28,34 @@
</size>
</property>
</widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <property name="windowTitle">
+ <string>Main</string>
+ </property>
+ <property name="allowedAreas">
+ <set>Qt::TopToolBarArea</set>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QToolBar" name="navigationToolBar">
+ <property name="windowTitle">
+ <string>Navigation</string>
+ </property>
+ <property name="allowedAreas">
+ <set>Qt::TopToolBarArea</set>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp
index cdd473a..5ef0618 100644
--- a/src/widgets/mainwindowmenubar.cpp
+++ b/src/widgets/mainwindowmenubar.cpp
@@ -32,6 +32,8 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, Main
Q_ASSERT(config);
Q_CHECK_PTR(parent);
+ setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+
// Browser menu
QMenu *browserMenu = new QMenu(qApp->applicationName(), this);
addMenu(browserMenu);