replaced all unique_ptr.reset calls with std::make_unique

This commit is contained in:
Niall Cooling
2021-03-22 17:56:26 +00:00
parent e5e3fc02b8
commit 8eb947a223
7 changed files with 45 additions and 39 deletions

View File

@@ -56,7 +56,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen1() {
};
return std::unique_ptr<Screen>(new Screens::Tile(0, app, settingsController, applications));
return std::make_unique<Screens::Tile>(0, app, settingsController, applications);
}
std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
@@ -70,7 +70,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
}
};
return std::unique_ptr<Screen>(new Screens::Tile(1, app, settingsController, applications));
return std::make_unique<Screens::Tile>(1, app, settingsController, applications);
}
std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
@@ -84,6 +84,6 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen3() {
}
};
return std::unique_ptr<Screen>(new Screens::Tile(2, app, settingsController, applications));
return std::make_unique<Screens::Tile>(2, app, settingsController, applications);
}

View File

@@ -64,20 +64,20 @@ bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
return std::unique_ptr<Screen>(new Screens::WatchFaceDigital(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, heartRateController));
return std::make_unique<Screens::WatchFaceDigital>(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, heartRateController);
}
std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
return std::unique_ptr<Screen>(new Screens::WatchFaceAnalog(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController));
return std::make_unique<Screens::WatchFaceAnalog>(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
}
/*
// Examples for more watch faces
std::unique_ptr<Screen> Clock::WatchFaceMinimalScreen() {
return std::unique_ptr<Screen>(new Screens::WatchFaceMinimal(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController));
return std::make_unique<Screens::WatchFaceMinimal>(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
}
std::unique_ptr<Screen> Clock::WatchFaceCustomScreen() {
return std::unique_ptr<Screen>(new Screens::WatchFaceCustom(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController));
return std::make_unique<Screens::WatchFaceCustom>(app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
}
*/

View File

@@ -17,22 +17,22 @@ Notifications::Notifications(DisplayApp *app,
auto notification = notificationManager.GetLastNotification();
if(notification.valid) {
currentId = notification.id;
currentItem.reset(new NotificationItem("\nNotification",
currentItem = std::make_unique<NotificationItem>("\nNotification",
notification.message.data(),
notification.index,
notification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
alertNotificationService);
validDisplay = true;
} else {
currentItem.reset(new NotificationItem("\nNotification",
currentItem = std::make_unique<NotificationItem>("\nNotification",
"No notification to display",
0,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
alertNotificationService));
alertNotificationService);
}
if(mode == Modes::Preview) {
@@ -87,13 +87,13 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = previousNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up);
currentItem.reset(new NotificationItem("\nNotification",
currentItem = std::make_unique<NotificationItem>("\nNotification",
previousNotification.message.data(),
previousNotification.index,
previousNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
alertNotificationService);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeDown: {
@@ -109,13 +109,13 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
currentId = nextNotification.id;
currentItem.reset(nullptr);
app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down);
currentItem.reset(new NotificationItem("\nNotification",
currentItem = std::make_unique<NotificationItem>("\nNotification",
nextNotification.message.data(),
nextNotification.index,
nextNotification.category,
notificationManager.NbNotifications(),
mode,
alertNotificationService));
alertNotificationService);
}
return true;
case Pinetime::Applications::TouchEvents::LongTap: {

View File

@@ -104,14 +104,14 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds,
batteryPercent, brightness, resetReason);
return std::unique_ptr<Screen>(new Screens::Label(app, t1));
return std::make_unique<Screens::Label>(app, t1);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
auto& bleAddr = bleController.Address();
sprintf(t2, "BLE MAC: \n %02x:%02x:%02x:%02x:%02x:%02x",
bleAddr[5], bleAddr[4], bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0]);
return std::unique_ptr<Screen>(new Screens::Label(app, t2));
return std::make_unique<Screens::Label>(app, t2);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@@ -123,5 +123,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
"Source code:\n"
"https://github.com/\n"
" JF002/InfiniTime");
return std::unique_ptr<Screen>(new Screens::Label(app, t3));
return std::make_unique<Screens::Label>(app, t3);
}