Commit b878a64c authored by Nate Graham's avatar Nate Graham 💤
Browse files

[applets/devicenotifier] Move all settings into main UI itself and rename

Right now the Device Notifier applet has two settings: what kind of
devices to show, and whether or not to open on new device attachment.

My sense is that nobody knows that these options exist because they're
hidden away in a config window that you can only access by
right-clicking on the item in the system tray.

Furthermore, the setting for what kind of devices to show is more useful
than we give it credit for; when set to "All devices", the applet functions
as an always-visible way to access all of the machine's disks. This is
quite handy.

Accordingly, this commit removes the config window and moves all of the
settings into the main UI of the applet using PlasmoidHeaders--one
header and one footer, exactly like the plasma-pa applet.

With this change, the "Show all devices" feature becomes discoverable:
when you plug in a flash drive or whatever, the applet will pop open,
showing you the combobox that chooses what it will display. In this moment,
you can notice it, play with it, and configure it to show all devices if
you'd like.

Accordingly again, the name of the applet is renamed to "Disks &
Devices" since "Device Notifier" is not an accurate name. It was only
ever accurate when using the applet's default settings, and now that
non-default settings are made more discoverable, it feels appropriate
to give it a more generally appropriate name.
parent 01f68ba5
/*
* Copyright 2013 Bhushan Shah <bhush94@gmail.com>
*
* 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 org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("General")
icon: "plasma"
source: "configGeneral.qml"
}
}
......@@ -31,21 +31,102 @@ import org.kde.plasma.components 2.0 as PlasmaComponents // For Highlight
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
MouseArea {
PlasmaComponents3.Page {
id: fullRep
property bool spontaneousOpen: false
hoverEnabled: true
Layout.minimumWidth: units.gridUnit * 12
Layout.minimumHeight: units.gridUnit * 12
header: PlasmaExtras.PlasmoidHeading {
id: headerToolbarContainer
RowLayout {
width: parent.width
PlasmaComponents3.Label {
text: i18n("Show:")
}
PlasmaComponents3.ComboBox {
Layout.preferredWidth: units.gridUnit * 11
model: ["Removable devices",
"Non-removable devices",
"All devices"
]
currentIndex: {
if (plasmoid.configuration.removableDevices) {
return 0
} else if (plasmoid.configuration.nonRemovableDevices) {
return 1
} else {
return 2
}
}
onActivated: {
switch (currentIndex) {
case 0:
plasmoid.configuration.removableDevices = true;
plasmoid.configuration.nonRemovableDevices = false;
plasmoid.configuration.allDevices = false;
break;
case 1:
plasmoid.configuration.removableDevices = false;
plasmoid.configuration.nonRemovableDevices = true;
plasmoid.configuration.allDevices = false;
break;
case 2:
plasmoid.configuration.removableDevices = false;
plasmoid.configuration.nonRemovableDevices = false;
plasmoid.configuration.allDevices = true;
break
}
}
}
Item {
Layout.fillWidth: true
}
PlasmaComponents3.ToolButton {
id: unmountAll
visible: devicenotifier.mountedRemovables > 1;
icon.name: "media-eject"
text: i18n("Remove All")
PlasmaComponents3.ToolTip {
text: i18n("Click to safely remove all devices")
}
}
// TODO: Once the automounter KCM is ported to QML, embed it in the
// config window and change the action to open the config window
PlasmaComponents3.ToolButton {
icon.name: "configure"
onClicked: plasmoid.action("openAutomounterKcm").trigger()
visible: devicenotifier.openAutomounterKcmAuthorized
Accessible.name: plasmoid.action("openAutomounterKcm").text
PlasmaComponents3.ToolTip {
text: plasmoid.action("openAutomounterKcm").text
}
}
}
}
MouseArea {
id: fullRepMouseArea
hoverEnabled: true
}
PlasmaCore.DataSource {
id: userActivitySource
engine: "powermanagement"
connectedSources: "UserActivity"
property int polls: 0
//poll only on plasmoid expanded
interval: !fullRep.containsMouse && !fullRep.Window.active && spontaneousOpen && plasmoid.expanded ? 3000 : 0
interval: !fullRepMouseArea.containsMouse && !fullRep.Window.active && spontaneousOpen && plasmoid.expanded ? 3000 : 0
onIntervalChanged: polls = 0;
onDataChanged: {
//only do when polling
......@@ -104,63 +185,59 @@ MouseArea {
}
}
Item {
PlasmaExtras.ScrollArea {
anchors.fill: parent
PlasmaComponents3.ToolButton {
id: unmountAll
visible: devicenotifier.mountedRemovables > 1;
anchors.right: parent.right
icon.name: "media-eject"
text: i18n("Remove all")
PlasmaComponents3.ToolTip {
text: i18n("Click to safely remove all devices")
}
}
PlasmaExtras.ScrollArea {
anchors.fill: parent
anchors.top: unmountAll.top
ListView {
id: notifierDialog
focus: true
boundsBehavior: Flickable.StopAtBounds
ListView {
id: notifierDialog
focus: true
boundsBehavior: Flickable.StopAtBounds
model: filterModel
model: filterModel
delegate: DeviceItem {
udi: DataEngineSource
}
highlight: PlasmaComponents.Highlight { }
currentIndex: devicenotifier.currentIndex
//this is needed to make SectionScroller actually work
//acceptable since one doesn't have a billion of devices
cacheBuffer: 1000
section {
property: "Type Description"
delegate: Item {
height: childrenRect.height
width: notifierDialog.width
PlasmaExtras.Heading {
level: 3
opacity: 0.6
text: section
}
delegate: DeviceItem {
udi: DataEngineSource
}
highlight: PlasmaComponents.Highlight { }
currentIndex: devicenotifier.currentIndex
//this is needed to make SectionScroller actually work
//acceptable since one doesn't have a billion of devices
cacheBuffer: 1000
section {
property: "Type Description"
delegate: Item {
height: childrenRect.height
width: notifierDialog.width
PlasmaExtras.Heading {
level: 3
opacity: 0.6
text: section
}
}
}
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (units.largeSpacing * 4)
text: i18n("No devices available")
visible: notifierDialog.count === 0 && !devicenotifier.pendingDelegateRemoval
}
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (units.largeSpacing * 4)
text: i18n("No devices available")
visible: notifierDialog.count === 0 && !devicenotifier.pendingDelegateRemoval
}
}
}
footer: PlasmaExtras.PlasmoidHeading {
id: footerToolbarContainer
location: PlasmaExtras.PlasmoidHeading.Location.Footer
PlasmaComponents3.CheckBox {
anchors.fill: parent
text: i18n("Open when new device is plugged in")
checked: plasmoid.configuration.popupOnNewDevice
onToggled: plasmoid.configuration.popupOnNewDevice = checked
}
}
}
/*
* Copyright 2013 Bhushan Shah <bhush94@gmail.com>
*
* 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.Controls 2.5
import org.kde.kirigami 2.4 as Kirigami
Item {
width: childrenRect.width
height: childrenRect.height
property alias cfg_removableDevices: removableOnly.checked
property alias cfg_nonRemovableDevices: nonRemovableOnly.checked
property alias cfg_allDevices: allDevices.checked
property alias cfg_popupOnNewDevice: autoPopup.checked
Kirigami.FormLayout {
anchors.left: parent.left
anchors.right: parent.right
RadioButton {
id: removableOnly
Kirigami.FormData.label: i18n("Show:")
text: i18n("Removable devices only")
}
RadioButton {
id: nonRemovableOnly
text: i18n("Non-removable devices only")
}
RadioButton {
id: allDevices
text: i18n("All devices")
}
CheckBox {
id: autoPopup
text: i18n("Open popup when new device is plugged in")
}
}
}
......@@ -31,7 +31,7 @@ import org.kde.kquickcontrolsaddons 2.0
Item {
id: devicenotifier
readonly property string automounterKcmName: "device_automounter_kcm"
readonly property bool openAutomounterKcmAuthorized: KCMShell.authorize("device_automounter_kcm.desktop").length > 0
property string devicesType: {
if (plasmoid.configuration.allDevices) {
......@@ -230,13 +230,13 @@ Item {
Plasmoid.status = PlasmaCore.Types.PassiveStatus;
}
if (KCMShell.authorize(devicenotifier.automounterKcmName + ".desktop").length > 0) {
if (devicenotifier.openAutomounterKcmAuthorized) {
plasmoid.setAction("openAutomounterKcm", i18nc("Open auto mounter kcm", "Configure Removable Devices"), "drive-removable-media")
}
}
function action_openAutomounterKcm() {
KCMShell.openSystemSettings(devicenotifier.automounterKcmName)
KCMShell.openSystemSettings("device_automounter_kcm")
}
Plasmoid.onExpandedChanged: {
......
[Desktop Entry]
Name=Device Notifier
Name=Disks & Devices
Name[ar]=مُخطِر الأجهزة
Name[ast]=Avisador de preseos
Name[az]=Cihaz qoşulmaları bildirişləri
......@@ -76,7 +76,7 @@ Name[wa]=Notifiaedje d' éndjin
Name[x-test]=xxDevice Notifierxx
Name[zh_CN]=设备通知器
Name[zh_TW]=裝置通知
Comment=Notifications and access for new devices
Comment=Notifications and access for devices
Comment[ar]=إخطارات ووصول الأجهزة الجديدة
Comment[az]=Yeni qoşulan cihaz bildirişləri və onlara giriş
Comment[be@latin]=Infarmavańnie j dostup da novych pryładaŭ
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment