parent
c76dea3ab3
commit
6d075744f7
@ -0,0 +1,53 @@ |
||||
"""Implement the "about" dialog.""" |
||||
|
||||
import os |
||||
import json |
||||
import time |
||||
|
||||
from PyQt5 import uic |
||||
from PyQt5.QtWidgets import QDialog |
||||
|
||||
from vasl_templates.webapp.config.constants import APP_NAME, APP_VERSION, BASE_DIR |
||||
|
||||
# --------------------------------------------------------------------- |
||||
|
||||
class AboutDialog( QDialog ): |
||||
"""Show the about box.""" |
||||
|
||||
def __init__( self, parent ) : |
||||
|
||||
# initialize |
||||
super().__init__( parent=parent ) |
||||
|
||||
# initialize the UI |
||||
base_dir = os.path.split( __file__ )[0] |
||||
dname = os.path.join( base_dir, "ui/about.ui" ) |
||||
uic.loadUi( dname, self ) |
||||
self.setFixedSize( self.size() ) |
||||
self.close_button.clicked.connect( self.on_close ) |
||||
|
||||
# get the build info |
||||
dname = os.path.join( BASE_DIR, "config" ) |
||||
fname = os.path.join( dname, "build-info.json" ) |
||||
if os.path.isfile( fname ): |
||||
build_info = json.load( open( fname, "r" ) ) |
||||
else: |
||||
build_info = None |
||||
|
||||
# load the dialog |
||||
self.app_name.setText( "{} ({})".format( APP_NAME, APP_VERSION ) ) |
||||
self.license.setText( "Licensed under the GNU Affero General Public License (v3)." ) |
||||
if build_info: |
||||
timestamp = build_info[ "timestamp" ] |
||||
self.build_info.setText( "Built {}.".format( |
||||
time.strftime( "%d %B %Y %H:%S", time.localtime( timestamp ) ) # nb: "-d" doesn't work on Windows :-/ |
||||
) ) |
||||
else: |
||||
self.build_info.setText( "" ) |
||||
self.home_url.setText( |
||||
"Get the source code and releases from <a href='http://github.com/pacman-ghost/vasl-templates'>Github</a>." |
||||
) |
||||
|
||||
def on_close( self ): |
||||
"""Close the dialog.""" |
||||
self.close() |
@ -0,0 +1,132 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>Dialog</class> |
||||
<widget class="QDialog" name="Dialog"> |
||||
<property name="windowModality"> |
||||
<enum>Qt::ApplicationModal</enum> |
||||
</property> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>428</width> |
||||
<height>142</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>About</string> |
||||
</property> |
||||
<property name="modal"> |
||||
<bool>true</bool> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="app_name"> |
||||
<property name="font"> |
||||
<font> |
||||
<family>DejaVu Sans</family> |
||||
<pointsize>12</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="text"> |
||||
<string>*** APP NAME ***</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="build_info"> |
||||
<property name="text"> |
||||
<string>*** BUILD INFO ***</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="home_url"> |
||||
<property name="text"> |
||||
<string>*** HOME URL ***</string> |
||||
</property> |
||||
<property name="openExternalLinks"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="license"> |
||||
<property name="text"> |
||||
<string>Licensed under the GNU Affero General Public License (v3).</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QWidget" name="widget" native="true"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>0</width> |
||||
<height>30</height> |
||||
</size> |
||||
</property> |
||||
<property name="maximumSize"> |
||||
<size> |
||||
<width>16777215</width> |
||||
<height>30</height> |
||||
</size> |
||||
</property> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<property name="spacing"> |
||||
<number>5</number> |
||||
</property> |
||||
<property name="leftMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="topMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="rightMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="bottomMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>309</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="close_button"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Close</string> |
||||
</property> |
||||
<property name="default"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
Loading…
Reference in new issue