Skip to content

Commit

Permalink
[prefs] Add preference to save in the same folder as the currently lo…
Browse files Browse the repository at this point in the history
…aded video, avoid file name conflicts
  • Loading branch information
eumagga0x2a committed Feb 21, 2017
1 parent 0961222 commit 14daee9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 4 deletions.
12 changes: 10 additions & 2 deletions avidemux/common/ADM_commonUI/DIA_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bool loadDefault=false;
char *alsaDevice=NULL;

bool balternate_mp3_tag=true;
bool lastReadDirAsTarget=false;

uint32_t pp_type=3;
uint32_t pp_value=5;
Expand Down Expand Up @@ -162,6 +163,9 @@ std::string currentSdlDriver=getSdlDriverName();

prefs->get(RESET_ENCODER_ON_VIDEO_LOAD,&loadDefault);

// Make users happy who prefer the output dir to be the same as the input dir
prefs->get(FEATURES_USE_LAST_READ_DIR_AS_TARGET,&lastReadDirAsTarget);

// Multithreads
prefs->get(FEATURES_THREADING_LAVC, &lavcThreads);

Expand Down Expand Up @@ -274,6 +278,8 @@ std::string currentSdlDriver=getSdlDriverName();

diaElemToggle togTagMp3(&balternate_mp3_tag,QT_TRANSLATE_NOOP("adm","_Use alternative tag for MP3 in .mp4"));

diaElemToggle useLastReadAsTarget(&lastReadDirAsTarget,QT_TRANSLATE_NOOP("adm","_Default to the directory of the last read file for saving"));

