Merge branch 'master' into editbubble

This commit is contained in:
Sebastian Kügler 2011-11-28 23:47:48 +01:00
commit 1e8cc6c2d5
12 changed files with 132 additions and 123 deletions

View File

@ -194,7 +194,7 @@ void DialogProxy::setVisible(const bool visible)
if (m_dialog->isVisible() != visible) { if (m_dialog->isVisible() != visible) {
m_dialog->setVisible(visible); m_dialog->setVisible(visible);
if (visible) { if (visible) {
m_dialog->setWindowFlags(m_flags); m_dialog->setWindowFlags(Qt::FramelessWindowHint|m_flags);
m_dialog->setVisible(visible); m_dialog->setVisible(visible);
m_dialog->raise(); m_dialog->raise();
} }

View File

@ -92,12 +92,12 @@ void ToolTipProxy::syncTarget()
return; return;
} }
if (!m_declarativeItemContainer) { if (!m_declarativeItemContainer && scene) {
m_declarativeItemContainer = QWeakPointer<DeclarativeItemContainer>(new DeclarativeItemContainer()); m_declarativeItemContainer = QWeakPointer<DeclarativeItemContainer>(new DeclarativeItemContainer());
m_declarativeItemContainer.data()->setObjectName("DIContainer"); m_declarativeItemContainer.data()->setObjectName("DIContainer");
scene->addItem(m_declarativeItemContainer.data()); scene->addItem(m_declarativeItemContainer.data());
} }
if (m_declarativeItemContainer) { if (m_declarativeItemContainer) {
m_target.data()->setObjectName("Original Item"); m_target.data()->setObjectName("Original Item");
m_declarativeItemContainer.data()->setDeclarativeItem(item, false); m_declarativeItemContainer.data()->setDeclarativeItem(item, false);
@ -105,7 +105,7 @@ void ToolTipProxy::syncTarget()
m_declarativeItemContainer.data()->setParentItem(m_target.data()); m_declarativeItemContainer.data()->setParentItem(m_target.data());
m_widget = m_declarativeItemContainer.data(); m_widget = m_declarativeItemContainer.data();
emit targetChanged(); emit targetChanged();
} }
} }
QString ToolTipProxy::mainText() const QString ToolTipProxy::mainText() const

View File

@ -112,8 +112,9 @@ Item {
onActiveWindowChanged: if (!activeWindow) dialog.visible = false onActiveWindowChanged: if (!activeWindow) dialog.visible = false
mainItem: Item { mainItem: Item {
id: mainItem
width: theme.defaultFont.mSize.width * 40 width: theme.defaultFont.mSize.width * 40
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8
// Consume all key events that are not processed by children // Consume all key events that are not processed by children
Keys.onPressed: event.accepted = true Keys.onPressed: event.accepted = true
@ -134,6 +135,7 @@ Item {
id: contentItem id: contentItem
clip: true clip: true
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
anchors { anchors {
top: titleBar.bottom top: titleBar.bottom
left: parent.left left: parent.left
@ -146,11 +148,11 @@ Item {
id: buttonItem id: buttonItem
height: childrenRect.height height: childrenRect.height
clip: true
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 8
} }
} }
} }

View File

@ -151,11 +151,6 @@ Item {
} }
sectionLabel.text = Sections.closestSection(y/listView.height) sectionLabel.text = Sections.closestSection(y/listView.height)
} }
Behavior on y {
NumberAnimation {
duration: 150
}
}
} }
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {
imagePath: "widgets/tooltip" imagePath: "widgets/tooltip"
@ -163,7 +158,7 @@ Item {
height: sectionLabel.paintedHeight + margins.top + margins.bottom height: sectionLabel.paintedHeight + margins.top + margins.bottom
Label { Label {
id: sectionLabel id: sectionLabel
font.pointSize: theme.defaultFont.pointSize*3 font.pointSize: theme.defaultFont.pointSize * 1.5
x: parent.margins.left x: parent.margins.left
y: parent.margins.top y: parent.margins.top
} }
@ -179,14 +174,7 @@ Item {
} }
} }
} }
/*Repeater {
id: sectionsRepeater
delegate: Label {
anchors.horizontalCenter: parent.horizontalCenter
text: Sections._sections[modelData]
y: Sections._sectionData[modelData].index*(listView.height/listView.model.count)
}
}*/
MouseArea { MouseArea {
id: dragArea id: dragArea
anchors.fill: parent anchors.fill: parent
@ -200,6 +188,7 @@ Item {
onPressed: { onPressed: {
mouse.accepted = true mouse.accepted = true
handle.y = mouse.y handle.y = mouse.y
fadeTimer.running = false
} }
onReleased: fadeTimer.restart() onReleased: fadeTimer.restart()
@ -231,8 +220,6 @@ Item {
if (listView.model.itemsRemoved) if (listView.model.itemsRemoved)
listView.model.itemsRemoved.connect(dirtyObserver); listView.model.itemsRemoved.connect(dirtyObserver);
sectionsRepeater.model = Sections._sections.length
} }
} }
} }

