Example #1
0
 def __init__(self, parent=None, mtime=2):
     """
     Initialize Eddy's splash screen.
     :type parent: QWidget
     :type mtime: float
     """
     super().__init__(parent, QtGui.QPixmap(), QtCore.Qt.WindowStaysOnTopHint)
     pixmap = QtGui.QIcon(':/images/im_eddy_splash').pixmap(380 * self.devicePixelRatio())
     pixmap.setDevicePixelRatio(self.devicePixelRatio())
     self.setPixmap(pixmap)
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     self.mtime = time() + mtime
     self.font1 = Font('Arial', 40, Font.Light)
     self.font1.setCapitalization(Font.SmallCaps)
     self.font2 = Font('Arial', 18, Font.Light)
     self.font2.setCapitalization(Font.SmallCaps)
     self.font3 = Font('Arial', 12, Font.Light)
     self.__spaceX = 0
     self.__spaceY = 0
Example #2
0
 def doAddDiagram(self, diagram):
     """
     Add a diagram in the treeview.
     :type diagram: Diagram
     """
     if not self.findItem(diagram.name):
         item = QtGui.QStandardItem(diagram.name)
         item.setData(diagram)
         item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)
         item.setFont(Font('Roboto', 12))
         item.setIcon(self.iconGraphol)
         self.root.appendRow(item)
         self.proxy.sort(0, QtCore.Qt.AscendingOrder)
Example #3
0
    def __init__(self, project, parent=None):
        """
        Initialize the project block.
        :type project: str
        :type parent: QtWidgets.QWidget
        """
        super().__init__(parent)

        self.nameLabel = QtWidgets.QLabel(os.path.basename(project), self)
        self.nameLabel.setContentsMargins(20, 0, 20, 0)
        self.nameLabel.setProperty('class', 'name')
        self.nameLabel.setFont(Font(bold=True))
        self.pathLabel = QtWidgets.QLabel(compressPath(shortPath(project), 34),
                                          self)
        self.pathLabel.setContentsMargins(20, 0, 20, 0)
        self.pathLabel.setProperty('class', 'path')
        self.removeBtn = PHCQPushButton(self)
        self.removeBtn.setIcon(QtGui.QIcon(':icons/24/ic_close_black'))
        self.removeBtn.setToolTip('Remove Project')
        self.removeBtn.setVisible(False)
        connect(self.removeBtn.clicked, self.onRemoveButtonClicked)
        self.deleteBtn = PHCQPushButton(self)
        self.deleteBtn.setToolTip('Delete Project')
        self.deleteBtn.setIcon(QtGui.QIcon(':/icons/24/ic_delete_black'))
        self.deleteBtn.setVisible(False)
        connect(self.deleteBtn.clicked, self.onDeleteButtonClicked)
        self.leftWidget = QtWidgets.QWidget(self)
        self.leftWidget.setContentsMargins(0, 0, 0, 0)
        self.leftLayout = QtWidgets.QVBoxLayout(self.leftWidget)
        self.leftLayout.setContentsMargins(0, 0, 0, 0)
        self.leftLayout.setSpacing(0)
        self.leftLayout.addWidget(self.nameLabel)
        self.leftLayout.addWidget(self.pathLabel)
        self.rightWidget = QtWidgets.QWidget(self)
        self.rightWidget.setContentsMargins(0, 0, 10, 0)
        self.rightLayout = QtWidgets.QHBoxLayout(self.rightWidget)
        self.rightLayout.setContentsMargins(0, 0, 0, 0)
        self.rightLayout.setSpacing(0)
        self.rightLayout.addWidget(self.removeBtn)
        self.rightLayout.addWidget(self.deleteBtn)
        self.mainLayout = QtWidgets.QHBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.leftWidget)
        self.mainLayout.addWidget(self.rightWidget, 1, QtCore.Qt.AlignRight)
        self.installEventFilter(self)
        self.setContentsMargins(0, 0, 0, 0)
        self.setCursor(QtCore.Qt.PointingHandCursor)
        self.setFixedHeight(40)
        self.setFocusPolicy(QtCore.Qt.TabFocus)
        self.setToolTip(expandPath(project))
        self.path = project
Example #4
0
    def __init__(self, diagram, node, session):
        """
        Initialize the node properties dialog.
        :type diagram: Diagram
        :type node: AbstractNode
        :type session: Session
        """
        super().__init__(diagram, node, session)

        #############################################
        # ORDERING TAB
        #################################

        if self.node.inputs:

            self.sortLabel = QtWidgets.QLabel(self)
            self.sortLabel.setFont(Font('Roboto', 12))
            self.sortLabel.setText('Sort')
            self.list = QtWidgets.QListWidget(self)
            for i in self.node.inputs:
                edge = self.diagram.edge(i)
                item = QtWidgets.QListWidgetItem('{0} ({1})'.format(edge.source.text(), edge.source.id))
                item.setData(QtCore.Qt.UserRole, edge.id)
                self.list.addItem(item)
            self.list.setCurrentRow(0)
            self.list.setDragDropMode(QtWidgets.QAbstractItemView.NoDragDrop)

            self.buttonUp = QtWidgets.QPushButton(self)
            self.buttonUp.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_up_black'))
            self.buttonUp.setFixedSize(20, 20)
            connect(self.buttonUp.clicked, self.moveUp)

            self.buttonDown = QtWidgets.QPushButton(self)
            self.buttonDown.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_down_black'))
            self.buttonDown.setFixedSize(20, 20)
            connect(self.buttonDown.clicked, self.moveDown)

            inLayout = QtWidgets.QVBoxLayout()
            inLayout.addWidget(self.buttonUp)
            inLayout.addWidget(self.buttonDown)

            outLayout = QtWidgets.QHBoxLayout()
            outLayout.addWidget(self.list)
            outLayout.addLayout(inLayout)

            self.orderWidget = QtWidgets.QWidget()
            self.orderLayout = QtWidgets.QFormLayout(self.orderWidget)
            self.orderLayout.addRow(self.sortLabel, outLayout)

            self.mainWidget.addTab(self.orderWidget, 'Ordering')
    def __init__(self, plugin):
        """
        Initialize the project explorer.
        :type plugin: ProjectExplorer
        """
        super().__init__(plugin.session)

        self.plugin = plugin
        self.project = None

        self.iconRoot = QtGui.QIcon(':/icons/18/ic_folder_open_black')
        self.iconBlank = QtGui.QIcon(':/icons/18/ic_document_blank')
        self.iconGraphol = QtGui.QIcon(':/icons/18/ic_document_graphol')
        self.iconOwl = QtGui.QIcon(':/icons/18/ic_document_owl')

        self.root = QtGui.QStandardItem()
        self.root.setFlags(self.root.flags() & ~QtCore.Qt.ItemIsEditable)
        self.root.setFont(Font('Roboto', 12, bold=True))
        self.root.setIcon(self.iconRoot)

        self.shortcut = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Shift+b'), self.session)
        self.model = QtGui.QStandardItemModel(self)
        self.proxy = ProjectExplorerSortedProxyModel(self)
        self.proxy.setDynamicSortFilter(False)
        self.proxy.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.proxy.setSortCaseSensitivity(QtCore.Qt.CaseSensitive)
        self.proxy.setSourceModel(self.model)
        self.projectview = ProjectExplorerView(self)
        self.projectview.setModel(self.proxy)
        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.projectview)

        self.setContentsMargins(0, 0, 0, 0)
        self.setMinimumWidth(216)

        header = self.projectview.header()
        header.setStretchLastSection(False)
        header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

        connect(plugin.sgnDiagramCreated, self.doAddDiagram)
        connect(plugin.sgnProjectChanged, self.onProjectChanged)

        connect(self.projectview.activated, self.onItemActivated)
        connect(self.projectview.doubleClicked, self.onItemDoubleClicked)
        connect(self.projectview.pressed, self.onItemPressed)
        connect(self.shortcut.activated, self.doFocusProjectView)
        connect(self.sgnItemActivated, self.plugin.doFocusDiagram)
        connect(self.sgnItemDoubleClicked, self.plugin.doFocusDiagram)
Example #6
0
    def __init__(self, diagram, node, session):
        """
        Initialize the node properties dialog.
        :type diagram: Diagram
        :type node: AbstractNode
        :type session: Session
        """
        super().__init__(diagram, node, session)

        #############################################
        # DATATYPE TAB
        #################################

        self.datatypeLabel = QtWidgets.QLabel(self)
        self.datatypeLabel.setFont(Font('Roboto', 12))
        self.datatypeLabel.setText('Datatype')
        self.datatypeField = ComboBox(self)
        self.datatypeField.setFixedWidth(200)
        self.datatypeField.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.datatypeField.setFont(Font('Roboto', 12))

        for datatype in Datatype:
            self.datatypeField.addItem(datatype.value, datatype)
        datatype = self.node.datatype
        for i in range(self.datatypeField.count()):
            if self.datatypeField.itemData(i) is datatype:
                self.datatypeField.setCurrentIndex(i)
                break
        else:
            self.datatypeField.setCurrentIndex(0)

        self.datatypeWidget = QtWidgets.QWidget()
        self.datatypeLayout = QtWidgets.QFormLayout(self.datatypeWidget)
        self.datatypeLayout.addRow(self.datatypeLabel, self.datatypeField)

        self.mainWidget.addTab(self.datatypeWidget, 'Datatype')
Example #7
0
 def __init__(self, widget):
     """
     Initialize the Explanation explorer view.
     :type widget: ExplanationExplorerWidget
     """
     super().__init__(widget)
     self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
     self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
     self.setFont(Font('Roboto', 12))
     self.setFocusPolicy(QtCore.Qt.NoFocus)
     self.setHeaderHidden(True)
     self.setHorizontalScrollMode(QtWidgets.QTreeView.ScrollPerPixel)
     self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
     self.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
     self.setSortingEnabled(True)
     self.setWordWrap(True)
Example #8
0
    def addAColumnOfButtons(self, floor, ceiling):

        explanationButtonsColumnLayout = QtWidgets.QVBoxLayout()
        explanationButtonsColumnArea = QtWidgets.QWidget()

        for e in range(floor, ceiling + 1):

            widget = QtWidgets.QPushButton(objectName=str(e))
            widget.setText('Explanation ' + str(e))
            widget.setFont(Font('Roboto', 12))

            connect(widget.clicked, self.set_explanation_to_display_in_widget,
                    e)

            explanationButtonsColumnLayout.addWidget(widget)
        explanationButtonsColumnArea.setLayout(explanationButtonsColumnLayout)
        self.explanationButtonsLayout.addWidget(explanationButtonsColumnArea)
Example #9
0
    def __init__(self, parent=None):
        """
        Initialize the dialog.
        :type parent: QWidget
        """
        super().__init__(parent)

        stream = LOGGER.getDefaultStream()

        #############################################
        # MESSAGE AREA
        #################################

        self.messageArea = QtWidgets.QPlainTextEdit(self)
        self.messageArea.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.messageArea.setContentsMargins(10, 0, 0, 0)
        self.messageArea.setFont(Font('Monospace', style=Font.TypeWriter))
        self.messageArea.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)
        self.messageArea.setMinimumSize(800, 500)
        self.highlighter = LogHighlighter(self.messageArea.document())
        self.messageArea.setPlainText(stream.getvalue())
        self.messageArea.setReadOnly(True)

        #############################################
        # CONFIRMATION AREA
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
        self.confirmationBox.setContentsMargins(10, 0, 0, 0)

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(10, 10, 10, 10)
        self.mainLayout.addWidget(self.messageArea)
        self.mainLayout.addWidget(self.confirmationBox, 0,
                                  QtCore.Qt.AlignRight)

        connect(self.confirmationBox.accepted, self.accept)

        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Log')
Example #10
0
    def __init__(self, session, parent=None):
        super().__init__(session, parent)

        self.header = BBHeader('')
        self.header.setFont(Font('Roboto', 12))

        self.tableWidget = QtWidgets.QTableWidget(self)
        self.tableWidget.setColumnCount(6)
        self.tableWidget.verticalHeader().setVisible(False)
        self.tableWidget.horizontalHeader().setVisible(False)
        self.tableWidget.resizeColumnsToContents()

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setAlignment(QtCore.Qt.AlignTop)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.mainLayout.addWidget(self.header)
        self.mainLayout.addWidget(self.tableWidget)
Example #11
0
 def sceneEvent(self, event: QtCore.QEvent) -> bool:
     """
     Executed when an event is dispatched to this item in the scene,
     before any of the specialized handlers.
     :type event: QtCore.QEvent
     :rtype: bool
     """
     if event.type() == QtCore.QEvent.FontChange and not self.customFont:
         nfont = Font(font=self.diagram.font(), weight=Font.Light)
         if self.font() != nfont:
             # UPDATE THE DOCUMENT FONT AND ADJUST ITEM SIZE AND POSITION
             npos = self.pos()
             self.setFont(nfont)
             self.setAlignment(self.alignment())
             self.setPos(npos)
         # CASCADE THE EVENT TO EACH CHILD ITEM
         for item in self.childItems():
             self.diagram.sendEvent(item, event)
     return super().sceneEvent(event)
Example #12
0
    def __init__(self, template='', movable=True, editable=True, parent=None):
        """
        Initialize the label.
        :type template: str
        :type movable: bool
        :type editable: bool
        :type parent: QObject
        """
        self._alignment = QtCore.Qt.AlignCenter
        self._editable = bool(editable)
        self._movable = bool(movable)
        super().__init__(parent)
        self.focusInData = None
        self.template = template
        self.setDefaultTextColor(
            QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)).color())
        self.setFlag(AbstractLabel.ItemIsFocusable, self.isEditable())
        self.setFont(Font('Roboto', 12, Font.Light))
        self.setText(self.template)
        self.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)

        document = self.document()
        connect(document.contentsChange[int, int, int], self.onContentsChanged)
Example #13
0
    def test_change_diagram_font(self, session):
        # GIVEN
        project = session.project
        diagram = session.mdi.activeDiagram()

        iri1 = project.getIRI('http://www.dis.uniroma1.it/~graphol/test_project/Male')
        node1 = first(project.iriOccurrences(Item.ConceptIRINode, iri1, diagram))

        iri2 = project.getIRI('http://www.dis.uniroma1.it/~graphol/test_project/Person')
        node2 = first(project.iriOccurrences(Item.ConceptIRINode, iri2, diagram))

        iri3 = project.getIRI('http://www.dis.uniroma1.it/~graphol/test_project/hasMother')
        node3 = first(project.iriOccurrences(Item.RoleIRINode, iri3, diagram))

        iri4 = project.getIRI('http://www.dis.uniroma1.it/~graphol/test_project/hasFather')
        node4 = first(project.iriOccurrences(Item.RoleIRINode, iri4, diagram))

        pos1 = node1.textPos()
        pos2 = node2.textPos()
        pos3 = node3.textPos()
        pos4 = node4.textPos()
        font = diagram.font()
        # WHEN
        diagram.setFont(Font(font=font, pixelSize=font.pixelSize() * 2))
        # THEN
        assert pos1 == node1.textPos()
        assert pos2 == node2.textPos()
        assert pos3 == node3.textPos()
        assert pos4 == node4.textPos()
        # WHEN
        diagram.setFont(font)
        # THEN
        assert pos1 == node1.textPos()
        assert pos2 == node2.textPos()
        assert pos3 == node3.textPos()
        assert pos4 == node4.textPos()
Example #14
0
    def __init__(self, item, name, current, importing, parent=None):
        """
        Initialize the project dialog.
        :type item: Item
        :type name: str
        :type current: str
        :type importing: str
        :type parent: QWidget
        """
        super().__init__(parent)

        self.item = item
        self.name = name

        #############################################
        # LEFT SIDE
        #################################

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('current_title')
        widget.setText('Current')
        self.addWidget(widget)

        widget = TextField(self)
        widget.setFixedSize(300, 200)
        widget.setFocusPolicy(QtCore.Qt.NoFocus)
        widget.setFont(Font('Roboto', 12))
        widget.setObjectName('current_documentation')
        widget.setReadOnly(True)
        widget.setValue(current)
        self.addWidget(widget)

        widget = PHCQPushButton(self)
        widget.setAutoDefault(False)
        widget.setDefault(False)
        widget.setProperty('class', 'flat blue')
        widget.setFixedWidth(32)
        widget.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_right_black'))
        widget.setIconSize(QtCore.QSize(24, 24))
        widget.setObjectName('pick_current_button')
        widget.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
        connect(widget.clicked, self.doPickDocumentation)
        self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setFixedSize(QtCore.QSize(24, 24))
        # widget.setPixmap(QtGui.QIcon(':/icons/24/ic_compare_arrows_black').pixmap(24))
        # widget.setObjectName('compare_arrows_current_icon')
        # self.addWidget(widget)

        #############################################
        # MIDDLE SIDE
        #################################

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('final_title')
        widget.setText('Final')
        self.addWidget(widget)

        widget = TextField(self)
        widget.setFixedSize(300, 200)
        widget.setFont(Font('Roboto', 12))
        widget.setObjectName('final_documentation')
        self.addWidget(widget)

        #############################################
        # RIGHT SIDE
        #################################

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('importing_title')
        widget.setText('Importing')
        self.addWidget(widget)

        widget = TextField(self)
        widget.setFixedSize(300, 200)
        widget.setFocusPolicy(QtCore.Qt.NoFocus)
        widget.setFont(Font('Roboto', 12))
        widget.setObjectName('importing_documentation')
        widget.setReadOnly(True)
        widget.setValue(importing)
        self.addWidget(widget)

        widget = PHCQPushButton(self)
        widget.setAutoDefault(False)
        widget.setDefault(False)
        widget.setProperty('class', 'flat blue')
        widget.setFixedWidth(32)
        widget.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_left_black'))
        widget.setIconSize(QtCore.QSize(24, 24))
        widget.setObjectName('pick_importing_button')
        widget.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
        connect(widget.clicked, self.doPickDocumentation)
        self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setFixedSize(QtCore.QSize(24, 24))
        # widget.setPixmap(QtGui.QIcon(':/icons/24/ic_compare_arrows_black').pixmap(24))
        # widget.setObjectName('compare_arrows_importing_icon')
        # self.addWidget(widget)

        #############################################
        # CONFIRMATION AREA
        #################################

        widget = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal, self)
        widget.addButton(QtWidgets.QDialogButtonBox.Ok)
        widget.addButton(QtWidgets.QDialogButtonBox.Abort)
        widget.setContentsMargins(0, 4, 0, 0)
        widget.setFont(Font('Roboto', 12))
        widget.setObjectName('confirmation_box')
        connect(widget.accepted, self.accept)
        connect(widget.rejected, self.reject)
        self.addWidget(widget)

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        gridWidget = QtWidgets.QWidget(self)
        gridLayout = QtWidgets.QGridLayout(gridWidget)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        gridLayout.addWidget(self.widget('current_title'), 0, 0)
        gridLayout.addWidget(self.widget('current_documentation'), 1, 0)
        gridLayout.addWidget(self.widget('final_title'), 0, 2)
        gridLayout.addWidget(self.widget('final_documentation'), 1, 2)
        gridLayout.addWidget(self.widget('importing_title'), 0, 4)
        gridLayout.addWidget(self.widget('importing_documentation'), 1, 4)
        # gridLayout.addWidget(self.widget('compare_arrows_current_icon'), 0, 1, QtCore.Qt.AlignCenter)
        # gridLayout.addWidget(self.widget('compare_arrows_importing_icon'), 0, 3, QtCore.Qt.AlignCenter)
        gridLayout.addWidget(self.widget('pick_current_button'), 1, 1)
        gridLayout.addWidget(self.widget('pick_importing_button'), 1, 3)

        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addWidget(gridWidget)
        mainLayout.addWidget(self.widget('confirmation_box'))
        mainLayout.setContentsMargins(10, 10, 10, 10)

        self.setLayout(mainLayout)
        self.setFixedSize(self.sizeHint())
        self.setFont(Font('Roboto', 12))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle("Resolve documentation conflict for {0} '{1}'...".format(self.item.shortName, self.name))
Example #15
0
class Splash(QtWidgets.QSplashScreen):
    """
    This class implements Eddy's splash screen.
    It can be used with the context manager, i.e:

    >>> import sys
    >>> from PyQt5 import QtWidgets
    >>> app = QtWidgets.QApplication(sys.argv)
    >>> with Splash(mtime=5):
    >>>     app.do_something_heavy()

    will draw a 5 seconds (at least) splash screen on the screen.
    The with statement body can be used to initialize the application and process heavy stuff.
    """
    def __init__(self, parent=None, mtime=2):
        """
        Initialize Eddy's splash screen.
        :type parent: QWidget
        :type mtime: float
        """
        super().__init__(parent, QtGui.QPixmap(),
                         QtCore.Qt.WindowStaysOnTopHint)
        pixmap = QtGui.QIcon(':/images/im_eddy_splash').pixmap(
            380 * self.devicePixelRatio())
        pixmap.setDevicePixelRatio(self.devicePixelRatio())
        self.setPixmap(pixmap)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.mtime = time() + mtime
        self.font1 = Font('Roboto', 40, Font.Light)
        self.font1.setCapitalization(Font.SmallCaps)
        self.font2 = Font('Roboto', 18, Font.Light)
        self.font2.setCapitalization(Font.SmallCaps)
        self.font3 = Font('Roboto', 11, Font.Light)
        self.__spaceX = 0
        self.__spaceY = 0

    #############################################
    #   INTERFACE
    #################################

    def setSpaceX(self, spaceX):
        """
        Set the text horizontal spacing.
        :type spaceX: int
        """
        self.__spaceX = spaceX

    def setSpaceY(self, spaceY):
        """
        Set the text vertical spacing.
        :type spaceY: int
        """
        self.__spaceY = spaceY

    def sleep(self):
        """
        Wait for the splash screen to be drawn for at least 'mtime' seconds.
        """
        now = time()
        if now < self.mtime:
            for _ in rangeF(start=0, stop=self.mtime - now, step=0.1):
                # noinspection PyArgumentList
                QtWidgets.QApplication.processEvents()
                sleep(0.1)

    #############################################
    #   CONTEXT MANAGER
    #################################

    def __enter__(self):
        """
        Draw the splash screen.
        """
        self.show()

    def __exit__(self, exc_type, exc_value, traceback):
        """
        Remove the splash screen from the screen.
        """
        self.sleep()
        self.close()

    #############################################
    #   EVENTS
    #################################

    def paintEvent(self, paintEvent):
        """
        Executed when the splashscreen needs to be painted.
        :type paintEvent: QPaintEvent
        """
        painter = QtGui.QPainter(self)
        # APPNAME
        painter.setFont(self.font1)
        painter.setPen(
            QtGui.QPen(QtGui.QColor(255, 255, 255), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(
            QtCore.QRect(31 + self.__spaceX, 138 + self.__spaceY, 380, 400),
            QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft, APPNAME)
        # VERSION
        painter.setFont(self.font2)
        painter.setPen(
            QtGui.QPen(QtGui.QColor(255, 255, 255), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(
            QtCore.QRect(34 + self.__spaceX, 185 + self.__spaceY, 380,
                         400), QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft,
            'Version {0}'.format(VERSION))
        # COPYRIGHT
        painter.setFont(self.font3)
        painter.setPen(
            QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(
            QtCore.QRect(0 + self.__spaceX, 220 + self.__spaceY, 360, 40),
            QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter, COPYRIGHT)
        # CREDITS
        painter.setFont(self.font3)
        painter.setPen(
            QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(
            QtCore.QRect(0 + self.__spaceX, 273 + self.__spaceY, 360, 80),
            QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter, CREDITS)
        # LICENSE
        painter.setFont(self.font3)
        painter.setPen(
            QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(
            QtCore.QRect(0 + self.__spaceX, 286 + self.__spaceY, 360, 40),
            QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter, LICENSE)
Example #16
0
    def configure(self):
        """
        Perform initial configuration tasks for Eddy to work properly.
        """
        #############################################
        # CONFIGURE FONTS
        #################################

        fontDB = QtGui.QFontDatabase()
        fonts = QtCore.QDirIterator(':/fonts/')
        while fonts.hasNext():
            fontDB.addApplicationFont(fonts.next())

        # FONT SUBSTITUTIONS
        QtGui.QFont.insertSubstitution('Sans Serif', 'Roboto')
        QtGui.QFont.insertSubstitution('Monospace', 'Roboto Mono')

        # APPLICATION DEFAULT FONT
        self.setFont(Font('Roboto', pixelSize=12))

        #############################################
        # CONFIGURE LAYOUT
        #################################

        style = EddyProxyStyle('Fusion')
        self.setStyle(style)
        self.setStyleSheet(style.stylesheet)

        #############################################
        # DRAW THE SPLASH SCREEN
        #################################

        splash = None
        if not self.options.isSet(CommandLineParser.NO_SPLASH):
            splash = Splash(mtime=2)
            splash.show()

        #############################################
        # CONFIGURE RECENT PROJECTS
        #################################

        settings = QtCore.QSettings()

        if not settings.contains('project/recent'):
            # From PyQt5 documentation: if the value of the setting is a container (corresponding
            # to either QVariantList, QVariantMap or QVariantHash) then the type is applied to the
            # contents of the container. So we can't use an empty list as default value because
            # PyQt5 needs to know the type of the contents added to the collection: we avoid
            # this problem by placing the list of example projects as recent project list.
            examples = list(filter(lambda path: fexists(path) and faccess(path), [
                expandPath('@examples/Animals{}'.format(File.Graphol.extension)),
                expandPath('@examples/Diet{}'.format(File.Graphol.extension)),
                expandPath('@examples/Family{}'.format(File.Graphol.extension)),
                expandPath('@examples/LUBM{}'.format(File.Graphol.extension)),
                expandPath('@examples/Pizza{}'.format(File.Graphol.extension)),
            ]))
            settings.setValue('project/recent', examples)
        else:
            # If we have some projects in our recent list, check whether they exists on the
            # filesystem. If they do not exists we remove them from our recent list.
            projects = []
            for path in map(expandPath, settings.value('project/recent', None, str) or []):
                if fexists(path) and path not in projects:
                    projects.append(path)
            settings.setValue('project/recent', projects)
            settings.sync()

        #############################################
        # LOOKUP PLUGINS
        #################################

        PluginManager.scan('@plugins/', '@home/plugins/')

        #############################################
        # CLOSE THE SPLASH SCREEN
        #################################

        if splash and not self.options.isSet(CommandLineParser.NO_SPLASH):
            splash.sleep()
            splash.close()
Example #17
0
    def __init__(self, collection, parent=None):
        """
        Initialize the project dialog.
        :type collection: T <= list | tuple
        :type parent: QWidget
        """
        super().__init__(parent)

        self.collection = sorted(collection, key=itemgetter(K_ITEM, K_NAME))

        #############################################
        # CHECKBOX WIDGETS
        #################################

        self.marks = {K_CURRENT: {}, K_IMPORTING: {}, K_FINAL: {}}

        for e in self.collection:
            ## CREATE CURRENT CHECKBOX
            mark = CheckBox(self)
            mark.setEnabled(False)
            mark.setChecked(e[K_CURRENT])
            if e[K_ITEM] not in self.marks[K_CURRENT]:
                self.marks[K_CURRENT][e[K_ITEM]] = {}
            if e[K_NAME] not in self.marks[K_CURRENT][e[K_ITEM]]:
                self.marks[K_CURRENT][e[K_ITEM]][e[K_NAME]] = {}
            self.marks[K_CURRENT][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]] = mark
            ## CREATE IMPORTING CHECKBOX
            mark = CheckBox(self)
            mark.setEnabled(False)
            mark.setChecked(e[K_IMPORTING])
            if e[K_ITEM] not in self.marks[K_IMPORTING]:
                self.marks[K_IMPORTING][e[K_ITEM]] = {}
            if e[K_NAME] not in self.marks[K_IMPORTING][e[K_ITEM]]:
                self.marks[K_IMPORTING][e[K_ITEM]][e[K_NAME]] = {}
            self.marks[K_IMPORTING][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]] = mark
            ## CREATE FINAL CHECKBOX
            mark = CheckBox(self)
            mark.setEnabled(True)
            mark.setTristate(True)
            mark.setCheckState(QtCore.Qt.PartiallyChecked)
            connect(mark.stateChanged, self.onMarkStateChanged)
            if e[K_ITEM] not in self.marks[K_FINAL]:
                self.marks[K_FINAL][e[K_ITEM]] = {}
            if e[K_NAME] not in self.marks[K_FINAL][e[K_ITEM]]:
                self.marks[K_FINAL][e[K_ITEM]][e[K_NAME]] = {}
            self.marks[K_FINAL][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]] = mark

        #############################################
        # BUTTONS & PLACEHOLDERS
        #################################

        # widget = QtWidgets.QLabel(self)
        # widget.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        # widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        # widget.setObjectName('title_type')
        # widget.setText('Type')
        # self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        # widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        # widget.setObjectName('title_name')
        # widget.setText('Name')
        # self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        # widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        # widget.setObjectName('title_property')
        # widget.setText('Property')
        # self.addWidget(widget)

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('title_current')
        widget.setText('Current')
        self.addWidget(widget)

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('title_final')
        widget.setText('Final')
        self.addWidget(widget)

        widget = QtWidgets.QLabel(self)
        widget.setAlignment(QtCore.Qt.AlignCenter)
        widget.setFont(Font('Roboto', 14, bold=True, capitalization=Font.AllUppercase))
        widget.setObjectName('title_importing')
        widget.setText('Importing')
        self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setFixedSize(QtCore.QSize(24, 24))
        # widget.setPixmap(QtGui.QIcon(':/icons/24/ic_compare_arrows_black').pixmap(24))
        # widget.setObjectName('compare_arrows_current_icon')
        # self.addWidget(widget)

        # widget = QtWidgets.QLabel(self)
        # widget.setFixedSize(QtCore.QSize(24, 24))
        # widget.setPixmap(QtGui.QIcon(':/icons/24/ic_compare_arrows_black').pixmap(24))
        # widget.setObjectName('compare_arrows_importing_icon')
        # self.addWidget(widget)

        widget = PHCQPushButton(self)
        widget.setAutoDefault(False)
        widget.setDefault(False)
        widget.setProperty('class', 'flat blue')
        widget.setFixedWidth(32)
        widget.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_right_black'))
        widget.setIconSize(QtCore.QSize(24, 24))
        widget.setObjectName('pick_current_button')
        widget.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
        connect(widget.clicked, self.doPickBooleanSet)
        self.addWidget(widget)

        widget = PHCQPushButton(self)
        widget.setAutoDefault(False)
        widget.setDefault(False)
        widget.setProperty('class', 'flat blue')
        widget.setFixedWidth(32)
        widget.setIcon(QtGui.QIcon(':/icons/24/ic_keyboard_arrow_left_black'))
        widget.setIconSize(QtCore.QSize(24, 24))
        widget.setObjectName('pick_importing_button')
        widget.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
        connect(widget.clicked, self.doPickBooleanSet)
        self.addWidget(widget)

        #############################################
        # CONFIRMATION AREA
        #################################

        widget = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal, self)
        widget.addButton(QtWidgets.QDialogButtonBox.Ok)
        widget.addButton(QtWidgets.QDialogButtonBox.Abort)
        widget.setContentsMargins(0, 4, 0, 0)
        widget.setFont(Font('Roboto', 12))
        widget.setObjectName('confirmation_box')
        widget.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
        connect(widget.accepted, self.accept)
        connect(widget.rejected, self.reject)
        self.addWidget(widget)

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        gridWidget = QtWidgets.QWidget(self)
        gridLayout = QtWidgets.QGridLayout(gridWidget)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        #gridLayout.addWidget(self.widget('title_type'), 0, 0)
        #gridLayout.addWidget(self.widget('title_name'), 0, 1)
        #gridLayout.addWidget(self.widget('title_property'), 0, 2)
        gridLayout.addWidget(self.widget('title_current'), 0, 3)
        gridLayout.addWidget(self.widget('title_final'), 0, 5)
        gridLayout.addWidget(self.widget('title_importing'), 0, 7)
        #gridLayout.addWidget(self.widget('compare_arrows_current_icon'), 0, 4, QtCore.Qt.AlignCenter)
        #gridLayout.addWidget(self.widget('compare_arrows_importing_icon'), 0, 6, QtCore.Qt.AlignCenter)

        for row, e in enumerate(self.collection, start=1):
            w_type = QtWidgets.QLabel(self)
            w_type.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
            w_type.setFont(Font('Roboto', 12))
            w_type.setText(e[K_ITEM].shortName.title())
            w_name = QtWidgets.QLabel(self)
            w_name.setContentsMargins(40, 0, 40, 0)
            w_name.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
            w_name.setFont(Font('Roboto', 12, italic=True))
            w_name.setText(e[K_NAME])
            w_prop = QtWidgets.QLabel(self)
            w_prop.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
            w_prop.setFont(Font('Roboto', 14, bold=True, capitalization=Font.SmallCaps))
            w_prop.setText(RE_CAMEL_SPACE.sub('\g<1> \g<2>', e[K_PROPERTY]).lower())
            gridLayout.addWidget(w_type, row, 0)
            gridLayout.addWidget(w_name, row, 1)
            gridLayout.addWidget(w_prop, row, 2)
            gridLayout.addWidget(self.marks[K_CURRENT][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]], row, 3, QtCore.Qt.AlignCenter)
            gridLayout.addWidget(self.marks[K_FINAL][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]], row, 5, QtCore.Qt.AlignCenter)
            gridLayout.addWidget(self.marks[K_IMPORTING][e[K_ITEM]][e[K_NAME]][e[K_PROPERTY]], row, 7, QtCore.Qt.AlignCenter)

        gridLayout.addWidget(self.widget('pick_current_button'), 1, 4, len(self.collection), 1)
        gridLayout.addWidget(self.widget('pick_importing_button'), 1, 6, len(self.collection), 1)

        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addWidget(gridWidget)
        mainLayout.addWidget(self.widget('confirmation_box'))
        mainLayout.setContentsMargins(10, 10, 10, 10)

        self.setLayout(mainLayout)
        self.setFixedSize(self.sizeHint())
        self.setFont(Font('Roboto', 12))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle("Resolve conflicts...")
Example #18
0
    def __init__(self, project, session):
        """
        Initialize the dialog.
        :type project: Project
        :type session: Session
        """
        super().__init__(session)

        self.project = project
        self.workerThread = None
        self.worker = None

        self.msgbox_busy = QtWidgets.QMessageBox(self,
                                                 objectName='msgbox_busy')
        self.msgbox_busy.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.msgbox_busy.setWindowTitle('Please Wait!')
        self.msgbox_busy.setStandardButtons(QtWidgets.QMessageBox.NoButton)
        self.msgbox_busy.setText('Running reasoner  (Please Wait!)')
        self.msgbox_busy.setTextFormat(QtCore.Qt.RichText)

        self.status_bar = QtWidgets.QStatusBar()
        self.status_bar.setMinimumWidth(350)
        ####################################################

        self.messageBoxLayout = QtWidgets.QVBoxLayout()
        self.messageBoxLayout.setContentsMargins(0, 6, 0, 0)
        self.messageBoxLayout.setAlignment(QtCore.Qt.AlignCenter)

        self.messageBoxLayout.addWidget(self.msgbox_busy)
        self.messageBoxLayout.addWidget(self.status_bar)

        self.messageBoxArea = QtWidgets.QWidget()
        self.messageBoxArea.setLayout(self.messageBoxLayout)
        self.mainLayout = QtWidgets.QVBoxLayout()
        self.mainLayout.addWidget(self.messageBoxArea)

        self.setLayout(self.mainLayout)

        if sys.platform.startswith('linux'):
            desktopsize = QtWidgets.QDesktopWidget().screenGeometry()
            top = (desktopsize.height() / 2) - (self.height() / 2)
            left = (desktopsize.width() / 2) - (self.width() / 2)
            self.move(left, top)

        self.setFont(Font('Roboto', 12))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Please Wait!')
        self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.CustomizeWindowHint)
        self.hide()
        self.setWindowModality(QtCore.Qt.NonModal)
        self.show()

        ######################################################
        self.msgbox_done = QtWidgets.QMessageBox(self)
        self.msgbox_done.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.msgbox_done.setWindowTitle('Ontology consistency check complete')
        self.msgbox_done.setStandardButtons(QtWidgets.QMessageBox.Close)
        self.msgbox_done.setTextFormat(QtCore.Qt.RichText)

        connect(self.sgnWork, self.doWork)
        self.sgnWork.emit()

        self.session.pmanager.dispose_and_remove_plugin_from_session(
            plugin_id='Unsatisfiable_Entity_Explorer')
        self.session.pmanager.dispose_and_remove_plugin_from_session(
            plugin_id='Explanation_explorer')
        self.session.BackgrounddeColourNodesAndEdges(
            call_updateNode=True,
            call_ClearInconsistentEntitiesAndDiagItemsData=True)

        connect(self.project.sgnItemAdded,
                self.project.reset_changes_made_after_reasoning_task)
        connect(self.project.sgnItemRemoved,
                self.project.reset_changes_made_after_reasoning_task)
