All Classes Functions Properties
PreviewActions.qml
/*
* Copyright (C) 2014 Canonical, Ltd.
*
* 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; version 3.
*
* 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.1
PreviewWidget {
id: root
height: row.height + units.gu(1)
Row {
id: row
readonly property var actions: root.widgetData ? root.widgetData["actions"] : null
anchors.right: parent.right
spacing: units.gu(1)
Loader {
id: loader
readonly property bool button: row.actions && row.actions.length == 2
readonly property bool combo: row.actions && row.actions.length > 2
source: button ? "PreviewActionButton.qml" : (combo ? "PreviewActionCombo.qml" : "")
width: (root.width - units.gu(1)) / 2
onLoaded: {
if (button) {
item.data = row.actions[1];
} else if (combo) {
item.model = row.actions.slice(1);
}
}
Connections {
target: loader.item
onTriggeredAction: {
root.triggered(root.widgetId, actionData.id, actionData);
}
}
}
PreviewActionButton {
data: visible ? row.actions[0] : null
visible: row.actions && row.actions.length > 0
onTriggeredAction: root.triggered(root.widgetId, actionData.id, actionData)
width: (root.width - units.gu(1)) / 2
}
}
}