Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

アイコンを追加、ツールボタンを追加 #20

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
return None

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

Check warning on line 130 in japanese_grids/algorithms/load_estat_csv.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/algorithms/load_estat_csv.py#L130

Added line #L130 was not covered by tests

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 @@
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(

Check warning on line 45 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L42-L45

Added lines #L42 - L45 were not covered by tests
lambda: execAlgorithmDialog("japanesegrid:creategridsquare", {})
)
tool_button.setDefaultAction(default_action)

Check warning on line 48 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L48

Added line #L48 was not covered by tests

menu = QMenu()
tool_button.setMenu(menu)
tool_button.setPopupMode(QToolButton.MenuButtonPopup)

Check warning on line 52 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L50-L52

Added lines #L50 - L52 were not covered by tests

action_grid_square = QAction(icon, "地域メッシュを作成", self.iface.mainWindow())
action_grid_square.triggered.connect(

Check warning on line 55 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L54-L55

Added lines #L54 - L55 were not covered by tests
lambda: execAlgorithmDialog("japanesegrid:creategridsquare", {})
)
menu.addAction(action_grid_square)

Check warning on line 58 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L58

Added line #L58 was not covered by tests

action_legacy = QAction(icon, "国土基本図郭を作成", self.iface.mainWindow())
action_legacy.triggered.connect(

Check warning on line 61 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L60-L61

Added lines #L60 - L61 were not covered by tests
lambda: execAlgorithmDialog("japanesegrid:createlegacygrid", {})
)
menu.addAction(action_legacy)

Check warning on line 64 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L64

Added line #L64 was not covered by tests

action_estat = QAction(icon, "地域メッシュ統計を読み込む", self.iface.mainWindow())
action_estat.triggered.connect(

Check warning on line 67 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L66-L67

Added lines #L66 - L67 were not covered by tests
lambda: execAlgorithmDialog("japanesegrid:loadestatgridstats", {})
)
menu.addAction(action_estat)

Check warning on line 70 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L70

Added line #L70 was not covered by tests

self.toolButtonAction = self.iface.addToolBarWidget(tool_button)

Check warning on line 72 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L72

Added line #L72 was not covered by tests

def unload(self):
if self.iface:
self.iface.removeToolBarIcon(self.toolButtonAction)

Check warning on line 76 in japanese_grids/plugin.py

View check run for this annotation

Codecov / codecov/patch

japanese_grids/plugin.py#L76

Added line #L76 was not covered by tests
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