mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Modernized unique pointer construction (#6982)
This commit is contained in:
@@ -309,7 +309,7 @@ ComboBox KeyDropDownControl::GetComboBox()
|
|||||||
// Function to add a drop down to the shortcut stack panel
|
// Function to add a drop down to the shortcut stack panel
|
||||||
void KeyDropDownControl::AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow, bool ignoreWarning)
|
void KeyDropDownControl::AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const int colIndex, RemapBuffer& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects, TextBox targetApp, bool isHybridControl, bool isSingleKeyWindow, bool ignoreWarning)
|
||||||
{
|
{
|
||||||
keyDropDownControlObjects.push_back(std::move(std::unique_ptr<KeyDropDownControl>(new KeyDropDownControl(true, ignoreWarning, colIndex == 1))));
|
keyDropDownControlObjects.emplace_back(std::make_unique<KeyDropDownControl>(true, ignoreWarning, colIndex == 1));
|
||||||
parent.Children().Append(keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->GetComboBox());
|
parent.Children().Append(keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->GetComboBox());
|
||||||
keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->SetSelectionHandler(table, shortcutControl, parent, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow);
|
keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->SetSelectionHandler(table, shortcutControl, parent, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow);
|
||||||
parent.UpdateLayout();
|
parent.UpdateLayout();
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void ShortcutControl::AddNewShortcutControlRow(Grid& parent, std::vector<std::ve
|
|||||||
|
|
||||||
// Create new ShortcutControl objects dynamically so that we does not get destructed
|
// Create new ShortcutControl objects dynamically so that we does not get destructed
|
||||||
std::vector<std::unique_ptr<ShortcutControl>> newrow;
|
std::vector<std::unique_ptr<ShortcutControl>> newrow;
|
||||||
newrow.push_back(std::move(std::unique_ptr<ShortcutControl>(new ShortcutControl(parent, 0, targetAppTextBox))));
|
newrow.emplace_back(std::make_unique<ShortcutControl>(parent, 0, targetAppTextBox));
|
||||||
newrow.push_back(std::move(std::unique_ptr<ShortcutControl>(new ShortcutControl(parent, 1, targetAppTextBox))));
|
newrow.emplace_back(std::make_unique<ShortcutControl>(parent, 1, targetAppTextBox));
|
||||||
keyboardRemapControlObjects.push_back(std::move(newrow));
|
keyboardRemapControlObjects.push_back(std::move(newrow));
|
||||||
|
|
||||||
// Add to grid
|
// Add to grid
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ SingleKeyRemapControl::SingleKeyRemapControl(Grid table, const int colIndex)
|
|||||||
// Key column
|
// Key column
|
||||||
if (colIndex == 0)
|
if (colIndex == 0)
|
||||||
{
|
{
|
||||||
keyDropDownControlObjects.push_back(std::move(std::unique_ptr<KeyDropDownControl>(new KeyDropDownControl(false))));
|
keyDropDownControlObjects.emplace_back(std::make_unique<KeyDropDownControl>(false));
|
||||||
singleKeyRemapControlLayout.as<StackPanel>().Children().Append(keyDropDownControlObjects[0]->GetComboBox());
|
singleKeyRemapControlLayout.as<StackPanel>().Children().Append(keyDropDownControlObjects[0]->GetComboBox());
|
||||||
// Set selection handler for the drop down
|
// Set selection handler for the drop down
|
||||||
keyDropDownControlObjects[0]->SetSelectionHandler(table, singleKeyRemapControlLayout.as<StackPanel>(), colIndex, singleKeyRemapBuffer);
|
keyDropDownControlObjects[0]->SetSelectionHandler(table, singleKeyRemapControlLayout.as<StackPanel>(), colIndex, singleKeyRemapBuffer);
|
||||||
@@ -76,8 +76,8 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(Grid& parent, std::vector<s
|
|||||||
{
|
{
|
||||||
// Create new SingleKeyRemapControl objects dynamically so that we does not get destructed
|
// Create new SingleKeyRemapControl objects dynamically so that we does not get destructed
|
||||||
std::vector<std::unique_ptr<SingleKeyRemapControl>> newrow;
|
std::vector<std::unique_ptr<SingleKeyRemapControl>> newrow;
|
||||||
newrow.push_back(std::move(std::unique_ptr<SingleKeyRemapControl>(new SingleKeyRemapControl(parent, 0))));
|
newrow.emplace_back(std::make_unique<SingleKeyRemapControl>(parent, 0));
|
||||||
newrow.push_back(std::move(std::unique_ptr<SingleKeyRemapControl>(new SingleKeyRemapControl(parent, 1))));
|
newrow.emplace_back(std::make_unique<SingleKeyRemapControl>(parent, 1));
|
||||||
keyboardRemapControlObjects.push_back(std::move(newrow));
|
keyboardRemapControlObjects.push_back(std::move(newrow));
|
||||||
|
|
||||||
// Add to grid
|
// Add to grid
|
||||||
|
|||||||
Reference in New Issue
Block a user