mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Rename setTabStyle
This commit is contained in:
parent
2c45a3fa0f
commit
593780c1ea
@ -80,9 +80,9 @@ Is used to keep track of currently available and visible tabs.
|
|||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setTabFont( int tabIndex, const QFont &font );
|
void setTabStyle( int tabIndex, const QFont &font, const QColor &color );
|
||||||
%Docstring
|
%Docstring
|
||||||
Sets the optional custom ``font`` for the tab idenfied by ``tabIndex``.
|
Sets the optional custom ``font`` and ``color`` for the tab idenfied by ``tabIndex``.
|
||||||
|
|
||||||
.. versionadded:: 3.26
|
.. versionadded:: 3.26
|
||||||
%End
|
%End
|
||||||
|
@ -1611,7 +1611,7 @@ void QgsAttributeForm::init()
|
|||||||
WidgetInfo widgetInfo = createWidgetFromDef( widgDef, formWidget, mLayer, mContext );
|
WidgetInfo widgetInfo = createWidgetFromDef( widgDef, formWidget, mLayer, mContext );
|
||||||
if ( widgetInfo.overrideLabelStyle )
|
if ( widgetInfo.overrideLabelStyle )
|
||||||
{
|
{
|
||||||
widgetInfo.widget->setStyleSheet( QStringLiteral( "QGroupBox::title { color: rgba(%1,%2,%3,%4); }" ).arg( widgetInfo.labelColor.red() ).arg( widgetInfo.labelColor.green() ).arg( widgetInfo.labelColor.blue() ).arg( QString::number( widgetInfo.labelColor.alphaF(), 'f', 4 ) ) );
|
widgetInfo.widget->setStyleSheet( QStringLiteral( "QGroupBox::title { color: %1; }" ).arg( widgetInfo.labelColor.name( QColor::HexArgb ) ) );
|
||||||
widgetInfo.widget->setFont( widgetInfo.labelFont );
|
widgetInfo.widget->setFont( widgetInfo.labelFont );
|
||||||
}
|
}
|
||||||
layout->addWidget( widgetInfo.widget, row, column, 1, 2 );
|
layout->addWidget( widgetInfo.widget, row, column, 1, 2 );
|
||||||
@ -1636,8 +1636,7 @@ void QgsAttributeForm::init()
|
|||||||
|
|
||||||
if ( widgDef->overrideLabelStyle() )
|
if ( widgDef->overrideLabelStyle() )
|
||||||
{
|
{
|
||||||
tabWidget->setTabFont( tabWidget->tabBar()->count() - 1, widgDef->labelFont() );
|
tabWidget->setTabStyle( tabWidget->tabBar()->count() - 1, widgDef->labelFont(), widgDef->labelColor() );
|
||||||
tabWidget->tabBar()->setTabTextColor( tabWidget->tabBar()->count() - 1, widgDef->labelColor() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( containerDef->visibilityExpression().enabled() )
|
if ( containerDef->visibilityExpression().enabled() )
|
||||||
@ -2263,7 +2262,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
|
|||||||
if ( newWidgetInfo.overrideLabelStyle )
|
if ( newWidgetInfo.overrideLabelStyle )
|
||||||
{
|
{
|
||||||
groupBox->setFont( newWidgetInfo.labelFont );
|
groupBox->setFont( newWidgetInfo.labelFont );
|
||||||
groupBox->setStyleSheet( QStringLiteral( "QGroupBox::title { color: rgba(%1,%2,%3,%4); }" ).arg( newWidgetInfo.labelColor.red() ).arg( newWidgetInfo.labelColor.green() ).arg( newWidgetInfo.labelColor.blue() ).arg( QString::number( newWidgetInfo.labelColor.alphaF(), 'f', 4 ) ) );
|
groupBox->setStyleSheet( QStringLiteral( "QGroupBox::title { color: %1; }" ).arg( newWidgetInfo.labelColor.name( QColor::HexArgb ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myContainer = groupBox;
|
myContainer = groupBox;
|
||||||
|
@ -30,16 +30,20 @@ void QgsTabBarProxyStyle::drawControl( ControlElement element, const QStyleOptio
|
|||||||
{
|
{
|
||||||
if ( element == CE_TabBarTab && mTabStyles.contains( mTabBar->tabAt( option->rect.center() ) ) )
|
if ( element == CE_TabBarTab && mTabStyles.contains( mTabBar->tabAt( option->rect.center() ) ) )
|
||||||
{
|
{
|
||||||
painter->save(); // save the painter to restore later
|
if ( const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>( option ) )
|
||||||
const TabStyle &style { mTabStyles.value( mTabBar->tabAt( option->rect.center() ) ) };
|
{
|
||||||
painter->setFont( style.font ); // change the defaul font of painter
|
painter->save();
|
||||||
QProxyStyle::drawControl( element, option, painter, widget ); // paint the TabBarTab using the default drawControl
|
const TabStyle &style { mTabStyles.value( mTabBar->tabAt( option->rect.center() ) ) };
|
||||||
painter->restore(); // restore to default painter
|
painter->setFont( style.font );
|
||||||
}
|
QStyleOptionTab opt { *tab };
|
||||||
else
|
QProxyStyle::drawControl( element, &opt, painter, widget );
|
||||||
{
|
painter->restore();
|
||||||
QProxyStyle::drawControl( element, option, painter, widget ); // use default drawControl to paint all other components without changes.
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QProxyStyle::drawControl( element, option, painter, widget );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsTabBarProxyStyle::addStyle( int tabIndex, const TabStyle &style )
|
void QgsTabBarProxyStyle::addStyle( int tabIndex, const TabStyle &style )
|
||||||
|
@ -38,6 +38,7 @@ class QgsTabBarProxyStyle : public QProxyStyle
|
|||||||
struct TabStyle
|
struct TabStyle
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
|
QColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
QgsTabBarProxyStyle( QTabBar *tabBar );
|
QgsTabBarProxyStyle( QTabBar *tabBar );
|
||||||
|
@ -74,9 +74,9 @@ int QgsTabWidget::realTabIndex( QWidget *widget )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsTabWidget::setTabFont( int tabIndex, const QFont &customFont )
|
void QgsTabWidget::setTabStyle( int tabIndex, const QFont &font, const QColor &color )
|
||||||
{
|
{
|
||||||
mTabBarStyle->addStyle( tabIndex, QgsTabBarProxyStyle::TabStyle{ customFont } );
|
mTabBarStyle->addStyle( tabIndex, QgsTabBarProxyStyle::TabStyle{ font, color } );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsTabWidget::tabInserted( int index )
|
void QgsTabWidget::tabInserted( int index )
|
||||||
|
@ -92,10 +92,10 @@ class GUI_EXPORT QgsTabWidget : public QTabWidget
|
|||||||
void tabRemoved( int index ) override;
|
void tabRemoved( int index ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the optional custom \a font for the tab idenfied by \a tabIndex.
|
* Sets the optional custom \a font and \a color for the tab idenfied by \a tabIndex.
|
||||||
* \since QGIS 3.26
|
* \since QGIS 3.26
|
||||||
*/
|
*/
|
||||||
void setTabFont( int tabIndex, const QFont &font );
|
void setTabStyle( int tabIndex, const QFont &font, const QColor &color );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void synchronizeIndexes();
|
void synchronizeIndexes();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user