You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
297 lines
10 KiB
QML
297 lines
10 KiB
QML
8 years ago
|
/*
|
||
|
* Copyright 2016 Smith AR <audoban@openmailbox.org>
|
||
|
* Michail Vourlakos <mvourlakos@gmail.com>
|
||
|
*
|
||
|
* This file is part of Latte-Dock
|
||
|
*
|
||
|
* Latte-Dock is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU General Public License as
|
||
|
* published by the Free Software Foundation; either version 2 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
|
* Latte-Dock 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 General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
8 years ago
|
import QtQuick 2.1
|
||
|
|
||
8 years ago
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||
|
import QtGraphicalEffects 1.0
|
||
|
|
||
8 years ago
|
import org.kde.latte 0.1 as Latte
|
||
|
|
||
8 years ago
|
Image{
|
||
8 years ago
|
id: editVisual
|
||
8 years ago
|
width: root.isHorizontal ? editLength : visibilityManager.thicknessNormalOriginal
|
||
|
height: root.isVertical ? editLength : visibilityManager.thicknessNormalOriginal
|
||
8 years ago
|
|
||
8 years ago
|
fillMode: Image.Tile
|
||
8 years ago
|
source: !dock || dock.session===Latte.Dock.DefaultSession ? "../icons/blueprint.jpg":"../icons/purpleprint.jpg"
|
||
8 years ago
|
opacity: 0
|
||
|
|
||
|
property int speed: root.durationTime*4*units.longDuration
|
||
8 years ago
|
property int thickness: visibilityManager.thicknessNormalOriginal + root.editShadow
|
||
|
property int rootThickness: visibilityManager.thicknessZoomOriginal + root.editShadow
|
||
8 years ago
|
property int editLength: root.isHorizontal ? (root.behaveAsPlasmaPanel ? root.width - root.maxIconSize/4 : root.maxLength) :
|
||
|
(root.behaveAsPlasmaPanel ? root.height - root.maxIconSize/4 : root.maxLength)
|
||
8 years ago
|
|
||
|
property bool animationSent: false
|
||
|
property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge)
|
||
|
property bool editAnimationEnded: false
|
||
|
|
||
8 years ago
|
property rect efGeometry
|
||
|
|
||
8 years ago
|
layer.enabled: true
|
||
|
layer.effect: DropShadow {
|
||
8 years ago
|
radius: root.editShadow
|
||
8 years ago
|
samples: 2 * radius
|
||
|
color: "#ee080808"
|
||
|
}
|
||
|
|
||
8 years ago
|
/*Behavior on width {
|
||
|
NumberAnimation { duration: 300 }
|
||
|
enabled: root.isHorizontal
|
||
|
}
|
||
|
|
||
|
Behavior on height {
|
||
|
NumberAnimation { duration: 300 }
|
||
|
enabled: root.isVertical
|
||
|
}*/
|
||
|
|
||
8 years ago
|
Connections{
|
||
|
target: plasmoid
|
||
|
onLocationChanged: initializeEditPosition();
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
Connections{
|
||
|
target: root
|
||
|
onIconSizeChanged: initializeEditPosition();
|
||
8 years ago
|
onPanelAlignmentChanged: initializeEditPosition();
|
||
8 years ago
|
onOffsetChanged: initializeEditPosition();
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
onRootThicknessChanged: {
|
||
|
initializeEditPosition();
|
||
|
}
|
||
|
|
||
8 years ago
|
onEditAnimationEndedChanged: {
|
||
8 years ago
|
if (!dock) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
8 years ago
|
if (editAnimationEnded && !root.behaveAsPlasmaPanel) {
|
||
8 years ago
|
dock.shadow = root.editShadow;
|
||
8 years ago
|
} else {
|
||
8 years ago
|
dock.shadow = root.panelShadow;
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
onXChanged: updateEffectsArea();
|
||
|
onYChanged: updateEffectsArea();
|
||
|
|
||
8 years ago
|
onWidthChanged: {
|
||
|
if (root.isHorizontal) {
|
||
|
initializeEditPosition();
|
||
|
}
|
||
8 years ago
|
|
||
|
updateEffectsArea();
|
||
8 years ago
|
}
|
||
|
|
||
|
onHeightChanged: {
|
||
|
if (root.isVertical) {
|
||
|
initializeEditPosition();
|
||
|
}
|
||
8 years ago
|
|
||
|
updateEffectsArea();
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
function updateEffectsArea(){
|
||
|
if (!dock || state !== "edit" || !editAnimationEnded)
|
||
|
return;
|
||
|
|
||
|
var rootGeometry = mapToItem(root, 0, 0);
|
||
|
|
||
|
efGeometry.x = rootGeometry.x;
|
||
|
efGeometry.y = rootGeometry.y;
|
||
|
efGeometry.width = width;
|
||
|
efGeometry.height = height;
|
||
|
|
||
|
dock.effectsArea = efGeometry;
|
||
|
}
|
||
|
|
||
|
|
||
8 years ago
|
function initializeNormalPosition() {
|
||
8 years ago
|
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
|
||
|
y = rootThickness;
|
||
|
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
|
||
|
x = rootThickness;
|
||
|
} else if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
|
||
8 years ago
|
x = -editVisual.thickness;
|
||
8 years ago
|
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
|
||
8 years ago
|
y = -editVisual.thickness;
|
||
|
}
|
||
8 years ago
|
|
||
|
if (root.isHorizontal) {
|
||
|
if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
|
||
8 years ago
|
x = root.width/2 - editVisual.editLength/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Left) {
|
||
8 years ago
|
x = root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||
8 years ago
|
x = root.width/2 - editVisual.editLength/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Right) {
|
||
8 years ago
|
x = root.width - editVisual.editLength - root.offset;
|
||
8 years ago
|
}
|
||
|
} else if (root.isVertical) {
|
||
|
if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
|
||
8 years ago
|
y = root.height/2 - editVisual.editLength/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Top) {
|
||
8 years ago
|
y = root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||
8 years ago
|
y = root.height/2 - editVisual.editLength/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Bottom) {
|
||
8 years ago
|
y = root.height - editVisual.editLength - root.offset;
|
||
8 years ago
|
}
|
||
|
}
|
||
8 years ago
|
}
|
||
|
|
||
|
function initializeEditPosition() {
|
||
|
if (root.editMode) {
|
||
8 years ago
|
if (plasmoid.location === PlasmaCore.Types.LeftEdge){
|
||
8 years ago
|
x = 0;
|
||
8 years ago
|
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
|
||
8 years ago
|
y = 0;
|
||
8 years ago
|
} else if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
|
||
8 years ago
|
y = rootThickness - thickness;
|
||
8 years ago
|
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
|
||
8 years ago
|
x = rootThickness - thickness;
|
||
8 years ago
|
}
|
||
|
|
||
|
if (root.isHorizontal) {
|
||
|
if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
|
||
8 years ago
|
x = root.width/2 - editVisual.width/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Left) {
|
||
8 years ago
|
x = root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||
8 years ago
|
x = root.width/2 - editVisual.width/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Right) {
|
||
8 years ago
|
x = root.width - editVisual.width - root.offset;
|
||
8 years ago
|
}
|
||
|
} else if (root.isVertical) {
|
||
|
if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
|
||
8 years ago
|
y = root.height/2 - editVisual.height/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Top) {
|
||
8 years ago
|
y = root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||
8 years ago
|
y = root.height/2 - editVisual.height/2 + root.offset;
|
||
8 years ago
|
} else if (root.panelAlignment === Latte.Dock.Bottom) {
|
||
8 years ago
|
y = root.height - editVisual.height - root.offset;
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//////////// States ////////////////////
|
||
|
|
||
|
states: [
|
||
|
State{
|
||
|
name: "*"
|
||
|
when: !root.editMode
|
||
|
},
|
||
|
|
||
|
State{
|
||
|
name: "edit"
|
||
|
when: root.editMode
|
||
|
}
|
||
|
]
|
||
|
|
||
|
transitions: [
|
||
|
Transition{
|
||
|
id: editTransition
|
||
|
from: "*"
|
||
|
to: "edit"
|
||
|
|
||
|
SequentialAnimation{
|
||
|
ScriptAction{
|
||
|
script:{
|
||
|
editVisual.opacity = 0
|
||
8 years ago
|
editVisual.editAnimationEnded = false;
|
||
8 years ago
|
|
||
|
initializeNormalPosition();
|
||
|
|
||
|
if(!animationSent) {
|
||
|
animationSent = true;
|
||
8 years ago
|
root.slotAnimationsNeedLength(1);
|
||
8 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ParallelAnimation{
|
||
|
PropertyAnimation {
|
||
|
target: editVisual
|
||
|
property: "opacity"
|
||
8 years ago
|
to: root.behaveAsPlasmaPanel && dock.session===Latte.Dock.DefaultSession ? 0.3 : 0.6
|
||
8 years ago
|
duration: editVisual.speed / 2
|
||
|
easing.type: Easing.OutQuad
|
||
|
}
|
||
|
|
||
|
PropertyAnimation {
|
||
|
target: editVisual
|
||
|
property: root.isHorizontal ? "y" : "x"
|
||
8 years ago
|
to: editVisual.farEdge ? editVisual.rootThickness - editVisual.thickness : 0
|
||
8 years ago
|
duration: editVisual.speed
|
||
|
easing.type: Easing.OutBounce
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ScriptAction{
|
||
|
script:{
|
||
|
editVisual.editAnimationEnded = true;
|
||
8 years ago
|
updateEffectsArea();
|
||
8 years ago
|
visibilityManager.updateMaskArea();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
Transition{
|
||
|
from: "edit"
|
||
|
to: "*"
|
||
|
SequentialAnimation{
|
||
|
ParallelAnimation{
|
||
|
PropertyAnimation {
|
||
|
target: editVisual
|
||
|
property: root.isHorizontal ? "y" : "x"
|
||
|
to: editVisual.farEdge ? editVisual.rootThickness : -editVisual.thickness
|
||
|
duration: editVisual.speed
|
||
|
easing.type: Easing.OutBounce
|
||
|
}
|
||
|
PropertyAnimation {
|
||
|
target: editVisual
|
||
|
property: "opacity"
|
||
|
to: 0
|
||
|
duration: editVisual.speed
|
||
|
easing.type: Easing.OutQuad
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ScriptAction{
|
||
|
script:{
|
||
|
editVisual.editAnimationEnded = false;
|
||
|
if (editVisual.animationSent) {
|
||
8 years ago
|
root.slotAnimationsNeedLength(-1);
|
||
8 years ago
|
editVisual.animationSent = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
]
|
||
8 years ago
|
}
|