Falkon Develop
Cross-platform Qt-based web browser
navigationcontainer.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "navigationcontainer.h"
19#include "qzsettings.h"
20#include "tabbar.h"
21
22#include <QPainter>
23#include <QVBoxLayout>
24
26 : QWidget(parent)
27 , m_tabBar(nullptr)
28{
29 m_layout = new QVBoxLayout(this);
30 m_layout->setContentsMargins(0, 0, 0, 0);
31 m_layout->setSpacing(0);
32 setLayout(m_layout);
33
34 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
35}
36
37void NavigationContainer::addWidget(QWidget* widget)
38{
39 m_layout->addWidget(widget);
40}
41
43{
44 m_tabBar = tabBar;
45 m_layout->addWidget(m_tabBar);
46
47 toggleTabsOnTop(qzSettings->tabsOnTop);
48}
49
51{
52 setUpdatesEnabled(false);
53
54 m_layout->removeWidget(m_tabBar);
55 m_layout->insertWidget(enable ? 0 : m_layout->count(), m_tabBar);
56 m_layout->setContentsMargins(0, enable ? 2 : 0, 0, enable ? 2 : 0);
57
58 setUpdatesEnabled(true);
59}
60
61void NavigationContainer::paintEvent(QPaintEvent* event)
62{
63 QWidget::paintEvent(event);
64
65 // Draw line at the bottom of navigation bar if tabs are on top
66 // To visually distinguish navigation bar from the page
67
68 if (qzSettings->tabsOnTop) {
69 QPainter p(this);
70 QRect lineRect(0, height() - 1, width(), 1);
71 QColor c = palette().window().color().darker(125);
72 p.fillRect(lineRect, c);
73 }
74}
NavigationContainer(QWidget *parent=nullptr)
void addWidget(QWidget *widget)
void toggleTabsOnTop(bool enable)
void setTabBar(TabBar *tabBar)
Definition: tabbar.h:31
#define qzSettings
Definition: qzsettings.h:69