mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 02:52:12 +01:00
ComboTabBar: Add possibility to change base color from stylesheets
This commit is contained in:
parent
c62b41d3d7
commit
50d1bb6d96
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Falkon - Qt web browser
|
* Falkon - Qt web browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,6 +16,10 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "proxystyle.h"
|
#include "proxystyle.h"
|
||||||
|
#include "combotabbar.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
|
||||||
ProxyStyle::ProxyStyle()
|
ProxyStyle::ProxyStyle()
|
||||||
: QProxyStyle()
|
: QProxyStyle()
|
||||||
|
@ -56,6 +60,20 @@ int ProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||||
|
{
|
||||||
|
if (element == PE_FrameTabBarBase) {
|
||||||
|
TabBarHelper *tabBar = qobject_cast<TabBarHelper*>(option->styleObject);
|
||||||
|
if (tabBar && tabBar->baseColor().isValid()) {
|
||||||
|
painter->setPen(QPen(tabBar->baseColor(), 0));
|
||||||
|
painter->drawLine(option->rect.topLeft(), option->rect.topRight());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProxyStyle::name() const
|
QString ProxyStyle::name() const
|
||||||
{
|
{
|
||||||
return baseStyle()->objectName();
|
return baseStyle()->objectName();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Falkon - Qt web browser
|
* Falkon - Qt web browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,6 +29,7 @@ public:
|
||||||
|
|
||||||
int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
|
int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
|
||||||
int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const;
|
int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const;
|
||||||
|
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
|
|
|
@ -1015,6 +1015,16 @@ void TabBarHelper::setTabPadding(int padding)
|
||||||
m_tabPadding = padding;
|
m_tabPadding = padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor TabBarHelper::baseColor() const
|
||||||
|
{
|
||||||
|
return m_baseColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabBarHelper::setBaseColor(const QColor &color)
|
||||||
|
{
|
||||||
|
m_baseColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
void TabBarHelper::setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget)
|
void TabBarHelper::setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget)
|
||||||
{
|
{
|
||||||
QTabBar::setTabButton(index, position, widget);
|
QTabBar::setTabButton(index, position, widget);
|
||||||
|
|
|
@ -229,6 +229,7 @@ class FALKON_EXPORT TabBarHelper : public QTabBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int tabPadding READ tabPadding WRITE setTabPadding)
|
Q_PROPERTY(int tabPadding READ tabPadding WRITE setTabPadding)
|
||||||
|
Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TabBarHelper(bool isPinnedTabBar, ComboTabBar* comboTabBar);
|
explicit TabBarHelper(bool isPinnedTabBar, ComboTabBar* comboTabBar);
|
||||||
|
@ -236,6 +237,9 @@ public:
|
||||||
int tabPadding() const;
|
int tabPadding() const;
|
||||||
void setTabPadding(int padding);
|
void setTabPadding(int padding);
|
||||||
|
|
||||||
|
QColor baseColor() const;
|
||||||
|
void setBaseColor(const QColor &color);
|
||||||
|
|
||||||
void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget);
|
void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget);
|
||||||
|
|
||||||
QSize tabSizeHint(int index) const;
|
QSize tabSizeHint(int index) const;
|
||||||
|
@ -277,6 +281,7 @@ private:
|
||||||
QScrollArea* m_scrollArea;
|
QScrollArea* m_scrollArea;
|
||||||
|
|
||||||
int m_tabPadding = -1;
|
int m_tabPadding = -1;
|
||||||
|
QColor m_baseColor;
|
||||||
int m_pressedIndex;
|
int m_pressedIndex;
|
||||||
bool m_dragInProgress;
|
bool m_dragInProgress;
|
||||||
QPoint m_dragStartPosition;
|
QPoint m_dragStartPosition;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user