Skip to content

Commit

Permalink
UX - Display the next version because we have now only master version…
Browse files Browse the repository at this point in the history
… in the metadata.txt
  • Loading branch information
Gustry committed Aug 10, 2021
1 parent a407025 commit 5b8edfd
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cadastre/dialogs/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog

from cadastre.tools import set_window_title

ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
str(Path(__file__).resolve().parent.parent),
Expand All @@ -28,6 +30,8 @@ def __init__(self, iface, parent=None):
self.iface = iface
self.setupUi(self)

self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))

# Signals/Slot Connections
self.rejected.connect(self.onReject)
self.buttonBox.rejected.connect(self.onReject)
Expand Down
2 changes: 2 additions & 0 deletions cadastre/dialogs/cadastre_export_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import cadastre.cadastre_common_base as cadastre_common

from cadastre.cadastre_export import CadastreExport as cadastreExportBase
from cadastre.tools import set_window_title

PRINT_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
Expand All @@ -43,6 +44,7 @@ def __init__(self, parent=None):
super(cadastrePrintProgress, self).__init__(parent)
# Set up the user interface
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))


from contextlib import contextmanager
Expand Down
2 changes: 2 additions & 0 deletions cadastre/dialogs/cadastre_load_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from qgis.PyQt.QtWidgets import QDialog

from cadastre.cadastre_loading import cadastreLoading
from cadastre.tools import set_window_title

LOAD_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
Expand All @@ -28,6 +29,7 @@ def __init__(self, iface, cadastre_search_dialog, parent=None):
super(CadastreLoadDialog, self).__init__(parent)
self.iface = iface
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))
self.mc = self.iface.mapCanvas()

self.cadastre_search_dialog = cadastre_search_dialog
Expand Down
2 changes: 2 additions & 0 deletions cadastre/dialogs/import_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from cadastre.cadastre_import import cadastreImport
from cadastre.dialogs.dialog_common import CadastreCommon
from cadastre.tools import set_window_title

IMPORT_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
Expand All @@ -32,6 +33,7 @@ def __init__(self, iface, parent=None):
self.iface = iface
super(CadastreImportDialog, self).__init__(parent)
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))

# Images
plugin_dir = str(Path(__file__).resolve().parent.parent)
Expand Down
3 changes: 3 additions & 0 deletions cadastre/dialogs/message_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog

from cadastre.tools import set_window_title

MESSAGE_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
str(Path(__file__).resolve().parent.parent),
Expand All @@ -26,6 +28,7 @@ def __init__(self, iface, message, parent=None):
super(CadastreMessageDialog, self).__init__(parent)
self.iface = iface
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))

self.teMessage.setText(message)

Expand Down
3 changes: 3 additions & 0 deletions cadastre/dialogs/options_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QMessageBox

from cadastre.tools import set_window_title

OPTION_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
str(Path(__file__).resolve().parent.parent),
Expand All @@ -29,6 +31,7 @@ def __init__(self, iface, parent=None):
super(CadastreOptionDialog, self).__init__(parent)
self.iface = iface
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))

# Images
self.plugin_dir = str(Path(__file__).resolve().parent.parent)
Expand Down
2 changes: 2 additions & 0 deletions cadastre/dialogs/parcelle_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from cadastre.dialogs.cadastre_export_dialog import CadastreExport
from cadastre.dialogs.dialog_common import CadastreCommon
from cadastre.tools import set_window_title

PARCELLE_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
Expand All @@ -48,6 +49,7 @@ def __init__(self, iface, layer, feature, cadastre_search_dialog, parent=None):
self.layer = layer
self.mc = iface.mapCanvas()
self.setupUi(self)
self.setWindowTitle('{} {}'.format(self.windowTitle(), set_window_title()))
self.cadastre_search_dialog = cadastre_search_dialog
self.setWindowIcon(QIcon(
os.path.join(
Expand Down
55 changes: 55 additions & 0 deletions cadastre/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
__license__ = "GPL version 3"
__email__ = "[email protected]"

import subprocess
import time

from pathlib import Path

from qgis.utils import pluginMetadata


def timing(f):
"""
Expand All @@ -19,3 +24,53 @@ def wrap(*args):
return ret

return wrap


def current_git_hash() -> str:
""" Retrieve the current git hash number of the git repo (first 6 digit). """
repo_dir = Path(__file__).parent
git_show = subprocess.Popen(
'git rev-parse --short=6 HEAD',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=repo_dir,
universal_newlines=True,
encoding='utf8'
)
hash_number = git_show.communicate()[0].partition('\n')[0]
if hash_number == '':
hash_number = 'unknown'
return hash_number


def next_git_tag():
""" Using Git command, trying to guess the next tag. """
repo_dir = Path(__file__).parent
git_show = subprocess.Popen(
'git describe --tags $(git rev-list --tags --max-count=1)',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=repo_dir,
universal_newlines=True,
encoding='utf8'
)
tag = git_show.communicate()[0].partition('\n')[0]
if not tag:
return 'next'
versions = tag.split('.')
text = '{}.{}.{}-pre'.format(versions[0], versions[1], int(versions[2]) + 1)
return text


def set_window_title() -> str:
""" Set the window title if on a dev version. """
version = pluginMetadata('cadastre', 'version')
if version != 'master':
return ''

# return 'branch {}, commit {}, next {}'.format(
# version, current_git_hash(), next_git_tag())

return 'next {}'.format(next_git_tag())

0 comments on commit 5b8edfd

Please sign in to comment.