diff --git a/vasl_templates/about.py b/vasl_templates/about.py index a4e8de5..d3b941f 100644 --- a/vasl_templates/about.py +++ b/vasl_templates/about.py @@ -1,14 +1,18 @@ """Implement the "about" dialog.""" +import sys import os import json import time import io +import re -from PyQt5 import uic +from PyQt5 import uic, QtCore +from PyQt5.QtCore import QUrl +from PyQt5.QtGui import QDesktopServices, QIcon, QCursor from PyQt5.QtWidgets import QDialog -from vasl_templates.webapp.config.constants import APP_NAME, APP_VERSION, BASE_DIR +from vasl_templates.webapp.config.constants import APP_NAME, APP_VERSION, APP_HOME_URL, BASE_DIR, IS_FROZEN # --------------------------------------------------------------------- @@ -22,11 +26,21 @@ class AboutDialog( QDialog ): # initialize the UI base_dir = os.path.split( __file__ )[0] - dname = os.path.join( base_dir, "ui/about.ui" ) - uic.loadUi( dname, self ) + fname = os.path.join( base_dir, "ui/about.ui" ) + uic.loadUi( fname, self ) self.setFixedSize( self.size() ) self.close_button.clicked.connect( self.on_close ) + # initialize the UI + if IS_FROZEN: + dname = os.path.join( sys._MEIPASS, "vasl_templates/webapp" ) #pylint: disable=no-member,protected-access + else: + dname = os.path.join( os.path.split(__file__)[0], "webapp" ) + fname = os.path.join( dname, "static/images/app.ico" ) + self.app_icon.setPixmap( QIcon( fname ).pixmap(64,64) ) + self.app_icon.mouseReleaseEvent = self.on_app_icon_clicked + self.app_icon.setCursor( QCursor( QtCore.Qt.PointingHandCursor ) ) + # get the build info dname = os.path.join( BASE_DIR, "config" ) fname = os.path.join( dname, "build-info.json" ) @@ -53,9 +67,14 @@ class AboutDialog( QDialog ): self.build_info.setText( buf.getvalue() ) else: self.build_info.setText( "" ) - self.home_url.setText( - "Get the source code and releases from Github." - ) + mo = re.search( r"^https?://(.+)", APP_HOME_URL ) + self.home_url.setText( "Visit us at {}.".format( + APP_HOME_URL, mo.group(1) if mo else APP_HOME_URL + ) ) + + def on_app_icon_clicked( self, event ): #pylint: disable=no-self-use,unused-argument + """Click handler.""" + QDesktopServices.openUrl( QUrl( APP_HOME_URL ) ) def on_close( self ): """Close the dialog.""" diff --git a/vasl_templates/ui/about.ui b/vasl_templates/ui/about.ui index ed9fd2d..e62debd 100644 --- a/vasl_templates/ui/about.ui +++ b/vasl_templates/ui/about.ui @@ -9,8 +9,8 @@ 0 0 - 428 - 142 + 410 + 150 @@ -19,113 +19,130 @@ 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 + + + + 10 + 10 + 64 + 64 + + + + QFrame::NoFrame + + + + + + + + + 80 + 20 + 321 + 44 + + + + + + + + DejaVu Sans + 12 + - - 0 + + *** APP NAME *** - - 0 + + + + + + + DejaVu Sans + true + - - 0 + + *** BUILD INFO *** - - 0 + + + + + + + + 10 + 110 + 391 + 31 + + + + + + + Qt::Horizontal - - - - Qt::Horizontal - - - - 309 - 20 - - - - - - - - - 0 - 0 - - - - Close - - - true - - - - - - - + + + 309 + 20 + + + + + + + + + 0 + 0 + + + + Close + + + true + + + + + + + + + 10 + 100 + 391 + 17 + + + + *** HOME URL *** + + + true + + + + + + 10 + 80 + 388 + 17 + + + + Licensed under the GNU Affero General Public License (v3). + + diff --git a/vasl_templates/webapp/config/constants.py b/vasl_templates/webapp/config/constants.py index c92492a..5a227fe 100644 --- a/vasl_templates/webapp/config/constants.py +++ b/vasl_templates/webapp/config/constants.py @@ -6,6 +6,7 @@ import os APP_NAME = "VASL Templates" APP_VERSION = "v0.10" # nb: also update setup.py APP_DESCRIPTION = "Generate HTML for use in VASL scenarios." +APP_HOME_URL = "https://vasl-templates.org" if getattr( sys, "frozen", False ): IS_FROZEN = True diff --git a/vasl_templates/webapp/static/images/app.ico b/vasl_templates/webapp/static/images/app.ico index 2333135..2e23759 100644 Binary files a/vasl_templates/webapp/static/images/app.ico and b/vasl_templates/webapp/static/images/app.ico differ diff --git a/vasl_templates/webapp/static/images/app.snag b/vasl_templates/webapp/static/images/app.snag new file mode 100644 index 0000000..ff2a39c Binary files /dev/null and b/vasl_templates/webapp/static/images/app.snag differ