Пример #1
0
    def initGui(self):
        if not valid: return
        if int(self.QgisVersion) < 1:
            QMessageBox.warning(
                self.iface.getMainWindow(), "Gdal Tools",
                QCoreApplication.translate("GdalTools",
                                           "QGIS version detected: ") +
                unicode(self.QgisVersion) + ".xx\n" +
                QCoreApplication.translate(
                    "GdalTools",
                    "This version of Gdal Tools requires at least QGIS version 1.0.0\nPlugin will not be enabled."
                ))
            return None

        from tools.GdalTools_utils import GdalConfig, LayerRegistry
        self.GdalVersionNum = GdalConfig.versionNum()
        LayerRegistry.setIface(self.iface)

        # find the Raster menu
        rasterMenu = None
        menu_bar = self.iface.mainWindow().menuBar()
        actions = menu_bar.actions()

        rasterText = QCoreApplication.translate("QgisApp", "&Raster")

        for a in actions:
            if a.menu() is not None and a.menu().title() == rasterText:
                rasterMenu = a.menu()
                break

        if rasterMenu is None:
            # no Raster menu, create and insert it before the Help menu
            self.menu = QMenu(rasterText, self.iface.mainWindow())
            lastAction = actions[len(actions) - 1]
            menu_bar.insertMenu(lastAction, self.menu)
        else:
            self.menu = rasterMenu
            self.menu.addSeparator()

        # projections menu (Warp (Reproject), Assign projection)
        self.projectionsMenu = QMenu(
            QCoreApplication.translate("GdalTools", "Projections"),
            self.iface.mainWindow())
        self.projectionsMenu.setObjectName("projectionsMenu")

        self.warp = QAction(
            QIcon(":/icons/warp.png"),
            QCoreApplication.translate("GdalTools", "Warp (Reproject)..."),
            self.iface.mainWindow())
        self.warp.setObjectName("warp")
        self.warp.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Warp an image into a new coordinate system"))
        QObject.connect(self.warp, SIGNAL("triggered()"), self.doWarp)

        self.projection = QAction(
            QIcon(":icons/projection-add.png"),
            QCoreApplication.translate("GdalTools", "Assign Projection..."),
            self.iface.mainWindow())
        self.projection.setObjectName("projection")
        self.projection.setStatusTip(
            QCoreApplication.translate("GdalTools",
                                       "Add projection info to the raster"))
        QObject.connect(self.projection, SIGNAL("triggered()"),
                        self.doProjection)

        self.extractProj = QAction(
            QIcon(":icons/projection-export.png"),
            QCoreApplication.translate("GdalTools", "Extract Projection..."),
            self.iface.mainWindow())
        self.extractProj.setObjectName("extractProj")
        self.extractProj.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Extract projection information from raster(s)"))
        QObject.connect(self.extractProj, SIGNAL("triggered()"),
                        self.doExtractProj)

        self.projectionsMenu.addActions(
            [self.warp, self.projection, self.extractProj])

        # conversion menu (Rasterize (Vector to raster), Polygonize (Raster to vector), Translate, RGB to PCT, PCT to RGB)
        self.conversionMenu = QMenu(
            QCoreApplication.translate("GdalTools", "Conversion"),
            self.iface.mainWindow())
        self.conversionMenu.setObjectName("conversionMenu")

        if self.GdalVersionNum >= 1300:
            self.rasterize = QAction(
                QIcon(":/icons/rasterize.png"),
                QCoreApplication.translate("GdalTools",
                                           "Rasterize (Vector to Raster)..."),
                self.iface.mainWindow())
            self.rasterize.setObjectName("rasterize")
            self.rasterize.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools", "Burns vector geometries into a raster"))
            QObject.connect(self.rasterize, SIGNAL("triggered()"),
                            self.doRasterize)
            self.conversionMenu.addAction(self.rasterize)

        if self.GdalVersionNum >= 1600:
            self.polygonize = QAction(
                QIcon(":/icons/polygonize.png"),
                QCoreApplication.translate("GdalTools",
                                           "Polygonize (Raster to Vector)..."),
                self.iface.mainWindow())
            self.polygonize.setObjectName("polygonize")
            self.polygonize.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools",
                    "Produces a polygon feature layer from a raster"))
            QObject.connect(self.polygonize, SIGNAL("triggered()"),
                            self.doPolygonize)
            self.conversionMenu.addAction(self.polygonize)

        self.translate = QAction(
            QIcon(":/icons/translate.png"),
            QCoreApplication.translate("GdalTools",
                                       "Translate (Convert Format)..."),
            self.iface.mainWindow())
        self.translate.setObjectName("translate")
        self.translate.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Converts raster data between different formats"))
        QObject.connect(self.translate, SIGNAL("triggered()"),
                        self.doTranslate)

        self.paletted = QAction(
            QIcon(":icons/24-to-8-bits.png"),
            QCoreApplication.translate("GdalTools", "RGB to PCT..."),
            self.iface.mainWindow())
        self.paletted.setObjectName("paletted")
        self.paletted.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Convert a 24bit RGB image to 8bit paletted"))
        QObject.connect(self.paletted, SIGNAL("triggered()"), self.doPaletted)

        self.rgb = QAction(
            QIcon(":icons/8-to-24-bits.png"),
            QCoreApplication.translate("GdalTools", "PCT to RGB..."),
            self.iface.mainWindow())
        self.rgb.setObjectName("rgb")
        self.rgb.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Convert an 8bit paletted image to 24bit RGB"))
        QObject.connect(self.rgb, SIGNAL("triggered()"), self.doRGB)

        self.conversionMenu.addActions(
            [self.translate, self.paletted, self.rgb])

        # extraction menu (Clipper, Contour)
        self.extractionMenu = QMenu(
            QCoreApplication.translate("GdalTools", "Extraction"),
            self.iface.mainWindow())
        self.extractionMenu.setObjectName("extractionMenu")

        if self.GdalVersionNum >= 1600:
            self.contour = QAction(
                QIcon(":/icons/contour.png"),
                QCoreApplication.translate("GdalTools", "Contour..."),
                self.iface.mainWindow())
            self.contour.setObjectName("contour")
            self.contour.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools", "Builds vector contour lines from a DEM"))
            QObject.connect(self.contour, SIGNAL("triggered()"),
                            self.doContour)
            self.extractionMenu.addAction(self.contour)

        self.clipper = QAction(
            QIcon(":icons/raster-clip.png"),
            QCoreApplication.translate("GdalTools", "Clipper..."),
            self.iface.mainWindow())
        self.clipper.setObjectName("clipper")
        #self.clipper.setStatusTip( QCoreApplication.translate( "GdalTools", "Converts raster data between different formats") )
        QObject.connect(self.clipper, SIGNAL("triggered()"), self.doClipper)

        self.extractionMenu.addActions([self.clipper])

        # analysis menu (DEM (Terrain model), Grid (Interpolation), Near black, Proximity (Raster distance), Sieve)
        self.analysisMenu = QMenu(
            QCoreApplication.translate("GdalTools", "Analysis"),
            self.iface.mainWindow())
        self.analysisMenu.setObjectName("analysisMenu")

        if self.GdalVersionNum >= 1600:
            self.sieve = QAction(
                QIcon(":/icons/sieve.png"),
                QCoreApplication.translate("GdalTools", "Sieve..."),
                self.iface.mainWindow())
            self.sieve.setObjectName("sieve")
            self.sieve.setStatusTip(
                QCoreApplication.translate("GdalTools",
                                           "Removes small raster polygons"))
            QObject.connect(self.sieve, SIGNAL("triggered()"), self.doSieve)
            self.analysisMenu.addAction(self.sieve)

        if self.GdalVersionNum >= 1500:
            self.nearBlack = QAction(
                QIcon(":/icons/nearblack.png"),
                QCoreApplication.translate("GdalTools", "Near Black..."),
                self.iface.mainWindow())
            self.nearBlack.setObjectName("nearBlack")
            self.nearBlack.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools",
                    "Convert nearly black/white borders to exact value"))
            QObject.connect(self.nearBlack, SIGNAL("triggered()"),
                            self.doNearBlack)
            self.analysisMenu.addAction(self.nearBlack)

        if self.GdalVersionNum >= 1700:
            self.fillNodata = QAction(
                QIcon(":/icons/fillnodata.png"),
                QCoreApplication.translate("GdalTools", "Fill nodata..."),
                self.iface.mainWindow())
            self.fillNodata.setObjectName("fillNodata")
            self.fillNodata.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools",
                    "Fill raster regions by interpolation from edges"))
            QObject.connect(self.fillNodata, SIGNAL("triggered()"),
                            self.doFillNodata)
            self.analysisMenu.addAction(self.fillNodata)

        if self.GdalVersionNum >= 1600:
            self.proximity = QAction(
                QIcon(":/icons/proximity.png"),
                QCoreApplication.translate("GdalTools",
                                           "Proximity (Raster Distance)..."),
                self.iface.mainWindow())
            self.proximity.setObjectName("proximity")
            self.proximity.setStatusTip(
                QCoreApplication.translate("GdalTools",
                                           "Produces a raster proximity map"))
            QObject.connect(self.proximity, SIGNAL("triggered()"),
                            self.doProximity)
            self.analysisMenu.addAction(self.proximity)

        if self.GdalVersionNum >= 1500:
            self.grid = QAction(
                QIcon(":/icons/grid.png"),
                QCoreApplication.translate("GdalTools",
                                           "Grid (Interpolation)..."),
                self.iface.mainWindow())
            self.grid.setObjectName("grid")
            self.grid.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools", "Create raster from the scattered data"))
            QObject.connect(self.grid, SIGNAL("triggered()"), self.doGrid)
            self.analysisMenu.addAction(self.grid)

        if self.GdalVersionNum >= 1700:
            self.dem = QAction(
                QIcon(":icons/dem.png"),
                QCoreApplication.translate("GdalTools",
                                           "DEM (Terrain Models)..."),
                self.iface.mainWindow())
            self.dem.setObjectName("dem")
            self.dem.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools", "Tool to analyze and visualize DEMs"))
            QObject.connect(self.dem, SIGNAL("triggered()"), self.doDEM)
            self.analysisMenu.addAction(self.dem)

        #self.analysisMenu.addActions( [  ] )

        # miscellaneous menu (Build overviews (Pyramids), Tile index, Information, Merge, Build Virtual Raster (Catalog))
        self.miscellaneousMenu = QMenu(
            QCoreApplication.translate("GdalTools", "Miscellaneous"),
            self.iface.mainWindow())
        self.miscellaneousMenu.setObjectName("miscellaneousMenu")

        if self.GdalVersionNum >= 1600:
            self.buildVRT = QAction(
                QIcon(":/icons/vrt.png"),
                QCoreApplication.translate(
                    "GdalTools", "Build Virtual Raster (Catalog)..."),
                self.iface.mainWindow())
            self.buildVRT.setObjectName("buildVRT")
            self.buildVRT.setStatusTip(
                QCoreApplication.translate(
                    "GdalTools", "Builds a VRT from a list of datasets"))
            QObject.connect(self.buildVRT, SIGNAL("triggered()"),
                            self.doBuildVRT)
            self.miscellaneousMenu.addAction(self.buildVRT)

        self.merge = QAction(
            QIcon(":/icons/merge.png"),
            QCoreApplication.translate("GdalTools", "Merge..."),
            self.iface.mainWindow())
        self.merge.setObjectName("merge")
        self.merge.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Build a quick mosaic from a set of images"))
        QObject.connect(self.merge, SIGNAL("triggered()"), self.doMerge)

        self.info = QAction(
            QIcon(":/icons/raster-info.png"),
            QCoreApplication.translate("GdalTools", "Information..."),
            self.iface.mainWindow())
        self.info.setObjectName("info")
        self.info.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Lists information about raster dataset"))
        QObject.connect(self.info, SIGNAL("triggered()"), self.doInfo)

        self.overview = QAction(
            QIcon(":icons/raster-overview.png"),
            QCoreApplication.translate("GdalTools",
                                       "Build Overviews (Pyramids)..."),
            self.iface.mainWindow())
        self.overview.setObjectName("overview")
        self.overview.setStatusTip(
            QCoreApplication.translate("GdalTools",
                                       "Builds or rebuilds overview images"))
        QObject.connect(self.overview, SIGNAL("triggered()"), self.doOverview)

        self.tileindex = QAction(
            QIcon(":icons/tiles.png"),
            QCoreApplication.translate("GdalTools", "Tile Index..."),
            self.iface.mainWindow())
        self.tileindex.setObjectName("tileindex")
        self.tileindex.setStatusTip(
            QCoreApplication.translate(
                "GdalTools", "Build a shapefile as a raster tileindex"))
        QObject.connect(self.tileindex, SIGNAL("triggered()"),
                        self.doTileIndex)

        self.miscellaneousMenu.addActions(
            [self.merge, self.info, self.overview, self.tileindex])

        self.menu.addMenu(self.projectionsMenu)
        self.menu.addMenu(self.conversionMenu)
        self.menu.addMenu(self.extractionMenu)

        if not self.analysisMenu.isEmpty():
            self.menu.addMenu(self.analysisMenu)

        self.menu.addMenu(self.miscellaneousMenu)

        self.settings = QAction(
            QCoreApplication.translate("GdalTools", "GdalTools Settings..."),
            self.iface.mainWindow())
        self.settings.setObjectName("settings")
        self.settings.setStatusTip(
            QCoreApplication.translate("GdalTools",
                                       "Various settings for Gdal Tools"))
        QObject.connect(self.settings, SIGNAL("triggered()"), self.doSettings)
        self.menu.addAction(self.settings)
Пример #2
0
        regex.setCaseSensitivity(Qt.CaseInsensitive)
        self.validator = QRegExpValidator(regex, self)
        self.setRange(1, 3999)
        self.connect(self.lineEdit(), SIGNAL("textEdited(QString)"),
                     self.fixCase)

    def fixCase(self, text):
        self.lineEdit().setText(text.toUpper())

    def validate(self, text, pos):
        return self.validator.validate(text, pos)

    def valueFromText(self, text):
        return intFromRoman(str(text))

    def textFromValue(self, value):
        return romanFromInt(value)


if __name__ == "__main__":

    def report(value):
        print("{0:4d} {1}".format(value, romanFromInt(value)))

    app = QApplication(sys.argv)
    spinbox = RomanSpinBox()
    spinbox.show()
    spinbox.setWindowTitle("Roman")
    spinbox.connect(spinbox, SIGNAL("valueChanged(int)"), report)
    app.exec_()
Пример #3
0
 def emit_about_to_update(self):
     self.emit(SIGNAL('about_to_update()'))
Пример #4
0
 def about_to_update(self):
     self.emit(SIGNAL('about_to_update'))
Пример #5
0
    def __init__(self, parent):
        QtGui.QTreeWidget.__init__(self, parent)

        self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.headerItem().setHidden(True)
        self.setAllColumnsShowFocus(True)
        self.setSortingEnabled(False)
        self.setUniformRowHeights(True)
        self.setAnimated(True)
        self.setRootIsDecorated(False)
        self.setIndentation(0)

        self.add_item(N_('Staged'), hide=True)
        self.add_item(N_('Unmerged'), hide=True)
        self.add_item(N_('Modified'), hide=True)
        self.add_item(N_('Untracked'), hide=True)

        # Used to restore the selection
        self.old_scroll = None
        self.old_selection = None
        self.old_contents = None
        self.old_current_item = None
        self.expanded_items = set()

        self.process_selection = qtutils.add_action(self,
                N_('Stage / Unstage'), self._process_selection,
                cmds.Stage.SHORTCUT)

        self.launch_difftool = qtutils.add_action(self,
                cmds.LaunchDifftool.name(),
                cmds.run(cmds.LaunchDifftool),
                cmds.LaunchDifftool.SHORTCUT)
        self.launch_difftool.setIcon(qtutils.icon('git.svg'))

        self.launch_editor = qtutils.add_action(self,
                cmds.LaunchEditor.name(),
                cmds.run(cmds.LaunchEditor),
                cmds.LaunchEditor.SHORTCUT,
                'Return', 'Enter')
        self.launch_editor.setIcon(qtutils.options_icon())

        if not utils.is_win32():
            self.open_using_default_app = qtutils.add_action(self,
                    cmds.OpenDefaultApp.name(),
                    self._open_using_default_app,
                    cmds.OpenDefaultApp.SHORTCUT)
            self.open_using_default_app.setIcon(qtutils.file_icon())

            self.open_parent_dir = qtutils.add_action(self,
                    cmds.OpenParentDir.name(),
                    self._open_parent_dir,
                    cmds.OpenParentDir.SHORTCUT)
            self.open_parent_dir.setIcon(qtutils.open_file_icon())

        self.up = qtutils.add_action(self, N_('Move Up'), self.move_up,
                                     Qt.Key_K)

        self.down = qtutils.add_action(self, N_('Move Down'), self.move_down,
                                       Qt.Key_J)

        self.copy_path_action = qtutils.add_action(self,
                N_('Copy Path to Clipboard'),
                self.copy_path, QtGui.QKeySequence.Copy)
        self.copy_path_action.setIcon(qtutils.theme_icon('edit-copy.svg'))

        self.connect(self, SIGNAL('about_to_update'), self._about_to_update)
        self.connect(self, SIGNAL('updated'), self._updated)

        self.m = main.model()
        self.m.add_observer(self.m.message_about_to_update,
                            self.about_to_update)
        self.m.add_observer(self.m.message_updated, self.updated)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.show_selection)

        self.connect(self, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'),
                     self.double_clicked)

        self.connect(self, SIGNAL('itemCollapsed(QTreeWidgetItem*)'),
                     lambda x: self.update_column_widths())

        self.connect(self, SIGNAL('itemExpanded(QTreeWidgetItem*)'),
                     lambda x: self.update_column_widths())
