Exemple #1
0
 def formata(self, destacat: bool, discret: bool):
     if self.flat: return
     if self.isEnabled():
         if destacat:
             colors = (QvConstants.COLORBLANCHTML,
                       QvConstants.COLORDESTACATHTML)
         else:
             if discret:
                 colors = (QvConstants.COLORBLANCHTML,
                           QvConstants.COLORCLARHTML)
             else:
                 colors = (QvConstants.COLORBLANCHTML,
                           QvConstants.COLORFOSCHTML)
     else:
         colors = (QvConstants.COLORCLARHTML, QvConstants.COLORGRISHTML)
     self.setStyleSheet(
         # "margin-right: 20px;"
         # "margin-top: 10px;"
         # "margin-bottom: 10px;"
         "border: none;"
         "padding: 5px 20px;"
         "color: %s;"
         "background-color: %s" % colors)
     self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     QvConstants.afegeixOmbraWidget(self)
Exemple #2
0
 def _errorProper(self, x, y):
     self.setCursor(QvConstants.cursorOcupat())
     if self._teErrors:
         if x + 1 in self._errors:
             self._setError(self._errors.index(x + 1), True)
         else:
             return
             distancies = enumerate(
                 map(lambda xx: abs(xx - x), self._errors))
             index = sorted(distancies, key=lambda x: x[1])[0][0]
             self._setError(index, True)
     self.setCursor(QvConstants.cursorFletxa())
Exemple #3
0
def startMovie():
    """Mostra un spinner de càrrega flotant

    Returns:
        QvVideo -- Spinner que s'està mostrant (important guardar-lo en algun lloc)
    """
    player = QvVideo(os.path.join(imatgesDir, "Spinner_2.gif"), 160, 160)
    QvConstants.afegeixOmbraWidget(player)
    player.setModal(True)
    player.activateWindow()
    player.mediaPlayer.play()
    player.show()
    return player
Exemple #4
0
    def formata(self, titol):
        '''Dóna format al diàleg de notícies'''
        pal = self.caixaText.palette()
        pal.setBrush(QPalette.Base, Qt.transparent)
        self.caixaText.page().setPalette(pal)
        self.caixaText.setAttribute(Qt.WA_OpaquePaintEvent, False)
        self.caixaText.page().currentFrame().setScrollBarPolicy(
            Qt.Vertical, Qt.ScrollBarAlwaysOn)
        self.caixaText.settings().setUserStyleSheetUrl(
            QUrl('file:///style.qss'))

        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.lblLogo.setFixedSize(40, 40)
        self.lblCapcalera.setStyleSheet(
            'background-color: %s; color: %s; border: 0px' %
            (QvConstants.COLORFOSCHTML, QvConstants.COLORBLANCHTML))
        self.lblCapcalera.setFont(QvConstants.FONTCAPCALERES)
        self.lblCapcalera.setFixedHeight(40)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layoutCapcalera.setContentsMargins(0, 0, 0, 0)
        self.layoutCapcalera.setSpacing(0)
        self.layoutBoto.setContentsMargins(10, 0, 10, 10)
        self.layoutBoto.setSpacing(10)
        self.layoutCaixaText.setContentsMargins(10, 10, 2, 10)
        self.widgetSup.setGraphicsEffect(
            QvConstants.ombraHeader(self.widgetSup))

        self.setWindowTitle(titol)
        self.resize(640, 480)
        self.oldPos = self.pos()
Exemple #5
0
    def formata(self):
        self.layoutTiD.setContentsMargins(20, 0, 20, 0)
        self.layoutTiD.setSpacing(20)
        self.lblTitle.setText("Títol:")
        self.leTitle.setFixedHeight(26)
        self.caixaText.viewport().setAutoFillBackground(False)
        self.caixaText.setEnabled(
            True)  #Millor que es pugui seleccionar el text? O que no es pugui?
        #self.caixaText.setFrameStyle(QFrame.NoFrame)
        self.caixaText.setViewportMargins(3, 3, 3, 3)
        self.leTitle.setViewportMargins(3, 0, 3, 0)
        self.offset1.setFixedWidth(17)
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.lblLogo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        self.lblCapcalera.setFont(QvConstants.FONTCAPCALERES)
        self.lblCapcalera.setFixedHeight(40)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layoutCapcalera.setContentsMargins(0, 0, 0, 0)
        self.layoutCapcalera.setSpacing(0)
        self.layoutBoto.setContentsMargins(0, 0, 0, 0)
        self.layoutBoto.setSpacing(0)

        self.widgetSup.setGraphicsEffect(QvConstants.ombraHeader(self))
        self.widgetSup.setStyleSheet(
            'color: %s; background-color: solid %s; border: 0px;' %
            (QvConstants.COLORBLANCHTML, QvConstants.COLORFOSCHTML))

        self.setWindowTitle("qVista - Problemes i Suggeriments")
        self.setFixedSize(520, 360)
        self.oldPos = self.pos()
