Skip to content

Commit

Permalink
Fix Plugin cannot be accessed from QGIS interface #426
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Nov 10, 2024
1 parent fd9e788 commit a5ac43c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
12 changes: 8 additions & 4 deletions geest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,15 @@ def debug(self):

def run(self):
"""
Shows the settings dialog.
Toggles the visibility of the dock widget.
"""
self.iface.showOptionsDialog(
parent=self.iface.mainWindow(), currentPage="geest"
)
if self.dock_widget.isVisible():
self.dock_widget.hide()
self.run_action.setText("Show GEEST Panel")
else:
self.dock_widget.show()
self.dock_widget.raise_()
self.run_action.setText("Hide GEEST Panel")

def display_information_message_bar(
self,
Expand Down
37 changes: 22 additions & 15 deletions geest/gui/geest_dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def __init__(
self.stacked_widget: QStackedWidget = QStackedWidget()

try:
INTRO_PANEL = 0
ORS_PANEL = 1
SETUP_PANEL = 2
OPEN_PROJECT_PANEL = 3
CREATE_PROJECT_PANEL = 4
TREE_PANEL = 5
HELP_PANEL = 6
# Create and add the "Intro" panel (IntroPanel)
self.intro_widget: IntroPanel = IntroPanel()
intro_panel: QWidget = QWidget()
Expand All @@ -63,7 +70,7 @@ def __init__(
self.stacked_widget.addWidget(intro_panel)
self.intro_widget.switch_to_next_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(1)
lambda: self.stacked_widget.setCurrentIndex(ORS_PANEL)
)
# Create and add the "ORS" panel (ORSPanel)
self.ors_widget: OrsPanel = OrsPanel()
Expand All @@ -74,11 +81,11 @@ def __init__(
self.stacked_widget.addWidget(ors_panel)
self.ors_widget.switch_to_next_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(2)
lambda: self.stacked_widget.setCurrentIndex(SETUP_PANEL)
)
self.ors_widget.switch_to_previous_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(0)
lambda: self.stacked_widget.setCurrentIndex(INTRO_PANEL)
)

# Create and add the "Project" panel (SetupPanel)
Expand All @@ -91,17 +98,17 @@ def __init__(

self.setup_widget.switch_to_load_project_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(3)
lambda: self.stacked_widget.setCurrentIndex(OPEN_PROJECT_PANEL)
)

self.setup_widget.switch_to_create_project_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(4)
lambda: self.stacked_widget.setCurrentIndex(CREATE_PROJECT_PANEL)
)

self.setup_widget.switch_to_previous_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(1)
# Switch to the previous tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(ORS_PANEL)
)

# Create and add the "Open Project" panel
Expand All @@ -114,11 +121,11 @@ def __init__(

self.open_project_widget.switch_to_next_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(5)
lambda: self.stacked_widget.setCurrentIndex(TREE_PANEL)
)
self.open_project_widget.switch_to_previous_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(3)
# Switch to the previous tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(SETUP_PANEL)
)

# Create and add the "Create Project" panel
Expand All @@ -131,7 +138,7 @@ def __init__(

self.create_project_widget.switch_to_next_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(5)
lambda: self.stacked_widget.setCurrentIndex(TREE_PANEL)
)

# Create and add the "Tree" panel (TreePanel)
Expand All @@ -143,11 +150,11 @@ def __init__(
self.stacked_widget.addWidget(tree_panel)
self.tree_widget.switch_to_next_tab.connect(
# Switch to the next tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(4)
lambda: self.stacked_widget.setCurrentIndex(HELP_PANEL)
)
self.tree_widget.switch_to_previous_tab.connect(
# Switch to the previous tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(2)
lambda: self.stacked_widget.setCurrentIndex(SETUP_PANEL)
)
# Create and add the "Help" panel (HelpPanel)
help_widget: HelpPanel = HelpPanel()
Expand All @@ -158,7 +165,7 @@ def __init__(
self.stacked_widget.addWidget(help_panel)
help_widget.switch_to_previous_tab.connect(
# Switch to the previous tab when the button is clicked
lambda: self.stacked_widget.setCurrentIndex(5)
lambda: self.stacked_widget.setCurrentIndex(TREE_PANEL)
)
# Add the stacked widget to the main layout
layout.addWidget(self.stacked_widget)
Expand All @@ -167,7 +174,7 @@ def __init__(
self.setWidget(main_widget)

# Start with the first panel selected
self.stacked_widget.setCurrentIndex(0)
self.stacked_widget.setCurrentIndex(INTRO_PANEL)

# Customize allowed areas for docking
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
Expand Down

0 comments on commit a5ac43c

Please sign in to comment.