forked from openlp/openlp
Hopefully, for one and for all, fix the off-by-one issues on all platforms
Fixes: https://launchpad.net/bugs/1669007, https://launchpad.net/bugs/1668994
This commit is contained in:
parent
561f272e86
commit
77d36b607c
@ -31,7 +31,8 @@ import shutil
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, translate
|
||||
from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, \
|
||||
translate, is_macosx
|
||||
from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list
|
||||
from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box
|
||||
from openlp.plugins.songs.lib import VerseType, clean_song
|
||||
@ -382,7 +383,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.themes = theme_list
|
||||
self.theme_combo_box.addItems(theme_list)
|
||||
set_case_insensitive_completer(self.themes, self.theme_combo_box)
|
||||
self.theme_combo_box.setEditText('')
|
||||
self.theme_combo_box.setCurrentIndex(-1)
|
||||
self.theme_combo_box.setCurrentText('')
|
||||
|
||||
def load_media_files(self):
|
||||
"""
|
||||
@ -421,7 +423,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.load_topics()
|
||||
self.load_songbooks()
|
||||
self.load_media_files()
|
||||
self.theme_combo_box.setEditText('')
|
||||
self.theme_combo_box.setCurrentIndex(-1)
|
||||
self.theme_combo_box.setCurrentText('')
|
||||
# it's a new song to preview is not possible
|
||||
self.preview_button.setVisible(False)
|
||||
|
||||
@ -446,8 +449,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
find_and_set_in_combo_box(self.theme_combo_box, str(self.song.theme_name))
|
||||
else:
|
||||
# Clear the theme combo box in case it was previously set (bug #1212801)
|
||||
self.theme_combo_box.setEditText('')
|
||||
self.theme_combo_box.setCurrentIndex(0)
|
||||
self.theme_combo_box.setCurrentIndex(-1)
|
||||
self.theme_combo_box.setCurrentText('')
|
||||
self.copyright_edit.setText(self.song.copyright if self.song.copyright else '')
|
||||
self.comments_edit.setPlainText(self.song.comments if self.song.comments else '')
|
||||
self.ccli_number_edit.setText(self.song.ccli_number if self.song.ccli_number else '')
|
||||
@ -550,12 +553,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
item = int(self.authors_combo_box.currentIndex())
|
||||
text = self.authors_combo_box.currentText().strip(' \r\n\t')
|
||||
author_type = self.author_types_combo_box.itemData(self.author_types_combo_box.currentIndex())
|
||||
# This if statement is for OS X, which doesn't seem to work well with
|
||||
# the QCompleter auto-completion class. See bug #812628.
|
||||
if text in self.authors:
|
||||
# Index 0 is a blank string, so add 1
|
||||
item = self.authors.index(text) + 1
|
||||
if item == 0 and text:
|
||||
if item == -1 and text:
|
||||
if QtWidgets.QMessageBox.question(
|
||||
self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Author'),
|
||||
@ -570,10 +568,11 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.manager.save_object(author)
|
||||
self._add_author_to_list(author, author_type)
|
||||
self.load_authors()
|
||||
self.authors_combo_box.setEditText('')
|
||||
self.authors_combo_box.setCurrentIndex(-1)
|
||||
self.authors_combo_box.setCurrentText('')
|
||||
else:
|
||||
return
|
||||
elif item > 0:
|
||||
elif item >= 0:
|
||||
item_id = (self.authors_combo_box.itemData(item))
|
||||
author = self.manager.get_object(Author, item_id)
|
||||
if self.authors_list_view.findItems(author.get_display_name(author_type), QtCore.Qt.MatchExactly):
|
||||
@ -581,7 +580,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
message=translate('SongsPlugin.EditSongForm', 'This author is already in the list.'))
|
||||
else:
|
||||
self._add_author_to_list(author, author_type)
|
||||
self.authors_combo_box.setEditText('')
|
||||
self.authors_combo_box.setCurrentIndex(-1)
|
||||
self.authors_combo_box.setCurrentText('')
|
||||
else:
|
||||
QtWidgets.QMessageBox.warning(
|
||||
self, UiStrings().NISs,
|
||||
@ -633,7 +633,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
def on_topic_add_button_clicked(self):
|
||||
item = int(self.topics_combo_box.currentIndex())
|
||||
text = self.topics_combo_box.currentText()
|
||||
if item == 0 and text:
|
||||
if item == -1 and text:
|
||||
if QtWidgets.QMessageBox.question(
|
||||
self, translate('SongsPlugin.EditSongForm', 'Add Topic'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic does not exist, do you want to add it?'),
|
||||
@ -645,10 +645,11 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
topic_item.setData(QtCore.Qt.UserRole, topic.id)
|
||||
self.topics_list_view.addItem(topic_item)
|
||||
self.load_topics()
|
||||
self.topics_combo_box.setEditText('')
|
||||
self.topics_combo_box.setCurrentIndex(-1)
|
||||
self.topics_combo_box.setCurrentText('')
|
||||
else:
|
||||
return
|
||||
elif item > 0:
|
||||
elif item >= 0:
|
||||
item_id = (self.topics_combo_box.itemData(item))
|
||||
topic = self.manager.get_object(Topic, item_id)
|
||||
if self.topics_list_view.findItems(str(topic.name), QtCore.Qt.MatchExactly):
|
||||
@ -658,7 +659,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
topic_item = QtWidgets.QListWidgetItem(str(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole, topic.id)
|
||||
self.topics_list_view.addItem(topic_item)
|
||||
self.topics_combo_box.setEditText('')
|
||||
self.topics_combo_box.setCurrentIndex(-1)
|
||||
self.topics_combo_box.setCurrentText('')
|
||||
else:
|
||||
QtWidgets.QMessageBox.warning(
|
||||
self, UiStrings().NISs,
|
||||
@ -678,7 +680,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
def on_songbook_add_button_clicked(self):
|
||||
item = int(self.songbooks_combo_box.currentIndex())
|
||||
text = self.songbooks_combo_box.currentText()
|
||||
if item == 0 and text:
|
||||
if item == -1 and text:
|
||||
if QtWidgets.QMessageBox.question(
|
||||
self, translate('SongsPlugin.EditSongForm', 'Add Songbook'),
|
||||
translate('SongsPlugin.EditSongForm', 'This Songbook does not exist, do you want to add it?'),
|
||||
@ -688,11 +690,12 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
self.manager.save_object(songbook)
|
||||
self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text())
|
||||
self.load_songbooks()
|
||||
self.songbooks_combo_box.setEditText('')
|
||||
self.songbooks_combo_box.setCurrentIndex(-1)
|
||||
self.songbooks_combo_box.setCurrentText('')
|
||||
self.songbook_entry_edit.clear()
|
||||
else:
|
||||
return
|
||||
elif item > 0:
|
||||
elif item >= 0:
|
||||
item_id = (self.songbooks_combo_box.itemData(item))
|
||||
songbook = self.manager.get_object(Book, item_id)
|
||||
if self.songbooks_list_view.findItems(str(songbook.name), QtCore.Qt.MatchExactly):
|
||||
@ -700,7 +703,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
||||
message=translate('SongsPlugin.EditSongForm', 'This Songbook is already in the list.'))
|
||||
else:
|
||||
self.add_songbook_entry_to_list(songbook.id, songbook.name, self.songbook_entry_edit.text())
|
||||
self.songbooks_combo_box.setEditText('')
|
||||
self.songbooks_combo_box.setCurrentIndex(-1)
|
||||
self.songbooks_combo_box.setCurrentText('')
|
||||
self.songbook_entry_edit.clear()
|
||||
else:
|
||||
QtWidgets.QMessageBox.warning(
|
||||
|
Loading…
Reference in New Issue
Block a user