QToolBar: Fix QToolbar extension button icon after LayoutDirectionChange
When the layout direction is changed after the QToolButton is created, the extension button icon was not updated. Task-number: QTBUG-66344 Change-Id: I8690b2c42c4f485a39490f16b15b8ee58e6f4ace Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
ede6c44756
commit
23eab78f51
@ -38,7 +38,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qtoolbarextension_p.h"
|
#include "qtoolbarextension_p.h"
|
||||||
#include <qpixmap.h>
|
#include <qevent.h>
|
||||||
#include <qstyle.h>
|
#include <qstyle.h>
|
||||||
#include <qstylepainter.h>
|
#include <qstylepainter.h>
|
||||||
#include <qstyleoption.h>
|
#include <qstyleoption.h>
|
||||||
@ -47,10 +47,11 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QToolBarExtension::QToolBarExtension(QWidget *parent)
|
QToolBarExtension::QToolBarExtension(QWidget *parent)
|
||||||
: QToolButton(parent)
|
: QToolButton(parent)
|
||||||
|
, m_orientation(Qt::Horizontal)
|
||||||
{
|
{
|
||||||
setObjectName(QLatin1String("qt_toolbar_ext_button"));
|
setObjectName(QLatin1String("qt_toolbar_ext_button"));
|
||||||
setAutoRaise(true);
|
setAutoRaise(true);
|
||||||
setOrientation(Qt::Horizontal);
|
setOrientation(m_orientation);
|
||||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
setCheckable(true);
|
setCheckable(true);
|
||||||
}
|
}
|
||||||
@ -63,7 +64,8 @@ void QToolBarExtension::setOrientation(Qt::Orientation o)
|
|||||||
setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt));
|
setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt));
|
||||||
} else {
|
} else {
|
||||||
setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton, &opt));
|
setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton, &opt));
|
||||||
}
|
}
|
||||||
|
m_orientation = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QToolBarExtension::paintEvent(QPaintEvent *)
|
void QToolBarExtension::paintEvent(QPaintEvent *)
|
||||||
@ -83,6 +85,18 @@ QSize QToolBarExtension::sizeHint() const
|
|||||||
return QSize(ext, ext);
|
return QSize(ext, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QToolBarExtension::event(QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::LayoutDirectionChange:
|
||||||
|
setOrientation(m_orientation);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QToolButton::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#include "moc_qtoolbarextension_p.cpp"
|
#include "moc_qtoolbarextension_p.cpp"
|
||||||
|
@ -69,6 +69,12 @@ public:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setOrientation(Qt::Orientation o);
|
void setOrientation(Qt::Orientation o);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::Orientation m_orientation;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user