From 8a1502c9cf06f2cc0baf90b03a75e1e0440de5e8 Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 11 Feb 2013 13:08:11 +0100 Subject: [PATCH] Draw line at the bottom of navigation bar if tabs are on top. To visually distinguish navigation bar from the page --- src/lib/app/qupzilla.cpp | 3 +- src/lib/lib.pro | 6 ++- src/lib/navigation/navigationcontainer.cpp | 43 ++++++++++++++++++++++ src/lib/navigation/navigationcontainer.h | 33 +++++++++++++++++ 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 src/lib/navigation/navigationcontainer.cpp create mode 100644 src/lib/navigation/navigationcontainer.h diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 35a019b50..60f3e8035 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -59,6 +59,7 @@ #include "qztools.h" #include "reloadstopbutton.h" #include "enhancedmenu.h" +#include "navigationcontainer.h" #include "settings.h" #include "qzsettings.h" #include "webtab.h" @@ -297,7 +298,7 @@ void QupZilla::setupUi() m_navigationBar->setSplitterSizes(locationBarWidth, websearchBarWidth); m_bookmarksToolbar = new BookmarksToolbar(this); - m_navigationContainer = new QWidget(this); + m_navigationContainer = new NavigationContainer(this); QVBoxLayout* l = new QVBoxLayout(m_navigationContainer); l->setContentsMargins(0, 0, 0, 0); l->setSpacing(0); diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 3dbe9f9ae..deabae9b0 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -212,7 +212,8 @@ SOURCES += \ network/schemehandlers/ftpschemehandler.cpp \ autofill/autofillicon.cpp \ autofill/autofillwidget.cpp \ - tools/menubar.cpp + tools/menubar.cpp \ + navigation/navigationcontainer.cpp HEADERS += \ webview/tabpreview.h \ @@ -379,7 +380,8 @@ HEADERS += \ network/schemehandlers/ftpschemehandler.h \ autofill/autofillicon.h \ autofill/autofillwidget.h \ - tools/menubar.h + tools/menubar.h \ + navigation/navigationcontainer.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/lib/navigation/navigationcontainer.cpp b/src/lib/navigation/navigationcontainer.cpp new file mode 100644 index 000000000..48a844903 --- /dev/null +++ b/src/lib/navigation/navigationcontainer.cpp @@ -0,0 +1,43 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "navigationcontainer.h" +#include "qzsettings.h" + +#include +#include + +NavigationContainer::NavigationContainer(QWidget* parent) + : QWidget(parent) +{ +} + +void NavigationContainer::paintEvent(QPaintEvent* event) +{ + QWidget::paintEvent(event); + + if (qzSettings->tabsOnTop) { + // Draw line at the bottom of navigation bar if tabs are on top + // To visually distinguish navigation bar from the page + QStyleOptionFrameV3 option; + option.initFrom(this); + + QPainter p(this); + QRect lineRect(0, height() - 1, width(), 1); + p.fillRect(lineRect, option.palette.window().color().darker(150)); + } +} diff --git a/src/lib/navigation/navigationcontainer.h b/src/lib/navigation/navigationcontainer.h new file mode 100644 index 000000000..b8af373ca --- /dev/null +++ b/src/lib/navigation/navigationcontainer.h @@ -0,0 +1,33 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef NAVIGATIONCONTAINER_H +#define NAVIGATIONCONTAINER_H + +#include + +class NavigationContainer : public QWidget +{ +public: + explicit NavigationContainer(QWidget* parent = 0); + +private: + void paintEvent(QPaintEvent* event); + +}; + +#endif // NAVIGATIONCONTAINER_H