Exemple #6
0
    def __init__(self,parent=None):
        '''Construeix el catàleg de capes
        Li passem qVista com a paràmetre, per poder carregar les capes des d'aquí
        '''
        super().__init__()
        # self.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Minimum)
        self.setCursor(QvConstants.cursorClick())
        self.setMinimumHeight(500)
        self.layout=QVBoxLayout()
        self.setFont(QvConstants.FONTTEXT)
        self.setStyleSheet('color: %s; background: %s; border: none'%(QvConstants.COLORFOSCHTML,QvConstants.COLORBLANCHTML))
        self.setLayout(self.layout)

        #Afegir el cercador
        self.leCercador=QLineEdit(self)
        self.leCercador.setStyleSheet('background: white')
        self.leCercador.setPlaceholderText('Cercar...')
        self.leCercador.textChanged.connect(self.canviaFiltre)
        self.accioEsborra=self.leCercador.addAction(QIcon(os.path.join(imatgesDir,'cc_buidar_cercar.png')),QLineEdit.TrailingPosition)
        self.accioEsborra.triggered.connect(lambda: self.leCercador.setText(''))
        self.accioEsborra.setVisible(False)

        self.treeCataleg=QTreeView()
        self.treeCataleg.setFixedWidth(300)
        self.treeCataleg.setDragEnabled(True) #Per poder arrosegar
        # self.treeCataleg.doubleClicked.connect(self.afegirQlr)
        self.treeCataleg.activated.connect(self.afegirQlr)
        self.treeCataleg.clicked.connect(self.actualitzaMetadades)
        self.treeCataleg.setItemDelegate(DelegatNegreta(self))
        self.treeCataleg.setIndentation(20)
        self.treeCataleg.setSortingEnabled(False)
        self.treeCataleg.setWindowTitle("Catàleg d'Informació Territorial")
        self.treeCataleg.adjustSize()
        self.treeCataleg.setHeaderHidden(True)
        self.treeCataleg.setStyleSheet('background: transparent')
        # self.treeCataleg.setAutoFillBackground(False)

        self.model=ModelArxius()
        self.model.setIconProvider(ProveidorIcones())
        self.model.setNameFilterDisables(False)
        # self.model.setNameFilters(['*.qlr'])
        self.model.setReadOnly(True)
        # self.model.selectionChanged.connect(self.actualitzaMetadades)
        rootPath=self.model.setRootPath(carpetaCataleg)
        # self.treeCataleg.setModel(self.model)
        self.treeCataleg.setModel(self.model)
        self.treeCataleg.selectionModel().selectionChanged.connect(self.actualitzaMetadades)
        self.treeCataleg.setRootIndex(rootPath)
        self.canviaFiltre()
        for i in range (1,4):
            self.treeCataleg.header().hideSection(i)

        self.preview=Preview(self)

        self.layout.addWidget(self.leCercador)
        self.layout.addWidget(self.treeCataleg)
        self.layout.addWidget(self.preview)
Exemple #7
0
 def leaveEvent(self, event):
     super().leaveEvent(event)
     self.setCursor(QvConstants.cursorFletxa())
Exemple #8
0
 def enterEvent(self, event):
     super().enterEvent(event)
     self.setCursor(QvConstants.cursorClick())
Exemple #9
0
    def __init__(self,
                 campCoordX,
                 campCoordY,
                 projeccio,
                 carregador,
                 parent=None):
        super().__init__(carregador, parent)
        self._setTitol('Afegir com a capa de punts')
        self._campCoordX = campCoordX
        self._campCoordY = campCoordY
        self._projeccio = projeccio
        # Nom de la capa
        layLbls = QVBoxLayout()
        layTries = QVBoxLayout()
        layGrup = QHBoxLayout()
        layGrup.addLayout(layLbls)
        layGrup.addLayout(layTries)
        self._lay.addLayout(layGrup)
        # layNom = QHBoxLayout()
        layLbls.addWidget(QLabel('Nom de la capa: '))
        self._leNomCapa = QLineEdit()
        self._leNomCapa.setText(Path(self._carregador._csv).stem)
        layTries.addWidget(self._leNomCapa)
        # self._lay.addLayout(layNom)
        # Color de la representació
        self._color = 'red'
        # layColor = QHBoxLayout()
        lblColor = QLabel('Color: ')
        lblColor.setAlignment(Qt.AlignRight)
        layLbls.addWidget(lblColor)

        def setColorBoto():
            self._bColor.setStyleSheet('color: %s; background-color: %s' %
                                       (self._color, self._color))

        def obrirDialegColor():
            color = QColorDialog.getColor(
                QColor(self._color), self,
                'Tria del color de la representació')
            self._color = color.name()
            setColorBoto()

        self._bColor = QvPushButton(flat=True)
        self._bColor.setIcon(QIcon('Imatges/da_color.png'))
        self._bColor.setStyleSheet('background: solid %s; border: none' %
                                   self._color)
        self._bColor.setIconSize(QSize(25, 25))
        self._bColor.setFixedSize(25, 25)
        QvConstants.afegeixOmbraWidget(self._bColor)
        self._bColor.clicked.connect(obrirDialegColor)
        layTries.addWidget(self._bColor)
        # layColor.addStretch()
        setColorBoto()
        # self._lay.addLayout(layColor)
        self._lay.addStretch()

        # Forma

        def setForma(imatge):
            self._forma = imatge

        gbForma = QGroupBox()
        self._lay.addWidget(gbForma)
        layForma = QGridLayout()
        gbForma.setLayout(layForma)
        rbCreu = QRadioButton()
        rbCreu.setIcon(QIcon(os.path.join(imatgesDir, 'crossW.png')))
        rbCreu.toggled.connect(lambda x: setForma('cross_fill')
                               if x else print(':D'))
        layForma.addWidget(rbCreu, 1, 2)

        rbQuadrat = QRadioButton()
        rbQuadrat.setIcon(QIcon(os.path.join(imatgesDir, 'squareW.png')))
        rbQuadrat.toggled.connect(lambda x: setForma('square')
                                  if x else print(':D'))
        layForma.addWidget(rbQuadrat, 0, 1)

        rbRombe = QRadioButton()
        rbRombe.setIcon(QIcon(os.path.join(imatgesDir, 'rhombusW.png')))
        rbRombe.toggled.connect(lambda x: setForma('diamond')
                                if x else print(':D'))
        layForma.addWidget(rbRombe, 0, 2)

        rbPentagon = QRadioButton()
        rbPentagon.setIcon(QIcon(os.path.join(imatgesDir, 'pentagonW.png')))
        rbPentagon.toggled.connect(lambda x: setForma('pentagon')
                                   if x else print(':D'))
        layForma.addWidget(rbPentagon, 0, 3)

        rbEstrella = QRadioButton()
        rbEstrella.setIcon(QIcon(os.path.join(imatgesDir, 'starW.png')))
        rbEstrella.toggled.connect(lambda x: setForma('star')
                                   if x else print(':D'))
        layForma.addWidget(rbEstrella, 1, 0)

        rbTriangle = QRadioButton()
        rbTriangle.setIcon(QIcon(os.path.join(imatgesDir, 'triangleW.png')))
        rbTriangle.toggled.connect(lambda x: setForma('triangle')
                                   if x else print(':D'))
        layForma.addWidget(rbTriangle, 1, 1)

        rbCercle = QRadioButton()
        rbCercle.setIcon(QIcon(os.path.join(imatgesDir, 'circleW.png')))
        rbCercle.toggled.connect(lambda x: setForma('circle')
                                 if x else print(':D'))
        rbCercle.click()
        layForma.addWidget(rbCercle, 0, 0)

        rbHexagon = QRadioButton()
        rbHexagon.setIcon(QIcon(os.path.join(imatgesDir, 'hexagonW.png')))
        rbHexagon.toggled.connect(lambda x: setForma('hexagon')
                                  if x else print(':D'))
        layForma.addWidget(rbHexagon, 1, 3)
        # Afegim els botons
        layBotons = QHBoxLayout()
        layBotons.addStretch()
        self._bAfegir = QvPushButton('Afegir com a capa de punts',
                                     destacat=True)
        self._bAfegir.setToolTip('Afegeix al mapa com a capa de punts')
        self._bAfegir.clicked.connect(self.afegir)
        self._bEnrere = QvPushButton('Enrere')
        self._bEnrere.setToolTip('Retrocedeix a la pantalla anterior')
        self._bEnrere.clicked.connect(self._enrere)
        self._leNomCapa.textChanged.connect(
            lambda x: self._bAfegir.setEnabled(x != ''))
        layBotons.addWidget(self._bEnrere)
        layBotons.addWidget(self._bAfegir)
        self._lay.addLayout(layBotons)
