def accept(self):
        # check if exiftool installed
        if not utils.exiftoolInstalled():
            QMessageBox.warning(self,
                                self.tr("Missing exiftool"),
                                self.tr("Can't locate exiftool executable! Make sure that it is installed and available in PATH or, alternatively, specify path to binary in plugin settings"))
            return

        # save ui state
        settings = QSettings("Faunalia", "Geotagphotos")
        settings.setValue("ui/recurseDirs", self.chkRecurse.isChecked())
        settings.setValue("ui/appendFile", self.chkAppend.isChecked())
        settings.setValue("ui/addToCanvas", self.chkAddToCanvas.isChecked())

        if self.lePhotosPath.text() == "":
            QMessageBox.warning(self,
                                self.tr("Path not set"),
                                self.tr("Path to photos is not set. Please specify directory with photos."))
            return

        if self.outFileName is None or self.outFileName == "":
            QMessageBox.warning(self,
                                self.tr("Output file is not set"),
                                self.tr("Output file name is missing. Please specify correct output file."))
            return

        # TODO: check for fields compatibility?

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        self.btnOk.setEnabled(False)

        tagList = []
        for i in xrange(self.lstTags.topLevelItemCount()):
            item = self.lstTags.topLevelItem(i)
            if item.checkState(0) == Qt.Checked:
                tagList.append(unicode(item.text(0)))

        self.workThread = importthread.ImportThread(self.lePhotosPath.text(),
                                                    self.chkRecurse.isChecked(),
                                                    tagList,
                                                    self.outFileName,
                                                    self.outEncoding,
                                                    self.chkAppend.isChecked(),
                                                    cfgFile)

        self.workThread.rangeChanged.connect(self.setProgressRange)
        self.workThread.updateProgress.connect(self.updateProgress)
        self.workThread.processFinished.connect(self.processFinished)
        self.workThread.processInterrupted.connect(self.processInterrupted)

        self.btnClose.setText(self.tr("Cancel"))
        self.buttonBox.rejected.disconnect(self.reject)
        self.btnClose.clicked.connect(self.stopProcessing)

        self.workThread.start()
    def loadTags(self, dirName):
        if dirName == "":
            return

        self.lstTags.clear()

        etPath = utils.getExifToolPath()
        if not etPath == "":
            etPath = os.path.join(os.path.normpath(unicode(etPath)),
                                  "exiftool")
        else:
            etPath = "exiftool"

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        if cfgFile != "":
            etPath += " -config " + unicode(cfgFile)

        et = exiftool.ExifTool(etPath)

        md = None
        found = False

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        # fetch metadata from first photo
        with et:
            for root, dirs, files in os.walk(unicode(dirName)):
                if len(files) == 0:
                    continue

                for f in files:
                    if f.lower().endswith(".jpg") or f.lower().endswith(
                            ".jpeg"):
                        md = et.get_metadata(os.path.join(root, f))
                        if len(md) > 0:
                            found = True
                            break

                if found:
                    break

        # process metadata and populate tag list
        for k, v in md.iteritems():
            if not k.startswith("EXIF:"):
                continue
            ti = QTreeWidgetItem(self.lstTags)
            ti.setText(0, k)
            ti.setCheckState(0, Qt.Unchecked)
        self.lstTags.sortItems(0, Qt.AscendingOrder)

        QApplication.restoreOverrideCursor()
    def loadTags(self, dirName):
        if dirName == "":
            return

        self.lstTags.clear()

        etPath = utils.getExifToolPath()
        if not etPath == "":
            etPath = os.path.join(os.path.normpath(unicode(etPath)), "exiftool")
        else:
            etPath = "exiftool"

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        if cfgFile != "":
            etPath += " -config " + unicode(cfgFile)

        et = exiftool.ExifTool(etPath)

        md = None
        found = False

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

        # fetch metadata from first photo
        with et:
            for root, dirs, files in os.walk(unicode(dirName)):
                if len(files) == 0:
                    continue

                for f in files:
                    if f.lower().endswith(".jpg") or f.lower().endswith(".jpeg"):
                        md = et.get_metadata(os.path.join(root, f))
                        if len(md) > 0:
                            found = True
                            break

                if found:
                    break

        # process metadata and populate tag list
        for k, v in md.iteritems():
            if not k.startswith("EXIF:"):
                continue
            ti = QTreeWidgetItem(self.lstTags)
            ti.setText(0, k)
            ti.setCheckState(0, Qt.Unchecked)
        self.lstTags.sortItems(0, Qt.AscendingOrder)

        QApplication.restoreOverrideCursor()
