Ejemplo n.º 1
0
    def mouseMoveEvent(self, event):
        if self.tab_rect:
            self.tab_rect.moveTopLeft(event.pos())

        if event.buttons(
        ) == Qt.LeftButton and self.pressEvent and not self.bar_rect.contains(
                self.tab_rect):
            event.accept()
            index = self.currentIndex()
            mimeData = QMimeData()
            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(self.pixmap)
            drag.setHotSpot(self.tab_rect.topLeft() - event.pos())
            DetachableTabWidget.drag_widget = self.parent.widget(index)
            DetachableTabWidget.drag_text = self.tabText(index)
            self.parent.removeTab(index)
            dropAction = drag.exec_(Qt.MoveAction | Qt.TargetMoveAction
                                    | Qt.IgnoreAction)
            self.parent.dragLeaveEvent(event)
            if dropAction == 0:
                self.parent.insertTab(index, DetachableTabWidget.drag_widget,
                                      DetachableTabWidget.drag_text)
                self.parent.setCurrentIndex(index)
        else:
            QTabBar.mouseMoveEvent(self, event)
Ejemplo n.º 2
0
    def mouseMoveEvent(self, event):
        if not (event.buttons() & Qt.LeftButton):
            return
        if (event.pos() - self.drag_start_position).manhattanLength() < 2:
            global correction
            correction = event.pos() - self.drag_start_position
        drag = QDrag(self)
        mimedata = QMimeData()
        mimedata.setImageData(self.pixmap().toImage())  # изображение в качестве данных, которое потом можно будет дропнуть

        drag.setMimeData(mimedata)
        #t = QTransform().rotate(ui.angle)
        pixmap = QPixmap(drag.mimeData().imageData())  # POGU
        pixmap = pixmap.scaled(self.size())

        painter = QPainter(pixmap)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        painter.drawPixmap(self.rect(), self.grab())
        painter.end()

        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - self.rect().topLeft())
        drag.exec_(Qt.CopyAction | Qt.MoveAction)
Ejemplo n.º 3
0
    def mousePressEvent(self, event):

        if event.buttons() != Qt.LeftButton:
            return

        icon = QLabel()

        mimeData = QMimeData()
        mime_text = str(self.row) + str(self.column) + str(
            self.__class__.__name__)
        mimeData.setText(mime_text)

        pixmap = QPixmap('images/ExecOp.png').scaled(120, 60)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(self.pixmap)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        if drag.exec_(Qt.CopyAction | Qt.MoveAction,
                      Qt.CopyAction) == Qt.MoveAction:
            icon.close()
        else:
            icon.show()
            icon.setPixmap(self.pixmap)
Ejemplo n.º 4
0
    def mousePressEvent(self, event):

        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        mimeData = QMimeData()
        mimeData.setText(child.type)

        drag = QDrag(self)
        drag.setPixmap(child.pixmap())
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QPixmap(pixmap)
        painter = QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction,
                      Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
Ejemplo n.º 5
0
    def mouseMoveEvent(self, event):
        # перетягивание на левую кнопку мыши + установка минимальной длины для начала перетягивания (4 пикселя)
        if not (event.buttons() & Qt.LeftButton):
            return
        if (event.pos() - self.drag_start_position).manhattanLength() < 2:
            global correction
            correction = event.pos() - self.drag_start_position
        drag = QDrag(self)

        # QMimeData() - класс для хранения данных любого типа во время перетягивания
        mimedata = QMimeData()

        mimedata.setImageData(self.pixmap().toImage())  # изображение в качестве данных, которое потом можно будет дропнуть

        drag.setMimeData(mimedata)

        t = QTransform().rotate(ui.angle)
        pixmap = QPixmap(ui.image_raw_main.transformed(t))  #Все исправление в 3 строчки
        pixmap = pixmap.scaled(self.size())


        painter = QPainter(pixmap)

        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")

        painter.drawPixmap(self.rect(), self.grab())
        painter.end()

        drag.setPixmap(pixmap)  #именно здесь происходит прорисовка изображения, работает и без QPainter, но
        #Но он помогает восстановить качество картинки, по сути перерисовывая новую картинку поверх старой,
        #повреждено из за метода scaled. Картинка из этой строчки по сути является фоном, и именно в ней и была проблема
        drag.setHotSpot(event.pos() - self.rect().topLeft())
        drag.exec_(Qt.CopyAction | Qt.MoveAction)
Ejemplo n.º 6
0
    def mousePressEvent(self, event):
        from widgets.columneditor import ColumnEditor
        from widgets.sectioneditor import SectionEditor
        if self.mode != Mode.ENABLED or event.button() != Qt.LeftButton:
            return

        if self.parentWidget().layout.count() == 1:
            self.elementDragged.emit()

        mimeData = WidgetMimeData()
        mimeData.setData(self)
        parent = self.parentWidget()
        if isinstance(parent, ColumnEditor):
            mimeData.source_list = parent.column._items
        elif isinstance(parent, SectionEditor):
            mimeData.source_list = parent.section._items

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos())
        drag.setPixmap(pixmap)
        self.hide()

        if drag.exec(Qt.MoveAction) == Qt.IgnoreAction:
            self.show()
Ejemplo n.º 7
0
    def mousePressEvent(self, event):

        logging.debug('DropBox::mousePressEvent() called: {}'.format(
            event.pos()))
        try:
            mimeData = QMimeData()
            mimeData.setText(self.type)
            # load config into memory tmp_config of storabar
            self.parent.tmp_config = self.config
            self.parent.tmp_element = self
            # push config to active workingarea
            self.parent.loadConfig()
        except Exception as e:
            logging.error(
                'DropBox::mousePressEvent() Exception caught: {}'.format(
                    str(e)))
            return

        drag = QDrag(self)
        drag.setHotSpot(event.pos())
        drag.setPixmap(self.label.pixmap())
        drag.setMimeData(mimeData)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction,
                      Qt.CopyAction) == Qt.MoveAction:
            self.close()
        else:
            self.show()
            self.label.setPixmap(self.label.pixmap())
            logging.debug('DropBox::mousePressEvent() dropped')
Ejemplo n.º 8
0
    def __prepareDropData(self, event):
        """prepares data for the drag and drop process"""
        drag = QDrag(self)

        dropData = QMimeData()
        data = {
            'id':
            self.tileLayout.id,
            'from_row':
            self.fromRow,
            'from_column':
            self.fromColumn,
            'row_span':
            self.rowSpan,
            'column_span':
            self.columnSpan,
            'row_offset':
            event.pos().y() //
            (self.verticalSpan + self.tileLayout.verticalSpacing()),
            'column_offset':
            event.pos().x() //
            (self.horizontalSpan + self.tileLayout.horizontalSpacing()),
        }
        dataToText = json.dumps(data)
        dropData.setData('TileData', QByteArray(dataToText.encode()))
        dragIcon = self.widget.grab()

        drag.setPixmap(dragIcon)
        drag.setMimeData(dropData)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        return drag
    def mouseMoveEvent(self, event):
        if not (event.buttons() & Qt.LeftButton):
            return None

        manhattanLength = event.pos()
        manhattanLength -= self.drag_start_position
        manhattanLength = manhattanLength.manhattanLength()
        if manhattanLength < QApplication.startDragDistance():
            return None

        drag = QDrag(self)
        mimedata = QMimeData()
        message = json.dumps({
            "codigo": self.code,
            "estado": self.state,
            "semestre actual": self.semester
        })
        mimedata.setText(message)

        drag.setMimeData(mimedata)

        pixmap = QPixmap(QSize(subject_width, self.height))
        painter = QPainter(pixmap)
        painter.drawPixmap(0, 0, subject_width, self.height, self.grab())
        painter.end()
        pixmap = pixmap.scaled(QSize(subject_width, self.height))
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos())
        drag.exec_(Qt.CopyAction | Qt.MoveAction)
Ejemplo n.º 10
0
    def mousePressEvent(self, event):
        mimeData = WidgetMimeData()
        mimeData.setSize(self.size().width(), self.size().height())
        mimeData.setData(self)

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos())
        drag.setPixmap(pixmap)

        pe = self.parentWidget()
        pe.removeSectionEditor(self)
        pe.enableColumnAcceptDrop(False)
        pe.enableSectionAcceptDrop(False)
        self.hide()

        if drag.exec(Qt.MoveAction) == Qt.IgnoreAction:
            pe.addSection(self)
            self.show()

        pe.enableColumnAcceptDrop(True)
        pe.enableSectionAcceptDrop(True)
Ejemplo n.º 11
0
    def mouseMoveEvent(self, event):
        if QLineF(QPointF(event.screenPos()), QPointF(event.buttonDownScreenPos(Qt.LeftButton))).length() < QApplication.startDragDistance():
            return

        drag = QDrag(event.widget())
        mime = QMimeData()
        drag.setMimeData(mime)

        ColorItem.n += 1
        if ColorItem.n > 2 and qrand() % 3 == 0:
            image = QImage(':/images/head.png')
            mime.setImageData(image)
            drag.setPixmap(QPixmap.fromImage(image).scaled(30,40))
            drag.setHotSpot(QPoint(15, 30))
        else:
            mime.setColorData(self.color)
            mime.setText("#%02x%02x%02x" % (self.color.red(), self.color.green(), self.color.blue()))

            pixmap = QPixmap(34, 34)
            pixmap.fill(Qt.white)

            painter = QPainter(pixmap)
            painter.translate(15, 15)
            painter.setRenderHint(QPainter.Antialiasing)
            self.paint(painter, None, None)
            painter.end()

            pixmap.setMask(pixmap.createHeuristicMask())

            drag.setPixmap(pixmap)
            drag.setHotSpot(QPoint(15, 20))

        drag.exec_()
        self.setCursor(Qt.OpenHandCursor)
Ejemplo n.º 12
0
    def mousePressEvent(self, event):
        # handle an internal move

        # start a drag event
        if event.button() == Qt.LeftButton and self.dragDropRect().contains(
                event.pos()):
            # create the pixmap
            pixmap = QPixmap.grabWidget(self, self.rect())

            # create the mimedata
            mimeData = QMimeData()
            mimeData.setText('ItemTitle::%s' % (self.title()))

            # create the drag
            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)
            drag.setHotSpot(event.pos())

            if not drag.exec_():
                self._accordianWidget.emitItemDragFailed(self)

            event.accept()

        # determine if the expand/collapse should occur
        elif event.button() == Qt.LeftButton and self.expandCollapseRect(
        ).contains(event.pos()):
            self._clicked = True
            event.accept()

        else:
            event.ignore()