Пример #6
0
 def stop(self):
     " Triggered when the user requesed to stop the process "
     self.emit(SIGNAL('KillIOConsoleProcess'), self.__threadID)
     return
Пример #7
0
 def __onUserInput(self, userInput):
     " Triggered when the user finished input in the redirected IO console "
     self.emit(SIGNAL('UserInput'), self.__threadID, userInput)
     self.__clearButton.setEnabled(True)
     return
Пример #8
0
def move_up(widget):
    return qtutils.add_action(widget, N_('Previous File'),
                              lambda: widget.emit(SIGNAL('move_up()')),
                              hotkeys.MOVE_UP_SECONDARY)
Пример #9
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        #        QDialog.__init__(self, parent, Qt.FramelessWindowHint)
        QDialog.__init__(self, parent)
        self.setupUi(self)

        self.nerfModel = Model()
        self.dispView = View(None, NUM_CHANNEL, DISPLAY_SCALING, VIEWER_REFRESH_RATE, \
                             CHANNEL_COLOR)

        self.dispView.show()
        self.data = []
        self.isLogData = False

        self.connect(self.dispView.timer, SIGNAL("timeout()"),
                     self.onCheckMoney)
        #        self.connect(self, SIGNAL("initRT"), self.on_horizontalSlider_sliderMoved)
        #        self.emit(SIGNAL("initRT"), 1)
        self.on_horizontalSlider_valueChanged(1)

        #        self.connect(self.doubleSpinBox_0, SIGNAL("editingFinished()"), self.onNewWire00In)
        #        self.connect(self.doubleSpinBox_0, SIGNAL("valueChanged(double)"), self.onNewWire00In)
        #
        #        self.connect(self.doubleSpinBox_1, SIGNAL("editingFinished()"), self.onNewWire01In)
        #        self.connect(self.doubleSpinBox_1, SIGNAL("valueChanged(double)"), self.onNewWire01In)

        self.connect(self.doubleSpinBox_2, SIGNAL("editingFinished()"),
                     self.onNewWireIn2)
        self.connect(self.doubleSpinBox_2, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn2)

        self.connect(self.doubleSpinBox_3, SIGNAL("editingFinished()"),
                     self.onNewWireIn3)
        self.connect(self.doubleSpinBox_3, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn3)
        #
        self.connect(self.doubleSpinBox_4, SIGNAL("editingFinished()"),
                     self.onNewWireIn4)
        self.connect(self.doubleSpinBox_4, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn4)

        self.connect(self.doubleSpinBox_5, SIGNAL("editingFinished()"),
                     self.onNewWireIn5)
        self.connect(self.doubleSpinBox_5, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn5)

        self.connect(self.doubleSpinBox_6, SIGNAL("editingFinished()"),
                     self.onNewWireIn6)
        self.connect(self.doubleSpinBox_6, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn6)
        #
        #        self.connect(self.doubleSpinBox_7, SIGNAL("editingFinished()"), self.onNewWire07In)
        #        self.connect(self.doubleSpinBox_7, SIGNAL("valueChanged(double)"), self.onNewWire07In)
        #
        #        self.connect(self.doubleSpinBox_8, SIGNAL("editingFinished()"), self.onNewWire08In)
        #        self.connect(self.doubleSpinBox_8, SIGNAL("valueChanged(double)"), self.onNewWire08In)
        #
        #        self.connect(self.doubleSpinBox_9, SIGNAL("editingFinished()"), self.onNewWire09In)
        #        self.connect(self.doubleSpinBox_9, SIGNAL("valueChanged(double)"), self.onNewWire09In)

        self.connect(self.doubleSpinBox_14, SIGNAL("editingFinished()"),
                     self.onNewWireIn14)
        self.connect(self.doubleSpinBox_14, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn14)

        self.connect(self.doubleSpinBox_15, SIGNAL("editingFinished()"),
                     self.onNewWireIn15)
        self.connect(self.doubleSpinBox_15, SIGNAL("valueChanged(double)"),
                     self.onNewWireIn15)
