Skip to content

Commit

Permalink
Add a "Defaults" button to the "Options (Project)" dialog. (WinMerge#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmprm77 authored Aug 3, 2024
1 parent 66eb2b4 commit e96cf11
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,7 @@ FONT 8, FONTNAME, 0, 0, 0x1
BEGIN
LTEXT "Items saved to or restored from the project file:",IDC_STATIC,7,10,270,10
CONTROL "",IDC_PROJECT_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,22,270,76
PUSHBUTTON "Defaults", IDC_COMPARE_DEFAULTS, 191, 228, 88, 14
END

IDD_COMPARE_STATISTICS DIALOGEX 0, 0, 257, 174
Expand Down Expand Up @@ -3177,7 +3178,8 @@ IDD_PROPPAGE_PROJECT AFX_DIALOG_LAYOUT
BEGIN
0,
0, 0, 100, 0,
0, 0, 100, 0
0, 0, 100, 0,
100, 0, 0, 0
END

IDD_PROPPAGE_SYSTEM AFX_DIALOG_LAYOUT
Expand Down
16 changes: 16 additions & 0 deletions Src/OptionsProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,20 @@ bool Get(COptionsMgr* pOptionsMgr, Operation operation, Item item)
return pOptionsMgr->GetBool(name);
}

/**
* @brief Get the default project setting from OptionsMgr.
* @param [in] pOptionsMgr Pointer to OptionsMgr
* @param [in] operation Operation for project files
* @param [in] item Item to save to or restore from the project file
* @return Default project setting
*/
bool GetDefault(COptionsMgr* pOptionsMgr, Operation operation, Item item)
{
if (pOptionsMgr == nullptr)
return false;

String name = strutils::format(_T("%s/%s.%s"), Section, OperationKeyword[static_cast<int>(operation)], ItemKeyword[static_cast<int>(item)]);
return pOptionsMgr->GetDefault<bool>(name);
}

}}
1 change: 1 addition & 0 deletions Src/OptionsProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ void Init(COptionsMgr *pOptionsMgr);
void Load(COptionsMgr *pOptionsMgr, Settings settings);
void Save(COptionsMgr *pOptionsMgr, const Settings& settings);
bool Get(COptionsMgr* pOptionsMgr, Operation operation, Item item);
bool GetDefault(COptionsMgr* pOptionsMgr, Operation operation, Item item);
}}
14 changes: 13 additions & 1 deletion Src/PropProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void PropProject::DoDataExchange(CDataExchange* pDX)

BEGIN_MESSAGE_MAP(PropProject, OptionsPanel)
//{{AFX_MSG_MAP(PropEditor)
// ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

Expand Down Expand Up @@ -91,6 +91,18 @@ BOOL PropProject::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}

/**
* @brief Sets options to defaults
*/
void PropProject::OnDefaults()
{
for (int i = 0; i < Options::Project::OperationCount; i++)
for (int j = 0; j < Options::Project::ItemCount; j++)
m_settings[i][j] = Options::Project::GetDefault(GetOptionsMgr(), static_cast<Options::Project::Operation>(i), static_cast<Options::Project::Item>(j));

UpdateData(FALSE);
}

/**
* @brief Initialize listcontrol containing project settings.
*/
Expand Down
1 change: 1 addition & 0 deletions Src/PropProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PropProject : public OptionsPanel
// Generated message map functions
//{{AFX_MSG(PropEditor)
afx_msg BOOL OnInitDialog() override;
afx_msg void OnDefaults();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

0 comments on commit e96cf11

Please sign in to comment.