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.
258 lines
11 KiB
QML
258 lines
11 KiB
QML
8 years ago
|
/*
|
||
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.0
|
||
|
import QtQuick.Layouts 1.1
|
||
|
import QtGraphicalEffects 1.0
|
||
|
|
||
6 years ago
|
import org.kde.plasma.plasmoid 2.0
|
||
8 years ago
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||
|
|
||
6 years ago
|
import org.kde.latte 0.2 as Latte
|
||
7 years ago
|
|
||
6 years ago
|
import "../code/ColorizerTools.js" as ColorizerTools
|
||
6 years ago
|
|
||
8 years ago
|
Item{
|
||
6 years ago
|
id: indicatorRoot
|
||
8 years ago
|
|
||
6 years ago
|
property int size: 0.08 * rootItem.iconSize
|
||
|
|
||
|
property real textColorBrightness: ColorizerTools.colorBrightness(theme.textColor)
|
||
8 years ago
|
|
||
|
property color isActiveColor: theme.buttonFocusColor
|
||
6 years ago
|
property color minimizedColor: {
|
||
|
if (rootItem.multiColorEnabled) {
|
||
|
return (textColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7));
|
||
|
}
|
||
|
|
||
|
return isActiveColor;
|
||
|
}
|
||
|
property color notActiveColor: rootItem.isMinimized ? minimizedColor : isActiveColor
|
||
|
|
||
|
property Item rootItem: parent
|
||
8 years ago
|
|
||
8 years ago
|
/*Rectangle{
|
||
8 years ago
|
anchors.fill: parent
|
||
|
border.width: 1
|
||
|
border.color: "yellow"
|
||
|
color: "transparent"
|
||
|
opacity:0.6
|
||
|
}*/
|
||
6 years ago
|
|
||
8 years ago
|
Item{
|
||
6 years ago
|
id: mainIndicatorElement
|
||
8 years ago
|
|
||
|
width: flowItem.width
|
||
|
height: flowItem.height
|
||
|
|
||
|
Flow{
|
||
|
id: flowItem
|
||
6 years ago
|
flow: plasmoid.formFactor === PlasmaCore.Types.Vertical ? Flow.TopToBottom : Flow.LeftToRight
|
||
8 years ago
|
|
||
7 years ago
|
Latte.GlowPoint{
|
||
8 years ago
|
id:firstPoint
|
||
|
visible: ( !IsLauncher ) ? true: false
|
||
|
|
||
6 years ago
|
basicColor: rootItem.isActive || (rootItem.isGroup && rootItem.hasShown) ? indicatorRoot.isActiveColor : indicatorRoot.notActiveColor
|
||
8 years ago
|
|
||
6 years ago
|
size: indicatorRoot.size
|
||
|
glow3D: rootItem.glow3D
|
||
|
animation: Math.max(1.65*3*units.longDuration,rootItem.durationTime*3*units.longDuration)
|
||
7 years ago
|
location: plasmoid.location
|
||
6 years ago
|
glowOpacity: rootItem.glowOpacity
|
||
|
contrastColor: rootItem.shadowColor
|
||
|
attentionColor: theme.negativeTextColor
|
||
7 years ago
|
|
||
8 years ago
|
roundCorners: true
|
||
6 years ago
|
showAttention: rootItem.inAttention
|
||
7 years ago
|
showGlow: {
|
||
6 years ago
|
if (rootItem.glowEnabled && (rootItem.glowOption === Latte.Types.GlowAll || showAttention ))
|
||
7 years ago
|
return true;
|
||
6 years ago
|
else if (rootItem.glowEnabled && rootItem.glowOption === Latte.Types.GlowOnlyOnActive && rootItem.hasActive)
|
||
7 years ago
|
return true;
|
||
|
else
|
||
|
return false;
|
||
|
}
|
||
6 years ago
|
showBorder: rootItem.glowEnabled && rootItem.glow3D
|
||
8 years ago
|
|
||
6 years ago
|
property int stateWidth: rootItem.isGroup ? indicatorRoot.width - secondPoint.width : indicatorRoot.width - spacer.width
|
||
|
property int stateHeight: rootItem.isGroup ? indicatorRoot.height - secondPoint.height : indicatorRoot.width - spacer.height
|
||
8 years ago
|
|
||
6 years ago
|
property int animationTime: rootItem.durationTime* (0.7*units.longDuration)
|
||
8 years ago
|
|
||
6 years ago
|
property bool isActive: rootItem.hasActive || rootItem.isActive
|
||
8 years ago
|
|
||
6 years ago
|
property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
|
||
8 years ago
|
|
||
6 years ago
|
property real scaleFactor: rootItem.scaleFactor
|
||
8 years ago
|
|
||
|
function updateInitialSizes(){
|
||
6 years ago
|
if(indicatorRoot){
|
||
8 years ago
|
if(vertical)
|
||
6 years ago
|
width = indicatorRoot.size;
|
||
8 years ago
|
else
|
||
6 years ago
|
height = indicatorRoot.size;
|
||
8 years ago
|
|
||
6 years ago
|
if(vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
8 years ago
|
height = stateHeight;
|
||
|
else
|
||
6 years ago
|
height = indicatorRoot.size;
|
||
8 years ago
|
|
||
6 years ago
|
if(!vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
8 years ago
|
width = stateWidth;
|
||
|
else
|
||
6 years ago
|
width = indicatorRoot.size;
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
onIsActiveChanged: {
|
||
6 years ago
|
if (rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
8 years ago
|
activeAndReverseAnimation.start();
|
||
|
}
|
||
|
|
||
|
onScaleFactorChanged: {
|
||
6 years ago
|
if(!activeAndReverseAnimation.running && !vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator){
|
||
8 years ago
|
width = stateWidth;
|
||
|
}
|
||
6 years ago
|
else if (!activeAndReverseAnimation.running && vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator){
|
||
8 years ago
|
height = stateHeight;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onStateWidthChanged:{
|
||
6 years ago
|
if(!activeAndReverseAnimation.running && !vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
8 years ago
|
width = stateWidth;
|
||
|
}
|
||
|
|
||
|
onStateHeightChanged:{
|
||
6 years ago
|
if(!activeAndReverseAnimation.running && vertical && isActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
8 years ago
|
height = stateHeight;
|
||
|
}
|
||
|
|
||
|
onVerticalChanged: updateInitialSizes();
|
||
|
|
||
|
Component.onCompleted: {
|
||
|
updateInitialSizes();
|
||
|
|
||
6 years ago
|
rootItem.onIconSizeChanged.connect(updateInitialSizes);
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
Component.onDestruction: {
|
||
6 years ago
|
rootItem.onIconSizeChanged.disconnect(updateInitialSizes);
|
||
7 years ago
|
}
|
||
|
|
||
8 years ago
|
NumberAnimation{
|
||
|
id: activeAndReverseAnimation
|
||
|
target: firstPoint
|
||
6 years ago
|
property: plasmoid.formFactor === PlasmaCore.Types.Vertical ? "height" : "width"
|
||
|
to: rootItem.hasActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator
|
||
|
? (plasmoid.formFactor === PlasmaCore.Types.Vertical ? firstPoint.stateHeight : firstPoint.stateWidth) : indicatorRoot.size
|
||
8 years ago
|
duration: firstPoint.animationTime
|
||
|
easing.type: Easing.InQuad
|
||
|
|
||
|
onStopped: firstPoint.updateInitialSizes()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Item{
|
||
|
id:spacer
|
||
6 years ago
|
width: secondPoint.visible ? 0.5*indicatorRoot.size : 0
|
||
|
height: secondPoint.visible ? 0.5*indicatorRoot.size : 0
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
Latte.GlowPoint{
|
||
8 years ago
|
id:secondPoint
|
||
6 years ago
|
width: visible ? indicatorRoot.size : 0
|
||
8 years ago
|
height: width
|
||
|
|
||
6 years ago
|
size: indicatorRoot.size
|
||
|
glow3D: rootItem.glow3D
|
||
|
animation: Math.max(1.65*3*units.longDuration,rootItem.durationTime*3*units.longDuration)
|
||
7 years ago
|
location: plasmoid.location
|
||
6 years ago
|
glowOpacity: rootItem.glowOpacity
|
||
|
contrastColor: rootItem.shadowColor
|
||
|
showBorder: rootItem.glowEnabled && rootItem.glow3D
|
||
7 years ago
|
|
||
6 years ago
|
basicColor: state2Color
|
||
8 years ago
|
roundCorners: true
|
||
6 years ago
|
showGlow: rootItem.glowEnabled && rootItem.glowOption === Latte.Types.GlowAll
|
||
|
visible: ( rootItem.isGroup && ((rootItem.dotsOnActive && rootItem.activeIndicatorType === Latte.Types.LineIndicator)
|
||
|
|| rootItem.activeIndicatorType === Latte.Types.DotIndicator
|
||
|
|| !rootItem.hasActive) )? true: false
|
||
8 years ago
|
|
||
|
//when there is no active window
|
||
6 years ago
|
property color state1Color: rootItem.hasShown ? indicatorRoot.isActiveColor : indicatorRoot.minimizedColor
|
||
8 years ago
|
//when there is active window
|
||
6 years ago
|
property color state2Color: rootItem.hasMinimized ? indicatorRoot.minimizedColor : indicatorRoot.isActiveColor
|
||
8 years ago
|
}
|
||
|
}
|
||
6 years ago
|
|
||
|
states: [
|
||
|
State {
|
||
|
name: "left"
|
||
6 years ago
|
when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !rootItem.reversedEnabled) ||
|
||
|
(plasmoid.location === PlasmaCore.Types.RightEdge && rootItem.reversedEnabled))
|
||
6 years ago
|
|
||
|
AnchorChanges {
|
||
|
target: mainIndicatorElement
|
||
|
anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined;
|
||
|
top:undefined; bottom:undefined; left:parent.left; right:undefined;}
|
||
|
}
|
||
|
},
|
||
|
State {
|
||
|
name: "bottom"
|
||
6 years ago
|
when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !rootItem.reversedEnabled) ||
|
||
|
(plasmoid.location === PlasmaCore.Types.TopEdge && rootItem.reversedEnabled))
|
||
6 years ago
|
|
||
|
AnchorChanges {
|
||
|
target: mainIndicatorElement
|
||
|
anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter;
|
||
|
top:undefined; bottom:parent.bottom; left:undefined; right:undefined;}
|
||
|
}
|
||
|
},
|
||
|
State {
|
||
|
name: "top"
|
||
6 years ago
|
when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !rootItem.reversedEnabled) ||
|
||
|
(plasmoid.location === PlasmaCore.Types.BottomEdge && rootItem.reversedEnabled))
|
||
6 years ago
|
|
||
|
AnchorChanges {
|
||
|
target: mainIndicatorElement
|
||
|
anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter;
|
||
|
top:parent.top; bottom:undefined; left:undefined; right:undefined;}
|
||
|
}
|
||
|
},
|
||
|
State {
|
||
|
name: "right"
|
||
6 years ago
|
when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !rootItem.reversedEnabled) ||
|
||
|
(plasmoid.location === PlasmaCore.Types.LeftEdge && rootItem.reversedEnabled))
|
||
6 years ago
|
|
||
|
AnchorChanges {
|
||
|
target: mainIndicatorElement
|
||
|
anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined;
|
||
|
top:undefined; bottom:undefined; left:undefined; right:parent.right;}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
8 years ago
|
}
|
||
|
}// number of windows indicator
|
||
|
|