[obsolete] Add a preference setting to abstain from resizing the main window

Started by eumagga0x2a, October 14, 2016, 05:33:14 PM

Previous topic - Next topic

eumagga0x2a

The following patch adds a preference setting which controls whether the size of the video widget should influence the size of the main window (the default is to keep the current behaviour i.e. to resize the main window). Disabling resizing will become more useful once saving the size of Avidemux window on exit gets implemented, this is just a small first step.

diff --git a/avidemux/common/ADM_commonUI/DIA_prefs.cpp b/avidemux/common/ADM_commonUI/DIA_prefs.cpp
index 24ecdb1..f980473 100644
--- a/avidemux/common/ADM_commonUI/DIA_prefs.cpp
+++ b/avidemux/common/ADM_commonUI/DIA_prefs.cpp
@@ -63,6 +63,7 @@ uint32_t msglevel=2;
uint32_t mixer=0;
bool     doAutoUpdate=false;
bool     loadDefault=false;
+bool     resizeWindow=true;
char     *alsaDevice=NULL;

bool     balternate_mp3_tag=true;
@@ -163,6 +164,8 @@ std::string currentSdlDriver=getSdlDriverName();

         prefs->get(RESET_ENCODER_ON_VIDEO_LOAD,&loadDefault);

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

@@ -239,6 +242,7 @@ std::string currentSdlDriver=getSdlDriverName();
         diaElemToggle allowAnyMpeg(&mpeg_no_limit,QT_TRANSLATE_NOOP("adm","_Accept non-standard audio frequency for DVD"));
         diaElemToggle openDml(&use_odml,QT_TRANSLATE_NOOP("adm","Create _OpenDML files"));
         diaElemToggle resetEncoder(&loadDefault,QT_TRANSLATE_NOOP("adm","_Revert to saved default output settings on video load"));
+        diaElemToggle resizeMainWindow(&resizeWindow,QT_TRANSLATE_NOOP("adm","Resize the _window based on video dimensions and zoom level"));
         diaElemToggle checkForUpdate(&doAutoUpdate,QT_TRANSLATE_NOOP("adm","_Check for new release"));


@@ -437,8 +441,8 @@ std::string currentSdlDriver=getSdlDriverName();


         /* User Interface */
-        diaElem *diaUser[]={&useSysTray,&menuMessage,&menuLanguage,&resetEncoder,&checkForUpdate};
-        diaElemTabs tabUser(QT_TRANSLATE_NOOP("adm","User Interface"),5,diaUser);
+        diaElem *diaUser[]={&useSysTray,&menuMessage,&menuLanguage,&resetEncoder,&resizeMainWindow,&checkForUpdate};
+        diaElemTabs tabUser(QT_TRANSLATE_NOOP("adm","User Interface"),6,diaUser);

          /* Automation */

@@ -598,6 +602,8 @@ std::string currentSdlDriver=getSdlDriverName();
             prefs->set(FEATURES_USE_SYSTRAY,useTray);
             // Discard changes to output config on video load
             prefs->set(RESET_ENCODER_ON_VIDEO_LOAD, loadDefault);
+            // Resize the main window according to video dimensions and zoom level
+            prefs->set(RESIZE_MAIN_WINDOW, resizeWindow);

             // VDPAU
             prefs->set(FEATURES_VDPAU,bvdpau);
diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/T_preview.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/T_preview.cpp
index b0081cd..d004307 100644
--- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/T_preview.cpp
+++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/T_preview.cpp
@@ -45,6 +45,7 @@ extern "C"
#include "../ADM_render/GUI_render.h"
#include "../ADM_render/GUI_accelRender.h"
#include "DIA_coreToolkit.h"
+#include "prefs.h"
     
void UI_QT4VideoWidget(QFrame *host);
static uint8_t *lastImage=NULL;
@@ -166,8 +167,15 @@ void  UI_updateDrawWindowSize(void *win,uint32_t w,uint32_t h)
displayW = w;
displayH = h;

-    videoWindow->setADMSize(w,h);   
-    QuiMainWindows->resize(w+218,h+100);
+    bool resizeWindow;
+    if(!prefs->get(RESIZE_MAIN_WINDOW, &resizeWindow)) resizeWindow=true;
+    if(resizeWindow)
+    {
+        uint16_t extra_w=240; // width of the codec widget in px; not sufficient depending on translation and theme
+        uint16_t extra_h=240; // height of the navigation widget in px
+        QuiMainWindows->resize(w+extra_w,h+extra_h);
+    }
+    videoWindow->setADMSize(w,h);
#if 0