Пример #10
0
 def __rshift__(self, func):
     self.connect(self, SIGNAL("triggered()"), func)
Пример #11
0
def move_down(widget):
    return qtutils.add_action(widget, N_('Next File'),
                              lambda: widget.emit(SIGNAL('move_down()')),
                              hotkeys.MOVE_DOWN_SECONDARY)
Пример #12
0
 def __rshift__(self, functor):
     s = self.qshortcut
     s.connect(s, SIGNAL("activated()"), functor)
 def txtDistanceEditingFinished(self):
     self.emit(SIGNAL("editingFinished"), self)
Пример #14
0
    log(args)
    try:
        url = baseUrl % apiName

        data = urllib.urlencode(args)
        req = urllib2.Request(url, data)
        #import time
        #time.sleep(5)
        ret = (True, urllib2.urlopen(req).read())
    except Exception, e:
        ret = (False, e)


#    return callBack((False,  "lalala"))
#    load.emit(SIGNAL("finished()"))
    callBack.emit(SIGNAL("callBack(QVariant, QDialog*)"), ret, load)
    #callBack(ret)


def callCustomRestWithCallBack(apiName, args, callBack, load):
    log(args)
    try:
        myUrllib = customRest.myurllib()
        #import time
        #time.sleep(5)
        ret = (True, myUrllib.request(apiName, args))
    except Exception, e:
        ret = (False, e)


