[kde-workspace] plasma/generic/applets/systemtray2/package/contents/ui: Systemtray: Delegate Sizing

Mark Gaiser markg85 at gmail.com
Sat Nov 2 16:53:55 UTC 2013


On Sat, Nov 2, 2013 at 3:43 AM, Sebastian Kügler <sebas at kde.org> wrote:
> Git commit f5e0dde35e5d7da14acf6e0b4a53ead96685daec by Sebastian Kügler.
> Committed on 02/11/2013 at 02:27.
> Pushed by sebas into branch 'master'.
>
> Systemtray: Delegate Sizing
>
> This commit makes the gridview more dynamically sized. I think in a
> world of Retina displays, we should move away from pixel-based sizes as
> much as possible. From this point on, protocols are simply not allowed
> to determine the size of their items. We can still apply tricks in the
> possible x11 protocol, and have support for images and movies of fixed
> size working well. The input area absolutely has to be client-defined,
> we can't have applications tell us "the interactive area for this app is
> 22x22 pixels" -- that is not going to happen, as it simply breaks on
> different dpi *and* input devices.
>
> As such, the item size is now more dynamic, the logic is not complete
> yet, but the direction of this gets clearer. This makes the "basic"
> itemSize a "recommendation" to the UI for now (it will become an even
> more internal detail later).
>
> Otherwise, the system tray is coming along nicely. What works:
>
> - Display of status notifier items (not interactive yet, just icons)
> - Embedding of plasmoids such as battery, network
> - Status: items are shown and hidden (moved between the models, really)
>
> A few things that I want to improve at a later stage is the messy popup
> situation. We can probably embed the popups of the plasmoids and
> statusitems into the systemtray popup and streamline this navigational
> process a bit, while keeping the same interaction model.
>
> We're obviously not feature-complete yet and it's all very
> work-in-progressish, but it's "coming along nicely". :)
>
> Here's a screenshot: http://i.imgur.com/LuQdkDL.png
>
> CCMAIL:plasma-devel at kde.org
> DIGEST:
>
> M  +14   -1    plasma/generic/applets/systemtray2/package/contents/ui/CompactRepresentation.qml
> M  +10   -10   plasma/generic/applets/systemtray2/package/contents/ui/TaskDelegate.qml
> M  +3    -2    plasma/generic/applets/systemtray2/package/contents/ui/main.qml
>
> http://commits.kde.org/kde-workspace/f5e0dde35e5d7da14acf6e0b4a53ead96685daec
>
> diff --git a/plasma/generic/applets/systemtray2/package/contents/ui/CompactRepresentation.qml b/plasma/generic/applets/systemtray2/package/contents/ui/CompactRepresentation.qml
> index e3cd88b..4971d37 100644
> --- a/plasma/generic/applets/systemtray2/package/contents/ui/CompactRepresentation.qml
> +++ b/plasma/generic/applets/systemtray2/package/contents/ui/CompactRepresentation.qml
> @@ -118,6 +118,7 @@ Item {
>      GridView {
>          id: gridView
>          objectName: "gridView"
> +        flow: !root.vertical ? GridView.LeftToRight : GridView.TopToBottom
>
>          anchors {
>              top: notificationsContainer.top
> @@ -126,7 +127,19 @@ Item {
>              leftMargin: root.vertical ? 0 : itemSpacing
>              right: arrow.left
>          }
> -        cellWidth: root.vertical ? parent.width : parent.height
> +        cellWidth: root.vertical ? parent.width / gridRows() : parent.height / gridRows()
> +
> +        function gridRows() {
> +            var r = 0;
> +            if (root.vertical) {
> +                r = Math.floor(parent.width / plasmoid.configuration.itemSize);
> +            } else {
> +                r = Math.floor(parent.height / plasmoid.configuration.itemSize);
> +            }
> +            print("ST2 ROW: ::::::: " + r);
> +            return Math.max(1, r);
> +
> +        }
>          cellHeight: cellWidth
>          interactive: false
>
> diff --git a/plasma/generic/applets/systemtray2/package/contents/ui/TaskDelegate.qml b/plasma/generic/applets/systemtray2/package/contents/ui/TaskDelegate.qml
> index 56ecc87..4b2c5a4 100644
> --- a/plasma/generic/applets/systemtray2/package/contents/ui/TaskDelegate.qml
> +++ b/plasma/generic/applets/systemtray2/package/contents/ui/TaskDelegate.qml
> @@ -20,6 +20,7 @@
>  import QtQuick 2.0
>  import org.kde.plasma.core 2.0 as PlasmaCore
>  import org.kde.plasma.components 2.0 as PlasmaComponents
> +import org.kde.plasma.extras 2.0 as PlasmaExtras
>
>  import org.kde.private.systemtray 2.0 as SystemTray
>
> @@ -28,14 +29,9 @@ Item {
>      id: taskItemContainer
>      objectName: "taskItemContainer"
>
> -    // FIXME: the applet itself is anchored here, but we want to center it,
> -    // yet keep the whole cell mouse-interactive
>      width: gridView.cellWidth
>      height: gridView.cellHeight
> -    // basically, this:
> -//     width: _h
> -//     height: width
> -    //anchors.centerIn: parent
> +    property int taskStatus: status
>
>      Rectangle {
>          anchors.fill: parent;
> @@ -48,10 +44,11 @@ Item {
>
>      PlasmaCore.IconItem {
>          id: itemIcon
> -        width: _h
> -        height: width
> +        width: parent.height
> +        height: parent.height
>          anchors {
> -            centerIn: taskItemContainer
> +            left: parent.left
> +            verticalCenter: parent.verticalCenter
>          }
>          //visible: source != ""
>          source: iconName != "" ? iconName : (typeof(icon) != "undefined" ? icon : "")
> @@ -62,6 +59,9 @@ Item {
>          running: status == SystemTray.Task.NeedsAttention
>      }
>
> +    onTaskStatusChanged: {
> +        print("ST2 status changed to " + taskStatusString());
> +    }
>      // just for debugging purposes
>      function taskStatusMnemonic() {
>          if (status == SystemTray.Task.Passive) {
> @@ -86,7 +86,7 @@ Item {
>
>      Component.onCompleted: {
>          //host.rootItem = gridView;
> -        //print(" taskitem: " + taskItem + " " + iconName);
> +        print(" ST2 taskitem created: " + taskItem + " " + iconName);
>          if ((taskItem != undefined)) {
>              //print( " TASK ITEM CHANGED"  + (taskItem != undefined));
>              taskItem.parent = taskItemContainer;
> diff --git a/plasma/generic/applets/systemtray2/package/contents/ui/main.qml b/plasma/generic/applets/systemtray2/package/contents/ui/main.qml
> index 85c4dd7..0fd3d3e 100644
> --- a/plasma/generic/applets/systemtray2/package/contents/ui/main.qml
> +++ b/plasma/generic/applets/systemtray2/package/contents/ui/main.qml
> @@ -80,15 +80,16 @@ Item {
>
>          anchors {
>              top: (loadingItem.visible && !plasmoid.expanded) ? loadingItem.bottom : parent.top
> +            bottom: (loadingItem.visible && !plasmoid.expanded) ? undefined : parent.bottom
>              left: parent.left
>              right: parent.right
> -            bottom: parent.bottom
> +            //bottom: parent.bottom
>          }
>          spacing: 4
>
>          model: host.hiddenTasks
>
> -        delegate: TaskDelegate {}
> +        delegate: TaskListDelegate {}
>      }
>
>  }
> \ No newline at end of file
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel


That's awesome! +100 :)

However..
Why are you using javascript for this? Since Qt 5.1 we have those
awesome dynamic layout things that automatically grow. Use that
instead of javascript.


More information about the Plasma-devel mailing list