def _OpenSelectedFileSeedData(self): file_seeds = self._list_ctrl.GetData(only_selected=True) if len(file_seeds) > 0: if len(file_seeds) > 10: message = 'You have many objects selected--are you sure you want to open them all?' result = ClientGUIDialogsQuick.GetYesNo(self, message) if result != QW.QDialog.Accepted: return if file_seeds[0].file_seed_data.startswith('http'): for file_seed in file_seeds: ClientPaths.LaunchURLInWebBrowser(file_seed.file_seed_data) else: try: for file_seed in file_seeds: HydrusPaths.OpenFileLocation(file_seed.file_seed_data) except Exception as e: QW.QMessageBox.critical(self, 'Error', str(e))
def DoOpenKnownURLFromShortcut( win, media ): urls = media.GetLocationsManager().GetURLs() matched_labels_and_urls = [] unmatched_urls = [] if len( urls ) > 0: for url in urls: try: url_class = HG.client_controller.network_engine.domain_manager.GetURLClass( url ) except HydrusExceptions.URLClassException: continue if url_class is None: unmatched_urls.append( url ) else: label = url_class.GetName() + ': ' + url matched_labels_and_urls.append( ( label, url ) ) matched_labels_and_urls.sort() unmatched_urls.sort() if len( matched_labels_and_urls ) == 0: return elif len( matched_labels_and_urls ) == 1: url = matched_labels_and_urls[0][1] else: matched_labels_and_urls.extend( ( url, url ) for url in unmatched_urls ) try: url = ClientGUIDialogsQuick.SelectFromList( win, 'Select which URL', matched_labels_and_urls, sort_tuples = False ) except HydrusExceptions.CancelledException: return ClientPaths.LaunchURLInWebBrowser( url )
def do_it( urls ): job_key = None num_urls = len( urls ) if num_urls > 5: job_key = ClientThreading.JobKey( pausable = True, cancellable = True ) job_key.SetVariable( 'popup_title', 'Opening URLs' ) HG.client_controller.pub( 'message', job_key ) try: for ( i, url ) in enumerate( urls ): if job_key is not None: ( i_paused, should_quit ) = job_key.WaitIfNeeded() if should_quit: return job_key.SetVariable( 'popup_text_1', HydrusData.ConvertValueRangeToPrettyString( i + 1, num_urls ) ) job_key.SetVariable( 'popup_gauge_1', ( i + 1, num_urls ) ) ClientPaths.LaunchURLInWebBrowser( url ) time.sleep( 1 ) finally: if job_key is not None: job_key.Finish() job_key.Delete( 1 )
def _OpenSelectedGalleryURLs(self): gallery_seeds = self._list_ctrl.GetData(only_selected=True) if len(gallery_seeds) > 0: if len(gallery_seeds) > 10: message = 'You have many objects selected--are you sure you want to open them all?' result = ClientGUIDialogsQuick.GetYesNo(self, message) if result != QW.QDialog.Accepted: return for gallery_seed in gallery_seeds: ClientPaths.LaunchURLInWebBrowser(gallery_seed.url)