Commit 74697d0c authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Folder View] Honor editable_desktop_icons KIOSK restriction

Disallows moving desktop icons, basically force-enables the "positions locked" option

Differential Revision: https://phabricator.kde.org/D15160
parent 2d008a5b
......@@ -27,6 +27,7 @@ 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.kquickcontrolsaddons 2.0
import org.kde.kconfig 1.0 // for KAuthorized
import org.kde.private.desktopcontainment.desktop 0.1 as Desktop
import org.kde.private.desktopcontainment.folder 0.1 as Folder
......@@ -43,7 +44,7 @@ Item {
property alias cfg_useCustomIcon: useCustomIcon.checked
property alias cfg_arrangement: arrangement.currentIndex
property alias cfg_alignment: alignment.currentIndex
property alias cfg_locked: locked.checked
property bool cfg_locked
property alias cfg_sortMode: sortMode.mode
property alias cfg_sortDesc: sortDesc.checked
property alias cfg_sortDirsFirst: sortDirsFirst.checked
......@@ -56,6 +57,8 @@ Item {
property alias cfg_iconSize: iconSize.value
property alias cfg_textLines: textLines.value
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
IconDialog {
id: iconDialog
onIconNameChanged: cfg_icon = iconName || "folder"
......@@ -194,6 +197,14 @@ Item {
Layout.columnSpan: 3
visible: ("containmentType" in plasmoid)
checked: cfg_locked || lockedByKiosk
enabled: !lockedByKiosk
onCheckedChanged: {
if (!lockedByKiosk) {
cfg_locked = checked;
}
}
text: i18n("Lock in place")
}
......
......@@ -21,6 +21,7 @@ import QtQuick 2.0
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.kconfig 1.0 // for KAuthorized
import org.kde.private.desktopcontainment.folder 0.1 as Folder
......@@ -39,6 +40,8 @@ Item {
property alias overflowing: folderView.overflowing
property alias flow: folderView.flow
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
function updateContextualActions() {
folderView.model.updateActions();
......@@ -101,6 +104,8 @@ Item {
showLockAction: isContainment
showIconSizeActions: !root.useListViewMode
lockedEnabled: !lockedByKiosk
onArrangementChanged: {
plasmoid.configuration.arrangement = arrangement;
}
......@@ -114,7 +119,9 @@ Item {
}
onLockedChanged: {
plasmoid.configuration.locked = locked;
if (!lockedByKiosk) {
plasmoid.configuration.locked = locked;
}
}
onSortModeChanged: {
......@@ -137,7 +144,7 @@ Item {
arrangement = plasmoid.configuration.arrangement;
alignment = plasmoid.configuration.alignment;
previews = plasmoid.configuration.previews;
locked = plasmoid.configuration.locked;
locked = plasmoid.configuration.locked || lockedByKiosk;
sortMode = plasmoid.configuration.sortMode;
sortDesc = plasmoid.configuration.sortDesc;
sortDirsFirst = plasmoid.configuration.sortDirsFirst;
......@@ -236,7 +243,7 @@ Item {
isRootView: true
url: plasmoid.configuration.url
locked: (plasmoid.configuration.locked || !isContainment)
locked: (plasmoid.configuration.locked || !isContainment || lockedByKiosk)
filterMode: plasmoid.configuration.filterMode
filterPattern: plasmoid.configuration.filterPattern
filterMimeTypes: plasmoid.configuration.filterMimeTypes
......
......@@ -213,6 +213,19 @@ void ViewPropertiesMenu::setLocked(bool locked)
}
}
bool ViewPropertiesMenu::lockedEnabled() const
{
return m_locked->isEnabled();
}
void ViewPropertiesMenu::setLockedEnabled(bool enabled)
{
if (m_locked->isEnabled() != enabled) {
m_locked->setEnabled(enabled);
emit lockedEnabledChanged();
}
}
int ViewPropertiesMenu::sortMode() const
{
return m_sortMode->checkedAction()->data().toInt();
......
......@@ -40,6 +40,7 @@ class FOLDERPLUGIN_TESTS_EXPORT ViewPropertiesMenu : public QObject
Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
Q_PROPERTY(bool previews READ previews WRITE setPreviews NOTIFY previewsChanged)
Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged)
Q_PROPERTY(bool lockedEnabled READ lockedEnabled WRITE setLockedEnabled NOTIFY lockedEnabledChanged)
Q_PROPERTY(int sortMode READ sortMode WRITE setSortMode NOTIFY sortModeChanged)
Q_PROPERTY(bool sortDesc READ sortDesc WRITE setSortDesc NOTIFY sortDescChanged)
Q_PROPERTY(bool sortDirsFirst READ sortDirsFirst WRITE setSortDirsFirst NOTIFY sortDirsFirstChanged)
......@@ -72,6 +73,9 @@ class FOLDERPLUGIN_TESTS_EXPORT ViewPropertiesMenu : public QObject
bool locked() const;
void setLocked(bool locked);
bool lockedEnabled() const;
void setLockedEnabled(bool lockedEnabled);
int sortMode() const;
void setSortMode(int sortMode);
......@@ -92,6 +96,7 @@ class FOLDERPLUGIN_TESTS_EXPORT ViewPropertiesMenu : public QObject
void alignmentChanged() const;
void previewsChanged() const;
void lockedChanged() const;
void lockedEnabledChanged() const;
void sortModeChanged() const;
void sortDescChanged() const;
void sortDirsFirstChanged() const;
......
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