#    return callBack((False,  "lalala"))
Пример #15
0
    def __init__(self, neditable):
        super(Editor, self).__init__()
        self._neditable = neditable
        # QScintilla Configuration
        self._configure_qscintilla()

        # Markers
        self.foldable_lines = []
        self.breakpoints = []
        self.bookmarks = []
        self.search_lines = []
        self._fold_expanded_marker = 1
        self._fold_collapsed_marker = 2
        self._bookmark_marker = 3
        self._breakpoint_marker = 4
        self.setMarginSensitivity(1, True)
        self.connect(
            self,
            SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'),
            self.on_margin_clicked)
        color_fore = resources.get_color("FoldArea")
        # Marker Fold Expanded
        self.markerDefine(QsciScintilla.DownTriangle,
                          self._fold_expanded_marker)
        color = resources.get_color("FoldArrowExpanded")
        self.setMarkerBackgroundColor(QColor(color), self._fold_expanded_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._fold_expanded_marker)
        # Marker Fold Collapsed
        self.markerDefine(QsciScintilla.RightTriangle,
                          self._fold_collapsed_marker)
        color = resources.get_color("FoldArrowCollapsed")
        self.setMarkerBackgroundColor(QColor(color),
                                      self._fold_collapsed_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._fold_collapsed_marker)
        # Marker Breakpoint
        self.markerDefine(QsciScintilla.Circle,
                          self._breakpoint_marker)
        self.setMarkerBackgroundColor(QColor(255, 11, 11),
                                      self._breakpoint_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._breakpoint_marker)
        # Marker Bookmark
        self.markerDefine(QsciScintilla.SmallRectangle,
                          self._bookmark_marker)
        self.setMarkerBackgroundColor(QColor(10, 158, 227),
                                      self._bookmark_marker)
        self.setMarkerForegroundColor(QColor(color_fore),
                                      self._bookmark_marker)
        # Configure key bindings
        self._configure_keybindings()

        self.lexer = highlighter.get_lexer(self._neditable.extension())

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

        # Config Editor
        self._mini = None
        if settings.SHOW_MINIMAP:
            self._load_minimap(settings.SHOW_MINIMAP)
        self._docmap = None
        if settings.SHOW_DOCMAP:
            self._load_docmap(settings.SHOW_DOCMAP)
            self.cursorPositionChanged.connect(self._docmap.update)

        self._last_block_position = 0
        self.set_flags()
        # FIXME this lang should be guessed in the same form as lexer.
        self.lang = highlighter.get_lang(self._neditable.extension())
        self._cursor_line = self._cursor_index = -1
        self.__lines_count = 0
        self.pos_margin = 0
        self._indentation_guide = 0
        self._indent = 0
        self.__font = None
        self.__encoding = None
        self.__positions = []  # Caret positions
        self.SCN_CHARADDED.connect(self._on_char_added)

        # FIXME these should be language bound
        self.allows_less_indentation = ['else', 'elif', 'finally', 'except']
        self.set_font(settings.FONT)
        self._selected_word = ''
        self._patIsWord = re.compile('\\w+')
        # Completer
        # Dict functions for KeyPress
        self.preKeyPress = {
            Qt.Key_Backspace: self.__backspace,
            Qt.Key_Enter: self.__ignore_extended_line,
            Qt.Key_Return: self.__ignore_extended_line,
            # Qt.Key_Colon: self.__retreat_to_keywords,
            Qt.Key_BracketRight: self.__brace_completion,
            Qt.Key_BraceRight: self.__brace_completion,
            Qt.Key_ParenRight: self.__brace_completion,
            Qt.Key_Apostrophe: self.__quot_completion,
            Qt.Key_QuoteDbl: self.__quot_completion}

        self.postKeyPress = {
            Qt.Key_Enter: self.__auto_indent,
            Qt.Key_Return: self.__auto_indent,
            Qt.Key_BracketLeft: self.__complete_braces,
            Qt.Key_BraceLeft: self.__complete_braces,
            Qt.Key_ParenLeft: self.__complete_braces,
            Qt.Key_Apostrophe: self.__complete_quotes,
            Qt.Key_QuoteDbl: self.__complete_quotes}

        # Highlight word timer
        self._highlight_word_timer = QTimer()
        self._highlight_word_timer.setSingleShot(True)
        self._highlight_word_timer.timeout.connect(self.highlight_selected_word)
        # Highlight the words under cursor after 500 msec, starting when
        # the cursor changes position
        self.cursorPositionChanged.connect(
            lambda: self._highlight_word_timer.start(500))

        self.connect(self, SIGNAL("linesChanged()"), self._update_sidebar)
        self.connect(self, SIGNAL("blockCountChanged(int)"),
                     self._update_file_metadata)

        self.load_project_config()
        # Context Menu Options
        self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self)
        self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"),
                     self._find_occurrences)

        ninjaide = IDE.get_service('ide')
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_font(PyQt_PyObject)"),
            self.set_font)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_showTabsAndSpaces(PyQt_PyObject)"),
            self.set_flags)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_showIndentationGuide(PyQt_PyObject)"),
            self.set_flags)
        # TODO: figure it out it doesn´t work if gets shown after init
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_minimapShow(PyQt_PyObject)"),
                     self._load_minimap)
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_docmapShow(PyQt_PyObject)"),
                     self._load_docmap)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_indent(PyQt_PyObject)"),
            self.load_project_config)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_marginLine(PyQt_PyObject)"),
            self._set_margin_line)
        self.connect(
            ninjaide,
            SIGNAL("ns_preferences_editor_showLineNumbers(PyQt_PyObject)"),
            self._show_line_numbers)
        self.connect(ninjaide,
                     SIGNAL(
                         "ns_preferences_editor_errorsUnderlineBackground(PyQt_PyObject)"),
                     self._change_indicator_style)
        # self.connect(
        # ninjaide,
        # self.restyle)
        # self.connect(
        # ninjaide,
        # lambda: self.restyle())

        self.additional_builtins = None
        # Set the editor after initialization
        if self._neditable.editor:
            self.setDocument(self._neditable.document)
        else:
            self._neditable.set_editor(self)

        if self._neditable.file_path in settings.BREAKPOINTS:
            self.breakpoints = settings.BREAKPOINTS[self._neditable.file_path]
        if self._neditable.file_path in settings.BOOKMARKS:
            self.bookmarks = settings.BOOKMARKS[self._neditable.file_path]
        # Add breakpoints
        for line in self.breakpoints:
            self.markerAdd(line, self._breakpoint_marker)
        # Add bookmarks
        for line in self.bookmarks:
            self.markerAdd(line, self._bookmark_marker)

        self.connect(
            self._neditable,
            SIGNAL("checkersUpdated(PyQt_PyObject)"),
            self._highlight_checkers)