Ejemplo n.º 13
0
    def mousePressEvent(self, event):
            
        logging.debug('ElementMaster::mousePressEvent() called')
        # uncomment this for debugging purpose
        #self.listChild()

        if event.buttons() != Qt.LeftButton:
            return

        icon = QLabel()

        mimeData = QMimeData()
        mime_text = str(self.row) + str(self.column) + str(self.__class__.__name__)
        mimeData.setText(mime_text)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(self.pixmap)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            icon.close()
        else:
            icon.show()
            icon.setPixmap(self.pixmap)
Ejemplo n.º 14
0
    def mousePressEvent(self, event):
        child = self.childAt(event.pos())

        if child is None:
            return

        hotSpot = event.pos() - child.pos()

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream.writeQString(child.labelText())
        dataStream << hotSpot

        mimeData = QMimeData()
        mimeData.setData(fridgeMagnetsMimeType(), itemData)
        mimeData.setText(child.labelText())

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(child.pixmap())
        drag.setHotSpot(hotSpot)

        child.hide()

        if drag.exec(Qt.MoveAction | Qt.CopyAction,
                     Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
Ejemplo n.º 15
0
 def drag(self, parent, mimeData):
     """Called by dragFile and dragData. Execs a QDrag on the mime data."""
     d = QDrag(parent)
     d.setMimeData(mimeData)
     d.setPixmap(self.pixmap())
     d.setHotSpot(QPoint(-10, -10))
     return d.exec_(Qt.CopyAction)
Ejemplo n.º 16
0
    def mouseMoveEvent(self, event):
        """ If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
        """
        if not event.buttons() & Qt.LeftButton:
            return

        if (event.pos() - self.dragStartPosition).manhattanLength() \
             < QApplication.startDragDistance():
            return

        if not self.hasImage:
            return

        drag = QDrag(self)
        mimeData = QMimeData()

        output = QByteArray()
        outputBuffer = QBuffer(output)
        outputBuffer.open(QIODevice.WriteOnly)
        self.imageLabel.pixmap().toImage().save(outputBuffer, 'PNG')
        outputBuffer.close()
        mimeData.setData('image/png', output)

        drag.setMimeData(mimeData)
        drag.setPixmap(self.imageLabel.pixmap().scaled(64, 64, Qt.KeepAspectRatio))
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                                      drag.pixmap().height()))
        drag.start()
Ejemplo n.º 17
0
    def startDrag(self, event):
        """ Override startDrag method to display custom icon """

        # Get image of selected item
        selected = self.selectedIndexes()

        # Start drag operation
        drag = QDrag(self)
        drag.setMimeData(self.model.mimeData(selected))
        icon = self.model.data(selected[0], Qt.DecorationRole)
        drag.setPixmap(
            icon.pixmap(QSize(self.drag_item_size, self.drag_item_size)))
        drag.setHotSpot(
            QPoint(self.drag_item_size / 2, self.drag_item_size / 2))

        # Create emoji file before drag starts
        data = json.loads(drag.mimeData().text())
        file = self.add_file(data[0])

        # Update mimedata for emoji
        data = QMimeData()
        data.setText(json.dumps([file.id]))
        data.setHtml("clip")
        drag.setMimeData(data)

        # Start drag
        drag.exec_()
Ejemplo n.º 18
0
    def mouseMoveEvent(self, ev):
        if (ev.pos() - self.press_pos).manhattanLength() > 16:
            # print("drag start")

            drag = QDrag(self.controller._gui._window)

            # Create the drag thumbnail
            if False:
                pix = QPixmap(self.tile_rect.width(), self.tile_rect.height())
                painter = QPainter(pix)
                self.paint(painter, None, None)
                painter.end()
                drag.setPixmap(pix)
                drag.setHotSpot(ev.pos().toPoint() - self.tile_rect.topLeft())
            else:
                pix = QPixmap("/usr/share/icons/mate/32x32/actions/gtk-dnd-multiple.png").scaled(48, 48)
                drag.setPixmap(pix)

            if not self.isSelected():
                self.controller.clear_selection()
                self.setSelected(True)

            mime_data = self.controller.selection_to_mimedata(uri_only=True)
            drag.setMimeData(mime_data)

            # Qt does not allow custom drag actions officially. The
            # default drag action value is however carried through
            # even if it's invalid, but cursor changes and signals
            # like actionChanged() misbehave. The DragWidget class is
            # a workaround.
            drag_widget = DragWidget(None)  # noqa: F841

            # this will eat up the mouseReleaseEvent
            drag.exec(Qt.CopyAction | Qt.MoveAction | Qt.LinkAction | 0x40, 0x40)
Ejemplo n.º 19
0
    def mousePressEvent(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << pixmap << QPoint(event.pos() - child.pos())

        mimeData = QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QPixmap(pixmap)
        painter = QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
Ejemplo n.º 20
0
class Button(QPushButton):

    def __init__(self, title, parent):
        super().__init__(title, parent)

    def mouseMoveEvent(self, e):

        if e.buttons() != Qt.LeftButton:
            return

        mimeData = QMimeData()
        mimeData.setText(self.text())

        self.drag = QDrag(self)
        self.drag.setMimeData(mimeData)
        self.drag.setPixmap(self.grab())
        self.drag.setHotSpot(self.rect().center())

        dropAction = self.drag.exec_(Qt.MoveAction)
        
    def mousePressEvent(self, e):

        super().mousePressEvent(e)

        if e.button() == Qt.RightButton:
            text, result = QInputDialog.getText(self, 'Input Dialog', 'Upiši zadatak:')
            if(result == True):
                self.setText(text)
Ejemplo n.º 21
0
    def mouseMoveEvent(self, a0: QMouseEvent) -> None:
        if (a0.buttons() == Qt.LeftButton) and abs(a0.pos().y()) > 30:
            globalPos = self.mapToGlobal(a0.pos())
            posInTab = self.mapFromGlobal(globalPos)

            TabBar.indexTabToDrag = self.currentIndex()

            tabRect = self.tabRect(self.indexTabToDrag)
            pixmap = QPixmap(tabRect.size())
            self.render(pixmap, QPoint(), QRegion(tabRect))

            mimeData = QMimeData()
            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)
            cursor = QCursor(Qt.OpenHandCursor)
            drag.setHotSpot(cursor.pos())
            drag.setHotSpot(a0.pos() - posInTab)
            drag.setDragCursor(cursor.pixmap(), Qt.MoveAction)
            dropAction = drag.exec(Qt.MoveAction)
            # If the drag completed outside of the tab bar, detach the tab and move
            # the content to the current cursor position
            if dropAction == Qt.IgnoreAction:
                a0.accept()
                self.detachTab(self.indexTabToDrag, self.cursor().pos())
        else:
            super(TabBar, self).mouseMoveEvent(a0)
Ejemplo n.º 22
0
    def mouseMoveEvent(self, event):
        if self.dialog.removable:
            return

        if not (event.buttons() & Qt.LeftButton):
            return

        if (event.pos() - self.drag_start_position).manhattanLength() < QApplication.startDragDistance():
            return

        drag = QDrag(self)
        mimedata = QMimeData()
        mimedata.setText(self.text())

        if self.pixmap() is None:
            return

        mimedata.setImageData(self.pixmap().toImage())

        drag.setMimeData(mimedata)
        pixmap = QPixmap(self.size())
        self.image = pixmap
        painter = QPainter(pixmap)
        painter.drawPixmap(self.rect(), self.grab())
        painter.end()
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos())
        print("Moving")
        drag.exec_(Qt.MoveAction)
Ejemplo n.º 23
0
    def startDrag(self, event):
        """ Override startDrag method to display custom icon """

        # Get first column indexes for all selected rows
        selected = self.selectionModel().selectedRows(0)

        # Get image of current item
        current = self.selectionModel().currentIndex()
        if not current.isValid() and selected:
            current = selected[0]

        if not current.isValid():
            # We can't find anything to drag
            log.warning("No draggable items found in model!")
            return False

        # Get icon from column 0 on same row as current item
        icon = current.sibling(current.row(), 0).data(Qt.DecorationRole)

        # Start drag operation
        drag = QDrag(self)
        drag.setMimeData(self.model().mimeData(selected))
        drag.setPixmap(icon.pixmap(QSize(self.drag_item_size, self.drag_item_size)))
        drag.setHotSpot(QPoint(self.drag_item_size / 2, self.drag_item_size / 2))
        drag.exec_()
Ejemplo n.º 24
0
    def startDrag(self, DropActions):
        """
        开始拖
        """
        item = self.currentItem()
        # 表示一个小拼图
        itemData = QByteArray()
        # QByteArray类提供了一个字节数组
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        # QDataStream类提供二进制数据到QIODevice的序列化
        piecePix = item.data(Qt.UserRole)
        pieceLocation = item.data(Qt.UserRole+1)
        # 返回给定角色的项目数据,这里分别是拼图本身和拼图的位置。
        # 这里的Qt.UserRole是特定于应用程序目的的角色。
        dataStream << piecePix << pieceLocation
        # 将拼图数据和拼图位置信息存入数据流中,注意:这里的操作符<<
        mimeData = QMimeData()
        mimeData.setData("image/x-puzzle-xdbcb8", itemData)
        # 构造一个没有数据的新MIME数据对象

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        # QDrag类支持基于MIME的拖放数据传输
        drag.setHotSpot(QPoint(piecePix.width()/2, piecePix.height()/2))
        # 光标的热点指向其底边的中心
        drag.setPixmap(piecePix)
        # 拖得时候显示的图片

        if drag.exec(Qt.MoveAction) == Qt.MoveAction:
            moveItem = self.takeItem(self.row(item))
            del moveItem
Ejemplo n.º 25
0
    def mouseMoveEvent(self, event):
        if (event.pos() - self.dragStartPosition
            ).manhattanLength() < QApplication.startDragDistance():
            return
        mimeData = QMimeData()
        if not self.layer.selected:
            name = self.layer.name
        else:
            name = ''
            for layer in self.layer.viewer.layers:
                if layer.selected:
                    name = layer.name + '; ' + name
            name = name[:-2]
        mimeData.setText(name)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - self.rect().topLeft())
        dropAction = drag.exec_(Qt.MoveAction | Qt.CopyAction)

        if dropAction == Qt.CopyAction:
            if not self.layer.selected:
                index = self.layer.viewer.layers.index(self.layer)
                self.layer.viewer.layers.pop(index)
            else:
                self.layer.viewer.layers.remove_selected()
Ejemplo n.º 26
0
    def mouseMoveEvent(self, event):
        """ If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
        """
        if not event.buttons() & Qt.LeftButton:
            return

        if (event.pos() - self.dragStartPosition).manhattanLength() \
             < QApplication.startDragDistance():
            return

        if not self.hasImage:
            return

        drag = QDrag(self)
        mimeData = QMimeData()

        output = QByteArray()
        outputBuffer = QBuffer(output)
        outputBuffer.open(QIODevice.WriteOnly)
        self.imageLabel.pixmap().toImage().save(outputBuffer, 'PNG')
        outputBuffer.close()
        mimeData.setData('image/png', output)

        drag.setMimeData(mimeData)
        drag.setPixmap(self.imageLabel.pixmap().scaled(64, 64, Qt.KeepAspectRatio))
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                                      drag.pixmap().height()))
        drag.start()