Example #19
0
    def __init__(self, application, parent=None):
        """
        Initialize the workspace dialog.
        :type application: QApplication
        :type parent: QtWidgets.QWidget
        """
        super().__init__(parent)

        settings = QtCore.QSettings()

        self.pending = False
        self.workspace = settings.value('workspace/home', WORKSPACE, str)

        #############################################
        # LEFT AREA
        #################################

        self.innerWidgetL = QtWidgets.QWidget(self)
        self.innerWidgetL.setProperty('class', 'inner-left')
        self.innerWidgetL.setContentsMargins(0, 0, 0, 0)

        self.innerLayoutL = QtWidgets.QVBoxLayout(self.innerWidgetL)
        self.innerLayoutL.setContentsMargins(0, 0, 0, 0)
        self.innerLayoutL.setSpacing(0)

        #############################################
        # RIGHT AREA
        #################################

        self.actionBugTracker = QtWidgets.QAction('Report a bug', self)
        self.actionBugTracker.setData(BUG_TRACKER)
        connect(self.actionBugTracker.triggered, self.doOpenURL)
        self.actionGrapholWeb = QtWidgets.QAction('Visit Graphol website',
                                                  self)
        self.actionGrapholWeb.setData(GRAPHOL_HOME)
        connect(self.actionGrapholWeb.triggered, self.doOpenURL)
        self.actionProjectHome = QtWidgets.QAction('GitHub repository', self)
        self.actionProjectHome.setData(PROJECT_HOME)
        connect(self.actionProjectHome.triggered, self.doOpenURL)

        self.menuHelp = QtWidgets.QMenu(self)
        self.menuHelp.addAction(self.actionBugTracker)
        self.menuHelp.addAction(self.actionProjectHome)
        self.menuHelp.addAction(self.actionGrapholWeb)

        self.innerWidgetR = QtWidgets.QWidget(self)
        self.innerWidgetR.setProperty('class', 'inner-right')
        self.innerWidgetR.setContentsMargins(0, 30, 0, 0)

        self.appPix = QtWidgets.QLabel(self)
        self.appPix.setPixmap(QtGui.QIcon(':/icons/128/ic_eddy').pixmap(128))
        self.appPix.setContentsMargins(0, 0, 0, 0)
        self.appName = QtWidgets.QLabel(APPNAME, self)
        self.appName.setFont(Font(scale=2.5, capitalization=Font.SmallCaps))
        self.appName.setProperty('class', 'appname')
        self.appVersion = QtWidgets.QLabel('Version: {0}'.format(VERSION),
                                           self)
        self.appVersion.setFont(
            Font(scale=1.3333, capitalization=Font.SmallCaps))
        self.appVersion.setProperty('class', 'version')

        self.buttonNewProject = PHCQPushButton(self)
        self.buttonNewProject.setIcon(
            QtGui.QIcon(':/icons/24/ic_add_document_black'))
        self.buttonNewProject.setIconSize(QtCore.QSize(24, 24))
        self.buttonNewProject.setText('&Create new project')
        connect(self.buttonNewProject.clicked, self.doNewProject)
        self.buttonOpenProject = PHCQPushButton(self)
        self.buttonOpenProject.setIcon(
            QtGui.QIcon(':/icons/24/ic_folder_open_black'))
        self.buttonOpenProject.setIconSize(QtCore.QSize(24, 24))
        self.buttonOpenProject.setText('&Open project')
        connect(self.buttonOpenProject.clicked, self.doOpen)

        self.buttonHelp = PHCQToolButton(self)
        self.buttonHelp.setIcon(
            QtGui.QIcon(':/icons/24/ic_help_outline_black'))
        self.buttonHelp.setIconSize(QtCore.QSize(24, 24))
        self.buttonHelp.setText('&Help')
        self.buttonHelp.setMenu(self.menuHelp)
        self.buttonHelp.setPopupMode(PHCQToolButton.InstantPopup)
        self.buttonHelp.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)

        self.buttonLayoutRT = QtWidgets.QVBoxLayout()
        self.buttonLayoutRT.addWidget(self.buttonNewProject)
        self.buttonLayoutRT.addWidget(self.buttonOpenProject)
        self.buttonLayoutRT.setContentsMargins(0, 38, 0, 0)
        self.buttonLayoutRT.setAlignment(QtCore.Qt.AlignHCenter)
        self.buttonLayoutRB = QtWidgets.QHBoxLayout()
        self.buttonLayoutRB.addWidget(self.buttonHelp)
        self.buttonLayoutRB.setAlignment(QtCore.Qt.AlignBottom
                                         | QtCore.Qt.AlignRight)
        self.buttonLayoutRB.setContentsMargins(0, 30, 8, 0)

        self.innerLayoutR = QtWidgets.QVBoxLayout(self.innerWidgetR)
        self.innerLayoutR.setContentsMargins(0, 0, 0, 0)
        self.innerLayoutR.addWidget(self.appPix, 0, QtCore.Qt.AlignHCenter)
        self.innerLayoutR.addWidget(self.appName, 0, QtCore.Qt.AlignHCenter)
        self.innerLayoutR.addWidget(self.appVersion, 0, QtCore.Qt.AlignHCenter)
        self.innerLayoutR.addLayout(self.buttonLayoutRT)
        self.innerLayoutR.addLayout(self.buttonLayoutRB)

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        self.placeholder = QtWidgets.QLabel('No Recent Projects', self)
        self.placeholder.setEnabled(False)
        self.placeholder.setFixedSize(300, 400)
        self.placeholder.setFont(Font(scale=1.5))
        self.placeholder.setAlignment(QtCore.Qt.AlignCenter
                                      | QtCore.Qt.AlignHCenter)

        self.outerWidgetL = QtWidgets.QWidget(self)
        self.outerWidgetL.setProperty('class', 'outer-left')
        self.outerWidgetL.setContentsMargins(0, 0, 0, 0)
        self.outerWidgetL.setFixedWidth(300)
        self.outerLayoutL = QtWidgets.QVBoxLayout(self.outerWidgetL)
        self.outerLayoutL.setContentsMargins(0, 0, 0, 0)
        self.outerLayoutL.addWidget(self.placeholder, 1, QtCore.Qt.AlignTop)
        self.outerLayoutL.addWidget(self.innerWidgetL, 0, QtCore.Qt.AlignTop)

        self.outerWidgetR = QtWidgets.QWidget(self)
        self.outerWidgetR.setProperty('class', 'outer-right')
        self.outerWidgetR.setContentsMargins(0, 0, 0, 0)
        self.outerLayoutR = QtWidgets.QVBoxLayout(self.outerWidgetR)
        self.outerLayoutR.setContentsMargins(0, 0, 0, 0)
        self.outerLayoutR.addWidget(self.innerWidgetR, 0, QtCore.Qt.AlignTop)

        self.mainLayout = QtWidgets.QHBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.outerWidgetL)
        self.mainLayout.addWidget(self.outerWidgetR)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setFixedSize(720, 400)
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Welcome to {0}'.format(APPNAME))

        connect(self.sgnCreateSession, application.doCreateSession)
        connect(self.sgnCreateSessionFromScratch,
                application.doCreateSessionFromScratch)

        connect(self.sgnOpenProject, self.doOpenProject)
        connect(self.sgnUpdateRecentProjects, self.doUpdateRecentProjects)

        desktop = QtWidgets.QDesktopWidget()
        screen = desktop.availableGeometry(self)
        widget = self.geometry()
        x = screen.x() + (screen.width() - widget.width()) / 2
        y = screen.y() + (screen.height() - widget.height()) / 2
        self.move(x, y)

        # UPDATE RECENT PROJECTS
        self.sgnUpdateRecentProjects.emit()
Example #20
0
    def iconFor(self, item):
        """
        Returns the appropriate icon for the given item.
        :type item: Item
        :rtype: QtGui.QIcon
        """
        icon = QtGui.QIcon()

        for i in (1.0, 2.0):

            pixmap = QtGui.QPixmap(60 * i, 44 * i)
            pixmap.setDevicePixelRatio(i)
            pixmap.fill(QtCore.Qt.transparent)

            #############################################
            # CONCEPT NODE
            #################################

            if item is Item.ConceptNode:
                painter = QtGui.QPainter(pixmap)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawRect(QtCore.QRectF(-27, -17, 54, 34))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-27, -17, 54, 34), QtCore.Qt.AlignCenter, 'concept')
                painter.end()

            #############################################
            # ROLE NODE
            #################################

            elif item is Item.RoleNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(0, +17),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(0, -17),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -17, 46, 34), QtCore.Qt.AlignCenter, 'role')
                painter.end()

            #############################################
            # ATTRIBUTE NODE
            #################################

            elif item is Item.AttributeNode:

                painter = QtGui.QPainter(pixmap)
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.translate(0, 0)
                painter.drawText(QtCore.QRectF(0, 0, 60, 22), QtCore.Qt.AlignCenter, 'attribute')
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 30)
                painter.drawEllipse(QtCore.QRectF(-9, -9, 18, 18))
                painter.end()

            #############################################
            # VALUE-DOMAIN NODE
            #################################

            elif item is Item.ValueDomainNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawRoundedRect(QtCore.QRectF(-27, -17, 54, 34), 6, 6)
                painter.setFont(Font('Roboto', 10, Font.Light))
                painter.drawText(QtCore.QRectF(-27, -17, 54, 34), QtCore.Qt.AlignCenter, 'xsd:string')
                painter.end()

            #############################################
            # INDIVIDUAL NODE
            #################################

            elif item is Item.IndividualNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-20, -((40 / (1 + sqrt(2))) / 2)),
                    QtCore.QPointF(-20, +((40 / (1 + sqrt(2))) / 2)),
                    QtCore.QPointF(-((40 / (1 + sqrt(2))) / 2), +20),
                    QtCore.QPointF(+((40 / (1 + sqrt(2))) / 2), +20),
                    QtCore.QPointF(+20, +((40 / (1 + sqrt(2))) / 2)),
                    QtCore.QPointF(+20, -((40 / (1 + sqrt(2))) / 2)),
                    QtCore.QPointF(+((40 / (1 + sqrt(2))) / 2), -20),
                    QtCore.QPointF(-((40 / (1 + sqrt(2))) / 2), -20),
                    QtCore.QPointF(-20, -((40 / (1 + sqrt(2))) / 2)),
                ]))
                painter.setFont(Font('Roboto', 8 if self.isHDPI() else 9, Font.Light))
                painter.drawText(-16 if self.isHDPI() else -18, 4, 'individual')
                painter.end()

            #############################################
            # FACET NODE
            #################################

            elif item is Item.FacetNode:

                polygonA = QtGui.QPolygonF([
                    QtCore.QPointF(-54 / 2 + 4, -32 / 2),
                    QtCore.QPointF(+54 / 2, -32 / 2),
                    QtCore.QPointF(+54 / 2 - 4 / 2, 0),
                    QtCore.QPointF(-54 / 2 + 4 / 2, 0),
                    QtCore.QPointF(-54 / 2 + 4, -32 / 2),
                ])
                polygonB = QtGui.QPolygonF([
                    QtCore.QPointF(-54 / 2 + 4 / 2, 0),
                    QtCore.QPointF(+54 / 2 - 4 / 2, 0),
                    QtCore.QPointF(+54 / 2 - 4, +32 / 2),
                    QtCore.QPointF(-54 / 2, +32 / 2),
                    QtCore.QPointF(-54 / 2 + 4 / 2, 0),
                ])
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.setBrush(QtGui.QBrush(QtGui.QColor(222, 222, 222, 255)))
                painter.drawPolygon(polygonA)
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.drawPolygon(polygonB)
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.drawText(QtCore.QPointF(-19 if _MACOS else -20, -5), Facet.length.value)
                painter.drawText(QtCore.QPointF(-8, 12), '"32"')
                painter.end()

            #############################################
            # DOMAIN RESTRICTION NODE
            #################################

            elif item is Item.DomainRestrictionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.translate(0, 0)
                painter.drawText(QtCore.QRectF(0, 0, 60, 22), QtCore.Qt.AlignCenter, 'restriction')
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawRect(QtCore.QRectF(-18 / 2, -18 / 2 + 6, 18, 18))
                painter.end()

            #############################################
            # RANGE RESTRICTION NODE
            #################################

            elif item is Item.RangeRestrictionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.translate(0, 0)
                painter.drawText(QtCore.QRectF(0, 0, 60, 22), QtCore.Qt.AlignCenter, 'restriction')
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.translate(30, 22)
                painter.drawRect(QtCore.QRectF(-18 / 2, -18 / 2 + 6, 18, 18))
                painter.end()

            #############################################
            # INTERSECTION NODE
            #################################

            elif item is Item.IntersectionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'and')
                painter.end()

            #############################################
            # ROLE CHAIN NODE
            #################################

            elif item is Item.RoleChainNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'chain')
                painter.end()

            #############################################
            # DATATYPE RESTRICTION NODE
            #################################

            elif item is Item.DatatypeRestrictionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'data')
                painter.end()

            #############################################
            # ROLE INVERSE NODE
            #################################

            elif item is Item.RoleInverseNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'inv')
                painter.end()

            #############################################
            # COMPLEMENT NODE
            #################################

            elif item is Item.ComplementNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'not')
                painter.end()

            #############################################
            # ENUMERATION NODE
            #################################

            elif item is Item.EnumerationNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'oneOf')
                painter.end()

            #############################################
            # UNION NODE
            #################################

            elif item is Item.UnionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.setFont(Font('Roboto', 11, Font.Light))
                painter.drawText(QtCore.QRectF(-23, -15, 46, 30), QtCore.Qt.AlignCenter, 'or')
                painter.end()

            #############################################
            # DISJOINT-UNION NODE
            #################################

            elif item is Item.DisjointUnionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.translate(30, 22)
                painter.drawPolygon(QtGui.QPolygonF([
                    QtCore.QPointF(-23, 0),
                    QtCore.QPointF(-23 + 6, +15),
                    QtCore.QPointF(+23 - 6, +15),
                    QtCore.QPointF(+23, 0),
                    QtCore.QPointF(+23 - 6, -15),
                    QtCore.QPointF(-23 + 6, -15),
                    QtCore.QPointF(-23, 0),
                ]))
                painter.end()

            #############################################
            # PROPERTY ASSERTION NODE
            #################################

            elif item is Item.PropertyAssertionNode:

                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.0, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.translate(30, 22)
                painter.drawRoundedRect(QtCore.QRectF(-23, -15, 46, 30), 14, 14)
                painter.end()

            #############################################
            # INCLUSION EDGE
            #################################

            elif item is Item.InclusionEdge:

                P1 = QtCore.QPointF(3, 22)
                P2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(P1, P2)
                A1 = L1.angle()
                P1 = QtCore.QPointF(L1.p2().x() + 2, L1.p2().y())
                P2 = P1 - QtCore.QPointF(sin(A1 + M_PI / 3.0) * 8, cos(A1 + M_PI / 3.0) * 8)
                P3 = P1 - QtCore.QPointF(sin(A1 + M_PI - M_PI / 3.0) * 8, cos(A1 + M_PI - M_PI / 3.0) * 8)
                H1 = QtGui.QPolygonF([P1, P2, P3])
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.drawPolygon(H1)
                painter.end()

            #############################################
            # EQUIVALENCE EDGE
            #################################

            elif item is Item.EquivalenceEdge:

                P1 = QtCore.QPointF(3, 22)
                P2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(P1, P2)
                A1 = L1.angle()
                P1 = QtCore.QPointF(L1.p2().x(), L1.p2().y())
                P2 = P1 - QtCore.QPointF(sin(A1 + M_PI / 3.0) * 8, cos(A1 + M_PI / 3.0) * 8)
                P3 = P1 - QtCore.QPointF(sin(A1 + M_PI - M_PI / 3.0) * 8, cos(A1 + M_PI - M_PI / 3.0) * 8)
                H1 = QtGui.QPolygonF([P1, P2, P3])
                P1 = QtCore.QPointF(L1.p1().x(), L1.p1().y())
                P2 = P1 + QtCore.QPointF(sin(A1 + M_PI / 3.0) * 8, cos(A1 + M_PI / 3.0) * 8)
                P3 = P1 + QtCore.QPointF(sin(A1 + M_PI - M_PI / 3.0) * 8, cos(A1 + M_PI - M_PI / 3.0) * 8)
                T1 = QtGui.QPolygonF([P1, P2, P3])
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.drawPolygon(H1)
                painter.drawPolygon(T1)
                painter.end()

            #############################################
            # INPUT EDGE
            #################################

            elif item is Item.InputEdge:

                P1 = QtCore.QPointF(3, 22)
                P2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(P1, P2)
                A1 = L1.angle()
                P1 = QtCore.QPointF(L1.p2().x() + 2, L1.p2().y())
                P2 = P1 - QtCore.QPointF(sin(A1 + M_PI / 4.0) * 8, cos(A1 + M_PI / 4.0) * 8)
                P3 = P2 - QtCore.QPointF(sin(A1 + 3.0 / 4.0 * M_PI) * 8, cos(A1 + 3.0 / 4.0 * M_PI) * 8)
                p4 = P3 - QtCore.QPointF(sin(A1 - 3.0 / 4.0 * M_PI) * 8, cos(A1 - 3.0 / 4.0 * M_PI) * 8)
                H1 = QtGui.QPolygonF([P1, P2, P3, p4])
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.CustomDashLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)
                pen.setDashPattern([3, 3])
                painter.setPen(pen)
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(252, 252, 252, 255)))
                painter.drawPolygon(H1)
                painter.end()

            #############################################
            # MEMBERSHIP EDGE
            #################################

            elif item is Item.MembershipEdge:

                PP1 = QtCore.QPointF(2, 22)
                PP2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(PP1, PP2)
                A1 = L1.angle()
                P1 = QtCore.QPointF(L1.p2().x() + 2, L1.p2().y())
                P2 = P1 - QtCore.QPointF(sin(A1 + M_PI / 3.0) * 8, cos(A1 + M_PI / 3.0) * 8)
                P3 = P1 - QtCore.QPointF(sin(A1 + M_PI - M_PI / 3.0) * 8, cos(A1 + M_PI - M_PI / 3.0) * 8)
                H1 = QtGui.QPolygonF([P1, P2, P3])
                S1 = 2 if _MACOS else 0
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.drawPolygon(H1)
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.drawText(PP1.x() + S1, 18, 'instanceOf')
                painter.end()

            #############################################
            # SAME EDGE
            #################################

            elif item is Item.SameEdge:

                PP1 = QtCore.QPointF(2, 22)
                PP2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(PP1, PP2)
                S1 = (PP2.x() - PP1.x() - 25) / 2
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.drawText(PP1.x() + S1, 18, 'same')
                painter.end()

            #############################################
            # DIFFERENT EDGE
            #################################

            elif item is Item.DifferentEdge:

                PP1 = QtCore.QPointF(2, 22)
                PP2 = QtCore.QPointF(55, 22)
                L1 = QtCore.QLineF(PP1, PP2)
                S1 = (PP2.x() - PP1.x() - 35) / 2
                painter = QtGui.QPainter(pixmap)
                painter.setRenderHint(QtGui.QPainter.Antialiasing)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.drawLine(L1)
                painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)), 1.1, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
                painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 255)))
                painter.setFont(Font('Roboto', 9, Font.Light))
                painter.drawText(PP1.x() + S1, 18, 'different')
                painter.end()

            #############################################
            # ADD THE GENERATED PIXMAP TO THE ICON
            #################################

            icon.addPixmap(pixmap)

        return icon
Example #21
0
    def __init__(self, diagram, node, session):
        """
        Initialize the node properties dialog.
        :type diagram: Diagram
        :type node: AbstractNode
        :type session: Session
        """
        super().__init__(session)

        self.diagram = diagram
        self.node = node

        #############################################
        # GENERAL TAB
        #################################

        self.idLabel = QtWidgets.QLabel(self)
        self.idLabel.setFont(Font('Roboto', 12))
        self.idLabel.setText('ID')
        self.idField = StringField(self)
        self.idField.setFont(Font('Roboto', 12))
        self.idField.setFixedWidth(300)
        self.idField.setFocusPolicy(QtCore.Qt.NoFocus)
        self.idField.setReadOnly(True)
        self.idField.setValue(self.node.id)

        self.typeLabel = QtWidgets.QLabel(self)
        self.typeLabel.setFont(Font('Roboto', 12))
        self.typeLabel.setText('Type')
        self.typeField = StringField(self)
        self.typeField.setFont(Font('Roboto', 12))
        self.typeField.setFocusPolicy(QtCore.Qt.NoFocus)
        self.typeField.setFixedWidth(300)
        self.typeField.setReadOnly(True)
        self.typeField.setValue(node.shortName.capitalize())

        self.identityLabel = QtWidgets.QLabel(self)
        self.identityLabel.setFont(Font('Roboto', 12))
        self.identityLabel.setText('Identity')
        self.identityField = StringField(self)
        self.identityField.setFont(Font('Roboto', 12))
        self.identityField.setFocusPolicy(QtCore.Qt.NoFocus)
        self.identityField.setFixedWidth(300)
        self.identityField.setReadOnly(True)
        self.identityField.setValue(self.node.identityName)

        self.neighboursLabel = QtWidgets.QLabel(self)
        self.neighboursLabel.setFont(Font('Roboto', 12))
        self.neighboursLabel.setText('Neighbours')
        self.neighboursField = IntegerField(self)
        self.neighboursField.setFont(Font('Roboto', 12))
        self.neighboursField.setFocusPolicy(QtCore.Qt.NoFocus)
        self.neighboursField.setFixedWidth(300)
        self.neighboursField.setReadOnly(True)
        self.neighboursField.setValue(len(self.node.adjacentNodes()))

        self.generalWidget = QtWidgets.QWidget()
        self.generalLayout = QtWidgets.QFormLayout(self.generalWidget)
        self.generalLayout.addRow(self.idLabel, self.idField)
        self.generalLayout.addRow(self.typeLabel, self.typeField)
        self.generalLayout.addRow(self.identityLabel, self.identityField)
        self.generalLayout.addRow(self.neighboursLabel, self.neighboursField)

        #############################################
        # GEOMETRY TAB
        #################################

        nodePos = self.node.pos()
        sceneRect = self.diagram.sceneRect()

        self.xLabel = QtWidgets.QLabel(self)
        self.xLabel.setFont(Font('Roboto', 12))
        self.xLabel.setText('X')
        self.xField = SpinBox(self)
        self.xField.setFixedWidth(60)
        self.xField.setFont(Font('Roboto', 12))
        self.xField.setRange(sceneRect.left(), sceneRect.right())
        self.xField.setValue(int(nodePos.x()))

        self.yLabel = QtWidgets.QLabel(self)
        self.yLabel.setFont(Font('Roboto', 12))
        self.yLabel.setText('Y')
        self.yField = SpinBox(self)
        self.yField.setFixedWidth(60)
        self.yField.setFont(Font('Roboto', 12))
        self.yField.setRange(sceneRect.top(), sceneRect.bottom())
        self.yField.setValue(int(nodePos.y()))

        self.widthLabel = QtWidgets.QLabel(self)
        self.widthLabel.setFont(Font('Roboto', 12))
        self.widthLabel.setText('Width')
        self.widthField = SpinBox(self)
        self.widthField.setFixedWidth(60)
        self.widthField.setFont(Font('Roboto', 12))
        self.widthField.setRange(20, sceneRect.width())
        self.widthField.setReadOnly(True)
        self.widthField.setValue(int(self.node.width()))

        self.heightLabel = QtWidgets.QLabel(self)
        self.heightLabel.setFont(Font('Roboto', 12))
        self.heightLabel.setText('Height')
        self.heightField = SpinBox(self)
        self.heightField.setFixedWidth(60)
        self.heightField.setFont(Font('Roboto', 12))
        self.heightField.setRange(20, sceneRect.height())
        self.heightField.setReadOnly(True)
        self.heightField.setValue(int(self.node.height()))

        self.geometryWidget = QtWidgets.QWidget()
        self.geometryLayout = QtWidgets.QFormLayout(self.geometryWidget)
        self.geometryLayout.addRow(self.xLabel, self.xField)
        self.geometryLayout.addRow(self.yLabel, self.yField)
        self.geometryLayout.addRow(self.widthLabel, self.widthField)
        self.geometryLayout.addRow(self.heightLabel, self.heightField)

        #############################################
        # CONFIRMATION BOX
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(
            QtCore.Qt.Horizontal, self)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Ok)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Cancel)
        self.confirmationBox.setContentsMargins(10, 0, 10, 10)
        self.confirmationBox.setFont(Font('Roboto', 12))

        #############################################
        # MAIN WIDGET
        #################################

        self.mainWidget = QtWidgets.QTabWidget(self)
        self.mainWidget.addTab(self.generalWidget, 'General')
        self.mainWidget.addTab(self.geometryWidget, 'Geometry')
        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.mainWidget)
        self.mainLayout.addWidget(self.confirmationBox, 0,
                                  QtCore.Qt.AlignRight)

        self.setWindowTitle('Properties: {0}'.format(self.node))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))

        connect(self.confirmationBox.accepted, self.complete)
        connect(self.confirmationBox.rejected, self.reject)
Example #22
0
    def __init__(self, parent=None):
        """
        Initialize the project dialog.
        :type parent: QWidget
        """
        super().__init__(parent)

        #############################################
        # FORM AREA
        #################################

        settings = QtCore.QSettings(ORGANIZATION, APPNAME)

        self.workspace = expandPath(
            settings.value('workspace/home', WORKSPACE, str))
        self.workspace = '{0}{1}'.format(rstrip(self.workspace, os.path.sep),
                                         os.path.sep)

        self.nameLabel = QtWidgets.QLabel(self)
        self.nameLabel.setFont(Font('Roboto', 12))
        self.nameLabel.setText('Name')
        self.nameField = StringField(self)
        self.nameField.setFont(Font('Roboto', 12))
        self.nameField.setMinimumWidth(400)
        self.nameField.setMaxLength(64)

        self.prefixLabel = QtWidgets.QLabel(self)
        self.prefixLabel.setFont(Font('Roboto', 12))
        self.prefixLabel.setText('Prefix')
        self.prefixField = StringField(self)
        self.prefixField.setFont(Font('Roboto', 12))
        self.prefixField.setMinimumWidth(400)

        self.iriLabel = QtWidgets.QLabel(self)
        self.iriLabel.setFont(Font('Roboto', 12))
        self.iriLabel.setText('IRI')
        self.iriField = StringField(self)
        self.iriField.setFont(Font('Roboto', 12))
        self.iriField.setMinimumWidth(400)

        connect(self.prefixField.textChanged, self.doAcceptForm)
        connect(self.iriField.textChanged, self.doAcceptForm)
        connect(self.nameField.textChanged, self.doAcceptForm)
        connect(self.nameField.textChanged, self.onNameFieldChanged)

        self.pathLabel = QtWidgets.QLabel(self)
        self.pathLabel.setFont(Font('Roboto', 12))
        self.pathLabel.setText('Location')
        self.pathField = StringField(self)
        self.pathField.setFont(Font('Roboto', 12))
        self.pathField.setMinimumWidth(400)
        self.pathField.setReadOnly(True)
        self.pathField.setFocusPolicy(QtCore.Qt.NoFocus)
        self.pathField.setValue(self.workspace)

        spacer = QtWidgets.QFrame()
        spacer.setFrameShape(QtWidgets.QFrame.HLine)
        spacer.setFrameShadow(QtWidgets.QFrame.Sunken)

        self.formWidget = QtWidgets.QWidget(self)
        self.formLayout = QtWidgets.QFormLayout(self.formWidget)
        self.formLayout.addRow(self.nameLabel, self.nameField)
        self.formLayout.addRow(self.prefixLabel, self.prefixField)
        self.formLayout.addRow(self.iriLabel, self.iriField)
        self.formLayout.addWidget(spacer)
        self.formLayout.addRow(self.pathLabel, self.pathField)

        #############################################
        # CONFIRMATION AREA
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(
            QtCore.Qt.Horizontal, self)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Ok)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Cancel)
        self.confirmationBox.setContentsMargins(10, 0, 10, 10)
        self.confirmationBox.setFont(Font('Roboto', 12))
        self.confirmationBox.button(
            QtWidgets.QDialogButtonBox.Ok).setEnabled(False)

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        self.caption = QtWidgets.QLabel(self)
        self.caption.setFont(Font('Roboto', 12))
        self.caption.setContentsMargins(8, 0, 8, 0)
        self.caption.setProperty('class', 'invalid')
        self.caption.setVisible(False)

        self.gridLayout = QtWidgets.QVBoxLayout(self)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.addWidget(self.formWidget)
        self.gridLayout.addWidget(self.caption)
        self.gridLayout.addWidget(self.confirmationBox, 0,
                                  QtCore.Qt.AlignRight)

        self.setFixedSize(self.sizeHint())
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('New project')

        connect(self.confirmationBox.accepted, self.accept)
        connect(self.confirmationBox.rejected, self.reject)
Example #23
0
    def start(self):
        """
        Perform initialization tasks for the plugin.
        """
        # INITIALIZE THE WIDGET
        self.debug('Creating palette widget')
        widget = PaletteWidget(self)
        widget.setObjectName('palette')
        self.addWidget(widget)

        # CREATE TOGGLE ACTIONS
        self.debug('Creating palette toggle actions')
        group = QtWidgets.QActionGroup(self, objectName='palette_toggle')
        group.setExclusive(False)
        for item in widget.items:
            action = QtWidgets.QAction(item.realName.title(), group, objectName=item.name, checkable=True)
            action.setChecked(widget.display[item])
            action.setData(item)
            action.setFont(Font('Roboto', 11))
            connect(action.triggered, widget.onMenuButtonClicked)
            connect(action.triggered, self.onMenuButtonClicked)
            group.addAction(action)
        self.addAction(group)

        # CREATE TOGGLE MENU
        self.debug('Creating palette toggle menu')
        menu = QtWidgets.QMenu(objectName='palette_toggle')
        menu.addActions(self.action('palette_toggle').actions())
        self.addMenu(menu)

        # CREATE CONTROL WIDGET
        self.debug('Creating palette toggle control widget')
        button = QtWidgets.QToolButton(objectName='palette_toggle')
        button.setIcon(QtGui.QIcon(':/icons/18/ic_settings_black'))
        button.setContentsMargins(0, 0, 0, 0)
        button.setFixedSize(18, 18)
        button.setMenu(self.menu('palette_toggle'))
        button.setPopupMode(QtWidgets.QToolButton.InstantPopup)
        self.addWidget(button)

        # CREATE DOCKING AREA WIDGET
        self.debug('Creating docking area widget')
        widget = DockWidget('Palette', QtGui.QIcon(':/icons/18/ic_palette_black'), self.session)
        widget.addTitleBarButton(self.widget('palette_toggle'))
        widget.installEventFilter(self)
        widget.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea)
        widget.setObjectName('palette_dock')
        widget.setWidget(self.widget('palette'))
        self.addWidget(widget)

        # CREATE ENTRY IN VIEW MENU
        self.debug('Creating docking area widget toggle in "view" menu')
        menu = self.session.menu('view')
        menu.addAction(self.widget('palette_dock').toggleViewAction())

        # INSTALL DOCKING AREA WIDGET
        self.debug('Installing docking area widget')
        self.session.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.widget('palette_dock'))

        # LISTEN FOR SESSION READY SIGNAL
        self.debug('Connecting to active session')
        connect(self.session.sgnReady, self.onSessionReady)
        connect(self.session.sgnReady, self.doActivatePalette)
Example #24
0
    def __init__(self, diagram, session):
        """
        Initialize the diagram properties dialog.
        :type diagram: Diagram
        :type session: Session
        """
        super().__init__(session)

        self.diagram = diagram

        #############################################
        # GENERAL TAB
        #################################

        self.nodesLabel = QtWidgets.QLabel(self)
        self.nodesLabel.setFont(Font('Roboto', 12))
        self.nodesLabel.setText('N° nodes')
        self.nodesField = IntegerField(self)
        self.nodesField.setFixedWidth(300)
        self.nodesField.setFont(Font('Roboto', 12))
        self.nodesField.setReadOnly(True)
        self.nodesField.setValue(len(self.diagram.nodes()))

        self.edgesLabel = QtWidgets.QLabel(self)
        self.edgesLabel.setFont(Font('Roboto', 12))
        self.edgesLabel.setText('N° edges')
        self.edgesField = IntegerField(self)
        self.edgesField.setFixedWidth(300)
        self.edgesField.setFont(Font('Roboto', 12))
        self.edgesField.setReadOnly(True)
        self.edgesField.setValue(len(self.diagram.edges()))

        self.generalWidget = QtWidgets.QWidget()
        self.generalLayout = QtWidgets.QFormLayout(self.generalWidget)
        self.generalLayout.addRow(self.nodesLabel, self.nodesField)
        self.generalLayout.addRow(self.edgesLabel, self.edgesField)

        #############################################
        # GEOMETRY TAB
        #################################

        sceneRect = self.diagram.sceneRect()

        self.diagramSizeLabel = QtWidgets.QLabel(self)
        self.diagramSizeLabel.setFont(Font('Roboto', 12))
        self.diagramSizeLabel.setText('Size')
        self.diagramSizeField = SpinBox(self)
        self.diagramSizeField.setFont(Font('Roboto', 12))
        self.diagramSizeField.setRange(Diagram.MinSize, Diagram.MaxSize)
        self.diagramSizeField.setSingleStep(100)
        self.diagramSizeField.setValue(
            max(sceneRect.width(), sceneRect.height()))

        self.geometryWidget = QtWidgets.QWidget()
        self.geometryLayout = QtWidgets.QFormLayout(self.geometryWidget)
        self.geometryLayout.addRow(self.diagramSizeLabel,
                                   self.diagramSizeField)

        #############################################
        # CONFIRMATION BOX
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(
            QtCore.Qt.Horizontal, self)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Ok)
        self.confirmationBox.addButton(QtWidgets.QDialogButtonBox.Cancel)
        self.confirmationBox.setContentsMargins(10, 0, 10, 10)
        self.confirmationBox.setFont(Font('Roboto', 12))

        #############################################
        # MAIN WIDGET
        #################################

        self.mainWidget = QtWidgets.QTabWidget(self)
        self.mainWidget.addTab(self.generalWidget, 'General')
        self.mainWidget.addTab(self.geometryWidget, 'Geometry')
        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.mainWidget)
        self.mainLayout.addWidget(self.confirmationBox, 0,
                                  QtCore.Qt.AlignRight)

        self.setWindowTitle('Properties: {0}'.format(self.diagram.name))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))

        connect(self.confirmationBox.accepted, self.complete)
        connect(self.confirmationBox.rejected, self.reject)
Example #25
0
    def __init__(self, parent=None):
        """
        Initialize the workspace dialog.
        :type parent: QtWidgets.QWidget
        """
        super().__init__(parent)

        #############################################
        # HEAD AREA
        #################################

        self.headTitle = QtWidgets.QLabel('Select a workspace', self)
        self.headTitle.setFont(Font('Roboto', 12, bold=True))
        self.headDescription = QtWidgets.QLabel(dedent("""
        {0} stores your projects in a directory called workspace.<br/>
        Please choose a workspace directory to use.""".format(APPNAME)), self)
        self.headDescription.setFont(Font('Roboto', 12))
        self.headPix = QtWidgets.QLabel(self)
        self.headPix.setPixmap(QtGui.QIcon(':/icons/128/ic_eddy').pixmap(48))
        self.headPix.setContentsMargins(0, 0, 0, 0)
        self.headWidget = QtWidgets.QWidget(self)
        self.headWidget.setProperty('class', 'head')
        self.headWidget.setContentsMargins(10, 10, 10, 10)
        self.headLayoutL = QtWidgets.QVBoxLayout()
        self.headLayoutL.addWidget(self.headTitle)
        self.headLayoutL.addWidget(self.headDescription)
        self.headLayoutL.setContentsMargins(0, 0, 0, 0)
        self.headLayoutR = QtWidgets.QVBoxLayout()
        self.headLayoutR.addWidget(self.headPix, 0, QtCore.Qt.AlignRight)
        self.headLayoutR.setContentsMargins(0, 0, 0, 0)
        self.headLayoutM = QtWidgets.QHBoxLayout(self.headWidget)
        self.headLayoutM.addLayout(self.headLayoutL)
        self.headLayoutM.addLayout(self.headLayoutR)
        self.headLayoutM.setContentsMargins(0, 0, 0, 0)

        #############################################
        # EDIT AREA
        #################################

        self.workspaceField = StringField(self)
        self.workspaceField.setFont(Font('Roboto', 12))
        self.workspaceField.setFixedWidth(400)
        self.workspaceField.setReadOnly(True)
        self.workspaceField.setText(expandPath(WORKSPACE))

        self.btnBrowse = QtWidgets.QPushButton(self)
        self.btnBrowse.setFont(Font('Roboto', 12))
        self.btnBrowse.setFixedWidth(30)
        self.btnBrowse.setText('...')

        self.editLayout = QtWidgets.QHBoxLayout()
        self.editLayout.setContentsMargins(10, 10, 10, 10)
        self.editLayout.addWidget(self.workspaceField)
        self.editLayout.addWidget(self.btnBrowse)

        #############################################
        # CONFIRMATION AREA
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok, self)
        self.confirmationBox.setContentsMargins(10, 0, 10, 10)
        self.confirmationBox.setFont(Font('Roboto', 12))

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.headWidget)
        self.mainLayout.addLayout(self.editLayout)
        self.mainLayout.addWidget(self.confirmationBox, 0, QtCore.Qt.AlignRight)

        self.setFixedSize(self.sizeHint())
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Configure workspace')

        connect(self.btnBrowse.clicked, self.choosePath)
        connect(self.confirmationBox.accepted, self.accept)
Example #26
0
    def __init__(self, project, session):
        """
        Initialize the dialog.
        :type project: Project
        :type session: Session
        """
        super().__init__(session)

        # Here we perform the validation on all the edges in the project and the isolated nodes. This is
        # due to the implementation of the checkEdge() function in the Profile class which validates the
        # edge endpoints at first, and then (if no error is detected) will perform the validation on the
        # edge itself. However, disconnected nodes won't be taken into account and thus we must perform
        # an additional step to validate the isolated nodes separately.
        self.items = list(project.edges()) + list(
            filter(lambda n: not n.adjacentNodes(), project.nodes()))
        self.project = project
        self.workerThread = None
        self.worker = None
        self.i = 0

        #############################################
        # TOP AREA
        #################################

        self.progressBar = QtWidgets.QProgressBar(self)
        self.progressBar.setAlignment(QtCore.Qt.AlignHCenter)
        self.progressBar.setRange(self.i, len(self.items) - 1)
        self.progressBar.setFixedSize(400, 30)
        self.progressBar.setValue(self.i)

        self.progressBox = QtWidgets.QWidget(self)
        self.progressBoxLayout = QtWidgets.QVBoxLayout(self.progressBox)
        self.progressBoxLayout.setContentsMargins(10, 10, 10, 10)
        self.progressBoxLayout.addWidget(self.progressBar)

        #############################################
        # CONTROLS AREA
        #################################

        self.buttonAbort = QtWidgets.QPushButton('Abort', self)
        self.buttonAbort.setFont(Font('Roboto', 12))
        self.buttonIgnore = QtWidgets.QPushButton('Ignore', self)
        self.buttonIgnore.setFont(Font('Roboto', 12))
        self.buttonShow = QtWidgets.QPushButton('Show', self)
        self.buttonShow.setFont(Font('Roboto', 12))

        self.buttonBox = QtWidgets.QWidget(self)
        self.buttonBox.setVisible(False)
        self.buttonBoxLayout = QtWidgets.QHBoxLayout(self.buttonBox)
        self.buttonBoxLayout.setContentsMargins(10, 0, 10, 10)
        self.buttonBoxLayout.addWidget(self.buttonAbort, 0,
                                       QtCore.Qt.AlignRight)
        self.buttonBoxLayout.addWidget(self.buttonIgnore, 0,
                                       QtCore.Qt.AlignRight)
        self.buttonBoxLayout.addWidget(self.buttonShow, 0,
                                       QtCore.Qt.AlignRight)

        #############################################
        # MESSAGE AREA
        #################################

        self.messageField = QtWidgets.QTextEdit(self)
        self.messageField.setAcceptRichText(True)
        self.messageField.setAttribute(QtCore.Qt.WA_MacShowFocusRect, 0)
        self.messageField.setFixedSize(400, 100)
        self.messageField.setFont(Font('Roboto', 12))
        self.messageField.setReadOnly(True)

        self.messageBox = QtWidgets.QWidget(self)
        self.messageBox.setVisible(False)
        self.messageBoxLayout = QtWidgets.QVBoxLayout(self.messageBox)
        self.messageBoxLayout.setContentsMargins(10, 0, 10, 10)
        self.messageBoxLayout.addWidget(self.messageField)

        #############################################
        # CONFIGURE LAYOUT
        #################################

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.progressBox)
        self.mainLayout.addWidget(self.buttonBox, 0, QtCore.Qt.AlignRight)
        self.mainLayout.addWidget(self.messageBox)

        connect(self.buttonAbort.clicked, self.doAbort)
        connect(self.buttonIgnore.clicked, self.doIgnore)
        connect(self.buttonShow.clicked, self.doShow)
        connect(self.sgnWork, self.doWork)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
        self.setFixedSize(self.sizeHint())
        self.setWindowTitle('Running syntax validation...')
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
Example #27
0
    def __init__(self, session):
        """
        Initialize the plugin install dialog.
        :type session: Session
        """
        super().__init__(session)

        #############################################
        # HEAD AREA
        #################################

        self.headTitle = QtWidgets.QLabel('Install a plugin', self)
        self.headTitle.setFont(Font('Roboto', 12, bold=True))
        self.headDescription = QtWidgets.QLabel(
            dedent("""
        Plugins are software components that add specific features to {0}.<br/>
        Please select the plugin you wish to install.""".format(APPNAME)),
            self)
        self.headDescription.setFont(Font('Roboto', 12))
        self.headPix = QtWidgets.QLabel(self)
        self.headPix.setPixmap(
            QtGui.QIcon(':/icons/48/ic_extension_black').pixmap(48))
        self.headPix.setContentsMargins(0, 0, 0, 0)
        self.headWidget = QtWidgets.QWidget(self)
        self.headWidget.setProperty('class', 'head')
        self.headWidget.setContentsMargins(10, 10, 10, 10)

        self.headLayoutL = QtWidgets.QVBoxLayout()
        self.headLayoutL.addWidget(self.headTitle)
        self.headLayoutL.addWidget(self.headDescription)
        self.headLayoutL.setContentsMargins(0, 0, 0, 0)
        self.headLayoutR = QtWidgets.QVBoxLayout()
        self.headLayoutR.addWidget(self.headPix, 0, QtCore.Qt.AlignRight)
        self.headLayoutR.setContentsMargins(0, 0, 0, 0)
        self.headLayoutM = QtWidgets.QHBoxLayout(self.headWidget)
        self.headLayoutM.addLayout(self.headLayoutL)
        self.headLayoutM.addLayout(self.headLayoutR)
        self.headLayoutM.setContentsMargins(0, 0, 0, 0)

        #############################################
        # SELECTION AREA
        #################################

        self.pluginField = StringField(self)
        self.pluginField.setFont(Font('Roboto', 12))
        self.pluginField.setFixedWidth(400)
        self.pluginField.setReadOnly(True)

        self.btnBrowse = QtWidgets.QPushButton(self)
        self.btnBrowse.setFont(Font('Roboto', 12))
        self.btnBrowse.setFixedWidth(30)
        self.btnBrowse.setText('...')

        self.editLayout = QtWidgets.QHBoxLayout()
        self.editLayout.setContentsMargins(10, 10, 10, 10)
        self.editLayout.addWidget(self.pluginField)
        self.editLayout.addWidget(self.btnBrowse)

        #############################################
        # CONFIRMATION AREA
        #################################

        self.confirmationBox = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok, self)
        self.confirmationBox.setContentsMargins(10, 0, 10, 10)
        self.confirmationBox.setEnabled(False)
        self.confirmationBox.setFont(Font('Roboto', 12))

        #############################################
        # SETUP DIALOG LAYOUT
        #################################

        self.mainLayout = QtWidgets.QVBoxLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.addWidget(self.headWidget)
        self.mainLayout.addLayout(self.editLayout)
        self.mainLayout.addWidget(self.confirmationBox, 0,
                                  QtCore.Qt.AlignRight)

        self.setFixedSize(self.sizeHint())
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Install a plugin')

        connect(self.btnBrowse.clicked, self.selectPlugin)
        connect(self.confirmationBox.accepted, self.accept)
Example #28
0
    def __init__(self, project, path, session):

        super().__init__(session)

        self.msgbox_done = QtWidgets.QMessageBox(self,
                                                 objectName='msgbox_done')

        self.msgbox_done.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.msgbox_done.setWindowTitle('Ontology consistency check complete')
        self.msgbox_done.setStandardButtons(QtWidgets.QMessageBox.NoButton)
        self.msgbox_done.setTextFormat(QtCore.Qt.RichText)
        self.msgbox_done.setText(
            'Ontology is inconsistent.\n The link(s) for the explanation(s) are displayed below.\n You may choose to display one explanation at a time in the Explanation\
                                 Explorer in the bottom-right portion of the screen.\
                                 To reset the background colouring of the nodes in the diagram, press the Reset button in the toolbar'
        )

        if sys.platform.startswith('linux'):

            size = self.size()
            desktopsize = QtWidgets.QDesktopWidget().screenGeometry()
            top = (desktopsize.height() / 2) - (size.height() / 2)
            left = (desktopsize.width() / 2) - (size.width() / 2)
            self.move(left, top)

        self.addWidget(self.msgbox_done)

        self.messageBoxLayout = QtWidgets.QHBoxLayout()
        self.messageBoxLayout.setContentsMargins(0, 6, 0, 0)
        self.messageBoxLayout.setAlignment(QtCore.Qt.AlignCenter)
        self.messageBoxLayout.addWidget(self.widget('msgbox_done'))

        self.messageBoxArea = QtWidgets.QWidget()
        self.messageBoxArea.setLayout(self.messageBoxLayout)

        self.confirmation = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal,
                                                       self)
        self.confirmation.addButton(QtWidgets.QDialogButtonBox.Close)
        self.confirmation.setFont(Font('Roboto', 12))
        self.confirmation.setObjectName('confirmation')

        connect(self.confirmation.rejected, self.close)

        self.addWidget(self.confirmation)

        self.confirmationLayout = QtWidgets.QHBoxLayout()
        self.confirmationLayout.setContentsMargins(0, 0, 0, 0)
        self.confirmationLayout.addWidget(self.widget('confirmation'), 0,
                                          QtCore.Qt.AlignCenter)

        self.confirmationArea = QtWidgets.QWidget()
        self.confirmationArea.setLayout(self.confirmationLayout)

        self.mainLayout = QtWidgets.QVBoxLayout()
        self.mainLayout.addWidget(self.messageBoxArea)
        self.mainLayout.addWidget(self.confirmationArea)

        self.setLayout(self.mainLayout)
        self.setFont(Font('Roboto', 12))
        self.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
        self.setWindowTitle('Ontology consistency check complete')

        self.explanationButtonsLayout = QtWidgets.QHBoxLayout()
        self.explanationButtonsArea = QtWidgets.QWidget()

        #self.setWindowFlags(QtCore.Qt.Window)

        self.hide()
        self.setWindowModality(QtCore.Qt.NonModal)
        self.show()

        self.project = project
        self.session = session

        connect(self.sgnWork, self.doWork)

        self.sgnWork.emit()
Example #29
0
    def __init__(self, diagram, node, session):
        """
        Initialize the node properties dialog.
        :type diagram: Diagram
        :type node: AbstractNode
        :type session: Session
        """
        super().__init__(diagram, node, session)

        meta = diagram.project.meta(node.type(), node.text())

        self.urlLabel = QtWidgets.QLabel(self)
        self.urlLabel.setFont(Font('Roboto', 12))
        self.urlLabel.setText('URL')
        self.urlField = StringField(self)
        self.urlField.setFixedWidth(300)
        self.urlField.setFont(Font('Roboto', 12))
        self.urlField.setValue(meta.get(K_URL, ''))

        self.descriptionLabel = QtWidgets.QLabel(self)
        self.descriptionLabel.setFont(Font('Roboto', 12))
        self.descriptionLabel.setText('Description')
        self.descriptionField = TextField(self)
        self.descriptionField.setFixedSize(300, 160)
        self.descriptionField.setFont(Font('Roboto', 12))
        self.descriptionField.setValue(meta.get(K_DESCRIPTION, ''))

        self.generalLayout.addRow(self.urlLabel, self.urlField)
        self.generalLayout.addRow(self.descriptionLabel, self.descriptionField)

        #############################################
        # LABEL TAB
        #################################

        self.textLabel = QtWidgets.QLabel(self)
        self.textLabel.setFont(Font('Roboto', 12))
        self.textLabel.setText('Text')
        self.textField = StringField(self)
        self.textField.setFixedWidth(300)
        self.textField.setFont(Font('Roboto', 12))
        self.textField.setValue(self.node.text())

        self.refactorLabel = QtWidgets.QLabel(self)
        self.refactorLabel.setFont(Font('Roboto', 12))
        self.refactorLabel.setText('Refactor')
        self.refactorField = CheckBox(self)
        self.refactorField.setFont(Font('Roboto', 12))
        self.refactorField.setChecked(False)

        if node.type() in {
                Item.AttributeNode, Item.ConceptNode, Item.RoleNode
        }:
            if node.special() is not None:
                self.refactorField.setEnabled(False)

        self.labelWidget = QtWidgets.QWidget()
        self.labelLayout = QtWidgets.QFormLayout(self.labelWidget)
        self.labelLayout.addRow(self.textLabel, self.textField)
        self.labelLayout.addRow(self.refactorLabel, self.refactorField)

        self.mainWidget.addTab(self.labelWidget, 'Label')
Example #30
0
    def configure(self, options):
        """
        Perform initial configuration tasks for Eddy to work properly.
        :type options: Namespace
        """
        #############################################
        # DRAW THE SPLASH SCREEN
        #################################

        splash = None
        if not options.nosplash:
            splash = Splash(mtime=4)
            splash.show()

        #############################################
        # CONFIGURE RECENT PROJECTS
        #################################

        settings = QtCore.QSettings(ORGANIZATION, APPNAME)
        examples = [
            expandPath('@examples/Animals'),
            expandPath('@examples/Diet'),
            expandPath('@examples/Family'),
            expandPath('@examples/LUBM'),
            expandPath('@examples/Pizza'),
        ]

        if not settings.contains('project/recent'):
            # From PyQt5 documentation: if the value of the setting is a container (corresponding
            # to either QVariantList, QVariantMap or QVariantHash) then the type is applied to the
            # contents of the container. So we can't use an empty list as default value because
            # PyQt5 needs to know the type of the contents added to the collection: we avoid
            # this problem by placing the list of example projects as recent project list.
            settings.setValue('project/recent', examples)
        else:
            # If we have some projects in our recent list, check whether they exists on the
            # filesystem. If they do not exists we remove them from our recent list.
            projects = []
            for path in map(expandPath, settings.value('project/recent')):
                if isdir(path) and path not in projects:
                    projects.append(path)
            settings.setValue('project/recent', projects or examples)
            settings.sync()

        #############################################
        # CONFIGURE FONTS
        #################################

        fontDB = QtGui.QFontDatabase()
        fontDB.addApplicationFont(':/fonts/Roboto-Black')
        fontDB.addApplicationFont(':/fonts/Roboto-BlackItalic')
        fontDB.addApplicationFont(':/fonts/Roboto-Bold')
        fontDB.addApplicationFont(':/fonts/Roboto-BoldItalic')
        fontDB.addApplicationFont(':/fonts/Roboto-Italic')
        fontDB.addApplicationFont(':/fonts/Roboto-Light')
        fontDB.addApplicationFont(':/fonts/Roboto-LightItalic')
        fontDB.addApplicationFont(':/fonts/Roboto-Medium')
        fontDB.addApplicationFont(':/fonts/Roboto-MediumItalic')
        fontDB.addApplicationFont(':/fonts/Roboto-Regular')
        fontDB.addApplicationFont(':/fonts/Roboto-Thin')
        fontDB.addApplicationFont(':/fonts/Roboto-ThinItalic')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-Bold')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-BoldItalic')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-Italic')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-Light')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-LightItalic')
        fontDB.addApplicationFont(':/fonts/RobotoCondensed-Regular')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Bold')
        fontDB.addApplicationFont(':/fonts/RobotoMono-BoldItalic')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Italic')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Light')
        fontDB.addApplicationFont(':/fonts/RobotoMono-LightItalic')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Medium')
        fontDB.addApplicationFont(':/fonts/RobotoMono-MediumItalic')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Regular')
        fontDB.addApplicationFont(':/fonts/RobotoMono-Thin')
        fontDB.addApplicationFont(':/fonts/RobotoMono-ThinItalic')

        self.setFont(Font('Roboto', 12))

        #############################################
        # CONFIGURE LAYOUT
        #################################

        buffer = ''
        resources = expandPath('@resources/styles/')
        for name in os.listdir(resources):
            path = os.path.join(resources, name)
            if fexists(path) and File.forPath(path) is File.Qss:
                buffer += fread(path)
        self.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
        self.setStyle(EddyProxyStyle('Fusion'))
        self.setStyleSheet(buffer)

        #############################################
        # LOOKUP PLUGINS
        #################################

        PluginManager.scan('@plugins/', '@home/plugins/')

        #############################################
        # CLOSE THE SPLASH SCREEN
        #################################

        if splash and not options.nosplash:
            splash.sleep()
            splash.close()

        #############################################
        # CONFIGURE THE WORKSPACE
        #################################

        workspace = expandPath(settings.value('workspace/home', WORKSPACE,
                                              str))
        if not isdir(workspace):
            window = WorkspaceDialog()
            if window.exec_() == WorkspaceDialog.Rejected:
                raise SystemExit
Example #31
0
    def __init__(self, session, num):
        """
        Initialize the popup window.
        :type num: int
        """
        super().__init__(session)

        self.num = num

        self.hideAnimation = QtCore.QPropertyAnimation(self, b'windowOpacity',
                                                       self)
        self.hideAnimation.setDuration(400)
        self.hideAnimation.setStartValue(1.0)
        self.hideAnimation.setEndValue(0.0)

        self.showAnimation = QtCore.QPropertyAnimation(self, b'windowOpacity',
                                                       self)
        self.showAnimation.setDuration(400)
        self.showAnimation.setStartValue(0.0)
        self.showAnimation.setEndValue(1.0)

        self.sleepTimer = PausableTimer()
        self.sleepTimer.setSingleShot(True)

        #############################################
        # SETUP UI
        #################################

        self.btnClose = QtWidgets.QPushButton(self)
        self.btnClose.setContentsMargins(0, 0, 0, 0)
        self.btnClose.setFont(Font('Roboto', 12))
        self.btnClose.setIcon(QtGui.QIcon(':/icons/18/ic_close_black'))
        self.btnClose.setIconSize(QtCore.QSize(18, 18))

        self.popupLabel = QtWidgets.QLabel(self)
        self.popupLabel.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
        self.popupLabel.setFixedSize(QtCore.QSize(216, 88))
        self.popupLabel.setFont(Font('Roboto', 12))
        self.popupLabel.setOpenExternalLinks(True)
        self.popupLabel.setTextFormat(QtCore.Qt.RichText)
        self.popupLabel.setTextInteractionFlags(
            QtCore.Qt.TextBrowserInteraction)
        self.popupLabel.setWordWrap(True)

        self.mainLayout = QtWidgets.QHBoxLayout(self)
        self.mainLayout.setContentsMargins(10, 10, 10, 10)
        self.mainLayout.addWidget(self.popupLabel, 1,
                                  QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
        self.mainLayout.addWidget(self.btnClose, 0,
                                  QtCore.Qt.AlignTop | QtCore.Qt.AlignRight)

        self.setFixedSize(QtCore.QSize(260, 100))
        self.setWindowOpacity(0)
        self.setWindowFlags(QtCore.Qt.SplashScreen
                            | QtCore.Qt.FramelessWindowHint
                            | QtCore.Qt.WindowStaysOnTopHint)

        connect(self.btnClose.clicked, self.onButtonCloseClicked)
        connect(self.hideAnimation.finished, self.onHideAnimationFinished)
        connect(self.showAnimation.finished, self.onShowAnimationFinished)
        connect(self.sleepTimer.timeout, self.onSleepTimerTimeout)
Example #32
0
class Splash(QtWidgets.QSplashScreen):
    """
    This class implements Eddy's splash screen.
    It can be used with the context manager, i.e:

    >>> import sys
    >>> from PyQt5 import QtWidgets
    >>> app = QtWidgets.QApplication(sys.argv)
    >>> with Splash(mtime=5):
    >>>     app.do_something_heavy()

    will draw a 5 seconds (at least) splash screen on the screen.
    The with statement body can be used to initialize the application and process heavy stuff.
    """
    def __init__(self, parent=None, mtime=2):
        """
        Initialize Eddy's splash screen.
        :type parent: QWidget
        :type mtime: float
        """
        super().__init__(parent, QtGui.QPixmap(), QtCore.Qt.WindowStaysOnTopHint)
        pixmap = QtGui.QIcon(':/images/im_eddy_splash').pixmap(380 * self.devicePixelRatio())
        pixmap.setDevicePixelRatio(self.devicePixelRatio())
        self.setPixmap(pixmap)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.mtime = time() + mtime
        self.font1 = Font('Arial', 40, Font.Light)
        self.font1.setCapitalization(Font.SmallCaps)
        self.font2 = Font('Arial', 18, Font.Light)
        self.font2.setCapitalization(Font.SmallCaps)
        self.font3 = Font('Arial', 12, Font.Light)
        self.__spaceX = 0
        self.__spaceY = 0

    #############################################
    #   INTERFACE
    #################################

    def setSpaceX(self, spaceX):
        """
        Set the text horizontal spacing.
        :type spaceX: int
        """
        self.__spaceX = spaceX

    def setSpaceY(self, spaceY):
        """
        Set the text vertical spacing.
        :type spaceY: int
        """
        self.__spaceY = spaceY

    def sleep(self):
        """
        Wait for the splash screen to be drawn for at least 'mtime' seconds.
        """
        now = time()
        if now < self.mtime:
            for _ in rangeF(start=0, stop=self.mtime - now, step=0.1):
                # noinspection PyArgumentList
                QtWidgets.QApplication.processEvents()
                sleep(0.1)

    #############################################
    #   CONTEXT MANAGER
    #################################

    def __enter__(self):
        """
        Draw the splash screen.
        """
        self.show()

    def __exit__(self, exc_type, exc_value, traceback):
        """
        Remove the splash screen from the screen.
        """
        self.sleep()
        self.close()

    #############################################
    #   EVENTS
    #################################

    def paintEvent(self, paintEvent):
        """
        Executed when the splashscreen needs to be painted.
        :type paintEvent: QPaintEvent
        """
        painter = QtGui.QPainter(self)
        # APPNAME
        painter.setFont(self.font1)
        painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(QtCore.QRect(31 + self.__spaceX, 160 + self.__spaceY, 380, 400), QtCore.Qt.AlignTop|QtCore.Qt.AlignLeft, APPNAME)
        # VERSION
        painter.setFont(self.font2)
        painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(QtCore.QRect(34 + self.__spaceX, 204 + self.__spaceY, 380, 400), QtCore.Qt.AlignTop|QtCore.Qt.AlignLeft, 'Version {0}'.format(VERSION))
        # COPYRIGHT
        painter.setFont(self.font3)
        painter.setPen(QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(QtCore.QRect(0 + self.__spaceX, 254 + self.__spaceY, 360, 40), QtCore.Qt.AlignTop|QtCore.Qt.AlignHCenter, COPYRIGHT)
        # CREDITS
        painter.setFont(self.font3)
        painter.setPen(QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(QtCore.QRect(0 + self.__spaceX, 278 + self.__spaceY, 360, 80), QtCore.Qt.AlignTop|QtCore.Qt.AlignHCenter, CREDITS)
        # LICENSE
        painter.setFont(self.font3)
        painter.setPen(QtGui.QPen(QtGui.QColor(122, 101, 104), 1.0, QtCore.Qt.SolidLine))
        painter.drawText(QtCore.QRect(0 + self.__spaceX, 332 + self.__spaceY, 360, 40), QtCore.Qt.AlignTop|QtCore.Qt.AlignHCenter, LICENSE)