UI refactoring (part 1) #1092
|
@ -113,10 +113,11 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
|||
def __init__(self, parent=None):
|
||||
super(AboutDialog, self).__init__(parent)
|
||||
widgets.load('about.ui', self)
|
||||
commit = paths.lastCommit()[:7]
|
||||
last_commit = paths.lastCommit()
|
||||
version = softwareVersion
|
||||
commit = last_commit.get('commit')
|
||||
if commit:
|
||||
version += '-' + commit
|
||||
version += '-' + commit[:7]
|
||||
self.labelVersion.setText(
|
||||
self.labelVersion.text().replace(
|
||||
':version:', version
|
||||
|
@ -124,6 +125,16 @@ class AboutDialog(QtGui.QDialog, RetranslateMixin):
|
|||
)
|
||||
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):
|
||||
def __init__(self, parent=None, config=None):
|
||||
|
|
|
@ -85,9 +85,9 @@ def createSupportMessage(myapp):
|
|||
return
|
||||
myapp.ui.comboBoxSendFrom.setCurrentIndex(addrIndex)
|
||||
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS)
|
||||
|
||||
|
||||
version = softwareVersion
|
||||
commit = paths.lastCommit()
|
||||
commit = paths.lastCommit().get('commit')
|
||||
if commit:
|
||||
version += " GIT " + commit
|
||||
|
||||
|
|
17
src/paths.py
17
src/paths.py
|
@ -1,5 +1,7 @@
|
|||
from os import environ, path
|
||||
import sys
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
# 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
|
||||
|
@ -95,13 +97,18 @@ def tail(f, lines=20):
|
|||
all_read_text = ''.join(reversed(blocks))
|
||||
return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:])
|
||||
|
||||
|
||||
def lastCommit():
|
||||
githeadfile = path.join(codePath(), '..', '.git', 'logs', 'HEAD')
|
||||
version = ""
|
||||
if (path.isfile(githeadfile)):
|
||||
result = {}
|
||||
if path.isfile(githeadfile):
|
||||
try:
|
||||
with open(githeadfile, 'rt') as githead:
|
||||
version = tail(githead, 1).split()[1]
|
||||
except IOError:
|
||||
line = tail(githead, 1)
|
||||
result['commit'] = line.split()[1]
|
||||
result['time'] = datetime.fromtimestamp(
|
||||
float(re.search(r'>\s*(.*?)\s', line).group(1))
|
||||
)
|
||||
except (IOError, AttributeError, TypeError):
|
||||
pass
|
||||
return version
|
||||
return result
|
||||
|
|
Reference in New Issue
Block a user