forked from AG_QGIS/Plugin_SN_Basis
Aufgeräumt und Widget fixiert.
This commit is contained in:
@@ -13,25 +13,22 @@ class Navigation:
|
||||
iface.addToolBar(self.toolbar)
|
||||
|
||||
def add_action(self, text, callback, tooltip="", priority=100, icon=None):
|
||||
action = QAction(icon, text, self.iface.mainWindow()) if icon else QAction(text, self.iface.mainWindow())
|
||||
action = QAction(text, self.iface.mainWindow())
|
||||
if icon:
|
||||
action.setIcon(icon)
|
||||
if tooltip:
|
||||
action.setToolTip(tooltip)
|
||||
action.triggered.connect(callback)
|
||||
|
||||
# Action mit Priority speichern
|
||||
self.actions.append((priority, action))
|
||||
return action
|
||||
|
||||
def finalize_menu_and_toolbar(self):
|
||||
# Sortieren nach Priority
|
||||
self.actions.sort(key=lambda x: x[0])
|
||||
|
||||
# Menüeinträge
|
||||
# Menü und Toolbar leeren
|
||||
self.menu.clear()
|
||||
for _, action in self.actions:
|
||||
self.menu.addAction(action)
|
||||
|
||||
# Toolbar-Einträge
|
||||
self.toolbar.clear()
|
||||
for _, action in self.actions:
|
||||
|
||||
# Sortiert nach Priority einfügen
|
||||
for _, action in sorted(self.actions, key=lambda x: x[0]):
|
||||
self.menu.addAction(action)
|
||||
self.toolbar.addAction(action)
|
||||
|
||||
Reference in New Issue
Block a user