From 62f3839b20115f3d302bc7459ccf199320272671 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 13 Mar 2023 17:59:12 +0100 Subject: [PATCH] move to listwidget --- src/gui_qt/_py/basewindow.py | 4 +++- src/gui_qt/graphs/drawings.py | 19 ++++++------------- src/resources/_ui/basewindow.ui | 6 ++++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/gui_qt/_py/basewindow.py b/src/gui_qt/_py/basewindow.py index d278e78..f21b01c 100644 --- a/src/gui_qt/_py/basewindow.py +++ b/src/gui_qt/_py/basewindow.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'src/resources/_ui/basewindow.ui' +# Form implementation generated from reading ui file '/autohome/dominik/nmreval-gitea/src/resources/_ui/basewindow.ui' # # Created by: PyQt5 UI code generator 5.15.7 # @@ -568,6 +568,7 @@ class Ui_BaseWindow(object): self.actionTile.setText(_translate("BaseWindow", "Tile windows")) self.actionMinimize.setText(_translate("BaseWindow", "Minimize")) self.actionNew_window.setText(_translate("BaseWindow", "New graph")) + self.actionNew_window.setShortcut(_translate("BaseWindow", "Ctrl+N")) self.actionDelete_window.setText(_translate("BaseWindow", "Delete graph")) self.actionCascade_windows.setText(_translate("BaseWindow", "Cascade windows")) self.actionNext_window.setText(_translate("BaseWindow", "Next")) @@ -582,6 +583,7 @@ class Ui_BaseWindow(object): self.action_mean_t1.setText(_translate("BaseWindow", "Convert mean values...")) self.actionFilon.setText(_translate("BaseWindow", "Log FT...")) self.action_new_set.setText(_translate("BaseWindow", "New set")) + self.action_new_set.setShortcut(_translate("BaseWindow", "Ctrl+Shift+N")) self.action_magnitude.setText(_translate("BaseWindow", "Calculate magnitude")) self.actionCenterMax.setText(_translate("BaseWindow", "Center on max")) self.action_depake.setText(_translate("BaseWindow", "De-paked spectrum")) diff --git a/src/gui_qt/graphs/drawings.py b/src/gui_qt/graphs/drawings.py index 48a183c..b820349 100644 --- a/src/gui_qt/graphs/drawings.py +++ b/src/gui_qt/graphs/drawings.py @@ -37,20 +37,13 @@ class DrawingsWidget(QtWidgets.QWidget, Ui_Form): QtWidgets.QMessageBox.information(self, 'Not working', 'Something is missing to create this object') return - idx = self.treeWidget.selectedIndexes() - if idx: - idx = idx[0] - new_obj = [LineObject, MultipointObject, TextObject, RectangleObject, EllipseObject][self.mode_comboBox.currentIndex()](**dic) - item = self.treeWidget.itemFromIndex(idx) - graph_id = item.data(0, QtCore.Qt.UserRole) + new_obj = [LineObject, MultipointObject, TextObject, RectangleObject, EllipseObject][self.mode_comboBox.currentIndex()](**dic) + graph_id = self.graph_combobox.currentData() - child = QtWidgets.QTreeWidgetItem([str(new_obj)]) - child.setData(0, QtCore.Qt.UserRole, new_obj.id) - item.addChild(child) + child = QtWidgets.QListWidgetItem(str(new_obj)) + child.setData(QtCore.Qt.UserRole, new_obj.id) + self.listWidget.addItem(child) - self.graphs[graph_id].addDrawing(new_obj) - else: - QtWidgets.QMessageBox.information(self, 'Not working', 'No graph is selected to add this object.') + self.graphs[graph_id].addDrawing(new_obj) - self.treeWidget.expandAll() diff --git a/src/resources/_ui/basewindow.ui b/src/resources/_ui/basewindow.ui index 3987eb3..7e45310 100644 --- a/src/resources/_ui/basewindow.ui +++ b/src/resources/_ui/basewindow.ui @@ -757,6 +757,9 @@ New graph + + Ctrl+N + @@ -823,6 +826,9 @@ New set + + Ctrl+Shift+N +