Ejemplo n.º 27
0
    def mousePressEvent(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << pixmap << QPoint(event.pos() - child.pos())

        mimeData = QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QPixmap(pixmap)
        painter = QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction,
                      Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
Ejemplo n.º 28
0
    def mousePressEvent(self, event):
        from widgets.sectioneditor import SectionEditor
        mimeData = WidgetMimeData()
        mimeData.setSize(self.size().width(), self.size().height())
        mimeData.setData(self)
        parent = self.parentWidget()
        if isinstance(parent, SectionEditor):
            mimeData.source_list = parent.section._items

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos())
        drag.setPixmap(pixmap)

        se = self.parentWidget()
        se.removeRowEditor(self)
        pe = se.parentWidget()
        pe.enableColumnAcceptDrop(False)
        self.hide()

        if drag.exec(Qt.MoveAction) == Qt.IgnoreAction:
            se.addRowEditor(self)
            self.show()

        pe.enableColumnAcceptDrop(True)
Ejemplo n.º 29
0
 def mouseMoveEvent(self, e):
     mimeData = QMimeData()
     mimeData.setText(self.text())
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(e.pos() - self.rect().topLeft())
     dropAction = drag.exec_(Qt.MoveAction)
Ejemplo n.º 30
0
    def mouseMoveEvent(self, event):
        mime_data = QMimeData()
        mime_data.setText(self.text)

        drag = QDrag(self)
        drag.setMimeData(mime_data)
        drag.setHotSpot(event.pos() - self.rect().topLeft())
        drag.exec_()
Ejemplo n.º 31
0
 def mouseMoveEvent(self, e):
     if e.buttons() != Qt.LeftButton:
         return
     mimeData = QMimeData()
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(e.pos() - self.rect().topLeft())
     dropAction = drag.exec_(Qt.MoveAction)
Ejemplo n.º 32
0
 def mouseMoveEvent(self, e):
     if e.buttons() != Qt.RightButton:
         return
     mimeData = QMimeData()
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(e.pos() - self.rect().topLeft())
     dropAction = drag.exec_(Qt.MoveAction)
Ejemplo n.º 33
0
 def startDrag(self, dropActions):
     item = self.currentItem()
     mimeData = QMimeData()
     mimeData.setText(item.text())
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(QPoint(12, 12))
     drag.exec(Qt.MoveAction)
Ejemplo n.º 34
0
    def mouseMoveEvent(self, e):
        """
        Handles the snippet capture and drag drop initialization
        based off of: http://stackoverflow.com/questions/28258050/drag-n-drop-button-and-drop-down-menu-pyqt-qt-designer
        Parameters
        ----------
        e : qt event
        Returns
        -------
        None
        """
        if e.buttons() != Qt.LeftButton:
            if hasattr(self, 'drag_start_pos'):
                delattr(self, 'drag_start_pos')

        if not hasattr(self, 'drag_start_pos'):
            return

        if not (e.pos() - self.drag_start_pos).manhattanLength() > 75:
            return
        modifiers = QApplication.keyboardModifiers()
        if not modifiers == Qt.ControlModifier:
            return

        mime_data = self.get_mime()

        # let's make it fancy. we'll show a "ghost" of the button as we drag
        # grab the button to a pixmap
        pixmap = self.grab()
        size = pixmap.size() * .65
        half_pixmap = pixmap.scaled(size,
                                    Qt.KeepAspectRatio,
                                    transformMode=Qt.SmoothTransformation)

        # below makes the pixmap half transparent
        painter = QPainter(half_pixmap)
        painter.setCompositionMode(painter.CompositionMode_DestinationAtop)
        painter.fillRect(half_pixmap.rect(), QColor(0, 0, 0, 127))

        font = QFont()
        font.setFamily('Arial')
        font.setPointSize(15)
        font.setBold(True)
        painter.setFont(font)

        painter.setPen(Qt.red)
        painter.drawText(half_pixmap.rect(), Qt.AlignCenter, self.drag_label)
        painter.end()

        drag = QDrag(self)
        drag.setMimeData(mime_data)
        drag.setPixmap(half_pixmap)
        drag.setHotSpot(e.pos())

        # dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction)
        # dropAction = drag.exec_(Qt.TargetMoveAction)
        dropAction = drag.exec_()
        e.ignore()
Ejemplo n.º 35
0
def mouseMove(event, parent):
    """ Function for Mouse Move Event, used by original blocks and partially by generated blocks"""
    mimeData = QMimeData()

    drag = QDrag(parent)
    drag.setMimeData(mimeData)
    drag.setHotSpot(event.pos())

    drag.exec_(Qt.MoveAction)
Ejemplo n.º 36
0
	def newComponentButtonMousePress(self, componentType, event):
		self.tool = Tool.NewComponent
		self.mouseState = MouseState.Dragging
		self.newComponentType = componentType
		
		newComponentDrag = QDrag(self.view)
		newComponentDrag.setHotSpot(QPoint(self.view.ui.circuitDiagram.blockSideLength / 2, self.view.ui.circuitDiagram.blockSideLength / 2))
		newComponentDrag.setMimeData(QMimeData())
		newComponentDrag.setPixmap(QPixmap(self.view.ui.circuitDiagram.componentTypeToImageName(componentType)).scaled(self.view.ui.circuitDiagram.blockSideLength, self.view.ui.circuitDiagram.blockSideLength))
		newComponentDrag.exec_(Qt.MoveAction)
