ActivitiesView.qml 5.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*   vim:set foldenable foldmethod=marker:
 *
 *   Copyright (C) 2015 Ivan Cukic <ivan.cukic@kde.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   or (at your option) any later version, as published by the Free
 *   Software Foundation
 *
 *   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  02110-1301, USA.
 */

import QtQuick 2.0
import org.kde.kquickcontrolsaddons 2.0
import QtQuick.Controls 1.0 as QtControls

import org.kde.activities 0.1 as Activities
import org.kde.activities.settings 0.1
import org.kde.plasma.core 2.0 as PlasmaCore

Item {
    id: root

    anchors.fill: parent

    QtControls.Button {
        id: buttonCreateActivity

37
        text: i18nd("kcm_activities5", "Create activity...")
38 39 40 41 42 43 44 45 46 47
        iconName: "list-add"

        anchors {
            top: parent.top
            left: parent.left
        }

        onClicked: ActivitySettings.newActivity();

        enabled: !dialogCreateActivityLoader.itemVisible
48
        visible: ActivitySettings.newActivityAuthorized
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    }

    Loader {
        id: dialogCreateActivityLoader

        property bool itemVisible: status == Loader.Ready && item.visible

        z: 1

        anchors {
            top: buttonCreateActivity.bottom
            left: buttonCreateActivity.left
        }
    }

    QtControls.ScrollView {
        anchors {
            top: buttonCreateActivity.bottom
            topMargin: units.smallSpacing
            left: parent.left
            right: parent.right
            bottom: parent.bottom
        }

        enabled: !dialogCreateActivityLoader.itemVisible

        ListView {
            width: parent.width
            // anchors.fill: parent

            model: Activities.ActivityModel {
                id: kactivities
            }

            SystemPalette {
                id: palette
                colorGroup: SystemPalette.Active
            }

            ///////////////////////////////////////////////////////////////////
            delegate: Rectangle {
                width: parent.width

                Behavior on height { PropertyAnimation { duration: units.shortDuration } }
                height: icon.height + units.smallSpacing * 2 +
                            (dialogConfigureLoader.itemVisible ? dialogConfigureLoader.height : 0) +
                            (dialogDeleteLoader.itemVisible ? dialogDeleteLoader.height : 0)

                color: (model.index % 2 == 0) ? palette.base : palette.alternateBase

                Item {
                    id: header

                    height: units.iconSizes.medium

                    anchors {
                        left: parent.left
                        right: parent.right
                        top: parent.top
                    }

                    QIconItem {
                        id: icon
                        icon: model.icon

                        width:  height
                        height: parent.height

                        anchors {
                            left:   parent.left
                            top:    parent.top

                            topMargin: units.smallSpacing
                            bottomMargin: units.smallSpacing
                        }
                    }

                    QtControls.Label {
                        text: model.name

129
                        anchors.fill: parent
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
                    }

                    Row {
                        id: buttons

                        spacing: units.smallSpacing

                        anchors {
                            right: parent.right

                            rightMargin: units.smallSpacing
                            verticalCenter: parent.verticalCenter
                        }

                        QtControls.Button {
                            id: buttonConfigure

                            iconName: "configure"

                            onClicked: ActivitySettings.configureActivity(model.id);
                        }

                        QtControls.Button {
                            id: buttonDelete

                            iconName: "edit-delete"

                            onClicked: ActivitySettings.deleteActivity(model.id);
158 159

                            visible: ActivitySettings.newActivityAuthorized
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
                        }

                        visible: !dialogDeleteLoader.itemVisible
                    }

                    visible: !dialogConfigureLoader.itemVisible
                }

                Loader {
                    id: dialogConfigureLoader

                    property bool itemVisible: status == Loader.Ready && item.visible

                    anchors {
                        left: parent.left
                        top: parent.top
                    }
                }

                Loader {
                    id: dialogDeleteLoader

                    property bool itemVisible: status == Loader.Ready && item.visible

                    anchors {
                        left: parent.left
                        top: header.bottom
                    }
                }
            }
            ///////////////////////////////////////////////////////////////////
        }
    }
}