Exemple #10
0
 def showEvent(self, e):
     self.setCursor(QvConstants.cursorOcupat())
     super().showEvent(e)
     if self._teErrors:
         self._mostraErrorActual()
     self.setCursor(QvConstants.cursorFletxa())
Exemple #11
0
 def enterEvent(self, event):
     super().enterEvent(event)
     if not self.isEnabled(): return
     self.setCursor(QvConstants.cursorClick())
Exemple #12
0
    def __init__(self, funcCarregar, parent=None):
        '''Construeix un QvNouMapa. Rep obligatòriament el widget pare, que ha de ser el qVista
        Arguments:
            funcCarregar{Callable[str,str],None}
        Keyword Arguments:
            parent{QWidget} -- El parent'''
        super().__init__(parent)
        self.funcCarregar = funcCarregar
        self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)
        self.layout = QVBoxLayout(self)
        self.layout.setSpacing(0)
        self.layout.setContentsMargins(0, 0, 0, 0)
        #Fila superior
        self.layoutCapcalera = QHBoxLayout()
        self.widgetSup = QWidget(objectName='layout')
        self.widgetSup.setLayout(self.layoutCapcalera)
        self.lblLogo = QLabel()
        self.lblLogo.setPixmap(
            QPixmap(os.path.join(imatgesDir, 'QVistaLogo_40_32.png')))
        self.lblLogo.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.lblCapcalera = QLabel(objectName='Fosca')
        self.lblCapcalera.setText('  Crear un nou mapa')
        self.lblCapcalera.setStyleSheet(
            'background-color: %s; color: %s; border: 0px' %
            (QvConstants.COLORFOSCHTML, QvConstants.COLORBLANCHTML))
        self.lblCapcalera.setFont(QvConstants.FONTCAPCALERES)
        self.lblCapcalera.setFixedHeight(40)
        self.layoutCapcalera.setContentsMargins(0, 0, 0, 0)
        self.layoutCapcalera.setSpacing(0)
        self.widgetSup.setGraphicsEffect(
            QvConstants.ombraHeader(self.widgetSup))
        self.layoutCapcalera.addWidget(self.lblLogo)
        self.layoutCapcalera.addWidget(self.lblCapcalera)
        self.layoutCapcalera.addStretch()
        self.widgetSup.setStyleSheet('background: %s' %
                                     QvConstants.COLORFOSCHTML)
        self.layout.addWidget(self.widgetSup)

        wImage = 210
        hImage = 160

        self.layoutContingut = QVBoxLayout()
        self.layoutContingut.setContentsMargins(20, 20, 20, 20)
        self.layoutContingut.setSpacing(20)

        self.layoutTitol = QHBoxLayout()
        self.lblTitle = QLabel()
        self.offset1 = QLabel()
        self.leTitol = QLineEdit()
        self.lblTitle.setText("Títol del projecte:")
        self.layoutTitol.addWidget(self.lblTitle)
        self.layoutTitol.addWidget(self.offset1)
        self.layoutTitol.addWidget(self.leTitol)
        self.leTitol.textChanged.connect(
            lambda: self.setTitol(self.leTitol.text()))
        #self.leTitol.setPlaceholderText("Títol del projecte")
        self.layoutContingut.addLayout(self.layoutTitol)

        self.lblExplicacio = QLabel()
        self.lblExplicacio.setText(
            "Trieu amb quina base cartogràfica voleu iniciar el mapa. Més endavant podreu afergir-hi altres capes"
        )
        self.layoutContingut.addWidget(self.lblExplicacio)

        self.layoutTresBotons1 = QHBoxLayout(self)
        self.mapaBuit = QvToolButton(self)
        self.mapaBuit.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapaBuit.setText('Parcel·lari')
        self.mapaBuit.setIcon(
            QIcon(os.path.join(imatgesDir, 'nou_parcel·lari.png')))
        self.mapaBuit.setIconSize(QSize(wImage, hImage))
        self.mapaBuit.clicked.connect(lambda: self.botoClick(self.mapaBuit))

        self.mapa1 = QvToolButton(self)
        self.mapa1.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapa1.setText('Topogràfic')
        self.mapa1.setIcon(
            QIcon(os.path.join(imatgesDir, 'nou_topogràfic.png')))
        self.mapa1.setIconSize(QSize(wImage, hImage))
        self.mapa1.clicked.connect(lambda: self.botoClick(self.mapa1))

        self.mapa2 = QvToolButton(self)
        self.mapa2.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapa2.setText('Plànol guia')
        self.mapa2.setIcon(QIcon(os.path.join(imatgesDir, 'nou_guia.png')))
        self.mapa2.setIconSize(QSize(wImage, hImage))
        self.mapa2.clicked.connect(lambda: self.botoClick(self.mapa2))

        self.layoutTresBotons2 = QHBoxLayout(self)
        self.mapa3 = QvToolButton(self)
        self.mapa3.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapa3.setText('Ortofotos 1:1000')
        self.mapa3.setIcon(QIcon(os.path.join(imatgesDir, 'nou_ortofoto.png')))
        self.mapa3.setIconSize(QSize(wImage, hImage))
        self.mapa3.clicked.connect(lambda: self.botoClick(self.mapa3))

        self.mapa4 = QvToolButton(self)
        self.mapa4.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapa4.setText('Unitats administratives')
        self.mapa4.setIcon(
            QIcon(os.path.join(imatgesDir,
                               'nou_divisions_administratives.png')))
        self.mapa4.setIconSize(QSize(wImage, hImage))
        self.mapa4.clicked.connect(lambda: self.botoClick(self.mapa4))

        self.mapa5 = QvToolButton(self)
        self.mapa5.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.mapa5.setText('Mapa buit')
        self.mapa5.setIcon(QIcon(os.path.join(imatgesDir, 'nou_buit.png')))
        self.mapa5.setIconSize(QSize(wImage, hImage))
        self.mapa5.clicked.connect(lambda: self.botoClick(self.mapa5))

        self.layoutTresBotons1.addWidget(self.mapaBuit)
        self.layoutTresBotons1.addWidget(self.mapa1)
        self.layoutTresBotons1.addWidget(self.mapa2)
        self.layoutTresBotons2.addWidget(self.mapa3)
        self.layoutTresBotons2.addWidget(self.mapa4)
        self.layoutTresBotons2.addWidget(self.mapa5)

        self.layoutContingut.addLayout(self.layoutTresBotons1)
        self.layoutContingut.addLayout(self.layoutTresBotons2)

        self.layoutBotons = QHBoxLayout()
        self.botoAcceptar = QvPushButton('Acceptar',
                                         destacat=True,
                                         parent=self)
        self.botoAcceptar.setEnabled(False)
        self.botoAcceptar.clicked.connect(self.carrega)

        self.botoCancelar = QvPushButton('Cancel·lar', parent=self)
        self.botoCancelar.clicked.connect(self.close)

        self.layoutBotons.addStretch()
        self.layoutBotons.addWidget(self.botoAcceptar)
        self.layoutBotons.addWidget(self.botoCancelar)
        self.layoutContingut.addLayout(self.layoutBotons)
        self.layout.addLayout(self.layoutContingut)