Пример #16
0
    '''
        Demo application showing PinMatrix widget in action
    '''
    app = QApplication(sys.argv)

    matrix = PinMatrixWidget()

    def clicked():
        print("PinMatrix value is", matrix.get_value())
        print("Possible button combinations:", matrix.get_strength())
        sys.exit()

    ok = QPushButton('OK')
    if QT_VERSION_STR >= '5':
        ok.clicked.connect(clicked)
    elif QT_VERSION_STR >= '4':
        QObject.connect(ok, SIGNAL('clicked()'), clicked)
    else:
        raise Exception('Unsupported Qt version')

    vbox = QVBoxLayout()
    vbox.addWidget(matrix)
    vbox.addWidget(ok)

    w = QWidget()
    w.setLayout(vbox)
    w.move(100, 100)
    w.show()

    app.exec_()
Пример #17
0
 def _find_occurrences(self):
     if self.hasSelectedText():
         word = self.selectedText()
     else:
         word = self._text_under_cursor()
     self.emit(SIGNAL("findOcurrences(QString)"), word)
Пример #18
0
 def show_checkers_notifications(self):
     """Show the notifications obtained for the proper checker."""
     self._checkers_executed += 1
     if self._checkers_executed == len(self.registered_checkers):
         self._checkers_executed = 0
         self.emit(SIGNAL("checkersUpdated(PyQt_PyObject)"), self)
Пример #19
0
 def close(self):
     " Triggered when the console should be closed "
     self.emit(SIGNAL('CloseIOConsole'), self.__threadID)
     return
Пример #20
0
 def mousePressEvent(self,QMouseEvent):
     self.emit(SIGNAL("clicked()"))
Пример #21
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self.setWindowTitle(self.tr("About AL\'EXA-IDE"))
        self.setMaximumSize(QSize(0, 0))

        vbox = QVBoxLayout(self)

        #Create an icon for the Dialog
        pixmap = QPixmap(resources.IMAGES['iconalexaabout'])
        self.lblIcon = QLabel()
        self.lblIcon.setPixmap(pixmap)

        self.setStyleSheet("background-color: white; color: black;")


        hbox = QHBoxLayout()
        hbox.addWidget(self.lblIcon)
        '''
        lblTitle = QLabel(
                '<h1>AL\'EXA-IDE</h1>\n<i>By Alan Pipitone<i>')
        lblTitle.setStyleSheet("color:#ff9e21;")
        lblTitle.setTextFormat(Qt.RichText)
        lblTitle.setAlignment(Qt.AlignLeft)
        '''
        #hbox.addWidget(lblTitle)
        vbox.addLayout(hbox)

        #Add description
        vbox.addWidget(QLabel(
self.tr("""AL'EXA-IDE is an integrated development environment specially design
to build Al'exa Test Cases.
AL'EXA-IDE is a total conversion of NINJA-IDE.

AL'EXA-IDE and Al'exa Engine are developed and maintained by
Alan Pipitone.""")))
        vbox.addWidget(QLabel(self.tr("Version: %s") % ninja_ide.__alexaversion__))
        link_alexa = QLabel(
            self.tr('Al\'exa Website: <a href="%s"><span style=" '
            'text-decoration: underline; color:#3414f7;">%s</span></a>') %
                (ninja_ide.__alexaurl__, ninja_ide.__alexaurl__))
        vbox.addWidget(link_alexa)
        link_source = QLabel(
            self.tr('Al\'exa Source Code: <a href="%s"><span style=" '
            'text-decoration: underline; color:#3414f7;">%s</span></a>') %
                (ninja_ide.__alexasource__, ninja_ide.__alexasource__))
        vbox.addWidget(link_source)
        link_ninja = QLabel(
            self.tr('Ninja Website: <a href="%s"><span style=" '
            'text-decoration: underline; color:#3414f7;">%s</span></a>') %
                (ninja_ide.__url__, ninja_ide.__url__))
        vbox.addWidget(link_ninja)

        sponsored = QLabel(self.tr("""
Al'exa is sponsored by:"""))
        vbox.addWidget(sponsored)

                #Create an icon for the Dialog
        pixmap = QPixmap(resources.IMAGES['iconalexaaboutsponsor'])
        self.lblIcon = QLabel()
        self.lblIcon.setPixmap(pixmap)

        hbox = QHBoxLayout()
        hbox.addWidget(self.lblIcon)

        vbox.addLayout(hbox)

        link_wuerth = QLabel(
            self.tr('NetEye Website: <a href="%s"><span style=" '
            'text-decoration: underline; color:#3414f7;">%s</span></a>') %
                (ninja_ide.__neteyewebsite__, ninja_ide.__neteyewebsite__))
        vbox.addWidget(link_wuerth)

        self.connect(link_alexa, SIGNAL("linkActivated(QString)"),
            self.link_activated)

        self.connect(link_source, SIGNAL("linkActivated(QString)"),
            self.link_activated)

        self.connect(link_ninja, SIGNAL("linkActivated(QString)"),
            self.link_activated)

        self.connect(link_wuerth, SIGNAL("linkActivated(QString)"),
            self.link_activated)
