예제 #1
0
def onImgOccButton(ed, mode):
    """Launch Image Occlusion Enhanced"""
    io_model = mw.col.models.byName(IO_MODEL_NAME)
    if io_model:
        io_model_fields = mw.col.models.fieldNames(io_model)
        if "imgocc" in mw.col.conf:
            dflt_fields = mw.col.conf['imgocc']['flds'].values()
        else:
            dflt_fields = IO_FLDS.values()
        # note type integrity check
        if not all(x in io_model_fields for x in dflt_fields):
            ioError("<b>Error</b>: Image Occlusion note type " \
                "not configured properly.Please make sure you did not " \
                "manually delete or rename any of the default fields.",
                help="notetype")
            return False
    if mode != "add" and ed.note.model() != io_model:
        tooltip("Can only edit notes with the %s note type" % IO_MODEL_NAME)
        return
    try:  # allows us to fall back to old image if necessary
        oldimg = mw.ImgOccAdd.image_path
    except AttributeError:
        oldimg = None
    mw.ImgOccAdd = ImgOccAdd(ed, mode)
    mw.ImgOccAdd.selImage(oldimg)
예제 #2
0
 def getUserInputs(self, dialog, edit=False):
     """Get fields and tags from ImgOccEdit while checking note type"""
     fields = {}
     # note type integrity check:
     io_model_fields = mw.col.models.fieldNames(self.model)
     if not all(x in io_model_fields for x in self.ioflds.values()):
         ioError("<b>Error</b>: Image Occlusion note type " \
             "not configured properly.Please make sure you did not " \
             "manually delete or rename any of the default fields.",
             help="notetype")
         return False
     for i in self.mflds:
         fn = i['name']
         if fn in self.ioflds_priv:
             continue
         if edit and fn in self.sconf["skip"]:
             continue
         text = dialog.tedit[fn].toPlainText().replace('\n', '<br />')
         fields[fn] = text
     tags = dialog.tags_edit.text().split()
     return (fields, tags)
예제 #3
0
def onImgOccButton(self, origin=None, image_path=None):
    """Launch Image Occlusion Enhanced"""
    origin = origin or getEdParentInstance(self.parentWindow)
    io_model = mw.col.models.byName(IO_MODEL_NAME)
    if io_model:
        io_model_fields = mw.col.models.fieldNames(io_model)
        if "imgocc" in mw.col.conf:
            dflt_fields = mw.col.conf['imgocc']['flds'].values()
        else:
            dflt_fields = IO_FLDS.values()
        # note type integrity check
        if not all(x in io_model_fields for x in dflt_fields):
            ioError("<b>Error</b>: Image Occlusion note type " \
                "not configured properly.Please make sure you did not " \
                "manually delete or rename any of the default fields.",
                help="notetype")
            return False
    try:  # allows us to fall back to old image if necessary
        oldimg = mw.ImgOccAdd.image_path
    except AttributeError:
        oldimg = None
    mw.ImgOccAdd = ImgOccAdd(self, origin, oldimg)
    mw.ImgOccAdd.occlude(image_path)