touch specific Menu and MenuItem
This commit is contained in:
parent
a6d785ffc7
commit
b3597331f7
@ -38,13 +38,12 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri)
|
||||
KConfigGroup cg(KSharedConfig::openConfig("kdeclarativerc"), "Components-platform");
|
||||
const QString componentsPlatform = cg.readEntry("name", "desktop");
|
||||
|
||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "Menu");
|
||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "ContextMenu");
|
||||
qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
|
||||
|
||||
|
||||
if (componentsPlatform == "desktop") {
|
||||
qmlRegisterType<KDialogProxy>(uri, 0, 1, "QueryDialog");
|
||||
|
||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "Menu");
|
||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "ContextMenu");
|
||||
qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
|
||||
}
|
||||
|
||||
qmlRegisterType<Plasma::QRangeModel>(uri, 0, 1, "RangeModel");
|
||||
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2011 by Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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 1.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import "." 0.1
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
default property alias content: visualModel.children
|
||||
property Item visualParent
|
||||
property int status: DialogStatus.Closed
|
||||
|
||||
function open()
|
||||
{
|
||||
var parent = root.visualParent ? root.visualParent : root.parent
|
||||
var pos = dialog.popupPosition(parent, Qt.alignCenter)
|
||||
dialog.x = pos.x
|
||||
dialog.y = pos.y
|
||||
|
||||
dialog.visible = true
|
||||
dialog.focus = true
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
dialog.visible = false
|
||||
}
|
||||
|
||||
visible: false
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: dialog
|
||||
visible: false
|
||||
windowFlags: Qt.Popup
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
status = DialogStatus.Open
|
||||
} else {
|
||||
status = DialogStatus.Closed
|
||||
}
|
||||
}
|
||||
|
||||
mainItem: Item {
|
||||
id: contentItem
|
||||
|
||||
width: theme.defaultFont.mSize.width * 12
|
||||
height: Math.min(listView.contentHeight, theme.defaultFont.mSize.height * 25)
|
||||
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
|
||||
currentIndex : -1
|
||||
clip: true
|
||||
|
||||
model: VisualItemModel {
|
||||
id: visualModel
|
||||
onChildrenChanged: {
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
if (children[i].clicked != undefined)
|
||||
children[i].clicked.connect(root.close)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar {
|
||||
id: scrollBar
|
||||
flickableItem: listView
|
||||
visible: listView.contentHeight > contentItem.height
|
||||
//platformInverted: root.platformInverted
|
||||
anchors { top: listView.top; right: listView.right }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onStatusChanged: {
|
||||
if (status == DialogStatus.Opening) {
|
||||
if (listView.currentItem != null) {
|
||||
listView.currentItem.focus = false
|
||||
}
|
||||
listView.currentIndex = -1
|
||||
listView.positionViewAtIndex(0, ListView.Beginning)
|
||||
}
|
||||
else if (status == DialogStatus.Open) {
|
||||
listView.focus = true
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Components project.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 1.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property alias text: textArea.text
|
||||
|
||||
signal clicked
|
||||
|
||||
property int implicitWidth: textArea.paintedWidth + 6
|
||||
width: parent.width
|
||||
height: textArea.paintedHeight + 6
|
||||
|
||||
Label {
|
||||
id: textArea
|
||||
anchors.centerIn: parent
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
property bool canceled: false
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
onPressed: {
|
||||
canceled = false
|
||||
}
|
||||
onClicked: {
|
||||
if (!canceled)
|
||||
root.clicked()
|
||||
}
|
||||
onExited: canceled = true
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
event.accepted = true
|
||||
switch (event.key) {
|
||||
case Qt.Key_Select:
|
||||
case Qt.Key_Enter:
|
||||
case Qt.Key_Return: {
|
||||
if (!event.isAutoRepeat) {
|
||||
root.clicked()
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case Qt.Key_Up: {
|
||||
if (ListView.view != null)
|
||||
ListView.view.decrementCurrentIndex()
|
||||
else
|
||||
event.accepted = false
|
||||
break
|
||||
}
|
||||
|
||||
case Qt.Key_Down: {
|
||||
if (ListView.view != null)
|
||||
ListView.view.incrementCurrentIndex()
|
||||
else
|
||||
event.accepted = false
|
||||
break
|
||||
}
|
||||
default: {
|
||||
event.accepted = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,9 @@ QueryDialog 0.1 QueryDialog.qml
|
||||
SelectionDialog 0.1 SelectionDialog.qml
|
||||
Window 0.1 Window.qml
|
||||
ToolBarLayout 0.1 ToolBarLayout.qml
|
||||
Menu 0.1 Menu.qml
|
||||
ContextMenu 0.1 Menu.qml
|
||||
MenuItem 0.1 MenuItem.qml
|
||||
|
||||
Page 0.1 Page.qml
|
||||
PageStack 0.1 PageStack.qml
|
||||
|
Loading…
Reference in New Issue
Block a user