def create_textbox(setting, default_value=""): textbox = QLineEdit() textbox.setText(setting.fetch(default_value)) textbox.connect(textbox, SIGNAL("textEdited(QString)"), lambda text: update_text(setting, text)) elements[setting] = textbox return textbox
def setup_evernote(self): global evernote_default_deck global evernote_default_tag global evernote_tags_to_import global keep_evernote_tags global update_existing_notes widget = QWidget() layout = QVBoxLayout() # Default Deck evernote_default_deck_label = QLabel("Default Deck:") evernote_default_deck = QLineEdit() evernote_default_deck.setText(mw.col.conf.get(SETTING_DEFAULT_DECK, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_deck_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_deck) evernote_default_deck.connect(evernote_default_deck, SIGNAL("editingFinished()"), update_evernote_default_deck) # Default Tag evernote_default_tag_label = QLabel("Default Tag:") evernote_default_tag = QLineEdit() evernote_default_tag.setText(mw.col.conf.get(SETTING_DEFAULT_TAG, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_tag_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_tag) evernote_default_tag.connect(evernote_default_tag, SIGNAL("editingFinished()"), update_evernote_default_tag) # Tags to Import evernote_tags_to_import_label = QLabel("Tags to Import:") evernote_tags_to_import = QLineEdit() evernote_tags_to_import.setText(mw.col.conf.get(SETTING_TAGS_TO_IMPORT, "")) layout.insertWidget(int(layout.count()) + 1, evernote_tags_to_import_label) layout.insertWidget(int(layout.count()) + 2, evernote_tags_to_import) evernote_tags_to_import.connect(evernote_tags_to_import, SIGNAL("editingFinished()"), update_evernote_tags_to_import) # Keep Evernote Tags keep_evernote_tags = QCheckBox("Keep Evernote Tags", self) keep_evernote_tags.setChecked(mw.col.conf.get(SETTING_KEEP_TAGS, False)) keep_evernote_tags.stateChanged.connect(update_evernote_keep_tags) layout.insertWidget(int(layout.count()) + 1, keep_evernote_tags) # Update Existing Notes update_existing_notes = QComboBox() update_existing_notes.addItems(["Ignore Existing Notes", "Update Existing Notes In-Place", "Delete and Re-Add Existing Notes"]) update_existing_notes.setCurrentIndex(mw.col.conf.get(SETTING_UPDATE_EXISTING_NOTES, UpdateExistingNotes.UpdateNotesInPlace)) update_existing_notes.activated.connect(update_evernote_update_existing_notes) layout.insertWidget(int(layout.count()) + 1, update_existing_notes) # Vertical Spacer vertical_spacer = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(vertical_spacer) # Parent Widget widget.setLayout(layout) # New Tab self.form.tabWidget.addTab(widget, "Evernote Importer")
def setup_evernote(self): global evernote_default_deck global evernote_default_tag global evernote_tags_to_import global keep_evernote_tags global update_existing_notes widget = QWidget() layout = QVBoxLayout() # Default Deck evernote_default_deck_label = QLabel("Default Deck for imported Cards:") evernote_default_deck = QLineEdit() evernote_default_deck.setText(mw.col.conf.get(SETTING_DEFAULT_DECK, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_deck_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_deck) evernote_default_deck.connect(evernote_default_deck, SIGNAL("editingFinished()"), update_evernote_default_deck) # Default Tag evernote_default_tag_label = QLabel("Default Tag for imported Cards:") evernote_default_tag = QLineEdit() evernote_default_tag.setText(mw.col.conf.get(SETTING_DEFAULT_TAG, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_tag_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_tag) evernote_default_tag.connect(evernote_default_tag, SIGNAL("editingFinished()"), update_evernote_default_tag) # Tags to Import evernote_tags_to_import_label = QLabel("Evernote Tags to Import:") evernote_tags_to_import = QLineEdit() evernote_tags_to_import.setText(mw.col.conf.get(SETTING_TAGS_TO_IMPORT, "")) layout.insertWidget(int(layout.count()) + 1, evernote_tags_to_import_label) layout.insertWidget(int(layout.count()) + 2, evernote_tags_to_import) evernote_tags_to_import.connect(evernote_tags_to_import, SIGNAL("editingFinished()"), update_evernote_tags_to_import) # Keep Evernote Tags keep_evernote_tags = QCheckBox("Keep Evernote Tags", self) keep_evernote_tags.setChecked(mw.col.conf.get(SETTING_KEEP_TAGS, False)) keep_evernote_tags.stateChanged.connect(update_evernote_keep_tags) layout.insertWidget(int(layout.count()) + 1, keep_evernote_tags) # Update Existing Notes update_existing_notes = QComboBox() update_existing_notes.addItems(["Ignore Existing Notes", "Update Existing Notes In-Place", "Delete and Re-Add Existing Notes"]) update_existing_notes.setCurrentIndex(mw.col.conf.get(SETTING_UPDATE_EXISTING_NOTES, UpdateExistingNotes.UpdateNotesInPlace)) update_existing_notes.activated.connect(update_evernote_update_existing_notes) layout.insertWidget(int(layout.count()) + 1, update_existing_notes) # Vertical Spacer vertical_spacer = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(vertical_spacer) # Parent Widget widget.setLayout(layout) # New Tab self.form.tabWidget.addTab(widget, "Evernote2AnkiMac")
def setup_evernote(self): global evernote_default_deck global evernote_default_tag global evernote_tags_to_import global keep_evernote_tags layout_tab = self.form.tab_1.layout() group_box = QGroupBox("Evernote Importer") layout = QVBoxLayout() # Default Deck evernote_default_deck_label = QLabel("Default Deck:") evernote_default_deck = QLineEdit() evernote_default_deck.setText(mw.col.conf.get('evernoteDefaultDeck', "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_deck_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_deck) evernote_default_deck.connect(evernote_default_deck, SIGNAL("editingFinished()"), update_evernote_default_deck) # Default Tag evernote_default_tag_label = QLabel("Default Tag:") evernote_default_tag = QLineEdit() evernote_default_tag.setText(mw.col.conf.get('evernoteDefaultTag', "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_tag_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_tag) evernote_default_tag.connect(evernote_default_tag, SIGNAL("editingFinished()"), update_evernote_default_tag) # Tags to import evernote_tags_to_import_label = QLabel("Tags to import:") evernote_tags_to_import = QLineEdit() evernote_tags_to_import.setText(mw.col.conf.get('evernoteTagsToImport', "")) layout.insertWidget(int(layout.count()) + 1, evernote_tags_to_import_label) layout.insertWidget(int(layout.count()) + 2, evernote_tags_to_import) evernote_tags_to_import.connect(evernote_tags_to_import, SIGNAL("editingFinished()"), update_evernote_tags_to_import) # keep evernote tags keep_evernote_tags = QCheckBox("Keep Evernote Tags", self) keep_evernote_tags.setChecked(mw.col.conf.get('evernoteKeepTags', False)) keep_evernote_tags.stateChanged.connect(update_evernote_keep_tags) layout.insertWidget(int(layout.count()) + 1, keep_evernote_tags) group_box.setLayout(layout) layout_tab.insertWidget(int(layout.count()) + 1, group_box)
def setup_evernote(self): global evernote_default_deck global evernote_default_tag global evernote_tags_to_import global keep_evernote_tags global update_existing_notes widget = QWidget() layout = QVBoxLayout() # Default Deck evernote_default_deck_label = QLabel("Default Deck:") evernote_default_deck = QLineEdit() evernote_default_deck.setText(mw.col.conf.get(SETTING_DEFAULT_DECK, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_deck_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_deck) evernote_default_deck.connect(evernote_default_deck, SIGNAL("editingFinished()"), update_evernote_default_deck) # Default Tag evernote_default_tag_label = QLabel("Default Tag:") evernote_default_tag = QLineEdit() evernote_default_tag.setText(mw.col.conf.get(SETTING_DEFAULT_TAG, "")) layout.insertWidget(int(layout.count()) + 1, evernote_default_tag_label) layout.insertWidget(int(layout.count()) + 2, evernote_default_tag) evernote_default_tag.connect(evernote_default_tag, SIGNAL("editingFinished()"), update_evernote_default_tag) # Tags to Import evernote_tags_to_import_label = QLabel("Tags to Import:") evernote_tags_to_import = QLineEdit() evernote_tags_to_import.setText(mw.col.conf.get(SETTING_TAGS_TO_IMPORT, "")) layout.insertWidget(int(layout.count()) + 1, evernote_tags_to_import_label) layout.insertWidget(int(layout.count()) + 2, evernote_tags_to_import) evernote_tags_to_import.connect(evernote_tags_to_import, SIGNAL("editingFinished()"), update_evernote_tags_to_import) # Keep Evernote Tags keep_evernote_tags = QCheckBox("Keep Evernote Tags", self) keep_evernote_tags.setChecked(mw.col.conf.get(SETTING_KEEP_TAGS, False)) keep_evernote_tags.stateChanged.connect(update_evernote_keep_tags) layout.insertWidget(int(layout.count()) + 1, keep_evernote_tags) # Update Existing Notes updated_label = QLabel("Behavior if a note is already imported:") layout.insertWidget(int(layout.count()) + 1, updated_label) update_existing_notes = QComboBox() update_existing_notes.addItems(["Ignore (do nothing)", "Update (raise API usage, but useful if you tend to edit your cards in Evernote)", "Reset (same as Update, but cards are rescheduled)"]) update_existing_notes.setCurrentIndex(mw.col.conf.get(SETTING_UPDATE_EXISTING_NOTES, UpdateExistingNotes.UpdateNotesInPlace)) update_existing_notes.activated.connect(update_evernote_update_existing_notes) layout.insertWidget(int(layout.count()) + 1, update_existing_notes) deletebutton = QPushButton(_("Reset Account"), clicked=remove_token) layout.insertWidget(int(layout.count()) + 1, deletebutton) # Vertical Spacer vertical_spacer = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(vertical_spacer) # Parent Widget widget.setLayout(layout) # New Tab self.form.tabWidget.addTab(widget, "Evernote Importer")