Ejemplo n.º 37
0
 def mouseMoveEvent(self, event):
     # if the left mouse button is used
     if self.drag_started:
         data = QByteArray()
         mime_data = QMimeData()
         mime_data.setData(self.mimetext, data)
         drag = QDrag(self) 
         drag.setMimeData(mime_data)
         drag.setPixmap(self.icon.get_icon())
         drag.setHotSpot(self.rect().topLeft())  # where do we drag from
         if drag.exec_(Qt.MoveAction):
             self.parent().icons.remove(self)
             self.deleteLater()
    def mouseMoveEvent(self, e):

        # 右ボタンのときのみDnD有効
        if e.buttons() != Qt.RightButton:
            return

        # MIMEベースでDnD情報を転送する
        mimeData = QMimeData()

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(e.pos() - self.rect().topLeft())

        # PyQt4ではdrag.start()だった
        dropAction = drag.exec_(Qt.MoveAction)
Ejemplo n.º 39
0
 def startDrag(self, mainwin, ev):
     d = mainwin.currentDocument()
     if not d:
         return
     url = d.url()
     if url.isEmpty():
         return
     drag = QDrag(mainwin)
     data = QMimeData()
     data.setUrls([url])
     drag.setMimeData(data)
     pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
     hotspot = QPoint(pixmap.width() - 5, 5)
     drag.setPixmap(pixmap)
     drag.setHotSpot(hotspot)
     drag.start(Qt.LinkAction | Qt.CopyAction)
Ejemplo n.º 40
0
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     p = QPainter()
     p.begin(image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.fillRect(image.rect(), QColor(0, 0, 0, 160))
     p.end()
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
Ejemplo n.º 41
0
    def mouseMoveEvent(self, e):
        if e.buttons() != Qt.RightButton:
            return

        globalPos = self.mapToGlobal(e.pos())
        tabBar = self.tabBar()
        posInTab = tabBar.mapFromGlobal(globalPos)
        self.indexTab = tabBar.tabAt(e.pos())
        tabRect = tabBar.tabRect(self.indexTab)

        pixmap = QPixmap(tabRect.size())
        tabBar.render(pixmap, QPoint(), QRegion(tabRect))
        mimeData = QMimeData()
        drag = QDrag(tabBar)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        cursor = QCursor(Qt.OpenHandCursor)
        drag.setHotSpot(e.pos() - posInTab)
        drag.setDragCursor(cursor.pixmap(), Qt.MoveAction)
        drag.exec_(Qt.MoveAction)
Ejemplo n.º 42
0
    def mousePressEvent(self, event):
        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << QByteArray(self.labelText) << QPoint(event.pos() - self.rect().topLeft())

        mimeData = QMimeData()
        mimeData.setData("application/x-fridgemagnet", itemData)
        mimeData.setText(self.labelText)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - self.rect().topLeft())
        drag.setPixmap(self.pixmap())

        self.hide()

        if drag.exec_(Qt.MoveAction | Qt.CopyAction, Qt.CopyAction) == Qt.MoveAction:
            self.close()
        else:
            self.show()
Ejemplo n.º 43
0
    def startDrag(self, supportedActions):
        item = self.currentItem()

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        pixmap = QPixmap(item.data(Qt.UserRole))
        location = item.data(Qt.UserRole+1)

        dataStream << pixmap << location

        mimeData = QMimeData()
        mimeData.setData('image/x-puzzle-piece', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2))
        drag.setPixmap(pixmap)

        if drag.exec_(Qt.MoveAction) == Qt.MoveAction:
            if self.currentItem() is not None:
                self.takeItem(self.row(item))
Ejemplo n.º 44
0
    def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
Ejemplo n.º 45
0
 def mouseMoveEvent(self, event):
     if self.parent() is not self.parent().src_dragwidget:
         for item in self.parent().src_selected:
             item.icon.deselect_icon()
         self.parent().clear_dnd()
     # if self.drag_started:
     data = QByteArray()
     mime_data = QMimeData()
     mime_data.setData(self.mimetext, data)
     drag = QDrag(self) 
     drag.setMimeData(mime_data)
     drag.setPixmap(self.icon.get_icon())
     drag.setHotSpot(self.rect().topLeft())
     if drag.exec_(Qt.MoveAction):
         if len(self.parent().src_selected) > 0:
             for item in self.parent().src_selected:
                 self.parent().icons.remove(item)
                 item.deleteLater()
         else:
             self.parent().icons.remove(self)
             self.deleteLater()
     self.parent().clear_dnd()
Ejemplo n.º 46
0
    def mousePressEvent(self, event):
        square = self.targetSquare(event.pos())
        found = self.findPiece(square)

        if found == -1:
            return

        location = self.pieceLocations[found]
        pixmap = self.piecePixmaps[found]
        del self.pieceLocations[found]
        del self.piecePixmaps[found]
        del self.pieceRects[found]

        if location == QPoint(square.x() / 80, square.y() / 80):
            self.inPlace -= 1

        self.update(square)

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)

        dataStream << pixmap << location

        mimeData = QMimeData()
        mimeData.setData('image/x-puzzle-piece', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - square.topLeft())
        drag.setPixmap(pixmap)

        if drag.exec_(Qt.MoveAction) != Qt.MoveAction:
            self.pieceLocations.insert(found, location)
            self.piecePixmaps.insert(found, pixmap)
            self.pieceRects.insert(found, square)
            self.update(self.targetSquare(event.pos()))

            if location == QPoint(square.x() / 80, square.y() / 80):
                self.inPlace += 1
Ejemplo n.º 47
0
    def mouseMoveEvent(self, event):
        if event.buttons() == Qt.RightButton:
            # write the relative cursor position to mime data
            mimeData = QMimeData()
            # simple string with 'x,y'
            mimeData.setText('%d,%d' % (event.x(), event.y()))

            # let's make it fancy. we'll show a "ghost" of the button as we drag
            # grab the button to a pixmap
            pixmap = self.grab()

            # below makes the pixmap half transparent
            painter = QPainter(pixmap)
            painter.setCompositionMode(painter.CompositionMode_DestinationIn)
            painter.fillRect(pixmap.rect(), QColor(0, 0, 0, 127))
            painter.end()

            # make a QDrag
            drag = QDrag(self)
            # put our MimeData
            drag.setMimeData(mimeData)
            # set its Pixmap
            drag.setPixmap(pixmap)
            # shift the Pixmap so that it coincides with the cursor position
            drag.setHotSpot(event.pos())

            # start the drag operation
            # exec_ will return the accepted action from dropEvent
            if drag.exec_(Qt.CopyAction | Qt.MoveAction) == Qt.MoveAction:
                print('moved')
            else:
                print('copied:'+str(event.globalPos()))
                #self.move(event.pos())

        elif event.buttons() == Qt.LeftButton:
            delta = QPoint(event.globalPos() - self.oldPos)
            self.move(self.frameGeometry().x() + delta.x(), self.frameGeometry().y() + delta.y())
            self.oldPos = event.globalPos()
Ejemplo n.º 48
0
    def mouseMoveEvent(self, mouseEvent):
        """
        Executed when the mouse if moved while a button is being pressed.
        :type mouseEvent: QMouseEvent
        """
        if mouseEvent.buttons() & Qt.LeftButton:

            # Exclude edges from drag&drop since we need to source and edge to insert it in the diagram.
            if Item.ConceptNode <= self.item <= Item.PropertyAssertionNode:

                distance = (mouseEvent.pos() - self.startPos).manhattanLength()
                if distance >= QApplication.startDragDistance():

                    mimeData = QMimeData()
                    mimeData.setText(str(self.item.value))

                    drag = QDrag(self)
                    drag.setMimeData(mimeData)
                    drag.setPixmap(self.pixmap)
                    drag.setHotSpot(self.startPos - self.rect().topLeft())
                    drag.exec_(Qt.CopyAction)

        super().mouseMoveEvent(mouseEvent)
Ejemplo n.º 49
0
class MainView(QMainWindow):
	def __init__(self, model, controller):
		QWidget.__init__(self)

		self.controller = controller
		self.model = model

		# load QtDesigner UI 
		self.ui = Ui_mainWindow()
		self.ui.setupUi(self)

		#### SETUP CircuitDiagramView and controller
		self.ui.circuitDiagram.model = self.model
		self.ui.circuitDiagram.controller = self.controller

		# connect to CircuitDiagramView mouse triggers
		self.ui.circuitDiagram.mousePress.connect(self.controller.circuitDiagramMousePress)
		self.ui.circuitDiagram.mouseMove.connect(self.controller.circuitDiagramMouseMove)
		self.ui.circuitDiagram.mouseRelease.connect(self.controller.circuitDiagramMouseRelease)


		#### SETUP TOOLBAR
		self.ui.wireMode.clicked.connect(self.setWireMode)
		self.ui.deleteMode.clicked.connect(self.setDeleteMode)
		self.ui.selectMode.clicked.connect(self.setSelectMode)

		self.ui.runMode.clicked.connect(self.setRunMode)
		self.ui.buildMode.clicked.connect(self.setBuildMode)
		
		self.toolbarComponents = []
		self.ui.newBattery.componentType = ComponentType.Battery
		self.toolbarComponents.append(self.ui.newBattery)

		self.ui.newBulb.componentType = ComponentType.Bulb
		self.toolbarComponents.append(self.ui.newBulb)

		self.ui.newResistor.componentType = ComponentType.Resistor
		self.toolbarComponents.append(self.ui.newResistor)

		self.ui.newSwitch.componentType = ComponentType.Switch
		self.toolbarComponents.append(self.ui.newSwitch)

		self.ui.newButton.componentType = ComponentType.Button
		self.toolbarComponents.append(self.ui.newButton)

		self.ui.newAmmeter.componentType = ComponentType.Ammeter
		self.toolbarComponents.append(self.ui.newAmmeter)

		self.ui.newVoltmeter.componentType = ComponentType.Voltmeter
		self.toolbarComponents.append(self.ui.newVoltmeter)

		for toolbarButton in self.toolbarComponents:
			toolbarButton.setIcon(QIcon(QPixmap(self.ui.circuitDiagram.componentTypeToImageName(toolbarButton.componentType))))
			toolbarButton.setIconSize(QSize(50, 50))
			toolbarButton.mousePress.connect(self.controller.newComponentButtonMousePress)

		self.statusBar().showMessage('Ready')

		self.ui.actionNew.setShortcut('Ctrl+N')
		self.ui.actionNew.setStatusTip('New document')
		
		self.ui.actionOpen.triggered.connect(self.showFileDialog)
		self.ui.actionSave.triggered.connect(self.showSaveDialog)
		self.ui.actionSaveAs.triggered.connect(self.saveAs)
		self.ui.actionNew.triggered.connect(self.newFile)
		self.ui.actionSave.setShortcut('Ctrl+S')
		self.ui.actionSaveAs.setShortcut('Ctrl+Shift+S')
		self.ui.actionOpen.setShortcut('Ctrl+O')
		self.ui.actionNew.setShortcut('Ctrl+N')
		
		self.savePath = None

	def newFile(self):
		reply = QMessageBox.question(self, "Message", "Opening a new file overwrites the current file. Do you want to save the current file?", QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Yes)
		if reply == QMessageBox.No:
			self.model.clearModel()
		elif reply == QMessageBox.Yes:
			self.showSaveDialog()
			self.statusBar().showMessage('Saved')

	def saveAs(self):
		fname = QFileDialog.getSaveFileName(self, 'Save file', 'breadboard.eagle')
		if fname[0]:
			self.savePath = fname[0]
			self.model.saveModel(fname[0])
			self.statusBar().showMessage('Saved')
		
	def showFileDialog(self):
		reply = QMessageBox.question(self, "Message", "Opening a new file overwrites the current file. Do you want to save the current file?", QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Yes)
		if reply == QMessageBox.No:
			fname = QFileDialog.getOpenFileName(self, 'Open file', '')
			if fname[0]:
				self.savePath = fname[0]
				if not self.model.readModel(fname[0]):
					QMessageBox.question(self, "Message", "Parsing failed. File may be corrupted.", QMessageBox.Cancel, QMessageBox.Cancel)
				else:
					self.statusBar().showMessage('File Opened. Ready')
		elif reply == QMessageBox.Yes:
			self.showSaveDialog()
			self.statusBar().showMessage('Saved')
	
	def showSaveDialog(self):
		if self.savePath is None:
			self.saveAs()
		else:
			self.model.saveModel(self.savePath)
			self.statusBar().showMessage('Saved')


	def newComponentButtonMousePress(self, componentType, event):
		self.ui.build.setChecked(True)
		self.ui.wireMode.setChecked(False)
		self.ui.deleteMode.setChecked(False)
		self.ui.selectMode.setChecked(True)
		self.controller.bulbsOff()
		self.model.reRender()

		self.cursorState = CursorState.NewComponentDragging
		self.newComponentType = componentType
		self.newComponentDrag = QDrag(self)
		self.newComponentDrag.setHotSpot(QPoint(self.ui.circuitDiagram.blockSideLength / 2, self.ui.circuitDiagram.blockSideLength / 2))
		self.newComponentDrag.setMimeData(QMimeData())
		self.newComponentDrag.setPixmap(QPixmap(self.ui.circuitDiagram.componentTypeToImageName(componentType)).scaled(self.ui.circuitDiagram.blockSideLength, self.ui.circuitDiagram.blockSideLength))
		QApplication.setOverrideCursor(QCursor(Qt.ForbiddenCursor))
		self.newComponentDrag.exec_(Qt.MoveAction)

		self.cursorState = CursorState.Select
		self.ui.selectMode.setChecked(True)
		self.updateCursor()

	def updateCursorAndToolButtons(self, mode, tool, mouseState):
		self.ui.selectMode.setChecked(False)
		self.ui.wireMode.setChecked(False)
		self.ui.deleteMode.setChecked(False)
		self.ui.runMode.setChecked(False)
		self.ui.buildMode.setChecked(False)

		if mode is Mode.Build:
			self.ui.buildMode.setChecked(True)
			if tool is Tool.Select:
				self.ui.selectMode.setChecked(True)
				if mouseState is MouseState.Dragging:
					QApplication.setOverrideCursor(QCursor(Qt.ClosedHandCursor))
				else:
					QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
			elif tool is Tool.Wire:
				self.ui.wireMode.setChecked(True)
				QApplication.setOverrideCursor(QCursor(Qt.CrossCursor))
			elif tool is Tool.Delete:
				self.ui.deleteMode.setChecked(True)
				QApplication.setOverrideCursor(QCursor(Qt.CrossCursor))
			elif tool is Tool.NewComponent:
				QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
		elif mode is Mode.Run:
			QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
			self.ui.runMode.setChecked(True)


	def setRunMode(self):
		self.controller.mode = Mode.Run

	def setBuildMode(self):
		self.controller.mode = Mode.Build

	def setSelectMode(self):
		self.controller.tool = Tool.Select

	def setWireMode(self):
		self.ui.componentTypeLabel.hide()
		self.ui.componentType.hide()
		self.ui.closedLabel.hide()
		self.ui.closed.hide()
		self.ui.resistanceLabel.hide()
		self.ui.resistance.hide()
		self.ui.voltageLabel.hide()
		self.ui.voltage.hide()
		self.controller.tool = Tool.Wire
		
	def setDeleteMode(self):
		self.ui.componentTypeLabel.hide()
		self.ui.componentType.hide()
		self.ui.closedLabel.hide()
		self.ui.closed.hide()
		self.ui.resistanceLabel.hide()
		self.ui.resistance.hide()
		self.ui.voltageLabel.hide()
		self.ui.voltage.hide()
		self.controller.tool = Tool.Delete

	def closeEvent(self, event):
		reply = QMessageBox.question(self, "Message", "Do want to save your changes?", QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Yes)

		if reply == QMessageBox.No:
			event.accept()
		elif reply ==QMessageBox.Yes:
			self.showSaveDialog()
			event.accept()