Skip to content

Commit

Permalink
アイコンを追加、ツールボタンを追加 (#20)
Browse files Browse the repository at this point in the history
* Bump to 0.4.0

* Add Icon and tool button
  • Loading branch information
ciscorn authored Oct 27, 2023
1 parent addea40 commit 4d14acc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion japanese_grids/algorithms/load_estat_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def groupId(self):
return None

def displayName(self):
return _tr("地域メッシュ統計データを読み込む")
return _tr("地域メッシュ統計を読み込む")

def shortHelpString(self) -> str:
return _tr(_DESCRIPTION)
Expand Down
Binary file modified japanese_grids/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion japanese_grids/metadata.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
41 changes: 41 additions & 0 deletions japanese_grids/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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)
2 changes: 1 addition & 1 deletion japanese_grids/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4d14acc

Please sign in to comment.