Skip to content
Snippets Groups Projects
Commit 22ce6c9c authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Move about window and use in scheduler GUI as well

parent a5af5e02
No related branches found
No related tags found
1 merge request!184Move about window and use in scheduler GUI as well
Pipeline #89630 passed
......@@ -30,14 +30,15 @@ from qtpy.QtWidgets import (
import b_asic.core_operations
import b_asic.special_operations
from b_asic.GUI._preferences import GAP, GRID, MINBUTTONSIZE, PORTHEIGHT
from b_asic.GUI.about_window import AboutWindow, FaqWindow, KeybindsWindow
from b_asic.GUI.arrow import Arrow
from b_asic.GUI.drag_button import DragButton
from b_asic.GUI.gui_interface import Ui_main_window
from b_asic.GUI.select_sfg_window import SelectSFGWindow
from b_asic.GUI.show_pc_window import ShowPCWindow
from b_asic.GUI.simulate_sfg_window import Plot, SimulateSFGWindow
from b_asic.GUI.util_dialogs import FaqWindow, KeybindsWindow
from b_asic.GUI.utils import decorate_class, handle_error
from b_asic.gui_utils.about_window import AboutWindow
from b_asic.port import OutputPort
from b_asic.save_load_structure import python_to_sfg, sfg_to_python
from b_asic.signal_flow_graph import SFG
......
import sys # ONLY FOR DEBUG
from qtpy.QtCore import Qt
from qtpy.QtGui import QCursor, QPixmap
from qtpy.QtWidgets import QApplication # ONLY FOR DEBUG
from qtpy.QtWidgets import (
QDialog,
QFrame,
QHBoxLayout,
QLabel,
QPushButton,
QScrollArea,
QToolTip,
QVBoxLayout,
)
from b_asic._version import __version__
QUESTIONS = {
_QUESTIONS = {
"Adding operations": (
"Select an operation under 'Special operations' or 'Core operations' "
"to add it to the workspace."
......@@ -115,84 +107,6 @@ class KeybindsWindow(QDialog):
self.dialog_layout.addWidget(keybinds_label)
class AboutWindow(QDialog):
def __init__(self, window):
super().__init__()
self._window = window
self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
self.setWindowTitle("About B-ASIC")
self.dialog_layout = QVBoxLayout()
self.setLayout(self.dialog_layout)
self.add_information_to_layout()
def hoverText(self, url):
# self.setWindowTitle(url) # When removing mouse, the title gets "B-ASIC Scheduler". Where does THAT come from?
if url:
QToolTip.showText(QCursor.pos(), url)
else:
QToolTip.hideText()
def add_information_to_layout(self):
# |1 Title |2 |
# | License | Logo | <- layout12
# | Version | |
# ----------------------
# |3 links |4 OK | <- layout34
label1 = QLabel(
"# B-ASIC / Better ASIC Toolbox\n*Construct, simulate and analyze"
" components of an ASIC.*\n\nB-ASIC is an open source tool using"
" the B-ASIC library to construct, simulate and analyze"
" ASICs.\n\nB-ASIC is developed under the MIT-license and any"
" extension to the program should follow that same license.\n\nTo"
" read more about how the GUI works please refer to the FAQ under"
f" 'Help'.\n\n*Version: {__version__}*"
)
label1.setTextFormat(Qt.MarkdownText)
label1.setWordWrap(True)
label1.setOpenExternalLinks(True)
label1.linkHovered.connect(self.hoverText)
self.logo2 = QLabel(self)
self.logo2.setPixmap(
QPixmap("../../small_logo.png").scaledToWidth(100)
)
self.logo2.setFixedWidth(100)
label3 = QLabel(
"""See: <a href="https://da.gitlab-pages.liu.se/B-ASIC/">documentation</a>,"""
""" <a href="https://gitlab.liu.se/da/B-ASIC/">git</a>,"""
""" <a href="https://www.liu.se/?l=en">liu.se</a>,"""
""" <a href="https://liu.se/organisation/liu/isy/da">Computer Engineering</a>."""
)
label3.setOpenExternalLinks(True)
label3.linkHovered.connect(self.hoverText)
button4 = QPushButton()
button4.setText("OK")
button4.setFixedWidth(80)
button4.clicked.connect(self.close)
layout12 = QHBoxLayout()
layout34 = QHBoxLayout()
layout12.addWidget(label1)
layout12.addWidget(self.logo2)
layout34.addWidget(label3)
layout34.addWidget(button4)
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.dialog_layout.addLayout(layout12)
self.dialog_layout.addWidget(hline)
self.dialog_layout.addLayout(layout34)
class FaqWindow(QDialog):
def __init__(self, window):
super().__init__()
......@@ -203,7 +117,7 @@ class FaqWindow(QDialog):
self.dialog_layout = QVBoxLayout()
self.scroll_area = QScrollArea()
self.setLayout(self.dialog_layout)
for question, answer in QUESTIONS.items():
for question, answer in _QUESTIONS.items():
self.add_question_to_layout(question, answer)
self.scroll_area.setWidget(self)
......@@ -226,17 +140,3 @@ class FaqWindow(QDialog):
question_layout.addLayout(answer_layout)
self.dialog_layout.addLayout(question_layout)
# ONLY FOR DEBUG below
def start_about_window():
app = QApplication(sys.argv)
window = AboutWindow(QDialog)
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
start_about_window()
import sys # ONLY FOR DEBUG
from qtpy.QtCore import Qt
from qtpy.QtGui import QCursor, QPixmap
from qtpy.QtWidgets import QApplication # ONLY FOR DEBUG
from qtpy.QtWidgets import (
QDialog,
QFrame,
QHBoxLayout,
QLabel,
QPushButton,
QToolTip,
QVBoxLayout,
)
from b_asic._version import __version__
class AboutWindow(QDialog):
def __init__(self, window):
super().__init__()
self._window = window
self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
self.setWindowTitle("About B-ASIC")
self.dialog_layout = QVBoxLayout()
self.setLayout(self.dialog_layout)
self.add_information_to_layout()
def hoverText(self, url):
# self.setWindowTitle(url) # When removing mouse, the title gets "B-ASIC Scheduler". Where does THAT come from?
if url:
QToolTip.showText(QCursor.pos(), url)
else:
QToolTip.hideText()
def add_information_to_layout(self):
# |1 Title |2 |
# | License | Logo | <- layout12
# | Version | |
# ----------------------
# |3 links |4 OK | <- layout34
label1 = QLabel(
"# B-ASIC / Better ASIC Toolbox\n*Construct, simulate and analyze"
" components of an ASIC.*\n\nB-ASIC is an open source tool using"
" the B-ASIC library to construct, simulate and analyze"
" ASICs.\n\nB-ASIC is developed under the MIT-license and any"
" extension to the program should follow that same license.\n\nTo"
" read more about how the GUI works please refer to the FAQ under"
f" 'Help'.\n\n*Version: {__version__}*"
)
label1.setTextFormat(Qt.MarkdownText)
label1.setWordWrap(True)
label1.setOpenExternalLinks(True)
label1.linkHovered.connect(self.hoverText)
self.logo2 = QLabel(self)
self.logo2.setPixmap(
QPixmap("../../small_logo.png").scaledToWidth(100)
)
self.logo2.setFixedWidth(100)
label3 = QLabel(
"""See: <a href="https://da.gitlab-pages.liu.se/B-ASIC/">documentation</a>,"""
""" <a href="https://gitlab.liu.se/da/B-ASIC/">git</a>,"""
""" <a href="https://www.liu.se/?l=en">liu.se</a>,"""
""" <a href="https://liu.se/organisation/liu/isy/da">Computer Engineering</a>."""
)
label3.setOpenExternalLinks(True)
label3.linkHovered.connect(self.hoverText)
button4 = QPushButton()
button4.setText("OK")
button4.setFixedWidth(80)
button4.clicked.connect(self.close)
layout12 = QHBoxLayout()
layout34 = QHBoxLayout()
layout12.addWidget(label1)
layout12.addWidget(self.logo2)
layout34.addWidget(label3)
layout34.addWidget(button4)
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.dialog_layout.addLayout(layout12)
self.dialog_layout.addWidget(hline)
self.dialog_layout.addLayout(layout34)
# ONLY FOR DEBUG below
def start_about_window():
app = QApplication(sys.argv)
window = AboutWindow(QDialog)
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
start_about_window()
......@@ -46,6 +46,7 @@ from qtpy.QtWidgets import (
import b_asic.scheduler_gui.logger as logger
from b_asic._version import __version__
from b_asic.graph_component import GraphComponent, GraphID
from b_asic.gui_utils.about_window import AboutWindow
from b_asic.schedule import Schedule
from b_asic.scheduler_gui.axes_item import AxesItem
from b_asic.scheduler_gui.operation_item import OperationItem
......@@ -133,6 +134,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.actionT.triggered.connect(self._actionTbtn)
self.splitter.splitterMoved.connect(self._splitter_moved)
self.actionDocumentation.triggered.connect(self._open_documentation)
self.actionAbout.triggered.connect(self._open_about_window)
# Setup event member functions
self.closeEvent = self._close_event
......@@ -461,6 +463,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
else:
event.ignore()
def _open_about_window(self, event=None):
self.about_page = AboutWindow(self)
self.about_page.show()
###########################
# Helper member functions #
###########################
......
......@@ -12,10 +12,10 @@ Module contents
Submodules
----------
GUI.about\_window module
------------------------
GUI.main\_window module
-----------------------
.. automodule:: b_asic.GUI.about_window
.. automodule:: b_asic.GUI.main_window
:members:
:undoc-members:
:show-inheritance:
......@@ -44,14 +44,6 @@ GUI.gui\_interface module
:undoc-members:
:show-inheritance:
GUI.main\_window module
-----------------------
.. automodule:: b_asic.GUI.main_window
:members:
:undoc-members:
:show-inheritance:
GUI.port\_button module
-----------------------
......@@ -92,6 +84,14 @@ GUI.simulate\_sfg\_window module
:undoc-members:
:show-inheritance:
GUI.util\_dialogs module
------------------------
.. automodule:: b_asic.GUI.util_dialogs
:members:
:undoc-members:
:show-inheritance:
GUI.utils module
----------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment