plasma-framework/declarativeimports/plasmacomponents/platformcomponents/touch/EditBubble.qml
Sebastian Kügler 9dad1d2d14 Move edit bubble into its own file
Also make the sizing fully dynamix, just set editBubble.iconSize, this
works fine with minimal 24px. Below that value, it will be too hard to
hit anyway.
2011-11-24 23:02:32 +01:00

107 lines
4.1 KiB
QML

/*
* Copyright 2011 by Sebastian Kügler <sebas@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 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
import org.kde.qtextracomponents 0.1
PlasmaCore.FrameSvgItem {
id: editBubble
objectName: "editBubble"
property int iconSize: 32;
imagePath: "dialogs/background"
width: (iconSize*2) + iconSize
height: iconSize*2
z: 1
anchors { top: parent.bottom; right: parent.right; topMargin: -(iconSize/4); }
state: (textInput.activeFocus && (textInput.selectedText != "" || textInput.canPaste)) ? "expanded" : "collapsed";
Row {
id: buttonRow
spacing: 4
anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter; margins: 8; }
height: editBubble.iconSize
QIconItem {
id: pasteIcon
icon: QIcon("edit-paste")
width: editBubble.iconSize
height: editBubble.iconSize
enabled: textInput.canPaste
MouseArea {
anchors.fill: parent;
onClicked: textField.paste();
onPressed: PropertyAnimation { target: pasteIcon; properties: "scale";
from: 1.0; to: 0.9;
duration: 175; easing.type: Easing.OutExpo; }
onReleased: PropertyAnimation { target: pasteIcon; properties: "scale";
from: 0.9; to: 1.0;
duration: 175; easing.type: Easing.OutExpo; }
}
}
QIconItem {
id: copyIcon
icon: QIcon("edit-copy")
width: editBubble.iconSize
height: editBubble.iconSize
enabled: textInput.selectedText != ""
MouseArea {
anchors.fill: parent;
onClicked: textField.copy();
onPressed: PropertyAnimation { target: copyIcon; properties: "scale";
from: 1.0; to: 0.9;
duration: 175; easing.type: Easing.OutExpo; }
onReleased: PropertyAnimation { target: copyIcon; properties: "scale";
from: 0.9; to: 1.0;
duration: 175; easing.type: Easing.OutExpo; }
}
}
}
states: [
State {
id: expanded
name: "expanded";
PropertyChanges { target: editBubble; opacity: 1.0; scale: 1.0 }
},
State {
id: collapsed
name: "collapsed";
PropertyChanges { target: editBubble; opacity: 0; scale: 0.9 }
}
]
transitions: [
Transition {
from: "collapsed"; to: "expanded"
ParallelAnimation {
PropertyAnimation { properties: "opacity"; duration: 175; easing.type: Easing.InExpo; }
PropertyAnimation { properties: "scale"; duration: 175; easing.type: Easing.InExpo; }
}
},
Transition {
from: "expanded"; to: "collapsed"
ParallelAnimation {
PropertyAnimation { properties: "opacity"; duration: 175; easing.type: Easing.OutExpo; }
PropertyAnimation { properties: "scale"; duration: 100; easing.type: Easing.OutExpo; }
}
}
]
}