forked from AG_QGIS/Plugin_SN_Basis
Compare commits
28 Commits
9829ac9c81
...
unstable
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ff465b86d | |||
| f19fe71bfa | |||
| ae5f88c5b8 | |||
| 7cd6e3ef24 | |||
| 1be1420f66 | |||
| f25e30c489 | |||
| 0eb32453d6 | |||
| 841b529ad8 | |||
| ae5725cd03 | |||
| ac5a3993c8 | |||
| 22b45fe19a | |||
|
|
24c2137dc2 | ||
|
|
c0c0387b1d | ||
|
|
663ca770a1 | ||
|
|
04319b6f7b | ||
|
|
1c70d62739 | ||
|
|
3971bd3408 | ||
|
|
fa04fc80e3 | ||
|
|
04bdfbe9d8 | ||
|
|
b6b791e5bd | ||
|
|
82be564c29 | ||
|
|
f42260b66c | ||
|
|
327c25388f | ||
|
|
c6c9613120 | ||
| 6e1f4c615b | |||
| f876218134 | |||
| 948041da52 | |||
| 439de5527a |
133
.gitea/workflows/release.yaml
Normal file
133
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,133 @@
|
||||
name: Release Plugin
|
||||
run-name: "Release | ${{ github.ref_name }}"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: alpine-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Notwendige Abhängigkeiten installieren
|
||||
shell: sh
|
||||
run: |
|
||||
apk add --no-cache bash git jq curl
|
||||
|
||||
- name: Code holen
|
||||
run: |
|
||||
REPO_URL="https://${RELEASE_TOKEN}:x-oauth-basic@${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
git clone "$REPO_URL" repo
|
||||
cd repo
|
||||
|
||||
git checkout "$TAG"
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
TAG: "${{ github.ref_name }}"
|
||||
|
||||
- name: Version und Kanal bestimmen
|
||||
id: releaseinfo
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
RAW_VERSION="${TAG#v}"
|
||||
VERSION="${RAW_VERSION%%-*}"
|
||||
|
||||
# Channel und Suffix automatisch bestimmen anhand des Tag-Suffix
|
||||
case "$RAW_VERSION" in
|
||||
*-testing*|*-t|*-T)
|
||||
CHANNEL="testing"
|
||||
PRERELEASE="true"
|
||||
SUFFIX="-testing"
|
||||
;;
|
||||
*-unstable*|*-u|*-U)
|
||||
CHANNEL="unstable"
|
||||
PRERELEASE="true"
|
||||
SUFFIX="-unstable"
|
||||
;;
|
||||
*)
|
||||
CHANNEL="stable"
|
||||
PRERELEASE="false"
|
||||
SUFFIX=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# Output setzen
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
|
||||
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
|
||||
|
||||
# Optional Debug
|
||||
echo "VERSION=$VERSION"
|
||||
echo "CHANNEL=$CHANNEL"
|
||||
echo "PRERELEASE=$PRERELEASE"
|
||||
|
||||
# - name: plugin.cfg einlesen
|
||||
# id: config
|
||||
# run: |
|
||||
# cd repo
|
||||
# while read -r line || [ -n "$line" ]; do
|
||||
# key="${line%%=*}"
|
||||
# value="${line#*=}"
|
||||
# echo "$key=$value" >> $GITHUB_OUTPUT
|
||||
# done < plugin.cfg
|
||||
|
||||
- name: Payload erzeugen
|
||||
id: payload
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
NAME="${GITHUB_REPOSITORY##*/}"
|
||||
GROUP="${GITHUB_REPOSITORY%%/*}"
|
||||
VERSION="${{ steps.releaseinfo.outputs.version }}"
|
||||
CHANNEL="${{ steps.releaseinfo.outputs.channel }}"
|
||||
PRERELEASE="${{ steps.releaseinfo.outputs.prerelease }}"
|
||||
ZIP_FOLDER="${{ vars.ZIP_FOLDER }}"
|
||||
ZIP_FILE="${ZIP_FOLDER}.zip"
|
||||
TAG="${{ github.ref_name }}"
|
||||
#GIT_URL=${GITHUB_REPOSITORY}
|
||||
|
||||
jq -n \
|
||||
--arg name "$NAME" \
|
||||
--arg group "$GROUP" \
|
||||
--arg version "$VERSION" \
|
||||
--arg channel "$CHANNEL" \
|
||||
--arg prerelease "$PRERELEASE" \
|
||||
--arg zip_folder "$ZIP_FOLDER" \
|
||||
--arg zip_file "$ZIP_FILE" \
|
||||
--arg tag "$TAG" \
|
||||
'{
|
||||
name: $name,
|
||||
group: $group,
|
||||
version: $version,
|
||||
channel: $channel,
|
||||
prerelease: ($prerelease == "true"),
|
||||
zip_folder: $zip_folder,
|
||||
zip_file: $zip_file,
|
||||
tag: $tag
|
||||
}' > payload.json
|
||||
|
||||
cat payload.json
|
||||
|
||||
- name: Repository aktualisieren
|
||||
run: |
|
||||
NAME="${GITHUB_REPOSITORY##*/}"
|
||||
TAG="${{ steps.releaseinfo.outputs.version }}"-"${{ steps.releaseinfo.outputs.channel }}"
|
||||
PAYLOAD_B64=$(base64 -w0 repo/payload.json)
|
||||
|
||||
JSON="{\"ref\":\"hidden/workflows\",\"inputs\":{\"payload\":\"$PAYLOAD_B64\",\"name\":\"$NAME\",\"tag\":\"$TAG\"}}"
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON" \
|
||||
"https://${{ vars.RELEASE_URL }}/api/v1/repos/${OWNER}/Repository/actions/workflows/${WORKFLOW}/dispatches"
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
OWNER: "AG_QGIS"
|
||||
WORKFLOW: "release.yaml"
|
||||
|
||||
@@ -1,289 +0,0 @@
|
||||
name: Release Plugin
|
||||
run-name: "Release | ${{ github.ref_name }}"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: alpine-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Notwendige Abhängigkeiten installieren
|
||||
shell: sh
|
||||
run: |
|
||||
apk add --no-cache git zip curl jq rsync bash
|
||||
git config --global http.sslVerify false
|
||||
|
||||
- name: Code holen
|
||||
run: |
|
||||
# Tag aus GitHub Actions Kontext extrahieren
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
# Repo-URL dynamisch aus vars und github.repository bauen
|
||||
REPO_URL="https://${RELEASE_TOKEN}:x-oauth-basic@${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
# Repository klonen
|
||||
git clone "$REPO_URL" repo
|
||||
cd repo
|
||||
|
||||
git checkout "$TAG"
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- name: Version und Kanal bestimmen
|
||||
id: releaseinfo
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
VERSION="${TAG#v}"
|
||||
|
||||
case "$TAG" in
|
||||
*-unstable*)
|
||||
CHANNEL="unstable"
|
||||
DRAFT="false"
|
||||
PRERELEASE="true"
|
||||
;;
|
||||
*-testing*)
|
||||
CHANNEL="testing"
|
||||
DRAFT="false"
|
||||
PRERELEASE="true"
|
||||
;;
|
||||
*)
|
||||
CHANNEL="stable"
|
||||
DRAFT="false"
|
||||
PRERELEASE="false"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
|
||||
echo "draft=$DRAFT" >> $GITHUB_OUTPUT
|
||||
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: plugin.info einlesen
|
||||
id: info
|
||||
run: |
|
||||
cd repo
|
||||
while IFS='=' read -r key value; do
|
||||
echo "$key=$value" >> $GITHUB_OUTPUT
|
||||
done < plugin.info
|
||||
|
||||
- name: Changelog einlesen
|
||||
id: changelog
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
# Aktueller Block = alles vor dem ersten ---
|
||||
CURRENT=$(awk '/^---/{exit} {print}' changelog.txt)
|
||||
|
||||
# Vollständige Historie = alles nach dem ersten ---
|
||||
HISTORY=$(awk 'found{print} /^---/{found=1}' changelog.txt)
|
||||
|
||||
# Gitea Release Body zusammenbauen
|
||||
VERSION="${{ steps.releaseinfo.outputs.version }}"
|
||||
FULL=$(printf "## %s\n%s\n\n%s" "$VERSION" "$CURRENT" "$HISTORY")
|
||||
|
||||
echo "DEBUG | Aktueller Changelog:"
|
||||
echo "$CURRENT"
|
||||
|
||||
# Für GITHUB_OUTPUT: Multiline via EOF-Marker
|
||||
echo "current<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$CURRENT" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "full<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$FULL" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: metadata.txt erzeugen
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
# ------------------------ GEÄNDERT ------------------------
|
||||
# Temporär die Vorlage aus dem hidden/templates Branch holen
|
||||
git fetch origin hidden/templates
|
||||
git checkout origin/hidden/templates -- metadata.template
|
||||
TEMPLATE="metadata.template"
|
||||
# -----------------------------------------------------------
|
||||
|
||||
# TEMPLATE="templates/metadata.template"
|
||||
OUT="metadata.txt"
|
||||
|
||||
CONTENT=$(cat "$TEMPLATE")
|
||||
|
||||
CONTENT="${CONTENT//\{\{NAME\}\}/${{ steps.info.outputs.name }}}"
|
||||
CONTENT="${CONTENT//\{\{QGIS_MIN\}\}/${{ steps.info.outputs.qgisMinimumVersion }}}"
|
||||
CONTENT="${CONTENT//\{\{QGIS_MAX\}\}/${{ steps.info.outputs.qgisMaximumVersion }}}"
|
||||
CONTENT="${CONTENT//\{\{DESCRIPTION\}\}/${{ steps.info.outputs.description }}}"
|
||||
CONTENT="${CONTENT//\{\{VERSION\}\}/${{ steps.releaseinfo.outputs.version }}}"
|
||||
CONTENT="${CONTENT//\{\{AUTHOR\}\}/${{ steps.info.outputs.author }}}"
|
||||
CONTENT="${CONTENT//\{\{EMAIL\}\}/${{ steps.info.outputs.email }}}"
|
||||
CONTENT="${CONTENT//\{\{HOMEPAGE\}\}/${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}}"
|
||||
CONTENT="${CONTENT//\{\{TRACKER\}\}/${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}}"
|
||||
CONTENT="${CONTENT//\{\{REPOSITORY\}\}/${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}}"
|
||||
CONTENT="${CONTENT//\{\{EXPERIMENTAL\}\}/${{ steps.info.outputs.experimental }}}"
|
||||
CONTENT="${CONTENT//\{\{DEPRECATED\}\}/${{ steps.info.outputs.deprecated }}}"
|
||||
CONTENT="${CONTENT//\{\{QT6\}\}/${{ steps.info.outputs.supportsQt6 }}}"
|
||||
|
||||
printf "%s\n" "$CONTENT" > "$OUT"
|
||||
rm $TEMPLATE
|
||||
|
||||
- name: ZIP-Datei erstellen
|
||||
id: zip
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
ZIP_FOLDER="${{ steps.info.outputs.zip_folder }}"
|
||||
ZIP_FILE="${ZIP_FOLDER}.zip"
|
||||
|
||||
VERSION="${{ steps.releaseinfo.outputs.version }}"
|
||||
REPO_NAME="${GITHUB_REPOSITORY##*/}"
|
||||
#ZIP_NAME="${REPO_NAME}-${VERSION}.zip"
|
||||
|
||||
|
||||
mkdir -p dist/${ZIP_FOLDER}
|
||||
|
||||
rsync -a \
|
||||
--exclude='.git' \
|
||||
--exclude='.gitea' \
|
||||
--exclude='.plugin' \
|
||||
--exclude='dist' \
|
||||
./ dist/${ZIP_FOLDER}/
|
||||
|
||||
cd dist
|
||||
zip -r "${ZIP_FILE}" "${ZIP_FOLDER}/" \
|
||||
-x "*.pyc" -x "*/__pycache__/*"
|
||||
cd ..
|
||||
|
||||
echo "zip_file=${ZIP_FILE}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Gitea-Release erstellen
|
||||
id: create_release
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
VERSION="${{ steps.releaseinfo.outputs.version }}"
|
||||
CHANNEL="${{ steps.releaseinfo.outputs.channel }}"
|
||||
|
||||
API_URL="https://${{ vars.RELEASE_URL }}/api/v1/repos/${GITHUB_REPOSITORY}/releases"
|
||||
|
||||
JSON=$(jq -n \
|
||||
--arg tag "$TAG" \
|
||||
--arg name "Version $VERSION" \
|
||||
--arg body "${{ steps.changelog.outputs.current }}" \
|
||||
--argjson draft "${{ steps.releaseinfo.outputs.draft }}" \
|
||||
--argjson prerelease "${{ steps.releaseinfo.outputs.prerelease }}" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: $draft, prerelease: $prerelease}')
|
||||
|
||||
API_RESPONSE=$(curl -s -X POST "$API_URL" \
|
||||
-H "accept: application/json" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON")
|
||||
|
||||
RELEASE_ID=$(echo "$API_RESPONSE" | jq -r '.id')
|
||||
|
||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
||||
echo "Fehler beim Erstellen des Releases!"
|
||||
echo "$API_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: ZIP-Datei hochladen
|
||||
run: |
|
||||
RELEASE_ID="${{ steps.create_release.outputs.release_id }}"
|
||||
ZIP_FILE="${{ steps.zip.outputs.zip_file }}"
|
||||
|
||||
API_URL="https://${{ vars.RELEASE_URL }}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${ZIP_FILE}"
|
||||
|
||||
curl -s -X POST "$API_URL" \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary "@repo/dist/${ZIP_FILE}" \
|
||||
-o upload_response.json
|
||||
|
||||
# Optional: Fehlerprüfung
|
||||
if jq -e '.id' upload_response.json >/dev/null 2>&1; then
|
||||
echo "ZIP erfolgreich hochgeladen."
|
||||
else
|
||||
echo "Fehler beim Hochladen der ZIP!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Payload erzeugen
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
VERSION="${{ steps.releaseinfo.outputs.version }}"
|
||||
CHANNEL="${{ steps.releaseinfo.outputs.channel }}"
|
||||
ZIP_FILE="${{ steps.zip.outputs.zip_file }}"
|
||||
|
||||
DOWNLOAD_URL="https://${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}/releases/download/${{ github.ref_name }}/${ZIP_FILE}"
|
||||
|
||||
jq -n \
|
||||
--arg name "${{ steps.info.outputs.name }}" \
|
||||
--arg version "$VERSION" \
|
||||
--arg channel "$CHANNEL" \
|
||||
--arg description "${{ steps.info.outputs.description }}" \
|
||||
--arg author "${{ steps.info.outputs.author }}" \
|
||||
--arg email "${{ steps.info.outputs.email }}" \
|
||||
--arg qgis_min "${{ steps.info.outputs.qgisMinimumVersion }}" \
|
||||
--arg qgis_max "${{ steps.info.outputs.qgisMaximumVersion }}" \
|
||||
--arg homepage "${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}" \
|
||||
--arg tracker "${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}" \
|
||||
--arg repository "${{ vars.RELEASE_URL }}/${GITHUB_REPOSITORY}" \
|
||||
--arg experimental "${{ steps.info.outputs.experimental }}" \
|
||||
--arg deprecated "${{ steps.info.outputs.deprecated }}" \
|
||||
--arg qt6 "${{ steps.info.outputs.supportsQt6 }}" \
|
||||
--arg id "${{ steps.info.outputs.zip_folder }}" \
|
||||
--arg url "$DOWNLOAD_URL" \
|
||||
--arg changelog "${{ steps.changelog.outputs.current }}" \
|
||||
'{
|
||||
name: $name,
|
||||
version: $version,
|
||||
channel: $channel,
|
||||
description: $description,
|
||||
author: $author,
|
||||
email: $email,
|
||||
qgis_min: $qgis_min,
|
||||
qgis_max: $qgis_max,
|
||||
homepage: $homepage,
|
||||
tracker: $tracker,
|
||||
repository: $repository,
|
||||
experimental: $experimental,
|
||||
deprecated: $deprecated,
|
||||
qt6: $qt6,
|
||||
id: $id,
|
||||
url: $url,
|
||||
changelog: $changelog
|
||||
}' > payload.json
|
||||
|
||||
- name: Repository aktualisieren
|
||||
run: |
|
||||
OWNER="AG_QGIS"
|
||||
WORKFLOW="update.yml"
|
||||
|
||||
PAYLOAD_B64=$(base64 -w0 repo/payload.json)
|
||||
|
||||
FULL_NAME="${{ steps.info.outputs.name }}"
|
||||
NAME=$(echo "$FULL_NAME" | awk -F'|' '{gsub(/^ +| +$/,"",$2); print $2}')
|
||||
TAG="${{ steps.releaseinfo.outputs.version }}"
|
||||
|
||||
JSON="{\"ref\":\"hidden/workflows\",\"inputs\":{\"payload\":\"$PAYLOAD_B64\",\"name\":\"$NAME\",\"tag\":\"$TAG\"}}"
|
||||
|
||||
#JSON="{\"ref\":\"hidden/workflows\",\"inputs\":{\"payload\":\"$PAYLOAD_B64\"}}"
|
||||
|
||||
echo "DEBUG | Sende JSON:"
|
||||
echo "$JSON"
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON" \
|
||||
"https://${{ vars.RELEASE_URL }}/api/v1/repos/${OWNER}/Repository/actions/workflows/${WORKFLOW}/dispatches"
|
||||
0
changelog.txt
Normal file
0
changelog.txt
Normal file
@@ -5,7 +5,7 @@ from typing import Any
|
||||
from typing import Literal, Optional
|
||||
from sn_basis.functions.qt_wrapper import (
|
||||
QMessageBox, YES, NO, CANCEL, QT_VERSION, exec_dialog, ICON_QUESTION,
|
||||
QProgressDialog, QCoreApplication, Qt,
|
||||
QProgressDialog, QCoreApplication, Qt, QInputDialog, QLineEdit,
|
||||
)
|
||||
|
||||
def ask_yes_no(
|
||||
@@ -39,6 +39,50 @@ def ask_yes_no(
|
||||
return default
|
||||
|
||||
|
||||
def show_info_dialog(title: str, message: str, parent: Any = None) -> None:
|
||||
"""
|
||||
Zeigt einen modalen Info-Dialog mit OK-Button.
|
||||
Blockiert bis der Nutzer bestätigt.
|
||||
"""
|
||||
try:
|
||||
if QT_VERSION == 0: # Mock-Modus
|
||||
print(f"Mock-Modus: show_info_dialog('{title}')")
|
||||
return
|
||||
QMessageBox.information(parent, title, message)
|
||||
except Exception as e:
|
||||
print(f"⚠️ show_info_dialog Fehler: {e}")
|
||||
|
||||
|
||||
def ask_text(
|
||||
title: str,
|
||||
label: str,
|
||||
default_text: str = "",
|
||||
parent: Any = None,
|
||||
) -> tuple[str, bool]:
|
||||
"""Zeigt einen modalen Texteingabe-Dialog und gibt Text + OK-Status zurück."""
|
||||
try:
|
||||
if QT_VERSION == 0: # Mock-Modus
|
||||
print(f"Mock-Modus: ask_text('{title}') -> '{default_text}'")
|
||||
return default_text, True
|
||||
# PyQt6: QLineEdit.EchoMode.Normal / PyQt5: QLineEdit.Normal
|
||||
echo_mode = (
|
||||
getattr(QLineEdit, "Normal", None)
|
||||
or getattr(getattr(QLineEdit, "EchoMode", None), "Normal", None)
|
||||
or 0
|
||||
)
|
||||
text, accepted = QInputDialog.getText(
|
||||
parent,
|
||||
title,
|
||||
label,
|
||||
echo_mode,
|
||||
default_text,
|
||||
)
|
||||
return str(text or ""), bool(accepted)
|
||||
except Exception as e:
|
||||
print(f"⚠️ ask_text Fehler: {e}")
|
||||
return default_text, False
|
||||
|
||||
|
||||
OverwriteDecision = Optional[Literal["overwrite", "append", "cancel"]]
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,13 @@ QgsGeometry: Type[Any]
|
||||
QgsFeatureRequest: Type[Any]
|
||||
QgsCoordinateTransform: Type[Any]
|
||||
QgsCoordinateReferenceSystem: Type[Any]
|
||||
QgsPrintLayout: Type[Any]
|
||||
QgsLayoutItemMap: Type[Any]
|
||||
QgsLayoutItemLabel: Type[Any]
|
||||
QgsLayoutPoint: Type[Any]
|
||||
QgsLayoutSize: Type[Any]
|
||||
QgsUnitTypes: Type[Any]
|
||||
QgsLayoutItem: Type[Any]
|
||||
|
||||
QGIS_AVAILABLE = False
|
||||
|
||||
@@ -48,6 +55,13 @@ try:
|
||||
QgsFeatureRequest as _QgsFeatureRequest,
|
||||
QgsCoordinateTransform as _QgsCoordinateTransform,
|
||||
QgsCoordinateReferenceSystem as _QgsCoordinateReferenceSystem,
|
||||
QgsPrintLayout as _QgsPrintLayout,
|
||||
QgsLayoutItemMap as _QgsLayoutItemMap,
|
||||
QgsLayoutItemLabel as _QgsLayoutItemLabel,
|
||||
QgsLayoutPoint as _QgsLayoutPoint,
|
||||
QgsLayoutSize as _QgsLayoutSize,
|
||||
QgsUnitTypes as _QgsUnitTypes,
|
||||
QgsLayoutItem as _QgsLayoutItem,
|
||||
)
|
||||
|
||||
QgsProject = _QgsProject
|
||||
@@ -63,6 +77,13 @@ try:
|
||||
QgsFeatureRequest = _QgsFeatureRequest
|
||||
QgsCoordinateTransform = _QgsCoordinateTransform
|
||||
QgsCoordinateReferenceSystem = _QgsCoordinateReferenceSystem
|
||||
QgsPrintLayout = _QgsPrintLayout
|
||||
QgsLayoutItemMap = _QgsLayoutItemMap
|
||||
QgsLayoutItemLabel = _QgsLayoutItemLabel
|
||||
QgsLayoutPoint = _QgsLayoutPoint
|
||||
QgsLayoutSize = _QgsLayoutSize
|
||||
QgsUnitTypes = _QgsUnitTypes
|
||||
QgsLayoutItem = _QgsLayoutItem
|
||||
|
||||
QGIS_AVAILABLE = True
|
||||
|
||||
@@ -73,9 +94,17 @@ try:
|
||||
except Exception:
|
||||
QGIS_AVAILABLE = False
|
||||
|
||||
class _MockLayoutManager:
|
||||
def layoutByName(self, name: str):
|
||||
return None
|
||||
|
||||
def addLayout(self, layout: Any) -> bool:
|
||||
return True
|
||||
|
||||
class _MockQgsProject:
|
||||
def __init__(self):
|
||||
self._variables = {}
|
||||
self._layout_manager = _MockLayoutManager()
|
||||
|
||||
@staticmethod
|
||||
def instance() -> "_MockQgsProject":
|
||||
@@ -84,6 +113,9 @@ except Exception:
|
||||
def read(self) -> bool:
|
||||
return True
|
||||
|
||||
def layoutManager(self):
|
||||
return self._layout_manager
|
||||
|
||||
QgsProject = _MockQgsProject
|
||||
|
||||
class _MockQgsVectorLayer:
|
||||
@@ -134,6 +166,110 @@ except Exception:
|
||||
|
||||
QgsRasterLayer = _MockQgsRasterLayer
|
||||
|
||||
class _MockQgsPrintLayout:
|
||||
def __init__(self, project: Any):
|
||||
self.project = project
|
||||
self._name = ""
|
||||
self._page = _MockQgsLayoutPage()
|
||||
|
||||
def initializeDefaults(self) -> None:
|
||||
pass
|
||||
|
||||
def setName(self, name: str) -> None:
|
||||
self._name = name
|
||||
|
||||
def pageCollection(self):
|
||||
return self
|
||||
|
||||
def page(self, index: int):
|
||||
return self._page
|
||||
|
||||
def addLayoutItem(self, item: Any) -> None:
|
||||
pass
|
||||
|
||||
class _MockQgsLayoutPage:
|
||||
def setPageSize(self, size: Any) -> None:
|
||||
self.size = size
|
||||
|
||||
class _MockQgsLayoutItem:
|
||||
class ReferencePoint:
|
||||
LowerLeft = 0
|
||||
|
||||
class _MockQgsLayoutItemMap:
|
||||
def __init__(self, layout: Any):
|
||||
self.layout = layout
|
||||
|
||||
def setId(self, item_id: str) -> None:
|
||||
pass
|
||||
|
||||
def setExtent(self, extent: Any) -> None:
|
||||
pass
|
||||
|
||||
def setScale(self, scale: float) -> None:
|
||||
pass
|
||||
|
||||
def attemptMove(self, point: Any) -> None:
|
||||
pass
|
||||
|
||||
def attemptResize(self, size: Any) -> None:
|
||||
pass
|
||||
|
||||
def setFollowVisibilityPreset(self, active: bool) -> None:
|
||||
pass
|
||||
|
||||
def setFollowVisibilityPresetName(self, name: str) -> None:
|
||||
pass
|
||||
|
||||
class _MockQgsLayoutItemLabel:
|
||||
ModeHtml = 1
|
||||
|
||||
def __init__(self, layout: Any):
|
||||
self.layout = layout
|
||||
|
||||
def setId(self, item_id: str) -> None:
|
||||
pass
|
||||
|
||||
def setText(self, text: str) -> None:
|
||||
pass
|
||||
|
||||
def setMode(self, mode: Any) -> None:
|
||||
pass
|
||||
|
||||
def setFont(self, font: Any) -> None:
|
||||
pass
|
||||
|
||||
def setReferencePoint(self, point: Any) -> None:
|
||||
pass
|
||||
|
||||
def attemptMove(self, point: Any) -> None:
|
||||
pass
|
||||
|
||||
def attemptResize(self, size: Any) -> None:
|
||||
pass
|
||||
|
||||
class _MockQgsLayoutPoint:
|
||||
def __init__(self, x: float, y: float, unit: Any):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.unit = unit
|
||||
|
||||
class _MockQgsLayoutSize:
|
||||
def __init__(self, width: float, height: float, unit: Any):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.unit = unit
|
||||
|
||||
class _MockQgsUnitTypes:
|
||||
LayoutMillimeters = 0
|
||||
|
||||
QgsPrintLayout = _MockQgsPrintLayout
|
||||
QgsLayoutItemMap = _MockQgsLayoutItemMap
|
||||
QgsLayoutItemLabel = _MockQgsLayoutItemLabel
|
||||
QgsLayoutPoint = _MockQgsLayoutPoint
|
||||
QgsLayoutSize = _MockQgsLayoutSize
|
||||
QgsUnitTypes = _MockQgsUnitTypes
|
||||
QgsLayoutItem = _MockQgsLayoutItem
|
||||
|
||||
class _MockQgsFeatureRequest:
|
||||
def __init__(self):
|
||||
self._filter_rect = None
|
||||
|
||||
@@ -76,6 +76,9 @@ except Exception:
|
||||
def removeToolBar(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def openLayoutDesigner(self, layout):
|
||||
return layout
|
||||
|
||||
iface = _MockIface()
|
||||
|
||||
class _MockQgsFileWidget:
|
||||
@@ -132,6 +135,13 @@ def get_main_window():
|
||||
return None
|
||||
|
||||
|
||||
def open_layout_designer(layout: Any) -> Any:
|
||||
try:
|
||||
return iface.openLayoutDesigner(layout)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Dock-Handling
|
||||
# ---------------------------------------------------------
|
||||
|
||||
@@ -29,6 +29,7 @@ QWidget: Type[Any] = object
|
||||
QGridLayout: Type[Any] = object
|
||||
QLabel: Type[Any] = object
|
||||
QLineEdit: Type[Any] = object
|
||||
QInputDialog: Type[Any] = object
|
||||
QGroupBox: Type[Any] = object
|
||||
QVBoxLayout: Type[Any] = object
|
||||
QPushButton: Type[Any] = object
|
||||
@@ -41,7 +42,9 @@ QToolButton: Type[Any] = object
|
||||
QSizePolicy: Type[Any] = object
|
||||
Qt: Type[Any] = object
|
||||
QComboBox: Type[Any] = object
|
||||
QCheckBox: Type[Any] = object
|
||||
QHBoxLayout: Type[Any] = object
|
||||
QFont: Type[Any] = object
|
||||
|
||||
|
||||
def exec_dialog(dialog: Any) -> Any:
|
||||
@@ -73,6 +76,7 @@ try:
|
||||
QGridLayout as _QGridLayout,
|
||||
QLabel as _QLabel,
|
||||
QLineEdit as _QLineEdit,
|
||||
QInputDialog as _QInputDialog,
|
||||
QGroupBox as _QGroupBox,
|
||||
QVBoxLayout as _QVBoxLayout,
|
||||
QPushButton as _QPushButton,
|
||||
@@ -85,8 +89,10 @@ try:
|
||||
QToolButton as _QToolButton,
|
||||
QSizePolicy as _QSizePolicy,
|
||||
QComboBox as _QComboBox,
|
||||
QCheckBox as _QCheckBox,
|
||||
QHBoxLayout as _QHBoxLayout,
|
||||
)
|
||||
from qgis.PyQt.QtGui import QFont as _QFont
|
||||
from qgis.PyQt.QtCore import (
|
||||
QEventLoop as _QEventLoop,
|
||||
QTimer as _QTimer,
|
||||
@@ -118,6 +124,7 @@ try:
|
||||
QGridLayout = _QGridLayout
|
||||
QLabel = _QLabel
|
||||
QLineEdit = _QLineEdit
|
||||
QInputDialog = _QInputDialog
|
||||
QGroupBox = _QGroupBox
|
||||
QVBoxLayout = _QVBoxLayout
|
||||
QPushButton = _QPushButton
|
||||
@@ -129,8 +136,10 @@ try:
|
||||
QToolButton = _QToolButton
|
||||
QSizePolicy = _QSizePolicy
|
||||
QComboBox = _QComboBox
|
||||
QCheckBox = _QCheckBox
|
||||
QVariant = _QVariant
|
||||
QHBoxLayout= _QHBoxLayout
|
||||
QHBoxLayout = _QHBoxLayout
|
||||
QFont = _QFont
|
||||
# ✅ QT6 ENUMS
|
||||
YES = QMessageBox.StandardButton.Yes
|
||||
NO = QMessageBox.StandardButton.No
|
||||
@@ -167,6 +176,7 @@ except (ImportError, AttributeError):
|
||||
QGridLayout as _QGridLayout,
|
||||
QLabel as _QLabel,
|
||||
QLineEdit as _QLineEdit,
|
||||
QInputDialog as _QInputDialog,
|
||||
QGroupBox as _QGroupBox,
|
||||
QVBoxLayout as _QVBoxLayout,
|
||||
QPushButton as _QPushButton,
|
||||
@@ -179,8 +189,10 @@ except (ImportError, AttributeError):
|
||||
QToolButton as _QToolButton,
|
||||
QSizePolicy as _QSizePolicy,
|
||||
QComboBox as _QComboBox,
|
||||
QCheckBox as _QCheckBox,
|
||||
QHBoxLayout as _QHBoxLayout,
|
||||
)
|
||||
from PyQt5.QtGui import QFont as _QFont
|
||||
from PyQt5.QtCore import (
|
||||
QEventLoop as _QEventLoop,
|
||||
QTimer as _QTimer,
|
||||
@@ -210,6 +222,7 @@ except (ImportError, AttributeError):
|
||||
QGridLayout = _QGridLayout
|
||||
QLabel = _QLabel
|
||||
QLineEdit = _QLineEdit
|
||||
QInputDialog = _QInputDialog
|
||||
QGroupBox = _QGroupBox
|
||||
QVBoxLayout = _QVBoxLayout
|
||||
QPushButton = _QPushButton
|
||||
@@ -221,8 +234,10 @@ except (ImportError, AttributeError):
|
||||
QToolButton = _QToolButton
|
||||
QSizePolicy = _QSizePolicy
|
||||
QComboBox = _QComboBox
|
||||
QCheckBox = _QCheckBox
|
||||
QVariant = _QVariant
|
||||
QHBoxLayout = _QHBoxLayout
|
||||
QHBoxLayout= _QHBoxLayout
|
||||
QFont = _QFont
|
||||
|
||||
# ✅ PYQT5 ENUMS
|
||||
YES = QMessageBox.Yes
|
||||
@@ -294,6 +309,13 @@ except (ImportError, AttributeError):
|
||||
|
||||
QFileDialog = _MockQFileDialog
|
||||
|
||||
class _MockQInputDialog:
|
||||
@staticmethod
|
||||
def getText(parent, title, label, mode=None, text=""):
|
||||
return text, True
|
||||
|
||||
QInputDialog = _MockQInputDialog
|
||||
|
||||
class _MockQEventLoop:
|
||||
def exec(self) -> int: return 0
|
||||
def quit(self) -> None: pass
|
||||
@@ -341,11 +363,18 @@ except (ImportError, AttributeError):
|
||||
class _MockLabel:
|
||||
def __init__(self, text: str = ""): self._text = text
|
||||
class _MockLineEdit:
|
||||
Normal = 0
|
||||
|
||||
def __init__(self, *args, **kwargs): self._text = ""
|
||||
def text(self) -> str: return self._text
|
||||
def setText(self, value: str) -> None: self._text = value
|
||||
|
||||
class _MockButton:
|
||||
class _MockFont:
|
||||
def __init__(self, family: str = "", pointSize: int = 10):
|
||||
self.family = family
|
||||
self.pointSize = pointSize
|
||||
|
||||
class _MockButton:
|
||||
def __init__(self, *args, **kwargs): self.clicked = lambda *a, **k: None
|
||||
|
||||
QWidget = _MockWidget
|
||||
@@ -355,6 +384,7 @@ except (ImportError, AttributeError):
|
||||
QGroupBox = _MockWidget
|
||||
QVBoxLayout = _MockLayout
|
||||
QPushButton = _MockButton
|
||||
QFont = _MockFont
|
||||
QCoreApplication = object()
|
||||
|
||||
class _MockQt:
|
||||
@@ -529,6 +559,22 @@ except (ImportError, AttributeError):
|
||||
def setContentsMargins(self, *args, **kwargs):
|
||||
pass
|
||||
QHBoxLayout = _MockQHBoxLayout
|
||||
|
||||
class _MockQCheckBox:
|
||||
def __init__(self, text: str = "", *args, **kwargs):
|
||||
self._text = text
|
||||
self._checked = False
|
||||
|
||||
def setText(self, text: str) -> None:
|
||||
self._text = text
|
||||
|
||||
def isChecked(self) -> bool:
|
||||
return self._checked
|
||||
|
||||
def setChecked(self, checked: bool) -> None:
|
||||
self._checked = checked
|
||||
|
||||
QCheckBox = _MockQCheckBox
|
||||
def exec_dialog(dialog: Any) -> Any:
|
||||
return YES
|
||||
# --------------------------- TEST ---------------------------
|
||||
|
||||
23
metadata.txt
23
metadata.txt
@@ -1,15 +1,14 @@
|
||||
[general]
|
||||
name=LNO Sachsen | Basisfunktionen
|
||||
description=Plugin mit Basisfunktionen
|
||||
author=Michael Otto
|
||||
email=michael.otto@landkreis-mittelsachsen.de
|
||||
homepage=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_SN_Basis
|
||||
repository=https://entwicklung.flurneuordnung-sachsen/AG_QGIS/Repository
|
||||
name=LNO Sachsen | Plugin Basisfunktionen
|
||||
qgisMinimumVersion=3.40
|
||||
qgisMaximumVersion=4.99
|
||||
version=26.3.11
|
||||
deprecated=False
|
||||
qgisMaximumVersion=3.99
|
||||
description=Plugin mit Basisfunktionen
|
||||
version=26.3.6-unstable
|
||||
author=Daniel Helbig
|
||||
email=daniel.helbig@kreis-meissen.de
|
||||
homepage=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_SN_Basis
|
||||
tracker=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_SN_Basis/issues
|
||||
repository=https://entwicklung.flurneuordnung-sachsen.de/AG_QGIS/Plugin_SN_Basis/src/branch/unstable/
|
||||
experimental=true
|
||||
supportsQt6=Yes
|
||||
|
||||
zip_folder=sn_basis
|
||||
deprecated=false
|
||||
supportsQt6=true
|
||||
@@ -56,6 +56,27 @@ class Pruefmanager:
|
||||
)
|
||||
info("DataGrabber Zusammenfassung", message)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Allgemeine Nutzerinteraktionen
|
||||
# ------------------------------------------------------------------
|
||||
def zeige_hinweis(self, titel: str, meldung: str) -> None:
|
||||
"""Zeigt eine modale Hinweismeldung mit OK-Button."""
|
||||
from sn_basis.functions.dialog_wrapper import show_info_dialog
|
||||
show_info_dialog(titel, meldung, parent=self.parent)
|
||||
|
||||
def frage_ja_nein(self, titel: str, meldung: str, default: bool = True) -> bool:
|
||||
"""Stellt eine Ja/Nein-Frage. Gibt True zurück, wenn der Nutzer Ja wählt."""
|
||||
if self.ui_modus != "qgis":
|
||||
return default
|
||||
return ask_yes_no(titel, meldung, default=default, parent=self.parent)
|
||||
|
||||
def frage_text(self, titel: str, meldung: str, default_text: str = "") -> tuple[str, bool]:
|
||||
"""Fragt einen Textwert ab und gibt Text + OK-Status zurück."""
|
||||
from sn_basis.functions.dialog_wrapper import ask_text
|
||||
if self.ui_modus != "qgis":
|
||||
return default_text, True
|
||||
return ask_text(titel, meldung, default_text=default_text, parent=self.parent)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# VERFAHRENS-DB-spezifische Entscheidungen
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user