Skip to content
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
9 changes: 4 additions & 5 deletions models2plugin/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import shutil
from pathlib import Path

from qgis.core import Qgis
from qgis.utils import iface
from qgis.core import Qgis, QgsApplication

from models2plugin.__about__ import DIR_PLUGIN_ROOT
from models2plugin.toolbelt import PlgLogger
Expand Down Expand Up @@ -72,9 +71,9 @@ def generate(plugin_output_dir, context, models_to_include: list[str] = []):
f"Processing model: {model_to_include}", log_level=Qgis.MessageLevel.Info
)

current_profile = iface.userProfileManager().getProfile()
current_profile_folder = current_profile.folder()
models_dir = os.path.join(current_profile_folder, "processing", "models")
models_dir = os.path.join(
QgsApplication.qgisSettingsDirPath(), "processing", "models"
)

model_path = Path(models_dir, model_to_include)

Expand Down
21 changes: 13 additions & 8 deletions models2plugin/gui/main_dlg.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
from pathlib import Path

from qgis.core import QgsExpressionContext, QgsExpressionContextUtils, QgsExpression
from qgis.core import (
QgsApplication,
QgsExpression,
QgsExpressionContext,
QgsExpressionContextUtils,
)
from qgis.gui import QgsFileWidget
from qgis.PyQt import QtWidgets, uic
from qgis.utils import iface

from models2plugin.__about__ import DIR_PLUGIN_ROOT
from models2plugin.toolbelt.utils import get_text_content, to_snake_case
Expand All @@ -20,7 +24,9 @@ def __init__(self, parent=None):
self.setupUi(self)

self.authorLineEdit.setText(self.current_qgis_user())
self.outputDirectoryFileWidget.setStorageMode(QgsFileWidget.StorageMode.GetDirectory)
self.outputDirectoryFileWidget.setStorageMode(
QgsFileWidget.StorageMode.GetDirectory
)

self.menu_widget.currentRowChanged.connect(self.display_page)
self.nextButton.clicked.connect(self.go_to_next_page)
Expand Down Expand Up @@ -63,17 +69,16 @@ def display_page(self, index: int):
self.nextButton.setEnabled(next_button_enabled)

def current_qgis_user(self) -> str:
""" With a QGIS Expression, returns the current user name."""
"""With a QGIS Expression, returns the current user name."""
context = QgsExpressionContext()
context.appendScope(QgsExpressionContextUtils.globalScope())
expression = QgsExpression("@user_full_name")
return expression.evaluate(context)

def modelListFileName(self):
current_profile = iface.userProfileManager().getProfile()
current_profile_folder = current_profile.folder()

models_dir = os.path.join(current_profile_folder, "processing", "models")
models_dir = os.path.join(
QgsApplication.qgisSettingsDirPath(), "processing", "models"
)

return [
filename
Expand Down
4 changes: 2 additions & 2 deletions models2plugin/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ tracker=https://github.com/marcu/models2plugin/issues

# experimental flag
deprecated=False
experimental=True
experimental=False
qgisMinimumVersion=3.34
supportsQt6=True

# versioning
version=0.1.0
version=0.1.1
changelog=