~ubuntu-branches/ubuntu/saucy/share-like-connect/saucy

« back to all changes in this revision

Viewing changes to applet/contents/ui/menu/MenuItem.qml

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-09-17 11:30:06 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130917113006-5ohj8qt9kuf3izma
Tags: 1:0.4-0ubuntu1
* New upstream release LP: #1227602
* Use epoch to reset version number in line with upstream
* Add build-dep on nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2011 Marco Martin <mart@kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2 or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU Library General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
import QtQuick 1.1
 
21
import org.kde.plasma.core 0.1 as PlasmaCore
 
22
import org.kde.plasma.extras 0.1 as PlasmaExtras
 
23
 
 
24
Item {
 
25
    id: menuItem
 
26
 
 
27
    property string resourceUrl
 
28
    property string sourceName
 
29
 
 
30
    implicitHeight: itemLoader.height
 
31
    implicitWidth: itemLoader.width
 
32
 
 
33
    PlasmaExtras.FallbackComponent {
 
34
        id: fallback
 
35
        basePath: "plasma"
 
36
        candidates: ["slcmenuitems/" + providerId,  "slcmenuitems/Default"]
 
37
    }
 
38
 
 
39
    Loader {
 
40
        id: itemLoader
 
41
        width: item ? Math.max(item.implicitWidth, serviceMenu.width) : 0
 
42
        height: item ? item.implicitHeight : 0
 
43
 
 
44
        source: fallback.filePath("Item.qml")
 
45
 
 
46
        MouseArea {
 
47
            anchors.fill: parent
 
48
            onClicked: {
 
49
                menuItem.run(mouse.x, mouse.y)
 
50
            }
 
51
        }
 
52
    }
 
53
 
 
54
    Connections {
 
55
        target: itemLoader.item
 
56
        onOperationCompleted: {
 
57
            dialog.visible = false
 
58
        }
 
59
    }
 
60
 
 
61
    function run(x, y)
 
62
    {
 
63
        itemLoader.item.run(x, y)
 
64
        if (itemLoader.item.operationCompleted === undefined) {
 
65
            dialog.visible = false
 
66
        }
 
67
    }
 
68
}