diff --git a/_freeze.py b/_freeze.py index 3202c9a..c9fb0cb 100755 --- a/_freeze.py +++ b/_freeze.py @@ -7,6 +7,7 @@ import shutil import tempfile import time import datetime +import json import getopt from PyInstaller.__main__ import run as run_pyinstaller @@ -118,6 +119,7 @@ def ignore_files( dname, fnames ): #pylint: disable=redefined-outer-name shutil.copy( "LICENSE.txt", dist_dir ) shutil.copytree( "vasl_templates/webapp/data", os.path.join(dist_dir,"data") ) shutil.copytree( "vasl_templates/webapp/config", os.path.join(dist_dir,"config"), ignore=ignore_files ) + # copy the examples dname = os.path.join( dist_dir, "examples" ) os.makedirs( dname ) @@ -125,6 +127,14 @@ fnames = [ f for f in os.listdir("examples") if os.path.splitext(f)[1] in (".jso for f in fnames: shutil.copy( os.path.join("examples",f), dname ) +# set the build info +build_info = { + "timestamp": int( time.time() ), +} +dname = os.path.join( dist_dir, "config" ) +with open( os.path.join(dname,"build-info.json"), "w" ) as fp: + json.dump( build_info, fp ) + # create the release archive os.chdir( dist_dir ) print() diff --git a/vasl_templates/about.py b/vasl_templates/about.py new file mode 100644 index 0000000..aa96937 --- /dev/null +++ b/vasl_templates/about.py @@ -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 Github." + ) + + def on_close( self ): + """Close the dialog.""" + self.close() diff --git a/vasl_templates/main.py b/vasl_templates/main.py index 14b7573..e65f0c5 100755 --- a/vasl_templates/main.py +++ b/vasl_templates/main.py @@ -48,7 +48,7 @@ def qtMessageHandler( msg_type, context, msg ):# pylint: disable=unused-argument @click.option( "--remote-debugging", help="Chrome DevTools port number." ) @click.option( "--debug", help="Debug config file." ) def main( template_pack, default_scenario, remote_debugging, debug ): - """Main entry point for the application.""" + """Manage HTML labels in a VASL scenario.""" try: return _do_main( template_pack, default_scenario, remote_debugging, debug ) except Exception as ex: #pylint: disable=broad-except diff --git a/vasl_templates/main_window.py b/vasl_templates/main_window.py index 6b48cba..b5706a2 100644 --- a/vasl_templates/main_window.py +++ b/vasl_templates/main_window.py @@ -73,6 +73,7 @@ class MainWindow( QWidget ): action.triggered.connect( handler ) file_menu.addAction( action ) add_action( "&Settings", self.on_settings ) + add_action( "&About", self.on_about ) add_action( "E&xit", self.on_exit ) # set the window geometry @@ -200,6 +201,12 @@ class MainWindow( QWidget ): dlg = ServerSettingsDialog( self ) dlg.exec_() + def on_about( self ): + """Menu action handler.""" + from vasl_templates.about import AboutDialog #pylint: disable=cyclic-import + dlg = AboutDialog( self ) + dlg.exec_() + @pyqtSlot() @catch_exceptions( caption="SLOT EXCEPTION" ) def on_app_loaded( self ): diff --git a/vasl_templates/ui/about.ui b/vasl_templates/ui/about.ui new file mode 100644 index 0000000..ed9fd2d --- /dev/null +++ b/vasl_templates/ui/about.ui @@ -0,0 +1,132 @@ + + + Dialog + + + Qt::ApplicationModal + + + + 0 + 0 + 428 + 142 + + + + About + + + true + + + + + + + DejaVu Sans + 12 + + + + *** APP NAME *** + + + + + + + *** BUILD INFO *** + + + + + + + *** HOME URL *** + + + true + + + + + + + Licensed under the GNU Affero General Public License (v3). + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + 16777215 + 30 + + + + + 5 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 309 + 20 + + + + + + + + + 0 + 0 + + + + Close + + + true + + + + + + + + + + +