Ejemplo n.º 1
0
Archivo: mainUI.py Proyecto: sinhnn/ssh
 def loadDir(self):
     d = QtWidgets.QFileDialog.getExistingDirectory(
         self, "VPS directory", "", QtWidgets.QFileDialog.ShowDirsOnly)
     if not d: return
     data = load_ssh_dir(d)
     name = os.path.basename(os.path.dirname(d))
     model = ListModel(data=data, parent=self)
     self.models.append(model)
     thumbnailWidget = ThumbnailWidget(parent=self, model=model)
     table = SSHWidget(model.getData())
     self.tabWidget.addTab(thumbnailWidget, IMAGE_ICON, shorten(name))
     self.tabWidget.addTab(table, TABLE_ICON, shorten(name))
     return
Ejemplo n.º 2
0
    def data(self, index, role):
        if role == Qt.EditRole and index.column() == self.ColumnID.Color:
            return (self._elements[index.row()].brushColor(),
                    self._elements[index.row()].pmapColor())

        elif role == Qt.ToolTipRole and index.column() == self.ColumnID.Color:
            return ("Hex code : {}\nDouble click to change".format(
                self._elements[index.row()].brushColor().name()))


        elif role == Qt.DecorationRole and index.column() == self.ColumnID.Color:
            row = index.row()
            value = self._elements[row]
            if value.brushColor == value.pmapColor():
                pixmap = QPixmap(_NPIXELS, _NPIXELS)
                pixmap.fill(value.brushColor)
            else:
                a = value.brushColor().rgba()
                b = value.pmapColor().rgba()
                img = QImage(_NPIXELS,_NPIXELS, QImage.Format_RGB32)
                for i in range(_NPIXELS):
                    for j in range(0, _NPIXELS - i):
                        img.setPixel(i, j, a)
                for i in range(_NPIXELS):
                    for j in range(_NPIXELS - i, _NPIXELS):
                        img.setPixel(i, j, b)
                pixmap = QPixmap.fromImage(img)
            icon = QIcon(pixmap)
            return icon
        
        
        else:
            return ListModel.data(self,index,role)
Ejemplo n.º 3
0
Archivo: mainUI.py Proyecto: sinhnn/ssh
    def initUI(self):

        self.tabWidget = QtWidgets.QTabWidget(self)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.tabCloseRequested.connect(self.closeTab)

        # Main thumbnail widgets
        self.models = []
        model = ListModel(data=self._data, parent=self)
        self.models.append(model)

        self._thumbnailWidget = ThumbnailWidget(parent=self, model=model)
        self.table = SSHWidget(
            self._thumbnailWidget.thumbnailListView.model().getData())

        self.tabWidget.addTab(self._thumbnailWidget, IMAGE_ICON,
                              shorten(self._name))
        self.tabWidget.addTab(self.table, TABLE_ICON, shorten(self._name))
        self.setCentralWidget(self.tabWidget)

        self.exitAction = QtWidgets.QAction('Exit', self)
        self.exitAction.setShortcut('Ctrl+Q')
        self.exitAction.triggered.connect(self.on_exit)

        self.loadAction = QtWidgets.QAction('Load Directory', self)
        self.loadAction.triggered.connect(self.loadDir)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(self.loadAction)
        fileMenu.addSeparator()

        self.setWindowTitle("SSH-VNC Manager")
Ejemplo n.º 4
0
    def data(self, index, role):
        if role == Qt.EditRole and index.column() == self.ColumnID.Color:
            return (self._elements[index.row()].brushColor(), self._elements[index.row()].pmapColor())

        elif role == Qt.ToolTipRole and index.column() == self.ColumnID.Color:
            return "Hex code : {}\nDouble click to change".format(self._elements[index.row()].brushColor().name())

        elif role == Qt.DecorationRole and index.column() == self.ColumnID.Color:
            row = index.row()
            return self.createIconForCrop(row)

        else:
            return ListModel.data(self, index, role)
Ejemplo n.º 5
0
    def data(self, index, role):
        if role == Qt.EditRole and index.column() == self.ColumnID.Color:
            return (self._elements[index.row()].brushColor(),
                    self._elements[index.row()].pmapColor())

        elif role == Qt.ToolTipRole and index.column() == self.ColumnID.Color:
            return ("Hex code : {}\nDouble click to change".format(
                self._elements[index.row()].brushColor().name()))

        elif role == Qt.DecorationRole and index.column(
        ) == self.ColumnID.Color:
            row = index.row()
            return self.createIconForCrop(row)

        else:
            return ListModel.data(self, index, role)
Ejemplo n.º 6
0
    def setData(self, index, value, role=Qt.EditRole):
        if role == Qt.EditRole and index.column() == self.ColumnID.Color:
            row = index.row()
            brushColor = QColor(value[0])
            pmapColor = QColor(value[1])
            if brushColor.isValid() and pmapColor.isValid():
                logger.debug("setData: brushColor = {}, pmapColor = {}" "".format(brushColor.name(), pmapColor.name()))
                logger.debug("  self._elements[row] has type {}" "".format(type(self._elements[row])))
                self._elements[row].setBrushColor(brushColor)
                self._elements[row].setPmapColor(pmapColor)
                logger.debug("  self._elements[row].brushColor = {}" "".format(self._elements[row].brushColor().name()))
                logger.debug("  self._elements[row].pmapColor  = {}" "".format(self._elements[row].pmapColor().name()))
                self.dataChanged.emit(index, index)
                return True

        else:
            return ListModel.setData(self, index, value, role)
Ejemplo n.º 7
0
    def setData(self, index, value, role=Qt.EditRole):
        if role == Qt.EditRole and index.column() == self.ColumnID.Color:
            row = index.row()
            brushColor = QColor(value[0])
            pmapColor = QColor(value[1])
            if brushColor.isValid() and pmapColor.isValid():
                print "setData: brushColor = {}, pmapColor = {}".format(
                    brushColor.name(), pmapColor.name())
                print "  self._elements[row] has type {}".format(
                    type(self._elements[row]))
                self._elements[row].setBrushColor(brushColor)
                self._elements[row].setPmapColor(pmapColor)
                print "  self._elements[row].brushColor = {}".format(
                    self._elements[row].brushColor().name())
                print "  self._elements[row].pmapColor  = {}".format(
                    self._elements[row].pmapColor().name())
                self.dataChanged.emit(index, index)
                return True

        else:
            return ListModel.setData(self, index, value, role)
Ejemplo n.º 8
0
    def __init__(self, labels=None, parent=None):
        ListModel.__init__(self,labels, parent)


        self._labels=self._elements
        self.elementSelected.connect(self.labelSelected.emit)
Ejemplo n.º 9
0
 def flags(self, index):
     if  index.column() == self.ColumnID.Color:
         return Qt.ItemIsEnabled | Qt.ItemIsSelectable
     else:
         return ListModel.flags(self, index)
Ejemplo n.º 10
0
    def __init__(self, crops=None, parent=None):
        ListModel.__init__(self, crops, parent)

        self._crops = self._elements
        self.elementSelected.connect(self.cropSelected.emit)
Ejemplo n.º 11
0
 def flags(self, index):
     if index.column() == self.ColumnID.Color:
         return Qt.ItemIsEnabled | Qt.ItemIsSelectable
     else:
         return ListModel.flags(self, index)
Ejemplo n.º 12
0
    def __init__(self, labels=None, parent=None):
        ListModel.__init__(self, labels, parent)

        self._labels = self._elements
        self.elementSelected.connect(self.labelSelected.emit)
Ejemplo n.º 13
0
    def __init__(self, crops=None, parent=None):
        ListModel.__init__(self, crops, parent)

        self._crops = self._elements
        self.elementSelected.connect(self.cropSelected.emit)