diff --git a/japanese_grids/algorithms/load_estat_csv.py b/japanese_grids/algorithms/load_estat_csv.py index 91b0cbb..a1f7473 100644 --- a/japanese_grids/algorithms/load_estat_csv.py +++ b/japanese_grids/algorithms/load_estat_csv.py @@ -127,7 +127,7 @@ def groupId(self): return None def displayName(self): - return _tr("地域メッシュ統計データを読み込む") + return _tr("地域メッシュ統計を読み込む") def shortHelpString(self) -> str: return _tr(_DESCRIPTION) diff --git a/japanese_grids/icon.png b/japanese_grids/icon.png index 0f89ce8..80144ea 100644 Binary files a/japanese_grids/icon.png and b/japanese_grids/icon.png differ diff --git a/japanese_grids/metadata.txt b/japanese_grids/metadata.txt index 0a45db3..9451cf5 100644 --- a/japanese_grids/metadata.txt +++ b/japanese_grids/metadata.txt @@ -1,6 +1,6 @@ [general] name=Japanese Grid Mesh -version=0.3.0 +version=0.4.0 qgisMinimumVersion=3.6 description=Create common grid squares used in Japan. 日本で使われている「標準地域メッシュ」および「国土基本図図郭」を作成できます。また、国勢調査や経済センサスなどの「地域メッシュ統計」のCSVファイルを読み込むこともできます。プロセッシングツールボックスから利用できます。 author=MIERUNE Inc. diff --git a/japanese_grids/plugin.py b/japanese_grids/plugin.py index b61fa42..6a1abf9 100644 --- a/japanese_grids/plugin.py +++ b/japanese_grids/plugin.py @@ -16,11 +16,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +import contextlib + +from PyQt5.QtWidgets import QAction, QMenu, QToolButton from qgis.core import QgsApplication from qgis.gui import QgisInterface from .provider import JapanMeshProcessingProvider +with contextlib.suppress(ImportError): + from processing import execAlgorithmDialog + class JapanMeshPlugin: """Japanese Grid Square Mesh plugin""" @@ -32,5 +38,40 @@ def initGui(self): self.provider = JapanMeshProcessingProvider() QgsApplication.processingRegistry().addProvider(self.provider) + if self.iface: + tool_button = QToolButton() + icon = self.provider.icon() + default_action = QAction(icon, "地域メッシュを作成", self.iface.mainWindow()) + default_action.triggered.connect( + lambda: execAlgorithmDialog("japanesegrid:creategridsquare", {}) + ) + tool_button.setDefaultAction(default_action) + + menu = QMenu() + tool_button.setMenu(menu) + tool_button.setPopupMode(QToolButton.MenuButtonPopup) + + action_grid_square = QAction(icon, "地域メッシュを作成", self.iface.mainWindow()) + action_grid_square.triggered.connect( + lambda: execAlgorithmDialog("japanesegrid:creategridsquare", {}) + ) + menu.addAction(action_grid_square) + + action_legacy = QAction(icon, "国土基本図郭を作成", self.iface.mainWindow()) + action_legacy.triggered.connect( + lambda: execAlgorithmDialog("japanesegrid:createlegacygrid", {}) + ) + menu.addAction(action_legacy) + + action_estat = QAction(icon, "地域メッシュ統計を読み込む", self.iface.mainWindow()) + action_estat.triggered.connect( + lambda: execAlgorithmDialog("japanesegrid:loadestatgridstats", {}) + ) + menu.addAction(action_estat) + + self.toolButtonAction = self.iface.addToolBarWidget(tool_button) + def unload(self): + if self.iface: + self.iface.removeToolBarIcon(self.toolButtonAction) QgsApplication.processingRegistry().removeProvider(self.provider) diff --git a/japanese_grids/provider.py b/japanese_grids/provider.py index 3b10181..1ac9c71 100644 --- a/japanese_grids/provider.py +++ b/japanese_grids/provider.py @@ -36,7 +36,7 @@ def id(self, *args, **kwargs): return "japanesegrid" def name(self, *args, **kwargs): - return self.tr("地域メッシュツール") + return self.tr("地域メッシュ") def icon(self): path = (Path(__file__).parent / "icon.png").resolve()