Verified Commit e2306247 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

Fix up JavaScript code style

GIT_SILENT
parent 258f7a31
Pipeline #128094 passed with stage
in 2 minutes and 36 seconds
......@@ -32,13 +32,13 @@ PlasmaComponents.Button {
text: parent.showAccel ? accelLabel : normalLabel
onLabelChanged: {
var i = label.indexOf('&');
const i = label.indexOf('&');
if (i < 0) {
accelLabel = '<u>' + label[0] + '</u>' + label.substring(1, label.length);
accelKey = label[0].toUpperCase().charCodeAt(0);
normalLabel = label
} else {
var stringToReplace = label.substr(i, 2);
const stringToReplace = label.substr(i, 2);
accelKey = stringToReplace.toUpperCase().charCodeAt(1);
accelLabel = label.replace(stringToReplace, '<u>' + stringToReplace[1] + '</u>');
normalLabel = label.replace(stringToReplace, stringToReplace[1]);
......
......@@ -123,7 +123,7 @@ Item {
}
Keys.onPressed: {
var alt = (event.modifiers & Qt.AltModifier);
const alt = event.modifiers & Qt.AltModifier;
buttonRow.showAccel = alt;
if (alt) {
......@@ -133,11 +133,10 @@ Item {
// greeter.focus = false;
root.forceActiveFocus();
var buttons = [switchUser, unlock]
for (var b = 0; b < buttons.length; ++b) {
if (event.key == buttons[b].accelKey) {
for (const button of [switchUser, unlock]) {
if (event.key == button.accelKey) {
buttonRow.showAccel = false;
buttons[b].clicked();
button.clicked();
break;
}
}
......@@ -145,7 +144,7 @@ Item {
}
Keys.onReleased: {
buttonRow.showAccel = (event.modifiers & Qt.AltModifier)
buttonRow.showAccel = event.modifiers & Qt.AltModifier;
}
Connections {
......
......@@ -140,12 +140,12 @@ Item {
}
Keys.onPressed: {
var alt = (event.modifiers & Qt.AltModifier);
const alt = event.modifiers & Qt.AltModifier;
buttonRow.showAccel = alt;
if (alt) {
var buttons = [activateSession, newSession, cancelSession];
for (var b = 0; b < buttons.length; ++b) {
const buttons = [activateSession, newSession, cancelSession];
for (let b = 0; b < buttons.length; ++b) {
if (event.key == buttons[b].accelKey) {
buttonRow.showAccel = false;
buttons[b].clicked();
......@@ -156,6 +156,6 @@ Item {
}
Keys.onReleased: {
buttonRow.showAccel = (event.modifiers & Qt.AltModifier)
buttonRow.showAccel = event.modifiers & Qt.AltModifier;
}
}
......@@ -39,29 +39,29 @@ QtControls.StackView {
onSourceFileChanged: {
pop()
if (sourceFile) {
var props = {}
var lnfConfiguration = configDialog.lnfConfiguration
for (var key in lnfConfiguration) {
const props = {}
const lnfConfiguration = configDialog.lnfConfiguration
for (const key in lnfConfiguration) {
props["cfg_" + key] = lnfConfiguration[key]
}
var newItem = push(sourceFile, props, QtControls.StackView.ReplaceTransition)
const newItem = push(sourceFile, props, QtControls.StackView.ReplaceTransition)
lnfConfiguration.valueChanged.connect(function(key, value) {
lnfConfiguration.valueChanged.connect((key, value) => {
if (newItem["cfg_" + key] !== undefined) {
newItem["cfg_" + key] = value
}
})
var createSignalHandler = function(key) {
return function() {
const createSignalHandler = key => {
return () => {
configDialog.lnfConfiguration[key] = newItem["cfg_" + key]
configurationChanged()
}
}
for (var key in lnfConfiguration) {
var changedSignal = newItem["cfg_" + key + "Changed"]
for (const key in lnfConfiguration) {
const changedSignal = newItem["cfg_" + key + "Changed"]
if (changedSignal) {
changedSignal.connect(createSignalHandler(key))
}
......
......@@ -35,35 +35,34 @@ QtControls.StackView {
signal configurationChanged
onSourceFileChanged: {
if (sourceFile) {
var props = {}
var wallpaperConfig = configDialog.wallpaperConfiguration
for (var key in wallpaperConfig) {
const props = {}
const wallpaperConfig = configDialog.wallpaperConfiguration
for (const key in wallpaperConfig) {
props["cfg_" + key] = wallpaperConfig[key]
}
var newItem = replace(sourceFile, props, QtControls.StackView.ReplaceTransition)
const newItem = replace(sourceFile, props, QtControls.StackView.ReplaceTransition)
wallpaperConfig.valueChanged.connect(function(key, value) {
wallpaperConfig.valueChanged.connect((key, value) => {
if (newItem["cfg_" + key] !== undefined) {
newItem["cfg_" + key] = value
}
})
var createSignalHandler = function(key) {
return function() {
const createSignalHandler = key => {
return () => {
configDialog.wallpaperConfiguration[key] = newItem["cfg_" + key]
configurationChanged()
}
}
for (var key in wallpaperConfig) {
var changedSignal = newItem["cfg_" + key + "Changed"]
for (const key in wallpaperConfig) {
const changedSignal = newItem["cfg_" + key + "Changed"]
if (changedSignal) {
changedSignal.connect(createSignalHandler(key))
}
}
}
else {
} else {
replace(empty)
}
}
......
......@@ -55,12 +55,8 @@ KCM.SimpleKCM {
QQC2.SpinBox {
from: 1
editable: true
textFromValue: function (value) {
return i18np("%1 minute", "%1 minutes", value)
}
valueFromText: function (text) {
return parseInt(text)
}
textFromValue: value => i18np("%1 minute", "%1 minutes", value)
valueFromText: text => parseInt(text)
value: kcm.settings.timeout
onValueModified: kcm.settings.timeout = value
......@@ -91,12 +87,8 @@ KCM.SimpleKCM {
from: 0
to: 300
editable: true
textFromValue: function (value) {
return i18np("%1 second", "%1 seconds", value)
}
valueFromText: function (text) {
return parseInt(text)
}
textFromValue: value => i18np("%1 second", "%1 seconds", value)
valueFromText: text => parseInt(text)
value: kcm.settings.lockGrace
onValueModified: kcm.settings.lockGrace = value
......
Supports Markdown
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