plasma-framework/declarativeimports/test/AppTest.qml

95 lines
3.1 KiB
QML
Raw Normal View History

2012-03-16 03:38:04 +01:00
// -*- coding: iso-8859-1 -*-
/*
* Copyright 2011 Sebastian Kügler <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.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.plasma.extras 0.1 as PlasmaExtras
PlasmaExtras.App {
id: app
width: 800
height: 600
property string formFactor: "tablet"
navigation: navigationItem
content: contentItem
Item {
id: navigationItem
width: navigationWidth + space
height: parent.height
// PlasmaExtras.Title {
// text: "Navigation is zoo"
// elide: Text.ElideMiddle
// anchors { top: parent.top; left: parent.left; right: parent.right; }
// }
Column {
id: navigationColumn
anchors.fill: navigationItem
width: navigationWidth
PlasmaExtras.Title {
2012-03-16 04:50:47 +01:00
width: navigationColumn.width
2012-03-16 05:08:22 +01:00
visible: widthCheck.checked
2012-03-16 03:38:04 +01:00
text: "Navigation Pane."
2012-03-16 05:08:22 +01:00
elide: Text.ElideRight
2012-03-16 03:38:04 +01:00
//anchors { top: parent.top; left: parent.left; topMargin: 48; }
}
}
PlasmaComponents.CheckBox {
2012-03-16 05:08:22 +01:00
id: widthCheck
2012-03-16 04:50:47 +01:00
text: checked ? "Make big" : " "
//width: navigationWidth
2012-03-16 03:38:04 +01:00
checked: navigationWidth > 200
2012-03-16 05:08:22 +01:00
anchors { left: parent.left; leftMargin: space; bottomMargin: space; bottom: parent.bottom; }
2012-03-16 03:38:04 +01:00
onCheckedChanged: {
2012-03-16 04:50:47 +01:00
var w = !checked ? 48 : 340;
//print(" new: " + w);
2012-03-16 03:38:04 +01:00
navigationWidth = w;
}
//width: contentItem.width
}
2012-03-16 04:50:47 +01:00
//Rectangle { color: "blue"; opacity: 0.3; anchors.fill: parent; }
2012-03-16 03:38:04 +01:00
}
Loader {
2012-03-16 03:38:04 +01:00
id: contentItem
source: "gallery/Extras.qml"
2012-03-16 04:50:47 +01:00
width: app.width - navigationWidth - space*2
parent: contentArea
anchors.margins: space*2
2012-03-16 04:50:47 +01:00
Rectangle { color: "green"; opacity: 0.8; anchors.fill: contentItem; }
2012-03-16 03:38:04 +01:00
}
onWidthChanged: {
2012-03-16 04:50:47 +01:00
//return;
if (width < 340 + 200) {
2012-03-16 05:08:22 +01:00
//print("window changed: small " + width);
2012-03-16 04:50:47 +01:00
navigationWidth = 48;
2012-03-16 03:38:04 +01:00
} else {
2012-03-16 05:08:22 +01:00
//print("window changed: tablet " + width);
2012-03-16 04:50:47 +01:00
navigationWidth = 340;
2012-03-16 03:38:04 +01:00
}
2012-03-16 05:08:22 +01:00
widthCheck.checked = navigationWidth > 200;
2012-03-16 03:38:04 +01:00
}
}