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 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): """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 = QLocale(QSettings().value('locale/userLocale')) locale_path = os.path.join(self.plugin_dir, 'i18n') self.translator = QTranslator() self.translator.load(locale, 'QFieldSync', '_', locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&QFieldSync') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'QFieldSync') self.toolbar.setObjectName(u'QFieldSync') # instance of the QgsOfflineEditing self.offline_editing = QgsOfflineEditing() self.preferences = Preferences() QgsProject.instance().readProject.connect(self.update_button_enabled_status) # store warnings from last run self.last_action_warnings = []
def __init__(self, iface): 'initialize' # 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", "nl") if not locale: locale == 'nl' else: locale = locale[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'geopunt4qgis_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) QCoreApplication.installTranslator(self.translator) #version check if locale == 'nl': vc = versionChecker() if not vc.isUptoDate(): QMessageBox.warning(self.iface.mainWindow(), QCoreApplication.translate("geopunt4Qgis", "Waarschuwing"), QCoreApplication.translate("geopunt4Qgis", "Je versie van <a href='http://plugins.qgis.org/plugins/geopunt4Qgis' >geopunt4qgis</a> is niet meer up to date. <br/>Je kunt deze upgraden via het menu:<br/> "+ "<strong>Plugins > Beheer en installeer Plugins > Op te waarderen.</strong><br/>Klik daarna op <strong>Plugin opwaarderen</strong>")) # Create the dialogs (after translation) and keep reference self.adresdlg = geopunt4QgisAdresDialog(self.iface) self.batchgeoDlg = geopunt4QgisBatcGeoCodeDialog(self.iface) self.poiDlg = geopunt4QgisPoidialog(self.iface) self.gipodDlg = geopunt4QgisGipodDialog(self.iface) self.settingsDlg = geopunt4QgisSettingsDialog() if mathplotlibWorks : self.elevationDlg = geopunt4QgisElevationDialog(self.iface) self.datacatalogusDlg = geopunt4QgisDataCatalog(self.iface) self.parcelDlg = geopunt4QgisParcelDlg(self.iface) self.aboutDlg = geopunt4QgisAboutDialog()
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: 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.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, 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 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 getTranslate(namePlugin, nameDir=None): if nameDir is None: nameDir = namePlugin pluginPath = os.path.join('python', 'plugins', nameDir) userPath = QFileInfo(QgsApplication.qgisUserDatabaseFilePath()).path() userPluginPath = os.path.join(userPath, pluginPath) systemPath = QgsApplication.prefixPath() systemPluginPath = os.path.join(systemPath, pluginPath) overrideLocale = QSettings().value('locale/overrideFlag', False, type=bool) localeFullName = QLocale.system().name() if not overrideLocale else QSettings().value('locale/userLocale', '') qmPathFile = os.path.join('i18n', '{0}_{1}.qm'.format(namePlugin, localeFullName)) pp = userPluginPath if QFileInfo(userPluginPath).exists() else systemPluginPath translationFile = os.path.join(pp, qmPathFile) if QFileInfo(translationFile).exists(): translator = QTranslator() translator.load(translationFile) QCoreApplication.installTranslator(translator) QgsApplication.messageLog().logMessage(('Installed translation file {}'.format(translationFile)), 'Midvatten', level=Qgis.Info) return translator else: QgsApplication.messageLog().logMessage( ("translationFile {} didn't exist, no translation file installed!".format(translationFile)), 'Midvatten', level=Qgis.Info)
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): if not valid: return # Save reference to the QGIS interface self.iface = iface try: self.QgisVersion = unicode(QGis.QGIS_VERSION_INT) except: self.QgisVersion = unicode(QGis.qgisVersion)[0] if QGis.QGIS_VERSION[0:3] < "1.5": # For i18n support userPluginPath = qgis.utils.home_plugin_path + "/GdalTools" systemPluginPath = qgis.utils.sys_plugin_path + "/GdalTools" overrideLocale = QSettings().value("locale/overrideFlag", False, type=bool) if not overrideLocale: localeFullName = QLocale.system().name() else: localeFullName = QSettings().value("locale/userLocale", "", type=str) if QFileInfo(userPluginPath).exists(): translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm" else: translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm" self.localePath = translationPath if QFileInfo(self.localePath).exists(): self.translator = QTranslator() self.translator.load(self.localePath) QCoreApplication.installTranslator(self.translator) # The list of actions added to menus, so we can remove them when unloading the plugin self._menuActions = []
def __init__(self, iface): QObject.__init__(self) """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', 'MagneticDeclination_{}.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 = MagneticDeclinationDialog() # # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Magnetic Declination') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'MagneticDeclination') self.toolbar.setObjectName(u'MagneticDeclination') # #DECLARATION self.dlg.Calculate_Button.clicked.connect(self.simple_Calculate) self.dlg.FromMap_Button.clicked.connect(self.simple_FromMap) self.dlg.Compass_Button.clicked.connect(self.simple_Compass) self.dlg.Cancel_Button.clicked.connect(self.simple_Cancel) self.dlg.meter_radioButton.clicked.connect(self.simple_Meter) self.dlg.feet_radioButton.clicked.connect(self.simple_Feet) self.dlg.toMagnetic_radioButton.clicked.connect(self.simple_ToMag) self.dlg.toTrue_radioButton.clicked.connect(self.simple_ToTrue) self.dlg.color_toolButton.clicked.connect(self.simple_Kolors) # self.dlg.latitude_doubleSpinBox.valueChanged.connect(self.calcSenseLonLat) self.dlg.longitude_doubleSpinBox.valueChanged.connect(self.calcSenseLonLat) self.dlg.height_doubleSpinBox.valueChanged.connect(self.calcSense) self.dlg.heading_doubleSpinBox.valueChanged.connect(self.calcSense) self.dlg.d_spinBox.valueChanged.connect(self.calcSense) self.dlg.m_spinBox.valueChanged.connect(self.calcSense) self.dlg.y_spinBox.valueChanged.connect(self.calcSense) self.dlg.height_doubleSpinBox.valueChanged.connect(self.calcSense) self.dlg.date_groupBox.clicked.connect(self.calcSense) self.dlg.height_groupBox.clicked.connect(self.calcSense)
def __init__(self, iface): self.iface = iface locale = QgsApplication.locale() qmPath = "{}/i18n/statist_{}.qm".format(pluginPath, locale) if os.path.exists(qmPath): self.translator = QTranslator() self.translator.load(qmPath) QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): self.iface = iface locale = QgsApplication.locale() qmPath = "{}/i18n/rastertransparency_{}.qm".format(pluginPath, locale) if os.path.exists(qmPath): self.translator = QTranslator() self.translator.load(qmPath) QCoreApplication.installTranslator(self.translator) self.factory = TransparencyPanelFactory()
def test_qgis_translations(self): """Test for qgis translations.""" file_path = safe_dir('i18n/inasafe_id.qm') translator = QTranslator() translator.load(file_path) QCoreApplication.installTranslator(translator) expected_message = ( 'Tidak ada informasi gaya yang ditemukan pada lapisan %s') real_message = QCoreApplication.translate( '@default', 'No styleInfo was found for layer %s') message = 'expected %s but got %s' % (expected_message, real_message) self.assertEqual(expected_message, real_message, message)
def test_qgis_translations(self): """Test that translations work.""" parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) dir_path = os.path.abspath(parent_path) file_path = os.path.join( dir_path, 'i18n', 'af.qm') translator = QTranslator() translator.load(file_path) QCoreApplication.installTranslator(translator) expected_message = 'Goeie more' real_message = QCoreApplication.translate("@default", 'Good morning') self.assertEqual(real_message, expected_message)
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.similarLayer = [] """ """ self.previewLayer = 0 self.calcTask = CalculationModule() # Save reference to the QGIS interface self.iface = iface # Registering worker calculation self.calcThread = QThread(self.iface) self.calcTask.moveToThread(self.calcThread) self.calcThread.started.connect(self.calcTask.run) self.calcThread.setTerminationEnabled(True) # multithreading signal calculation self.calcTask.progress.connect(self.updateCalcProgress) self.calcTask.progressSim.connect(self.updateSimList) self.calcTask.finished.connect(self.finishedCalcThread) self.calcTask.error.connect(self.errorCalcThread) self.calcTask.eventTask.connect(self.eventCalcThread) # pan event self.actionPan = QAction("Pan", self.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', 'SimilarityPlugin_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Calculate Similarity Map') # 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 setup_logger('QuickOSM') # initialize plugin directory self.plugin_dir = dirname(__file__) # initialize locale # noinspection PyBroadException try: locale = QgsSettings().value('locale/userLocale', 'en')[0:2] except AttributeError: # Fallback to english #132 LOGGER.warning('Fallback to English as default language for the plugin') locale = 'en' locale_path = join( self.plugin_dir, 'i18n', 'QuickOSM_{0}.qm'.format(locale)) if exists(locale_path): LOGGER.info('Translation to {}'.format(locale)) self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) self.provider = None # Add the toolbar self.toolbar = self.iface.addToolBar('QuickOSM') self.toolbar.setObjectName('QuickOSM') self.quickosm_menu = None self.vector_menu = None self.mainWindowAction = None self.osmFileAction = None self.osmFileDockWidget = None self.queryAction = None self.queryDockWidget = None self.quickQueryAction = None self.quickQueryDockWidget = None self.josmAction = None
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', 'travel_time_platform_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) self.provider = Provider()
def __init__(self, iface): self.iface = iface readServers() class QgisLogger(): def logInfo(self, text): QgsMessageLog.logMessage(text, 'GeoCat Bridge', level=Qgis.Info) def logWarning(self, text): QgsMessageLog.logMessage(text, 'GeoCat Bridge', level=Qgis.Warning) def logError(self, text): QgsMessageLog.logMessage(text, 'GeoCat Bridge', level=Qgis.Critical) self.provider = BridgeProvider() self.pluginFolder = os.path.dirname(__file__) localePath = "" self.locale = QSettings().value("locale/userLocale")[0:2] if os.path.exists(self.pluginFolder): localePath = os.path.join(self.pluginFolder, "i18n", "bridge_" + self.locale + ".qm") self.translator = QTranslator() if os.path.exists(localePath): self.translator.load(localePath) QCoreApplication.installTranslator(self.translator) self.qgis_hook = sys.excepthook def plugin_hook(t, value, tb): errorList = traceback.format_exception(t, value, tb) trace = "".join(errorList) if PLUGIN_NAMESPACE in trace.lower(): try: handleError(errorList) except: pass #we swallow all exceptions here, to avoid entering an endless loop else: self.qgis_hook(t, value, tb) sys.excepthook = plugin_hook
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 try: locale = QSettings().value('locale/userLocale')[0:2] except Exception: locale = "hu" 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) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Configurable search') # table headers self.headers = [ self.tr(u'Value'), self.tr(u'Layer'), self.tr(u'Field'), self.tr(u'Feature Id') ] # comparision types self.compTypes = [ self.tr(u'='), self.tr(u'contains'), self.tr(u'begins with') ] # 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 # load search configuration if os.path.exists(DEFAULT_CONFIG): self.searchTypes = self.config(DEFAULT_CONFIG) else: self.searchTypes = self.config( os.path.join(self.plugin_dir, "default.cfg"))
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): """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.input_file_path = None self.output_file_path = None self.import_log_path = None self.csv_delimiter = None self.err_msg = '' self.field_assignment_controls = None self.obstacle_data = { 'ctry_name': '', 'obst_ident': '', 'obst_name': '', 'obst_type': '', 'lon_src': '', 'lat_src': '', 'agl': '', 'amsl': '', 'vert_uom': '' } self.count_imported = 0 # 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', 'ObstacleFromCSV_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&ObstacleFromCSV') # 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 = Path(__file__).parent # initialize locale # Bugfix: on Windows 10 and QGIS 3.6 Noosa occurred a TypeError. # The reason could be, that there are no translation files. try: locale = QSettings().value('locale/userLocale')[0:2] except TypeError as e: self.out( e, False) # TypeError: 'QVariant' object is not subscriptable else: locale_path = self.plugin_dir / 'i18n' / 'Radolan2Map_{}.qm'.format( locale) if locale_path.exists(): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&radolan2map') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'Radolan2Map') self.toolbar.setObjectName(u'Radolan2Map') self._model = Model() # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads # Create the dialog (after translation) and keep reference self.dock = None # Action Tabs (each has it's own logic): self._actiontab_radolan = None self._actiontab_adder = None self._actiontab_regnie = None self._settings_tab = None
def test_qgis_translations(self): """Test that translations work.""" parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) dir_path = os.path.abspath(parent_path) file_path = os.path.join( dir_path, 'i18n', 'DataPlotly_af.qm') self.assertTrue(os.path.exists(file_path), file_path) translator = QTranslator() translator.load(file_path) QCoreApplication.installTranslator(translator) expected_message = 'Goeie more' real_message = QCoreApplication.translate("@default", 'Good morning') self.assertEqual(real_message, expected_message)
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 setup_logger('QuickOSM') # initialize plugin directory self.plugin_dir = dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = join(self.plugin_dir, 'i18n', 'QuickOSM_{0}.qm'.format(locale)) if exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Create the folder if it does not exist. get_user_query_folder(over_write=True) # Add to processing # self.provider = QuickOSMAlgorithmProvider() # Processing.addProvider(self.provider, True) # Add the toolbar self.toolbar = self.iface.addToolBar('QuickOSM') self.toolbar.setObjectName('QuickOSM') self.quickosm_menu = None self.dock_menu = None self.vector_menu = None self.mainWindowAction = None self.osmFileAction = None self.osmFileDockWidget = None # self.myQueriesAction = None # self.myQueriesDockWidget = None self.queryAction = None self.queryDockWidget = None self.quickQueryAction = None self.quickQueryDockWidget = None self.josmAction = 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 setup_logger('QuickOSM') # initialize plugin directory self.plugin_dir = dirname(__file__) # initialize locale # noinspection PyBroadException try: locale = QgsSettings().value('locale/userLocale', 'en')[0:2] except AttributeError: # Fallback to english #132 LOGGER.warning( 'Fallback to English as default language for the plugin') locale = 'en' locale_path = join(self.plugin_dir, 'i18n', 'QuickOSM_{0}.qm'.format(locale)) if exists(locale_path): LOGGER.info('Translation to {}'.format(locale)) self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) self.provider = None # Add the toolbar self.toolbar = self.iface.addToolBar('QuickOSM') self.toolbar.setObjectName('QuickOSM') self.quickosm_menu = None self.vector_menu = None self.mainWindowAction = None self.osmFileAction = None self.osmFileDockWidget = None self.queryAction = None self.queryDockWidget = None self.quickQueryAction = None self.quickQueryDockWidget = None self.josmAction = 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', 'MsdcClient_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&MSDC Client') self.toolbar = self.iface.addToolBar(u'MsdcClient') self.toolbar.setObjectName(u'MsdcClient') #print "** INITIALIZING MsdcClient" self.pluginIsActive = False self.dockwidget = None self.logindiag = None self.importdiag = None self.exportdiag = None self.imagerydiag = None self.exportdir = None # default database settings self.username = "******" self.password = "******" self.host = "localhost" self.port = "5432" self.db = "msdc" self.workingdir = ":/plugins/msdc_client/data/"
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.dlg = gen_doc_calvecatDialog(parent=iface.mainWindow()) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'gen_doc_calvecat_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&gen_doc_calvecat') self.abrePredio6 = False self.directorioAGuardar6 = None self.cve_catastral6 = None self.canvas = iface.mapCanvas() # eventos self.dlg.btnBrowse_5.clicked.connect(self.selectDirectory5) self.dlg.btnGenerar_5.clicked.connect(self.generarDoc5) self.dlg.btnSeleccionar_5.clicked.connect(self.activarSeleccion5) self.dlg.exit_signal.connect(self.closeEvent) self.dlg.fldCveCat_5.textChanged.connect(self.lineEditToUpper5) #validaciones rx = QRegExp("[a-zA-Z0-9]{31}") val = QRegExpValidator(rx) self.dlg.fldCveCat_5.setValidator(val) self.onlyInt = QIntValidator() self.dlg.fldNomfolio.setValidator(self.onlyInt) self.onlyInt = QIntValidator() self.dlg.fldCodPostal.setValidator(self.onlyInt)
def __init__(self, iface, CFG=None, UTI = None): """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', 'busquedaCatastral_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&busquedaCatastral') self.CFG = CFG self.UTI = UTI self.pluginIsActive = False self.dockwidget = busquedaCatastralDialog(parent=iface.mainWindow()) #Eventos self.dockwidget.btLocalizar.clicked.connect(self.getPredio) self.dockwidget.btCerrar.clicked.connect(self.closeIt) self.dockwidget.btDetalle.clicked.connect(self.abrirDetallePredio) #validaciones QLineEdit self.onlyInt = QIntValidator() self.dockwidget.leReg.setValidator(self.onlyInt) self.dockwidget.leManz.setValidator(self.onlyInt) self.dockwidget.leLote.setValidator(self.onlyInt) self.dockwidget.leCondo.setValidator(self.onlyInt) # Check if plugin was started the first time in current QGIS session # Must be set in initGui() to survive plugin reloads self.first_start = 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 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_dlg = ChooseLayersDialog() self.choose_dlg.selected.connect(self.on_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
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 """ nowTime = time.strftime("%c") ## date and time representation QgsMessageLog.logMessage( '========================================================') QgsMessageLog.logMessage('Crop Rows Plugin Starts ' + time.strftime('%c')) QgsMessageLog.logMessage( '========================================================') # 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', 'PACropRows_{}.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'&Crop Rows Generator v1.0') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'PACropRows') self.toolbar.setObjectName(u'PACropRows') self.flagClipTaskDone = 0 #True only copy files #False clip by mask self.flagNoCropRaster = False # Must be set in initGui() to survive plugin reloads self.first_start = None QgsMessageLog.logMessage('Crop Rows Generator v1.0 - Loaded')
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', 'htpgeoprocessor_{}.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): self.iface = iface self.dock = None self.provider = None self.locator_filter = None setup_logger('pg_metadata') locale, file_path = setup_translation(folder=plugin_path("i18n"), file_pattern="pgmetadata_{}.qm") if file_path: self.translator = QTranslator() self.translator.load(file_path) # noinspection PyCallByClass,PyArgumentList QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): self.iface = iface overrideLocale = QSettings().value('locale/overrideFlag', False, bool) if not overrideLocale: locale = QLocale.system().name()[:2] else: locale = QSettings().value('locale/userLocale', '') qmPath = '{}/i18n/qscatter_{}.qm'.format(pluginPath, locale) if os.path.exists(qmPath): self.translator = QTranslator() self.translator.load(qmPath) QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): self.iface = iface overrideLocale = QSettings().value('locale/overrideFlag', False, bool) if not overrideLocale: locale = QLocale.system().name()[:2] else: locale = QSettings().value('locale/userLocale', '') qmPath = '{}/i18n/photo2shape_{}.qm'.format(pluginPath, locale) if os.path.exists(qmPath): self.translator = QTranslator() self.translator.load(qmPath) QCoreApplication.installTranslator(self.translator)
def __init__(self, pluginName): def getFile(): overrideLocale = QSettings().value('locale/overrideFlag', False, type=bool) localeFullName = QLocale.system().name() if not overrideLocale else QSettings().value('locale/userLocale', '') qmPathFile = "i18n/{0}_{1}.qm".format( pluginName, localeFullName ) pluginPath = os.path.dirname(__file__) translationFile = "{}/{}".format( pluginPath, qmPathFile ) return translationFile self.translator = None translationFile = getFile() if QFileInfo( translationFile ).exists(): self.translator = QTranslator() self.translator.load( translationFile ) QCoreApplication.installTranslator( self.translator )
def __init__(self): self.provider = 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)
def __init__(self, iface): self.provider = None self.dock = None self.iface = iface try: locale = QgsSettings().value('locale/userLocale', 'en')[0:2] except AttributeError: locale = 'en' locale_path = resources_path('i18n', '{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator)
def __init__(self, iface): self.provider = None self.dock = None self.iface = iface locale, file_path = setup_translation(folder=plugin_path("i18n"), file_pattern="lizsync_{}.qm") if file_path: # LOGGER.info('Translation to {}'.format(file_path)) self.translator = QTranslator() self.translator.load(file_path) QCoreApplication.installTranslator(self.translator) else: # LOGGER.info('Translation not found: {}'.format(locale)) pass
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 test_qgis_translations(self): """Test that translations work.""" return parent_path = os.path.join( __file__, os.path.pardir, os.path.pardir, os.pardir) dir_path = os.path.abspath(parent_path) file_path = os.path.join( dir_path, 'i18n', 'af.ts') translator = QTranslator() translator.load(file_path) QCoreApplication.installTranslator(translator) expected_message = 'Goeie more' real_message = QCoreApplication.translate('@default', 'Good morning') self.assertEqual(real_message, expected_message)
def __init__(self, iface): _ = iface self.provider = None setup_logger(plugin_name()) locale, ts_file = setup_translation() if ts_file: self.translator = QTranslator() self.translator.load(ts_file) QCoreApplication.installTranslator(self.translator) LOGGER.debug('Translation file set to {}'.format(ts_file)) else: LOGGER.debug('Translation file not found {}'.format(locale))
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 and the mapCanvas self.iface = iface self.mapcanvas = iface.mapCanvas() # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale if not QSettings().value('locale/userLocale'): locale = QSettings().value('locale/globalLocale')[0:2] else: locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'RuimtelijkePlannen_{}.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'&Ruimtelijke Plannen') self.toolbar = self.iface.addToolBar(u'RuimtelijkePlannen') self.toolbar.setObjectName(u'RuimtelijkePlannen') self.nam = networkaccessmanager.NetworkAccessManager() self.project = QgsProject.instance() # initialize styles folder self.settings = QSettings() self.available_styles_folder = os.path.join(self.plugin_dir, 'styles') self.map_style = self.settings.value("RuimtelijkePlannen/map_style", "print") self.map_style_folder = os.path.join(self.available_styles_folder, self.map_style) if not os.path.isdir(self.map_style_folder): self.map_style = "print" self.map_style_folder = os.path.join(self.available_styles_folder, self.map_style)
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', 'CoordinateCapture_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Coordinate Capture') # TODO: We are going to let the user set this up in a future iteration # print "** INITIALIZING CoordinateCapture" self.pluginIsActive = False self.dockwidget = None self.crs = QgsCoordinateReferenceSystem("EPSG:4326") self.transform = QgsCoordinateTransform() self.transform.setDestinationCrs(self.crs) if self.crs.mapUnits() == QgsUnitTypes.DistanceDegrees: self.userCrsDisplayPrecision = 5 else: self.userCrsDisplayPrecision = 3 self.canvasCrsDisplayPrecision = None self.iface.mapCanvas().destinationCrsChanged.connect(self.setSourceCrs) self.setSourceCrs() self.mapTool = CoordinateCaptureMapTool(self.iface.mapCanvas()) self.mapTool.mouseMoved.connect(self.mouseMoved) self.mapTool.mouseClicked.connect(self.mouseClicked)
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.path = QFileInfo(os.path.realpath(__file__)).path() self.toolBar = None self.canvas = self.iface.mapCanvas() self.dlgPosX = 100 self.dlgPosY = 100 self.lastSearch = "" self.localiseOnStartup = True self.defaultArea = Qt.LeftDockWidgetArea self.singleLayer = True self.read() # récup langue par défaut locale = QSettings().value("locale/userLocale") try: self.myLocale = locale[0:2] # exploiter le bon dictionnaire localePath = ( QFileInfo(os.path.realpath(__file__)).path() + "/i18n/" + self.myLocale + ".qm" ) # initialiser le traducteur if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) QCoreApplication.installTranslator(self.translator) except: # no translation pass try: self.nominatim_dlg except: self.nominatim_dlg = NominatimDialog(self.iface.mainWindow(), self) self.nominatim_dlg.visibilityChanged.connect(self.dockVisibilityChanged) self.nominatim_dlg.dockLocationChanged.connect(self.dockLocationChanged) try: self.nominatim_dlg.editSearch.setText(self.lastSearch) except: pass
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', 'TerraqubeCloud_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Terraqube Hyperspectral Cloud') # 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 # Create necessary variables used during upload self.upload_time_started = None # Create necessary internal project, hiperqube and signature lists. self.hiperqubes = [] self.hiperqube = None self.hiperqube_details = None self.signatures = [] self.signature = None # Stores the temporary filenames created when downloading # thumbnails and raster images from hiperqubes self.temp_filenames = [] # Flag that indicates whether the cursor is set to busy or not. # This will prevent the cursor to be set busy multiple times # which would prevent it to be restored properly self.cursor_busy = 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', 'en_US')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'PosiView_{}.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'&PosiView') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'PosiView') self.toolbar.setObjectName(u'PosiView') self.project = PosiViewProject(self.iface) self.tracking = TrackingDock() self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.tracking) self.tracking.providerToolbar.triggered.connect(self.dumpProvider) self.guidance = GuidanceDock() self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.guidance) self.guidanceVisible = False self.compass = CompassDock() self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.compass) self.compassVisible = False self.providerDump = None self.positionDisplay = PositionDisplay(self.iface) self.recorder = None iface.initializationCompleted.connect(self.postInitialize) self.mapTool = MeasureMapTool(self.iface.mapCanvas()) self.positionDisplay.exportPosition.connect( self.mapTool.positionUpdate)
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_str = QSettings().value('locale/userLocale') if isinstance(locale_str, str): locale = QLocale(locale_str) else: locale = QLocale() locale_path = os.path.join(self.plugin_dir, 'i18n') self.translator = QTranslator() self.translator.load(locale, 'qfieldsync', '_', locale_path) QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr('&QFieldSync') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar('QFieldSync') self.toolbar.setObjectName('QFieldSync') # instance of the map config widget factory, shown in layer properties self.mapLayerConfigWidgetFactory = MapLayerConfigWidgetFactory( 'QField', QIcon( os.path.join(os.path.dirname(__file__), 'resources/qfield_logo.svg'))) # instance of the QgsOfflineEditing self.offline_editing = QgsOfflineEditing() self.preferences = Preferences() QgsProject.instance().readProject.connect( self.update_button_enabled_status) # store warnings from last run self.last_action_warnings = []
def __init__(self, iface): QDialog.__init__(self, None) self.setWindowFlags( self.windowFlags() & ~Qt.WindowContextHelpButtonHint ) #self.setWindowFlags( self.windowFlags() |Qt.WindowStaysOnTopHint) self.iface = iface # initialize locale locale = QSettings().value("locale/userLocale", "nl") if not locale: locale == 'nl' else: locale = locale[0:2] localePath = os.path.join(os.path.dirname(__file__), 'i18n', 'geopunt4qgis_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) QCoreApplication.installTranslator(self.translator) self._initGui()
def __init__(self, iface): QDialog.__init__(self, None) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.iface = iface # initialize locale locale = QSettings().value("locale/userLocale", "en") if not locale: locale = 'en' else: locale = locale[0:2] localePath = os.path.join(os.path.dirname(__file__), 'i18n', 'geopunt4qgis_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) QCoreApplication.installTranslator(self.translator) self._initGui()
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 = QFileInfo(QgsApplication.qgisSettingsDirPath()).path() + "/python/plugins/distromap" # initialize locale localePath = "" locale = QSettings().value("locale/userLocale")[0:2] if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/distromap_" + locale + ".qm" if QFileInfo(localePath).exists(): 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 = DistroMapDialog()
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 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()))