width ()): continue # Show the menu under the name in the menu bar menu. actionGeometry ( x ) # Make sure that the menu item is actually displayed in the menu # and not the overflow if p. Instead get the position of the menu # widget on the menu bar p = x. isVisible (): continue # We can't use x.trigger() because it doesn't put the menu # in the right place. text () = name : try : # The menu item might be hidden if not x. # I don't know if this works on a Mac if x. added_actions : # This depends on no two menus with the same name. height ()))) return except Exception : continue # Now try the menu bar for x in gui. isVisible (): continue yield ( w ) except Exception : continue def show_menu_under_widget ( gui, menu, action, name ): # First try the tool bar for w in toolbar_widgets_for_action ( gui, action ): try : # The w.height() assures that the menu opens below the button. x () = 0 : continue # The button might be hidden if not w. widgetForAction ( action ) # It seems that multiple copies of the action can exist, such as # when the device-connected menu is changed while the device is # connected. #!/usr/bin/env python _license_ = 'GPL v3' _copyright_ = '2010, Kovid Goyal ' _docformat_ = 'restructuredtext en' from functools import partial from zipfile import ZipFile from qt.core import ( QToolButton, QAction, QIcon, QObject, QMenu, QPoint, QKeySequence ) from calibre import prints from nstants import ismacos from calibre.gui2 import Dispatcher from import NameConflict from polyglot.builtins import string_or_bytes def toolbar_widgets_for_action ( gui, action ): # Search the the toolbars for the widget associated with an action, passing # them to the caller for further processing for x in gui.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |