Use std::make_unique
This commit is contained in:
parent
99ba2c2e8b
commit
ed09627fdb
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
|
@ -281,7 +283,7 @@ void CollectionFilterWidget::SaveGroupBy() {
|
|||
void CollectionFilterWidget::ShowGroupingManager() {
|
||||
|
||||
if (!groupings_manager_) {
|
||||
groupings_manager_.reset(new SavedGroupingManager);
|
||||
groupings_manager_ = std::make_unique<SavedGroupingManager>();
|
||||
}
|
||||
groupings_manager_->SetFilter(this);
|
||||
groupings_manager_->UpdateModel();
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QAbstractItemView>
|
||||
|
@ -566,7 +568,7 @@ SongList CollectionView::GetSelectedSongs() const {
|
|||
void CollectionView::Organize() {
|
||||
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), app_->collection_backend(), this));
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), app_->collection_backend(), this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
|
@ -584,7 +586,7 @@ void CollectionView::Organize() {
|
|||
void CollectionView::EditTracks() {
|
||||
|
||||
if (!edit_tag_dialog_) {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(app_, this));
|
||||
edit_tag_dialog_ = std::make_unique<EditTagDialog>(app_, this);
|
||||
QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
}
|
||||
const SongList songs = GetSelectedSongs();
|
||||
|
@ -606,8 +608,9 @@ void CollectionView::RescanSongs() {
|
|||
void CollectionView::CopyToDevice() {
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
if (!organize_dialog_)
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||
organize_dialog_->SetCopy(true);
|
||||
|
|
|
@ -193,7 +193,7 @@ void ContextAlbum::SearchCoverInProgress() {
|
|||
downloading_covers_ = true;
|
||||
|
||||
// Show a spinner animation
|
||||
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
|
||||
spinner_animation_ = std::make_unique<QMovie>(":/pictures/spinner.gif", QByteArray(), this);
|
||||
QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &ContextAlbum::Update);
|
||||
spinner_animation_->start();
|
||||
update();
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <qcoreevent.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
|
@ -381,8 +383,9 @@ SongList ContextAlbumsView::GetSelectedSongs() const {
|
|||
|
||||
void ContextAlbumsView::Organize() {
|
||||
|
||||
if (!organize_dialog_)
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), app_->collection_backend(), this));
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), app_->collection_backend(), this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
organize_dialog_->SetCopy(false);
|
||||
|
@ -397,7 +400,7 @@ void ContextAlbumsView::Organize() {
|
|||
void ContextAlbumsView::EditTracks() {
|
||||
|
||||
if (!edit_tag_dialog_) {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(app_, this));
|
||||
edit_tag_dialog_ = std::make_unique<EditTagDialog>(app_, this);
|
||||
}
|
||||
edit_tag_dialog_->SetSongs(GetSelectedSongs());
|
||||
edit_tag_dialog_->show();
|
||||
|
@ -406,8 +409,9 @@ void ContextAlbumsView::EditTracks() {
|
|||
|
||||
void ContextAlbumsView::CopyToDevice() {
|
||||
#ifndef Q_OS_WIN
|
||||
if (!organize_dialog_)
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||
organize_dialog_->SetCopy(true);
|
||||
|
|
|
@ -2863,8 +2863,8 @@ void MainWindow::AutoCompleteTags() {
|
|||
|
||||
// Create the tag fetching stuff if it hasn't been already
|
||||
if (!tag_fetcher_) {
|
||||
tag_fetcher_.reset(new TagFetcher);
|
||||
track_selection_dialog_.reset(new TrackSelectionDialog);
|
||||
tag_fetcher_ = std::make_unique<TagFetcher>();
|
||||
track_selection_dialog_ = std::make_unique<TrackSelectionDialog>();
|
||||
track_selection_dialog_->set_save_on_close(true);
|
||||
|
||||
QObject::connect(tag_fetcher_.get(), &TagFetcher::ResultAvailable, track_selection_dialog_.get(), &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection);
|
||||
|
|
|
@ -127,7 +127,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
|||
#ifdef HAVE_VLC
|
||||
case Engine::VLC:
|
||||
use_enginetype=Engine::VLC;
|
||||
engine_.reset(new VLCEngine(app_->task_manager()));
|
||||
engine_ = std::make_unique<VLCEngine>(app_->task_manager());
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
|
@ -78,7 +80,7 @@ void CurrentAlbumCoverLoader::TempAlbumCoverLoaded(const quint64 id, AlbumCoverL
|
|||
id_ = 0;
|
||||
|
||||
if (!result.album_cover.image.isNull()) {
|
||||
temp_cover_.reset(new QTemporaryFile(temp_file_pattern_));
|
||||
temp_cover_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_->setAutoRemove(true);
|
||||
if (temp_cover_->open()) {
|
||||
if (result.album_cover.image.save(temp_cover_->fileName(), "JPEG")) {
|
||||
|
@ -95,7 +97,7 @@ void CurrentAlbumCoverLoader::TempAlbumCoverLoaded(const quint64 id, AlbumCoverL
|
|||
|
||||
QUrl thumbnail_url;
|
||||
if (!result.image_thumbnail.isNull()) {
|
||||
temp_cover_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_));
|
||||
temp_cover_thumbnail_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_thumbnail_->setAutoRemove(true);
|
||||
if (temp_cover_thumbnail_->open()) {
|
||||
if (result.image_thumbnail.save(temp_cover_thumbnail_->fileName(), "JPEG")) {
|
||||
|
|
|
@ -222,7 +222,7 @@ void DeviceView::SetApplication(Application *app) {
|
|||
|
||||
properties_dialog_->SetDeviceManager(app_->device_manager());
|
||||
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <memory>
|
||||
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/song.h"
|
||||
|
@ -61,7 +62,7 @@ void MtpLoader::LoadDatabase() {
|
|||
|
||||
bool MtpLoader::TryLoad() {
|
||||
|
||||
connection_.reset(new MtpConnection(url_));
|
||||
connection_ = std::make_unique<MtpConnection>(url_);
|
||||
|
||||
if (!connection_ || !connection_->is_valid()) {
|
||||
emit Error(tr("Error connecting MTP device %1").arg(url_.toString()));
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <dbus/objectmanager.h>
|
||||
#include <dbus/udisks2block.h>
|
||||
#include <dbus/udisks2drive.h>
|
||||
|
@ -179,7 +181,7 @@ void Udisks2Lister::UpdateDeviceFreeSpace(const QString &id) {
|
|||
|
||||
bool Udisks2Lister::Init() {
|
||||
|
||||
udisks2_interface_.reset(new OrgFreedesktopDBusObjectManagerInterface(udisks2_service_, "/org/freedesktop/UDisks2", QDBusConnection::systemBus()));
|
||||
udisks2_interface_ = std::make_unique<OrgFreedesktopDBusObjectManagerInterface>(udisks2_service_, "/org/freedesktop/UDisks2", QDBusConnection::systemBus());
|
||||
|
||||
QDBusPendingReply<ManagedObjectList> reply = udisks2_interface_->GetManagedObjects();
|
||||
reply.waitForFinished();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
@ -1216,7 +1217,7 @@ void GstEnginePipeline::StartFader(const qint64 duration_nanosec, const QTimeLin
|
|||
}
|
||||
}
|
||||
|
||||
fader_.reset(new QTimeLine(duration_msec, this));
|
||||
fader_ = std::make_unique<QTimeLine>(duration_msec, this);
|
||||
QObject::connect(fader_.get(), &QTimeLine::valueChanged, this, &GstEnginePipeline::SetVolumeModifier);
|
||||
QObject::connect(fader_.get(), &QTimeLine::finished, this, &GstEnginePipeline::FaderTimelineFinished);
|
||||
fader_->setDirection(direction);
|
||||
|
|
|
@ -676,7 +676,7 @@ void InternetSearchView::GroupByClicked(QAction *action) {
|
|||
|
||||
if (action->property("group_by").isNull()) {
|
||||
if (!group_by_dialog_) {
|
||||
group_by_dialog_.reset(new GroupByDialog);
|
||||
group_by_dialog_ = std::make_unique<GroupByDialog>();
|
||||
QObject::connect(group_by_dialog_.get(), &GroupByDialog::Accepted, this, &InternetSearchView::SetGroupBy);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "moodbarpipeline.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
#include <glib-object.h>
|
||||
|
||||
|
@ -111,7 +112,7 @@ void MoodbarPipeline::Start() {
|
|||
return;
|
||||
}
|
||||
|
||||
builder_.reset(new MoodbarBuilder);
|
||||
builder_ = std::make_unique<MoodbarBuilder>();
|
||||
|
||||
// Set properties
|
||||
g_object_set(decodebin, "uri", local_filename_.toEncoded().constData(), nullptr);
|
||||
|
|
|
@ -556,7 +556,7 @@ void OrganizeDialog::OrganizeFinished(const QStringList &files_with_errors, cons
|
|||
|
||||
if (files_with_errors.isEmpty()) return;
|
||||
|
||||
error_dialog_.reset(new OrganizeErrorDialog);
|
||||
error_dialog_ = std::make_unique<OrganizeErrorDialog>();
|
||||
error_dialog_->Show(OrganizeErrorDialog::Type_Copy, files_with_errors, log);
|
||||
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ OSDDBus::~OSDDBus() = default;
|
|||
|
||||
void OSDDBus::Init() {
|
||||
|
||||
interface_.reset(new OrgFreedesktopNotificationsInterface(OrgFreedesktopNotificationsInterface::staticInterfaceName(), "/org/freedesktop/Notifications", QDBusConnection::sessionBus()));
|
||||
interface_ = std::make_unique<OrgFreedesktopNotificationsInterface>(OrgFreedesktopNotificationsInterface::staticInterfaceName(), "/org/freedesktop/Notifications", QDBusConnection::sessionBus());
|
||||
if (!interface_->isValid()) {
|
||||
qLog(Warning) << "Error connecting to notifications service.";
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
|
@ -369,7 +371,7 @@ void PlaylistListContainer::CopyToDevice() {
|
|||
|
||||
// Reuse the organize dialog, but set the detail about the playlist name
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
}
|
||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||
organize_dialog_->SetCopy(true);
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
@ -100,7 +102,7 @@ int SmartPlaylistQueryWizardPlugin::CreatePages(QWizard *wizard, int finish_page
|
|||
search_page_ = new SearchPage(wizard);
|
||||
|
||||
QWizardPage *sort_page = new SortPage(this, wizard, finish_page_id);
|
||||
sort_ui_.reset(new Ui_SmartPlaylistQuerySortPage);
|
||||
sort_ui_ = std::make_unique<Ui_SmartPlaylistQuerySortPage>();
|
||||
sort_ui_->setupUi(sort_page);
|
||||
|
||||
sort_ui_->limit_value->setValue(PlaylistGenerator::kDefaultLimit);
|
||||
|
|
|
@ -154,7 +154,7 @@ void SubsonicService::SendPing() {
|
|||
void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username, const QString &password, const bool redirect) {
|
||||
|
||||
if (!redirect) {
|
||||
network_.reset(new QNetworkAccessManager);
|
||||
network_ = std::make_unique<QNetworkAccessManager>();
|
||||
ping_redirects_ = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
|
@ -535,7 +537,7 @@ void PlayingWidget::SearchCoverInProgress() {
|
|||
downloading_covers_ = true;
|
||||
|
||||
// Show a spinner animation
|
||||
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
|
||||
spinner_animation_ = std::make_unique<QMovie>(":/pictures/spinner.gif", QByteArray(), this);
|
||||
QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &PlayingWidget::Update);
|
||||
spinner_animation_->start();
|
||||
update();
|
||||
|
|
|
@ -45,7 +45,7 @@ class CollectionBackendTest : public ::testing::Test {
|
|||
protected:
|
||||
void SetUp() override {
|
||||
database_.reset(new MemoryDatabase(nullptr));
|
||||
backend_.reset(new CollectionBackend);
|
||||
backend_ = std::make_unique<CollectionBackend>();
|
||||
backend_->Init(database_.get(), Song::Source_Collection, SCollection::kSongsTable, SCollection::kDirsTable, SCollection::kSubdirsTable, SCollection::kFtsTable);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class SongPlaylistItemTest : public ::testing::TestWithParam<const char*> {
|
|||
song_.Init("Title", "Artist", "Album", 123);
|
||||
song_.set_url(QUrl::fromLocalFile(absolute_file_name_));
|
||||
|
||||
item_.reset(new SongPlaylistItem(song_));
|
||||
item_ = std::make_unique<SongPlaylistItem>(song_);
|
||||
|
||||
if (!absolute_file_name_.startsWith('/'))
|
||||
absolute_file_name_.prepend('/');
|
||||
|
|
Loading…
Reference in New Issue