26 from datetime
import datetime
28 from datetime
import datetime
29 from PyQt5
import QtCore, QtWidgets, QtGui
30 from gradient_info_handler
import GradientInfoHandler
31 from gradient_list_model
import GradientListModel
38 gradientSelected = QtCore.pyqtSignal(object, name=
"gradientSelected")
40 def __init__(self, gradient_edit, parent=None):
41 QtWidgets.QWidget.__init__(self, parent)
55 self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
57 preset_label = QtWidgets.QLabel(self.
text_)
58 font = preset_label.font()
62 self.add_action.setIcon(QtGui.QIcon(GradientPresetWidget.ICONS_DIR+
"add_icon.png"))
64 self.add_action.triggered.connect(self.
Add)
67 self.add_button_.setIconSize(QtCore.QSize(20,20))
68 self.add_button_.setDefaultAction(self.
add_action)
70 grid = QtWidgets.QGridLayout()
71 grid.setContentsMargins(0,5,0,0)
72 grid.addWidget(preset_label, 0, 0, 1, 1)
73 qhbox = QtWidgets.QHBoxLayout()
78 self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
83 self.list_view_.doubleClicked.connect(self.
Load)
88 self.immucontextMenu_.addAction(self.
load_)
96 self.contextMenu_.addAction(self.
load_)
97 self.contextMenu_.addAction(self.
remove_)
98 self.contextMenu_.addAction(self.
rename_)
100 self.remove_.triggered.connect(self.
Remove)
101 self.rename_.triggered.connect(self.
Rename)
105 index = self.list_view_.indexAt(pos)
107 if self.list_model_.IsEditable(index.row()):
108 self.contextMenu_.popup(QtWidgets.QCursor.pos())
110 self.immucontextMenu_.popup(QtWidgets.QCursor.pos())
113 if(self.list_view_.currentIndex().isValid()):
114 self.list_view_.closePersistentEditor(self.list_view_.currentIndex())
115 row = self.list_model_.GetLastRow()
116 if self.list_model_.AddItem(datetime.now().isoformat(
' '), self.gradient_edit_.GetGradient(), row,
True,
True):
117 index = self.list_model_.index(row)
118 self.list_view_.setCurrentIndex(index)
121 QtWidgets.QMessageBox.information(self,
"Gradient not added",
"The gradient could not be added!")
124 if(self.list_view_.currentIndex().isValid()):
125 ret = QtWidgets.QMessageBox.warning(self,
"Delete Gradient",
127 QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
128 if ret == QtWidgets.QMessageBox.Yes:
129 self.list_model_.RemoveItem(self.list_view_.currentIndex().row())
132 if(self.list_view_.currentIndex().isValid()):
133 self.
Load(self.list_view_.currentIndex())
137 self.gradientSelected.emit(self.list_model_.GetGradient(index))
140 if(self.list_view_.currentIndex().isValid()):
141 self.list_view_.edit(self.list_view_.currentIndex())
String DLLEXPORT_OST_BASE GetSharedDataPath()