[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace] plasma/generic/applets/devicenotifier/package/contents/ui: use
From:       Marco Martin <notmart () gmail ! com>
Date:       2014-02-06 13:02:17
Message-ID: E1WBOav-00063k-Km () scm ! kde ! org
[Download RAW message or body]

Git commit 7858bcdc86264c4076a482df15513144f5cec0f0 by Marco Martin.
Committed on 06/02/2014 at 13:00.
Pushed by mart into branch 'master'.

use Plasmoid.fullRepresentation

M  +216  -222  plasma/generic/applets/devicenotifier/package/contents/ui/devicenotifier.qml


http://commits.kde.org/kde-workspace/7858bcdc86264c4076a482df15513144f5cec0f0

diff --git a/plasma/generic/applets/devicenotifier/package/contents/ui/devicenotifier.qml \
b/plasma/generic/applets/devicenotifier/package/contents/ui/devicenotifier.qml index \
                8b74b7b..6596a57 100644
--- a/plasma/generic/applets/devicenotifier/package/contents/ui/devicenotifier.qml
+++ b/plasma/generic/applets/devicenotifier/package/contents/ui/devicenotifier.qml
@@ -27,12 +27,27 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
 
 Item {
     id: devicenotifier
-    Layout.minimumWidth: 290
-    Layout.minimumHeight: 340
     property string devicesType: "removable"
     property string expandedDevice
     property string popupIcon: "device-notifier"
 
+    Plasmoid.switchWidth: units.gridUnit * 10
+    Plasmoid.switchHeight: units.gridUnit * 15
+    Plasmoid.onExpandedChanged: {
+        popupEventSlot(plasmoid.expanded);
+    }
+
+    function popupEventSlot(popped) {
+        if (!popped) {
+            // reset the property that lets us remember if an item was clicked
+            // (versus only hovered) for autohide purposes
+            notifierDialog.itemClicked = true;
+            expandedDevice = "";
+            notifierDialog.currentExpanded = -1;
+            notifierDialog.currentIndex = -1;
+        }
+    }
+
     PlasmaCore.DataSource {
         id: hpSource
         engine: "hotplug"
@@ -92,24 +107,6 @@ Item {
         }
     }
 
-    function popupEventSlot(popped) {
-        if (!popped) {
-            // reset the property that lets us remember if an item was clicked
-            // (versus only hovered) for autohide purposes
-            notifierDialog.itemClicked = true;
-            expandedDevice = "";
-            notifierDialog.currentExpanded = -1;
-            notifierDialog.currentIndex = -1;
-        }
-    }
-
-    Connections {
-        target: plasmoid
-        onExpandedChanged: {
-            popupEventSlot(plasmoid.expanded);
-        }
-    }
-
     PlasmaCore.DataSource {
         id: statusSource
         engine: "devicenotifications"
@@ -182,6 +179,24 @@ Item {
         //plasmoid.popupIconToolTip = tooltip // FIXME
     }
 
+    function isMounted (udi) {
+        var types = sdSource.data[udi]["Device Types"];
+        if (types.indexOf("Storage Access")>=0) {
+            if (sdSource.data[udi]["Accessible"]) {
+                return true;
+            }
+            else {
+                return false;
+            }
+        }
+        else if (types.indexOf("Storage Volume")>=0 && \
types.indexOf("OpticalDisc")>=0) { +            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
     Timer {
         id: popupIconTimer
         interval: 2500
@@ -194,238 +209,217 @@ Item {
         onTriggered: plasmoid.status = PlasmaCore.Types.PassiveStatus
     }
 
-    PlasmaExtras.ConditionalLoader {
-        anchors.fill: parent
-        when: plasmoid.expanded
-
-        source: Component {
-            MouseArea {
-                hoverEnabled: true
-                anchors.fill: parent
 
-                onEntered: notifierDialog.itemHovered()
-                onExited: notifierDialog.itemUnhovered()
+    Plasmoid.fullRepresentation: MouseArea {
+        Layout.minimumWidth: units.gridUnit * 8
+        Layout.minimumHeight: units.gridUnit * 10
 
-                PlasmaComponents.Label {
-                    id: header
-                    text: filterModel.count>0 ? i18n("Available Devices") : i18n("No \
                Devices Available")
-                    anchors { top: parent.top; topMargin: 3; left: parent.left; \
                right: parent.right }
-                }
-
-                PlasmaExtras.ScrollArea {
-                    anchors {
-                        top : header.bottom
-                        topMargin: 10
-                        bottom: statusBarSeparator.top
-                        left: parent.left
-                        right: parent.right
-                    }
+        hoverEnabled: true
+        anchors.fill: parent
 
-                    ListView {
-                        id: notifierDialog
+        onEntered: notifierDialog.itemHovered()
+        onExited: notifierDialog.itemUnhovered()
 
-                        model: PlasmaCore.SortFilterModel {
-                            id: filterModel
-                            sourceModel: PlasmaCore.DataModel {
-                                dataSource: sdSource
-                            }
-                            filterRole: "Removable"
-                            filterRegExp: {
-                                // FIXME: This crashes
-                                //var all = plasmoid.configuration.allDevices;
-                                //var removable = \
                plasmoid.configuration.removableDevices;
-                                print("FIXME: Disabled reading from config due to \
                crash");
-                                var all = false;
-                                var removable = true;
-
-                                if (all == true) {
-                                    devicesType = "all";
-                                    print("ST2P all");
-                                    return "";
-                                } else if (removable == true) {
-                                    print("ST2P rem true");
-                                    devicesType = "removable";
-                                    return "true";
-                                } else {
-                                    print("ST2P nonRemovable");
-                                    devicesType = "nonRemovable";
-                                    return "false";
-                                }
-                            }
-                            sortRole: "Timestamp"
-                            sortOrder: Qt.DescendingOrder
-                        }
+        PlasmaComponents.Label {
+            id: header
+            text: filterModel.count>0 ? i18n("Available Devices") : i18n("No Devices \
Available") +            anchors { top: parent.top; topMargin: 3; left: parent.left; \
right: parent.right } +        }
 
-                        property int currentExpanded: -1
-                        property bool itemClicked: true
-                        delegate: deviceItem
-                        highlight: PlasmaComponents.Highlight{}
-
-                        //this is needed to make SectionScroller actually work
-                        //acceptable since one doesn't have a billion of devices
-                        cacheBuffer: 1000
-
-                        onCountChanged: {
-                            if (count == 0) {
-                                updateTooltip();
-                                passiveTimer.restart()
-                            } else {
-                                passiveTimer.stop()
-                                plasmoid.status = PlasmaCore.Types.ActiveStatus
-                            }
-                        }
+        PlasmaExtras.ScrollArea {
+            anchors {
+                top : header.bottom
+                topMargin: 10
+                bottom: statusBarSeparator.top
+                left: parent.left
+                right: parent.right
+            }
 
-                        function itemHovered()
-                        {
-                            // prevent autohide from catching us!
-                            plasmoid.expanded = true;
-                        }
+            ListView {
+                id: notifierDialog
 
-                        function itemUnhovered()
-                        {
-                            if (!itemClicked) {
-                                plasmoid.expanded = true;
-                            }
+                model: PlasmaCore.SortFilterModel {
+                    id: filterModel
+                    sourceModel: PlasmaCore.DataModel {
+                        dataSource: sdSource
+                    }
+                    filterRole: "Removable"
+                    filterRegExp: {
+                        // FIXME: This crashes
+                        //var all = plasmoid.configuration.allDevices;
+                        //var removable = plasmoid.configuration.removableDevices;
+                        print("FIXME: Disabled reading from config due to crash");
+                        var all = false;
+                        var removable = true;
+
+                        if (all == true) {
+                            devicesType = "all";
+                            print("ST2P all");
+                            return "";
+                        } else if (removable == true) {
+                            print("ST2P rem true");
+                            devicesType = "removable";
+                            return "true";
+                        } else {
+                            print("ST2P nonRemovable");
+                            devicesType = "nonRemovable";
+                            return "false";
                         }
+                    }
+                    sortRole: "Timestamp"
+                    sortOrder: Qt.DescendingOrder
+                }
 
-                        function itemFocused()
-                        {
-                            if (!itemClicked) {
-                                // prevent autohide from catching us!
-                                itemClicked = true;
-                                plasmoid.expanded = true;
-                            }
-                        }
+                property int currentExpanded: -1
+                property bool itemClicked: true
+                delegate: deviceItem
+                highlight: PlasmaComponents.Highlight{}
+
+                //this is needed to make SectionScroller actually work
+                //acceptable since one doesn't have a billion of devices
+                cacheBuffer: 1000
+
+                onCountChanged: {
+                    if (count == 0) {
+                        updateTooltip();
+                        passiveTimer.restart()
+                    } else {
+                        passiveTimer.stop()
+                        plasmoid.status = PlasmaCore.Types.ActiveStatus
+                    }
+                }
 
-                        section {
-                            property: "Type Description"
-                            delegate: Item {
-                                height: childrenRect.height
-                                width: notifierDialog.width
-                                PlasmaCore.SvgItem {
-                                    visible: parent.y > 0
-                                    svg: lineSvg
-                                    elementId: "horizontal-line"
-                                    anchors {
-                                        left: parent.left
-                                        right: parent.right
-                                    }
-                                    height: \
                lineSvg.elementSize("horizontal-line").height
-                                }
-                                PlasmaComponents.Label {
-                                    x: 8
-                                    y: 8
-                                    opacity: 0.6
-                                    text: section
-                                    color: theme.textColor
-                                }
-                            }
-                        }
+                function itemHovered()
+                {
+                    // prevent autohide from catching us!
+                    plasmoid.expanded = true;
+                }
 
-                        Component.onCompleted: currentIndex=-1
+                function itemUnhovered()
+                {
+                    if (!itemClicked) {
+                        plasmoid.expanded = true;
                     }
-
                 }
 
-                Component {
-                    id: deviceItem
+                function itemFocused()
+                {
+                    if (!itemClicked) {
+                        // prevent autohide from catching us!
+                        itemClicked = true;
+                        plasmoid.expanded = true;
+                    }
+                }
 
-                    DeviceItem {
-                        id: wrapper
+                section {
+                    property: "Type Description"
+                    delegate: Item {
+                        height: childrenRect.height
                         width: notifierDialog.width
-                        udi: DataEngineSource
-                        icon: sdSource.data[udi]["Icon"]
-                        deviceName: sdSource.data[udi]["Description"]
-                        emblemIcon: Emblems[0]
-                        state: model["State"]
-
-                        percentUsage: {
-                            var freeSpace = new Number(sdSource.data[udi]["Free \
                Space"]);
-                            var size = new Number(model["Size"]);
-                            var used = size-freeSpace;
-                            return used*100/size;
-                        }
-                        leftActionIcon: {
-                            if (mounted) {
-                                return "media-eject";
-                            } else {
-                                return "emblem-mounted";
+                        PlasmaCore.SvgItem {
+                            visible: parent.y > 0
+                            svg: lineSvg
+                            elementId: "horizontal-line"
+                            anchors {
+                                left: parent.left
+                                right: parent.right
                             }
+                            height: lineSvg.elementSize("horizontal-line").height
                         }
-                        mounted: model["Accessible"]
-
-                        onLeftActionTriggered: {
-                            var operationName = mounted ? "unmount" : "mount";
-                            var service = sdSource.serviceForSource(udi);
-                            var operation = \
                service.operationDescription(operationName);
-                            service.startOperationCall(operation);
+                        PlasmaComponents.Label {
+                            x: 8
+                            y: 8
+                            opacity: 0.6
+                            text: section
+                            color: theme.textColor
                         }
-                        property bool isLast: (expandedDevice == udi)
-                        property int operationResult: (model["Operation result"])
-
-                        onIsLastChanged: {
-                            if (isLast) {
-                                notifierDialog.currentExpanded = index
-                                makeCurrent();
-                            }
-                        }
-                        onOperationResultChanged: {
-                            if (operationResult == 1) {
-                                plasmoid.setPopupIconByName("dialog-ok")
-                                popupIconTimer.restart()
-                            } else if (operationResult == 2) {
-                                plasmoid.setPopupIconByName("dialog-error")
-                                popupIconTimer.restart()
-                            }
-                        }
-                        Behavior on height { NumberAnimation { duration: \
units.shortDuration * 3 } }  }
                 }
 
-                PlasmaCore.SvgItem {
-                    id: statusBarSeparator
-                    svg: lineSvg
-                    elementId: "horizontal-line"
-                    height: lineSvg.elementSize("horizontal-line").height
-                    anchors {
-                        bottom: statusBar.top
-                        bottomMargin: statusBar.visible ? 3:0
-                        left: parent.left
-                        right: parent.right
+                Component.onCompleted: currentIndex=-1
+            }
+
+        }
+
+        Component {
+            id: deviceItem
+
+            DeviceItem {
+                id: wrapper
+                width: notifierDialog.width
+                udi: DataEngineSource
+                icon: sdSource.data[udi]["Icon"]
+                deviceName: sdSource.data[udi]["Description"]
+                emblemIcon: Emblems[0]
+                state: model["State"]
+
+                percentUsage: {
+                    var freeSpace = new Number(sdSource.data[udi]["Free Space"]);
+                    var size = new Number(model["Size"]);
+                    var used = size-freeSpace;
+                    return used*100/size;
+                }
+                leftActionIcon: {
+                    if (mounted) {
+                        return "media-eject";
+                    } else {
+                        return "emblem-mounted";
                     }
-                    visible: statusBar.height>0
                 }
+                mounted: model["Accessible"]
 
-                StatusBar {
-                    id: statusBar
-                    anchors {
-                        left: parent.left
-                        leftMargin: 5
-                        right: parent.right
-                        rightMargin: 5
-                        bottom: parent.bottom
-                        bottomMargin: 5
+                onLeftActionTriggered: {
+                    var operationName = mounted ? "unmount" : "mount";
+                    var service = sdSource.serviceForSource(udi);
+                    var operation = service.operationDescription(operationName);
+                    service.startOperationCall(operation);
+                }
+                property bool isLast: (expandedDevice == udi)
+                property int operationResult: (model["Operation result"])
+
+                onIsLastChanged: {
+                    if (isLast) {
+                        notifierDialog.currentExpanded = index
+                        makeCurrent();
                     }
                 }
-            } // MouseArea
+                onOperationResultChanged: {
+                    if (operationResult == 1) {
+                        plasmoid.setPopupIconByName("dialog-ok")
+                        popupIconTimer.restart()
+                    } else if (operationResult == 2) {
+                        plasmoid.setPopupIconByName("dialog-error")
+                        popupIconTimer.restart()
+                    }
+                }
+                Behavior on height { NumberAnimation { duration: units.shortDuration \
* 3 } } +            }
         }
-    }
 
-    function isMounted (udi) {
-        var types = sdSource.data[udi]["Device Types"];
-        if (types.indexOf("Storage Access")>=0) {
-            if (sdSource.data[udi]["Accessible"]) {
-                return true;
-            }
-            else {
-                return false;
+        PlasmaCore.SvgItem {
+            id: statusBarSeparator
+            svg: lineSvg
+            elementId: "horizontal-line"
+            height: lineSvg.elementSize("horizontal-line").height
+            anchors {
+                bottom: statusBar.top
+                bottomMargin: statusBar.visible ? 3:0
+                left: parent.left
+                right: parent.right
             }
+            visible: statusBar.height>0
         }
-        else if (types.indexOf("Storage Volume")>=0 && \
                types.indexOf("OpticalDisc")>=0) {
-            return true;
-        }
-        else {
-            return false;
+
+        StatusBar {
+            id: statusBar
+            anchors {
+                left: parent.left
+                leftMargin: 5
+                right: parent.right
+                rightMargin: 5
+                bottom: parent.bottom
+                bottomMargin: 5
+            }
         }
-    }
+    } // MouseArea
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic