Skip to content

Commit 59532cb

Browse files
committed
make default values of lines spinboxes configurable
Thanks to Samuele Castiglioni for suggesting this.
1 parent 1e2292b commit 59532cb

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"defaultLinesOfContext": 2,
3+
"defaultLinesToRecite": 2,
4+
"defaultLinesInGroupsOf": 1,
25
"endOfStanzaMarker": "",
36
"endOfTextMarker": ""
47
}

src/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
LPCG Options:
22

3+
**defaultLinesOfContext**, **defaultLinesToRecite**, **defaultLinesInGroupsOf**: These control the values in the respective spin boxes when you open the LPCG import dialog. If you regularly like to use different values than the defaults (2, 1, and 1), you can set them here and avoid having to tweak them every time.
34
**endOfStanzaMarker**: This string will be added at the end of the last line of each stanza. It should normally begin with a space so it isn’t squashed against the end of the last word on the line.
45
**endOfTextMarker**: Like *endOfStanzaMarker*, but appears at the end of the last line of the entire text.

src/lpcg_dialog.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def __init__(self, mw):
3838
self.form.openFileButton.clicked.connect(self.onOpenFile)
3939
self.form.helpButton.clicked.connect(self.onHelp)
4040

41+
self.addonConfig = self.mw.addonManager.getConfig(__name__)
42+
self.form.contextLinesSpin.setValue(self.addonConfig['defaultLinesOfContext'])
43+
self.form.reciteLinesSpin.setValue(self.addonConfig['defaultLinesToRecite'])
44+
self.form.groupLinesSpin.setValue(self.addonConfig['defaultLinesInGroupsOf'])
45+
4146
def accept(self):
4247
"On close, create notes from the contents of the poem editor."
4348
title = self.form.titleBox.text().strip()
@@ -59,8 +64,7 @@ def accept(self):
5964
return
6065

6166
tags = self.mw.col.tags.split(self.form.tagsBox.text())
62-
text = cleanse_text(self.form.textBox.toPlainText().strip(),
63-
self.mw.addonManager.getConfig(__name__))
67+
text = cleanse_text(self.form.textBox.toPlainText().strip(), self.addonConfig)
6468
context_lines = self.form.contextLinesSpin.value()
6569
recite_lines = self.form.reciteLinesSpin.value()
6670
group_lines = self.form.groupLinesSpin.value()

0 commit comments

Comments
 (0)