UI_purge();
diff --git a/avidemux_core/ADM_coreUtils/include/prefs2_list.h b/avidemux_core/ADM_coreUtils/include/prefs2_list.h
index 9724e81..0ff9fda 100644
--- a/avidemux_core/ADM_coreUtils/include/prefs2_list.h
+++ b/avidemux_core/ADM_coreUtils/include/prefs2_list.h
@@ -48,3 +48,4 @@ AVISYNTH_AVISYNTH_ALWAYS_ASK, //bool
AVISYNTH_AVISYNTH_DEFAULTPORT, //uint32_t
AVISYNTH_AVISYNTH_LOCALPORT, //uint32_t
RESET_ENCODER_ON_VIDEO_LOAD, //bool
+RESIZE_MAIN_WINDOW, //bool
diff --git a/avidemux_core/ADM_coreUtils/src/prefs2.conf b/avidemux_core/ADM_coreUtils/src/prefs2.conf
index bfd3cc9..07e322b 100644
--- a/avidemux_core/ADM_coreUtils/src/prefs2.conf
+++ b/avidemux_core/ADM_coreUtils/src/prefs2.conf
@@ -92,5 +92,7 @@ uint32_t:avisynth_localport,         0,         1024, 65535
#
bool:reset_encoder_on_video_load,       0,      0,      1
#
+bool:resize_main_window,                1,      0,      1
+#
}
#
diff --git a/avidemux_core/ADM_coreUtils/src/prefs2.h b/avidemux_core/ADM_coreUtils/src/prefs2.h
index a6d484a..bcac658 100644
--- a/avidemux_core/ADM_coreUtils/src/prefs2.h
+++ b/avidemux_core/ADM_coreUtils/src/prefs2.h
@@ -70,4 +70,5 @@ struct  {
uint32_t avisynth_localport;
}avisynth;
bool reset_encoder_on_video_load;
+bool resize_main_window;
}my_prefs_struct;
diff --git a/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp b/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp
index c0b11ec..7232db4 100644
--- a/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp
+++ b/avidemux_core/ADM_coreUtils/src/prefs2_desc.cpp
@@ -50,5 +50,6 @@ extern const ADM_paramList my_prefs_struct_param[]={
  {"avisynth.avisynth_defaultport",offsetof(my_prefs_struct,avisynth.avisynth_defaultport),"uint32_t",ADM_param_uint32_t},
  {"avisynth.avisynth_localport",offsetof(my_prefs_struct,avisynth.avisynth_localport),"uint32_t",ADM_param_uint32_t},
  {"reset_encoder_on_video_load",offsetof(my_prefs_struct,reset_encoder_on_video_load),"bool",ADM_param_bool},
+ {"resize_main_window",offsetof(my_prefs_struct,resize_main_window),"bool",ADM_param_bool},
{NULL,0,NULL}
};
diff --git a/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp b/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp
index 19a1ce2..c184299 100644
--- a/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp
+++ b/avidemux_core/ADM_coreUtils/src/prefs2_json.cpp
@@ -73,6 +73,7 @@ json.addUint32("avisynth_defaultport",key->avisynth.avisynth_defaultport);
json.addUint32("avisynth_localport",key->avisynth.avisynth_localport);
json.endNode();
json.addBool("reset_encoder_on_video_load",key->reset_encoder_on_video_load);
+json.addBool("resize_main_window",key->resize_main_window);
return json.dumpToFile(file);
};
bool  my_prefs_struct_jdeserialize(const char *file, const ADM_paramList *tmpl,my_prefs_struct *key){
diff --git a/avidemux_core/ADM_coreUtils/src/prefs2_pref.h b/avidemux_core/ADM_coreUtils/src/prefs2_pref.h
index f785914..a05fed5 100644
--- a/avidemux_core/ADM_coreUtils/src/prefs2_pref.h
+++ b/avidemux_core/ADM_coreUtils/src/prefs2_pref.h
@@ -61,5 +61,6 @@ static optionDesc myOptions[]={
{ AVISYNTH_AVISYNTH_DEFAULTPORT,"avisynth.avisynth_defaultport"       ,ADM_param_uint32_t ,"9999", 1024, 65535},
{ AVISYNTH_AVISYNTH_LOCALPORT,"avisynth.avisynth_localport"           ,ADM_param_uint32_t ,"0", 1024, 65535},
{ RESET_ENCODER_ON_VIDEO_LOAD,"reset_encoder_on_video_load"           ,ADM_param_bool    ,"0", 0, 1},
+{ RESIZE_MAIN_WINDOW,"resize_main_window"                             ,ADM_param_bool    ,"1", 0, 1},
};

eumagga0x2a

Please scratch the patch above, there is a simple way to mostly fix Qt5: the content of a maximized window "unmaximises" on video start for loading or closing video without introducing a sort of an unfeature. I'll open a new topic for that.