Prevent Enter key on Manage authors/tags/etc. dialogs from closing the dialog. Fixes #1440146 [feature request: return on manage tags runs search instead of closing popup](https://bugs.launchpad.net/calibre/+bug/1440146)

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2015-04-04 19:03:40 +05:30
commit ba1812c173
3 changed files with 38 additions and 11 deletions

View File

@ -38,6 +38,8 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
except:
pass
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK'))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
self.buttonBox.accepted.connect(self.accepted)
# Set up the column headings
@ -114,6 +116,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
self.find_box.lineEdit().returnPressed.connect(self.do_find)
self.find_box.editTextChanged.connect(self.find_text_changed)
self.find_button.clicked.connect(self.do_find)
self.find_button.setDefault(True)
l = QLabel(self.table)
self.not_found_label = l

View File

@ -1,7 +1,8 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize)
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize,
QDialogButtonBox)
from calibre.gui2.dialogs.tag_list_editor_ui import Ui_TagListEditor
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
@ -147,10 +148,17 @@ class TagListEditor(QDialog, Ui_TagListEditor):
self.rename_button.clicked.connect(self.rename_tag)
self.table.itemDoubleClicked.connect(self._rename_tag)
self.table.itemChanged.connect(self.finish_editing)
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK'))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
self.buttonBox.accepted.connect(self.accepted)
self.search_box.initialize('tag_list_search_box_' + cat_name)
self.search_box.editTextChanged.connect(self.find_text_changed)
self.search_button.clicked.connect(self.search_clicked)
self.search_button.setDefault(True)
self.start_find_pos = -1
try:
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
@ -161,21 +169,21 @@ class TagListEditor(QDialog, Ui_TagListEditor):
except:
pass
def find_text_changed(self):
self.start_find_pos = -1
def search_clicked(self):
search_for = icu_lower(unicode(self.search_box.text()))
if not search_for:
error_dialog(self, _('Find'), _('You must enter some text to search for'),
show=True, show_copy_button=False)
return
row = self.table.currentRow()
if row < 0:
row = 0
rows = self.table.rowCount()
for i in range(0, rows):
row += 1
if row >= rows:
row = 0
item = self.table.item(row, 0)
self.start_find_pos += 1
if self.start_find_pos >= rows:
self.start_find_pos = 0
item = self.table.item(self.start_find_pos, 0)
if search_for in icu_lower(unicode(item.text())):
self.table.setCurrentItem(item)
return

View File

@ -18,19 +18,35 @@
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
</property>
<layout class="QGridLayout">
<item row="0" column="1">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel">
<property name="text">
<string>&amp;Search for:</string>
</property>
<property name="buddy">
<cstring>search_box</cstring>
</property>
</widget>
</item>
<item>
<widget class="HistoryLineEdit" name="search_box">
<property name="toolTip">
<string>Search for an item in the Tag column</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="search_button">
<widget class="QPushButton" name="search_button">
<property name="text">
<string>Find</string>
<string>&amp;Find</string>
</property>
<property name="toolTip">
<string>Copy the selected color name to the clipboard</string>