Set object names

This commit is contained in:
Jonas Kvinge 2024-09-02 22:26:36 +02:00
parent f265c055a5
commit 2a9ccd7480
20 changed files with 54 additions and 4 deletions

View File

@ -63,6 +63,8 @@ SCollection::SCollection(Application *app, QObject *parent)
save_playcounts_to_files_(false),
save_ratings_to_files_(false) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
backend_ = make_shared<CollectionBackend>();
@ -94,6 +96,7 @@ void SCollection::Init() {
watcher_ = new CollectionWatcher(Song::Source::Collection);
watcher_thread_ = new Thread(this);
watcher_thread_->setObjectName(watcher_->objectName());
watcher_thread_->SetIoPriority(Utilities::IoPriority::IOPRIO_CLASS_IDLE);

View File

@ -72,17 +72,21 @@ CollectionBackend::CollectionBackend(QObject *parent)
CollectionBackend::~CollectionBackend() {
qLog(Debug) << "Collection backend" << this << "for" << Song::TextForSource(source_) << "deleted";
qLog(Debug) << "Collection backend" << this << "deleted";
}
void CollectionBackend::Init(SharedPtr<Database> db, SharedPtr<TaskManager> task_manager, const Song::Source source, const QString &songs_table, const QString &dirs_table, const QString &subdirs_table) {
setObjectName(source == Song::Source::Collection ? QLatin1String(metaObject()->className()) : QStringLiteral("%1%2").arg(Song::DescriptionForSource(source), QLatin1String(metaObject()->className())));
db_ = db;
task_manager_ = task_manager;
source_ = source;
songs_table_ = songs_table;
dirs_table_ = dirs_table;
subdirs_table_ = subdirs_table;
}
void CollectionBackend::Close() {

View File

@ -101,6 +101,8 @@ CollectionModel::CollectionModel(SharedPtr<CollectionBackend> backend, Applicati
total_album_count_(0),
loading_(false) {
setObjectName(backend_->source() == Song::Source::Collection ? QLatin1String(metaObject()->className()) : QStringLiteral("%1%2").arg(Song::DescriptionForSource(backend_->source()), QLatin1String(metaObject()->className())));
filter_->setSourceModel(this);
filter_->setSortRole(Role_SortText);
filter_->sort(0);
@ -149,7 +151,7 @@ CollectionModel::CollectionModel(SharedPtr<CollectionBackend> backend, Applicati
CollectionModel::~CollectionModel() {
qLog(Debug) << "Collection model" << this << "for" << Song::TextForSource(backend_->source()) << "deleted";
qLog(Debug) << "Collection model" << this << "deleted";
beginResetModel();
Clear();

View File

@ -104,6 +104,8 @@ CollectionView::CollectionView(QWidget *parent)
is_in_keyboard_search_(false),
delete_files_(false) {
setObjectName(QLatin1String(metaObject()->className()));
setItemDelegate(new CollectionItemDelegate(this));
setAttribute(Qt::WA_MacShowFocusRect, false);
setHeaderHidden(true);

View File

@ -98,6 +98,8 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
cue_parser_(new CueParser(backend_, this)),
last_scan_time_(0) {
setObjectName(source_ == Song::Source::Collection ? QLatin1String(metaObject()->className()) : QStringLiteral("%1%2").arg(Song::DescriptionForSource(source_), QLatin1String(metaObject()->className())));
original_thread_ = thread();
rescan_timer_->setInterval(2s);

View File

@ -248,6 +248,8 @@ class ApplicationImpl {
Application::Application(QObject *parent)
: QObject(parent), p_(new ApplicationImpl(this)) {
setObjectName(QLatin1String(metaObject()->className()));
device_finders()->Init();
collection()->Init();
tag_reader_client();
@ -275,6 +277,8 @@ QThread *Application::MoveToNewThread(QObject *object) {
QThread *thread = new QThread(this);
thread->setObjectName(object->objectName());
MoveToThread(object, thread);
thread->start();

View File

@ -71,6 +71,8 @@ Database::Database(Application *app, QObject *parent, const QString &database_na
startup_schema_version_(-1),
original_thread_(nullptr) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
{

View File

@ -101,6 +101,8 @@ Player::Player(Application *app, QObject *parent)
volume_increment_(5),
play_offset_nanosec_(0) {
setObjectName(QLatin1String(metaObject()->className()));
Settings s;
s.beginGroup(BackendSettingsPage::kSettingsGroup);
EngineBase::Type enginetype = EngineBase::TypeFromName(s.value("engine", EngineBase::Name(EngineBase::Type::GStreamer)).toString().toLower());

View File

@ -44,6 +44,8 @@ TagReaderClient *TagReaderClient::sInstance = nullptr;
TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool_(new WorkerPool<HandlerType>(this)) {
setObjectName(QLatin1String(metaObject()->className()));
sInstance = this;
original_thread_ = thread();

View File

@ -30,7 +30,11 @@
#include "taskmanager.h"
TaskManager::TaskManager(QObject *parent) : QObject(parent), next_task_id_(1) {}
TaskManager::TaskManager(QObject *parent) : QObject(parent), next_task_id_(1) {
setObjectName(QLatin1String(metaObject()->className()));
}
int TaskManager::StartTask(const QString &name) {

View File

@ -57,6 +57,8 @@ AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
load_image_async_id_(1),
original_thread_(nullptr) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
}

View File

@ -44,6 +44,8 @@ CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *pare
temp_file_pattern_(QDir::tempPath() + QStringLiteral("/strawberry-cover-XXXXXX.jpg")),
id_(0) {
setObjectName(QLatin1String(metaObject()->className()));
options_.options = AlbumCoverLoaderOptions::Option::RawImageData | AlbumCoverLoaderOptions::Option::OriginalImage | AlbumCoverLoaderOptions::Option::ScaledImage;
options_.desired_scaled_size = QSize(120, 120);
options_.default_cover = QStringLiteral(":/pictures/cdcase.png");

View File

@ -47,6 +47,8 @@ DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent)
db_(nullptr),
original_thread_(nullptr) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
}

View File

@ -43,6 +43,8 @@ DeviceLister::DeviceLister(QObject *parent)
original_thread_(nullptr),
next_mount_request_id_(0) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
}
@ -60,6 +62,7 @@ DeviceLister::~DeviceLister() {
void DeviceLister::Start() {
thread_ = new QThread;
thread_->setObjectName(objectName());
QObject::connect(thread_, &QThread::started, this, &DeviceLister::ThreadStarted);
moveToThread(thread_);

View File

@ -94,6 +94,8 @@ DeviceManager::DeviceManager(Application *app, QObject *parent)
app_(app),
not_connected_overlay_(IconLoader::Load(QStringLiteral("edit-delete"))) {
setObjectName(QLatin1String(metaObject()->className()));
thread_pool_.setMaxThreadCount(1);
QObject::connect(&*app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);

View File

@ -49,7 +49,11 @@
# endif // _MSC_VER
#endif // Q_OS_WIN32
DeviceFinders::DeviceFinders(QObject *parent) : QObject(parent) {}
DeviceFinders::DeviceFinders(QObject *parent) : QObject(parent) {
setObjectName(QLatin1String(metaObject()->className()));
}
DeviceFinders::~DeviceFinders() {
qDeleteAll(device_finders_);

View File

@ -44,6 +44,8 @@ using std::make_shared;
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent), thread_(new QThread(this)), network_(make_shared<NetworkAccessManager>()) {
setObjectName(QLatin1String(metaObject()->className()));
thread_->setObjectName(objectName());
network_->moveToThread(thread_);
thread_->start();

View File

@ -205,6 +205,8 @@ int main(int argc, char *argv[]) {
return 0;
}
QThread::currentThread()->setObjectName(QStringLiteral("Main"));
QGuiApplication::setWindowIcon(IconLoader::Load(QStringLiteral("strawberry")));
#if defined(USE_BUNDLE)

View File

@ -65,6 +65,8 @@ PlaylistBackend::PlaylistBackend(Application *app, QObject *parent)
db_(app_->database()),
original_thread_(nullptr) {
setObjectName(QLatin1String(metaObject()->className()));
original_thread_ = thread();
}

View File

@ -75,6 +75,8 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
active_(-1),
playlists_loading_(0) {
setObjectName(QLatin1String(metaObject()->className()));
QObject::connect(&*app_->player(), &Player::Paused, this, &PlaylistManager::SetActivePaused);
QObject::connect(&*app_->player(), &Player::Playing, this, &PlaylistManager::SetActivePlaying);
QObject::connect(&*app_->player(), &Player::Stopped, this, &PlaylistManager::SetActiveStopped);