Example #1
0
    def __init__(self, lexer=None):
        super(EditorWidget, self).__init__()

        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("00000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#cccccc"))

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

        if lexer is not None:
            lexer.setDefaultFont(font)
            self.setLexer(lexer)

        self.setReadOnly(True)
        self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1,
                           'Courier'.encode())
    def __init__(self, parent, coord=None):

        if not coord:
            coord = [0, 0, 0, 0, True]
        super(GeoLocalizationDialog, self).__init__(parent)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        self.setupUi(self)

        self.check_haveresources.setChecked(coord[4])
        self.setModal(True)
        self.btn_cancel.clicked.connect(lambda: self.done(QDialog.Rejected))
        self.btn_add.clicked.connect(lambda: self.done(QDialog.Accepted))
        self.spin_west_limit.setValue(float(str(coord[0]).replace(",", ".")))
        self.spin_east_limit.setValue(float(str(coord[1]).replace(",", ".")))
        self.spin_north_limit.setValue(float(str(coord[2]).replace(",", ".")))
        self.spin_south_south.setValue(float(str(coord[3]).replace(",", ".")))
        self.spin_west_limit.setDecimals(5)
        self.spin_east_limit.setDecimals(5)
        self.spin_north_limit.setDecimals(5)
        self.spin_south_south.setDecimals(5)
        self.superParent = None
        temp = self.parent()
        while self.superParent is None:
            if issubclass(type(temp),
                          geographicinformationPanel.Ui_geographicinfo):
                self.superParent = temp
            else:
                temp = temp.parent()
        for info in self.findChildren(qwidgets.QPushButton, QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)
Example #3
0
    def setCommonOptions(self):
        # Enable non-ASCII characters
        self.setUtf8(True)

        # Default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(20)
        self.setFont(font)
        self.setMarginsFont(font)

        self.initLexer()

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
                                QsciScintilla.WrapFlagNone, 4)

        self.setSelectionForegroundColor(QColor('#2e3436'))
        self.setSelectionBackgroundColor(QColor('#babdb6'))

        # Show line numbers
        self.setMarginWidth(1, '000')
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor('#2e3436'))
        self.setMarginsBackgroundColor(QColor('#babdb6'))

        # Highlight current line
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor('#d3d7cf'))

        # Folding
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))

        # Mark column 80 with vertical line
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor('#eeeeec'))

        # Indentation
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setTabWidth(4)

        # Autocomletion
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        self.setFonts(10)
Example #4
0
    def setCommonOptions(self):
        # Enable non-ASCII characters
        self.setUtf8(True)

        # Default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(20)
        self.setFont(font)
        self.setMarginsFont(font)

        self.initLexer()

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
                                QsciScintilla.WrapFlagNone, 4)

        self.setSelectionForegroundColor(QColor('#2e3436'))
        self.setSelectionBackgroundColor(QColor('#babdb6'))

        # Show line numbers
        self.setMarginWidth(1, '000')
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor('#2e3436'))
        self.setMarginsBackgroundColor(QColor('#babdb6'))

        # Highlight current line
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor('#d3d7cf'))

        # Folding
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))

        # Mark column 80 with vertical line
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor('#eeeeec'))

        # Indentation
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setTabWidth(4)

        # Autocomletion
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

        self.setFonts(10)
Example #5
0
    def __init__(self, logger):
        super().__init__()
        self.setWindowTitle('Network Activity')

        self.view = ActivityView(logger)
        font = QFont()
        font.setFamily('Courier')
        font.setPointSize(font.pointSize() - 1)
        self.view.setFont(font)
        self.logger = logger

        self.l = QVBoxLayout()
        self.l.setContentsMargins(0, 0, 0, 0)

        self.clear_action = QAction('Clear')
        self.pause_action = QAction('Pause')
        self.pause_action.setCheckable(True)

        self.toolbar = QToolBar()
        self.toolbar.setIconSize(iface.iconSize(True))
        self.toolbar.addAction(self.clear_action)
        self.toolbar.addAction(self.pause_action)

        self.clear_action.triggered.connect(self.view.clear)
        self.pause_action.toggled.connect(self.view.pause)
        self.show_success_action = QAction('Show successful requests')
        self.show_success_action.setCheckable(True)
        self.show_success_action.setChecked(True)
        self.show_success_action.toggled.connect(self.view.show_successful)
        self.show_timeouts_action = QAction('Show timeouts')
        self.show_timeouts_action.setCheckable(True)
        self.show_timeouts_action.setChecked(True)
        self.show_timeouts_action.toggled.connect(self.view.show_timeouts)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.show_success_action)
        self.toolbar.addAction(self.show_timeouts_action)

        self.filter_line_edit = QgsFilterLineEdit()
        self.filter_line_edit.setShowSearchIcon(True)
        self.filter_line_edit.setPlaceholderText('Filter requests')
        self.filter_line_edit.textChanged.connect(self.view.set_filter_string)
        self.l.addWidget(self.toolbar)
        self.l.addWidget(self.filter_line_edit)
        self.l.addWidget(self.view)
        self.w = QWidget()
        self.w.setLayout(self.l)
        self.setWidget(self.w)
Example #6
0
    def __init__(self, parent):
        super(InlineServiceOperation, self).__init__(parent)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        self.setupUi(self)

        self.parent = parent
        self.superParent = parent.superParent

        self.combo_items_dcp = customCombo.dic_to_CustomComboBox_dic(
            self.superParent.codelist["DCPCodeList"])

        tla.setupListView(self.dcp, CustomComboBox, self, comboList=list(self.combo_items_dcp.values()), NoParent=True)
        tla.setupListView(self.connectionPoint, QgsFilterLineEdit, self, NoParent=True)
        tla.setupMandatoryField(None, self.operationName, self.label_operationName, u"Elemento Obrigatório.", )
        tla.setupMandatoryField(None, self.dcp, self.label_dcp, u"Obrigatório conter pelo menos uma entrada")
        tla.setupMandatoryField(None, self.connectionPoint, self.label_connectionPoint, u"Obrigatório conter pelo menos uma entrada")

        for btn in self.findChildren(QPushButton, QRegExp('btn_*')):
            if '_add_' in btn.objectName():
                btn.setIcon(QIcon(':/resourcesFolder/icons/plus_icon.svg'))
                btn.setText('')
            elif '_del_' in btn.objectName():
                btn.setIcon(QIcon(':/resourcesFolder/icons/delete_icon.svg'))
                btn.setText('')
        for info in self.findChildren(QPushButton, QRegExp('info_*')):
                     info.setIcon(QIcon(':/resourcesFolder/icons/help_icon.svg'))
                     info.setText('')
                     info.pressed.connect(self.printHelp)
        self.operationName.editingFinished.connect(self.update_title)
        self.update_title()
        self.btn_del_operation.setToolTip(u"Agagar Operação.")
        self.eater = tla.EatWheel()
        for x in self.findChildren(QComboBox):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
        for x in self.findChildren(QDateTimeEdit):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
        self.btn_del_operation.clicked.connect(self.deleteOperation)
        self.dcp.model().dataChanged.connect(self.update_title)
        self.connectionPoint.model().dataChanged.connect(self.update_title)
        self.combo_dcp.setCurrentIndex(self.combo_dcp.findText("WebServices"))
    def __init__(self, parent, model_to_insert, snimar_keyword_types_list):
        super(SNIMARKeywordsDialog, self).__init__(parent)
        self.model_to_insert = model_to_insert
        self.combo_items_md_keywordtypecode = snimar_keyword_types_list
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        self.setupUi(self)
        self.setModal(True)

        self.thesaurus_model = SnimarThesurusModel().get_Model()

        self.to_add_keywords = {}  # id : QStandartItem

        self.list_view_thesaurus.setModel(self.thesaurus_model)
        # TODO fix this
        self.thesaurus_model.itemChanged.connect(self.register_item)

        self.list_view_thesaurus.setAlternatingRowColors(True)
        self.list_view_thesaurus.setSelectionBehavior(
            QAbstractItemView.SelectColumns)
        self.list_view_thesaurus.setSelectionMode(
            QAbstractItemView.SingleSelection)
        self.list_view_thesaurus.setTextElideMode(Qt.ElideNone)
        self.list_view_thesaurus.setVerticalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.list_view_thesaurus.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAsNeeded)
        self.list_view_thesaurus.setResizeGripsVisible(False)
        self.list_view_thesaurus.setSizePolicy(QSizePolicy.Fixed,
                                               QSizePolicy.Fixed)
        self.list_view_thesaurus.setColumnWidths(
            [300, 300, 300, 0, 0, 0, 0, 0])
        self.list_view_thesaurus.setAutoScroll(True)
        label = QLabel('')
        label.setMaximumSize(0, 0)
        self.list_view_thesaurus.setPreviewWidget(label)
        label.hide()
        self.bt_add_selected.clicked.connect(self.add_keywords)
        self.btn_exit.clicked.connect(lambda: self.done(0))
        self.setSizeGripEnabled(True)
        self.resize(self.maximumSize())
        self.adjustSize()
 def _on_render_complete(p):
     deviceHeight = p.device().height() # Get paint device height on which this painter is currently painting
     deviceWidth = p.device().width() # Get paint device width on which this painter is currently painting
     # Create new container for structured rich text
     text = QTextDocument()
     font = QFont()
     font.setFamily(mQFont)
     font.setPointSize(int(mQFontsize))
     text.setDefaultFont(font)
     style = "<style type=\"text/css\"> p { color: " + mLabelQColor + " ; background: " + mLabelQColor2 + " }</style>" 
     text.setHtml( style + "<p>" + mLabelQString + "</p>" )
     # Text Size
     size = text.size()
     # RenderMillimeters
     pixelsInchX = p.device().logicalDpiX()
     pixelsInchY = p.device().logicalDpiY()
     xOffset = pixelsInchX * INCHES_TO_MM * int(mMarginHorizontal)
     yOffset = pixelsInchY * INCHES_TO_MM * int(mMarginVertical)
     # Calculate positions
     if case == 0:
         # Top Left
         add_copyright(p, text, xOffset, yOffset)
     elif case == 1:
         # Bottom Left
         yOffset = deviceHeight - yOffset - size.height()
         add_copyright(p, text, xOffset, yOffset)
     elif case == 2:
         # Top Right
         xOffset = deviceWidth - xOffset - size.width()
         add_copyright(p, text, xOffset, yOffset)
     elif case == 3:
         # Bottom Right
         yOffset = deviceHeight - yOffset - size.height()
         xOffset = deviceWidth - xOffset - size.width()
         add_copyright(p, text, xOffset, yOffset)
     elif case == 4:
         # Top Center
         xOffset = deviceWidth / 2
         add_copyright(p, text, xOffset, yOffset)
     else:
         # Bottom Center
         yOffset = deviceHeight - yOffset - size.height()
         xOffset = deviceWidth / 2
         add_copyright(p, text, xOffset, yOffset)
Example #9
0
def _add(imageUrl, layer, feature, duplicates, duplicatesIndex):
    #QgsMessageLog.logMessage('_add: {0}, {1}, duplicatesIndex: {2}'.format(imageUrl, duplicates, duplicatesIndex), 'Lanzen', level=Qgis.Info)
    if not imageUrl:  #nothing to do if there is no image to display
        return
    imagePath = imageUrl[8:]
    if not os.path.exists(imagePath):
        return
    annotation = QgsTextAnnotation(iface.mapCanvas())
    annotation.setMapLayer(layer)
    annotation.setAssociatedFeature(feature)
    #generate the HTML content
    doc = QTextDocument()
    font = QFont()
    font.setFamily('Times New Roman')
    doc.setDefaultFont(font)
    doc.setHtml('<img src="{0}" />{1}'.format(imageUrl, feature.id()))
    annotation.setDocument(doc)
    annotation.markerSymbol().setSize(0)
    annotation.setHasFixedMapPosition(True)
    annotation.setMapPosition(feature.geometry().asPoint())
    # we only need dimensions here to resize the annotation
    with Image.open(imagePath) as image:
        width, height = image.size
        annotation.setFrameSize(QSizeF((width * 1.1 + 3),
                                       (height + 18)))  #leave room for text
        #now avoid overlapping for a single point
        if duplicates:
            radius = 12 * (duplicates + 1)
            theta = 2 * math.pi * duplicatesIndex / (duplicates + 1)
            x = radius * math.cos(theta)
            y = radius * math.sin(theta)
            if x < 0:
                x -= width
            if y < 0:
                y -= height
            annotation.setFrameOffsetFromReferencePoint(QPointF(x, y))
    QgsProject.instance().annotationManager().addAnnotation(annotation)
Example #10
0
    def __init__(self, parent, scope=None, xml_doc=None, md=None):
        super(MetadadoSNIMar, self).__init__(parent)
        if scope is None:
            self.scope = SCOPES.get_code_representation(md.hierarchy)
        else:
            self.scope = scope

        self.current_index = 0
        self.widgetStalker = {}
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)

        self.sidelist = QListWidget(self)
        self.sidelist.setMinimumWidth(150)
        self.sidelist.setMaximumWidth(150)
        self.sidelist.setWordWrap(True)
        self.sidelist.setTextElideMode(Qt.ElideNone)
        self.sidelist.setIconSize(QSize(25, 25))
        self.sidelist.clicked.connect(self.list_clicked)
        index = 0
        if self.scope == SCOPES.SERVICES:
            tabs = cons.TABLIST_SERVICES
        else:
            tabs = cons.TABLIST_CDG_SERIES

        for tab_element in tabs:
            bufWidget = QListWidgetItem(
                qgui.QIcon(':/resourcesFolder/icons/' + tab_element[1]),
                tab_element[0])
            self.widgetStalker[tab_element[2]] = {
                "widget": bufWidget,
                "missingFields": set(),
                "incompleteEntries": set()
            }
            bufWidget.setSizeHint(QSize(150, 50))
            if platform.system() != "Linux":
                font = QFont()
                font.setFamily(u"Segoe UI Symbol")
                bufWidget.setFont(font)

            self.sidelist.insertItem(index, bufWidget)
            index += 1
        self.widgetstack = QStackedWidget(self)

        # Setup metadata stuff
        self.xml_doc = xml_doc
        self.is_new_file = True if xml_doc is None else False
        self.md = md
        self.codelist = self.parent().codelists
        self.helps = self.parent().helps
        self.orgs = self.parent().orgs
        f = open(
            os.path.join(pluginDirectory('EditorMetadadosMarswInforbiomares'),
                         'resourcesFolder/stylesheet.qtcss'))
        self.sytlesheet = f.read()
        for btn in self.findChildren(QPushButton):
            btn.setStyleSheet(self.sytlesheet)
            btn.setFocusPolicy(Qt.NoFocus)
        self.reference_systems_list = self.parent().reference_systems
        tab_list = []

        # Setup snimarEditorController
        self.identification = snimarEditorController.IdentificationWidget(
            self, self.scope)
        tab_list.append(self.identification)
        if self.scope == SCOPES.SERVICES:
            self.operations = snimarEditorController.ServiceOperationsWidget(
                self)
            tab_list.append(self.operations)
        self.keywords = snimarEditorController.KeywordsWidget(self, self.scope)
        tab_list.append(self.keywords)
        self.geographicinfo = snimarEditorController.GeographicInfoWidget(
            self, self.scope)
        tab_list.append(self.geographicinfo)
        self.temporalinfo = snimarEditorController.TemporalInfoWidget(
            self, self.scope)
        tab_list.append(self.temporalinfo)
        self.quality = snimarEditorController.QualityWidget(self, self.scope)
        tab_list.append(self.quality)
        self.restrictions = snimarEditorController.RestrictionsWidget(
            self, self.scope)
        tab_list.append(self.restrictions)
        self.distribution = snimarEditorController.DistributionWidget(
            self, self.scope)
        tab_list.append(self.distribution)
        self.metadata = snimarEditorController.MetadataWidget(self)
        tab_list.append(self.metadata)

        self.setupUi()
        if not self.is_new_file:
            # Setup data
            self.identification.set_data(self.md)
            if self.scope == SCOPES.SERVICES:
                self.operations.set_data(md)
            self.temporalinfo.set_data(self.md)
            self.keywords.set_data(self.md)
            self.metadata.set_data(self.md)
            self.distribution.set_data(self.md)
            self.restrictions.set_data(self.md)
            self.quality.set_data(self.md)
            self.geographicinfo.set_data(self.md)
Example #11
0
    def __init__(self, parent=None):
        super(ShellOutputScintilla, self).__init__(parent)
        self.parent = parent
        self.shell = self.parent.shell

        self.settings = QgsSettings()

        # Creates layout for message bar
        self.layout = QGridLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.layout.addItem(spacerItem, 1, 0, 1, 1)
        # messageBar instance
        self.infoBar = QgsMessageBar()
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.infoBar.setSizePolicy(sizePolicy)
        self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

        # Enable non-ascii chars for editor
        self.setUtf8(True)

        sys.stdout = writeOut(self, sys.stdout)
        sys.stderr = writeOut(self, sys.stderr, "_traceback")

        self.insertInitText()
        self.refreshSettingsOutput()
        self.setReadOnly(True)

        # Set the default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        # Margin 0 is used for line numbers
        self.setMarginWidth(0, 0)
        self.setMarginWidth(1, 0)
        self.setMarginWidth(2, 0)
        #fm = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(1, "00000")
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor("#3E3EE3"))
        self.setMarginsBackgroundColor(QColor("#f9f9f9"))
        self.setCaretLineVisible(True)
        self.setCaretWidth(0)

        self.setMinimumHeight(120)

        self.setWrapMode(QsciScintilla.WrapCharacter)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
        self.runScut.setContext(Qt.WidgetShortcut)
        self.runScut.activated.connect(self.enteredSelected)
        # Reimplemented copy action to prevent paste prompt (>>>,...) in command view
        self.copyShortcut = QShortcut(QKeySequence.Copy, self)
        self.copyShortcut.activated.connect(self.copy)
        self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
        self.selectAllShortcut.activated.connect(self.selectAll)
    def __init__(self, parent, boundingbox):
        super(ExtentDialog, self).__init__(parent)
        self.setupUi(self)
        self.superParent = None
        temp = self.parent()
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        while self.superParent is None:
            if issubclass(type(temp),
                          geographicinformationPanel.Ui_geographicinfo):
                self.superParent = temp
            else:
                temp = temp.parent()
        for info in self.findChildren(qwidgets.QPushButton,
                                      qcore.QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)

        self.layers = []
        self.maxExt = None
        self.boundingbox = boundingbox
        self.outBB = False

        # Create MapCanvas
        self.canvas = gui.QgsMapCanvas(self)

        # Append to Dialog Layout
        self.toolBar = qwidgets.QToolBar()
        self.layout = qwidgets.QVBoxLayout(self.frame)
        self.layout.addWidget(self.toolBar)
        self.layout.addWidget(self.canvas)

        # Trigger on scaleChanged
        self.canvas.scaleChanged.connect(self.scaleChanged)
        # Trigger on renderStarting
        self.canvas.renderStarting.connect(self.renderStarting)

        # Create Map Tools
        actionFullExt = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/globe.svg'), "Mapa total",
            self)
        actionPan = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/pan.svg'), "Mover", self)
        actionZoomIn = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/zoom_in.svg'), "Aproximar",
            self)
        actionZoomOut = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/zoom_out.svg'), "Afastar",
            self)
        actionSelect = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/selection.svg'), 'Desenhar',
            self)
        actionFromLayer = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/layers.svg'),
            'Obter de camada', self)

        actionFullExt.setCheckable(False)
        actionPan.setCheckable(True)
        actionZoomIn.setCheckable(True)
        actionZoomOut.setCheckable(True)
        actionSelect.setCheckable(True)

        actionFullExt.triggered.connect(self.fullext)
        actionPan.triggered.connect(self.pan)
        actionZoomIn.triggered.connect(self.zoomIn)
        actionZoomOut.triggered.connect(self.zoomOut)
        actionSelect.triggered.connect(self.select)
        actionFromLayer.triggered.connect(self.chooseLayer)

        # Add to created ToolBar
        self.toolBar.addAction(actionFullExt)
        self.toolBar.addSeparator()
        self.toolBar.addAction(actionPan)
        self.toolBar.addAction(actionZoomIn)
        self.toolBar.addAction(actionZoomOut)
        self.toolBar.addAction(actionSelect)
        self.toolBar.addAction(actionFromLayer)

        self.toolFullExtent = gui.QgsMapToolPan(self.canvas)
        self.toolFullExtent.setAction(actionFullExt)
        self.toolPan = gui.QgsMapToolPan(self.canvas)
        self.toolPan.setAction(actionPan)
        self.toolZoomIn = gui.QgsMapToolZoom(self.canvas, False)  # false = in
        self.toolZoomIn.setAction(actionZoomIn)
        self.toolZoomOut = gui.QgsMapToolZoom(self.canvas, True)  # true = out
        self.toolZoomOut.setAction(actionZoomOut)
        self.toolSelect = SelectionTool(self.canvas, self)
        self.resourcebox.setChecked(True)
        self.pan()

        lugin_path = utils.pluginDirectory('EditorMetadadosMarswInforbiomares')

        # Load Vector
        layerpath = os.path.join(plugin_path, "resourcesFolder/World.shp")
        llayer = core.QgsVectorLayer(layerpath, "WorldLayer", "ogr")

        # Set Layer Symbology
        props = {
            'color_border': '0,0,0,125',
            'style': 'no',
            'style_border': 'solid'
        }
        #s = core.QgsFillSymbolV2.createSimple(props)
        s = core.QgsFillSymbol.createSimple(props)
        #llayer.setRendererV2(core.QgsSingleSymbolRendererV2(s))
        llayer.setRenderer(core.QgsSingleSymbolRenderer(s))

        # Set CRS - necessary to load Raster - it assumes this default CRS
        s = qcore.QSettings()
        oldValidation = str(
            s.value("/Projections/defaultBehaviour", "useGlobal"))
        s.setValue("/Projections/defaultBehaviour", "useGlobal")

        # Load Raster
        fileName = os.path.join(plugin_path, "resourcesFolder/GMRT.tif")
        fileInfo = qcore.QFileInfo(fileName)
        baseName = fileInfo.baseName()
        layer = core.QgsRasterLayer(fileName, baseName)
        layer.setCrs(
            core.QgsCoordinateReferenceSystem(
                4326, core.QgsCoordinateReferenceSystem.EpsgCrsId))
        s.setValue("/Projections/defaultBehaviour", oldValidation)

        # Set Raster ColorRamp
        # layer.setDrawingStyle("SingleBandPseudoColor") # deprecated remove in 2.1.0 please
        vmin = -5683.08
        vmax = 2763.86
        vrange = vmax - vmin
        vadd = vrange // 2
        vint = vmin + vadd
        colDic = {
            'brown': '#90330a',
            'lightblue': '#d5f5f9',
            'blue': '#2099d4'
        }
        valueList = [vmin, vint, vmax]

        lst = [core.QgsColorRampShader.ColorRampItem(valueList[0], qgui.QColor(colDic['blue'])), \
               core.QgsColorRampShader.ColorRampItem(valueList[1],
                                                     qgui.QColor(colDic['lightblue'])), \
               core.QgsColorRampShader.ColorRampItem(valueList[2], qgui.QColor(colDic['brown']))]
        myRasterShader = core.QgsRasterShader()
        myColorRamp = core.QgsColorRampShader()
        myColorRamp.setColorRampItemList(lst)
        myColorRamp.setColorRampType(core.QgsColorRampShader.Interpolated)
        myRasterShader.setRasterShaderFunction(myColorRamp)
        myPseudoRenderer = core.QgsSingleBandPseudoColorRenderer(
            layer.dataProvider(), layer.type(), myRasterShader)
        layer.setRenderer(myPseudoRenderer)

        ## Add vector to map
        #core.QgsMapLayerRegistry.instance().addMapLayer(llayer, False)
        core.QgsProject.instance().addMapLayer(llayer, False)
        ## Add raster to map
        #core.QgsMapLayerRegistry.instance().addMapLayer(layer, False)
        core.QgsProject.instance().addMapLayer(layer, False)

        ## Save Max Extent
        self.maxExt = core.QgsRectangle(-180., -90., 180., 90.)

        # ----------------------------------
        ## Set initial general extent to ZEE or, if one is selected, from the selected boundingbox
        if self.boundingbox.selectionModel().hasSelection() == False:
            ## Change button's title
            self.add_extent.setText(u"Adicionar")
            initialrect = core.QgsRectangle(-46.63064, 22.52146, 9.64473,
                                            47.31826)
        else:
            ## Get selected bounding box coords and resource flag
            index = self.boundingbox.selectionModel().selectedRows()[0].row()
            row = self.boundingbox.model().matrix[index]

            minx = float(row[0].replace(',', '.'))
            miny = float(row[3].replace(',', '.'))
            maxx = float(row[1].replace(',', '.'))
            maxy = float(row[2].replace(',', '.'))

            if minx == 0. and miny == 0. and maxx == 0. and maxy == 0.:
                initialrect = core.QgsRectangle(-46.63064, 22.52146, 9.64473,
                                                47.31826)
            else:
                ## Set fields with these values
                self.xMin.setValue(minx)
                self.xMax.setValue(maxx)
                self.yMin.setValue(miny)
                self.yMax.setValue(maxy)
                self.resourcebox.setChecked(bool(row[4]))

                ## Set the extent and add a bit of zoom out of the selected extent
                initialrect = core.QgsRectangle(minx - minx * 0.1,
                                                miny - miny * 0.1,
                                                maxx + maxx * 0.1,
                                                maxy + maxy * 0.1)

                ## Draw initial extent on the map
                self.toolSelect.drawRect(minx, miny, maxx, maxy)

                ## Change button's title
                self.add_extent.setText(u"Alterar")

        self.canvas.setExtent(initialrect)
        # ----------------------------------

        ## Append layers to MapCanvas
        self.layers.append(llayer)
        self.layers.append(layer)
        #self.layers.append(gui.QgsMapCanvasLayer(llayer))
        #self.layers.append(gui.QgsMapCanvasLayer(layer))
        #self.canvas.setLayerSet(self.layers)
        self.canvas.setLayers([llayer, layer])

        ## Set triggers to buttons
        self.add_extent.clicked.connect(self.add_new_extent)
        self.btn_close.clicked.connect(lambda: self.done(QDialog.Rejected))
        self.finished.connect(self.cleanup)

        ## Disabled coord fields
        self.xMin.setEnabled(False)
        self.xMax.setEnabled(False)
        self.yMin.setEnabled(False)
        self.yMax.setEnabled(False)
    def __init__(self, parent, combos, coord=None):

        if not coord:
            coord = ["", None, "", None, None]
        super(FreeKeyWordsDialog, self).__init__(parent)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        self.setupUi(self)
        self.date_date_2 = NullQDateEditWrapper(self.date_date_2)
        self.setModal(True)
        self.combo_dataType.setModel(
            CustomComboBoxModel(
                self, [None] +
                sorted(list(combos[1].values()), key=lambda x: x.term_pt)))
        self.combo_dataType.setCurrentIndex(0)
        self.date_date_2.clear()
        self.combo_type.setModel(
            CustomComboBoxModel(
                self, [None] +
                sorted(list(combos[0].values()), key=lambda x: x.term_pt)))
        self.btn_cancelar.clicked.connect(lambda: self.done(QDialog.Rejected))
        self.line_keyword.textChanged.connect(lambda: self.check_fields())
        self.line_thesaurus.textChanged.connect(lambda: self.check_fields())
        self.combo_type.currentIndexChanged.connect(
            lambda: self.check_fields())
        self.combo_dataType.currentIndexChanged.connect(
            lambda: self.check_fields())
        self.date_date_2.get_original().dateTimeChanged.connect(
            lambda: self.check_fields())
        self.btn_adicionar.clicked.connect(lambda: self.done(QDialog.Accepted))
        self.btn_adicionar.setDisabled(True)
        self.combo_type.setDisabled(True)
        self.line_thesaurus.setDisabled(True)
        self.date_date_2.setDisabled(True)
        self.btn_clear_date_date_2.setDisabled(True)
        self.combo_dataType.setDisabled(True)

        self.line_keyword.setText(coord[0])
        if coord[1] is not None:
            buf = combos[0].get(coord[1].term_pt, None)
            if buf is not None:
                self.combo_type.setCurrentIndex(
                    self.combo_type.findText(buf.term_pt))
        self.line_thesaurus.setText(coord[2])
        if coord[3] is None:
            self.date_date_2.clear()
        else:
            self.date_date_2.setDate(coord[3])
        if coord[4] is not None:
            buf = combos[1].get(coord[4].term, None)
            if buf is not None:
                self.combo_dataType.setCurrentIndex(
                    self.combo_dataType.findText(buf.term_pt))
        self.superParent = None
        temp = self.parent()
        while self.superParent is None:
            if issubclass(type(temp), keywordsPanel.Ui_keywords):
                self.superParent = temp
            else:
                temp = temp.parent()

        for info in self.findChildren(qwidgets.QPushButton, QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)

        self.btn_clear_date_date_2.setIcon(
            qgui.QIcon(':/resourcesFolder/icons/delete_field.svg'))
        self.btn_clear_date_date_2.pressed.connect(
            lambda: self.date_date_2.clear())
Example #14
0
    def __init__(self, parent=None):
        super(ShellOutputScintilla, self).__init__(parent)
        self.parent = parent
        self.shell = self.parent.shell

        self.settings = QSettings()

        # Creates layout for message bar
        self.layout = QGridLayout(self)
        self.layout.setContentsMargins(0, 0, 0, 0)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.layout.addItem(spacerItem, 1, 0, 1, 1)
        # messageBar instance
        self.infoBar = QgsMessageBar()
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.infoBar.setSizePolicy(sizePolicy)
        self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

        # Enable non-ascii chars for editor
        self.setUtf8(True)

        sys.stdout = writeOut(self, sys.stdout)
        sys.stderr = writeOut(self, sys.stderr, "_traceback")

        self.insertInitText()
        self.refreshSettingsOutput()
        self.setReadOnly(True)

        # Set the default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)
        # Margin 0 is used for line numbers
        self.setMarginWidth(0, 0)
        self.setMarginWidth(1, 0)
        self.setMarginWidth(2, 0)
        #fm = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(1, "00000")
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor("#3E3EE3"))
        self.setMarginsBackgroundColor(QColor("#f9f9f9"))
        self.setCaretLineVisible(True)
        self.setCaretWidth(0)

        self.setMinimumHeight(120)

        self.setWrapMode(QsciScintilla.WrapCharacter)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
        self.runScut.setContext(Qt.WidgetShortcut)
        self.runScut.activated.connect(self.enteredSelected)
        # Reimplemeted copy action to prevent paste prompt (>>>,...) in command view
        self.copyShortcut = QShortcut(QKeySequence.Copy, self)
        self.copyShortcut.activated.connect(self.copy)
        self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
        self.selectAllShortcut.activated.connect(self.selectAll)
    def __init__(self, parent, orgslist, in_distribution=False):
        super(InlineContactWidget, self).__init__(parent)
        self.parent = parent
        self.superParent = parent.superParent
        self.setupUi(self)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)

        self.orgs = {}
        org = orgslist
        for x in org:
            name = org[x] + " (" + x + ")"
            self.orgs[x] = customCombo.CodeListItem(name, name, name)

        self.combo_org.setModel(
            customCombo.CustomComboBoxModel(
                self, [customCombo.CodeListItem(OUTRA, OUTRA, OUTRA)] +
                sorted(list(self.orgs.values()), key=lambda x: x.term_pt)))
        self.combo_org.currentIndexChanged.connect(self.check_org)

        # initialized where because if was on the spot the c++ garbage collector will destroy it and cause a error
        self.dialog = None
        tla.setupListView(self.phone, QgsFilterLineEdit, self, NoParent=True)
        tla.setupListView(self.email, QgsFilterLineEdit, self, NoParent=True)
        tla.setupListView(self.fax, QgsFilterLineEdit, self, NoParent=True)

        tla.setupMandatoryField(None, self.organization,
                                self.label_organization,
                                tla.formatTooltip(u"Elemento Obrigatório."))
        tla.setupMandatoryField(
            None, self.email, self.label_email,
            tla.formatTooltip(
                u"Deve ser indicado pelo menos um endereço eletrónico (\'<em>email</em>\')."
            ))

        for btn in self.findChildren(qwidgets.QPushButton,
                                     qcore.QRegExp('btn_*')):
            if '_add_' in btn.objectName():
                btn.setIcon(
                    qgui.QIcon(':/resourcesFolder/icons/plus_icon.svg'))
                btn.setText('')
            elif '_del_' in btn.objectName():
                btn.setIcon(
                    qgui.QIcon(':/resourcesFolder/icons/delete_icon.svg'))
                btn.setText('')
        for info in self.findChildren(qwidgets.QPushButton,
                                      qcore.QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)
        f = open(
            os.path.join(pluginDirectory('EditorMetadadosMarswInforbiomares'),
                         'resourcesFolder/stylesheet.qtcss'))
        self.sytlesheet = f.read()
        for btn in self.findChildren(qwidgets.QPushButton):
            btn.setStyleSheet(self.sytlesheet)
            btn.setFocusPolicy(Qt.NoFocus)
        self.name.editingFinished.connect(self.updateTitle)
        self.organization.textChanged.connect(self.updateTitle)
        self.city.editingFinished.connect(self.updateTitle)
        self.country.editingFinished.connect(self.updateTitle)
        self.email.model().dataChanged.connect(self.updateTitle)
        self.btn_del_contact.clicked.connect(self.deleteContact)
        self.btn_contact_list.clicked.connect(self.importFromListContacts)
        self.btn_addto_list_contacts.clicked.connect(self.addtoListOfContacts)
        self.mGroupBox.collapsedStateChanged.connect(self.hideButtons)
        self.btn_del_contact.setToolTip(tla.formatTooltip(u"Agagar contacto."))
        self.updateTitle()

        self.btn_addto_list_contacts.setIcon(
            qgui.QIcon(':/resourcesFolder/icons/save_icon.svg'))
        self.btn_addto_list_contacts.setToolTip(
            tla.formatTooltip(u"Guardar contacto na Lista de Contactos."))
        self.btn_contact_list.setIcon(
            qgui.QIcon(':/resourcesFolder/icons/contactsList_icon.svg'))
        self.btn_contact_list.setToolTip(u'Importar da Lista de Contactos')
        self.btn_contact_list.setText('')
        self.btn_addto_list_contacts.setText('')
        self.eater = tla.EatWheel()
        for x in self.findChildren(qwidgets.QComboBox):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
        for x in self.findChildren(QDateTimeEdit):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
        for x in self.findChildren(QDateEdit):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)

        if in_distribution:
            temp = {}
            temp["distributor"] = {}
            temp["distributor"]["en"] = "distributor"
            temp["distributor"]["pt"] = "Distribuidor"
            temp["distributor"]["description"] = "Distribuidor"

            self.roles = customCombo.dic_to_CustomComboBox_dic(temp)
            self.combo_role.setModel(
                customCombo.CustomComboBoxModel(
                    self,
                    sorted(list(self.roles.values()),
                           key=lambda x: x.term_pt)))
            self.combo_role.setDisabled(True)
        else:
            self.roles = customCombo.dic_to_CustomComboBox_dic(
                self.superParent.codelist["CI_RoleCode"])
            self.combo_role.setModel(
                customCombo.CustomComboBoxModel(
                    self,
                    sorted(list(self.roles.values()),
                           key=lambda x: x.term_pt)))
            tla.setupMandatoryField(
                None, self.combo_role, self.label_role,
                u"Tem que ser especificada uma função para o contacto.")
            self.combo_role.currentIndexChanged.connect(
                self.check_mandatory_completude)
Example #16
0
    def setCommonOptions(self):
        # Enable non-ASCII characters
        self.setUtf8(True)

        # Default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
                                QsciScintilla.WrapFlagNone, 4)

        self.setSelectionForegroundColor(QColor('#2e3436'))
        self.setSelectionBackgroundColor(QColor('#babdb6'))

        # Show line numbers
        self.setMarginWidth(1, '000')
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor('#2e3436'))
        self.setMarginsBackgroundColor(QColor('#babdb6'))

        # Highlight current line
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor('#d3d7cf'))

        # Folding
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))

        # Mark column 80 with vertical line
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor('#eeeeec'))

        # Indentation
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setTabWidth(4)

        # Autocomletion
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        self.setAutoCompletionCaseSensitivity(False)

        # Load font from Python console settings
        settings = QgsSettings()
        fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
        fontSize = int(settings.value('pythonConsole/fontsize', 10))

        self.defaultFont = QFont(fontName)
        self.defaultFont.setFixedPitch(True)
        self.defaultFont.setPointSize(fontSize)
        self.defaultFont.setStyleHint(QFont.TypeWriter)
        self.defaultFont.setStretch(QFont.SemiCondensed)
        self.defaultFont.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        self.defaultFont.setBold(False)

        self.boldFont = QFont(self.defaultFont)
        self.boldFont.setBold(True)

        self.italicFont = QFont(self.defaultFont)
        self.italicFont.setItalic(True)

        self.setFont(self.defaultFont)
        self.setMarginsFont(self.defaultFont)

        self.initLexer()
Example #17
0
    def __init__(self, parent, edition_mode=True):
        super(ContactsDialog, self).__init__(parent)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        # VIEW SETUP#############################################################
        self.setupUi(self)
        self.superParent = self.parent()

        for btn in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('btn_*')):
            if '_add_' in btn.objectName():
                btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/plus_icon.svg'))
                btn.setText('')
            elif '_del_' in btn.objectName():
                btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/delete_icon.svg'))
                btn.setText('')
            elif '_clear_' in btn.objectName():
                btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/delete_field.svg'))

        lists = ['phone', 'fax', 'email']
        for item in lists:
            btn = self.findChild(qwidgets.QPushButton, 'btn_add_' + item)
            btn.clicked.connect(self.add_list_row)
            btn = self.findChild(qwidgets.QPushButton, 'btn_del_' + item)
            btn.clicked.connect(self.del_list_row)

        for info in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)

        # Contact list connections and variables
        self.contact_array = None
        self.open_contact_array()
        self.current_contact = None
        self.contact_list.clearSelection()
        self.contactPanel.setDisabled(True)

        # SETUP THE DIALOG MODE
        if edition_mode:  # EDITION MODE

            self.orgs = {}
            org = self.superParent.orgs
            for x in org:
                name = org[x] + " (" + x + ")"
                self.orgs[x] = cus.CodeListItem(name, name, name)

            self.combo_org.setModel(
                cus.CustomComboBoxModel(self,
                                        [cus.CodeListItem(OUTRA, OUTRA, OUTRA)] + sorted(list(self.orgs.values()),
                                                                                         key=lambda x: x.term_pt)))
            self.combo_org.currentIndexChanged.connect(self.check_org)
            self.btn_contact_add.setVisible(True)
            self.btn_contact_del.setVisible(True)
            self.cancelChanges()
            self.btn_add_contact_metadata.setVisible(False)

            # CONNECTING FIELDS THAT CAN BE CHANGED
            self.name.textChanged.connect(self.changesMade)
            self.organization.textChanged.connect(self.changesMade)
            self.city.textChanged.connect(self.changesMade)
            self.postalcode.textChanged.connect(self.changesMade)
            self.country.textChanged.connect(self.changesMade)
            self.delivery_point.textChanged.connect(self.changesMade)
            self.phone.model().rowsInserted.connect(self.changesMade)
            self.fax.model().rowsInserted.connect(self.changesMade)
            self.email.model().rowsInserted.connect(self.changesMade)
            self.online.textChanged.connect(self.changesMade)
            self.phone.model().rowsRemoved.connect(self.changesMade)
            self.fax.model().rowsRemoved.connect(self.changesMade)
            self.email.model().rowsRemoved.connect(self.changesMade)
            self.online.textChanged.connect(self.changesMade)

            # SETUP MANDATORY FIELDS VISUAL VALIDATION
            self.organization.editingFinished.connect(self.setup_mandatory_label)
            self.name.editingFinished.connect(self.setup_mandatory_label)
            self.setup_mandatory_label()

            # ACTIONS SETUP
            self.btn_contact_save.clicked.connect(self.save_contact)  # save contact
            self.btn_cancelClose.clicked.connect(self.cancelChanges)  # cancel changes and revert contact
            self.btn_contact_add.clicked.connect(
                self.new_contact)  # add new contact if changes in current contact exists ask...
            self.btn_contact_del.clicked.connect(self.delete_contact)  # delete contact with confirmation

            self.contact_list.itemClicked.connect(
                self.selection_changed)  # change current selection if changes exists ask...
        else:  # EXPORT MODE
            self.contactPanel.hide()
            self.btn_add_contact_metadata.setVisible(True)
            self.btn_contact_add.setVisible(False)
            self.btn_contact_del.setVisible(False)
            self.adjustSize()

        # ACTIONS SETUP
        self.contact_list.itemClicked.connect(self.selection_changed_export_Mode)  # change current selection
        # ACTIONS FUNCTIONS
        self.eater = tla.EatWheel()
        for x in self.findChildren(qwidgets.QComboBox):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
        for x in self.findChildren(QDateTimeEdit):
            x.installEventFilter(self.eater)
            x.setFocusPolicy(Qt.StrongFocus)
Example #18
0
    def setCommonOptions(self):
        # Enable non-ASCII characters
        self.setUtf8(True)

        # Default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        self.setWrapMode(QsciScintilla.WrapWord)
        self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
                                QsciScintilla.WrapFlagNone, 4)

        self.setSelectionForegroundColor(QColor('#2e3436'))
        self.setSelectionBackgroundColor(QColor('#babdb6'))

        # Show line numbers
        self.setMarginWidth(1, '000')
        self.setMarginLineNumbers(1, True)
        self.setMarginsForegroundColor(QColor('#2e3436'))
        self.setMarginsBackgroundColor(QColor('#babdb6'))

        # Highlight current line
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor('#d3d7cf'))

        # Folding
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))

        # Mark column 80 with vertical line
        self.setEdgeMode(QsciScintilla.EdgeLine)
        self.setEdgeColumn(80)
        self.setEdgeColor(QColor('#eeeeec'))

        # Indentation
        self.setAutoIndent(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setBackspaceUnindents(True)
        self.setTabWidth(4)

        # Autocomletion
        self.setAutoCompletionThreshold(2)
        self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
        self.setAutoCompletionCaseSensitivity(False)

        # Load font from Python console settings
        settings = QgsSettings()
        fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
        fontSize = int(settings.value('pythonConsole/fontsize', 10))

        self.defaultFont = QFont(fontName)
        self.defaultFont.setFixedPitch(True)
        self.defaultFont.setPointSize(fontSize)
        self.defaultFont.setStyleHint(QFont.TypeWriter)
        self.defaultFont.setStretch(QFont.SemiCondensed)
        self.defaultFont.setLetterSpacing(QFont.PercentageSpacing, 87.0)
        self.defaultFont.setBold(False)

        self.boldFont = QFont(self.defaultFont)
        self.boldFont.setBold(True)

        self.italicFont = QFont(self.defaultFont)
        self.italicFont.setItalic(True)

        self.setFont(self.defaultFont)
        self.setMarginsFont(self.defaultFont)

        self.initLexer()
Example #19
0
    def __init__(self, parent, combos, coord=None):

        if not coord:
            coord = ["", None, None, ""]
        super(LegalRestrictionsDialog, self).__init__(parent)
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        self.setupUi(self)
        self.setModal(True)
        self.restrict_dic = combos[0]
        self.combo_accessrestrictions.setModel(
            CustomComboBoxModel(
                self, [None] +
                sorted(list(combos[0].values()), key=lambda x: x.term_pt)))
        self.combo_userestrictions.setModel(
            CustomComboBoxModel(
                self, [None] +
                sorted(list(combos[0].values()), key=lambda x: x.term_pt)))
        self.btn_cancel.clicked.connect(lambda: self.done(QDialog.Rejected))
        self.btn_add.clicked.connect(lambda: self.done(QDialog.Accepted))
        self.line_uselimitations.textChanged.connect(self.checkInput)
        self.combo_accessrestrictions.currentIndexChanged.connect(
            self.checkInput)
        self.combo_userestrictions.currentIndexChanged.connect(self.checkInput)
        self.line_otherrestrictions.textEdited.connect(self.checkInput)

        self.line_uselimitations.setText(coord[0])
        if coord[1] is not None:
            buf = combos[0].get(coord[1].term, None)
            if buf is not None:
                self.combo_accessrestrictions.setCurrentIndex(
                    self.combo_accessrestrictions.findText(buf.term_pt))

        if coord[2] is not None:
            buf = combos[0].get(coord[2].term, None)
            if buf is not None:
                self.combo_userestrictions.setCurrentIndex(
                    self.combo_userestrictions.findText(buf.term_pt))

        self.line_otherrestrictions.setText(coord[3])
        self.checkInput()

        tla.setupMandatoryField(None, self.line_uselimitations,
                                self.label_line_uselimitations,
                                u"Elemento Obrigatório.")
        tla.setupMandatoryField(None, self.combo_accessrestrictions,
                                self.label_combo_accessrestrictions,
                                u"Elemento Obrigatório.")
        tla.setupMandatoryField(None, self.combo_userestrictions,
                                self.label_combo_userestrictions,
                                u"Elemento Obrigatório.")
        self.superParent = None
        temp = self.parent()
        while self.superParent is None:
            if issubclass(type(temp), restrictionsPanel.Ui_restrictions):
                self.superParent = temp
            else:
                temp = temp.parent()
        for info in self.findChildren(qgui.QPushButton,
                                      qcore.QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)