diaMenuEntry videoMode[]={
{RENDER_GTK, getNativeRendererDesc(0), NULL}
#ifdef USE_XV
Expand Down Expand Up @@ -423,8 +429,8 @@ std::string currentSdlDriver=getSdlDriverName();


/* Output */
diaElem *diaOutput[]={&autoSplit,&openDml,&allowAnyMpeg,&togTagMp3};
diaElemTabs tabOutput(QT_TRANSLATE_NOOP("adm","Output"),4,(diaElem **)diaOutput);
diaElem *diaOutput[]={&autoSplit,&openDml,&allowAnyMpeg,&togTagMp3,&useLastReadAsTarget};
diaElemTabs tabOutput(QT_TRANSLATE_NOOP("adm","Output"),5,(diaElem **)diaOutput);

/* Audio */

Expand Down Expand Up @@ -609,6 +615,8 @@ std::string currentSdlDriver=getSdlDriverName();
prefs->set(FEATURES_LIBVA,blibva);
// Alternate mp3 tag (haali)
prefs->set(FEATURES_ALTERNATE_MP3_TAG,balternate_mp3_tag);
// Make users happy who prefer the output dir to be the same as the input dir
prefs->set(FEATURES_USE_LAST_READ_DIR_AS_TARGET,lastReadDirAsTarget);

prefs->set(DEFAULT_LANGUAGE,std::string(myLanguages[languageIndex].lang));

Expand Down
15 changes: 13 additions & 2 deletions avidemux/qt4/ADM_userInterfaces/ADM_gui/file_qt4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ static void GUI_FileSelSelectWriteInternal(const char *label, const char *ext, c
extSize+=strlen(ext);
}
//printf("Do filer=%d\n",(int)doFilter);
bool lastReadAsTarget=false;
prefs->get(FEATURES_USE_LAST_READ_DIR_AS_TARGET,&lastReadAsTarget);
std::string lastFolder;
admCoreUtils::getLastWriteFolder(lastFolder);
if(!lastFolder.size())
if(!lastReadAsTarget)
admCoreUtils::getLastWriteFolder(lastFolder);
if(!lastFolder.size() || lastReadAsTarget)
admCoreUtils::getLastReadFolder(lastFolder);
if (lastFolder.size())
{
Expand All @@ -73,7 +76,15 @@ static void GUI_FileSelSelectWriteInternal(const char *label, const char *ext, c

/* LASTDIR may have gone; then do nothing and use current dir instead (implied) */
if (!QDir(outputPath).exists())
{
str.clear();
}else
{
if(str==QString::fromUtf8(lastRead.c_str()))
{ // try to avoid name collision when saving in the same directory as the currently loaded video
str = outputPath+separator+inputBaseName+QString("_edit")+outputExt;
}
}
}

if(doFilter)
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/include/prefs2_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ FEATURES_ENABLE_OPENGL, //bool
FEATURES_CAP_REFRESH_ENABLED, //bool
FEATURES_CAP_REFRESH_VALUE, //uint32_t
FEATURES_SDLDRIVER, //string
FEATURES_USE_LAST_READ_DIR_AS_TARGET, //bool
UPDATE_ENABLED, //bool
UPDATE_LASTCHECK, //uint32_t
LASTFILES_LASTDIR_READ, //string
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/src/prefs2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bool:enable_opengl, 0, 0, 1
bool:cap_refresh_enabled, 0, 0, 1
uint32_t:cap_refresh_value, 100, 10, 1000
string:sdlDriver, ""
bool:use_last_read_dir_as_target, 0, 0, 1
}
#
update{
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/src/prefs2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct {
bool cap_refresh_enabled;
uint32_t cap_refresh_value;
std::string sdlDriver;
bool use_last_read_dir_as_target;
}features;
struct {
bool enabled;
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern const ADM_paramList my_prefs_struct_param[]={
{"features.cap_refresh_enabled",offsetof(my_prefs_struct,features.cap_refresh_enabled),"bool",ADM_param_bool},
{"features.cap_refresh_value",offsetof(my_prefs_struct,features.cap_refresh_value),"uint32_t",ADM_param_uint32_t},
{"features.sdlDriver",offsetof(my_prefs_struct,features.sdlDriver),"std::string",ADM_param_stdstring},
{"features.use_last_read_dir_as_target",offsetof(my_prefs_struct,features.use_last_read_dir_as_target),"bool",ADM_param_bool},
{"update.enabled",offsetof(my_prefs_struct,update.enabled),"bool",ADM_param_bool},
{"update.lastCheck",offsetof(my_prefs_struct,update.lastCheck),"uint32_t",ADM_param_uint32_t},
{"lastfiles.lastdir_read",offsetof(my_prefs_struct,lastfiles.lastdir_read),"std::string",ADM_param_stdstring},
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/src/prefs2_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ json.addBool("enable_opengl",key->features.enable_opengl);
json.addBool("cap_refresh_enabled",key->features.cap_refresh_enabled);
json.addUint32("cap_refresh_value",key->features.cap_refresh_value);
json.addString("sdlDriver",key->features.sdlDriver);
json.addBool("use_last_read_dir_as_target",key->features.use_last_read_dir_as_target);
json.endNode();
json.addNode("update");
json.addBool("enabled",key->update.enabled);
Expand Down
1 change: 1 addition & 0 deletions avidemux_core/ADM_coreUtils/src/prefs2_pref.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static optionDesc myOptions[]={
{ FEATURES_CAP_REFRESH_ENABLED,"features.cap_refresh_enabled" ,ADM_param_bool ,"0", 0, 1},
{ FEATURES_CAP_REFRESH_VALUE,"features.cap_refresh_value" ,ADM_param_uint32_t ,"100", 10, 1000},
{ FEATURES_SDLDRIVER,"features.sdlDriver" ,ADM_param_stdstring ,"", 0, 0},
{ FEATURES_USE_LAST_READ_DIR_AS_TARGET,"features.use_last_read_dir_as_target",ADM_param_bool ,"0", 0, 1},
{ UPDATE_ENABLED,"update.enabled" ,ADM_param_bool ,"1", 0, 1},
{ UPDATE_LASTCHECK,"update.lastCheck" ,ADM_param_uint32_t ,"0", 0, 5000},
{ LASTFILES_LASTDIR_READ,"lastfiles.lastdir_read" ,ADM_param_stdstring ,"", 0, 0},
Expand Down

0 comments on commit 14daee9

Please sign in to comment.