diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/ExtendedFunctionButton.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/ExtendedFunctionButton.qml index 98a36127a94..3f2956c93a0 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/ExtendedFunctionButton.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/ExtendedFunctionButton.qml @@ -1,11 +1,13 @@ import Qt 4.7 import Bauhaus 1.0 -QToolButton { +AnimatedToolButton { id: extendedFunctionButton property variant backendValue + hoverIconFromFile: "images/submenu.png"; + function setIcon() { if (backendValue == null) extendedFunctionButton.iconFromFile = "images/placeholder.png" @@ -40,15 +42,6 @@ QToolButton { styleSheet: "*::down-arrow, *::menu-indicator { image: none; width: 0; height: 0; }"; - - onMouseOverChanged: { - if (mouseOver) { - iconFromFile = "images/submenu.png"; - } else { - setIcon(); - } - } - onActiveChanged: { if (active) { setIcon(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp index 1edae7ea1a5..cfb099bc77a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp @@ -779,6 +779,43 @@ private: QUrl _url; }; +class AnimatedToolButton : public QToolButton +{ + +Q_OBJECT + + Q_PROPERTY(QUrl hoverIconFromFile READ hoverIconFromFile WRITE setHoverIconFromFile) + +public: + AnimatedToolButton( QWidget * parent = 0 ) : QToolButton(parent) + {} + +private: + QUrl hoverIconFromFile() const + { return m_hoverIconUrl; } + + void setHoverIconFromFile(const QUrl &url) + { m_hoverIconUrl= url; + m_hoverIcon = QIcon(m_hoverIconUrl.toLocalFile()); + } + + void leaveEvent(QEvent *) + { + setIcon(m_icon); + } + + void enterEvent(QEvent *) + { + m_icon = icon(); + setIcon(m_hoverIcon); + } + + QUrl m_hoverIconUrl; + QIcon m_hoverIcon; + QIcon m_icon; + +}; + class QComboBoxDeclarativeUI : public QObject { Q_OBJECT @@ -1357,6 +1394,7 @@ QML_DECLARE_TYPE(QTabObject); QML_DECLARE_TYPE(MyGroupBox); QML_DECLARE_TYPE(WidgetLoader); QML_DECLARE_TYPE(WidgetFrame); +QML_DECLARE_TYPE(AnimatedToolButton); void BasicWidgets::registerDeclarativeTypes() { @@ -1399,6 +1437,7 @@ void BasicWidgets::registerDeclarativeTypes() qmlRegisterType("Bauhaus",1,0,"QFrame"); qmlRegisterType("Bauhaus",1,0,"WidgetFrame"); qmlRegisterType("Bauhaus",1,0,"WidgetLoader"); + qmlRegisterType("Bauhaus",1,0,"AnimatedToolButton"); qmlRegisterExtendedType("Bauhaus",1,0,"QExtGroupBox"); qmlRegisterExtendedType("Bauhaus",1,0,"QTabWidget"); qmlRegisterExtendedType("Bauhaus",1,0,"QScrollArea");