Skip to content

Commit

Permalink
toggle-checkbox: Fix checkbox autocreation from list
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktor2200 committed Nov 27, 2023
1 parent 145fe71 commit 7635dd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions toggle-checkbox/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "Toggle checkbox",
"identifier": "toggle-checkbox",
"script": "toggle-checkbox.qml",
"version": "1.3.0",
"version": "1.4.0",
"minAppVersion": "19.3.2",
"authors": ["@sanderboom", "@pbek"],
"authors": ["@sanderboom", "@pbek", "@wiktor2200"],
"description" : "This script creates a menu item and a button to toggle checkbox state. Change one or more selected lines regarding checkboxes: plainlist -> unchecked, unchecked -> checked, checked -> disabled, disabled -> unchecked. Hint: assign a shortcut."
}
12 changes: 6 additions & 6 deletions toggle-checkbox/toggle-checkbox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,29 @@ QtObject {
if (multipleLinesMethod === 'synchronizeChecked' && mixedStatesPresent) {
lines[i] = lines[i].replace(/- \[( |x|X)\] /, checkboxCharacter);
}
// Default: cylce-all-lines-mode.
// Default: cycle-all-lines-mode.
else {
script.log('Scenario: cycle-all-lines');

// Toggle unchecked to checked.
if (lines[i].match(/- \[ \] /)) {
if (lines[i].match(/^- \[ \] /)) {
script.log('Convert unchecked to checked');
lines[i] = lines[i].replace(/- \[ \] /, CHECKED);
}
// Toggle checked to disabled.
else if (lines[i].match(/- \[(x|X)\] /)) {
else if (lines[i].match(/^- \[(x|X)\] /)) {
script.log('Convert checked to disabled');
lines[i] = lines[i].replace(/- \[(x|X)\] /, DISABLED);
}
// Toggle disabled to unchecked.
else if (lines[i].match(/- \[-\] /)) {
else if (lines[i].match(/^- \[-\] /)) {
script.log('Convert disabled to unchecked');
lines[i] = lines[i].replace(/- \[-\] /, UNCHECKED);
}
// Convert plain list lines (-, *, +) to unchecked checkboxes lines.
else if (!onlyTouchCheckboxes && lines[i].match(/(-|\*|\+) /)) {
else if (!onlyTouchCheckboxes && lines[i].match(/^(-|\*|\+) /)) {
script.log('Convert plain list to unchecked');
lines[i] = lines[i].replace(/(-|\*|\+) /, UNCHECKED);
lines[i] = lines[i].replace(/^(-|\*|\+) /, UNCHECKED);
}
// Add checkboxes when unpresent (empty lines are skipped).
else if (!onlyTouchCheckboxes) {
Expand Down

0 comments on commit 7635dd3

Please sign in to comment.