Beispiel #4
0
    def accept(self):
        # check if all necessary data entered
        rows = self.model.rowCount()
        if rows == 0:
            QMessageBox.warning(
                self, self.tr("No data found"),
                self.
                tr("Seems there are no data loaded. Please populate table first."
                   ))
            return

        noTags = True
        for r in xrange(rows):
            item = self.model.item(r, 1)
            if item and item.text() != "":
                noTags = False
                break

        if noTags:
            QMessageBox.warning(self, self.tr("No tags specified"),
                                self.tr("Please specify tags to add/modify."))
            return

        if self.workThread is not None:
            QMessageBox.warning(
                self, self.tr("Active process found"),
                self.tr(
                    "Running process found. Please wait until it finished."))
            return

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        # tagging
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        self.btnOk.setEnabled(False)

        self.workThread = tagphotosthread.TagPhotosThread(self.model, cfgFile)

        self.workThread.rangeChanged.connect(self.setProgressRange)
        self.workThread.updateProgress.connect(self.updateProgress)
        self.workThread.processFinished.connect(self.processFinished)
        self.workThread.processInterrupted.connect(self.processInterrupted)

        self.btnClose.setText(self.tr("Cancel"))
        self.buttonBox.rejected.disconnect(self.reject)
        self.btnClose.clicked.connect(self.stopProcessing)

        self.workThread.start()
    def accept(self):
        # check if all necessary data entered
        rows = self.model.rowCount()
        if rows == 0:
            QMessageBox.warning(self,
                                 self.tr("No data found"),
                                 self.tr("Seems there are no data loaded. Please populate table first."))
            return

        noTags = True
        for r in xrange(rows):
            item = self.model.item(r, 1)
            if item and item.text() != "":
                noTags = False
                break

        if noTags:
            QMessageBox.warning(self,
                                self.tr("No tags specified"),
                                self.tr("Please specify tags to add/modify."))
            return

        if self.workThread is not None:
            QMessageBox.warning(self,
                                self.tr("Active process found"),
                                self.tr("Running process found. Please wait until it finished."))
            return

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        # tagging
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        self.btnOk.setEnabled(False)

        self.workThread = tagphotosthread.TagPhotosThread(self.model, cfgFile)

        self.workThread.rangeChanged.connect(self.setProgressRange)
        self.workThread.updateProgress.connect(self.updateProgress)
        self.workThread.processFinished.connect(self.processFinished)
        self.workThread.processInterrupted.connect(self.processInterrupted)

        self.btnClose.setText(self.tr("Cancel"))
        self.buttonBox.rejected.disconnect(self.reject)
        self.btnClose.clicked.connect(self.stopProcessing)

        self.workThread.start()
 def manageGui(self):
     self.leExifToolPath.setText(utils.getExifToolPath())
     self.leConfigPath.setText(utils.getConfigPath())
Beispiel #7
0
 def manageGui(self):
     self.leExifToolPath.setText(utils.getExifToolPath())
     self.leConfigPath.setText(utils.getConfigPath())
    def accept(self):
        # check if exiftool installed
        if not utils.exiftoolInstalled():
            QMessageBox.warning(
                self, self.tr("Missing exiftool"),
                self.
                tr("Can't locate exiftool executable! Make sure that it is installed and available in PATH or, alternatively, specify path to binary in plugin settings"
                   ))
            return

        # save ui state
        settings = QSettings("Faunalia", "Geotagphotos")
        settings.setValue("ui/recurseDirs", self.chkRecurse.isChecked())
        settings.setValue("ui/appendFile", self.chkAppend.isChecked())
        settings.setValue("ui/addToCanvas", self.chkAddToCanvas.isChecked())

        if self.lePhotosPath.text() == "":
            QMessageBox.warning(
                self, self.tr("Path not set"),
                self.
                tr("Path to photos is not set. Please specify directory with photos."
                   ))
            return

        if self.outFileName is None or self.outFileName == "":
            QMessageBox.warning(
                self, self.tr("Output file is not set"),
                self.
                tr("Output file name is missing. Please specify correct output file."
                   ))
            return

        # TODO: check for fields compatibility?

        # config file
        cfgFile = self.leConfigFile.text()
        if cfgFile == "":
            cfgFile = utils.getConfigPath()

        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        self.btnOk.setEnabled(False)

        tagList = []
        for i in xrange(self.lstTags.topLevelItemCount()):
            item = self.lstTags.topLevelItem(i)
            if item.checkState(0) == Qt.Checked:
                tagList.append(unicode(item.text(0)))

        self.workThread = importthread.ImportThread(
            self.lePhotosPath.text(), self.chkRecurse.isChecked(),
            tagList, self.outFileName, self.outEncoding,
            self.chkAppend.isChecked(), cfgFile)

        self.workThread.rangeChanged.connect(self.setProgressRange)
        self.workThread.updateProgress.connect(self.updateProgress)
        self.workThread.processFinished.connect(self.processFinished)
        self.workThread.processInterrupted.connect(self.processInterrupted)

        self.btnClose.setText(self.tr("Cancel"))
        self.buttonBox.rejected.disconnect(self.reject)
        self.btnClose.clicked.connect(self.stopProcessing)

        self.workThread.start()