From ff5c3f3ad4d10885db6e19535c8d43d57a952aff Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 8 Sep 2023 18:35:37 +0100 Subject: [PATCH] change Report btn appearance if there are errors --- qt_ui/LogWidget.py | 25 +++++++++++++++++-------- qt_ui/dockwidget_main.py | 2 +- qt_ui/global_resources.py | 27 ++++++++++++++++++--------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/qt_ui/LogWidget.py b/qt_ui/LogWidget.py index 5d8fccb..4058a92 100644 --- a/qt_ui/LogWidget.py +++ b/qt_ui/LogWidget.py @@ -11,7 +11,8 @@ from specklepy.logging import metrics from specklepy.core.api.credentials import Account from specklepy_qt_ui.qt_ui.global_resources import ( - BACKGR_COLOR, BACKGR_COLOR_LIGHT, BACKGR_COLOR_GREY, BACKGR_COLOR_TRANSPARENT, BACKGR_COLOR_HIGHLIGHT + BACKGR_COLOR, BACKGR_COLOR_LIGHT, BACKGR_COLOR_GREY, BACKGR_COLOR_TRANSPARENT, BACKGR_COLOR_HIGHLIGHT, + NEW_GREY, NEW_GREY_HIGHLIGHT, BACKGR_ERROR_COLOR, BACKGR_ERROR_COLOR_LIGHT ) from specklepy_qt_ui.qt_ui.widget_report import ReportDialog @@ -105,20 +106,28 @@ class LogWidget(QWidget): widget = QWidget() boxLayout = QHBoxLayout(widget) - reportBtn = QPushButton(f"📈 Report") # to '{streamName}' Sent , v - reportBtn.clicked.connect(lambda: self.showReport()) - new_grey = BACKGR_COLOR_GREY.replace("1);","0.2);") - new_grey_highlight = BACKGR_COLOR_HIGHLIGHT.replace("1);","0.3);") - reportBtn.setStyleSheet("QPushButton {color: white; border-radius: 17px;padding:0px;padding-left: 10px;padding-right: 10px;text-align: center;"+ f"{new_grey}" + "} QPushButton:hover { "+ f"{new_grey_highlight}" + " }") - reportBtn.setMaximumWidth(150) - spacer = QPushButton("") spacer.setStyleSheet("QPushButton {padding:0px;"+ f"{BACKGR_COLOR_TRANSPARENT}" + "}") spacer.setMaximumWidth(10) # add btns to widget layout boxLayout.addWidget(btn) #, alignment=Qt.AlignCenter) + + # add report + reportBtn = QPushButton(f"☑️ Report") # 📈 to '{streamName}' Sent , v + reportBtn.clicked.connect(lambda: self.showReport()) + reportBtn.setMaximumWidth(150) + reportBtn.setStyleSheet("QPushButton {color: white; border-radius: 17px;padding:0px;padding-left: 10px;padding-right: 10px;text-align: center;"+ f"{NEW_GREY}" + "} QPushButton:hover { "+ f"{NEW_GREY_HIGHLIGHT}" + " }") + if report is True: + # color report btn + reportList = self.dataStorage.latestActionReport + for item in reportList: + if item["errors"] != "": + reportBtn.setText("⚠️ Report") + #reportBtn.setStyleSheet("QPushButton {color: white; border-radius: 17px;padding:0px;padding-left: 10px;padding-right: 10px;text-align: center;"+ f"{BACKGR_ERROR_COLOR}" + "} QPushButton:hover { "+ f"{BACKGR_ERROR_COLOR_LIGHT}" + " }") + break + boxLayout.addWidget(reportBtn) boxLayout.addWidget(spacer) diff --git a/qt_ui/dockwidget_main.py b/qt_ui/dockwidget_main.py index cd4b795..022f9df 100644 --- a/qt_ui/dockwidget_main.py +++ b/qt_ui/dockwidget_main.py @@ -729,7 +729,7 @@ class SpeckleQGISDialog(QtWidgets.QDockWidget, FORM_CLASS): #print("_________ENABLE OR DISABLE") #print(plugin.active_commit) #print(f"CURRENT TEXT2: {self.streamBranchDropdown.currentText()}") - if plugin.active_commit is not None: + if plugin.active_commit is not None and plugin.btnAction == 1: self.commit_web_view.setEnabled(True) else: self.commit_web_view.setEnabled(False) diff --git a/qt_ui/global_resources.py b/qt_ui/global_resources.py index 8f42acc..b2a54bf 100644 --- a/qt_ui/global_resources.py +++ b/qt_ui/global_resources.py @@ -1,11 +1,28 @@ import os +# colors COLOR_HIGHLIGHT = (210,210,210,1) - SPECKLE_COLOR = (59,130,246,1) SPECKLE_COLOR_LIGHT = (69,140,255,1) ICON_LOGO = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "logo-slab-white@0.5x.png") +ERROR_COLOR = (255,150,150,1) +ERROR_COLOR_LIGHT = (255,210,210,1) + +COLOR = f"color: rgba{str(SPECKLE_COLOR)};" +BACKGR_COLOR_TRANSPARENT = f"background-color: rgba(0,0,0,0);" +BACKGR_COLOR_HIGHLIGHT = f"background-color: rgba{str(COLOR_HIGHLIGHT)};" +BACKGR_COLOR = f"background-color: rgba{str(SPECKLE_COLOR)};" +BACKGR_COLOR_LIGHT = f"background-color: rgba{str(SPECKLE_COLOR_LIGHT)};" +BACKGR_COLOR_GREY = f"background-color: rgba(220,220,220,1);" + +BACKGR_ERROR_COLOR = f"background-color: rgba{str(ERROR_COLOR)};" +BACKGR_ERROR_COLOR_LIGHT = f"background-color: rgba{str(ERROR_COLOR_LIGHT)};" + +NEW_GREY = BACKGR_COLOR_GREY.replace("1);","0.2);") +NEW_GREY_HIGHLIGHT = BACKGR_COLOR_HIGHLIGHT.replace("1);","0.3);") + +# images ICON_SEARCH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "magnify.png") ICON_OPEN_WEB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "open-in-new.png") ICON_REPORT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "chart-line.png") @@ -22,14 +39,6 @@ ICON_RECEIVE_BLACK = os.path.join(os.path.dirname(os.path.abspath(__file__)), "a ICON_SEND_BLUE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-send-blue.png") ICON_RECEIVE_BLUE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "cube-receive-blue.png") -COLOR = f"color: rgba{str(SPECKLE_COLOR)};" -BACKGR_COLOR_TRANSPARENT = f"background-color: rgba(0,0,0,0);" -BACKGR_COLOR_HIGHLIGHT = f"background-color: rgba{str(COLOR_HIGHLIGHT)};" -BACKGR_COLOR = f"background-color: rgba{str(SPECKLE_COLOR)};" -BACKGR_COLOR_LIGHT = f"background-color: rgba{str(SPECKLE_COLOR_LIGHT)};" -BACKGR_COLOR_GREY = f"background-color: rgba(220,220,220,1);" - - ICON_XXL = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/size-xxl.png") ICON_RASTER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_raster.png") ICON_POLYGON = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "/legend_polygon.png")