Commit 6d852f30 authored by Hugo Pereira Da Costa's avatar Hugo Pereira Da Costa
Browse files

Delay update of widget's palette to after polish is completed, because...

Delay update of widget's palette to after polish is completed, because setPalette messes up with the
event queue otherwise, resulting with some input chains being broken.
BUG: 344425
parent 787708db
......@@ -31,6 +31,7 @@
#include <QPalette>
#include <QTabWidget>
#include <QTextStream>
#include <QTimer>
namespace Breeze
{
......@@ -45,12 +46,11 @@ namespace Breeze
PaletteHelper::~PaletteHelper()
{ if( _widget ) _widget->deleteLater(); }
//_____________________________________________________
bool PaletteHelper::registerWidget( QWidget* widget )
{
if( _registeredWidgets.contains( widget ) ) return false;
if( adjustPalette( widget, QApplication::palette() ) )
if( acceptWidget( widget ) )
{
if( !_widget )
......@@ -59,8 +59,11 @@ namespace Breeze
_widget->installEventFilter( this );
}
_registeredWidgets.insert( widget );
_pendingWidgets.insert( widget );
connect( widget, SIGNAL(destroyed(QObject*)), SLOT(unregisterWidget(QObject*)) );
QTimer::singleShot( 0, this, SLOT(adjustPendingPalettes()) );
return true;
} else return false;
......@@ -69,7 +72,10 @@ namespace Breeze
//_____________________________________________________
void PaletteHelper::unregisterWidget( QObject* object )
{ _registeredWidgets.remove( object ); }
{
_pendingWidgets.remove( object );
_registeredWidgets.remove( object );
}
//_____________________________________________________
bool PaletteHelper::eventFilter( QObject*, QEvent* event )
......@@ -81,6 +87,17 @@ namespace Breeze
}
//_____________________________________________________
void PaletteHelper::adjustPendingPalettes( void )
{
foreach( QObject* object, _pendingWidgets )
{
adjustPalette( static_cast<QWidget*>( object ), qApp->palette() );
_registeredWidgets.insert( object );
}
_pendingWidgets.clear();
}
//_____________________________________________________
void PaletteHelper::adjustPalettes( const QPalette& palette )
{
......@@ -139,4 +156,40 @@ namespace Breeze
}
//_____________________________________________________
bool PaletteHelper::acceptWidget( QWidget* widget ) const
{
// force side panels as flat, on option, and change font to not-bold
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>( widget );
if( scrollArea &&
!StyleConfigData::sidePanelDrawFrame() &&
( widget->inherits( "KDEPrivate::KPageListView" ) ||
widget->inherits( "KDEPrivate::KPageTreeView" ) ||
widget->property( PropertyNames::sidePanelView ).toBool() ) )
{
return true;
} else if( qobject_cast<QGroupBox*>( widget ) ||
qobject_cast<QMenu*>( widget ) ||
widget->inherits( "QComboBoxPrivateContainer" ) )
{
return true;
} else if( QTabWidget *tabWidget = qobject_cast<QTabWidget*>( widget ) ) {
if( !tabWidget->documentMode() ) return true;
} else if( qobject_cast<QDockWidget*>( widget ) && StyleConfigData::dockWidgetDrawFrame() ) {
return true;
}
return false;
}
}
......@@ -56,8 +56,16 @@ namespace Breeze
//* unregister widget
void unregisterWidget( QObject* );
protected Q_SLOTS:
//* adjust palettes
void adjustPendingPalettes( void );
protected:
//* adjust widget palette
bool acceptWidget( QWidget* ) const;
//* adjust palettes
void adjustPalettes( const QPalette& );
......@@ -73,6 +81,9 @@ namespace Breeze
/** it is used to keep track of application palette changes */
QWidget* _widget = nullptr;
//* widget set
QSet<QObject*> _pendingWidgets;
//* widget set
QSet<QObject*> _registeredWidgets;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment