def open_map_features(): """ Open MapFeatures """ desktop_service = QDesktopServices() desktop_service.openUrl( QUrl("http://wiki.openstreetmap.org/wiki/Mapfeatures"))
def open_doc_overpass(): """ Open Overpass's documentation """ url = "http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide" desktop_service = QDesktopServices() desktop_service.openUrl(QUrl(url))
def openLink(self, url): if url.toString() == "log": self.close() logDock = iface.mainWindow().findChild(QDockWidget, 'MessageLog') logDock.show() else: QDesktopServices.openUrl(url)
def onHelp(self): helpPath = Utils.getHelpPath() if helpPath == '': url = QUrl("http://www.gdal.org/" + self.helpFileName) else: url = QUrl.fromLocalFile(helpPath + '/' + self.helpFileName) QDesktopServices.openUrl(url)
def file_system_open(self, fpath: str): """Open a file on the operating system using the default action Args: fpath (str): [description] """ qurl = QUrl.fromLocalFile(fpath) QDesktopServices.openUrl(QUrl(qurl))
def openScriptFileExtEditor(self): tabWidget = self.tabEditorWidget.currentWidget() path = tabWidget.path import subprocess try: subprocess.Popen([os.environ['EDITOR'], path]) except KeyError: QDesktopServices.openUrl(QUrl.fromLocalFile(path))
def openScriptFileExtEditor(self): tabWidget = self.tabEditorWidget.currentWidget() path = tabWidget.path import subprocess try: subprocess.Popen([os.environ['EDITOR'], path]) except KeyError: QDesktopServices.openUrl(QUrl.fromLocalFile(path))
def open_href(self, url): """ # Slot for exposing the same-name function to Javascript. # Open the given URL in the browser. :param url: The URL to open :type url: str """ QDesktopServices.openUrl(QUrl(url))
def _help(self): """ Opens CQL help """ QDesktopServices.openUrl( QUrl( 'https://docs.geoserver.org/stable/en/user/tutorials/cql/cql_tutorial.html' ))
def open_object_web(self, object_type: Optional[str] = None) -> None: """Opens the Picterra web app, optionally on a given entity""" host = get_platform_url() if object_type == "detector": object_id = self.detector_menu.currentData() url = host + '/detectors/custom/' + object_id + '/run' else: url = host QDesktopServices.openUrl(QUrl(url))
def locateResources(self): """This the OS-agnostic "show in Finder" or "show in explorer" equivalent It should open the folder of the item in question Args: fpath (str): [description] """ qurl = QUrl.fromLocalFile(RESOURCES_DIR) QDesktopServices.openUrl(qurl)
def openHelp(self): locale = QgsApplication.locale() if locale in ['uk']: QDesktopServices.openUrl( QUrl(self.home)) else: QDesktopServices.openUrl( QUrl(self.home))
def link_activated(self, link): if link.url() == "#configure": cfg = OptionsDialog(self.base_configuration) if cfg.exec_(): settings = QSettings() settings.beginGroup("QgisModelBaker/ili2db") self.base_configuration.save(settings) else: QDesktopServices.openUrl(link)
def openHelp(self): locale = QgsApplication.locale() if locale in ['uk']: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape')) else: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape'))
def openHelp(self): locale = QgsApplication.locale() if locale in ['uk']: QDesktopServices.openUrl( QUrl(self.home)) else: QDesktopServices.openUrl( QUrl(self.home))
def openHelp(self): helpPath = os.path.join(pluginPath, 'docs', 'index.html') if os.path.exists(helpPath): url = QUrl('file://{}'.format(helpPath)) else: url = QUrl( 'https://github.com/qcooperative/qgis-testing/blob/main/tester-plugin.md' ) QDesktopServices.openUrl(url)
def link_activated(self, link): if link.url() == '#configure': cfg = OptionsDialog(self.base_configuration) if cfg.exec_(): settings = QSettings() settings.beginGroup('QgsProjectGenerator/ili2db') self.base_configuration.save(settings) else: QDesktopServices.openUrl(link)
def openHelp(self): locale = QgsApplication.locale() if locale in ['uk']: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape')) else: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape'))
def exportAsPDF(self): paths = super().exportAsPDF() if self.isMulti: # info = u"Les relevés ont été enregistrés dans le répertoire :\n%s\n\nOuvrir le dossier ?" % self.targetDir openFolder = QDesktopServices() openFolder.openUrl(QUrl('file:///%s' % self.targetDir)) return paths
def searchPyQGIS(self): if self.hasSelectedText(): text = self.selectedText() text = text.replace('>>> ', '').replace('... ', '').strip() # removing prompts version = '.'.join(Qgis.QGIS_VERSION.split('.')[0:2]) QDesktopServices.openUrl( QUrl('https://qgis.org/pyqgis/' + version + '/search.html?q=' + text))
def exportAsPDF(self): paths = super().exportAsPDF() if self.isMulti: info = u"Les relevés ont été enregistrés dans le répertoire :\n%s\n\nOuvrir le dossier ?" % self.targetDir openFolder = QDesktopServices() openFolder.openUrl(QUrl('file:///%s' % self.targetDir)) return paths
def run(field, value): """ Run an action with only one value as parameter @param field:Type of the action @type field:str @param value:Value of the field for one entity @type value:str """ if value == '': iface.messageBar().pushMessage(tr( "QuickOSM", u"Sorry man, this field is empty for this entity."), level=Qgis.Warning, duration=7) else: field = str(field, "UTF-8") value = str(value, "UTF-8") if field in ["url", "website", "wikipedia"]: var = QDesktopServices() url = None if field == "url" or field == "website": url = value if field == "ref_UAI": url = "http://www.education.gouv.fr/pid24302/annuaire-" \ "resultat-recherche.html?lycee_name=" + value if field == "wikipedia": url = "http://en.wikipedia.org/wiki/" + value var.openUrl(QUrl(url)) elif field == "josm": import urllib.request, urllib.error, urllib.parse try: url = "http://localhost:8111/load_object?objects=" + value urllib.request.urlopen(url).read() except urllib.error.URLError: iface.messageBar().pushMessage(tr( "QuickOSM", u"The JOSM remote seems to be disabled."), level=Qgis.Critical, duration=7) # NOT USED elif field == "rawedit": # url = QUrl("http://rawedit.openstreetmap.fr/edit/" + value) # web_browser = QWebView(None) # web_browser.load(url) # web_browser.show() pass
def showHelp(self): """Shows the help page.""" locale = QSettings().value('locale/userLocale')[0:2] help_file = self.plugin_dir + '/help/help_{}.html'.format(locale) if os.path.exists(help_file): QDesktopServices.openUrl(QUrl('file:///'+ help_file)) else: QDesktopServices.openUrl(QUrl( 'file:///'+ self.plugin_dir + '/help/help.html') )
def open_help(self): """ Open the online documentation for the panel. """ locale = QgsSettings().value("locale/userLocale", QLocale().name()) locale = locale[0:2] if locale not in ONLINE_HELP_LANGUAGES: locale = 'en' url = '{url}/{lang}/{page}'.format(url=DOC_URL, lang=locale, page=self.config.help()) QDesktopServices.openUrl(QUrl(url))
def show_help(message=None): """Open an help message in the user's browser :param message: An optional message object to display in the dialog. :type message: Message.Message """ help_path = mktemp('.html') with open(help_path, 'wb+') as f: help_html = get_help_html(message) f.write(help_html.encode('utf8')) path_with_protocol = 'file://' + help_path QDesktopServices.openUrl(QUrl(path_with_protocol))
def openHelp(self): overrideLocale = QSettings().value('locale/overrideFlag', False, bool) if not overrideLocale: locale = QLocale.system().name()[:2] else: locale = QSettings().value('locale/userLocale', '') if locale in ['uk']: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/qscatter')) else: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/qscatter'))
def report(feature_id): feat = self.alert.getFeature(feature_id) alerta_id = feat['alerta_id'] cars_ids = feat['cars'] if len(cars_ids) == 0: url = "{}/{}".format(API_MapbiomasAlert.urlReport, alerta_id) QDesktopServices.openUrl(QUrl(url)) else: for car_id in cars_ids.split('\n'): url = "{}/{}/car/{}".format(API_MapbiomasAlert.urlReport, alerta_id, car_id) QDesktopServices.openUrl(QUrl(url)) return {'isOk': True}
def file_system_locate(self, fpath: str): """This the OS-agnostic "show in Finder" or "show in explorer" equivalent It should open the folder of the item in question Args: fpath (str): [description] """ final_path = os.path.dirname(fpath) while not os.path.isdir(final_path): final_path = os.path.dirname(final_path) qurl = QUrl.fromLocalFile(final_path) QDesktopServices.openUrl(qurl)
def openHelp(self): overrideLocale = QSettings().value('locale/overrideFlag', False, bool) if not overrideLocale: locale = QLocale.system().name()[:2] else: locale = QSettings().value('locale/userLocale', '') if locale in ['uk']: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape')) else: QDesktopServices.openUrl( QUrl('https://github.com/alexbruy/photo2shape'))
def showHelp(): """Shows the help page.""" locale = QSettings().value('locale/userLocale')[0:2] help_file = os.path.join(os.path.dirname(__file__), 'help/help_{}.html'.format(locale)) help_file_en = os.path.join(os.path.dirname(__file__), 'help/help.html') if os.path.exists(help_file): QDesktopServices.openUrl(QUrl('file:///' + help_file)) #QDesktopServices.openUrl(QUrl(help_file)) else: QDesktopServices.openUrl(QUrl('file:///' + help_file_en))
def showMetadata(self, layer_name, url_metadata): """ # Slot for exposing the same-name function to Javascript. # Open the given URL in a browser. :param layer_name: The layer name :type layer_name: str :param url_metadata: The URL for the metadata to show :type url_metadata: str """ qgs_logger = QgsApplication.messageLog() qgs_logger.logMessage('showMetadata: {} {}'.format( layer_name, url_metadata), tag=configuration.LOGGER_TAG, level=Qgis.Info) QDesktopServices.openUrl(QUrl(url_metadata))
def add_user_button(self): user_menu = QMenu() self.acct_act = QAction(QIcon(EXT_LINK), "Account", user_menu) self.acct_act.triggered[bool].connect( lambda: QDesktopServices.openUrl(QUrl(ACCOUNT_URL)) ) user_menu.addAction(self.acct_act) self.logout_act = QAction("Logout", user_menu) self.logout_act.triggered[bool].connect(self.logout) user_menu.addAction(self.logout_act) self.user_button = QToolButton() self.user_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.user_button.setIcon( QIcon( os.path.join(plugin_path, "resources", "account.svg"), ) ) self.user_button.setMenu(user_menu) self.user_button.setPopupMode(QToolButton.MenuButtonPopup) # Also show menu on click, to keep disclosure triangle visible self.user_button.clicked.connect(self.user_button.showMenu) self.toolbar.addWidget(self.user_button)
def openHelp(self): overrideLocale = QSettings().value('locale/overrideFlag', False, type=bool) if not overrideLocale: localeFullName = QLocale.system().name() else: localeFullName = QSettings().value('locale/userLocale', '') localeShortName = localeFullName[0:2] if localeShortName in ['ru', 'uk']: QDesktopServices.openUrl( QUrl('http://gis-lab.info/qa/osmpoly.html')) else: QDesktopServices.openUrl( QUrl('http://gis-lab.info/qa/osmpoly-en.html'))
def finished(self, result): if result: layers = [] for filename, image_type in self.images: layers.append((QgsRasterLayer(filename, os.path.basename(filename)), image_type)) validity = [lay.isValid() for lay, _ in layers] if False in validity: widget = iface.messageBar().createMessage("Planet Explorer", f"Order '{self.order.name()}' correctly downloaded ") button = QPushButton(widget) button.setText("Open order folder") button.clicked.connect(lambda: QDesktopServices.openUrl( QUrl.fromLocalFile(self.order.download_folder())) ) widget.layout().addWidget(button) iface.messageBar().pushWidget(widget, level=Qgis.Success) else: for layer, image_type in layers: QgsProject.instance().addMapLayer(layer) iface.messageBar().pushMessage("Planet Explorer", f"Order '{self.order.name()}' correctly downloaded and processed", level=Qgis.Success, duration=5) elif self.exception is not None: QgsMessageLog.logMessage(f"Order '{self.order.name()}' could not be downloaded.\n{self.exception}", QGIS_LOG_SECTION_NAME, Qgis.Warning) iface.messageBar().pushMessage("Planet Explorer", f"Order '{self.order.name()}' could not be downloaded. See log for details", level=Qgis.Warning, duration=5)
def __init__(self, order, dialog): super().__init__() self.dialog = dialog self.order = order datestring = iso8601.parse_date(order.date).date().isoformat() txt = ('<style>h3{margin-bottom: 0px;}</style>' f'<b><h3>Order {order.name}</h3></b>' f'<b>Placed on</b>: {datestring}<br>' f'<b>Id</b>: {order.id()}<br>' f'<b>Quad count</b>: {len(order.quads)}<br>') label = QLabel(txt) button = QPushButton( 'Re-Download' if self.order.downloaded() else 'Download') button.clicked.connect(self.download) vlayout = QVBoxLayout() vlayout.addWidget(button) if self.order.downloaded(): labelOpenFolder = QLabel("<a href='#'>Open order folder</a>") vlayout.addWidget(labelOpenFolder) labelOpenFolder.setOpenExternalLinks(False) labelOpenFolder.linkActivated.connect( lambda: QDesktopServices.openUrl( QUrl.fromLocalFile(self.order.download_folder()))) layout = QHBoxLayout() layout.addWidget(label) layout.addStretch() layout.addLayout(vlayout) self.setLayout(layout)
def __init__(self, order, dialog): super().__init__() self.dialog = dialog self.order = order txt = (f'<b>Order {order.name()}<br>({order.date()})</b><br>' f'{order.assets_count()} assets - state: {order.state()}') label = QLabel(txt) if not order.is_zipped(): label.setStyleSheet("color: gray") button = QPushButton( 'Re-Download' if order.downloaded() else 'Download') button.clicked.connect(self.download) button.setEnabled(order.state() == 'success' and order.is_zipped()) vlayout = QVBoxLayout() vlayout.addWidget(button) if order.downloaded(): labelOpenFolder = QLabel("<a href='#'>Open order folder</a>") vlayout.addWidget(labelOpenFolder) labelOpenFolder.setOpenExternalLinks(False) labelOpenFolder.linkActivated.connect( lambda: QDesktopServices.openUrl( QUrl.fromLocalFile(self.order.download_folder()))) layout = QHBoxLayout() layout.addWidget(label) layout.addStretch() layout.addLayout(vlayout) self.setLayout(layout)
def __init__(self, order, dialog): super().__init__() self.dialog = dialog self.order = order datestring = iso8601.parse_date(self.order.date).date().isoformat() txt = (f'<b>Order {self.order.name}<br>({datestring})</b><br>' f'{self.order.description}') label = QLabel(txt) button = QPushButton( 'Re-Download' if self.order.downloaded() else 'Download') button.clicked.connect(self.download) vlayout = QVBoxLayout() vlayout.addWidget(button) if self.order.downloaded(): labelOpenFolder = QLabel("<a href='#'>Open order folder</a>") vlayout.addWidget(labelOpenFolder) labelOpenFolder.setOpenExternalLinks(False) labelOpenFolder.linkActivated.connect( lambda: QDesktopServices.openUrl( QUrl.fromLocalFile(self.order.download_folder()))) layout = QHBoxLayout() layout.addWidget(label) layout.addStretch() layout.addLayout(vlayout) self.setLayout(layout)
def finished(self, result): if result: layers = {} valid = True for mosaic, files in self.filenames.items(): mosaiclayers = [] for filename in files: mosaiclayers.append( QgsRasterLayer(filename, os.path.basename(filename), "gdal")) layers[mosaic] = mosaiclayers valid = valid and (False not in [ lay.isValid() for lay in mosaiclayers ]) if not valid: widget = iface.messageBar().createMessage( "Planet Explorer", f"Order '{self.order.name}' correctly downloaded ", ) button = QPushButton(widget) button.setText("Open order folder") button.clicked.connect(lambda: QDesktopServices.openUrl( QUrl.fromLocalFile(self.order.download_folder()))) widget.layout().addWidget(button) iface.messageBar().pushWidget(widget, level=Qgis.Success) else: if self.order.load_as_virtual: for mosaic, files in self.filenames.items(): vrtpath = os.path.join(self.order.download_folder(), mosaic, f"{mosaic}.vrt") gdal.BuildVRT(vrtpath, files) layer = QgsRasterLayer(vrtpath, mosaic, "gdal") QgsProject.instance().addMapLayer(layer) else: for mosaic, mosaiclayers in layers.items(): for layer in mosaiclayers: QgsProject.instance().addMapLayer(layer) # TODO create groups iface.messageBar().pushMessage( "Planet Explorer", f"Order '{self.order.name}' correctly downloaded and processed", level=Qgis.Success, duration=5, ) elif self.exception is not None: QgsMessageLog.logMessage( f"Order '{self.order.name}' could not be downloaded.\n{self.exception}", QGIS_LOG_SECTION_NAME, Qgis.Warning, ) iface.messageBar().pushMessage( "Planet Explorer", f"Order '{self.order.name}' could not be downloaded. See log for" " details", level=Qgis.Warning, duration=5, )
def run_sketch_line(network, ref): """ Run an action with two values for sketchline @param network:network of the bus @type network:str @param ref:ref of the bus @type ref:str """ if network == '' or ref == '': iface.messageBar().pushMessage( tr('Sorry man, this field is empty for this entity.'), level=Qgis.Warning, duration=7) else: var = QDesktopServices() url = 'http://www.overpass-api.de/api/sketch-line?' \ 'network=' + network + '&ref=' + ref var.openUrl(QUrl(url))
def run_sketch_line(network, ref): """ Run an action with two values for sketchline @param network:network of the bus @type network:str @param ref:ref of the bus @type ref:str """ if network == '' or ref == '': iface.messageBar().pushMessage( tr('Sorry, this field is empty for this entity.'), level=Qgis.Warning, duration=7) else: var = QDesktopServices() url = 'http://www.overpass-api.de/api/sketch-line?' \ 'network=' + network + '&ref=' + ref var.openUrl(QUrl(url))
def __reportError(self): body = ("Please provide any additional information here:\n\n\n" "If you encountered an upload error, if possible please attach a zip file containing a minimal extract of the dataset, as well as the QGIS project file.\n\n\n" "Technical information:\n%s\n\n" "Versions:\n" " QGIS: %s\n" " Python: %s\n" " OS: %s\n" " QGIS Cloud Plugin: %s\n\n" "Username: %s\n") % ( self.plainTextEdit.toPlainText(), Qgis.QGIS_VERSION, sys.version.replace("\n", " "), platform.platform(), self.metadata.version(), self.username) url = QUrl() url.toEncoded("mailto:[email protected]?subject=%s&body=%s" % ( urllib.parse.quote(self.windowTitle()), urllib.parse.quote(body)), ) QDesktopServices.openUrl(url)
def close_file(self, f, reportpath): f.write("\n</p></body></html>") f.close() #print reportpath#debug url_status = QDesktopServices.openUrl(QUrl.fromLocalFile(reportpath)) return url_status
def help(self): QDesktopServices.openUrl(QUrl.fromLocalFile( self.plugin_dir + "/help/html/index.html"))
def open_collection(self): """Slot for when user clicks 'Open' button.""" collection_path = local_collection_path(self._selected_collection_id) directory_url = QUrl.fromLocalFile(collection_path) QDesktopServices.openUrl(directory_url)
def open_help(self): '''Opens the html help file content with default browser''' #~ localHelpUrl = "https://github.com/3liz/QgisCadastrePlugin/blob/master/doc/index.rst" localHelpUrl = os.path.join(str(Path(__file__).resolve().parent), 'doc', 'index.html') QDesktopServices.openUrl( QUrl(localHelpUrl) )
def openResult(self, item, column): QDesktopServices.openUrl(QUrl.fromLocalFile(item.filename))
def giveHelp(self): self.showInfo('Giving help') QDesktopServices.openUrl(QUrl.fromLocalFile( self.plugin_dir + "/help/html/index.html"))
def openLink(self, url): QDesktopServices.openUrl(url)
def open_help(self): """Open help.""" doc_url = QUrl('http://www.akbargumbira.com/qgis_resources_sharing') QDesktopServices.openUrl(doc_url)
def openURL(self): QDesktopServices.openUrl(QUrl("https://qms.nextgis.com/create"))
def open_overpass_turbo(): """ Open Overpass Turbo """ desktop_service = QDesktopServices() desktop_service.openUrl(QUrl("http://overpass-turbo.eu/"))
def run(field, value): """ Run an action with only one value as parameter @param field:Type of the action @type field:str @param value:Value of the field for one entity @type value:str """ if value == '': iface.messageBar().pushMessage( tr('Sorry, this field \'{}\' is empty for this entity.' .format(field)), level=Qgis.Warning, duration=7) else: if field in ['url', 'website', 'wikipedia', 'wikidata']: var = QDesktopServices() url = None if field == 'url' or field == 'website': url = value if field == 'ref_UAI': url = "http://www.education.gouv.fr/pid24302/annuaire-" \ "resultat-recherche.html?lycee_name=" + value if field == 'wikipedia': url = "http://en.wikipedia.org/wiki/" + value if field == 'wikidata': url = "http://www.wikidata.org/wiki/" + value var.openUrl(QUrl(url)) elif field == 'mapillary': if 'go2mapillary' in plugins: plugins['go2mapillary'].dockwidget.show() plugins["go2mapillary"].mainAction.setChecked(False) plugins['go2mapillary'].viewer.openLocation(value) else: var = QDesktopServices() url = 'https://www.mapillary.com/map/im/' + value var.openUrl(QUrl(url)) elif field == 'josm': import urllib.request, urllib.error, urllib.parse try: url = 'http://localhost:8111/load_object?objects=' + value urllib.request.urlopen(url).read() except urllib.error.URLError: iface.messageBar().pushMessage( tr('The JOSM remote seems to be disabled.'), level=Qgis.Critical, duration=7) # NOT USED elif field == 'rawedit': # url = QUrl("http://rawedit.openstreetmap.fr/edit/" + value) # web_browser = QWebView(None) # web_browser.load(url) # web_browser.show() pass