Пример #22
0
    def __init__(self):
        QDialog.__init__(self, parent=None)
        
        self.setObjectName(_fromUtf8("Dialog"))
        #self.resize(1280, 740)
        self.setFixedSize(1280, 740)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setGeometry(QtCore.QRect(0,-5,1280,740))

        
        self.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 255);"))
        self.label = QtGui.QLabel(self)
        self.label.setGeometry(QtCore.QRect(450, 295, 91, 33))
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(self)
        self.label_2.setGeometry(QtCore.QRect(450, 375, 91, 33))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        
        self.txtUser = extQLineEdit(self)
        self.txtUser.setGeometry(QtCore.QRect(610, 295, 265, 33))
        self.txtUser.setObjectName(_fromUtf8("txtUser"))
        self.connect(self.txtUser,SIGNAL("clicked()"), self.printText)
        
        self.textPass = extQLineEdit(self) #QtGui.QLineEdit(self)
        self.textPass.setGeometry(QtCore.QRect(610, 375, 265, 33))
        self.textPass.setObjectName(_fromUtf8("textPass"))        
        self.textPass.setEchoMode(QtGui.QLineEdit.Password)
        self.connect(self.textPass,SIGNAL("clicked()"), self.printText)

        
        self.btnlogin = QtGui.QPushButton(self)
        self.btnlogin.setGeometry(QtCore.QRect(515, 440, 140, 31))
        self.btnlogin.setStyleSheet(_fromUtf8("background-color: rgb(170, 170, 255);"))
        self.btnlogin.setObjectName(_fromUtf8("btnlogin"))
        self.btncancel = QtGui.QPushButton(self)
        self.btncancel.setGeometry(QtCore.QRect(685, 440, 140, 31))
        self.btncancel.setStyleSheet(_fromUtf8("background-color: rgb(170, 170, 255);"))
        self.btncancel.setObjectName(_fromUtf8("btncancel"))

        self.lbl_escudo_1 = QtGui.QLabel(self)
        self.lbl_escudo_1.setGeometry(QtCore.QRect(30, 20, 61, 61))
        self.lbl_escudo_1.setStyleSheet(_fromUtf8("image: url(:/JCE/EscudoDom.png);"))
        self.lbl_escudo_1.setText(_fromUtf8(""))
        self.lbl_escudo_1.setObjectName(_fromUtf8("lbl_escudo_1"))

        self.lbl_JCE = QtGui.QLabel(self)
        self.lbl_JCE.setGeometry(QtCore.QRect(400, 10, 500, 71))
        self.lbl_JCE.setStyleSheet(_fromUtf8("image: url(:/JCE/JCEpag1.jpg);"))
        self.lbl_JCE.setText(_fromUtf8(""))
        self.lbl_JCE.setObjectName(_fromUtf8("lbl_JCE"))

        self.lbl_escudo_3 = QtGui.QLabel(self)
        self.lbl_escudo_3.setGeometry(QtCore.QRect(1180, 20, 61, 61))
        self.lbl_escudo_3.setStyleSheet(_fromUtf8("image: url(:/JCE/EscudoDom.png);"))
        self.lbl_escudo_3.setText(_fromUtf8(""))
        self.lbl_escudo_3.setObjectName(_fromUtf8("lbl_escudo_3"))

        self.lbl_info = QtGui.QLabel(self)
        self.lbl_info.setGeometry(QtCore.QRect(260, 90, 841, 41))
        self.lbl_info.setObjectName(_fromUtf8("lbl_info"))

        
        self.label_7 = QtGui.QLabel(self)
        self.label_7.setGeometry(QtCore.QRect(0, 150, 1280, 70))
        self.label_7.setStyleSheet(_fromUtf8("background-color: rgb(0, 85, 255);"))
        self.label_7.setObjectName(_fromUtf8("label_7"))


        
        self.label_3 = QtGui.QLabel(self)
        self.label_3.setGeometry(QtCore.QRect(450, 230, 111, 21))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.lblestado = QtGui.QLabel(self)
        self.lblestado.setGeometry(QtCore.QRect(610, 230, 250, 21))
        self.lblestado.setText(_fromUtf8("Desconectado"))
        self.lblestado.setObjectName(_fromUtf8("lblestado"))

        self.label_13 = QtGui.QLabel(self)
        self.label_13.setGeometry(QtCore.QRect(900, 440, 411, 21))
        self.label_13.setObjectName(_fromUtf8("label_13"))
        

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)
        _thread.start_new_thread(self.Internet, ())
        self.btncancel.clicked.connect(self.closeE)
        self.btnlogin.clicked.connect(self.login)
Пример #23
0
 def updated(self):
     """Update display from model data."""
     self.emit(SIGNAL('updated'))
Пример #24
0
  def __init__( self, iface ):
      QWidget.__init__( self )
      self.iface = iface

      self.setupUi( self )
      BaseBatchWidget.__init__( self, self.iface, "gdal_fillnodata.py" )

      self.inSelector.setType( self.inSelector.FILE_LAYER )
      self.outSelector.setType( self.outSelector.FILE )
      self.maskSelector.setType( self.maskSelector.FILE )

      self.progressBar.setValue(0)
      self.progressBar.hide()
      self.formatLabel.hide()
      self.formatCombo.hide()

      self.outputFormat = Utils.fillRasterOutputFormat()

      self.setParamsStatus([
          ( self.inSelector, SIGNAL( "filenameChanged()" ) ),
          ( self.outSelector, SIGNAL( "filenameChanged()" ) ),
          ( self.maskSelector, SIGNAL( "filenameChanged()" ), self.maskCheck ),
          ( self.distanceSpin, SIGNAL( "valueChanged( int )" ), self.distanceCheck ),
          ( self.smoothSpin, SIGNAL( "valueChanged( int )" ), self.smoothCheck ),
          ( self.bandSpin, SIGNAL( "valueChanged( int )" ), self.bandCheck ),
          ( self.nomaskCheck, SIGNAL( "stateChanged( int )" ) )
      ])

      self.connect( self.inSelector, SIGNAL( "selectClicked()" ), self.fillInputFile )
      self.connect( self.outSelector, SIGNAL( "selectClicked()" ), self.fillOutputFile)
      self.connect( self.maskSelector, SIGNAL( "selectClicked()" ), self.fillMaskFile)
      self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )

      # add raster filters to combo
      self.formatCombo.addItems( Utils.FileFilter.allRastersFilter().split( ";;" ) )
