forked from openkylin/qt5-ukui-platformtheme
Feat: 实现QML主题框架支持RoundButton
This commit is contained in:
parent
02f4d8e361
commit
7f4ae43169
|
@ -1484,7 +1484,9 @@ void KyQuickStyleItem::paint(QPainter *painter)
|
||||||
if(m_buttonType == "blueButton") {
|
if(m_buttonType == "blueButton") {
|
||||||
wid.setProperty("isImportant", true);
|
wid.setProperty("isImportant", true);
|
||||||
}
|
}
|
||||||
|
if(m_roundButton == "RoundButton") {
|
||||||
|
wid.setProperty("isRoundButton", true);
|
||||||
|
}
|
||||||
KyQuickStyleItem::style()->drawControl(QStyle::CE_PushButton, m_styleoption, painter,&wid);
|
KyQuickStyleItem::style()->drawControl(QStyle::CE_PushButton, m_styleoption, painter,&wid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -66,6 +66,7 @@ class KyQuickStyleItem: public QQuickItem
|
||||||
Q_PROPERTY( int bottomPadding READ bottomPadding NOTIFY bottomPaddingChanged)
|
Q_PROPERTY( int bottomPadding READ bottomPadding NOTIFY bottomPaddingChanged)
|
||||||
|
|
||||||
Q_PROPERTY( QString buttonType READ buttonType WRITE setbuttonType NOTIFY buttonTypeChanged)
|
Q_PROPERTY( QString buttonType READ buttonType WRITE setbuttonType NOTIFY buttonTypeChanged)
|
||||||
|
Q_PROPERTY( QString roundButton READ roundButton WRITE setroundButton NOTIFY roundButtonChanged)
|
||||||
|
|
||||||
Q_PROPERTY( QQuickItem *control READ control WRITE setControl NOTIFY controlChanged)
|
Q_PROPERTY( QQuickItem *control READ control WRITE setControl NOTIFY controlChanged)
|
||||||
|
|
||||||
|
@ -199,6 +200,12 @@ public:
|
||||||
emit buttonTypeChanged();
|
emit buttonTypeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString roundButton() const { return m_roundButton;}
|
||||||
|
void setroundButton(QString roundButton) {
|
||||||
|
m_roundButton = roundButton ;
|
||||||
|
emit roundButtonChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
int pixelMetric(const QString&);
|
int pixelMetric(const QString&);
|
||||||
QVariant styleHint(const QString&);
|
QVariant styleHint(const QString&);
|
||||||
|
@ -248,6 +255,7 @@ Q_SIGNALS:
|
||||||
void bottomPaddingChanged();
|
void bottomPaddingChanged();
|
||||||
|
|
||||||
void buttonTypeChanged();
|
void buttonTypeChanged();
|
||||||
|
void roundButtonChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *) override;
|
bool event(QEvent *) override;
|
||||||
|
@ -305,6 +313,7 @@ protected:
|
||||||
static QStyle *s_style;
|
static QStyle *s_style;
|
||||||
|
|
||||||
QString m_buttonType;
|
QString m_buttonType;
|
||||||
|
QString m_roundButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KYQUICKSTYLEITEM_H
|
#endif // KYQUICKSTYLEITEM_H
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Templates 2.5 as T
|
||||||
|
import org.ukui.qqc2style.private 1.0 as StylePrivate
|
||||||
|
|
||||||
|
T.RoundButton {
|
||||||
|
id: controlRoot
|
||||||
|
palette: StylePrivate.StyleHelper.palette
|
||||||
|
|
||||||
|
/* The value type of buttonType are "CloseButton","MaxButton","MinButton","blueButton","Default". */
|
||||||
|
StylePrivate.StyleHelper.buttonType: "Default"
|
||||||
|
|
||||||
|
|
||||||
|
implicitWidth: background.implicitWidth
|
||||||
|
implicitHeight: background.implicitHeight
|
||||||
|
|
||||||
|
hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7?
|
||||||
|
|
||||||
|
contentItem: Item {}
|
||||||
|
|
||||||
|
background: StylePrivate.StyleItem {
|
||||||
|
id: styleitem
|
||||||
|
anchors.fill: parent
|
||||||
|
buttonType: controlRoot.StylePrivate.StyleHelper.buttonType
|
||||||
|
control: controlRoot
|
||||||
|
elementType: "button"
|
||||||
|
roundButton:"RoundButton"
|
||||||
|
sunken: controlRoot.pressed || (controlRoot.checkable && controlRoot.checked)
|
||||||
|
raised: !(controlRoot.pressed || (controlRoot.checkable && controlRoot.checked))
|
||||||
|
hover: controlRoot.hovered
|
||||||
|
text: controlRoot.text
|
||||||
|
hasFocus: controlRoot.activeFocus
|
||||||
|
activeControl: controlRoot.isDefault ? "default" : "f"
|
||||||
|
properties: {
|
||||||
|
"icon": controlRoot.icon && controlRoot.display !== T.AbstractButton.TextOnly ? (controlRoot.icon.name || controlRoot.icon.source) : "",
|
||||||
|
"iconWidth": controlRoot.icon && controlRoot.icon.width ? controlRoot.icon.width : 0,
|
||||||
|
"iconHeight": controlRoot.icon && controlRoot.icon.height ? controlRoot.icon.height : 0,
|
||||||
|
"flat": controlRoot.flat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue