示例#1
0
 def current_screen_paste(self):
     value = Clipboard.paste()
     taxon_id, observation_id = get_ids_from_url(value)
     if taxon_id:
         self.select_taxon_from_photo(taxon_id)
         alert(f'Taxon {taxon_id} selected')
     if observation_id:
         self.select_observation_from_photo(observation_id)
         alert(f'Observation {observation_id} selected')
示例#2
0
 def _on_touch_down(self, instance, touch):
     """Copy text on right-click"""
     if not self.collide_point(*touch.pos):
         return
     elif touch.button == 'right':
         Clipboard.copy(self.text)
         alert('Copied to clipboard')
     else:
         super().on_touch_down(touch)
示例#3
0
    def clear_history(self, *args):
        logger.info('Settings: Clearing history')
        history, _, frequent, _ = get_app().settings_controller.stored_taxa
        history.clear()
        frequent.clear()

        # Update everything that refers to history/frequent items
        get_app().save_settings()
        get_app().refresh_history()
        self.update_cache_sizes()
        alert('History has been cleared')
示例#4
0
    def refresh_observed_taxa(self):
        """Get all user-observed taxa, if a username has been provided"""
        username = get_app().settings_controller.username
        # TODO: Show this alert only when clicking on tab instead
        if not username:
            alert('Please enter iNaturalist username on Settings page')
            return {}

        self.observed_taxa_ids = get_observed_taxa(
            username,
            include_casual=get_app().settings_controller.inaturalist.get(
                'casual_observations'),
        )
        self.set_taxon_sort_key(self.observed_taxa_list,
                                self.observed_taxa_ids)
        get_app().settings_controller.update_observed_taxa(
            self.observed_taxa_ids)
    def run(self, *args):
        """Run image tagging for selected images and input"""
        if not self.file_list:
            alert('Select images to tag')
            return
        if not self.input_dict['observation_id'] and not self.input_dict[
                'taxon_id']:
            alert(
                'Select either an observation or an organism to tag images with'
            )
            return
        selected_id = (f'Observation ID: {self.input_dict["observation_id"]}'
                       if self.input_dict['observation_id'] else
                       f'Taxon ID: {self.input_dict["taxon_id"]}')
        logger.info(
            f'Main: Tagging {len(self.file_list)} images with metadata for {selected_id}'
        )

        metadata_settings = get_app().settings_controller.metadata
        # TODO: Handle write errors (like file locked) and show dialog
        all_metadata, _, _ = tag_images(
            self.input_dict['observation_id'],
            self.input_dict['taxon_id'],
            metadata_settings['common_names'],
            metadata_settings['darwin_core'],
            metadata_settings['hierarchical_keywords'],
            metadata_settings['create_xmp'],
            self.file_list,
        )
        alert(
            f'{len(self.file_list)} images tagged with metadata for {selected_id}'
        )

        # Update image previews with new metadata
        previews = {
            img.metadata.image_path: img
            for img in self.image_previews.children
        }
        for metadata in all_metadata:
            previews[metadata.image_path].metadata = metadata
示例#6
0
 def clear_settings(self, *args):
     reset_defaults()
     self.update_control_widgets()
     alert('Settings have been reset to defaults')
示例#7
0
 def refresh_observed_taxa(*args):
     get_app().refresh_observed_taxa()
     alert('Refreshing observed species...')
示例#8
0
 def clear_thumbnail_cache(self, *args):
     logger.info('Settings: Clearing thumbnail cache')
     delete_thumbnails()
     self.update_cache_sizes()
     alert('Cache has been cleared')
示例#9
0
 def clear_http_cache(self, *args):
     logger.info('Settings: Clearing HTTP request cache')
     requests_cache.clear()
     self.update_cache_sizes()
     alert('Cache has been cleared')
示例#10
0
 def copy_flickr_tags(self, *args):
     Clipboard.copy(self.metadata.keyword_meta.flickr_tags)
     alert('Tags copied to clipboard')