|
12 | 12 |
|
13 | 13 | class OqtopusPlugin: |
14 | 14 |
|
15 | | - def __init__(self, iface): |
| 15 | + def __init__(self, iface, modules_config_path=None, about_dialog_cls=None): |
16 | 16 | """Constructor. |
17 | 17 |
|
18 | 18 | :param iface: An interface instance that will be passed to this class |
19 | 19 | which provides the hook by which you can manipulate the QGIS |
20 | 20 | application at run time. |
21 | 21 | :type iface: QgsInterface |
| 22 | + :param modules_config_path: Optional path to the modules configuration YAML file. |
| 23 | + Defaults to ``default_config.yaml`` next to this file. |
| 24 | + :type modules_config_path: Path | None |
| 25 | + :param about_dialog_cls: Optional custom About dialog class. |
| 26 | + Defaults to the bundled ``AboutDialog``. |
| 27 | + :type about_dialog_cls: type | None |
22 | 28 | """ |
23 | 29 | # Save reference to the QGIS interface |
24 | 30 | self.iface = iface |
25 | 31 | self.canvas = iface.mapCanvas() |
| 32 | + self._modules_config_path = ( |
| 33 | + modules_config_path or Path(__file__).parent / "default_config.yaml" |
| 34 | + ) |
| 35 | + self._about_dialog_cls = about_dialog_cls or AboutDialog |
26 | 36 |
|
27 | 37 | self.__version__ = PluginUtils.get_plugin_version() |
28 | 38 |
|
@@ -176,16 +186,18 @@ def unload(self): |
176 | 186 | logger.debug(f"Removed {mod} from sys.modules for clean reload") |
177 | 187 |
|
178 | 188 | def show_main_dialog(self): |
179 | | - conf_path = Path(__file__).parent / "default_config.yaml" |
180 | | - |
181 | | - main_dialog = MainDialog(modules_config_path=conf_path, parent=self.iface.mainWindow()) |
| 189 | + main_dialog = MainDialog( |
| 190 | + modules_config_path=self._modules_config_path, |
| 191 | + about_dialog_cls=self._about_dialog_cls, |
| 192 | + parent=self.iface.mainWindow(), |
| 193 | + ) |
182 | 194 | main_dialog.exec() |
183 | 195 |
|
184 | 196 | def show_logs_folder(self): |
185 | 197 | PluginUtils.open_logs_folder() |
186 | 198 |
|
187 | 199 | def show_about_dialog(self): |
188 | | - about_dialog = AboutDialog(self.iface.mainWindow()) |
| 200 | + about_dialog = self._about_dialog_cls(self.iface.mainWindow()) |
189 | 201 | about_dialog.exec() |
190 | 202 |
|
191 | 203 | def _get_main_menu_action(self): |
|
0 commit comments