1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
/**********************************************************************
Audacity: A Digital Audio Editor
@file FFmpegPrefs.cpp
@brief adds controls for FFmpeg import/export to Library preferences
Paul Licameli split from LibraryPrefs.cpp
**********************************************************************/
#include "../FFmpeg.h"
#include "Internat.h"
#include "ShuttleGui.h"
#include "LibraryPrefs.h"
#include "AudacityMessageBox.h"
#include "HelpSystem.h"
#include "ReadOnlyText.h"
#include <wx/stattext.h>
namespace {
struct State {
wxWindow *parent = nullptr;
ReadOnlyText *FFmpegVersion = nullptr;
};
void OnFFmpegFindButton(State &state);
void SetFFmpegVersionText(State &state)
{
auto FFmpegVersion = state.FFmpegVersion;
FFmpegVersion->SetValue(GetFFmpegVersion());
}
void AddControls( ShuttleGui &S )
{
auto pState = std::make_shared<State>();
pState->parent = S.GetParent();
S.StartStatic(XO("FFmpeg Import/Export Library"));
{
S.StartTwoColumn();
{
auto version =
XO("No compatible FFmpeg library was found");
pState->FFmpegVersion = S
.Position(wxALIGN_CENTRE_VERTICAL)
.AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
S.AddVariableText(XO("FFmpeg Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
auto pFindButton =
S
#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
.Disable()
#endif
.AddButton(XXO("Loca&te..."),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
if (pFindButton)
pFindButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
OnFFmpegFindButton(*pState);
});
S.AddVariableText(XO("FFmpeg Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
auto pDownButton =
S
#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
.Disable()
#endif
.AddButton(XXO("Dow&nload"),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
if (pDownButton)
pDownButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
HelpSystem::ShowHelp(pState->parent,
wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"), true);
});
}
S.EndTwoColumn();
}
S.EndStatic();
SetFFmpegVersionText(*pState);
}
void OnFFmpegFindButton(State &state)
{
bool showerrs =
#if defined(_DEBUG)
true;
#else
false;
#endif
// Load the libs ('true' means that all errors will be shown)
bool locate = !LoadFFmpeg(showerrs);
// Libs are fine, don't show "locate" dialog unless user really wants it
if (!locate) {
int response = AudacityMessageBox(
XO(
"Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
XO("Success"),
wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
if (response == wxYES) {
locate = true;
}
}
if (locate) {
// Show "Locate FFmpeg" dialog
FindFFmpegLibs(state.parent);
LoadFFmpeg(showerrs);
}
SetFFmpegVersionText(state);
}
LibraryPrefs::RegisteredControls reg{ wxT("FFmpeg"), AddControls };
}
|