Skip to content

Commit

Permalink
Give plugin its own toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamiltoncj committed Jun 12, 2023
1 parent 498c5b8 commit db5ffe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions bulkNominatim.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QAction
from qgis.PyQt.QtWidgets import QAction, QToolButton

import os.path
import webbrowser
Expand All @@ -16,6 +16,11 @@ def __init__(self, iface):

def initGui(self):
"""Initialize BulkNominatim GUI."""
# Set up a toolbar
self.toolbar = self.iface.addToolBar('Bulk Nominatim Toolbar')
self.toolbar.setObjectName('BulkNominatimToolbar')
self.toolbar.setToolTip('Bulk Nominatim Toolbar')

# Initialize the Dialog Boxes
self.settingsDialog = SettingsWidget(self.iface.mainWindow())
self.reverseGeocodeTool = ReverseGeocodeTool(self.iface, self.settingsDialog)
Expand All @@ -27,15 +32,15 @@ def initGui(self):
icon = QIcon(os.path.dirname(__file__) + "/images/icon.png")
self.nominatimAction = QAction(icon, u"Bulk GeoCoding", self.iface.mainWindow())
self.nominatimAction.triggered.connect(self.nominatimTool)
self.iface.addToolBarIcon(self.nominatimAction)
self.toolbar.addAction(self.nominatimAction)
self.iface.addPluginToMenu(u"Nominatim GeoCoding", self.nominatimAction)

# Add Interface for Reverse GeoCoding
icon = QIcon(os.path.dirname(__file__) + "/images/reverse.png")
self.reverseGeocodeAction = QAction(icon, u"Reverse Point GeoCoding", self.iface.mainWindow())
self.reverseGeocodeAction.triggered.connect(self.setReverseGeocodeTool)
self.reverseGeocodeAction.setCheckable(True)
self.iface.addToolBarIcon(self.reverseGeocodeAction)
self.toolbar.addAction(self.reverseGeocodeAction)
self.iface.addPluginToMenu(u"Nominatim GeoCoding", self.reverseGeocodeAction)


Expand Down Expand Up @@ -67,8 +72,8 @@ def unload(self):
self.iface.removePluginMenu(u"Nominatim GeoCoding", self.reverseGeocodeAction)
self.iface.removePluginMenu(u"Nominatim GeoCoding", self.settingsAction)
self.iface.removePluginMenu(u"Nominatim GeoCoding", self.helpAction)
self.iface.removeToolBarIcon(self.nominatimAction)
self.iface.removeToolBarIcon(self.reverseGeocodeAction)
# Remove Toolbar
del self.toolbar
self.reverseGeocodeTool.unload()

def setReverseGeocodeTool(self):
Expand Down
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name=Bulk Nominatim GeoCoding
qgisMinimumVersion=3.4
description=Bulk nominatim geocoding
version=3.0.5
version=3.0.6
author=C Hamilton
email=adenaculture@gmail.com
about=Bulk nominatim geocoding
Expand Down

0 comments on commit db5ffe2

Please sign in to comment.