Commit c0cf97a9 authored by Jan Grulich's avatar Jan Grulich
Browse files

Merge branch details

parents c48056d2 5f1550ba
......@@ -22,7 +22,7 @@ include(FeatureSummary)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
DBus
Designer
# Designer
Network
Test
Quick
......@@ -79,7 +79,7 @@ add_definitions(-DWITH_MODEMMANAGER_SUPPORT=${WITH_MODEMMANAGER_SUPPORT})
include_directories(${CMAKE_CURRENT_BINARY_DIR} # for config.h
${CMAKE_CURRENT_SOURCE_DIR}/libs
${CMAKE_CURRENT_SOURCE_DIR}/libs/editor/
${Qt5Designer_INCLUDE_DIRS}
# ${Qt5Designer_INCLUDE_DIRS}
${NETWORKMANAGER_INCLUDE_DIRS})
if (WITH_MODEMMANAGER_SUPPORT)
......
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/declarative/metadata.desktop.cmake
${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop
@ONLY)
install(DIRECTORY declarative/contents DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.plasma.networkmanagement)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.plasma.networkmanagement)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/declarative/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-applet-org.kde.plasma.networkmanagement.desktop)
add_subdirectory(icons)
plasma_install_package(. org.kde.plasma.networkmanagement)
/*
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -41,7 +41,7 @@ Item {
width: Math.min(parent.width, parent.height)
height: width
svg: svgIcons;
elementId: connectionIconProvider.connectionIcon
elementId: connectionIconProvider.connectionIcon;
PlasmaComponents.BusyIndicator {
id: connectingIndicator;
......
/*
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -24,7 +24,6 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.networkmanagement 0.1 as PlasmaNM
PlasmaComponents.ListItem {
id: connectionItem;
......@@ -35,13 +34,11 @@ PlasmaComponents.ListItem {
property bool visibleDetails: false;
property bool visiblePasswordDialog: false;
property int iconSize: units.iconSizes.medium;
property int baseHeight: connectionItemBase.height + padding.margins.top + padding.margins.bottom;
height: (visibleDetails || visiblePasswordDialog) ? baseHeight + expandableComponentLoader.height : baseHeight;
checked: ListView.isCurrentItem;
enabled: true;
height: if (visibleDetails || visiblePasswordDialog)
connectionItemBase.height + expandableComponentLoader.height + padding.margins.top + padding.margins.bottom;
else
connectionItemBase.height + padding.margins.top + padding.margins.bottom;
PlasmaCore.Svg {
id: svgNetworkIcons;
......@@ -53,23 +50,24 @@ PlasmaComponents.ListItem {
Item {
id: connectionItemBase;
height: Math.max(connectionSvgIcon.height, connectionNameLabel.height + connectionStatusLabel.height);
anchors {
left: parent.left;
right: parent.right;
top: parent.top;
}
height: Math.max(units.iconSizes.medium, connectionNameLabel.height + connectionStatusLabel.height);
PlasmaCore.SvgItem {
id: connectionSvgIcon;
width: iconSize;
height: width;
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
height: units.iconSizes.medium;
width: height;
svg: svgNetworkIcons;
elementId: ConnectionIcon;
}
......@@ -77,166 +75,69 @@ PlasmaComponents.ListItem {
PlasmaComponents.Label {
id: connectionNameLabel;
height: paintedHeight;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: !connectionItemMouseArea.containsMouse ? connectingIndicator.left : buttonRow.left;
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
bottom: connectionSvgIcon.verticalCenter
}
text: ItemUniqueName;
height: paintedHeight;
elide: Text.ElideRight;
font.weight: ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal;
font.italic: ConnectionState == PlasmaNM.Enums.Activating ? true : false;
text: ItemUniqueName;
}
PlasmaComponents.Label {
id: connectionStatusLabel;
height: paintedHeight;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: !connectionItemMouseArea.containsMouse ? connectingIndicator.left : buttonRow.left;
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
top: connectionNameLabel.bottom;
}
height: paintedHeight;
elide: Text.ElideRight;
font.pointSize: theme.smallestFont.pointSize;
opacity: 0.6
opacity: 0.6;
text: itemText();
elide: Text.ElideRight;
}
PlasmaComponents.BusyIndicator {
id: connectingIndicator;
width: iconSize;
height: width;
anchors {
right: parent.right;
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
rightMargin: padding.margins.right;
verticalCenter: parent.verticalCenter;
verticalCenter: connectionSvgIcon.verticalCenter;
}
height: units.iconSizes.medium;
width: height;
running: ConnectionState == PlasmaNM.Enums.Activating;
visible: running && !connectionItemMouseArea.containsMouse;
visible: running && !stateChangeButton.visible;
}
Row {
id: buttonRow;
PlasmaComponents.Button {
id: stateChangeButton;
anchors {
verticalCenter: parent.verticalCenter;
right: parent.right;
rightMargin: padding.margins.right;
verticalCenter: connectionSvgIcon.verticalCenter;
}
spacing: 8;
opacity: connectionItemMouseArea.containsMouse ? 1 : 0
opacity: connectionItem.containsMouse ? 1 : 0
visible: opacity != 0
Behavior on opacity { NumberAnimation { duration: units.shortDuration } }
PlasmaCore.SvgItem {
id: configureButton;
height: iconSize;
width: Uuid ? height: 0;
anchors {
verticalCenter: parent.verticalCenter;
}
svg: svgNetworkIcons;
elementId: configureButtonMouse.containsMouse ? "edit-hover" : "edit";
MouseArea {
id: configureButtonMouse;
anchors {
bottom: parent.bottom;
left: parent.left;
right: parent.right;
top: parent.top;
bottomMargin: -4;
leftMargin: -4;
rightMargin: -4;
topMargin: -4;
}
hoverEnabled: true;
onClicked: {
handler.editConnection(Uuid);
}
}
}
PlasmaCore.SvgItem {
id: openDetailsButton;
height: iconSize;
width: height;
anchors {
verticalCenter: parent.verticalCenter;
}
svg: svgNetworkIcons;
elementId: openDetailsButtonMouse.containsMouse ? "showinfo-hover" : "showinfo";
MouseArea {
id: openDetailsButtonMouse;
anchors {
bottom: parent.bottom;
left: parent.left;
right: parent.right;
top: parent.top;
margins: -4;
}
hoverEnabled: true;
onClicked: {
visiblePasswordDialog = false;
visibleDetails = !visibleDetails;
}
}
}
text: (ConnectionState == PlasmaNM.Enums.Deactivated) ? i18n("Connect") : i18n("Disconnect");
PlasmaComponents.Button {
id: stateChangeButton;
anchors {
verticalCenter: parent.verticalCenter;
}
text: if (ConnectionState == PlasmaNM.Enums.Deactivated)
i18n("Connect");
else
i18n("Disconnect");
onClicked: {
visibleDetails = false;
if (Uuid || !predictableWirelessPassword || visiblePasswordDialog) {
if (ConnectionState == PlasmaNM.Enums.Deactivated) {
if (!predictableWirelessPassword && !Uuid) {
handler.addAndActivateConnection(DevicePath, SpecificPath);
} else if (visiblePasswordDialog) {
handler.addAndActivateConnection(DevicePath, SpecificPath, expandableComponentLoader.item.password);
visiblePasswordDialog = false;
} else {
handler.activateConnection(ConnectionPath, DevicePath, SpecificPath);
}
} else {
handler.deactivateConnection(ConnectionPath, DevicePath);
}
} else if (predictableWirelessPassword) {
visiblePasswordDialog = true;
}
}
}
}
}
MouseArea {
id: connectionItemMouseArea;
Behavior on opacity { NumberAnimation { duration: units.shortDuration } }
anchors {
fill: parent;
onClicked: changeState();
}
hoverEnabled: true;
propagateComposedEvents: true
}
Loader {
......@@ -254,53 +155,92 @@ PlasmaComponents.ListItem {
id: detailsComponent;
Item {
height: childrenRect.height + padding.margins.top;
height: childrenRect.height + padding.margins.bottom;
PlasmaCore.SvgItem {
id: detailsSeparator;
height: lineSvg.elementSize("horizontal-line").height;
width: parent.width;
anchors {
left: parent.left;
right: parent.right;
top: parent.top;
}
elementId: "horizontal-line";
height: lineSvg.elementSize("horizontal-line").height;
width: parent.width;
elementId: "horizontal-line";
svg: PlasmaCore.Svg {
id: lineSvg;
imagePath: "widgets/line";
}
}
Item {
id: detailsContent;
height: detailsText.height;
Column {
id: details;
anchors {
left: parent.left;
leftMargin: units.iconSizes.medium;
right: parent.right;
top: detailsSeparator.bottom;
topMargin: padding.margins.top;
}
TextEdit {
id: detailsText;
Repeater {
id: repeater;
property int longestString: 0;
model: ConnectionDetails.length/2;
Item {
anchors {
left: parent.left;
right: parent.right;
topMargin: padding.margins.top;
}
height: Math.max(detailNameLabel.height, detailValueLabel.height);
PlasmaComponents.Label {
id: detailNameLabel;
anchors {
left: parent.left;
leftMargin: repeater.longestString - paintedWidth + padding.margins.left;
verticalCenter: parent.verticalCenter;
}
height: paintedHeight;
font.pointSize: theme.smallestFont.pointSize;
horizontalAlignment: Text.AlignRight;
opacity: 0.6;
text: "<b>" + ConnectionDetails[index*2] + "</b>: &nbsp";
Component.onCompleted: {
if (paintedWidth > repeater.longestString) {
repeater.longestString = paintedWidth;
}
}
}
height: implicitHeight;
anchors {
left: parent.left;
right: parent.right;
top: parent.top;
PlasmaComponents.Label {
id: detailValueLabel;
anchors {
left: detailNameLabel.right;
right: parent.right;
verticalCenter: parent.verticalCenter;
}
height: paintedHeight;
elide: Text.ElideRight;
font.pointSize: theme.smallestFont.pointSize;
opacity: 0.6;
text: ConnectionDetails[(index*2)+1];
textFormat: Text.StyledText;
}
}
color: theme.textColor;
readOnly: true;
selectByMouse: true;
wrapMode: TextEdit.WordWrap;
textFormat: Text.RichText;
text: ConnectionDetails;
}
}
}
......@@ -358,6 +298,7 @@ PlasmaComponents.ListItem {
right: parent.right;
top: passwordInput.bottom;
}
checked: false;
text: i18n("Show password");
}
......@@ -372,12 +313,16 @@ PlasmaComponents.ListItem {
},
State {
name: "expanded";
when: visibleDetails || visiblePasswordDialog;
name: "expandedDetails";
when: visibleDetails;
StateChangeScript { script: createContent(); }
},
State {
name: "expandedPasswordDialog";
when: visiblePasswordDialog;
StateChangeScript { script: createContent(); }
PropertyChanges { target: openDetailsButton; visible: true; }
PropertyChanges { target: stateChangeButton; visible: true; }
PropertyChanges { target: connectionItem; enabled: false; }
PropertyChanges { target: stateChangeButton; opacity: 1; }
}
]
......@@ -390,6 +335,26 @@ PlasmaComponents.ListItem {
}
}
function changeState() {
visibleDetails = false;
if (Uuid || !predictableWirelessPassword || visiblePasswordDialog) {
if (ConnectionState == PlasmaNM.Enums.Deactivated) {
if (!predictableWirelessPassword && !Uuid) {
handler.addAndActivateConnection(DevicePath, SpecificPath);
} else if (visiblePasswordDialog) {
handler.addAndActivateConnection(DevicePath, SpecificPath, expandableComponentLoader.item.password);
visiblePasswordDialog = false;
} else {
handler.activateConnection(ConnectionPath, DevicePath, SpecificPath);
}
} else {
handler.deactivateConnection(ConnectionPath, DevicePath);
}
} else if (predictableWirelessPassword) {
visiblePasswordDialog = true;
}
}
function itemText() {
if (ConnectionState == PlasmaNM.Enums.Activating) {
if (Type == PlasmaNM.Enums.Vpn)
......@@ -418,4 +383,22 @@ PlasmaComponents.ListItem {
}
}
}
onStateChanged: {
if (state == "expandedPasswordDialog" || state == "expandedDetails") {
ListView.view.currentIndex = index;
}
}
onClicked: {
if (visiblePasswordDialog) {
visiblePasswordDialog = false;
} else {
visibleDetails = !visibleDetails;
}
if (!visibleDetails) {
ListView.view.currentIndex = -1;
}
}
}
/*
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -26,22 +26,23 @@ PlasmaComponents.ListItem {
property alias text: headerLabel.text;
height: headerLabel.height + padding.margins.top + padding.margins.bottom;
sectionDelegate: true;
anchors {
left: parent.left;
right: parent.right;
}
height: headerLabel.height + padding.margins.top + padding.margins.bottom;
sectionDelegate: true;
PlasmaComponents.Label {
id: headerLabel
id: headerLabel;
height: paintedHeight;
anchors {
horizontalCenter: parent.horizontalCenter;
verticalCenter: parent.verticalCenter;
}
height: paintedHeight;
font.weight: Font.DemiBold;
}
}
/*
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -20,13 +20,13 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as Components
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.networkmanagement 0.1 as PlasmaNM
FocusScope {
PlasmaNM.Handler {
id: handler;
id: handler;
}
PlasmaNM.NetworkModel {
......@@ -41,6 +41,7 @@ FocusScope {
PlasmaCore.FrameSvgItem {
id: padding
imagePath: "widgets/viewitem"
prefix: "hover"
opacity: 0
......@@ -66,19 +67,13 @@ FocusScope {
right: parent.right;
top: toolbar.bottom;
}
clip: true
model: appletProxyModel;
currentIndex: -1;
interactive: true;
boundsBehavior: Flickable.StopAtBounds;
section.property: showSections ? "Section" : "";
section.delegate: Header { text: section }
delegate: ConnectionItem {
onStateChanged: {
if (state == "expanded") {
connectionView.currentIndex = index;
}
}
}
delegate: ConnectionItem { }
}
}
......@@ -38,17 +38,23 @@ Item {
id: svgNetworkIcons;
multipleImages: true;
imagePath: "icons/plasma-networkmanagement";
imagePath: "icons/network";
}
PlasmaComponents.CheckBox {
id: switchButtonCheckbox;
anchors {
bottomMargin: padding.margins.bottom
left: parent.left;
leftMargin: padding.margins.right;
topMargin: padding.margins.top
verticalCenter: parent.verticalCenter;
}
onClicked: {
switchButton.clicked();
}
}
PlasmaCore.SvgItem {
......@@ -59,18 +65,7 @@ Item {
leftMargin: padding.margins.left;
verticalCenter: parent.verticalCenter;
}
svg: svgNetworkIcons;
}
MouseArea {