Пример #25
0
    def __init__(self, plugin, git, path):
        QDialog.__init__(self)
        self.git = git
        self.plugin = plugin
        self.setWindowTitle('Git status')

        layout = QGridLayout(self)

        branches = self.git.branch(unicode(path))

        self.s_branches = QListWidget()

        if len(branches) > 0:
            self.s_branches.addItems(branches[1:])
            self.actual_branch = QLabel("<h2>{0}</h2>".format(branches[0]))
        else:
            self.actual_branch = QLabel()

        branch = QLabel("<h2>Branches</h2>")
        change_branch = QPushButton("Change to")
        merge_branches = QPushButton("Merge branch")

        H = QHBoxLayout()
        delete_branch = QPushButton("Delete branch")
        add_branch = QPushButton("Add branch")
        H.addWidget(add_branch)
        H.addWidget(delete_branch)

        self.lists = []

        no_staged = QLabel("<h2>No staged</h2>")

        untracked_files = QLabel("Untracked files")
        self.untracked_files = QListWidget()
        self.lists.append(self.untracked_files)

        modified_files = QLabel("Modified files")
        self.modified_files = QListWidget()
        self.lists.append(self.modified_files)

        deleted_files = QLabel("Deleted files")
        self.deleted_files = QListWidget()
        self.lists.append(self.deleted_files)

        staged = QLabel("<h2>Staged</h2>")

        added_files = QLabel("Added files")
        self.added_files = QListWidget()
        self.lists.append(self.added_files)

        s_modified_files = QLabel("Modified files")
        self.s_modified_files = QListWidget()
        self.lists.append(self.s_modified_files)

        s_deleted_files = QLabel("Deleted files")
        self.s_deleted_files = QListWidget()
        self.lists.append(self.s_deleted_files)

        layout.addWidget(self.actual_branch, 0, 0, Qt.AlignHCenter)
        layout.addWidget(change_branch, 1, 0)
        layout.addWidget(merge_branches, 2, 0)
        layout.addWidget(no_staged, 3, 0)
        layout.addWidget(untracked_files, 4, 0)
        layout.addWidget(self.untracked_files, 5, 0)
        layout.addWidget(modified_files, 6, 0)
        layout.addWidget(self.modified_files, 7, 0)
        layout.addWidget(deleted_files, 8, 0)
        layout.addWidget(self.deleted_files, 9, 0)

        layout.addWidget(branch, 0, 1)
        layout.addWidget(self.s_branches, 1, 1)
        layout.addLayout(H, 2, 1)
        layout.addWidget(staged, 3, 1)
        layout.addWidget(added_files, 4, 1)
        layout.addWidget(self.added_files, 5, 1)
        layout.addWidget(s_modified_files, 6, 1)
        layout.addWidget(self.s_modified_files, 7, 1)
        layout.addWidget(s_deleted_files, 8, 1)
        layout.addWidget(self.s_deleted_files, 9, 1)

        self.fill(self.git.no_staged["?"], self.untracked_files)
        self.fill(self.git.no_staged["M"], self.modified_files)
        self.fill(self.git.no_staged["D"], self.deleted_files)

        self.fill(self.git.staged["A"], self.added_files)
        self.fill(self.git.staged["M"], self.s_modified_files)
        self.fill(self.git.staged["D"], self.s_deleted_files)

        self.staged_b = QPushButton('Stage files', self)
        self.unstage_b = QPushButton("Unstage files", self)
        self.commit_b = QPushButton('Commit files', self)
        self.uncommit_b = QPushButton("Uncommit files", self)

        layout.addWidget(self.staged_b, 10, 0)
        layout.addWidget(self.unstage_b, 11, 0)
        layout.addWidget(self.commit_b, 10, 1)
        layout.addWidget(self.uncommit_b, 11, 1)

        self.setLayout(layout)

        self.connect(self.staged_b, SIGNAL('clicked()'), self.add)
        self.connect(self.unstage_b, SIGNAL('clicked()'), self.unstage)
        self.connect(self.commit_b, SIGNAL('clicked()'), self.commit)
        self.connect(self.uncommit_b, SIGNAL('clicked()'), self.uncommit)
        self.connect(change_branch, SIGNAL("clicked()"), self.change_branch)
        self.connect(add_branch, SIGNAL("clicked()"), self.add_branch)
        self.connect(delete_branch, SIGNAL("clicked()"), self.delete_branch)
        self.connect(merge_branches, SIGNAL("clicked()"), self.merge_branches)
Пример #26
0
 def _close(self):
     self.emit(SIGNAL("closeTrayIcon()"))
Пример #27
0
 def emit_update(self):
     self.emit(SIGNAL('update()'))
Пример #28
0
 def keyReleaseEvent(self, event):
     super(Editor, self).keyReleaseEvent(event)
     line, _ = self.getCursorPosition()
     if line != self._last_block_position:
         self._last_block_position = line
         self.emit(SIGNAL("currentLineChanged(int)"), line)
Пример #29
0
 def setModel(self, model):
     """Set the concrete QAbstractItemModel instance."""
     QtGui.QTreeView.setModel(self, model)
     self.connect(model, SIGNAL('restore()'), self.restore,
                  Qt.QueuedConnection)
Пример #30
0
 def setState(self, state):
     self.state = state
     self.reset()
     self.emit(SIGNAL("repositoriesChanged()"))