diff --git a/Source/Common/Preferences.cpp b/Source/Common/Preferences.cpp index 782db618e3..dbf9d29f0e 100644 --- a/Source/Common/Preferences.cpp +++ b/Source/Common/Preferences.cpp @@ -267,6 +267,8 @@ int Preferences::Config_Save() if (Config(__T("ShellExtension_Folder")).empty()) Config(__T("ShellExtension_Folder"))=__T("1"); if (Config(__T("ShellInfoTip")).empty()) Config(__T("ShellInfoTip"))=__T("0"); if (Config(__T("ShowToolBar")).empty()) Config(__T("ShowToolBar"))=__T("1"); + if (Config(__T("RememberWindowPosition")).empty()) Config(__T("RememberWindowPosition"))=__T("0"); + if (Config(__T("RememberWindowDimensions")).empty()) Config(__T("RememberWindowDimensions"))=__T("1"); if (Config(__T("ShowMenu")).empty()) Config(__T("ShowMenu"))=__T("1"); if (Config(__T("CloseAllAuto")).empty()) Config(__T("CloseAllAuto"))=__T("1"); if (Config(__T("FirstInstall")).empty()) Config(__T("FirstInstall")).From_Number((int64u)time(NULL)); diff --git a/Source/GUI/VCL/GUI_Main.cpp b/Source/GUI/VCL/GUI_Main.cpp index 82c297a2d2..4b87e9df91 100644 --- a/Source/GUI/VCL/GUI_Main.cpp +++ b/Source/GUI/VCL/GUI_Main.cpp @@ -6,6 +6,7 @@ //--------------------------------------------------------------------------- #include +#include #pragma hdrstop #include "GUI/VCL/GUI_Main.h" #ifndef MEDIAINFOGUI_PREFS_NO @@ -494,21 +495,71 @@ void __fastcall TMainF::GUI_Configure() //Translation Translate(); - //Set window size - float ScaledScreenWidth=Screen->Width/ScaleFactor; - float ScaledScreenHeight=Screen->Height/ScaleFactor; - Width=500; - Height=400; - if (ScaledScreenWidth>=1024) - Width=700; - if (ScaledScreenWidth>=1280) - Width=830; - if (ScaledScreenHeight>=768) - Height=500; - if (ScaledScreenHeight>=1024) - Height=600; - Width*=ScaleFactor; - Height*=ScaleFactor; + //Set window bounds + if (Prefs->Config(__T("RememberWindowDimensions")) == __T("1")) { + + // Loading dimensions + int nPrefWidth = Width; + int nPrefHeight = Height; + + if (Prefs->Config(__T("FormWidth")).IsNumber()) + nPrefWidth = Prefs->Config(__T("FormWidth")).To_int32s(); + if (Prefs->Config(__T("FormHeight")).IsNumber()) + nPrefHeight = Prefs->Config(__T("FormHeight")).To_int32s(); + + nPrefWidth = Min(Monitor->WorkareaRect.Width(), nPrefWidth); + nPrefHeight = Min(Monitor->WorkareaRect.Height(), nPrefHeight); + + SetBounds(Left, Top, nPrefWidth, nPrefHeight); + + } + else { + + // Default dimensions + float fpUnscaledMonitorWidth = Monitor->Width / ScaleFactor; + float fpUnscaledMonitorHeight = Monitor->Height / ScaleFactor; + + Width=500; + Height=400; + if (fpUnscaledMonitorWidth>=1024) + Width=700; + if (fpUnscaledMonitorWidth>=1280) + Width=830; + if (fpUnscaledMonitorHeight>=768) + Height=500; + if (fpUnscaledMonitorHeight>=1024) + Height=600; + if (fpUnscaledMonitorHeight>=1440) + Height=900; + Width *= ScaleFactor; + Height *= ScaleFactor; + + } + if (Prefs->Config(__T("RememberWindowPosition")) == __T("1")) { + + // Loading position + int nPrefTop = 0; + int nPrefLeft = 0; + + if (Prefs->Config(__T("FormTop")).IsNumber()) + nPrefTop = Prefs->Config(__T("FormTop")).To_int32s(); + if (Prefs->Config(__T("FormLeft")).IsNumber()) + nPrefLeft = Prefs->Config(__T("FormLeft")).To_int32s(); + + nPrefTop = Max(nPrefTop, 0); + nPrefTop = Min(nPrefTop, Monitor->WorkareaRect.Height() - Height); + nPrefLeft = Max(nPrefLeft, 0); + nPrefLeft = Min(nPrefLeft, Monitor->WorkareaRect.Width() - Width); + SetBounds(nPrefLeft, nPrefTop, Width, Height); + + Position = poDesigned; + + } + else { + // Default position + Position = poScreenCenter; + } + } //--------------------------------------------------------------------------- @@ -518,6 +569,21 @@ void __fastcall TMainF::FormClose(TObject *Sender, TCloseAction &Action) if (FileName_Temp!=__T("")) File::Delete(FileName_Temp); + bool bCallPrefsSave = false; + if (Prefs->Config(__T("RememberWindowPosition")) == __T("1")) { + Prefs->Config(__T("FormTop")).From_Number((int)this->Top); + Prefs->Config(__T("FormLeft")).From_Number((int)this->Left); + bCallPrefsSave = true; + } + if (Prefs->Config(__T("RememberWindowDimensions")) == __T("1")) { + Prefs->Config(__T("FormWidth")).From_Number((int)this->Width); + Prefs->Config(__T("FormHeight")).From_Number((int)this->Height); + bCallPrefsSave = true; + } + + if (bCallPrefsSave) + Prefs->Config.Save(); + //The form is closed and all allocated memory for the form is freed. Action = caFree; } diff --git a/Source/GUI/VCL/GUI_Preferences.cpp b/Source/GUI/VCL/GUI_Preferences.cpp index 0c50c62a0f..c9fe9d0408 100644 --- a/Source/GUI/VCL/GUI_Preferences.cpp +++ b/Source/GUI/VCL/GUI_Preferences.cpp @@ -410,6 +410,18 @@ void __fastcall TPreferencesF::CB_InfoTipClick(TObject *Sender) Prefs->Config(__T("ShellInfoTip"), 1)=__T("0"); } +//--------------------------------------------------------------------------- +void __fastcall TPreferencesF::CB_RememberWindowPositionClickClick(TObject *Sender) +{ + Prefs->Config(__T("RememberWindowPosition"), 1) = CB_RememberWindowPosition->Checked ? __T("1") : __T("0"); +} +//--------------------------------------------------------------------------- + +void __fastcall TPreferencesF::CB_RememberWindowDimensionsClickClick(TObject *Sender) +{ + Prefs->Config(__T("RememberWindowDimensions"), 1) = CB_RememberWindowDimensions->Checked ? __T("1") : __T("0"); +} + //--------------------------------------------------------------------------- void __fastcall TPreferencesF::CB_ShowToolBarClick(TObject *Sender) { @@ -668,6 +680,8 @@ void __fastcall TPreferencesF::Setup_GeneralShow(TObject *Sender) //--------------------------------------------------------------------------- void __fastcall TPreferencesF::Setup_AdvancedShow(TObject *Sender) { + CB_RememberWindowPosition->Checked=Prefs->Config(__T("RememberWindowPosition")).To_int32s(); + CB_RememberWindowDimensions->Checked=Prefs->Config(__T("RememberWindowDimensions")).To_int32s(); CB_ShowToolBar->Checked=Prefs->Config(__T("ShowToolBar")).To_int32s(); CB_ShowMenu->Checked=Prefs->Config(__T("ShowMenu")).To_int32s(); Advanced_CloseAllAuto->Checked=Prefs->Config(__T("CloseAllAuto")).To_int32s(); diff --git a/Source/GUI/VCL/GUI_Preferences.dfm b/Source/GUI/VCL/GUI_Preferences.dfm index 191aac4bb8..688a63a927 100644 --- a/Source/GUI/VCL/GUI_Preferences.dfm +++ b/Source/GUI/VCL/GUI_Preferences.dfm @@ -4,7 +4,7 @@ object PreferencesF: TPreferencesF BorderIcons = [] BorderStyle = bsDialog Caption = 'Preferences' - ClientHeight = 225 + ClientHeight = 256 ClientWidth = 850 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -14,12 +14,16 @@ object PreferencesF: TPreferencesF Font.Style = [] Position = poOwnerFormCenter OnShow = FormShow + DesignSize = ( + 850 + 256) TextHeight = 14 object OK: TButton Left = 720 - Top = 192 + Top = 223 Width = 122 Height = 27 + Anchors = [akRight, akBottom] Caption = 'OK' Default = True ModalResult = 1 @@ -30,7 +34,8 @@ object PreferencesF: TPreferencesF Left = 0 Top = 0 Width = 176 - Height = 184 + Height = 215 + Anchors = [akLeft, akTop, akRight, akBottom] Indent = 19 ParentShowHint = False ReadOnly = True @@ -38,25 +43,27 @@ object PreferencesF: TPreferencesF TabOrder = 1 OnChange = TreeChange Items.NodeData = { - 0302000000280000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000 - 00010000000105530065007400750070002E0000000000000000000000FFFFFF - FFFFFFFFFFFFFFFFFF0000000000000000010841006400760061006E00630065 - 006400300000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF0000000005 - 000000010943007500730074006F006D0069007A006500280000000000000000 - 000000FFFFFFFFFFFFFFFFFFFFFFFF0000000000000000010553006800650065 - 007400340000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF0000000000 - 000000010B540072006500650020002600200054006500780074003400000000 - 00000000000000FFFFFFFFFFFFFFFFFFFFFFFF0000000000000000010B430075 - 00730074006F006D0020007400650078007400280000000000000000000000FF - FFFFFFFFFFFFFFFFFFFFFF00000000000000000105470072006100700068002E - 0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000001 - 084C0061006E0067007500610067006500} + 070200000009540054007200650065004E006F00640065002900000000000000 + 00000000FFFFFFFFFFFFFFFFFFFFFFFF00000000000100000001055300650074 + 007500700000002F0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF00 + 0000000000000000010841006400760061006E00630065006400000031000000 + 0000000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000000005000000010943 + 007500730074006F006D0069007A0065000000290000000000000000000000FF + FFFFFFFFFFFFFFFFFFFFFF000000000000000000010553006800650065007400 + 0000350000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000 + 000000010B540072006500650020002600200054006500780074000000350000 + 000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000010B + 43007500730074006F006D002000740065007800740000002900000000000000 + 00000000FFFFFFFFFFFFFFFFFFFFFFFF00000000000000000001054700720061 + 007000680000002F0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF00 + 000000000000000001084C0061006E0067007500610067006500} end object Cancel: TButton Left = 593 - Top = 192 + Top = 223 Width = 121 Height = 27 + Anchors = [akRight, akBottom] Cancel = True Caption = 'Cancel' ModalResult = 2 @@ -66,8 +73,9 @@ object PreferencesF: TPreferencesF Left = 176 Top = 0 Width = 666 - Height = 186 - ActivePage = Setup + Height = 217 + ActivePage = Setup_Advanced + Anchors = [akLeft, akTop, akRight, akBottom] MultiLine = True TabHeight = 22 TabOrder = 3 @@ -202,7 +210,7 @@ object PreferencesF: TPreferencesF OnShow = Setup_AdvancedShow object Advanced_DisplayCaptions_Caption: TLabel Left = 2 - Top = 125 + Top = 158 Width = 141 Height = 14 Caption = 'Handling of 608/708 streams:' @@ -218,11 +226,11 @@ object PreferencesF: TPreferencesF end object Advanced_CloseAllAuto: TCheckBox Left = 2 - Top = 34 + Top = 65 Width = 658 Height = 18 Caption = 'Close all before open' - TabOrder = 5 + TabOrder = 6 OnClick = Advanced_CloseAllAutoClick end object CB_ShowMenu: TCheckBox @@ -236,34 +244,34 @@ object PreferencesF: TPreferencesF end object Advanced_InformVersion: TCheckBox Left = 2 - Top = 51 + Top = 81 Width = 658 Height = 18 Caption = 'Add version to text output' - TabOrder = 3 + TabOrder = 4 OnClick = Advanced_InformVersionClick end object Advanced_InformTimestamp: TCheckBox Left = 2 - Top = 68 + Top = 97 Width = 658 Height = 18 Caption = 'Add creation date to text output' - TabOrder = 6 + TabOrder = 7 OnClick = Advanced_InformTimestampClick end object Advanced_EnableFfmpeg: TCheckBox Left = 2 - Top = 85 + Top = 113 Width = 658 Height = 18 Caption = 'Enable FFmpeg plugin' - TabOrder = 4 + TabOrder = 5 OnClick = Advanced_EnableFfmpegClick end object Advanced_DisplayCaptions_Sel: TComboBox Left = 303 - Top = 122 + Top = 154 Width = 352 Height = 22 Style = csDropDownList @@ -277,13 +285,31 @@ object PreferencesF: TPreferencesF end object Advanced_LegacyStreamDisplay: TCheckBox Left = 2 - Top = 102 + Top = 129 Width = 658 Height = 18 Caption = 'LegacyStreamDisplay' - TabOrder = 7 + TabOrder = 8 OnClick = Advanced_LegacyStreamDisplayClick end + object CB_RememberWindowPosition: TCheckBox + Left = 2 + Top = 33 + Width = 279 + Height = 17 + Caption = 'Remember window position' + TabOrder = 9 + OnClick = CB_RememberWindowPositionClickClick + end + object CB_RememberWindowDimensions: TCheckBox + Left = 2 + Top = 49 + Width = 279 + Height = 17 + Caption = 'Remember window dimensions' + TabOrder = 3 + OnClick = CB_RememberWindowDimensionsClickClick + end end object Customize_Language: TTabSheet Caption = 'Language' diff --git a/Source/GUI/VCL/GUI_Preferences.h b/Source/GUI/VCL/GUI_Preferences.h index 5fad8590fa..5494c3a787 100644 --- a/Source/GUI/VCL/GUI_Preferences.h +++ b/Source/GUI/VCL/GUI_Preferences.h @@ -77,6 +77,8 @@ class TPreferencesF : public TForm TCheckBox *Advanced_LegacyStreamDisplay; TCheckBox *CB_InscrireShell_SeparateInstance; TCheckBox *CB_InscrireShell_RetainLegacy; + TCheckBox *CB_RememberWindowPosition; + TCheckBox *CB_RememberWindowDimensions; void __fastcall General_Language_SelChange(TObject *Sender); void __fastcall General_Output_SelChange(TObject *Sender); void __fastcall Custom_EditClick(TObject *Sender); @@ -117,6 +119,8 @@ class TPreferencesF : public TForm void __fastcall CB_InscrireShell_FolderClick(TObject *Sender); void __fastcall Advanced_LegacyStreamDisplayClick(TObject *Sender); void __fastcall CB_InscrireShell_RetainLegacyClick(TObject *Sender); + void __fastcall CB_RememberWindowPositionClickClick(TObject *Sender); + void __fastcall CB_RememberWindowDimensionsClickClick(TObject *Sender); private: // User declarations public: // User declarations __fastcall TPreferencesF(TComponent* Owner);