View File

@ -26,8 +26,8 @@ Item {
// Commmon API // Commmon API
property bool flat: true property bool flat: true
property bool checked: false property bool checked: defaultAction ? defaultAction.checked : false
property bool checkable: false property bool checkable: defaultAction ? defaultAction.checkable : false
property alias pressed: mouse.pressed property alias pressed: mouse.pressed
property alias text: label.text property alias text: label.text
property alias iconSource: icon.source property alias iconSource: icon.source
@ -35,11 +35,16 @@ Item {
signal clicked() signal clicked()
// Plasma extensiuons
property QtObject defaultAction
onFlatChanged: { onFlatChanged: {
delegate.opacity = 1 if (!flat) {
delegate.opacity = 1
}
} }
enabled: defaultAction==undefined||defaultAction.enabled
implicitWidth: { implicitWidth: {
if (label.paintedWidth == 0) { if (label.paintedWidth == 0) {
@ -54,46 +59,37 @@ Item {
// disabled buttons // disabled buttons
opacity: enabled ? 1.0 : 0.5 opacity: enabled ? 1.0 : 0.5
Keys.onSpacePressed: internal.pressButton() Keys.onSpacePressed: internal.userPressed = true
Keys.onReturnPressed: internal.pressButton() Keys.onReturnPressed: internal.userPressed = true
Keys.onReleased: { Keys.onReleased: {
internal.userPressed = false
if (event.key == Qt.Key_Space || if (event.key == Qt.Key_Space ||
event.key == Qt.Key_Return) event.key == Qt.Key_Return)
internal.releaseButton() internal.clickButton()
}
onActiveFocusChanged: {
if (activeFocus) {
shadow.state = "focus"
} else if (checked) {
shadow.state = "hidden"
} else {
shadow.state = "shadow"
}
} }
QtObject { QtObject {
id: internal id: internal
property bool userPressed: false property bool userPressed: false
function pressButton() function clickButton()
{ {
userPressed = true
}
function releaseButton()
{
userPressed = false
if (!button.enabled) { if (!button.enabled) {
return return
} }
if (button.checkable) { if (defaultAction && defaultAction.checkable) {
defaultAction.checked = !defaultAction.checked
} else if (button.checkable) {
button.checked = !button.checked button.checked = !button.checked
} }
button.clicked() button.clicked()
button.forceActiveFocus() button.forceActiveFocus()
if (defaultAction) {
defaultAction.trigger()
}
} }
} }
@ -142,10 +138,10 @@ Item {
Item { Item {
anchors.fill: parent anchors.fill: parent
property QtObject margins: QtObject { property QtObject margins: QtObject {
property int left: 16 property int left: 8
property int top: 16 property int top: 8
property int right: 16 property int right: 8
property int bottom: 16 property int bottom: 8
} }
RoundShadow { RoundShadow {
anchors.fill: parent anchors.fill: parent
@ -175,6 +171,10 @@ Item {
rightMargin: delegate.margins.right rightMargin: delegate.margins.right
bottomMargin: delegate.margins.bottom bottomMargin: delegate.margins.bottom
} }
scale: internal.userPressed ? 0.9 : 1
Behavior on scale {
PropertyAnimation { duration: 100 }
}
IconLoader { IconLoader {
id: icon id: icon
@ -184,6 +184,8 @@ Item {
left: label.text ? parent.left : undefined left: label.text ? parent.left : undefined
horizontalCenter: label.text ? undefined : parent.horizontalCenter horizontalCenter: label.text ? undefined : parent.horizontalCenter
} }
width: label.text ? implicitWidth : roundToStandardSize(parent.width)
height: width
} }
Text { Text {
@ -222,26 +224,9 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onPressed: internal.pressButton(); onPressed: internal.userPressed = true
onReleased: internal.userPressed = false
onReleased: internal.releaseButton(); onClicked: internal.clickButton()
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

@ -60,12 +60,7 @@ Item {
&& button.parent.exclusive && button.parent.exclusive
} }
function pressButton() function clickButton()
{
userPressed = true
}
function releaseButton()
{ {
userPressed = false userPressed = false
if (!button.enabled) { if (!button.enabled) {
@ -81,12 +76,13 @@ Item {
} }
} }
Keys.onSpacePressed: internal.pressButton() Keys.onSpacePressed: internal.userPressed = true
Keys.onReturnPressed: internal.pressButton() Keys.onReturnPressed: internal.userPressed = true
Keys.onReleased: { Keys.onReleased: {
internal.userPressed = false
if (event.key == Qt.Key_Space || if (event.key == Qt.Key_Space ||
event.key == Qt.Key_Return) event.key == Qt.Key_Return)
internal.releaseButton(); internal.clickButton();
} }
ButtonShadow { ButtonShadow {
@ -127,6 +123,10 @@ Item {
Item { Item {
id: buttonContent id: buttonContent
state: (internal.userPressed || checked) ? "pressed" : "normal" state: (internal.userPressed || checked) ? "pressed" : "normal"
scale: state == "pressed" ? 0.9 : 1
Behavior on scale {
PropertyAnimation { duration: 100 }
}
states: [ states: [
State { name: "normal" }, State { name: "normal" },
@ -206,8 +206,9 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onPressed: internal.pressButton() onPressed: internal.userPressed = true
onReleased: internal.releaseButton() onReleased: internal.userPressed = false
onCanceled: internal.releaseButton() onCanceled: internal.userPressed = false
onClicked: internal.clickButton()
} }
} }

View File

@ -82,14 +82,14 @@ Dialog {
QtObject { QtObject {
id: internal id: internal
function buttonWidth() { /*function buttonWidth() {
switch (buttonTexts.length) { switch (buttonTexts.length) {
case 0: return 0 case 0: return 0
case 1: return Math.round((800 - 3 * 4) / 2) case 1: return Math.round((800 - 3 * 4) / 2)
default: return (buttonContainer.width - (buttonTexts.length + 1) * default: return (buttonContainer.width - (buttonTexts.length + 1) *
4) / buttonTexts.length 4) / buttonTexts.length
} }
} }*/
function iconSource() { function iconSource() {
return root.titleIcon return root.titleIcon
@ -145,20 +145,13 @@ Dialog {
} }
} }
buttons: Item { buttons: Row {
id: buttonContainer id: buttonRow
LayoutMirroring.enabled: false LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true LayoutMirroring.childrenInherit: true
objectName: "buttonRow"
width: parent.width anchors.centerIn: parent
height: buttonTexts.length ? 48 + 2 * 2 : 0 spacing: 4
Row {
id: buttonRow
objectName: "buttonRow"
anchors.centerIn: parent
spacing: 4
}
} }
} }

View File

@ -112,8 +112,9 @@ Item {
} }
mainItem: Item { mainItem: Item {
id: mainItem
width: theme.defaultFont.mSize.width * 40 width: theme.defaultFont.mSize.width * 40
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8
// Consume all key events that are not processed by children // Consume all key events that are not processed by children
Keys.onPressed: event.accepted = true Keys.onPressed: event.accepted = true
@ -133,12 +134,15 @@ Item {
Item { Item {
id: contentItem id: contentItem
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
clip: true clip: true
anchors { anchors {
top: titleBar.bottom top: titleBar.bottom
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: buttonItem.top bottom: buttonItem.top
bottomMargin: 8
} }
} }
@ -146,15 +150,15 @@ Item {
id: buttonItem id: buttonItem
height: childrenRect.height height: childrenRect.height
clip: true
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 4
} }
} }
} }
Component.onCompleted: { Component.onCompleted: {
rootItem = Utils.rootObject() rootItem = Utils.rootObject()
} }

View File

@ -56,6 +56,23 @@ Item {
id: svgIcon id: svgIcon
} }
function roundToStandardSize(size)
{
if (size >= theme.enormousIconSize) {
return theme.enormousIconSize
} else if (size >= theme.hugeIconSize) {
return theme.hugeIconSize
} else if (size >= theme.largeIconSize) {
return theme.largeIconSize
} else if (size >= theme.mediumIconSize) {
return theme.mediumIconSize
} else if (size >= theme.smallMediumIconSize) {
return theme.smallMediumIconSize
} else {
return theme.smallIconSize
}
}
Loader { Loader {
id: imageLoader id: imageLoader
anchors.fill: parent anchors.fill: parent
@ -67,9 +84,10 @@ Item {
svg: svgIcon svg: svgIcon
elementId: root.source elementId: root.source
anchors.fill: parent anchors.fill: parent
smooth: true
} }
} }
Component { Component {
id: iconComponent id: iconComponent

View File

@ -121,17 +121,23 @@ Item {
} }
onInitialPageChanged: { onInitialPageChanged: {
if (!internal.completed) {
return
}
if (initialPage) { if (initialPage) {
if (depth == 0) if (depth == 0) {
push(initialPage, null, true) push(initialPage, null, true)
else if (depth == 1) } else if (depth == 1) {
replace(initialPage, null, true) replace(initialPage, null, true)
else } else {
console.log("Cannot update PageStack.initialPage") console.log("Cannot update PageStack.initialPage")
}
} }
} }
Component.onCompleted: { Component.onCompleted: {
internal.completed = true
if (initialPage && depth == 0) if (initialPage && depth == 0)
push(initialPage, null, true) push(initialPage, null, true)
} }
@ -142,6 +148,9 @@ Item {
// The number of ongoing transitions. // The number of ongoing transitions.
property int ongoingTransitionCount: 0 property int ongoingTransitionCount: 0
//FIXME: there should be a way to access to theh without storing it in an ugly way
property bool completed: false
// Sets the page status. // Sets the page status.
function setPageStatus(page, status) function setPageStatus(page, status)
{ {

View File

@ -23,7 +23,7 @@ import org.kde.plasma.core 0.1 as PlasmaCore
Item{ Item{
id: toolBar id: toolBar
width: parent.width width: parent.width
height: (tools && enabled) ? theme.defaultFont.mSize.height*2 + frameSvg.margins.top + frameSvg.margins.bottom : 0 height: (tools && enabled) ? tools.height + frameSvg.margins.top + frameSvg.margins.bottom : 0
visible: height > 0 visible: height > 0
Behavior on height { Behavior on height {
PropertyAnimation { PropertyAnimation {

View File

@ -26,8 +26,8 @@ Item {
// Commmon API // Commmon API
property bool flat: true property bool flat: true
property bool checked: false property bool checked: defaultAction ? defaultAction.checked : false
property bool checkable: false property bool checkable: defaultAction ? defaultAction.checkable : false
property alias pressed: mouse.pressed property alias pressed: mouse.pressed
property alias text: label.text property alias text: label.text
property alias iconSource: icon.source property alias iconSource: icon.source
@ -35,6 +35,11 @@ Item {
signal clicked() signal clicked()
// Plasma extensiuons
property QtObject defaultAction
enabled: defaultAction==undefined||defaultAction.enabled
onFlatChanged: { onFlatChanged: {
surface.opacity = 1 surface.opacity = 1
@ -54,12 +59,13 @@ Item {
// disabled buttons // disabled buttons
opacity: enabled ? 1.0 : 0.5 opacity: enabled ? 1.0 : 0.5
Keys.onSpacePressed: internal.pressButton() Keys.onSpacePressed: internal.userPressed = true
Keys.onReturnPressed: internal.pressButton() Keys.onReturnPressed: internal.userPressed = true
Keys.onReleased: { Keys.onReleased: {
internal.userPressed = false
if (event.key == Qt.Key_Space || if (event.key == Qt.Key_Space ||
event.key == Qt.Key_Return) event.key == Qt.Key_Return)
internal.releaseButton() internal.clickButton()
} }
onActiveFocusChanged: { onActiveFocusChanged: {
@ -76,24 +82,24 @@ Item {
id: internal id: internal
property bool userPressed: false property bool userPressed: false
function pressButton() function clickButton()
{ {
userPressed = true
}
function releaseButton()
{
userPressed = false
if (!button.enabled) { if (!button.enabled) {
return return
} }
if (button.checkable) { if (defaultAction && defaultAction.checkable) {
defaultAction.checked = !defaultAction.checked
} else if (button.checkable) {
button.checked = !button.checked button.checked = !button.checked
} }
button.clicked() button.clicked()
button.forceActiveFocus() button.forceActiveFocus()
if (defaultAction) {
defaultAction.trigger()
}
} }
} }
@ -112,7 +118,7 @@ Item {
//internal: if there is no hover status, don't paint on mouse over in touchscreens //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 opacity: (internal.userPressed || checked || !flat || (shadow.hasOverState && mouse.containsMouse)) ? 1 : 0
Behavior on opacity { Behavior on opacity {
PropertyAnimation { duration: 250 } PropertyAnimation { duration: 100 }
} }
} }
@ -124,6 +130,10 @@ Item {
rightMargin: surface.margins.right rightMargin: surface.margins.right
bottomMargin: surface.margins.bottom bottomMargin: surface.margins.bottom
} }
scale: internal.userPressed ? 0.9 : 1
Behavior on scale {
PropertyAnimation { duration: 250 }
}
IconLoader { IconLoader {
id: icon id: icon
@ -171,9 +181,9 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onPressed: internal.pressButton(); onPressed: internal.userPressed = true
onReleased: internal.userPressed = false
onReleased: internal.releaseButton(); onClicked: internal.clickButton()
onEntered: { onEntered: {
if (!flat) { if (!flat) {