mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add parents to a bunch more QMenus
Testing a few of these seem they work even without parents on macOS, but given that adding parents is easy/harmless, might as well do it. Dont know exactly what circumstances causes parentless QMenu's to malfunction on macOS in Qt 5.15
This commit is contained in:
parent
a69ff6e8dc
commit
48b107d0f3
@ -305,7 +305,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
action_title_case.triggered.connect(self.title_case)
|
action_title_case.triggered.connect(self.title_case)
|
||||||
action_capitalize.triggered.connect(self.capitalize)
|
action_capitalize.triggered.connect(self.capitalize)
|
||||||
|
|
||||||
m = self.au_context_menu = QMenu()
|
m = self.au_context_menu = QMenu(self)
|
||||||
idx = self.table.indexAt(point)
|
idx = self.table.indexAt(point)
|
||||||
id_ = int(self.table.item(idx.row(), 0).data(Qt.UserRole))
|
id_ = int(self.table.item(idx.row(), 0).data(Qt.UserRole))
|
||||||
sub = self.get_column_name(idx.column())
|
sub = self.get_column_name(idx.column())
|
||||||
|
@ -215,7 +215,7 @@ class SearchBar(QFrame): # {{{
|
|||||||
sb.setAutoRaise(True)
|
sb.setAutoRaise(True)
|
||||||
sb.setText(_('Sort'))
|
sb.setText(_('Sort'))
|
||||||
sb.setIcon(QIcon(I('sort.png')))
|
sb.setIcon(QIcon(I('sort.png')))
|
||||||
sb.setMenu(QMenu())
|
sb.setMenu(QMenu(sb))
|
||||||
sb.menu().aboutToShow.connect(self.populate_sort_menu)
|
sb.menu().aboutToShow.connect(self.populate_sort_menu)
|
||||||
sb.setVisible(False)
|
sb.setVisible(False)
|
||||||
l.addWidget(sb)
|
l.addWidget(sb)
|
||||||
|
@ -167,9 +167,9 @@ class MetadataSingleDialogBase(QDialog):
|
|||||||
if ac is not None:
|
if ac is not None:
|
||||||
ac.trigger()
|
ac.trigger()
|
||||||
return QMenu.mouseReleaseEvent(self, ev)
|
return QMenu.mouseReleaseEvent(self, ev)
|
||||||
b.m = m = Menu()
|
b.m = m = Menu(b)
|
||||||
else:
|
else:
|
||||||
b.m = m = QMenu()
|
b.m = m = QMenu(b)
|
||||||
ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author'))
|
ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author'))
|
||||||
ac2 = m.addAction(QIcon(I('back.png')), _('Set author from author sort'))
|
ac2 = m.addAction(QIcon(I('back.png')), _('Set author from author sort'))
|
||||||
ac3 = m.addAction(QIcon(I('user_profile.png')), _('Manage authors'))
|
ac3 = m.addAction(QIcon(I('user_profile.png')), _('Manage authors'))
|
||||||
@ -256,7 +256,7 @@ class MetadataSingleDialogBase(QDialog):
|
|||||||
b.setIcon(QIcon(I('edit-paste.png')))
|
b.setIcon(QIcon(I('edit-paste.png')))
|
||||||
b.clicked.connect(self.identifiers.paste_identifier)
|
b.clicked.connect(self.identifiers.paste_identifier)
|
||||||
b.setPopupMode(b.DelayedPopup)
|
b.setPopupMode(b.DelayedPopup)
|
||||||
b.setMenu(QMenu())
|
b.setMenu(QMenu(b))
|
||||||
self.update_paste_identifiers_menu()
|
self.update_paste_identifiers_menu()
|
||||||
|
|
||||||
self.publisher = PublisherEdit(self)
|
self.publisher = PublisherEdit(self)
|
||||||
|
@ -827,7 +827,7 @@ class CoversView(QListView): # {{{
|
|||||||
def show_context_menu(self, point):
|
def show_context_menu(self, point):
|
||||||
idx = self.currentIndex()
|
idx = self.currentIndex()
|
||||||
if idx and idx.isValid() and not idx.data(Qt.UserRole):
|
if idx and idx.isValid() and not idx.data(Qt.UserRole):
|
||||||
m = QMenu()
|
m = QMenu(self)
|
||||||
m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover)
|
m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover)
|
||||||
m.addAction(QIcon(I('edit-copy.png')), _('Copy this cover to clipboard'), self.copy_cover)
|
m.addAction(QIcon(I('edit-copy.png')), _('Copy this cover to clipboard'), self.copy_cover)
|
||||||
m.exec_(QCursor.pos())
|
m.exec_(QCursor.pos())
|
||||||
|
@ -421,7 +421,7 @@ class RuleEditor(QDialog): # {{{
|
|||||||
if self.rule_kind != 'color':
|
if self.rule_kind != 'color':
|
||||||
self.remove_button = b = bb.addButton(_('&Remove icon'), bb.ActionRole)
|
self.remove_button = b = bb.addButton(_('&Remove icon'), bb.ActionRole)
|
||||||
b.setIcon(QIcon(I('minus.png')))
|
b.setIcon(QIcon(I('minus.png')))
|
||||||
b.setMenu(QMenu())
|
b.setMenu(QMenu(b))
|
||||||
b.setToolTip('<p>' + _('Remove a previously added icon. Note that doing so will cause rules that use it to stop working.'))
|
b.setToolTip('<p>' + _('Remove a previously added icon. Note that doing so will cause rules that use it to stop working.'))
|
||||||
self.update_remove_button()
|
self.update_remove_button()
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ class SavedSearchBoxMixin(object): # {{{
|
|||||||
self.save_search_button.setToolTip('<p>' +
|
self.save_search_button.setToolTip('<p>' +
|
||||||
_("Save current search under the name shown in the box. "
|
_("Save current search under the name shown in the box. "
|
||||||
"Press and hold for a pop-up options menu.") + '</p>')
|
"Press and hold for a pop-up options menu.") + '</p>')
|
||||||
self.save_search_button.setMenu(QMenu())
|
self.save_search_button.setMenu(QMenu(self.save_search_button))
|
||||||
self.save_search_button.menu().addAction(
|
self.save_search_button.menu().addAction(
|
||||||
QIcon(I('plus.png')),
|
QIcon(I('plus.png')),
|
||||||
_('Create Saved search'),
|
_('Create Saved search'),
|
||||||
@ -575,7 +575,7 @@ class SavedSearchBoxMixin(object): # {{{
|
|||||||
QIcon(I('trash.png')), _('Delete Saved search'), self.saved_search.delete_current_search)
|
QIcon(I('trash.png')), _('Delete Saved search'), self.saved_search.delete_current_search)
|
||||||
self.save_search_button.menu().addAction(
|
self.save_search_button.menu().addAction(
|
||||||
QIcon(I('search.png')), _('Manage Saved searches'), partial(self.do_saved_search_edit, None))
|
QIcon(I('search.png')), _('Manage Saved searches'), partial(self.do_saved_search_edit, None))
|
||||||
self.add_saved_search_button.setMenu(QMenu())
|
self.add_saved_search_button.setMenu(QMenu(self.add_saved_search_button))
|
||||||
self.add_saved_search_button.menu().aboutToShow.connect(self.populate_add_saved_search_menu)
|
self.add_saved_search_button.menu().aboutToShow.connect(self.populate_add_saved_search_menu)
|
||||||
|
|
||||||
def populate_add_saved_search_menu(self):
|
def populate_add_saved_search_menu(self):
|
||||||
|
@ -329,7 +329,7 @@ class SearchRestrictionMixin(object):
|
|||||||
self.search_based_vl_name = None
|
self.search_based_vl_name = None
|
||||||
self.search_based_vl = None
|
self.search_based_vl = None
|
||||||
|
|
||||||
self.virtual_library_menu = QMenu()
|
self.virtual_library_menu = QMenu(self.virtual_library)
|
||||||
self.virtual_library.setMenu(self.virtual_library_menu)
|
self.virtual_library.setMenu(self.virtual_library_menu)
|
||||||
self.virtual_library_menu.aboutToShow.connect(self.virtual_library_menu_about_to_show)
|
self.virtual_library_menu.aboutToShow.connect(self.virtual_library_menu_about_to_show)
|
||||||
|
|
||||||
@ -342,9 +342,9 @@ class SearchRestrictionMixin(object):
|
|||||||
self.search_restriction = ComboBoxWithHelp(self)
|
self.search_restriction = ComboBoxWithHelp(self)
|
||||||
self.search_restriction.setVisible(False)
|
self.search_restriction.setVisible(False)
|
||||||
self.clear_vl.setText(_("(all books)"))
|
self.clear_vl.setText(_("(all books)"))
|
||||||
self.ar_menu = QMenu(_('Additional restriction'))
|
self.ar_menu = QMenu(_('Additional restriction'), self.virtual_library_menu)
|
||||||
self.edit_menu = QMenu(_('Edit Virtual library'))
|
self.edit_menu = QMenu(_('Edit Virtual library'), self.virtual_library_menu)
|
||||||
self.rm_menu = QMenu(_('Remove Virtual library'))
|
self.rm_menu = QMenu(_('Remove Virtual library'), self.virtual_library_menu)
|
||||||
self.search_restriction_list_built = False
|
self.search_restriction_list_built = False
|
||||||
|
|
||||||
def add_virtual_library(self, db, name, search):
|
def add_virtual_library(self, db, name, search):
|
||||||
|
@ -46,7 +46,7 @@ class ResultsView(QTreeView):
|
|||||||
|
|
||||||
plugin = self.model().get_plugin(index)
|
plugin = self.model().get_plugin(index)
|
||||||
|
|
||||||
menu = QMenu()
|
menu = QMenu(self)
|
||||||
ca = menu.addAction(_('Configure...'), partial(self.configure_plugin, plugin))
|
ca = menu.addAction(_('Configure...'), partial(self.configure_plugin, plugin))
|
||||||
if not plugin.is_customizable():
|
if not plugin.is_customizable():
|
||||||
ca.setEnabled(False)
|
ca.setEnabled(False)
|
||||||
|
@ -64,7 +64,7 @@ class ResultsView(QTreeView):
|
|||||||
|
|
||||||
result = self.model().get_result(index)
|
result = self.model().get_result(index)
|
||||||
|
|
||||||
menu = QMenu()
|
menu = QMenu(self)
|
||||||
da = menu.addAction(_('Download...'), partial(self.download_requested.emit, result))
|
da = menu.addAction(_('Download...'), partial(self.download_requested.emit, result))
|
||||||
if not result.downloads:
|
if not result.downloads:
|
||||||
da.setEnabled(False)
|
da.setEnabled(False)
|
||||||
|
@ -462,7 +462,7 @@ class TagBrowserBar(QWidget): # {{{
|
|||||||
' items, etc.'
|
' items, etc.'
|
||||||
)))
|
)))
|
||||||
b.setIcon(QIcon(I('config.png')))
|
b.setIcon(QIcon(I('config.png')))
|
||||||
b.m = QMenu()
|
b.m = QMenu(b)
|
||||||
b.setMenu(b.m)
|
b.setMenu(b.m)
|
||||||
|
|
||||||
self.item_search = FindBox(parent)
|
self.item_search = FindBox(parent)
|
||||||
@ -479,7 +479,7 @@ class TagBrowserBar(QWidget): # {{{
|
|||||||
'categories using syntax similar to search. For example, '
|
'categories using syntax similar to search. For example, '
|
||||||
'tags:foo will find foo in any tag, but not in authors etc. Entering '
|
'tags:foo will find foo in any tag, but not in authors etc. Entering '
|
||||||
'*foo will collapse all categories then showing only those categories '
|
'*foo will collapse all categories then showing only those categories '
|
||||||
'with items containing the text "foo"') + '</p')
|
'with items containing the text "foo"') + '</p>')
|
||||||
ac = QAction(parent)
|
ac = QAction(parent)
|
||||||
parent.addAction(ac)
|
parent.addAction(ac)
|
||||||
parent.keyboard.register_shortcut('tag browser find box',
|
parent.keyboard.register_shortcut('tag browser find box',
|
||||||
|
@ -91,7 +91,7 @@ class Check(QSplitter):
|
|||||||
self.items.clear()
|
self.items.clear()
|
||||||
|
|
||||||
def context_menu(self, pos):
|
def context_menu(self, pos):
|
||||||
m = QMenu()
|
m = QMenu(self)
|
||||||
if self.items.count() > 0:
|
if self.items.count() > 0:
|
||||||
m.addAction(QIcon(I('edit-copy.png')), _('Copy list of errors to clipboard'), self.copy_to_clipboard)
|
m.addAction(QIcon(I('edit-copy.png')), _('Copy list of errors to clipboard'), self.copy_to_clipboard)
|
||||||
if list(m.actions()):
|
if list(m.actions()):
|
||||||
|
@ -268,7 +268,7 @@ class Editor(QMainWindow):
|
|||||||
b.addSeparator()
|
b.addSeparator()
|
||||||
self.action_filters = ac = b.addAction(QIcon(I('filter.png')), _('Image filters'))
|
self.action_filters = ac = b.addAction(QIcon(I('filter.png')), _('Image filters'))
|
||||||
b.widgetForAction(ac).setPopupMode(QToolButton.InstantPopup)
|
b.widgetForAction(ac).setPopupMode(QToolButton.InstantPopup)
|
||||||
self.filters_menu = m = QMenu()
|
self.filters_menu = m = QMenu(self)
|
||||||
ac.setMenu(m)
|
ac.setMenu(m)
|
||||||
m.addAction(_('Auto-trim image'), self.canvas.autotrim_image)
|
m.addAction(_('Auto-trim image'), self.canvas.autotrim_image)
|
||||||
m.addAction(_('Sharpen image'), self.sharpen_image)
|
m.addAction(_('Sharpen image'), self.sharpen_image)
|
||||||
|
@ -865,7 +865,7 @@ class WordsView(QTableView):
|
|||||||
w = self.model().word_for_row(self.currentIndex().row())
|
w = self.model().word_for_row(self.currentIndex().row())
|
||||||
if w is not None:
|
if w is not None:
|
||||||
a = m.addAction(_('Change %s to') % w[0])
|
a = m.addAction(_('Change %s to') % w[0])
|
||||||
cm = QMenu()
|
cm = QMenu(self)
|
||||||
a.setMenu(cm)
|
a.setMenu(cm)
|
||||||
cm.addAction(_('Specify replacement manually'), partial(self.change_to.emit, w, None))
|
cm.addAction(_('Specify replacement manually'), partial(self.change_to.emit, w, None))
|
||||||
cm.addSeparator()
|
cm.addSeparator()
|
||||||
@ -874,7 +874,7 @@ class WordsView(QTableView):
|
|||||||
|
|
||||||
m.addAction(_('Ignore/un-ignore all selected words'), self.ignore_all)
|
m.addAction(_('Ignore/un-ignore all selected words'), self.ignore_all)
|
||||||
a = m.addAction(_('Add/remove all selected words'))
|
a = m.addAction(_('Add/remove all selected words'))
|
||||||
am = QMenu()
|
am = QMenu(self)
|
||||||
a.setMenu(am)
|
a.setMenu(am)
|
||||||
for dic in sorted(dictionaries.active_user_dictionaries, key=lambda x:sort_key(x.name)):
|
for dic in sorted(dictionaries.active_user_dictionaries, key=lambda x:sort_key(x.name)):
|
||||||
am.addAction(dic.name, partial(self.add_all.emit, dic.name))
|
am.addAction(dic.name, partial(self.add_all.emit, dic.name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user