🏡 index : quine-global-labs/plasma-desktop.git

/*
 * Copyright 2013  Heena Mahour <heena393@gmail.com>
 *
 * 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.
 *
 * 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.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.core 2.0 as PlasmaCore

Item {
    id: menuItem
    width: parent.width
    height: Math.max(iconItem.height, label.height) + highlightItem.marginHints.top + highlightItem.marginHints.bottom

    signal clicked()
    signal entered()
    signal executeJob(string jobName)
    signal setOnDesktop(int desktop)
    property alias nameLabel: label.text
    property int desktop
    property alias icon: iconItem.source
    property alias label: label.text
    property bool active: false
    property int iconSize: units.iconSizes.small
    property bool showDesktop: true
    property variant desktopItems: []

    PlasmaCore.IconItem {
        id: iconItem

        width: menuItem.iconSize
        height: width

        anchors {
            verticalCenter: parent.verticalCenter
            left: parent.left
            leftMargin: highlightItem.marginHints.left
        }
    }

    PlasmaComponents.Label {
        id: label

        height: implicitHeight
        anchors {
            left: iconItem.right
            leftMargin: highlightItem.marginHints.left
            right: parent.right
            verticalCenter: parent.verticalCenter
        }

        font.italic: (minimized == true) ? true : false

        elide: Text.ElideRight
    }

    MouseArea {
        id:root_item
        anchors.fill: parent
        hoverEnabled: true

        onClicked: {
            menuItem.clicked();
        }

        onEntered:{
            highlightItem.trackingItem = menuItem
            highlightItem.width = menuItem.width
            highlightItem.height = menuItem.height
            menuItem.entered();
            highlight = true
        }

        onExited: {
            highlight = false
        }
    }
}