def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/qgiscloud/icon.png"), \ "Cloud Settings", self.iface.mainWindow()) self.action.triggered.connect(self.showHideDockWidget) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu("&Cloud", self.action) self.plugin_dir = os.path.dirname(__file__) # initialize locale locale_short = QSettings().value("locale/userLocale", type=str)[0:2] locale_long = QSettings().value("locale/userLocale", type=str) if QFileInfo(self.plugin_dir).exists(): if QFileInfo(self.plugin_dir + "/i18n/qgiscloudplugin_" + locale_short + ".qm").exists(): self.translator = QTranslator() self.translator.load( self.plugin_dir + "/i18n/qgiscloudplugin_" + locale_short + ".qm") if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) elif QFileInfo(self.plugin_dir + "/i18n/qgiscloudplugin_" + locale_long + ".qm").exists(): self.translator = QTranslator() self.translator.load( self.plugin_dir + "/i18n/qgiscloudplugin_" + locale_long + ".qm") if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # # dock widget self.dockWidget = QgisCloudPluginDialog(self.iface, self.version) self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockWidget)
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath() ).path() + "/python/plugins/" + __package__ # initialize locale. Default to Danish self.config = QSettings() localePath = "" try: locale = self.config.value("locale/userLocale")[0:2] except: locale = 'da' if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/" + locale + ".qt.qm" if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QgsApplication.installTranslator(self.translator) # new config method self.settings = Settings() self.options_factory = OptionsFactory(self.settings) self.options_factory.setTitle('Geosearch DK') iface.registerOptionsWidgetFactory(self.options_factory)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory pluginPath = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( pluginPath, 'i18n', #'ThinGreyscale_{}.qm'.format(locale)) '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = ThinGreyscaleDialog(self.iface) # Declare instance attributes self.THINGRAYSCALE = self.tr(u'&Thin greyscale image to skeleton') self.THINGRAYSCALEAMP = self.tr('&ThinGreyscale') self.menu = self.THINGRAYSCALE
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save a reference to the QGIS interface self.iface = iface # initialize the plugin directory pluginPath = os.path.dirname(__file__) # initialize the locale using the QGIS locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( pluginPath, 'i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep the reference self.dlg = linedirectionhistogramDialog(self.iface) # Declare instance attributes self.menuname = self.tr(u'&Line Direction Histogram')
def __init__(self, iface): # Save reference to the QGIS interface self.outdir = '' self.ilayers = QgsProject.instance() self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'KuwaharaFilter_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Kuwahara Filter') # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads self.first_start = None
def __init__(self): # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] log('Locale: {}'.format(locale)) log('Plugin directory: {}'.format(self.plugin_dir)) locale_path = os.path.join(self.plugin_dir, 'i18n', 'visualist_{}.qm'.format(locale)) log('Translation file: {}'.format(locale_path)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) log('Translator added') #Store settings used by the plugin s = QgsSettings() s.setValue("visualist/homepage", "https://ipsac2.unil.ch/main/") yaml_path = os.path.join(self.plugin_dir, 'visualist.yaml') yaml_stream = open(yaml_path, 'r') yaml_document = yaml.safe_load(yaml_stream) for helper in yaml_document: s.setValue("visualist/help/" + helper, yaml_document[helper]) #initialize provider self.provider = VisualistProvider()
def __init__(self, iface): self.iface = iface self.message_bar = self.iface.messageBar() self.plugin_dir = os.path.dirname(__file__) self.settings = QSettings("CatAIS", "VeriSO") locale = QSettings().value('locale/userLocale')[0:2] self.locale_path = os.path.join(self.plugin_dir, 'i18n', 'veriso_{}.qm'.format(locale)) if os.path.exists(self.locale_path): self.translator = QTranslator() self.translator.load(self.locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # members self.toolbar = None self.menubar_projects = None self.menubar_file = None self.menu_file = None self.import_project = None self.delete_project = None self.menubar_settings = None self.menu_projects = None self.menu_settings = None self.options = None self.import_dlg = None self.delete_dlg = None self.options_dlg = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'MapsPrinter_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = MapsPrinterDialog() self.arret = False
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface self.syncer = None # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.dlg = None # Declare instance attributes self.actions = [] self.menu = self.tr(u'&ExcelSync') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'excel_sync') self.toolbar.setObjectName(u'excel_sync') self.initProject()
def __init__(self, iface): global almacen """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'Licenciamupcaza_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.dlg = LicenciamupcazaDialog() # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Sigmena') self.first_start = None
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # Initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # Initialize locale # Default locale is english useLocale = os.path.join(self.plugin_dir, 'i18n', 'SeilaplanPlugin_en.qm') # Get locale from QGIS settings qgisLocale = QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'SeilaplanPlugin_{}.qm'.format(qgisLocale)) if qgisLocale in ['de', 'en', 'fr', 'it'] and os.path.exists(localePath): useLocale = localePath self.translator = QTranslator() self.translator.load(useLocale) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.actions = [] self.menu = self.tr('SEILAPLAN') self.dlg = None self.progressDialog = None self.adjustmentWindow = None self.result = None # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads self.first_start = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save a reference to the QGIS interface self.iface = iface # initialize the plugin directory pluginPath = os.path.dirname(__file__) # initialize the locale using the QGIS locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(pluginPath, 'i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep the reference self.dlg = linedirectionhistogramDialog(self.iface) # Declare instance attributes self.menuname = self.tr(u'&Line Direction Histogram')
def __init__(self, iface): locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( os.path.dirname(__file__), 'i18n', 'qdraw_{}.qm'.format(locale)) self.translator = None if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.iface = iface self.sb = self.iface.statusBarIface() self.tool = None self.toolname = None self.bGeom = None self.actions = [] self.menu = '&Qdraw' self.toolbar = self.iface.addToolBar('Qdraw') self.toolbar.setObjectName('Qdraw') self.settings = QdrawSettings()
def __init__(self, iface): QgsMessageLog.logMessage("Starting TOMs ... ", tag="TOMs panel") """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'Test5Class_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] # ?? check - assume it initialises array of actions # self.menu = self.tr(u'&Test5') # TODO: We are going to let the user set this up in a future iteration # Set up log file and collect any relevant messages """logFilePath = os.environ.get('QGIS_LOGFILE_PATH')
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'DsgTools_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference # Declare instance attributes self.actions = [] self.menu = '&DSGTools' self.toolbar = self.iface.addToolBar(u'DsgTools') self.toolbar.setObjectName(u'DsgTools') self.dsgTools = None self.menuBar = self.iface.mainWindow().menuBar() self.provider = DSGToolsProcessingAlgorithmProvider()
def __init__(self, iface): self.iface = iface self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] locale_path = join(self.plugin_dir, 'i18n', 'GeoHealth_{}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyCallByClass,PyTypeChecker,PyArgumentList QCoreApplication.installTranslator(self.translator) self.plugin_menu = None self.geohealth_menu = None self.main_action = None self.xy_action = None self.blur_action = None self.incidence_action = None self.density_action = None self.histogram_action = None # Add to processing self.provider = Provider() Processing.addProvider(self.provider, True)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'SuroLeveling_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr('&GPS position lag correction') # print "** INITIALIZING SuroLeveling" self.pluginIsActive = False self.dockwidget = None self.iface = iface
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface self.provider = MapsPrinterProvider() # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'MapsPrinter_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save a reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'NNJoin_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.NNJOIN = self.tr('NNJoin') self.NNJOINAMP = self.tr('&NNJoin') self.toolbar = None
def __init__(self, iface): overrideLocale = QSettings().value("locale/overrideFlag", False, type=bool) if not overrideLocale: locale = QLocale.system().name() else: locale = QSettings().value("locale/userLocale", "") if locale.__class__.__name__ == 'QVariant': locale = 'en' locale = locale[0:2] locale_path = os.path.join(os.path.dirname(__file__), 'i18n', 'qdraw_{}.qm'.format(locale)) self.translator = None if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.iface = iface self.sb = self.iface.statusBarIface() self.tool = None self.toolname = None self.bGeom = None self.actions = [] self.menu = '&Qdraw' self.toolbar = self.iface.addToolBar('Qdraw') self.toolbar.setObjectName('Qdraw') self.settings = QdrawSettings()
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'vfk_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference # Declare instance attributes self.actions = [] self.menu = self.tr(u'&VFK') # TODO: We are going to let the user set this up in a future iteration # add plugin icon into plugin toolbar self.toolButton = QToolButton() self.iface.addToolBarWidget(self.toolButton)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = Path(self.plugin_dir, 'i18n', 'PCA4CD_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.menu_name_plugin = self.tr("PCA4CD - PCA for change detection") self.pluginIsActive = False PCA4CD.dialog = None self.about_dialog = AboutDialog()
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/" + __package__ # initialize locale. Default to Danish self.config = QSettings() localePath = "" try: locale = self.config.value("locale/userLocale")[0:2] except: locale = 'da' if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/" + locale + ".qt.qm" if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QgsApplication.installTranslator(self.translator) # new config method self.settings = Settings() self.options_factory = OptionsFactory(self.settings) self.options_factory.setTitle('Geosearch DK') iface.registerOptionsWidgetFactory(self.options_factory)
def __init__(self, iface): locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( os.path.dirname(__file__), 'i18n', 'qgeric_{}.qm'.format(locale)) self.translator = None if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.iface = iface self.sb = self.iface.mainWindow().statusBar() self.tool = None self.results = [] self.actions = [] self.menu = '&Qgeric' self.toolbar = self.iface.addToolBar('Qgeric') self.toolbar.setObjectName('Qgeric') self.loadingWindow = QProgressDialog(self.tr('Selecting...'),self.tr('Pass'),0,100) self.loadingWindow.setAutoClose(False) self.loadingWindow.close() self.themeColor = QColor(60,151,255, 128)
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'TOMsExport_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&TOMsExport') # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads self.first_start = None self.closeTOMs = False
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale", QLocale().name())[0:2] locale_path = os.path.join(self.plugin_dir, "i18n", "{}.qm".format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > "4.3.3": QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.action = None self.actions = [] self.menu = self.tr(u"&PreCourlis") self.profile_dialog = None self.provider = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'GBIFOccurrences_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = GBIFOccurrencesDialog() # Declare instance attributes self.actions = [] self.menu = self.tr(u'&GBIF Occurrences') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'GBIFOccurrences') self.toolbar.setObjectName(u'GBIFOccurrences')
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize options self.settings = Settings() self.settings.settings_updated.connect(self.reloadMenu) self.options_factory = OptionsFactory(self.settings) self.options_factory.setTitle(self.tr('Datafordeler')) iface.registerOptionsWidgetFactory(self.options_factory) self.layer_locator_filter = LayerLocatorFilter() self.iface.registerLocatorFilter(self.layer_locator_filter) # An error menu object, set to None. self.error_menu = None # Categories self.categories = [] self.nodes_by_index = {} self.node_count = 0 # initialize locale path = QFileInfo(os.path.realpath(__file__)).path() locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(path, 'i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): """ Contructor """ self.iface = iface log.initLogging() threadcount = QThread.idealThreadCount() # use all available cores and parallel rendering QgsApplication.setMaxThreads(threadcount) QSettings().setValue("/qgis/parallel_rendering", True) # OpenCL acceleration QSettings().setValue("/core/OpenClEnabled", True) self.plugin_dir = os.path.dirname(__file__) localeSetting = QSettings().value("locale//userLocale") if localeSetting: locale = localeSetting[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'qgisfmv_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '5.0.0': QCoreApplication.installTranslator(self.translator) self._FMVManager = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class, providing the hook to manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save the reference to the QGIS interface self.iface = iface # initialize the plugin directory self.plugin_dir = Path(__file__).parent # initialize the locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = Path(self.plugin_dir, 'i18n', 'QgsResourceSharing_{}.qm'.format(locale)) if Path(locale_path).exists(): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = ResourceSharingDialog(iface=self.iface) # Declare instance attributes self.actions = [] self.menuName = self.tr(u'&Resource Sharing') # TODO: We may let the user set this up self.toolbar = self.iface.addToolBar(self.menuName) self.toolbar.setObjectName(u'Resource Sharing')
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'Hectareas_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) #self.dlg = HectareasDialog() # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Sigmena') #self.toolbar = self.iface.addToolBar(u'Sigmena') #creo que no hace nada #self.toolbar.setObjectName(u'Sigmena') #creo que no hace nada # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads self.first_start = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'AcATaMa_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) print("** INITIALIZING AcATaMa") self.menu_name_plugin = self.tr("Accuracy Assessment of Thematic Maps") self.pluginIsActive = False self.dockwidget = None self.about_dialog = AboutDialog()
def __init__(self, iface): locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(os.path.dirname(__file__), 'i18n', 'qdraw_{}.qm'.format(locale)) self.translator = None if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.iface = iface self.sb = self.iface.statusBarIface() self.tool = None self.toolname = None self.bGeom = None self.actions = [] self.menu = '&Qdraw' self.toolbar = self.iface.addToolBar('Qdraw') self.toolbar.setObjectName('Qdraw') self.settings = QdrawSettings()
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgisInterface """ # Save reference to the QGIS interface self.iface = iface # QgsMapTool.__init(self, self.iface.mapCanvas()) self.canvas = self.iface.mapCanvas() self.canvas.setMouseTracking(True) # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'CandRRedistrict_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Arrowsmith Redistricter') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'CandRRedistrict') self.toolbar.setObjectName(u'CandRRedistrict') #print "** INITIALIZING CandRRedistrict" # variables to initialise self.pluginIsActive = False self.dockwidget = None #variable for the main dock self.attrdockwidget = None #variable for the attribute table dock self.dlgparameters = None #variable for the parameters dialog self.dlgtoolbox = None #variable for the toolbox dialog self.dlgelectorates = None #variable for the electorates dialog self.featIdentTool = None #make sure we can use the identify tool in the code self.districts = None #number of districts in the tool self.activedistrict = '1' #which district is active. We use string literals self.activeLayer = None #which layer is active - which layer we're reapportioning self.popfield = None #the population field in the database self.distfield = None #the district field in the database self.totalpop = 0 #the total population self.targetpop = 0 #the target population self.targetpoppct = 0 #target population percentage tolerance self.targetpoplower = 0 #target pop lower bound self.targetpophigher = 0 #target pop upper bound
def get_ui_class(ui_file): """Get UI Python class from .ui file. Can be filename.ui or subdirectory/filename.ui :param ui_file: The file of the ui in safe.gui.ui :type ui_file: str """ if qVersion()[0] == '4': m = importlib.import_module("qfieldsync.ui." + ui_file + '_ui4') else: m = importlib.import_module("qfieldsync.ui." + ui_file + '_ui5') return [obj for _, obj in inspect.getmembers(m) if inspect.isclass(obj) and obj.__name__[:3] == 'Ui_'][0]
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface self.canvas = self.iface.mapCanvas() # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'CircleCraters_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.export_dlg = ExportDialog() self.export_dlg.selected.connect(self.export) self.choose_counting_dlg = ChooseCountingLayerDialog() self.choose_counting_dlg.selected.connect(self.on_counting_layer_select) self.choose_raster_dlg = ChooseRasterLayerDialog() self.choose_raster_dlg.selected.connect(self.on_raster_layer_select) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Circle Craters') self.toolbar = self.iface.addToolBar(u'CircleCraters') self.toolbar.setObjectName(u'CircleCraters') self.tool = QgsMapToolEmitPoint(self.canvas) self.tool.canvasClicked.connect(self.handle_click) self.tool.deactivated.connect(self.reset_clicks) self.clicks = [] self.layer = None self.raster_layer = None
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'PotentialSlopeFailure_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.dlg = PotentialSlopeFailureDialog(self.iface) self.dlg.runButton.clicked.connect(self.start_progress) self.dlg.pushButtonHelp.clicked.connect(self.help) self.dlg.pushButtonSave.clicked.connect(self.folder_path) self.fileDialog = QFileDialog() self.fileDialog.setFileMode(QFileDialog.Directory) self.fileDialog.setOption(QFileDialog.ShowDirsOnly, True) # Declare instance attributes #self.actions = [] #self.menu = self.tr(u'&Potential Slope Failure') # TODO: We are going to let the user set this up in a future iteration #self.toolbar = self.iface.addToolBar(u'PotentialSlopeFailure') #self.toolbar.setObjectName(u'PotentialSlopeFailure') # self.layerComboManagerDEM = RasterLayerCombo(self.dlg.comboBoxDem) # RasterLayerCombo(self.dlg.comboBoxDem, initLayer="") # self.layerComboManagerSOIL = RasterLayerCombo(self.dlg.comboBoxSoil) # RasterLayerCombo(self.dlg.comboBoxSoil, initLayer="") self.layerComboManagerDEM = QgsMapLayerComboBox(self.dlg.widgetDEM) self.layerComboManagerDEM.setFilters(QgsMapLayerProxyModel.RasterLayer) self.layerComboManagerDEM.setFixedWidth(175) self.layerComboManagerSOIL = QgsMapLayerComboBox(self.dlg.widgetSOIL) self.layerComboManagerSOIL.setFilters( QgsMapLayerProxyModel.RasterLayer) self.layerComboManagerSOIL.setFixedWidth(175) self.folderPath = 'None'
def changeI18n(self, new_lang): """ Change internationalisation for the plugin. Override the system locale and then see if we can get a valid translation file for whatever locale is effectively being used. """ # os.environ["LANG"] = str(new_lang) root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) translation_path = "TimeManager:i18n/{}_{}.qm".format(self.name, new_lang) self.translator = QTranslator() result = self.translator.load(translation_path) if not result: error( "Translation file {} for lang {} was not loaded properly," + "falling back to English".format(translation_path, new_lang) ) return if qVersion() > "4.3.3": QCoreApplication.installTranslator(self.translator) else: self.translator = None warn("Translation not supported for Qt <= {}".format(qVersion()))
def changeI18n(self, new_lang): """ Change internationalisation for the plugin. Override the system locale and then see if we can get a valid translation file for whatever locale is effectively being used. """ # os.environ["LANG"] = str(new_lang) root = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir)) translation_path = "TimeManager:i18n/{}_{}.qm".format( self.name, new_lang) self.translator = QTranslator() result = self.translator.load(translation_path) if not result: error("Translation file {} for lang {} was not loaded properly," + "falling back to English".format(translation_path, new_lang)) return if qVersion() > "4.3.3": QCoreApplication.installTranslator(self.translator) else: self.translator = None warn("Translation not supported for Qt <= {}".format(qVersion()))
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) self.provider = None # initialize locale and translation locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', u'LDMP_{}.qm'.format(locale)) QgsMessageLog.logMessage( u'Starting MISLAND version {} using locale "{}" in path {}.'. format(__version__, locale, locale_path), tag="MISLAND", level=Qgis.Info) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) QgsMessageLog.logMessage("Translator installed.", tag="MISLAND", level=Qgis.Info) # Declare instance attributes self.actions = [] self.menu = QMenu(QApplication.translate('MISLAND', u'&MISLAND')) self.menu.setIcon(QIcon(':/plugins/MISLAND/misland_logo.png')) self.raster_menu = self.iface.rasterMenu() self.raster_menu.addMenu(self.menu) self.toolbar = self.iface.addToolBar(u'MISLAND') self.dlg_settings = DlgSettings() self.dlg_calculate = DlgCalculate() self.dlg_jobs = DlgJobs() self.dlg_timeseries = DlgTimeseries() self.dlg_visualization = DlgVisualization() self.dlg_download = DlgDownload() self.dlg_data_io = DlgDataIO() self.dlg_about = DlgAbout()
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'opeNoise_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = get_file_dir(__file__) # initialize locale self.translator = QTranslator() self.locale = Locale.get_locale() locale_path = os.path.join( self.plugin_dir, 'i18n', 'QuickMapServices_{}.qm'.format(self.locale)) if os.path.exists(locale_path): r = self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.custom_translator = CustomTranslator() QCoreApplication.installTranslator(self.custom_translator) # Create the dialog (after translation) and keep reference self.info_dlg = AboutDialog() # Check Contrib and User dirs try: ExtraSources.check_extra_dirs() except: error_message = self.tr('Extra dirs for %s can\'t be created: %s %s') % (PluginSettings.product_name(), sys.exc_type, sys.exc_value) self.iface.messageBar().pushMessage(self.tr('Error'), error_message, level=QgsMessageBar.CRITICAL) # Declare instance attributes self.service_actions = [] self.service_layers = [] # TODO: id and smart remove self._scales_list = None
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale_path = "" locale = QSettings().value("locale/userLocale")[0:2] if QFileInfo(self.plugin_dir).exists(): locale_path = self.plugin_dir + "/i18n/qchainage_" + locale + ".qm" if QFileInfo(locale_path).exists(): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): self.iface = iface self.plugin_dir = os.path.dirname(__file__) locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'LocatePoints_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': # noinspection PyTypeChecker,PyArgumentList,PyCallByClass QCoreApplication.installTranslator(self.translator) self.dlg = LocatePointsDialog(self.iface) self.actions = [] self.menu = self.tr(u'&Locate points along lines') self.toolbar = self.iface.addToolBar(u'LocatePoints') self.toolbar.setObjectName(u'LocatePoints')
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'constraintchecker_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference # self.dlg = ConstraintCheckerDialog() self.freeHandTool = FreehandPolygonMaptool(self.iface.mapCanvas())
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # docked or dialog, defaults to dialog # 2018 may: RD: deprecating Docked window, as the content is getting to big anyway # if isinstance(QSettings().value("/pdokservicesplugin/docked"), QVariant): # self.docked = QSettings().value("/pdokservicesplugin/docked", QVariant(False)) # else: # self.docked = QSettings().value("/pdokservicesplugin/docked", False) # # # Create the dialog and keep reference # if "True" == self.docked or "true" == self.docked or True is self.docked: # self.dlg = PdokServicesPluginDockWidget() # self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dlg) # else: # self.dlg = PdokServicesPluginDialog(parent=self.iface.mainWindow()) self.dlg = PdokServicesPluginDialog(parent=self.iface.mainWindow()) # initialize plugin directory self.plugin_dir = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() + "/python/plugins/pdokservicesplugin" # initialize locale localePath = "" if isinstance(QSettings().value("locale/userLocale"), QVariant): locale = QSettings().value("locale/userLocale").value()[0:2] else: locale = QSettings().value("locale/userLocale")[0:2] if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/pdokservicesplugin_" + locale + ".qm" if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self.currentLayer = None self.SETTINGS_SECTION = '/pdokservicesplugin/' self.pointer = None self.pdokgeocoder = PDOKGeoLocator(self.iface) self.geocoderSourceModel = None
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'azimuthdistancecalculator_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = AzimuthDistanceCalculatorDialog(self.iface) # Obtaining the map canvas self.canvas = iface.mapCanvas()
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # Keep a reference to all OL layers to avoid GC self._ol_layers = [] # initialize locale locale = QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, "i18n", "openlayers_{}.qm".format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) self._olLayerTypeRegistry = WebLayerTypeRegistry(self) self.olOverview = OLOverview(iface, self._olLayerTypeRegistry) self.dlgAbout = AboutDialog() self.pluginLayerRegistry = QgsPluginLayerRegistry()
from qgis.PyQt.QtCore import qVersion if qVersion()[0] == '4': from ..resources_rc4 import * else: from ..resources_rc5 import *