|
|
|
@ -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 <a href='http://github.com/pacman-ghost/vasl-templates'>Github</a>." |
|
|
|
|
) |
|
|
|
|
mo = re.search( r"^https?://(.+)", APP_HOME_URL ) |
|
|
|
|
self.home_url.setText( "Visit us at <a href='{}'>{}</a>.".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.""" |
|
|
|
|