Commit c1ff8b3a authored by Harald Sitter's avatar Harald Sitter 🏳🌈
Browse files

only enable guest checkbox if the smb.conf allows it

uses new ksambshare to check guest configuration and disable the
checkbox if guest support is enabled. also shows an info label
explaining why the box is disabled

BUG: 425203
FIXED-IN: 20.12
parent d0fecad4
...@@ -116,7 +116,9 @@ when the Share access rules would allow it.`) ...@@ -116,7 +116,9 @@ when the Share access rules would allow it.`)
} }
QQC2.CheckBox { QQC2.CheckBox {
id: allowGuestBox
text: i18nc("@option:check", "Allow guests") text: i18nc("@option:check", "Allow guests")
enabled: sambaPlugin.shareContext.canEnableGuest
checked: sambaPlugin.shareContext.guestEnabled checked: sambaPlugin.shareContext.guestEnabled
onToggled: { onToggled: {
sambaPlugin.shareContext.guestEnabled = checked sambaPlugin.shareContext.guestEnabled = checked
...@@ -124,6 +126,15 @@ when the Share access rules would allow it.`) ...@@ -124,6 +126,15 @@ when the Share access rules would allow it.`)
} }
} }
QQC2.Label {
Layout.fillWidth: true
enabled: false // looks more visually connected if both are disabled
visible: !allowGuestBox.enabled
text: i18nc("@label", "Guest access is disabled by the system's Samba configuration.")
wrapMode: Text.Wrap
font: theme.smallestFont
}
// TODO: this could benefit form some splitting. This is half the file. // TODO: this could benefit form some splitting. This is half the file.
QQC2.ScrollView { QQC2.ScrollView {
id: scroll id: scroll
......
...@@ -42,6 +42,7 @@ class ShareContext : public QObject ...@@ -42,6 +42,7 @@ class ShareContext : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool canEnableGuest READ canEnableGuest CONSTANT)
Q_PROPERTY(bool guestEnabled READ guestEnabled WRITE setGuestEnabled NOTIFY guestEnabledChanged) Q_PROPERTY(bool guestEnabled READ guestEnabled WRITE setGuestEnabled NOTIFY guestEnabledChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(int maximumNameLength READ maximumNameLength CONSTANT) Q_PROPERTY(int maximumNameLength READ maximumNameLength CONSTANT)
...@@ -65,6 +66,11 @@ public: ...@@ -65,6 +66,11 @@ public:
Q_EMIT enabledChanged(); Q_EMIT enabledChanged();
} }
bool canEnableGuest()
{
return KSambaShare::instance()->areGuestsAllowed();
}
bool guestEnabled() const bool guestEnabled() const
{ {
// WTF is that enum even... // WTF is that enum even...
......
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