From 8900c89214b1d9a929aad8a0ec5a48a3e2c940eb Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 9 Mar 2022 14:20:09 +0200 Subject: [PATCH] - added a few new GUI custom widgets - removed the status bar Tcl Shell toggleable QLable. Now the Tcl Shell is toggled by clicking the Message in the Status bar --- CHANGELOG.md | 5 ++++ appGUI/GUIElements.py | 58 ++++++++++++++++++++++++++++++++++++++++++- appGUI/MainGUI.py | 24 +----------------- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11b349e5..8bd0ab77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +9.03.2022 + +- added a few new GUI custom widgets +- removed the status bar Tcl Shell toggleable QLable. Now the Tcl Shell is toggled by clicking the Message in the Status bar + 24.02.2022 - some changes to the Preferences diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index 0c9d8834..b98de4f1 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -5238,12 +5238,16 @@ class FlatCAMInfoBar(QtWidgets.QWidget): """ This class create a place to display the App messages in the Status Bar """ + clicked = QtCore.pyqtSignal(bool) def __init__(self, parent=None, app=None): super(FlatCAMInfoBar, self).__init__(parent=parent) self.app = app + # for the usage of this label as a clickable label, to know that current state + self.clicked_state = False + self.icon = QtWidgets.QLabel(self) self.icon.setGeometry(0, 0, 12, 12) self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png') @@ -5270,6 +5274,11 @@ class FlatCAMInfoBar(QtWidgets.QWidget): layout.addWidget(self.text) layout.addStretch() + def mousePressEvent(self, event): + if event.button() == Qt.MouseButton.LeftButton: + self.clicked_state = not self.clicked_state + self.clicked.emit(self.clicked_state) + def set_text_(self, text, color=None): self.text.setText(text) self.text.setToolTip(text) @@ -5487,7 +5496,54 @@ class FCMessageBox(QtWidgets.QMessageBox): def mouseMoveEvent(self, event): if self.moving: self.move(event.globalPosition().toPoint() - self.offset.toPoint()) - + + +class FCDateTime(QtWidgets.QDateTimeEdit): + + def __init__(self, parent): + super(FCDateTime, self).__init__(parent) + + def set_value(self, val): + year = val[0] + month = val[1] + day = val[2] + hour = val[3] + min = val[4] + date = QDateTime(year, month, day, hour, min) + self.setDateTime(date) + + def get_value(self): + dt = self.dateTime() + date = dt.date() + time = dt.time() + date_list = [date.year(), date.month(), date.day(), time.hour(), time.minute()] + return date_list + + +class FCDate(QtWidgets.QDateEdit): + + def __init__(self, parent=None): + super(FCDate, self).__init__(parent) + self.setStyleSheet(""" + QDateEdit { + border: 0px solid white; + background-color : none; + } + """) + + def set_value(self, val): + val_split = val.split('-') + year = int(val_split[0]) + month = int(val_split[1]) + day = int(val_split[2]) + date = QDate(year, month, day) + self.setDate(date) + + def get_value(self): + date = self.date() + date_formated = date.toString(QtCore.Qt.DateFormat.ISODate) + return date_formated + def message_dialog(title, message, kind="info", parent=None): """ diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index d0b30c1c..64732cf8 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1354,12 +1354,6 @@ class MainGUI(QtWidgets.QMainWindow): self.status_toolbar.addWidget(self.pref_status_label) self.status_toolbar.addWidget(FCLabel(" ")) - self.shell_status_label = FCLabel() - self.shell_status_label.setToolTip(_("Command Line")) - self.shell_status_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/shell20.png')) - self.status_toolbar.addWidget(self.shell_status_label) - self.status_toolbar.addWidget(FCLabel(" ")) - self.hud_label = FCLabel() self.hud_label.setToolTip(_("HUD (Heads up display)")) self.hud_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/hud16.png')) @@ -2009,7 +2003,7 @@ class MainGUI(QtWidgets.QMainWindow): self.clear_btn.clicked.connect(self.on_gui_clear) self.wplace_label.clicked.connect(self.app.on_workspace_toggle) - self.shell_status_label.clicked.connect(self.toggle_shell_ui) + self.fcinfo.clicked.connect(self.toggle_shell_ui) # to be used in the future # self.plot_tab_area.tab_attached.connect(lambda x: print(x)) @@ -2036,8 +2030,6 @@ class MainGUI(QtWidgets.QMainWindow): self.geom_update[int, int, int, int, int].connect(self.save_geometry) self.final_save.connect(self.app.final_save) - self.shell_dock.visibilityChanged.connect(self.on_shelldock_toggled) - # Notebook and Plot Tab Area signals # make the right click on the notebook tab and plot tab area tab raise a menu self.notebook.tabBar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu) @@ -2853,20 +2845,6 @@ class MainGUI(QtWidgets.QMainWindow): # no_km) # QtCore.QCoreApplication.instance().sendEvent(self.shell._edit, f) - def on_shelldock_toggled(self, visibility): - if visibility is True: - self.shell_status_label.setStyleSheet(""" - QLabel - { - color: black; - background-color: lightcoral; - } - """) - self.app.inform[str, bool].emit(_("Shell enabled."), False) - else: - self.shell_status_label.setStyleSheet("") - self.app.inform[str, bool].emit(_("Shell disabled."), False) - def keyPressEvent(self, event): """ Key event handler for the entire app.