forked from qt-creator/qt-creator
QmlDesigner.properyEditor: fix hovering for reset button
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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<QFrame>("Bauhaus",1,0,"QFrame");
|
||||
qmlRegisterType<WidgetFrame>("Bauhaus",1,0,"WidgetFrame");
|
||||
qmlRegisterType<WidgetLoader>("Bauhaus",1,0,"WidgetLoader");
|
||||
qmlRegisterType<AnimatedToolButton>("Bauhaus",1,0,"AnimatedToolButton");
|
||||
qmlRegisterExtendedType<MyGroupBox,QGroupBoxDeclarativeUI>("Bauhaus",1,0,"QExtGroupBox");
|
||||
qmlRegisterExtendedType<QTabWidget,QTabWidgetDeclarativeUI>("Bauhaus",1,0,"QTabWidget");
|
||||
qmlRegisterExtendedType<QScrollArea,QScrollAreaDeclarativeUI>("Bauhaus",1,0,"QScrollArea");
|
||||
|
||||
Reference in New Issue
Block a user