Switch is a CheckBox on desktop
the sliding Switch is touch specific
This commit is contained in:
parent
3355360444
commit
7a7914126e
@ -61,7 +61,6 @@ install(FILES qml/QueryDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimpo
|
|||||||
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Switch.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
|
||||||
install(FILES qml/TabBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/TabBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/TabButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/TabButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/TabGroup.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/TabGroup.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 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 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import "private" as Private
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean toggle button with the visual representation of a "realistic"
|
||||||
|
* switch with a movable toggle showing the state of the Switch. Generally
|
||||||
|
* easier to use on touch devices than a CheckBox due to the larger surface
|
||||||
|
* space and more evident state visualization.
|
||||||
|
*
|
||||||
|
* You can bind the Switch component, for example, to a feature that the
|
||||||
|
* application has to enable or disable depending on the user's input.
|
||||||
|
*
|
||||||
|
* All elements of this component are defined in DualStateButton, its base component.
|
||||||
|
*/
|
||||||
|
Private.DualStateButton {
|
||||||
|
id: switchItem
|
||||||
|
|
||||||
|
view: PlasmaCore.FrameSvgItem {
|
||||||
|
imagePath: "widgets/slider"
|
||||||
|
prefix: "groove"
|
||||||
|
width: height * 2
|
||||||
|
height: Math.max(theme.mSize(theme.defaultFont).height + margins.top + margins.bottom,
|
||||||
|
button.margins.top + button.margins.bottom)
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: highlight
|
||||||
|
imagePath: "widgets/slider"
|
||||||
|
prefix: "groove-highlight"
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
opacity: checked ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
PropertyAnimation { duration: 100 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: "shadow"
|
||||||
|
anchors {
|
||||||
|
fill: button
|
||||||
|
leftMargin: -margins.left
|
||||||
|
topMargin: -margins.top
|
||||||
|
rightMargin: -margins.right
|
||||||
|
bottomMargin: -margins.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: button
|
||||||
|
imagePath: "widgets/button"
|
||||||
|
prefix: "normal"
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
width: height
|
||||||
|
x: checked ? width : 0
|
||||||
|
Behavior on x {
|
||||||
|
PropertyAnimation { duration: 100 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,64 +22,45 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
|||||||
import "private" as Private
|
import "private" as Private
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A boolean toggle button with the visual representation of a "realistic"
|
* A check box is a component that can be switched on (checked) or off
|
||||||
* switch with a movable toggle showing the state of the Switch. Generally
|
* (unchecked). Check boxes are typically used to represent features in an
|
||||||
* easier to use on touch devices than a CheckBox due to the larger surface
|
* application that can be enabled or disabled without affecting others, but
|
||||||
* space and more evident state visualization.
|
* different types of behavior can be implemented. When a check box is checked
|
||||||
|
* or unchecked it sends a clicked signal for the application to handle.
|
||||||
*
|
*
|
||||||
* You can bind the Switch component, for example, to a feature that the
|
* When a check box has the focus, its state can be toggled using the
|
||||||
* application has to enable or disable depending on the user's input.
|
* Qt.Key_Select, Qt.Key_Return, and Qt.Key_Enter hardware keys that send the
|
||||||
|
* clicked signal.
|
||||||
*
|
*
|
||||||
* All elements of this component are defined in DualStateButton, its base component.
|
* All elements of this component are defined in DualStateButton, its base component.
|
||||||
*/
|
*/
|
||||||
Private.DualStateButton {
|
Private.DualStateButton {
|
||||||
id: switchItem
|
id: checkBox
|
||||||
|
|
||||||
view: PlasmaCore.FrameSvgItem {
|
view: PlasmaCore.FrameSvgItem {
|
||||||
imagePath: "widgets/slider"
|
imagePath: "widgets/button"
|
||||||
prefix: "groove"
|
prefix: "normal"
|
||||||
width: height * 2
|
width: theme.mSize(theme.defaultFont).height + margins.left
|
||||||
height: Math.max(theme.mSize(theme.defaultFont).height + margins.top + margins.bottom,
|
height: theme.mSize(theme.defaultFont).height + margins.top
|
||||||
button.margins.top + button.margins.bottom)
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: highlight
|
|
||||||
imagePath: "widgets/slider"
|
|
||||||
prefix: "groove-highlight"
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
svg: PlasmaCore.Svg {
|
||||||
|
id: checkmarkSvg
|
||||||
|
imagePath: "widgets/checkmarks"
|
||||||
|
}
|
||||||
|
elementId: "checkbox"
|
||||||
opacity: checked ? 1 : 0
|
opacity: checked ? 1 : 0
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
margins: parent.margins.left/2
|
||||||
|
}
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
PropertyAnimation { duration: 100 }
|
NumberAnimation {
|
||||||
}
|
duration: 250
|
||||||
}
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: "shadow"
|
|
||||||
anchors {
|
|
||||||
fill: button
|
|
||||||
leftMargin: -margins.left
|
|
||||||
topMargin: -margins.top
|
|
||||||
rightMargin: -margins.right
|
|
||||||
bottomMargin: -margins.bottom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: button
|
|
||||||
imagePath: "widgets/button"
|
|
||||||
prefix: "normal"
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
width: height
|
|
||||||
x: checked ? width : 0
|
|
||||||
Behavior on x {
|
|
||||||
PropertyAnimation { duration: 100 }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
shadow: Private.ButtonShadow {}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user