mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
use an actual panel
sliding panel logic moved to the phone panel containment things in the panel are actually justy qml, the applets are in a tabbar in the sliding thing
This commit is contained in:
parent
b6122d7e7a
commit
6aafa9329a
12 changed files with 796 additions and 157 deletions
|
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
plasma_install_package(homescreen org.kde.phone.homescreen)
|
plasma_install_package(homescreen org.kde.phone.homescreen)
|
||||||
|
plasma_install_package(panel org.kde.phone.panel)
|
||||||
|
|
|
||||||
189
containments/panel/contents/code/LayoutManager.js
Normal file
189
containments/panel/contents/code/LayoutManager.js
Normal file
|
|
@ -0,0 +1,189 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 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 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.pragma library
|
||||||
|
|
||||||
|
|
||||||
|
var layout;
|
||||||
|
var root;
|
||||||
|
var plasmoid;
|
||||||
|
var lastSpacer;
|
||||||
|
|
||||||
|
|
||||||
|
function restore() {
|
||||||
|
var configString = String(plasmoid.configuration.AppletOrder)
|
||||||
|
|
||||||
|
//array, a cell for encoded item order
|
||||||
|
var itemsArray = configString.split(";");
|
||||||
|
|
||||||
|
//map applet id->order in panel
|
||||||
|
var idsOrder = new Object();
|
||||||
|
//map order in panel -> applet pointer
|
||||||
|
var appletsOrder = new Object();
|
||||||
|
|
||||||
|
for (var i = 0; i < itemsArray.length; i++) {
|
||||||
|
//property name: applet id
|
||||||
|
//property value: order
|
||||||
|
idsOrder[itemsArray[i]] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < plasmoid.applets.length; ++i) {
|
||||||
|
if (idsOrder[plasmoid.applets[i].id] !== undefined) {
|
||||||
|
appletsOrder[idsOrder[plasmoid.applets[i].id]] = plasmoid.applets[i];
|
||||||
|
//ones that weren't saved in AppletOrder go to the end
|
||||||
|
} else {
|
||||||
|
appletsOrder["unordered"+i] = plasmoid.applets[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//finally, restore the applets in the correct order
|
||||||
|
for (var i in appletsOrder) {
|
||||||
|
root.addApplet(appletsOrder[i], -1, -1)
|
||||||
|
}
|
||||||
|
//rewrite, so if in the orders there were now invalid ids or if some were missing creates a correct list instead
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
var ids = new Array();
|
||||||
|
for (var i = 0; i < layout.children.length; ++i) {
|
||||||
|
var child = layout.children[i];
|
||||||
|
|
||||||
|
if (child.applet) {
|
||||||
|
ids.push(child.applet.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plasmoid.configuration.AppletOrder = ids.join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeApplet (applet) {
|
||||||
|
for (var i = layout.children.length - 1; i >= 0; --i) {
|
||||||
|
var child = layout.children[i];
|
||||||
|
if (child.applet === applet) {
|
||||||
|
child.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//insert item2 before item1
|
||||||
|
function insertBefore(item1, item2) {
|
||||||
|
if (item1 === item2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var removed = new Array();
|
||||||
|
|
||||||
|
var child;
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = layout.children.length - 1; i >= 0; --i) {
|
||||||
|
child = layout.children[i];
|
||||||
|
removed.push(child);
|
||||||
|
child.parent = root;
|
||||||
|
|
||||||
|
if (child === item1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item2.parent = layout;
|
||||||
|
|
||||||
|
for (var j = removed.length - 1; j >= 0; --j) {
|
||||||
|
removed[j].parent = layout;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
//insert item2 after item1
|
||||||
|
function insertAfter(item1, item2) {
|
||||||
|
if (item1 === item2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var removed = new Array();
|
||||||
|
|
||||||
|
var child;
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = layout.children.length - 1; i >= 0; --i) {
|
||||||
|
child = layout.children[i];
|
||||||
|
//never ever insert after lastSpacer
|
||||||
|
if (child === lastSpacer && item1 === lastSpacer) {
|
||||||
|
removed.push(child);
|
||||||
|
child.parent = root;
|
||||||
|
break;
|
||||||
|
} else if (child === item1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
removed.push(child);
|
||||||
|
child.parent = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
item2.parent = layout;
|
||||||
|
|
||||||
|
for (var j = removed.length - 1; j >= 0; --j) {
|
||||||
|
removed[j].parent = layout;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertAtIndex(item, position) {
|
||||||
|
if (position < 0 || position >= layout.children.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//never ever insert after lastSpacer
|
||||||
|
if (layout.children[position] === lastSpacer) {
|
||||||
|
--position;
|
||||||
|
}
|
||||||
|
|
||||||
|
var removedItems = new Array();
|
||||||
|
|
||||||
|
for (var i = position; i < layout.children.length; ++i) {
|
||||||
|
var child = layout.children[position];
|
||||||
|
child.parent = root;
|
||||||
|
removedItems.push(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.parent = layout;
|
||||||
|
for (var i in removedItems) {
|
||||||
|
removedItems[i].parent = layout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertAtCoordinates(item, x, y) {
|
||||||
|
if (root.isHorizontal) {
|
||||||
|
y = layout.height / 2;
|
||||||
|
} else {
|
||||||
|
x = layout.width / 2;
|
||||||
|
}
|
||||||
|
var child = layout.childAt(x, y);
|
||||||
|
|
||||||
|
if (!child || child === item) {
|
||||||
|
child = layout.children[0];
|
||||||
|
}
|
||||||
|
item.parent = root;
|
||||||
|
|
||||||
|
//PlasmaCore.Types.Vertical = 3
|
||||||
|
if ((plasmoid.formFactor === 3 && y < child.y + child.height/2) ||
|
||||||
|
(plasmoid.formFactor !== 3 && x < child.x + child.width/2)) {
|
||||||
|
return insertBefore(child, item);
|
||||||
|
} else {
|
||||||
|
return insertAfter(child, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
containments/panel/contents/config/main.xml
Normal file
14
containments/panel/contents/config/main.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||||
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||||
|
<kcfgfile name=""/>
|
||||||
|
|
||||||
|
<group name="General">
|
||||||
|
<entry name="AppletOrder" type="String">
|
||||||
|
<label>encoded order of items</label>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</kcfg>
|
||||||
|
|
@ -57,6 +57,7 @@ Window {
|
||||||
height: window.height - y
|
height: window.height - y
|
||||||
clip: true
|
clip: true
|
||||||
state: "closed"
|
state: "closed"
|
||||||
|
drag.filterChildren: true
|
||||||
|
|
||||||
property int oldMouseY: 0
|
property int oldMouseY: 0
|
||||||
property int startOffset: units.iconSizes.large;
|
property int startOffset: units.iconSizes.large;
|
||||||
263
containments/panel/contents/ui/main.qml
Normal file
263
containments/panel/contents/ui/main.qml
Normal file
|
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import MeeGo.QOfono 0.2
|
||||||
|
|
||||||
|
import org.kde.plasma.plasmoid 2.0
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
|
import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace
|
||||||
|
|
||||||
|
import "plasmapackage:/code/LayoutManager.js" as LayoutManager
|
||||||
|
|
||||||
|
PlasmaCore.ColorScope {
|
||||||
|
id: root
|
||||||
|
width: 480
|
||||||
|
height: 640
|
||||||
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
|
||||||
|
property Item toolBox
|
||||||
|
property int buttonHeight: width/4
|
||||||
|
property bool reorderingApps: false
|
||||||
|
|
||||||
|
Containment.onAppletAdded: {
|
||||||
|
addApplet(applet, x, y);
|
||||||
|
LayoutManager.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addApplet(applet, x, y) {
|
||||||
|
var container = appletContainerComponent.createObject(tabGroup)
|
||||||
|
container.visible = true
|
||||||
|
print("Applet added: " + applet)
|
||||||
|
|
||||||
|
var appletWidth = applet.width;
|
||||||
|
var appletHeight = applet.height;
|
||||||
|
applet.parent = container;
|
||||||
|
container.applet = applet;
|
||||||
|
applet.anchors.fill = container;
|
||||||
|
applet.visible = true;
|
||||||
|
container.visible = true;
|
||||||
|
|
||||||
|
//container.parent = tabs;
|
||||||
|
|
||||||
|
//The tab
|
||||||
|
var tab = tabComponent.createObject(tabBar.layout);
|
||||||
|
tab.iconSource = applet.icon;
|
||||||
|
tab.tab = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
LayoutManager.plasmoid = plasmoid;
|
||||||
|
LayoutManager.root = root;
|
||||||
|
LayoutManager.layout = appletsLayout;
|
||||||
|
LayoutManager.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: appletsLayout
|
||||||
|
Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: appletContainerComponent
|
||||||
|
Item {
|
||||||
|
//not used yet
|
||||||
|
property bool animationsEnabled: false
|
||||||
|
property Item applet
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: tabComponent
|
||||||
|
PlasmaComponents.TabButton {
|
||||||
|
width: parent.width / parent.children.length
|
||||||
|
height: units.iconSizes.huge
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaCore.DataSource {
|
||||||
|
id: timeSource
|
||||||
|
engine: "time"
|
||||||
|
connectedSources: ["Local"]
|
||||||
|
interval: 60 * 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
OfonoNetworkRegistration {
|
||||||
|
id: netreg
|
||||||
|
Component.onCompleted: {
|
||||||
|
netreg.scan()
|
||||||
|
updateStrengthIcon()
|
||||||
|
}
|
||||||
|
|
||||||
|
onNetworkOperatorsChanged : {
|
||||||
|
console.log("operators :"+netreg.currentOperator["Name"].toString())
|
||||||
|
}
|
||||||
|
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
|
||||||
|
function updateStrengthIcon() {
|
||||||
|
if (netreg.strength >= 100) {
|
||||||
|
strengthIcon.source = "network-mobile-100";
|
||||||
|
} else if (netreg.strength >= 80) {
|
||||||
|
strengthIcon.source = "network-mobile-80";
|
||||||
|
} else if (netreg.strength >= 60) {
|
||||||
|
strengthIcon.source = "network-mobile-60";
|
||||||
|
} else if (netreg.strength >= 40) {
|
||||||
|
strengthIcon.source = "network-mobile-40";
|
||||||
|
} else if (netreg.strength >= 20) {
|
||||||
|
strengthIcon.source = "network-mobile-20";
|
||||||
|
} else {
|
||||||
|
strengthIcon.source = "network-mobile-0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onStrengthChanged: {
|
||||||
|
console.log("Strength changed to " + netreg.strength)
|
||||||
|
updateStrengthIcon()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
parent: slidingPanel.visible ? panelContents : root
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
height: root.height
|
||||||
|
color: PlasmaCore.ColorScope.backgroundColor
|
||||||
|
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
id: strengthIcon
|
||||||
|
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
width: height
|
||||||
|
height: parent.height
|
||||||
|
}
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
anchors {
|
||||||
|
left: strengthIcon.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
text: netreg.strength + "% " + netreg.name
|
||||||
|
color: PlasmaCore.ColorScope.textColor
|
||||||
|
font.pixelSize: parent.height / 2
|
||||||
|
}
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
id: clock
|
||||||
|
anchors.fill: parent
|
||||||
|
text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm")
|
||||||
|
color: PlasmaCore.ColorScope.textColor
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
font.pixelSize: height / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaWorkspace.BatteryIcon {
|
||||||
|
id: batteryIcon
|
||||||
|
anchors {
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
width: height
|
||||||
|
height: parent.height
|
||||||
|
hasBattery: pmSource.data["Battery"]["Has Battery"]
|
||||||
|
// batteryType: "Phone"
|
||||||
|
percent: pmSource.data["Battery0"] ? pmSource.data["Battery0"]["Percent"] : 0
|
||||||
|
|
||||||
|
PlasmaCore.DataSource {
|
||||||
|
id: pmSource
|
||||||
|
engine: "powermanagement"
|
||||||
|
connectedSources: sources
|
||||||
|
onSourceAdded: {
|
||||||
|
disconnectSource(source);
|
||||||
|
connectSource(source);
|
||||||
|
}
|
||||||
|
onSourceRemoved: {
|
||||||
|
disconnectSource(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
height: units.smallSpacing/2
|
||||||
|
color: PlasmaCore.ColorScope.highlightColor
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
property int oldMouseY: 0
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
onPressed: {
|
||||||
|
oldMouseY = mouse.y;
|
||||||
|
slidingPanel.visible = true;
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
//var factor = (mouse.y - oldMouseY > 0) ? (1 - Math.max(0, (slidingArea.y + slidingPanel.overShoot) / slidingPanel.overShoot)) : 1
|
||||||
|
var factor = 1;
|
||||||
|
print(slidingPanel.offset +" "+ slidingPanel.height)
|
||||||
|
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
|
||||||
|
oldMouseY = mouse.y;
|
||||||
|
}
|
||||||
|
onReleased: slidingPanel.updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
SlidingPanel {
|
||||||
|
id: slidingPanel
|
||||||
|
width: plasmoid.availableScreenRect.width
|
||||||
|
height: plasmoid.availableScreenRect.height
|
||||||
|
contents: Item {
|
||||||
|
id: panelContents
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
PlasmaComponents.TabBar {
|
||||||
|
id: tabBar
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: parent.top
|
||||||
|
right: parent.right
|
||||||
|
margins: units.smallSpacing
|
||||||
|
}
|
||||||
|
height: units.iconSizes.huge
|
||||||
|
}
|
||||||
|
PlasmaComponents.TabGroup {
|
||||||
|
id: tabGroup
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: tabBar.bottom
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
margins: units.smallSpacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
containments/panel/metadata.desktop
Normal file
18
containments/panel/metadata.desktop
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Keywords=
|
||||||
|
Name=Phone Panel
|
||||||
|
Type=Service
|
||||||
|
|
||||||
|
X-KDE-ServiceTypes=Plasma/Applet,Plasma/Containment
|
||||||
|
X-Plasma-API=declarativeappletscript
|
||||||
|
X-KDE-ParentApp=
|
||||||
|
X-KDE-PluginInfo-Author=Marco Martin
|
||||||
|
X-KDE-PluginInfo-Category=
|
||||||
|
X-KDE-PluginInfo-Email=mart@kde.org
|
||||||
|
X-KDE-PluginInfo-License=GPLv2+
|
||||||
|
X-KDE-PluginInfo-Name=org.kde.phone.panel
|
||||||
|
X-KDE-PluginInfo-Version=
|
||||||
|
X-KDE-PluginInfo-Website=
|
||||||
|
X-Plasma-MainScript=ui/main.qml
|
||||||
|
X-Plasma-ContainmentType=Panel
|
||||||
51
shell/contents/applet/AppletError.qml
Normal file
51
shell/contents/applet/AppletError.qml
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
Layout.minimumWidth: units.gridUnit * 20
|
||||||
|
Layout.minimumHeight: units.gridUnit * 8
|
||||||
|
|
||||||
|
property alias reason: messageText.text
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
id: icon
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
Layout.minimumWidth: units.iconSizes.huge
|
||||||
|
Layout.minimumHeight: units.iconSizes.huge
|
||||||
|
source: "dialog-error"
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaComponents.TextArea {
|
||||||
|
id: messageText
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
verticalAlignment: TextEdit.AlignVCenter
|
||||||
|
backgroundVisible: false
|
||||||
|
readOnly: true
|
||||||
|
width: parent.width - icon.width
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
}
|
||||||
|
}
|
||||||
153
shell/contents/applet/CompactApplet.qml
Normal file
153
shell/contents/applet/CompactApplet.qml
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Window 2.0
|
||||||
|
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
import org.kde.kquickcontrolsaddons 2.0
|
||||||
|
|
||||||
|
PlasmaCore.ToolTipArea {
|
||||||
|
id: root
|
||||||
|
objectName: "org.kde.desktop-CompactApplet"
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
icon: plasmoid.icon
|
||||||
|
mainText: plasmoid.toolTipMainText
|
||||||
|
subText: plasmoid.toolTipSubText
|
||||||
|
location: plasmoid.location
|
||||||
|
active: !plasmoid.expanded
|
||||||
|
property Item fullRepresentation
|
||||||
|
property Item compactRepresentation
|
||||||
|
property Item expandedFeedback: expandedItem
|
||||||
|
|
||||||
|
onCompactRepresentationChanged: {
|
||||||
|
if (compactRepresentation) {
|
||||||
|
compactRepresentation.parent = root;
|
||||||
|
compactRepresentation.anchors.fill = root;
|
||||||
|
compactRepresentation.visible = true;
|
||||||
|
}
|
||||||
|
root.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
onFullRepresentationChanged: {
|
||||||
|
|
||||||
|
if (!fullRepresentation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//if the fullRepresentation size was restored to a stored size, or if is dragged from the desktop, restore popup size
|
||||||
|
if (fullRepresentation.width > 0) {
|
||||||
|
popupWindow.mainItem.width = fullRepresentation.width;
|
||||||
|
} else if (fullRepresentation.Layout && fullRepresentation.Layout.preferredWidth > 0) {
|
||||||
|
popupWindow.mainItem.width = fullRepresentation.Layout.preferredWidth
|
||||||
|
} else if (fullRepresentation.implicitWidth > 0) {
|
||||||
|
popupWindow.mainItem.width = fullRepresentation.implicitWidth
|
||||||
|
} else {
|
||||||
|
popupWindow.mainItem.width = theme.mSize(theme.defaultFont).width * 35
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullRepresentation.height > 0) {
|
||||||
|
popupWindow.mainItem.height = fullRepresentation.height;
|
||||||
|
} else if (fullRepresentation.Layout && fullRepresentation.Layout.preferredHeight > 0) {
|
||||||
|
popupWindow.mainItem.height = fullRepresentation.Layout.preferredHeight
|
||||||
|
} else if (fullRepresentation.implicitHeight > 0) {
|
||||||
|
popupWindow.mainItem.height = fullRepresentation.implicitHeight
|
||||||
|
} else {
|
||||||
|
popupWindow.mainItem.height = theme.mSize(theme.defaultFont).height * 25
|
||||||
|
}
|
||||||
|
|
||||||
|
fullRepresentation.parent = appletParent;
|
||||||
|
fullRepresentation.anchors.fill = fullRepresentation.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: expandedItem
|
||||||
|
anchors.fill: parent
|
||||||
|
imagePath: "widgets/tabbar"
|
||||||
|
visible: fromCurrentTheme
|
||||||
|
prefix: {
|
||||||
|
var prefix;
|
||||||
|
switch (plasmoid.location) {
|
||||||
|
case PlasmaCore.Types.LeftEdge:
|
||||||
|
prefix = "west-active-tab";
|
||||||
|
break;
|
||||||
|
case PlasmaCore.Types.TopEdge:
|
||||||
|
prefix = "north-active-tab";
|
||||||
|
break;
|
||||||
|
case PlasmaCore.Types.RightEdge:
|
||||||
|
prefix = "east-active-tab";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prefix = "south-active-tab";
|
||||||
|
}
|
||||||
|
if (!hasElementPrefix(prefix)) {
|
||||||
|
prefix = "active-tab";
|
||||||
|
}
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
opacity: plasmoid.expanded ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: units.shortDuration
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: expandedSync
|
||||||
|
interval: 100
|
||||||
|
onTriggered: plasmoid.expanded = popupWindow.visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.Dialog {
|
||||||
|
id: popupWindow
|
||||||
|
objectName: "popupWindow"
|
||||||
|
flags: Qt.WindowStaysOnTopHint
|
||||||
|
visible: plasmoid.expanded && fullRepresentation
|
||||||
|
visualParent: compactRepresentation ? compactRepresentation : null
|
||||||
|
location: plasmoid.location
|
||||||
|
hideOnWindowDeactivate: plasmoid.hideOnWindowDeactivate
|
||||||
|
|
||||||
|
property var oldStatus: PlasmaCore.Types.UnknownStatus
|
||||||
|
|
||||||
|
//It's a MouseEventListener to get all the events, so the eventfilter will be able to catch them
|
||||||
|
mainItem: MouseEventListener {
|
||||||
|
id: appletParent
|
||||||
|
Layout.minimumWidth: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.minimumWidth : 0
|
||||||
|
Layout.minimumHeight: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.minimumHeight: 0
|
||||||
|
Layout.maximumWidth: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.maximumWidth : Infinity
|
||||||
|
Layout.maximumHeight: (fullRepresentation && fullRepresentation.Layout) ? fullRepresentation.Layout.maximumHeight: Infinity
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (!visible) {
|
||||||
|
expandedSync.restart();
|
||||||
|
plasmoid.status = oldStatus;
|
||||||
|
} else {
|
||||||
|
oldStatus = plasmoid.status;
|
||||||
|
plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus;
|
||||||
|
// This call currently fails and complains at runtime:
|
||||||
|
// QWindow::setWindowState: QWindow::setWindowState does not accept Qt::WindowActive
|
||||||
|
popupWindow.requestActivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
61
shell/contents/applet/DefaultCompactRepresentation.qml
Normal file
61
shell/contents/applet/DefaultCompactRepresentation.qml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
|
PlasmaCore.IconItem {
|
||||||
|
id: icon
|
||||||
|
|
||||||
|
Layout.minimumWidth: {
|
||||||
|
switch (plasmoid.formFactor) {
|
||||||
|
case PlasmaCore.Types.Vertical:
|
||||||
|
return 0;
|
||||||
|
case PlasmaCore.Types.Horizontal:
|
||||||
|
return height;
|
||||||
|
default:
|
||||||
|
return units.gridUnit * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout.minimumHeight: {
|
||||||
|
switch (plasmoid.formFactor) {
|
||||||
|
case PlasmaCore.Types.Vertical:
|
||||||
|
return width;
|
||||||
|
case PlasmaCore.Types.Horizontal:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return units.gridUnit * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source: plasmoid.icon ? plasmoid.icon : "plasma"
|
||||||
|
active: mouseArea.containsMouse
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouseArea
|
||||||
|
|
||||||
|
property bool wasExpanded: false
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onPressed: wasExpanded = plasmoid.expanded
|
||||||
|
onClicked: plasmoid.expanded = !wasExpanded
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,3 +15,7 @@ for (var j = 0; j < desktopsArray.length; j++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
desktopsForActivity(id)[0].addWidget("org.kde.phone.notifications");
|
desktopsForActivity(id)[0].addWidget("org.kde.phone.notifications");
|
||||||
|
|
||||||
|
var panel = new Panel("org.kde.phone.panel");
|
||||||
|
panel.addWidget("org.kde.plasma.battery");
|
||||||
|
panel.addWidget("org.kde.plasma.devicenotifier");
|
||||||
|
|
@ -55,13 +55,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
|
||||||
id: timeSource
|
|
||||||
engine: "time"
|
|
||||||
connectedSources: ["Local"]
|
|
||||||
interval: 60 * 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
OfonoManager {
|
OfonoManager {
|
||||||
id: ofonoManager
|
id: ofonoManager
|
||||||
onAvailableChanged: {
|
onAvailableChanged: {
|
||||||
|
|
@ -104,39 +97,6 @@ Item {
|
||||||
modemPath: ofonoManager.modems.length > 0 ? ofonoManager.modems[0] : ""
|
modemPath: ofonoManager.modems.length > 0 ? ofonoManager.modems[0] : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
OfonoNetworkRegistration {
|
|
||||||
id: netreg
|
|
||||||
Component.onCompleted: {
|
|
||||||
netreg.scan()
|
|
||||||
updateStrengthIcon()
|
|
||||||
}
|
|
||||||
|
|
||||||
onNetworkOperatorsChanged : {
|
|
||||||
console.log("operators :"+netreg.currentOperator["Name"].toString())
|
|
||||||
}
|
|
||||||
modemPath: ofonoManager.modems.length ? ofonoManager.modems[0] : ""
|
|
||||||
function updateStrengthIcon() {
|
|
||||||
if (netreg.strength >= 100) {
|
|
||||||
strengthIcon.source = "network-mobile-100";
|
|
||||||
} else if (netreg.strength >= 80) {
|
|
||||||
strengthIcon.source = "network-mobile-80";
|
|
||||||
} else if (netreg.strength >= 60) {
|
|
||||||
strengthIcon.source = "network-mobile-60";
|
|
||||||
} else if (netreg.strength >= 40) {
|
|
||||||
strengthIcon.source = "network-mobile-40";
|
|
||||||
} else if (netreg.strength >= 20) {
|
|
||||||
strengthIcon.source = "network-mobile-20";
|
|
||||||
} else {
|
|
||||||
strengthIcon.source = "network-mobile-0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onStrengthChanged: {
|
|
||||||
console.log("Strength changed to " + netreg.strength)
|
|
||||||
updateStrengthIcon()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OfonoNetworkOperator {
|
OfonoNetworkOperator {
|
||||||
id: netop
|
id: netop
|
||||||
}
|
}
|
||||||
|
|
@ -192,123 +152,6 @@ Item {
|
||||||
source: simManager.pinRequired != OfonoSimManager.NoPin ? Qt.resolvedUrl("Pin.qml") : ""
|
source: simManager.pinRequired != OfonoSimManager.NoPin ? Qt.resolvedUrl("Pin.qml") : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.ColorScope {
|
|
||||||
id: statusPanel
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
height: units.iconSizes.small
|
|
||||||
z: 2
|
|
||||||
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
parent: slidingPanel.visible ? panelContents : statusPanel
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
height: units.iconSizes.small
|
|
||||||
color: PlasmaCore.ColorScope.backgroundColor
|
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
|
||||||
id: strengthIcon
|
|
||||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
width: units.iconSizes.small
|
|
||||||
height: width
|
|
||||||
}
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
anchors {
|
|
||||||
left: strengthIcon.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
text: netreg.strength + "% " + netreg.name
|
|
||||||
color: PlasmaCore.ColorScope.textColor
|
|
||||||
font.pixelSize: parent.height / 2
|
|
||||||
}
|
|
||||||
PlasmaComponents.Label {
|
|
||||||
id: clock
|
|
||||||
anchors.fill: parent
|
|
||||||
text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm")
|
|
||||||
color: PlasmaCore.ColorScope.textColor
|
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
|
||||||
verticalAlignment: Qt.AlignVCenter
|
|
||||||
font.pixelSize: height / 2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PlasmaWorkspace.BatteryIcon {
|
|
||||||
id: batteryIcon
|
|
||||||
anchors {
|
|
||||||
right: parent.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
width: units.iconSizes.small
|
|
||||||
height: width
|
|
||||||
hasBattery: pmSource.data["Battery"]["Has Battery"]
|
|
||||||
batteryType: "Phone"
|
|
||||||
percent: pmSource.data["Battery0"] ? pmSource.data["Battery0"]["Percent"] : 0
|
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
|
||||||
id: pmSource
|
|
||||||
engine: "powermanagement"
|
|
||||||
connectedSources: sources
|
|
||||||
onSourceAdded: {
|
|
||||||
disconnectSource(source);
|
|
||||||
connectSource(source);
|
|
||||||
}
|
|
||||||
onSourceRemoved: {
|
|
||||||
disconnectSource(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Rectangle {
|
|
||||||
height: units.smallSpacing/2
|
|
||||||
color: PlasmaCore.ColorScope.highlightColor
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MouseArea {
|
|
||||||
property int oldMouseY: 0
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
enabled: !dialerOverlay.item.visible
|
|
||||||
onPressed: {
|
|
||||||
oldMouseY = mouse.y;
|
|
||||||
slidingPanel.visible = true;
|
|
||||||
}
|
|
||||||
onPositionChanged: {
|
|
||||||
//var factor = (mouse.y - oldMouseY > 0) ? (1 - Math.max(0, (slidingArea.y + slidingPanel.overShoot) / slidingPanel.overShoot)) : 1
|
|
||||||
var factor = 1;
|
|
||||||
print(slidingPanel.offset +" "+ slidingPanel.height)
|
|
||||||
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor;
|
|
||||||
oldMouseY = mouse.y;
|
|
||||||
}
|
|
||||||
onReleased: slidingPanel.updateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SlidingPanel {
|
|
||||||
id: slidingPanel
|
|
||||||
width: homescreen.width
|
|
||||||
height: homescreen.height
|
|
||||||
contents: Item {
|
|
||||||
id: panelContents
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
//configure the view behavior
|
//configure the view behavior
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
|
|
||||||
41
shell/contents/views/Panel.qml
Normal file
41
shell/contents/views/Panel.qml
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
visible: false //adjust borders is run during setup. We want to avoid painting till completed
|
||||||
|
|
||||||
|
property Item containment
|
||||||
|
|
||||||
|
onContainmentChanged: {
|
||||||
|
containment.parent = root;
|
||||||
|
containment.visible = true;
|
||||||
|
containment.anchors.fill = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue