Commit 52a41323 authored by Jan Grulich's avatar Jan Grulich
Browse files

Change details layout

parent dff0b0a6
......@@ -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)
......@@ -90,7 +90,7 @@ add_subdirectory(applet)
add_subdirectory(editor)
add_subdirectory(kded)
add_subdirectory(libs)
add_subdirectory(settings)
# add_subdirectory(settings)
add_subdirectory(vpn)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
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
......
/*
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: Math.max(units.iconSizes.medium, connectionNameLabel.height + connectionStatusLabel.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;
......@@ -50,193 +47,85 @@ PlasmaComponents.ListItem {
imagePath: "icons/network";
}
Item {
id: connectionItemBase;
height: Math.max(connectionSvgIcon.height, connectionNameLabel.height + connectionStatusLabel.height);
PlasmaCore.SvgItem {
id: connectionSvgIcon;
anchors {
left: parent.left;
right: parent.right;
left: parent.left
top: parent.top;
}
PlasmaCore.SvgItem {
id: connectionSvgIcon;
width: iconSize;
height: width;
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
svg: svgNetworkIcons;
elementId: ConnectionIcon;
}
height: units.iconSizes.medium;
width: height;
svg: svgNetworkIcons;
elementId: ConnectionIcon;
}
PlasmaComponents.Label {
id: connectionNameLabel;
PlasmaComponents.Label {
id: connectionNameLabel;
height: paintedHeight;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: !connectionItemMouseArea.containsMouse ? connectingIndicator.left : buttonRow.left;
bottom: connectionSvgIcon.verticalCenter
}
text: ItemUniqueName;
elide: Text.ElideRight;
font.weight: ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal;
font.italic: ConnectionState == PlasmaNM.Enums.Activating ? true : false;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
bottom: connectionSvgIcon.verticalCenter
}
PlasmaComponents.Label {
id: connectionStatusLabel;
height: paintedHeight;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: !connectionItemMouseArea.containsMouse ? connectingIndicator.left : buttonRow.left;
top: connectionNameLabel.bottom;
}
font.pointSize: theme.smallestFont.pointSize;
opacity: 0.6
text: itemText();
elide: Text.ElideRight;
}
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.BusyIndicator {
id: connectingIndicator;
PlasmaComponents.Label {
id: connectionStatusLabel;
width: iconSize;
height: width;
anchors {
right: parent.right;
rightMargin: padding.margins.right;
verticalCenter: parent.verticalCenter;
}
running: ConnectionState == PlasmaNM.Enums.Activating;
visible: running && !connectionItemMouseArea.containsMouse;
anchors {
left: connectionSvgIcon.right;
leftMargin: padding.margins.left;
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
top: connectionNameLabel.bottom;
}
Row {
id: buttonRow;
anchors {
verticalCenter: parent.verticalCenter;
right: parent.right;
}
spacing: 8;
opacity: connectionItemMouseArea.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;
}
}
}
height: paintedHeight;
elide: Text.ElideRight;
font.pointSize: theme.smallestFont.pointSize;
opacity: 0.6;
text: itemText();
}
PlasmaComponents.Button {
id: stateChangeButton;
PlasmaComponents.BusyIndicator {
id: connectingIndicator;
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;
}
}
}
anchors {
right: stateChangeButton.visible ? stateChangeButton.left : parent.right;
rightMargin: padding.margins.right;
verticalCenter: connectionSvgIcon.verticalCenter;
}
height: units.iconSizes.medium;
width: height;
running: ConnectionState == PlasmaNM.Enums.Activating;
visible: running && !stateChangeButton.visible;
}
MouseArea {
id: connectionItemMouseArea;
PlasmaComponents.Button {
id: stateChangeButton;
anchors {
fill: parent;
right: parent.right;
rightMargin: padding.margins.right;
verticalCenter: connectionSvgIcon.verticalCenter;
}
hoverEnabled: true;
propagateComposedEvents: true
opacity: connectionItem.containsMouse ? 1 : 0
visible: opacity != 0
text: (ConnectionState == PlasmaNM.Enums.Deactivated) ? i18n("Connect") : i18n("Disconnect");
Behavior on opacity { NumberAnimation { duration: units.shortDuration } }
onClicked: changeState();
}
Loader {
......@@ -245,7 +134,7 @@ PlasmaComponents.ListItem {
anchors {
left: parent.left;
right: parent.right;
top: connectionItemBase.bottom;
top: connectionSvgIcon.bottom;
topMargin: padding.margins.top;
}
}
......@@ -254,53 +143,68 @@ 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;
PlasmaComponents.Button {
id: configureButton;
anchors {
right: parent.right;
rightMargin: padding.margins.right;
top: detailsSeparator.bottom;
topMargin: padding.margins.top;
}
height: detailsText.height;
opacity: connectionItem.containsMouse && Uuid ? 1 : 0
visible: opacity != 0
text: i18n("Configure");
Behavior on opacity { NumberAnimation { duration: units.shortDuration } }
}
Column {
anchors {
left: parent.left;
right: parent.right;
leftMargin: units.iconSizes.medium + padding.margins.left;
right: configureButton.visible ? configureButton.left : parent.right;
top: detailsSeparator.bottom;
topMargin: padding.margins.top;
}
TextEdit {
id: detailsText;
Repeater {
model: ConnectionDetails.length/2;
PlasmaComponents.Label {
anchors {
left: parent.left;
right: parent.right;
topMargin: padding.margins.top;
}
height: implicitHeight;
anchors {
left: parent.left;
right: parent.right;
top: parent.top;
elide: (index > 2 ) ? Text.ElideNone : Text.ElideRight;
height: paintedHeight;
font.pointSize: theme.smallestFont.pointSize;
opacity: 0.6;
textFormat: Text.StyledText;
text: "<b>" + ConnectionDetails[index*2] + "</b>: " + ConnectionDetails[(index*2)+1];
}
color: theme.textColor;
readOnly: true;
selectByMouse: true;
wrapMode: TextEdit.WordWrap;
textFormat: Text.RichText;
text: ConnectionDetails;
}
}
}
......@@ -358,6 +262,7 @@ PlasmaComponents.ListItem {
right: parent.right;
top: passwordInput.bottom;
}
checked: false;
text: i18n("Show password");
}
......@@ -372,12 +277,20 @@ PlasmaComponents.ListItem {
},
State {
name: "expanded";
when: visibleDetails || visiblePasswordDialog;
name: "expandedDetails";
when: visibleDetails;
StateChangeScript { script: createContent(); }
// PropertyChanges { target: stateChangeButton; opacity: 1 }
// PropertyChanges { target: connectionItem; height: connectionView.height }
// PropertyChanges { target: connectionItem.ListView.view; explicit: true; contentY: connectionItem.y }
// PropertyChanges { target: connectionItem.ListView.view; interactive: false }
},
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 +303,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 +351,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;