mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-10 15:04:34 +12:00
Cleanup code
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
acd23e9651
commit
414cd0f8a3
|
@ -337,28 +337,28 @@ class mainEditor(QWidget, Ui_mainEditor):
|
||||||
|
|
||||||
if settings.progressChars:
|
if settings.progressChars:
|
||||||
self.lblRedacWC.setText(self.tr("({} chars) {} words / {} ").format(
|
self.lblRedacWC.setText(self.tr("({} chars) {} words / {} ").format(
|
||||||
locale.format("%d", cc, grouping=True),
|
locale.format_string("%d", cc, grouping=True),
|
||||||
locale.format("%d", wc, grouping=True),
|
locale.format_string("%d", wc, grouping=True),
|
||||||
locale.format("%d", goal, grouping=True)))
|
locale.format_string("%d", goal, grouping=True)))
|
||||||
self.lblRedacWC.setToolTip("")
|
self.lblRedacWC.setToolTip("")
|
||||||
else:
|
else:
|
||||||
self.lblRedacWC.setText(self.tr("{} words / {} ").format(
|
self.lblRedacWC.setText(self.tr("{} words / {} ").format(
|
||||||
locale.format("%d", wc, grouping=True),
|
locale.format_string("%d", wc, grouping=True),
|
||||||
locale.format("%d", goal, grouping=True)))
|
locale.format_string("%d", goal, grouping=True)))
|
||||||
self.lblRedacWC.setToolTip(self.tr("{} chars").format(
|
self.lblRedacWC.setToolTip(self.tr("{} chars").format(
|
||||||
locale.format("%d", cc, grouping=True)))
|
locale.format_string("%d", cc, grouping=True)))
|
||||||
else:
|
else:
|
||||||
self.lblRedacProgress.hide()
|
self.lblRedacProgress.hide()
|
||||||
|
|
||||||
if settings.progressChars:
|
if settings.progressChars:
|
||||||
self.lblRedacWC.setText(self.tr("{} chars ").format(
|
self.lblRedacWC.setText(self.tr("{} chars ").format(
|
||||||
locale.format("%d", cc, grouping=True)))
|
locale.format_string("%d", cc, grouping=True)))
|
||||||
self.lblRedacWC.setToolTip("")
|
self.lblRedacWC.setToolTip("")
|
||||||
else:
|
else:
|
||||||
self.lblRedacWC.setText(self.tr("{} words ").format(
|
self.lblRedacWC.setText(self.tr("{} words ").format(
|
||||||
locale.format("%d", wc, grouping=True)))
|
locale.format_string("%d", wc, grouping=True)))
|
||||||
self.lblRedacWC.setToolTip(self.tr("{} chars").format(
|
self.lblRedacWC.setToolTip(self.tr("{} chars").format(
|
||||||
locale.format("%d", cc, grouping=True)))
|
locale.format_string("%d", cc, grouping=True)))
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# VIEWS
|
# VIEWS
|
||||||
|
|
|
@ -569,7 +569,7 @@ class textEditView(QTextEdit):
|
||||||
suggestions = []
|
suggestions = []
|
||||||
|
|
||||||
# Check for any suggestions for corrections at the cursors position
|
# Check for any suggestions for corrections at the cursors position
|
||||||
if self._dict != None:
|
if self._dict is not None:
|
||||||
text = self.toPlainText()
|
text = self.toPlainText()
|
||||||
|
|
||||||
suggestions = self._dict.findSuggestions(text, cursor.selectionStart(), cursor.selectionEnd())
|
suggestions = self._dict.findSuggestions(text, cursor.selectionStart(), cursor.selectionEnd())
|
||||||
|
@ -598,7 +598,7 @@ class textEditView(QTextEdit):
|
||||||
|
|
||||||
popup_menu = self.appendContextMenuEntriesForWord(popup_menu, selectedWord)
|
popup_menu = self.appendContextMenuEntriesForWord(popup_menu, selectedWord)
|
||||||
|
|
||||||
if len(suggestions) > 0 or selectedWord != None:
|
if len(suggestions) > 0 or selectedWord is not None:
|
||||||
valid = len(suggestions) == 0
|
valid = len(suggestions) == 0
|
||||||
|
|
||||||
if not valid:
|
if not valid:
|
||||||
|
@ -611,7 +611,7 @@ class textEditView(QTextEdit):
|
||||||
spell_menu = QMenu(self.tr('Spelling Suggestions'), self)
|
spell_menu = QMenu(self.tr('Spelling Suggestions'), self)
|
||||||
spell_menu.setIcon(F.themeIcon("spelling"))
|
spell_menu.setIcon(F.themeIcon("spelling"))
|
||||||
|
|
||||||
if (match.end > match.start and selectedWord == None):
|
if match.end > match.start and selectedWord is None:
|
||||||
# Select the actual area of the match
|
# Select the actual area of the match
|
||||||
cursor = self.textCursor()
|
cursor = self.textCursor()
|
||||||
cursor.setPosition(match.start, QTextCursor.MoveAnchor);
|
cursor.setPosition(match.start, QTextCursor.MoveAnchor);
|
||||||
|
@ -642,7 +642,7 @@ class textEditView(QTextEdit):
|
||||||
correct_menu = None
|
correct_menu = None
|
||||||
correct_action = None
|
correct_action = None
|
||||||
|
|
||||||
if (len(match.replacements) > 0 and match.end > match.start):
|
if len(match.replacements) > 0 and match.end > match.start:
|
||||||
# Select the actual area of the match
|
# Select the actual area of the match
|
||||||
cursor = self.textCursor()
|
cursor = self.textCursor()
|
||||||
cursor.setPosition(match.start, QTextCursor.MoveAnchor);
|
cursor.setPosition(match.start, QTextCursor.MoveAnchor);
|
||||||
|
@ -658,7 +658,7 @@ class textEditView(QTextEdit):
|
||||||
action.correct.connect(self.correctWord)
|
action.correct.connect(self.correctWord)
|
||||||
correct_menu.addAction(action)
|
correct_menu.addAction(action)
|
||||||
|
|
||||||
if correct_menu == None:
|
if correct_menu is None:
|
||||||
correct_action = QAction(self.tr('&Correction Suggestion'), popup_menu)
|
correct_action = QAction(self.tr('&Correction Suggestion'), popup_menu)
|
||||||
correct_action.setIcon(F.themeIcon("spelling"))
|
correct_action.setIcon(F.themeIcon("spelling"))
|
||||||
correct_action.setEnabled(False)
|
correct_action.setEnabled(False)
|
||||||
|
@ -670,10 +670,10 @@ class textEditView(QTextEdit):
|
||||||
for i in range(0, len(msg_lines)):
|
for i in range(0, len(msg_lines)):
|
||||||
popup_menu.insertSection(popup_menu.actions()[0], msg_lines[len(msg_lines) - (i + 1)])
|
popup_menu.insertSection(popup_menu.actions()[0], msg_lines[len(msg_lines) - (i + 1)])
|
||||||
|
|
||||||
if correct_menu != None:
|
if correct_menu is None:
|
||||||
popup_menu.insertMenu(popup_menu.actions()[0], correct_menu)
|
|
||||||
else:
|
|
||||||
popup_menu.insertAction(popup_menu.actions()[0], correct_action)
|
popup_menu.insertAction(popup_menu.actions()[0], correct_action)
|
||||||
|
else:
|
||||||
|
popup_menu.insertMenu(popup_menu.actions()[0], correct_menu)
|
||||||
|
|
||||||
# If word was added to custom dict, give the possibility to remove it
|
# If word was added to custom dict, give the possibility to remove it
|
||||||
elif self._dict.isCustomWord(selectedWord):
|
elif self._dict.isCustomWord(selectedWord):
|
||||||
|
|
Loading…
Reference in a new issue