From 5766fcc9cd375966d31618eb082d0b1f6b5b0475 Mon Sep 17 00:00:00 2001 From: heena mahour Date: Tue, 13 Aug 2013 12:53:44 +0000 Subject: [PATCH 1/2] ehh, not be pushed --- .../desktop/contents/views/Desktop.qml | 140 ++++++++++++++---- 1 file changed, 108 insertions(+), 32 deletions(-) diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index c5bff200e..c667bcc62 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -1,43 +1,119 @@ /* - * Copyright 2012 Marco Martin + * Copyright 2013 Heena Mahour * - * This program 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. + * This program 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. * - * 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. + * 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 General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ - import QtQuick 2.0 -//import org.kde.plasma 2.0 - import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as Components +import org.kde.qtextracomponents 2.0 +import org.kde.dirmodel 2.0 - -Rectangle { - id: root - color: "black" - width: 1024 - height: 768 - - property Item containment - - onContainmentChanged: { - print("New Containment: " + containment) - //containment.parent = root - containment.visible = true - containment.anchors.fill = root +Item { + id:root + + property int minimumWidth:formFactor == Horizontal ? height : 1 + property int minimumHeight:formFactor == Vertical ? width : 1 + property int formFactor: plasmoid.formFactor + property bool constrained:formFactor==Vertical||formFactor==Horizontal + + DirModel { + id:dirModel + url: "trash:/" + } + + Connections { + target: plasmoid + onFormFactorChanged: { + root.formFactor = plasmoid.formFactor + if(root.formFactor==Planar || root.formFactor == MediaCenter ) + { + minimumWidth=root.width/3.5 + minimumHeight=root.height/3.5 + } + } } - Component.onCompleted: { - print("View QML loaded") + function action_open() { + plasmoid.openUrl("trash:/"); } -} + + function action_empty() { + emptyDialog=emptyDialogComponent.createObject(root); + emptyDialog.open(); + } + + Component.onCompleted: { + plasmoid.setBackgroundHints( 0 ) + plasmoid.action_open = function() { + plasmoid.openUrl("trash:/"); + } + plasmoid.setAction("open", i18n("Open"),"document-open"); + plasmoid.action_empty=function() { + emptyDialog=emptyDialogComponent.createObject(root); + emptyDialog.open(); + } + plasmoid.setAction("empty",i18n("Empty"),"trash-empty"); + plasmoid.popupIcon = QIcon("user-trash"); + plasmoid.aspectRatioMode = IgnoreAspectRatio; + } + + MouseArea { + id: mouseArea + hoverEnabled: true + onReleased: plasmoid.openUrl("trash:/"); + anchors.fill:parent + PlasmaCore.IconItem { + id:icon + source: (dirModel.count > 0) ? "user-trash-full" : "user-trash" + anchors{ + left:parent.left + right:parent.right + top:parent.top + bottom:constrained?parent.bottom:text.top + } + active:mouseArea.containsMouse + } + Components.Label { + id:text + text: (dirModel.count==0)?i18n(" Trash\nEmpty"):(dirModel.count==1)?i18n(" Trash\nOne item"):i18n(" Trash\n"+ dirModel.count +"items") + anchors { + left:parent.left + bottom:parent.bottom + right:parent.right + } + horizontalAlignment:Text.AlignHCenter + opacity:constrained ? 0 : 1 + } + PlasmaCore.ToolTip { + target: mouseArea + mainText:"Trash" + subText: (dirModel.count==0)?i18n("Trash \n Empty"):(dirModel.count==1)?i18n("Trash \n One item"):i18n("Trash \n "+ dirModel.count +"items") + image: (dirModel.count > 0) ? "user-trash-full" : "user-trash" + } + } + + Component { + id:emptyDialogComponent + Components.QueryDialog { + id:queryDialog + titleIcon:"user-trash" + titleText:i18n("Empty Trash") + message:i18n("Do you really want to empty the trash ? All the items will be deleted.") + acceptButtonText:i18n("Empty Trash") + rejectButtonText:i18n("Cancel") + onAccepted:plasmoid.runCommand("ktrash", ["--empty"]); + } + } +} \ No newline at end of file From 57d2b1ee1838ecc7d626fa44ff3731d00a36a4a7 Mon Sep 17 00:00:00 2001 From: heena mahour Date: Fri, 16 Aug 2013 15:16:43 +0000 Subject: [PATCH 2/2] Added marginHints in Highlight.qml --- src/declarativeimports/plasmacomponents/qml/Highlight.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarativeimports/plasmacomponents/qml/Highlight.qml b/src/declarativeimports/plasmacomponents/qml/Highlight.qml index b9a21d731..86626c932 100644 --- a/src/declarativeimports/plasmacomponents/qml/Highlight.qml +++ b/src/declarativeimports/plasmacomponents/qml/Highlight.qml @@ -40,6 +40,7 @@ Item { /** true if the mouse button is pressed over the component. */ property bool pressed: false width: ListView.view ? ListView.view.width : undefined + property alias marginHints: background.margins; Connections { target: highlight.ListView.view