def on_import_action(): directory_path = str(QFileDialog.getExistingDirectory(caption="Select Deck Directory")) if not directory_path: return import_directory = Path(directory_path) AnkiJsonImporter.import_deck(aqt.mw.col, import_directory)
def get_save_file(parent, title, dir_description, key, ext, fname=None): if ext == constants.ANKI_EXPORT_EXTENSION: directory = str(QFileDialog.getExistingDirectory(caption="Select Export Directory", directory=fname)) if directory: return os.path.join(directory, str(anki.utils.intTime())) return None return aqt.utils.getSaveFile_old(parent, title, dir_description, key, ext, fname)
def anki_actions_init(window): action_vendor = ActionVendor( window, QAction, lambda caption: QFileDialog.getExistingDirectory(caption=caption)) after_export_action_position = -2 window.form.menuCol.insertActions( window.form.menuCol.actions()[after_export_action_position], action_vendor.actions())
def get_save_file(parent, title, dir_description, key, ext, fname=None): if ext == crowd_anki.anki_exporter_wrapper.AnkiJsonExporterWrapper.ext: directory = str( QFileDialog.getExistingDirectory(caption="Select Export Directory", directory=fname)) if directory: return os.path.join(directory, str(anki.utils.intTime())) return None aqt.utils.getSaveFile_(parent, title, dir_description, key, ext, fname)
def on_import_action(): directory_path = str( QFileDialog.getExistingDirectory(caption="Select Deck Directory")) if not directory_path: return exported_directory = Path(directory_path) importer = AnkiJsonImporter(mw.col) try: importer.load_from_directory(exported_directory) aqt.utils.showInfo("Import of {} deck was successful".format( exported_directory.name)) except ValueError as error: aqt.utils.showWarning(error.args[0])
def anki_actions_init(window): action_vendor = ActionVendor(window, QAction, lambda caption: QFileDialog.getExistingDirectory(caption=caption)) after_export_action_position = -2 window.form.menuCol.insertActions(window.form.menuCol.actions()[after_export_action_position], action_vendor.actions())