From a5af5e02ddbf86f1792bba898d40e97762c7ba94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petter=20K=C3=A4llstr=C3=B6m?= <petter.kallstrom@liu.se> Date: Wed, 15 Feb 2023 10:41:35 +0000 Subject: [PATCH] About window --- b_asic/GUI/about_window.py | 99 ++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/b_asic/GUI/about_window.py b/b_asic/GUI/about_window.py index aab822ff..6252c7d0 100644 --- a/b_asic/GUI/about_window.py +++ b/b_asic/GUI/about_window.py @@ -1,13 +1,21 @@ +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 = { "Adding operations": ( "Select an operation under 'Special operations' or 'Core operations' " @@ -119,35 +127,70 @@ class AboutWindow(QDialog): 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): - information_layout = QVBoxLayout() + # |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) - title_label = QLabel("B-ASIC / Better ASIC Toolbox") - subtitle_label = QLabel( - "Construct, simulate and analyze components of an ASIC." + 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) - frame = QFrame() - frame.setFrameShape(QFrame.HLine) - frame.setFrameShadow(QFrame.Sunken) - self.dialog_layout.addWidget(frame) + button4 = QPushButton() + button4.setText("OK") + button4.setFixedWidth(80) + button4.clicked.connect(self.close) - about_label = QLabel( - "B-ASIC is an open source tool using the B-ASIC library to " - "construct, simulate and analyze ASICs.\n" - "B-ASIC is developed under the MIT-license and any extension to " - "the program should follow that same license.\n" - "To read more about how the GUI works please refer to the FAQ " - "under 'Help'." - ) + layout12 = QHBoxLayout() + layout34 = QHBoxLayout() - information_layout.addWidget(title_label) - information_layout.addWidget(subtitle_label) + layout12.addWidget(label1) + layout12.addWidget(self.logo2) - self.dialog_layout.addLayout(information_layout) - self.dialog_layout.addWidget(frame) + layout34.addWidget(label3) + layout34.addWidget(button4) + + hline = QFrame() + hline.setFrameShape(QFrame.HLine) + hline.setFrameShadow(QFrame.Sunken) - self.dialog_layout.addWidget(about_label) + self.dialog_layout.addLayout(layout12) + self.dialog_layout.addWidget(hline) + self.dialog_layout.addLayout(layout34) class FaqWindow(QDialog): @@ -183,3 +226,17 @@ 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() -- GitLab