UI refactoring (part 1) #1092
|
@ -113,10 +113,11 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(AboutDialog, self).__init__(parent)
|
super(AboutDialog, self).__init__(parent)
|
||||||
widgets.load('about.ui', self)
|
widgets.load('about.ui', self)
|
||||||
commit = paths.lastCommit()[:7]
|
last_commit = paths.lastCommit()
|
||||||
version = softwareVersion
|
version = softwareVersion
|
||||||
|
commit = last_commit.get('commit')
|
||||||
if commit:
|
if commit:
|
||||||
version += '-' + commit
|
version += '-' + commit[:7]
|
||||||
self.labelVersion.setText(
|
self.labelVersion.setText(
|
||||||
self.labelVersion.text().replace(
|
self.labelVersion.text().replace(
|
||||||
':version:', version
|
':version:', version
|
||||||
|
@ -124,6 +125,16 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
||||||
)
|
)
|
||||||
self.labelVersion.setOpenExternalLinks(True)
|
self.labelVersion.setOpenExternalLinks(True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.label_2.setText(
|
||||||
|
self.label_2.text().replace(
|
||||||
|
'2017', str(last_commit.get('time').year)
|
||||||
|
))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
|
|
||||||
class IconGlossaryDialog(QtGui.QDialog, RetranslateMixin):
|
class IconGlossaryDialog(QtGui.QDialog, RetranslateMixin):
|
||||||
def __init__(self, parent=None, config=None):
|
def __init__(self, parent=None, config=None):
|
||||||
|
|
|
@ -87,7 +87,7 @@ def createSupportMessage(myapp):
|
||||||
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
||||||
|
|
||||||
version = softwareVersion
|
version = softwareVersion
|
||||||
commit = paths.lastCommit()
|
commit = paths.lastCommit().get('commit')
|
||||||
if commit:
|
if commit:
|
||||||
version += " GIT " + commit
|
version += " GIT " + commit
|
||||||
|
|
||||||
|
|
17
src/paths.py
17
src/paths.py
|
@ -1,5 +1,7 @@
|
||||||
from os import environ, path
|
from os import environ, path
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# When using py2exe or py2app, the variable frozen is added to the sys
|
# When using py2exe or py2app, the variable frozen is added to the sys
|
||||||
# namespace. This can be used to setup a different code path for
|
# namespace. This can be used to setup a different code path for
|
||||||
|
@ -95,13 +97,18 @@ def tail(f, lines=20):
|
||||||
all_read_text = ''.join(reversed(blocks))
|
all_read_text = ''.join(reversed(blocks))
|
||||||
return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:])
|
return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:])
|
||||||
|
|
||||||
|
|
||||||
def lastCommit():
|
def lastCommit():
|
||||||
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
|
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
|
||||||
version = ""
|
result = {}
|
||||||
if (path.isfile(githeadfile)):
|
if path.isfile(githeadfile):
|
||||||
try:
|
try:
|
||||||
with open(githeadfile, 'rt') as githead:
|
with open(githeadfile, 'rt') as githead:
|
||||||
version = tail(githead, 1).split()[1]
|
line = tail(githead, 1)
|
||||||
except IOError:
|
result['commit'] = line.split()[1]
|
||||||
|
result['time'] = datetime.fromtimestamp(
|
||||||
|
float(re.search(r'>\s*(.*?)\s', line).group(1))
|
||||||
|
)
|
||||||
|
except (IOError, AttributeError, TypeError):
|
||||||
pass
|
pass
|
||||||
return version
|
return result
|
||||||
|
|
Reference in New Issue
Block a user