Skip to content

Commit

Permalink
minor changes related to app_info and lib_info
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Jan 13, 2019
1 parent 5e6049b commit 077797d
Show file tree
Hide file tree
Showing 20 changed files with 537 additions and 128 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ HydrOffice Sound Speed's documentation


.. note::
© University of New Hampshire, Center for Coastal and Ocean Mapping, 2018. All rights reserved. Portions of this
© University of New Hampshire, Center for Coastal and Ocean Mapping, 2019. All rights reserved. Portions of this
project were developed under a cooperative agreement with NOAA Coast Survey Development Laboratory, and contain
NOAA-developed code in the public domain.
2 changes: 1 addition & 1 deletion freeze/SIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PySide2 import QtWidgets

from hyo2.sis.gui.mainwin import MainWin
from hyo2.sis.app.mainwin import MainWin


class DebugFilter(logging.Filter):
Expand Down
4 changes: 2 additions & 2 deletions hyo2/sis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"""

import logging

log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())

name = "SIS"
__version__ = '0.4.0'
__version__ = '1.0.0'
__author__ = '[email protected]'
__license__ = 'LGPLv3 license'
__copyright__ = 'Copyright 2019 University of New Hampshire, Center for Coastal and Ocean Mapping'

3 changes: 2 additions & 1 deletion hyo2/sis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from multiprocessing import freeze_support

from PySide import QtGui
from PySide2 import QtWidgets

logger = logging.getLogger()
logger.setLevel(logging.NOTSET)
Expand All @@ -25,6 +25,7 @@ def sis_gui():

sys.exit(app.exec_())


if __name__ == '__main__':
freeze_support()
sis_gui()
25 changes: 25 additions & 0 deletions hyo2/sis/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
from hyo2.abc.app.app_info import AppInfo
from hyo2.sis import name, __version__

app_info = AppInfo()

app_info.app_name = name
app_info.app_version = __version__
app_info.app_author = "Giuseppe Masetti(UNH,CCOM)"
app_info.app_author_email = "[email protected]"

app_info.app_license = "LGPLv3"
app_info.app_license_url = "https://www.hydroffice.org/license/"

app_info.app_path = os.path.abspath(os.path.dirname(__file__))

app_info.app_url = "https://www.hydroffice.org/soundspeed/"
app_info.app_manual_url = "https://www.hydroffice.org/manuals/soundspeed/index.html"
app_info.app_support_email = "[email protected]"
app_info.app_latest_url = "https://www.hydroffice.org/latest/soundspeedmanager.txt"

app_info.app_media_path = os.path.join(app_info.app_path, "media")
app_info.app_main_window_object_name = "MainWindow"
app_info.app_license_path = os.path.join(app_info.app_media_path, "LICENSE")
app_info.app_icon_path = os.path.join(app_info.app_media_path, "app_icon.png")
21 changes: 9 additions & 12 deletions hyo2/sis/gui/controlpanel.py → hyo2/sis/app/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
from PySide2 import QtCore, QtGui, QtWidgets

from hyo2.sis.lib.process import SisProcess
from hyo2.sis.gui.infoviewer import InfoViewerDialog
from hyo2.sis.app.infoviewer import InfoViewerDialog
from hyo2.abc.app.qt_progress import QtProgress

logger = logging.getLogger(__name__)


class ControlPanel(QtWidgets.QWidget):

here = os.path.abspath(os.path.dirname(__file__)).replace("\\", "/")

def __init__(self):
Expand Down Expand Up @@ -45,10 +44,10 @@ def __init__(self):
self._make_sis_commands()

self.vbox.addSpacing(12)
credits = QtWidgets.QLabel("<i>Comments and suggestions:</i> "
"<a href='mailto:[email protected]'>[email protected]</a>")
credits.setOpenExternalLinks(True)
self.vbox.addWidget(credits)
comments = QtWidgets.QLabel("<i>Comments and suggestions:</i> "
"<a href='mailto:[email protected]'>[email protected]</a>")
comments.setOpenExternalLinks(True)
self.vbox.addWidget(comments)

# info viewer
self.info_viewer = InfoViewerDialog(self)
Expand Down Expand Up @@ -87,7 +86,7 @@ def _make_sis_settings(self):
self.set_output_ip = QtWidgets.QLineEdit("")
hbox.addWidget(self.set_output_ip)
octet = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"
reg_ex = QtCore.QRegExp("^%s\.%s\.%s\.%s$" % (octet, octet, octet, octet))
reg_ex = QtCore.QRegExp(r"^%s\.%s\.%s\.%s$" % (octet, octet, octet, octet))
validator = QtGui.QRegExpValidator(reg_ex)
self.set_output_ip.setValidator(validator)
self.set_output_ip.setText("127.0.0.1")
Expand Down Expand Up @@ -200,8 +199,8 @@ def _add_source_files(self):
# ask the file path to the user
# noinspection PyCallByClass
selections, _ = QtWidgets.QFileDialog.getOpenFileNames(self, "Add Kongsberg data files", source_folder,
"Kongsberg file (*.all);;All files (*.*)", None,
QtWidgets.QFileDialog.ExistingFiles)
"Kongsberg file (*.all);;All files (*.*)", None,
QtWidgets.QFileDialog.ExistingFiles)
if not selections:
logger.debug('no selection')
return
Expand Down Expand Up @@ -233,7 +232,6 @@ def monitoring(self):
data = self.conn.recv()

if isinstance(data, str):

self.info_viewer.append(data)
# logger.debug("%s" % data)

Expand All @@ -247,7 +245,7 @@ def start_emulation(self):
if self.sis.is_alive():
# noinspection PyCallByClass
QtWidgets.QMessageBox.warning(self, "Emulator running ...", "The emulator is running! Stop it",
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
return

self.info_viewer.viewer.verticalScrollBar().setValue(self.info_viewer.viewer.verticalScrollBar().maximum())
Expand Down Expand Up @@ -284,7 +282,6 @@ def start_emulation(self):
def stop_emulation(self):
logger.debug("stop SIS")
if self.sis:

progress = QtProgress(self)
progress.start(title="Halting", text="Wait while threads stop")
progress.update(value=20)
Expand Down
File renamed without changes.
31 changes: 5 additions & 26 deletions hyo2/sis/gui/mainwin.py → hyo2/sis/app/mainwin.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import logging
import os
import sys

from PySide2 import QtCore, QtGui, QtWidgets

from hyo2.sis import name as sis_name
from hyo2.sis import __version__ as sis_version
from hyo2.sis.gui import controlpanel
from hyo2.sis.app import app_info, controlpanel

logger = logging.getLogger(__name__)


class MainWin(QtWidgets.QMainWindow):

here = os.path.abspath(os.path.dirname(__file__))
media = os.path.join(here, "media")

def __init__(self):
super().__init__()

self.name = sis_name
self.version = sis_version

# setup default project folder
self.projects_folder = self.here
self.name = app_info.app_name
self.version = app_info.app_version

self.setWindowTitle('%s v.%s' % (self.name, self.version))
# noinspection PyArgumentList
Expand All @@ -33,18 +23,7 @@ def __init__(self):
_app.setOrganizationDomain("hydroffice.org")

# set icons
icon_info = QtCore.QFileInfo(os.path.join(self.here, 'media', 'favicon.png'))
self.setWindowIcon(QtGui.QIcon(icon_info.absoluteFilePath()))
if (sys.platform == 'win32') or (os.name is "nt"):

try:
# This is needed to display the app icon on the taskbar on Windows 7
import ctypes
app_id = '%s v.%s' % (self.name, self.version)
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)

except AttributeError as e:
logger.debug("Unable to change app icon: %s" % e)
self.setWindowIcon(QtGui.QIcon(app_info.app_icon_path))

self.panel = controlpanel.ControlPanel()
self.setCentralWidget(self.panel)
Expand All @@ -53,7 +32,7 @@ def _do_you_really_want(self, title="Quit", text="quit"):
"""helper function that show to the user a message windows asking to confirm an action"""
msg_box = QtWidgets.QMessageBox(self)
msg_box.setWindowTitle(title)
msg_box.setIconPixmap(QtGui.QPixmap(os.path.join(self.media, 'favicon.png')).scaled(QtCore.QSize(36, 36)))
msg_box.setIconPixmap(QtGui.QPixmap(app_info.app_icon_path).scaled(QtCore.QSize(36, 36)))
msg_box.setText('Do you really want to %s?' % text)
msg_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
msg_box.setDefaultButton(QtWidgets.QMessageBox.No)
Expand Down
Loading

0 comments on commit 077797d

Please sign in to comment.