forked from qt-creator/qt-creator
Core: Deduplicate FancyToolButton initialization
Change-Id: Iea178d2af7ab03e14a59745bc1bbe34e7d3294f1 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
committed by
Martin Kampas
parent
f58ab8d723
commit
e26cce2b5a
@@ -52,9 +52,12 @@ using namespace Utils;
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
FancyToolButton::FancyToolButton(QWidget *parent)
|
FancyToolButton::FancyToolButton(QAction *action, QWidget *parent)
|
||||||
: QToolButton(parent), m_fader(0)
|
: QToolButton(parent), m_fader(0)
|
||||||
{
|
{
|
||||||
|
setDefaultAction(action);
|
||||||
|
connect(action, &QAction::changed, this, &FancyToolButton::actionChanged);
|
||||||
|
|
||||||
setAttribute(Qt::WA_Hover, true);
|
setAttribute(Qt::WA_Hover, true);
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
@@ -336,18 +339,12 @@ FancyActionBar::FancyActionBar(QWidget *parent)
|
|||||||
|
|
||||||
void FancyActionBar::addProjectSelector(QAction *action)
|
void FancyActionBar::addProjectSelector(QAction *action)
|
||||||
{
|
{
|
||||||
FancyToolButton* toolButton = new FancyToolButton(this);
|
m_actionsLayout->insertWidget(0, new FancyToolButton(action, this));
|
||||||
toolButton->setDefaultAction(action);
|
|
||||||
connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
|
|
||||||
m_actionsLayout->insertWidget(0, toolButton);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void FancyActionBar::insertAction(int index, QAction *action)
|
void FancyActionBar::insertAction(int index, QAction *action)
|
||||||
{
|
{
|
||||||
FancyToolButton *toolButton = new FancyToolButton(this);
|
m_actionsLayout->insertWidget(index, new FancyToolButton(action, this));
|
||||||
toolButton->setDefaultAction(action);
|
|
||||||
connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
|
|
||||||
m_actionsLayout->insertWidget(index, toolButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout *FancyActionBar::actionsLayout() const
|
QLayout *FancyActionBar::actionsLayout() const
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class FancyToolButton : public QToolButton
|
|||||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FancyToolButton(QWidget *parent = 0);
|
FancyToolButton(QAction *action, QWidget *parent = 0);
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
bool event(QEvent *e);
|
bool event(QEvent *e);
|
||||||
|
|||||||
Reference in New Issue
Block a user