mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
commit
ba1812c173
@ -38,6 +38,8 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK'))
|
||||||
|
self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel'))
|
||||||
self.buttonBox.accepted.connect(self.accepted)
|
self.buttonBox.accepted.connect(self.accepted)
|
||||||
|
|
||||||
# Set up the column headings
|
# 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.lineEdit().returnPressed.connect(self.do_find)
|
||||||
self.find_box.editTextChanged.connect(self.find_text_changed)
|
self.find_box.editTextChanged.connect(self.find_text_changed)
|
||||||
self.find_button.clicked.connect(self.do_find)
|
self.find_button.clicked.connect(self.do_find)
|
||||||
|
self.find_button.setDefault(True)
|
||||||
|
|
||||||
l = QLabel(self.table)
|
l = QLabel(self.table)
|
||||||
self.not_found_label = l
|
self.not_found_label = l
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__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.dialogs.tag_list_editor_ui import Ui_TagListEditor
|
||||||
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
|
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.rename_button.clicked.connect(self.rename_tag)
|
||||||
self.table.itemDoubleClicked.connect(self._rename_tag)
|
self.table.itemDoubleClicked.connect(self._rename_tag)
|
||||||
self.table.itemChanged.connect(self.finish_editing)
|
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.buttonBox.accepted.connect(self.accepted)
|
||||||
|
|
||||||
self.search_box.initialize('tag_list_search_box_' + cat_name)
|
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.clicked.connect(self.search_clicked)
|
||||||
|
self.search_button.setDefault(True)
|
||||||
|
|
||||||
|
self.start_find_pos = -1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
|
geom = gprefs.get('tag_list_editor_dialog_geometry', None)
|
||||||
@ -161,21 +169,21 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def find_text_changed(self):
|
||||||
|
self.start_find_pos = -1
|
||||||
|
|
||||||
def search_clicked(self):
|
def search_clicked(self):
|
||||||
search_for = icu_lower(unicode(self.search_box.text()))
|
search_for = icu_lower(unicode(self.search_box.text()))
|
||||||
if not search_for:
|
if not search_for:
|
||||||
error_dialog(self, _('Find'), _('You must enter some text to search for'),
|
error_dialog(self, _('Find'), _('You must enter some text to search for'),
|
||||||
show=True, show_copy_button=False)
|
show=True, show_copy_button=False)
|
||||||
return
|
return
|
||||||
row = self.table.currentRow()
|
|
||||||
if row < 0:
|
|
||||||
row = 0
|
|
||||||
rows = self.table.rowCount()
|
rows = self.table.rowCount()
|
||||||
for i in range(0, rows):
|
for i in range(0, rows):
|
||||||
row += 1
|
self.start_find_pos += 1
|
||||||
if row >= rows:
|
if self.start_find_pos >= rows:
|
||||||
row = 0
|
self.start_find_pos = 0
|
||||||
item = self.table.item(row, 0)
|
item = self.table.item(self.start_find_pos, 0)
|
||||||
if search_for in icu_lower(unicode(item.text())):
|
if search_for in icu_lower(unicode(item.text())):
|
||||||
self.table.setCurrentItem(item)
|
self.table.setCurrentItem(item)
|
||||||
return
|
return
|
||||||
|
@ -18,19 +18,35 @@
|
|||||||
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
|
<normaloff>:/images/chapters.png</normaloff>:/images/chapters.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="1">
|
<item row="0" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Search for:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>search_box</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="HistoryLineEdit" name="search_box">
|
<widget class="HistoryLineEdit" name="search_box">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Search for an item in the Tag column</string>
|
<string>Search for an item in the Tag column</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>100</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="search_button">
|
<widget class="QPushButton" name="search_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Find</string>
|
<string>&Find</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Copy the selected color name to the clipboard</string>
|
<string>Copy the selected color name to the clipboard</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user