mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
[BrowserWindow] Move TabBar into NavigationContainer
Simplifies entering/leaving fullscreen, as it is only needed to update visibility of the whole container.
This commit is contained in:
parent
6e71ae3c54
commit
b95da97904
@ -301,7 +301,6 @@ void BrowserWindow::setupUi()
|
|||||||
m_mainLayout->setSpacing(0);
|
m_mainLayout->setSpacing(0);
|
||||||
m_mainSplitter = new QSplitter(this);
|
m_mainSplitter = new QSplitter(this);
|
||||||
m_mainSplitter->setObjectName("sidebar-splitter");
|
m_mainSplitter->setObjectName("sidebar-splitter");
|
||||||
m_mainSplitter->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
|
||||||
m_tabWidget = new TabWidget(this);
|
m_tabWidget = new TabWidget(this);
|
||||||
m_superMenu = new QMenu(this);
|
m_superMenu = new QMenu(this);
|
||||||
m_navigationToolbar = new NavigationBar(this);
|
m_navigationToolbar = new NavigationBar(this);
|
||||||
@ -309,18 +308,16 @@ void BrowserWindow::setupUi()
|
|||||||
m_bookmarksToolbar = new BookmarksToolbar(this);
|
m_bookmarksToolbar = new BookmarksToolbar(this);
|
||||||
|
|
||||||
m_navigationContainer = new NavigationContainer(this);
|
m_navigationContainer = new NavigationContainer(this);
|
||||||
QVBoxLayout* l = new QVBoxLayout(m_navigationContainer);
|
m_navigationContainer->addWidget(m_navigationToolbar);
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
m_navigationContainer->addWidget(m_bookmarksToolbar);
|
||||||
l->setSpacing(0);
|
m_navigationContainer->setTabBar(m_tabWidget->getTabBar());
|
||||||
l->addWidget(m_navigationToolbar);
|
|
||||||
l->addWidget(m_bookmarksToolbar);
|
|
||||||
m_navigationContainer->setLayout(l);
|
|
||||||
|
|
||||||
m_mainSplitter->addWidget(m_tabWidget);
|
m_mainSplitter->addWidget(m_tabWidget);
|
||||||
toggleTabsOnTop(qzSettings->tabsOnTop);
|
|
||||||
m_mainLayout->addWidget(m_mainSplitter);
|
|
||||||
m_mainSplitter->setCollapsible(0, false);
|
m_mainSplitter->setCollapsible(0, false);
|
||||||
|
|
||||||
|
m_mainLayout->addWidget(m_navigationContainer);
|
||||||
|
m_mainLayout->addWidget(m_mainSplitter);
|
||||||
|
|
||||||
statusBar()->setObjectName("mainwindow-statusbar");
|
statusBar()->setObjectName("mainwindow-statusbar");
|
||||||
statusBar()->setCursor(Qt::ArrowCursor);
|
statusBar()->setCursor(Qt::ArrowCursor);
|
||||||
m_progressBar = new ProgressBar(statusBar());
|
m_progressBar = new ProgressBar(statusBar());
|
||||||
@ -796,16 +793,8 @@ void BrowserWindow::toggleShowNavigationToolbar()
|
|||||||
|
|
||||||
void BrowserWindow::toggleTabsOnTop(bool enable)
|
void BrowserWindow::toggleTabsOnTop(bool enable)
|
||||||
{
|
{
|
||||||
if (enable) {
|
|
||||||
m_mainLayout->insertWidget(0, m_tabWidget->getTabBar());
|
|
||||||
m_mainLayout->insertWidget(1, m_navigationContainer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_mainLayout->insertWidget(0, m_navigationContainer);
|
|
||||||
m_mainLayout->insertWidget(1, m_tabWidget->getTabBar());
|
|
||||||
}
|
|
||||||
|
|
||||||
qzSettings->tabsOnTop = enable;
|
qzSettings->tabsOnTop = enable;
|
||||||
|
m_navigationContainer->toggleTabsOnTop(enable);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// workaround for changing TabsOnTop state when sidebar is visible
|
// workaround for changing TabsOnTop state when sidebar is visible
|
||||||
@ -1081,7 +1070,6 @@ void BrowserWindow::showNavigationWithFullScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_navigationContainer->show();
|
m_navigationContainer->show();
|
||||||
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::hideNavigationWithFullScreen()
|
void BrowserWindow::hideNavigationWithFullScreen()
|
||||||
@ -1098,7 +1086,6 @@ void BrowserWindow::hideNavigationSlot()
|
|||||||
|
|
||||||
if (isFullScreen() && mouseInView) {
|
if (isFullScreen() && mouseInView) {
|
||||||
m_navigationContainer->hide();
|
m_navigationContainer->hide();
|
||||||
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,10 +1103,9 @@ bool BrowserWindow::event(QEvent* event)
|
|||||||
m_statusBarVisible = statusBar()->isVisible();
|
m_statusBarVisible = statusBar()->isVisible();
|
||||||
menuBar()->hide();
|
menuBar()->hide();
|
||||||
statusBar()->hide();
|
statusBar()->hide();
|
||||||
|
|
||||||
m_navigationContainer->hide();
|
m_navigationContainer->hide();
|
||||||
m_tabWidget->getTabBar()->hide();
|
|
||||||
m_navigationToolbar->setSuperMenuVisible(false);
|
m_navigationToolbar->setSuperMenuVisible(false);
|
||||||
m_hideNavigationTimer->stop();
|
|
||||||
m_navigationToolbar->buttonExitFullscreen()->setVisible(true);
|
m_navigationToolbar->buttonExitFullscreen()->setVisible(true);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (m_useTransparentBackground) {
|
if (m_useTransparentBackground) {
|
||||||
@ -1135,11 +1121,9 @@ bool BrowserWindow::event(QEvent* event)
|
|||||||
|
|
||||||
menuBar()->setVisible(m_menuBarVisible);
|
menuBar()->setVisible(m_menuBarVisible);
|
||||||
statusBar()->setVisible(m_statusBarVisible);
|
statusBar()->setVisible(m_statusBarVisible);
|
||||||
|
|
||||||
m_navigationContainer->show();
|
m_navigationContainer->show();
|
||||||
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
|
|
||||||
m_tabWidget->getTabBar()->setVisible(true);
|
|
||||||
m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible);
|
m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible);
|
||||||
m_hideNavigationTimer->stop();
|
|
||||||
m_navigationToolbar->buttonExitFullscreen()->setVisible(false);
|
m_navigationToolbar->buttonExitFullscreen()->setVisible(false);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (m_useTransparentBackground) {
|
if (m_useTransparentBackground) {
|
||||||
@ -1148,6 +1132,8 @@ bool BrowserWindow::event(QEvent* event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
m_hideNavigationTimer->stop();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -50,6 +50,7 @@ class SideBarManager;
|
|||||||
class ProgressBar;
|
class ProgressBar;
|
||||||
class StatusBarMessage;
|
class StatusBarMessage;
|
||||||
class NavigationBar;
|
class NavigationBar;
|
||||||
|
class NavigationContainer;
|
||||||
class ClickableLabel;
|
class ClickableLabel;
|
||||||
class WebInspectorDockWidget;
|
class WebInspectorDockWidget;
|
||||||
class LocationBar;
|
class LocationBar;
|
||||||
@ -191,7 +192,7 @@ private:
|
|||||||
SideBarManager* m_sideBarManager;
|
SideBarManager* m_sideBarManager;
|
||||||
StatusBarMessage* m_statusBarMessage;
|
StatusBarMessage* m_statusBarMessage;
|
||||||
|
|
||||||
QWidget* m_navigationContainer;
|
NavigationContainer* m_navigationContainer;
|
||||||
NavigationBar* m_navigationToolbar;
|
NavigationBar* m_navigationToolbar;
|
||||||
BookmarksToolbar* m_bookmarksToolbar;
|
BookmarksToolbar* m_bookmarksToolbar;
|
||||||
|
|
||||||
@ -210,7 +211,7 @@ private:
|
|||||||
bool m_useTabNumberShortcuts;
|
bool m_useTabNumberShortcuts;
|
||||||
bool m_useSpeedDialNumberShortcuts;
|
bool m_useSpeedDialNumberShortcuts;
|
||||||
|
|
||||||
// Used for F11 FullScreen remember visibility of menubar and statusbar
|
// Remember visibility of menubar and statusbar after entering Fullscreen
|
||||||
bool m_menuBarVisible;
|
bool m_menuBarVisible;
|
||||||
bool m_statusBarVisible;
|
bool m_statusBarVisible;
|
||||||
Qt::WindowStates m_windowStates;
|
Qt::WindowStates m_windowStates;
|
||||||
|
@ -49,7 +49,8 @@ NavigationBar::NavigationBar(BrowserWindow* window)
|
|||||||
: QWidget(window)
|
: QWidget(window)
|
||||||
, m_window(window)
|
, m_window(window)
|
||||||
{
|
{
|
||||||
setObjectName("navigationbar");
|
setObjectName(QSL("navigationbar"));
|
||||||
|
|
||||||
m_layout = new QHBoxLayout(this);
|
m_layout = new QHBoxLayout(this);
|
||||||
m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this));
|
m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this));
|
||||||
m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
|
m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
|
||||||
|
@ -17,12 +17,44 @@
|
|||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "navigationcontainer.h"
|
#include "navigationcontainer.h"
|
||||||
#include "qzsettings.h"
|
#include "qzsettings.h"
|
||||||
|
#include "tabbar.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
NavigationContainer::NavigationContainer(QWidget* parent)
|
NavigationContainer::NavigationContainer(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
, m_tabBar(0)
|
||||||
{
|
{
|
||||||
|
m_layout = new QVBoxLayout(this);
|
||||||
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_layout->setSpacing(0);
|
||||||
|
|
||||||
|
setLayout(m_layout);
|
||||||
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationContainer::addWidget(QWidget* widget)
|
||||||
|
{
|
||||||
|
m_layout->addWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationContainer::setTabBar(TabBar* tabBar)
|
||||||
|
{
|
||||||
|
m_tabBar = tabBar;
|
||||||
|
m_layout->addWidget(m_tabBar);
|
||||||
|
|
||||||
|
toggleTabsOnTop(qzSettings->tabsOnTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationContainer::toggleTabsOnTop(bool enable)
|
||||||
|
{
|
||||||
|
setUpdatesEnabled(false);
|
||||||
|
|
||||||
|
m_layout->removeWidget(m_tabBar);
|
||||||
|
m_layout->insertWidget(enable ? 0 : m_layout->count(), m_tabBar);
|
||||||
|
|
||||||
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationContainer::paintEvent(QPaintEvent* event)
|
void NavigationContainer::paintEvent(QPaintEvent* event)
|
||||||
|
@ -20,16 +20,27 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "qzsettings.h"
|
#include "qzcommon.h"
|
||||||
|
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
|
class TabBar;
|
||||||
|
|
||||||
class QUPZILLA_EXPORT NavigationContainer : public QWidget
|
class QUPZILLA_EXPORT NavigationContainer : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NavigationContainer(QWidget* parent = 0);
|
explicit NavigationContainer(QWidget* parent = 0);
|
||||||
|
|
||||||
|
void addWidget(QWidget* widget);
|
||||||
|
void setTabBar(TabBar* tabBar);
|
||||||
|
|
||||||
|
void toggleTabsOnTop(bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event);
|
||||||
|
|
||||||
|
QVBoxLayout* m_layout;
|
||||||
|
TabBar* m_tabBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAVIGATIONCONTAINER_H
|
#endif // NAVIGATIONCONTAINER_H
|
||||||
|
@ -99,25 +99,6 @@ void TabBar::loadSettings()
|
|||||||
setUpLayout();
|
setUpLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabBar::updateVisibilityWithFullscreen(bool visible)
|
|
||||||
{
|
|
||||||
// It is needed to save original geometry, otherwise
|
|
||||||
// tabbar will get 3px height in fullscreen once it was hidden
|
|
||||||
|
|
||||||
ComboTabBar::setVisible(visible);
|
|
||||||
|
|
||||||
// Make sure to honor user preference
|
|
||||||
if (visible) {
|
|
||||||
visible = !(count() == 1 && m_hideTabBarWithOneTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (visible) {
|
|
||||||
setGeometry(m_originalGeometry);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_tabWidget->setUpLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabBar::setVisible(bool visible)
|
void TabBar::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
if (visible && m_window->isFullScreen()) {
|
if (visible && m_window->isFullScreen()) {
|
||||||
@ -129,10 +110,6 @@ void TabBar::setVisible(bool visible)
|
|||||||
visible = !(count() == 1 && m_hideTabBarWithOneTab);
|
visible = !(count() == 1 && m_hideTabBarWithOneTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!visible) {
|
|
||||||
m_originalGeometry = geometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
hideTabPreview(false);
|
hideTabPreview(false);
|
||||||
ComboTabBar::setVisible(visible);
|
ComboTabBar::setVisible(visible);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ public:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
void updateVisibilityWithFullscreen(bool visible);
|
|
||||||
|
|
||||||
void overrideTabTextColor(int index, QColor color);
|
void overrideTabTextColor(int index, QColor color);
|
||||||
void restoreTabTextColor(int index);
|
void restoreTabTextColor(int index);
|
||||||
@ -116,7 +115,6 @@ private:
|
|||||||
mutable int m_activeTabWidth;
|
mutable int m_activeTabWidth;
|
||||||
|
|
||||||
QColor m_originalTabTextColor;
|
QColor m_originalTabTextColor;
|
||||||
QRect m_originalGeometry;
|
|
||||||
QPoint m_dragStartPosition;
|
QPoint m_dragStartPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user