Example #1
0
    def Execute(self):
        curLang = Settings().GetLanguage()

        localeDir = None
        for localeDir in (os.path.join(Constants.APP_DIR, "share", "locale"),
                          os.path.join(Constants.APP_DIR, "locale"),):
            if os.path.isdir(localeDir):
                break

        if localeDir is None:
            gettext.install(Constants.APP_NAME)
            return

        try:
            lang = gettext.translation(Constants.APP_NAME,
                                       localeDir,
                                       languages=[curLang, "en"])
            lang.install(True)
        except IOError:
            gettext.install(Constants.APP_NAME)
Example #2
0
    def OnChoiceFormat(self, event):
        if event is None:
            formatData = self.__GetChoiceDataSelected(self.choiceFormat)
        else:
            formatData = event.GetClientData()

        if isinstance(formatData, FormatData):
            self.cmdStart.Enable(formatData.IsOk())
            if formatData.IsMPEG():
                self.__InitProfiles(formatData.GetName().split(" ")[0],
                                    GetMPEGProfiles())
            else:
                self.__InitProfiles()

            if isinstance(formatData.GetData(), MetaBaseRenderer):
                self.cmdRendererProps.Enable(True)
            else:
                self.cmdRendererProps.Enable(False)

        self.__SelectProfileByName(Settings().GetLastProfile())
Example #3
0
    def _OnRender(self, event):  # pylint: disable=unused-argument
        dlg = DlgRender(self, RendererProvider(), Aspect.ASPECT_16_9)
        try:
            if dlg.ShowModal() != wx.ID_OK:
                return

            profile = dlg.GetProfile()
            gstElements = dlg.GetFormatData().GetData()
        finally:
            dlg.Destroy()

        dlg = wx.FileDialog(self, _("Video file"),
                            Settings().GetProjectPath(), "",
                            _("Video files") + " (*.*)|*.*", wx.FD_SAVE)
        try:
            if dlg.ShowModal() == wx.ID_OK:
                self._OnStart(dlg.GetPath(), profile, gstElements)
            else:
                return
        finally:
            dlg.Destroy()
Example #4
0
    def __init__(self, parent, rendererClass):
        self._init_ctrls(parent)
        self.Bind(wx.EVT_CLOSE, self.OnCmdCancelButton)

        self.pnlHdr.SetTitle(_(u'Edit extended output properties'))
        self.pnlHdr.SetBitmap(wx.ArtProvider.GetBitmap('PFS_VIDEO_FORMAT_32'))
        self.rendererClass = rendererClass

        self.lcProps.DeleteAllItems()
        savedProps = Settings().GetRenderProperties(rendererClass.__name__)
        for prop in rendererClass.GetProperties():
            value = savedProps.get(prop.lower(), rendererClass.GetProperty(prop))
            self.lcProps.Append([prop, value])

            rendererClass.SetProperty(prop, value)

        self.SetAffirmativeId(wxID_DLGRENDERERPROPSCMDOK)
        self.SetEscapeId(wxID_DLGRENDERERPROPSCMDCANCEL)
        self.SetInitialSize(self.GetEffectiveMinSize())
        self.CentreOnParent()
        self.SetFocus()
Example #5
0
    def OnProcess(self, wxParent):
        dlg = wx.MessageDialog(
            wxParent,
            _(u"Some images does not exist in the folder '%s' anymore. If the files has moved you can select the new path. Do you want to select a new path?"
              ) % self.__imgPath, _(u"Question"), wx.YES_NO | wx.ICON_QUESTION)
        try:
            if dlg.ShowModal() == wx.ID_NO:
                self.GetJob().SetAltPath(self.__imgPath, self.__imgPath)
                return
        finally:
            dlg.Destroy()

        dlg = wx.DirDialog(wxParent, defaultPath=Settings().GetImagePath())
        try:
            if dlg.ShowModal() == wx.ID_OK:
                path = dlg.GetPath()
                self.GetJob().SetAltPath(self.__imgPath, path)
                return
            else:
                self.Skip()
        finally:
            dlg.Destroy()
Example #6
0
    def Execute(self):
        audioFiles = []
        invalidAudioFiles = []
        audioLength = 0
        for audioFile in self.__photoFilmStrip.GetAudioFiles():
            if CheckFile(audioFile):
                length = GPlayer(audioFile).GetLength()
                if length is None:
                    logging.warning("Invalid audiofile '%s'", audioFile)
                    invalidAudioFiles.append(audioFile)
                else:
                    audioFiles.append(audioFile)
                    logging.debug("Using audiofile '%s' with length: %s",
                                  audioFile, length)
                    audioLength += length
            else:
                logging.warning("Missing audiofile '%s'!", audioFile)

        if len(audioFiles) != len(self.__photoFilmStrip.GetAudioFiles()):
            raise RenderException(
                _("The following audio files are invalid or missing:") +
                "\n\n" + "\n".join(invalidAudioFiles))

        outFile = self._CheckAndGetOutFile()

        self._SaveSettings()

        savedProps = Settings().GetRenderProperties(
            self.__rendererClass.__name__)
        for prop in self.__rendererClass.GetProperties():
            value = savedProps.get(prop.lower(),
                                   self.__rendererClass.GetProperty(prop))
            self.__rendererClass.SetProperty(prop, value)

        totalLength = self.__photoFilmStrip.GetDuration(False)
        if totalLength == -1:
            totalLength = int(round((audioLength + 500) / 1000.0))

        renderer = self.__rendererClass()
        renderer.Init(self.__profile, self.__photoFilmStrip.GetAspect(),
                      outFile)

        renderer.SetAudioFiles(audioFiles)

        if self.__photoFilmStrip.GetTimelapse():
            uxEvent = "RenderTimeLapse"
            renderEngine = RenderEngineTimelapse(
                self.__profile, self.__photoFilmStrip.GetPictures(),
                self.__draftMode)
        else:
            uxEvent = "RenderSlideshow"
            renderEngine = RenderEngineSlideshow(
                self.__profile, self.__photoFilmStrip.GetPictures(),
                self.__draftMode, totalLength)

        name = "%s (%s)" % (self.__photoFilmStrip.GetName(),
                            self.__profile.GetName())

        self.__renderJob = RenderJob(name, renderer, renderEngine.GetTasks())
        self.__renderJob.AddUxEvent(uxEvent)
        self.__renderJob.AddUxEvent(self.__profile.GetName())
Example #7
0
    def _SaveSettings(self):
        settings = Settings()
        settings.SetLastProfile(self.__profile.GetName())

        idxRenderer = RENDERERS.index(self.__rendererClass)
        settings.SetUsedRenderer(idxRenderer)
Example #8
0
 def GetDefault(self):
     settings = Settings()
     if settings.GetUsedRenderer() is None:
         return self.DEFAULT_FORMAT
     else:
         return settings.GetUsedRenderer()
Example #9
0
 def AddFileToHistory(self, filename):
     fileList = Settings().GetFileHistory()
     if filename in fileList:
         fileList.remove(filename)
     fileList.insert(0, filename)
     Settings().SetFileHistory(fileList)
Example #10
0
 def _GetDefaultSaveFolder(self):
     return Settings().GetProjectPath()
Example #11
0
    def __init__(self, parent, project=None):
        wx.Dialog.__init__(self,
                           parent,
                           name=u'DlgProjectProps',
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=_(u'Project properties'))
        self.Bind(wx.EVT_CLOSE, self.OnDlgProjectPropsClose)

        self._InitCtrls(parent)

        self.SetSizeHints(700, 250)
        self.szCtrls.AddGrowableCol(1)

        self.pnlHdr.SetTitle(_(u'PhotoFilmStrip project'))
        self.pnlHdr.SetBitmap(
            wx.ArtProvider.GetBitmap('PFS_ICON_48', wx.ART_TOOLBAR, (32, 32)))

        self.choiceAspect.Append(Aspect.ASPECT_16_9)
        self.choiceAspect.Append(Aspect.ASPECT_4_3)
        self.choiceAspect.Append(Aspect.ASPECT_3_2)
        self.choiceAspect.Select(0)

        self.tcProject.SetMinSize(wx.Size(300, -1))
        self.tcFolder.SetMinSize(wx.Size(300, -1))
        self.choiceAspect.SetMinSize(wx.Size(300, -1))
        self.timeCtrlTotalLength.SetMinSize(wx.Size(300, -1))
        self.lvAudio.SetMinSize(wx.Size(300, -1))

        defTime = wx.DateTime.Now()
        defTime.SetHMS(0, 0, 30)
        minTime = wx.DateTime.Now()
        minTime.SetHMS(0, 0, 1)
        maxTime = wx.DateTime.Now()
        maxTime.SetHMS(1, 59, 59)
        self.timeCtrlTotalLength.SetValue(defTime)
        self.timeCtrlTotalLength.SetMin(minTime)
        self.timeCtrlTotalLength.SetMax(maxTime)
        self.timeCtrlTotalLength.SetLimited(True)

        self.mediaCtrl = None

        self.__project = project

        if project is None:
            projName = _(u"Unnamed PhotoFilmStrip")
            self.tcProject.SetValue(projName)
            self.tcProject.SelectAll()
            self.tcProject.SetFocus()

            projPath = Settings().GetProjectPath()
            if not projPath:
                projPath = os.path.join(wx.GetHomeDir(),
                                        _(u"My PhotoFilmStrips"))
                Settings().SetProjectPath(projPath)
            self.tcFolder.SetValue(projPath)

            self.cbTotalLength.SetValue(False)
            self.rbManual.SetValue(True)
        else:
            projName = os.path.splitext(os.path.basename(
                project.GetFilename()))[0]
            self.tcProject.SetValue(projName)
            self.tcProject.Enable(False)

            self.tcFolder.SetValue(os.path.dirname(project.GetFilename()))
            self.tcFolder.Enable(False)
            self.cmdBrowseFolder.Enable(False)

            self.choiceAspect.SetStringSelection(project.GetAspect())
            self.choiceAspect.Enable(False)

            pfsDur = project.GetDuration(calc=True)
            duration = project.GetDuration(calc=False)
            if project.GetTimelapse():
                self.cbTotalLength.SetValue(True)
                self.rbTimelapse.SetValue(True)
            elif duration is None:
                self.cbTotalLength.SetValue(False)
            elif duration <= 0:
                self.cbTotalLength.SetValue(True)
                self.rbAudio.SetValue(True)
            else:
                self.cbTotalLength.SetValue(True)
                self.rbManual.SetValue(True)
                pfsDur = duration

            pfsDur = int(round(pfsDur))

            dur = wx.DateTime.Now()
            dur.SetHMS(0, pfsDur // 60, pfsDur % 60)
            try:
                self.timeCtrlTotalLength.SetWxDateTime(dur)
            except ValueError:
                # duration is invalid if there are no photos
                pass

            for audioFile in project.GetAudioFiles():
                idx = self.lvAudio.Append(audioFile)
                self.lvAudio.Select(idx)

        self.__ControlStatusTotalLength()
        self.__ControlStatusAudio()

        self.Fit()
        self.CenterOnParent()
        self.SetFocus()