Merge branch 'master' of git://anongit.kde.org/kde-runtime

This commit is contained in:
Jacopo De Simoi 2011-11-24 18:05:28 +01:00
commit fa809e96c8
4 changed files with 311 additions and 42 deletions

View File

@ -54,7 +54,7 @@ install(FILES qml/ProgressBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimpo
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ScrollBarDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ScrollDecoratorDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/SectionScroller.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/SectionScroller.js 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/Switch.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
@ -62,11 +62,11 @@ install(FILES qml/TabBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimp
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/TabGroup.js 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/TextArea.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/TextField.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
#install platform overrides

View File

@ -0,0 +1,247 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by 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 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
Item {
id: button
// Commmon API
property bool flat: true
property bool checked: false
property bool checkable: false
property alias pressed: mouse.pressed
property alias text: label.text
property alias iconSource: icon.source
property alias font: label.font
signal clicked()
onFlatChanged: {
delegate.opacity = 1
}
implicitWidth: {
if (label.paintedWidth == 0) {
return implicitHeight
} else {
return Math.max(theme.defaultFont.mSize.width*12, icon.width + label.paintedWidth + delegate.margins.left + delegate.margins.right) + ((icon.valid) ? delegate.margins.left : 0)
}
}
implicitHeight: Math.max(theme.defaultFont.mSize.height*1.6, Math.max(icon.height, label.paintedHeight) + delegate.margins.top/2 + delegate.margins.bottom/2)
// TODO: needs to define if there will be specific graphics for
// disabled buttons
opacity: enabled ? 1.0 : 0.5
Keys.onSpacePressed: internal.pressButton()
Keys.onReturnPressed: internal.pressButton()
Keys.onReleased: {
if (event.key == Qt.Key_Space ||
event.key == Qt.Key_Return)
internal.releaseButton()
}
onActiveFocusChanged: {
if (activeFocus) {
shadow.state = "focus"
} else if (checked) {
shadow.state = "hidden"
} else {
shadow.state = "shadow"
}
}
QtObject {
id: internal
property bool userPressed: false
function pressButton()
{
userPressed = true
}
function releaseButton()
{
userPressed = false
if (!button.enabled) {
return
}
if (button.checkable) {
button.checked = !button.checked
}
button.clicked()
button.forceActiveFocus()
}
}
Loader {
id: delegate
anchors.fill:parent
property QtObject margins: item.margins
sourceComponent: {
if (label.paintedWidth == 0 && !flat) {
return roundButtonComponent
} else {
return buttonComponent
}
}
}
Component {
id: buttonComponent
Item {
anchors.fill: parent
property alias margins: surface.margins
ButtonShadow {
id: shadow
anchors.fill: parent
visible: !flat
state: (internal.userPressed || checked) ? "hidden" : "shadow"
}
PlasmaCore.FrameSvgItem {
id: surface
anchors.fill: parent
imagePath: "widgets/button"
prefix: (internal.userPressed || checked) ? "pressed" : "normal"
//internal: if there is no hover status, don't paint on mouse over in touchscreens
opacity: (internal.userPressed || checked || !flat || (shadow.hasOverState && mouse.containsMouse)) ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: 250 }
}
}
}
}
Component {
id: roundButtonComponent
Item {
anchors.fill: parent
property QtObject margins: QtObject {
property int left: 16
property int top: 16
property int right: 16
property int bottom: 16
}
RoundShadow {
anchors.fill: parent
state: (internal.userPressed || checked) ? "hidden" : "shadow"
}
PlasmaCore.Svg {
id: buttonSvg
imagePath: "widgets/actionbutton"
}
PlasmaCore.SvgItem {
id: buttonItem
svg: buttonSvg
elementId: (internal.userPressed || checked) ? "pressed" : "normal"
width: parent.height
height: width
}
}
}
Item {
anchors {
fill: parent
leftMargin: delegate.margins.left
topMargin: delegate.margins.top
rightMargin: delegate.margins.right
bottomMargin: delegate.margins.bottom
}
IconLoader {
id: icon
anchors {
verticalCenter: parent.verticalCenter
left: label.text ? parent.left : undefined
horizontalCenter: label.text ? undefined : parent.horizontalCenter
}
}
Text {
id: label
//FIXME: why this is needed?
onPaintedWidthChanged: {
icon.anchors.horizontalCenter = label.paintedWidth > 0 ? undefined : icon.parent.horizontalCenter
icon.anchors.left = label.paintedWidth > 0 ? icon.parent.left : undefined
}
anchors {
top: parent.top
bottom: parent.bottom
left: icon.valid ? icon.right : parent.left
right: parent.right
}
font.capitalization: theme.defaultFont.capitalization
font.family: theme.defaultFont.family
font.italic: theme.defaultFont.italic
font.letterSpacing: theme.defaultFont.letterSpacing
font.pointSize: theme.defaultFont.pointSize
font.strikeout: theme.defaultFont.strikeout
font.underline: theme.defaultFont.underline
font.weight: theme.defaultFont.weight
font.wordSpacing: theme.defaultFont.wordSpacing
color: theme.buttonTextColor
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
onPressed: internal.pressButton();
onReleased: internal.releaseButton();
onEntered: {
if (!flat) {
shadow.state = "hover"
}
}
onExited: {
if (!flat) {
if (button.activeFocus) {
shadow.state = "focus"
} else if (checked) {
shadow.state = "hidden"
} else {
shadow.state = "shadow"
}
}
}
}
}

View File

@ -41,6 +41,7 @@
****************************************************************************/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import "." 0.1
@ -58,7 +59,8 @@ CommonDialog {
id: defaultDelegate
Label {
//platformInverted: root.platformInverted
visible: modelData.search(RegExp(filterField.filterText, "i")) != -1
height: visible? paintedHeight*2 : 0
text: modelData
MouseArea {
anchors.fill: parent
@ -78,35 +80,53 @@ CommonDialog {
content: Item {
id: contentItem
width: theme.defaultFont.mSize.width * 40
implicitWidth: theme.defaultFont.mSize.width * 40
height: theme.defaultFont.mSize.height * 12
Item {
// Clipping item with bottom margin added to align content with rounded background graphics
id: clipItem
anchors.fill: parent
anchors.bottomMargin: 4
TextField {
id: filterField
property string filterText
onTextChanged: searchTimer.restart()
clearButtonShown: true
anchors {
top: parent.top
left: parent.left
right: parent.right
}
Timer {
id: searchTimer
running: false
repeat: false
interval: 500
onTriggered: filterField.filterText = filterField.text
}
}
ListView {
id: listView
anchors {
top: filterField.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
currentIndex : -1
width: contentItem.width
height: contentItem.height
delegate: root.delegate
clip: true
ListView {
id: listView
currentIndex : -1
width: contentItem.width
height: contentItem.height
delegate: root.delegate
clip: true
Keys.onPressed: {
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down
|| event.key == Qt.Key_Left || event.key == Qt.Key_Right
|| event.key == Qt.Key_Select || event.key == Qt.Key_Enter
|| event.key == Qt.Key_Return) {
listView.currentIndex = 0
event.accepted = true
}
Keys.onPressed: {
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down
|| event.key == Qt.Key_Left || event.key == Qt.Key_Right
|| event.key == Qt.Key_Select || event.key == Qt.Key_Enter
|| event.key == Qt.Key_Return) {
listView.currentIndex = 0
event.accepted = true
}
}
}
ScrollBar {
id: scrollBar
flickableItem: listView

View File

@ -35,22 +35,16 @@ Item {
property string valueIndicatorText: value
// Plasma API
property bool animated: false
property alias inverted: range.inverted
property bool updateValueWhileDragging: true
property real handleSize: 22
// Convenience API
property bool _isVertical: orientation == Qt.Vertical
width: _isVertical ? theme.defaultFont.mSize.height*1.6 : 200
height: _isVertical ? 200 : theme.defaultFont.mSize.height*1.6
width: contents.isVertical ? theme.defaultFont.mSize.height*1.6 : 200
height: contents.isVertical ? 200 : theme.defaultFont.mSize.height*1.6
// TODO: needs to define if there will be specific graphics for
// disabled sliders
opacity: enabled ? 1.0 : 0.5
Keys.onUpPressed: {
if (!enabled || !_isVertical)
if (!enabled || !contents.isVertical)
return;
if (inverted)
@ -63,7 +57,7 @@ Item {
if (!enabled || !enabled)
return;
if (!_isVertical)
if (!contents.isVertical)
return;
if (inverted)
@ -73,7 +67,7 @@ Item {
}
Keys.onLeftPressed: {
if (!enabled || _isVertical)
if (!enabled || contents.isVertical)
return;
if (inverted)
@ -83,7 +77,7 @@ Item {
}
Keys.onRightPressed: {
if (!enabled || _isVertical)
if (!enabled || contents.isVertical)
return;
if (inverted)
@ -95,9 +89,17 @@ Item {
Item {
id: contents
width: _isVertical ? slider.height : slider.width
height: _isVertical ? slider.width : slider.height
rotation: _isVertical ? -90 : 0
// Plasma API
property bool animated: true
property bool updateValueWhileDragging: true
property real handleSize: theme.defaultFont.mSize.height*1.3
// Convenience API
property bool isVertical: orientation == Qt.Vertical
width: contents.isVertical ? slider.height : slider.width
height: contents.isVertical ? slider.width : slider.height
rotation: contents.isVertical ? -90 : 0
anchors.centerIn: parent
@ -158,8 +160,8 @@ Item {
anchors {
verticalCenter: groove.verticalCenter
}
width: handleSize
height: handleSize
width: contents.handleSize
height: contents.handleSize
svg: PlasmaCore.Svg { imagePath: "widgets/slider" }
elementId: "horizontal-slider-handle"