refactor:move AddingVisuals to LatteComponents

pull/6/head
Michail Vourlakos 6 years ago
parent a8a19bb550
commit cda688c2a5

@ -28,6 +28,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.latte 0.2 as Latte
import org.kde.latte.components 1.0 as LatteComponents
import "colorizer" as Colorizer
import "communicator" as Communicator
@ -730,7 +731,15 @@ Item {
Loader {
anchors.fill: parent
active: isLattePlasmoid
sourceComponent: TasksArea{}
sourceComponent: LatteComponents.AddingArea{
anchors.fill: parent
radius: root.iconSize/10
opacity: root.addLaunchersMessage ? 1 : 0
backgroundOpacity: 0.75
duration: root.durationTime
title: i18n("Tasks Area")
}
}
MouseArea{

@ -29,6 +29,7 @@ import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.plasmoid 2.0
import org.kde.latte 0.2 as Latte
import org.kde.latte.components 1.0 as LatteComponents
import "applet" as Applet
import "colorizer" as Colorizer
@ -1772,7 +1773,7 @@ Item {
opacity: 0
z:1500
AddWidgetVisual{
LatteComponents.AddItem{
anchors.fill: parent
}
}

@ -1,6 +1,5 @@
/*
* Copyright 2016 Smith AR <audoban@openmailbox.org>
* Michail Vourlakos <mvourlakos@gmail.com>
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
@ -20,10 +19,14 @@
import QtQuick 2.1
import "../code/ColorizerTools.js" as ColorizerTools
import org.kde.plasma.plasmoid 2.0
import "code/ColorizerTools.js" as ColorizerTools
Item{
id: newDroppedLauncherVisual
id: addItem
property real backgroundOpacity: 1
Rectangle{
width: Math.min(parent.width, parent.height)
@ -32,7 +35,7 @@ Item{
radius: Math.max(width,height)/2
color: theme.backgroundColor
color: Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, backgroundOpacity)
border.width: 1
border.color: outlineColor

@ -23,14 +23,11 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import "../" as RootElements
import "code/ColorizerTools.js" as ColorizerTools
Rectangle{
anchors.fill: parent
radius: root.iconSize/10
opacity: root.addLaunchersMessage ? 1 : 0
color: Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, 0.75)
id: addingArea
color: Qt.rgba(theme.backgroundColor.r, theme.backgroundColor.g, theme.backgroundColor.b, backgroundOpacity)
border.width: 1
border.color: outlineColor
@ -44,8 +41,13 @@ Rectangle{
}
}
property real backgroundOpacity: 0.75
property real duration: 2
property string title: ""
Behavior on opacity{
NumberAnimation { duration: 2*root.durationTime*appletItem.animationTime }
NumberAnimation { duration: 2*addingArea.duration*appletItem.animationTime }
}
PlasmaExtras.Heading {
@ -53,7 +55,7 @@ Rectangle{
width: parent.width
height: parent.height * 0.4
text: i18n("Tasks Area")
text: title
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
@ -62,7 +64,7 @@ Rectangle{
color: theme.textColor
rotation: {
if (root.isHorizontal)
if (plasmoid.formFactor === PlasmaCore.Types.Horizontal)
return 0;
else if (plasmoid.location === PlasmaCore.Types.LeftEdge)
return -90;
@ -71,7 +73,7 @@ Rectangle{
}
}
RootElements.AddWidgetVisual {
AddItem {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: heading.bottom
anchors.topMargin: units.smallSpacing

@ -0,0 +1,48 @@
/*
* Copyright 2018 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/>.
*/
function colorBrightness(color) {
return colorBrightnessFromRGB(color.r * 255, color.g * 255, color.b * 255)
}
// formula for brightness according to:
// https://www.w3.org/TR/AERT/#color-contrast
function colorBrightnessFromRGB(r, g, b) {
return (r * 299 + g * 587 + b * 114) / 1000
}
function colorLuminas(color) {
return colorLuminasFromRGB(color.r, color.g, color.b)
}
// formula for luminance according to:
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
function colorLuminasFromRGB(r, g, b) {
var rS = (r <= 0.03928) ? ( r / 12.92) : Math.pow( ((r + 0.055) / 1.055), 2.4 );
var gS = (g <= 0.03928) ? ( g / 12.92) : Math.pow( ((g + 0.055) / 1.055), 2.4 );
var bS = (b <= 0.03928) ? ( b / 12.92) : Math.pow( ((b + 0.055) / 1.055), 2.4 );
return 0.2126*rS + 0.7152*gS + 0.0722*bS;
}
function normalize(min, max, per) {
return min + ((max-min) * per);
}

@ -1,5 +1,7 @@
module org.kde.latte.components
AddItem 1.0 AddItem.qml
AddingArea 1.0 AddingArea.qml
BadgeText 1.0 BadgeText.qml
CheckBox 1.0 CheckBox.qml
CheckBoxesColumn 1.0 CheckBoxesColumn.qml

@ -32,6 +32,7 @@ import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet
import org.kde.activities 0.1 as Activities
import org.kde.latte 0.2 as Latte
import org.kde.latte.components 1.0 as LatteComponents
import "previews" as Previews
import "task" as Task
@ -1310,19 +1311,16 @@ Item {
flickable: scrollableList
} // ScrollEdgeShadows
Task.VisualAddItem{
LatteComponents.AddingArea {
id: newDroppedLauncherVisual
width: !root.vertical ? length : thickness
height: !root.vertical ? thickness : length
anchors.centerIn: mouseHandler
anchors.fill: mouseHandler
visible: backgroundOpacity > 0
radius: root.iconSize/10
backgroundOpacity: root.dropNewLauncher && mouseHandler.onlyLaunchers && (root.dragSource == null)? 0.75 : 0
duration: root.durationTime
readonly property int length: root.iconSize + root.lengthMargins
readonly property int thickness: root.iconSize + root.thickMargins
visible: opacity == 0 ? false : true
opacity: root.dropNewLauncher && mouseHandler.onlyLaunchers && (root.dragSource == null)? 0.7 : 0
title: i18n("Tasks Area")
}
}
//// helpers

@ -28,7 +28,9 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlAddons
import org.kde.latte 0.2 as Latte
import org.kde.latte.components 1.0 as LatteComponents
import "animations" as TaskAnimations
@ -559,8 +561,10 @@ Item{
}
}
VisualAddItem{
Loader {
id: dropFilesVisual
active: applyOpacity>0
width: !root.vertical ? length : thickness
height: !root.vertical ? thickness : length
anchors.centerIn: parent
@ -568,11 +572,13 @@ Item{
readonly property int length: root.iconSize + root.lengthMargins
readonly property int thickness: root.iconSize + root.thickMargins
//anchors.fill: iconGraphic
readonly property real applyOpacity: root.dropNewLauncher && !mouseHandler.onlyLaunchers
&& (root.dragSource == null) && (mouseHandler.hoveredItem === taskItem) ? 0.7 : 0
visible: opacity == 0 ? false : true
opacity: root.dropNewLauncher && !mouseHandler.onlyLaunchers
&& (root.dragSource == null) && (mouseHandler.hoveredItem === taskItem) ? 0.7 : 0
sourceComponent: LatteComponents.AddItem {
anchors.fill: parent
backgroundOpacity: dropFilesVisual.applyOpacity
}
}
Component.onDestruction: {

@ -1,54 +0,0 @@
/*
* 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/>.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "../../code/ColorizerTools.js" as ColorizerTools
Item{
Rectangle{
width: Math.min(parent.width, parent.height)
height: width
anchors.centerIn: parent
radius: Math.max(width,height)/2
color: theme.backgroundColor // "#aa222222"
border.width: 1
border.color: outlineColor // "#ff656565"
property int crossSize: Math.min(0.4*parent.width, 0.4 * parent.height)
readonly property color outlineColorBase: theme.backgroundColor
readonly property real outlineColorBaseBrightness: ColorizerTools.colorBrightness(outlineColorBase)
readonly property color outlineColor: {
if (outlineColorBaseBrightness > 127.5) {
return Qt.darker(outlineColorBase, 1.5);
} else {
return Qt.lighter(outlineColorBase, 2.2);
}
}
Rectangle{width: parent.crossSize; height: 4; anchors.centerIn: parent; color: theme.highlightColor}
Rectangle{width: 4; height: parent.crossSize; anchors.centerIn: parent; color: theme.highlightColor}
}
}
Loading…
Cancel
Save