[TextField] Allow disabling reveal password button through KIOSK restriction
This introduces a new lineedit_reveal_password restriction (similar to lineedit_text_completion) that disables the reveal password button on Plasma text fields, like the lock screen and WiFi password inputs. Differential Revision: https://phabricator.kde.org/D3654
This commit is contained in:
parent
eb81b3f162
commit
a7ccca25ba
@ -22,7 +22,7 @@ import QtQuick 2.1
|
||||
import QtQuick.Controls 1.2 as QtControls
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import QtQuick.Controls.Styles.Plasma 2.0 as Styles
|
||||
|
||||
import org.kde.kconfig 1.0
|
||||
|
||||
/**
|
||||
* A plasma theme based text field widget.
|
||||
@ -45,6 +45,10 @@ QtControls.TextField {
|
||||
*/
|
||||
property bool revealPasswordButtonShown: false
|
||||
|
||||
// this takes into account kiosk restriction
|
||||
readonly property bool __effectiveRevealPasswordButtonShown: revealPasswordButtonShown
|
||||
&& KAuthorized.authorize("lineedit_reveal_password")
|
||||
|
||||
//Deprecated/unsupported api
|
||||
/**
|
||||
* type: string
|
||||
@ -88,10 +92,10 @@ QtControls.TextField {
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
id: showPasswordButton
|
||||
source: revealPasswordButtonShown ? (textField.echoMode === TextInput.Normal ? "hint" : "visibility") : ""
|
||||
source: __effectiveRevealPasswordButtonShown ? (textField.echoMode === TextInput.Normal ? "hint" : "visibility") : ""
|
||||
height: Math.max(textField.height * 0.8, units.iconSizes.small)
|
||||
width: height
|
||||
opacity: (textField.length > 0 && revealPasswordButtonShown && textField.enabled) ? 1 : 0
|
||||
opacity: (textField.length > 0 && __effectiveRevealPasswordButtonShown && textField.enabled) ? 1 : 0
|
||||
visible: opacity > 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
|
@ -74,7 +74,7 @@ QtQuickControlStyle.TextFieldStyle {
|
||||
var actionIconSize = Math.max(textField.height * 0.8, units.iconSizes.small);
|
||||
//actionCount is an int of the number of items
|
||||
var actionCount = (control.hasOwnProperty("clearButtonShown") && control.clearButtonShown) +
|
||||
(control.hasOwnProperty("revealPasswordButtonShown") && control.revealPasswordButtonShown);
|
||||
(control.hasOwnProperty("__effectiveRevealPasswordButtonShown") && control.__effectiveRevealPasswordButtonShown);
|
||||
return base.margins.right + (actionIconSize * actionCount) + (actionCount > 0 ? units.smallSpacing : 0);
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user