Add missing component: RoundButton
This commit is contained in:
parent
2c07878237
commit
9f08668147
@ -163,8 +163,14 @@ void IconItem::setSource(const QVariant &source)
|
||||
}
|
||||
|
||||
if (!localFile.isEmpty()) {
|
||||
m_icon = QIcon();
|
||||
m_imageIcon = QImage(localFile);
|
||||
if (sourceString.endsWith(QLatin1String(".svg")) ||
|
||||
sourceString.endsWith(QLatin1String(".svgz"))) {
|
||||
m_icon = QIcon(localFile);
|
||||
m_imageIcon = QImage();
|
||||
} else {
|
||||
m_icon = QIcon(localFile);
|
||||
m_imageIcon = QImage();
|
||||
}
|
||||
m_svgIconName.clear();
|
||||
delete m_svgIcon;
|
||||
m_svgIcon = nullptr;
|
||||
|
140
src/declarativeimports/plasmacomponents3/RoundButton.qml
Normal file
140
src/declarativeimports/plasmacomponents3/RoundButton.qml
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright 2018 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Templates @QQC2_VERSION@ as T
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import "private" as Private
|
||||
|
||||
T.Button {
|
||||
id: control
|
||||
|
||||
implicitWidth: Math.max(background.implicitWidth,
|
||||
contentItem.implicitWidth + leftPadding + rightPadding)
|
||||
implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding)
|
||||
|
||||
leftPadding: surfaceNormal.margins.left
|
||||
topPadding: surfaceNormal.margins.top
|
||||
rightPadding: surfaceNormal.margins.right
|
||||
bottomPadding: surfaceNormal.margins.bottom
|
||||
|
||||
hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7?
|
||||
|
||||
contentItem: RowLayout {
|
||||
PlasmaCore.IconItem {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: source.length > 0
|
||||
source: control.icon ? (control.icon.name || control.icon.source) : ""
|
||||
}
|
||||
Label {
|
||||
visible: text.length > 0
|
||||
text: control.text
|
||||
font: control.font
|
||||
opacity: enabled || control.highlighted || control.checked ? 1 : 0.4
|
||||
color: theme.buttonTextColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
background: Item {
|
||||
//retrocompatibility with old controls
|
||||
implicitWidth: units.gridUnit * 1.6
|
||||
implicitHeight: units.gridUnit * 1.6
|
||||
|
||||
PlasmaCore.Svg {
|
||||
id: buttonSvg
|
||||
imagePath: "widgets/actionbutton"
|
||||
}
|
||||
|
||||
Private.RoundShadow {
|
||||
id: roundShadow
|
||||
visible: !control.flat || control.activeFocus
|
||||
anchors.fill: parent
|
||||
state: {
|
||||
if (control.pressed) {
|
||||
return "hidden"
|
||||
} else if (control.hovered) {
|
||||
return "hover"
|
||||
} else if (control.activeFocus) {
|
||||
return "focus"
|
||||
} else {
|
||||
return "shadow"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.SvgItem {
|
||||
id: buttonItem
|
||||
svg: buttonSvg
|
||||
elementId: (control.pressed || control.checked) ? "pressed" : "normal"
|
||||
anchors.fill: parent
|
||||
//internal: if there is no hover status, don't paint on mouse over in touchscreens
|
||||
opacity: (control.pressed || control.checked || !control.flat || (roundShadow.hasOverState && control.hovered)) ? 1 : 0
|
||||
Behavior on opacity {
|
||||
PropertyAnimation { duration: units.longDuration }
|
||||
}
|
||||
}
|
||||
|
||||
Private.ButtonShadow {
|
||||
anchors.fill: parent
|
||||
visible: control.text.length > 0 && (!control.flat || control.hovered) && (!control.pressed || !control.checked)
|
||||
state: {
|
||||
if (control.pressed) {
|
||||
return "hidden"
|
||||
} else if (control.hovered) {
|
||||
return "hover"
|
||||
} else if (control.activeFocus) {
|
||||
return "focus"
|
||||
} else {
|
||||
return "shadow"
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: surfaceNormal
|
||||
anchors.fill: parent
|
||||
imagePath: "widgets/button"
|
||||
prefix: "normal"
|
||||
opacity: control.text.length > 0 && (!control.flat || control.hovered) && (!control.pressed || !control.checked) ? 1 : 0
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaCore.FrameSvgItem {
|
||||
anchors.fill: parent
|
||||
imagePath: "widgets/button"
|
||||
prefix: "pressed"
|
||||
visible: control.text.length > 0
|
||||
opacity: control.checked || control.pressed ? 1 : 0
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -32,3 +32,4 @@ TextField 3.0 TextField.qml
|
||||
ToolBar 3.0 ToolBar.qml
|
||||
ToolButton 3.0 ToolButton.qml
|
||||
ToolTip 3.0 ToolTip.qml
|
||||
RoundButton 3.0 RoundButton.qml
|
||||
|
Loading…
x
Reference in New Issue
Block a user