Add advanced settings for configuring collection watcher
This commit is contained in:
parent
78adc388df
commit
e31c9d74fa
@ -94,11 +94,18 @@ void SCollection::Init() {
|
|||||||
|
|
||||||
watcher_ = new CollectionWatcher(Song::Source_Collection);
|
watcher_ = new CollectionWatcher(Song::Source_Collection);
|
||||||
watcher_thread_ = new Thread(this);
|
watcher_thread_ = new Thread(this);
|
||||||
watcher_thread_->SetIoPriority(Utilities::IOPRIO_CLASS_IDLE);
|
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
if (io_priority_ != Utilities::IoPriority::IOPRIO_CLASS_NONE) {
|
||||||
|
watcher_thread_->SetIoPriority(io_priority_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
watcher_->moveToThread(watcher_thread_);
|
watcher_->moveToThread(watcher_thread_);
|
||||||
watcher_thread_->start(QThread::IdlePriority);
|
|
||||||
qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_;
|
qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_ << "with I/O priority" << io_priority_ << "and thread priority" << thread_priority_;
|
||||||
|
|
||||||
|
watcher_thread_->start(thread_priority_);
|
||||||
|
|
||||||
watcher_->set_backend(backend_);
|
watcher_->set_backend(backend_);
|
||||||
watcher_->set_task_manager(app_->task_manager());
|
watcher_->set_task_manager(app_->task_manager());
|
||||||
@ -176,6 +183,8 @@ void SCollection::ReloadSettings() {
|
|||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
|
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
|
||||||
|
io_priority_ = static_cast<Utilities::IoPriority>(s.value("io_priority", Utilities::IOPRIO_CLASS_IDLE).toInt());
|
||||||
|
thread_priority_ = static_cast<QThread::Priority>(s.value("thread_priority", QThread::Priority::IdlePriority).toInt());
|
||||||
save_playcounts_to_files_ = s.value("save_playcounts", false).toBool();
|
save_playcounts_to_files_ = s.value("save_playcounts", false).toBool();
|
||||||
save_ratings_to_files_ = s.value("save_ratings", false).toBool();
|
save_ratings_to_files_ = s.value("save_ratings", false).toBool();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
|
#include "core/utilities.h"
|
||||||
class QThread;
|
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class Thread;
|
class Thread;
|
||||||
@ -99,6 +99,8 @@ class SCollection : public QObject {
|
|||||||
|
|
||||||
QList<QObject*> wait_for_exit_;
|
QList<QObject*> wait_for_exit_;
|
||||||
|
|
||||||
|
Utilities::IoPriority io_priority_;
|
||||||
|
QThread::Priority thread_priority_;
|
||||||
bool save_playcounts_to_files_;
|
bool save_playcounts_to_files_;
|
||||||
bool save_ratings_to_files_;
|
bool save_ratings_to_files_;
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QSettings>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
@ -36,6 +37,7 @@
|
|||||||
|
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "tagreaderclient.h"
|
#include "tagreaderclient.h"
|
||||||
|
#include "settings/collectionsettingspage.h"
|
||||||
|
|
||||||
const char *TagReaderClient::kWorkerExecutableName = "strawberry-tagreader";
|
const char *TagReaderClient::kWorkerExecutableName = "strawberry-tagreader";
|
||||||
TagReaderClient *TagReaderClient::sInstance = nullptr;
|
TagReaderClient *TagReaderClient::sInstance = nullptr;
|
||||||
@ -45,8 +47,15 @@ TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool
|
|||||||
sInstance = this;
|
sInstance = this;
|
||||||
original_thread_ = thread();
|
original_thread_ = thread();
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
|
||||||
|
int workers = s.value("tagreader_workers", qBound(1, QThread::idealThreadCount() / 2, 4)).toInt();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
qLog(Debug) << "Using" << workers << "tagreader workers.";
|
||||||
|
|
||||||
worker_pool_->SetExecutableName(kWorkerExecutableName);
|
worker_pool_->SetExecutableName(kWorkerExecutableName);
|
||||||
worker_pool_->SetWorkerCount(qBound(1, QThread::idealThreadCount() / 2, 4));
|
worker_pool_->SetWorkerCount(workers);
|
||||||
QObject::connect(worker_pool_, &WorkerPool<HandlerType>::WorkerFailedToStart, this, &TagReaderClient::WorkerFailedToStart);
|
QObject::connect(worker_pool_, &WorkerPool<HandlerType>::WorkerFailedToStart, this, &TagReaderClient::WorkerFailedToStart);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
void Thread::run() {
|
void Thread::run() {
|
||||||
Utilities::SetThreadIOPriority(io_priority_);
|
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
if (io_priority_ != Utilities::IOPRIO_CLASS_NONE) {
|
||||||
|
Utilities::SetThreadIOPriority(io_priority_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QThread::run();
|
QThread::run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@ -78,6 +79,9 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
|||||||
ui_->combobox_cache_size->addItems({"KB", "MB"});
|
ui_->combobox_cache_size->addItems({"KB", "MB"});
|
||||||
ui_->combobox_disk_cache_size->addItems({"KB", "MB", "GB"});
|
ui_->combobox_disk_cache_size->addItems({"KB", "MB", "GB"});
|
||||||
|
|
||||||
|
ui_->combobox_iopriority->addItems({"Auto", "Realtime", "Best effort", "Idle"});
|
||||||
|
ui_->combobox_threadpriority->addItems({"Idle", "Lowest", "Low", "Normal"});
|
||||||
|
|
||||||
QObject::connect(ui_->add, &QPushButton::clicked, this, &CollectionSettingsPage::Add);
|
QObject::connect(ui_->add, &QPushButton::clicked, this, &CollectionSettingsPage::Add);
|
||||||
QObject::connect(ui_->remove, &QPushButton::clicked, this, &CollectionSettingsPage::Remove);
|
QObject::connect(ui_->remove, &QPushButton::clicked, this, &CollectionSettingsPage::Remove);
|
||||||
|
|
||||||
@ -102,6 +106,11 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
|||||||
ui_->song_tracking->hide();
|
ui_->song_tracking->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
ui_->label_iopriority->hide();
|
||||||
|
ui_->combobox_iopriority->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
||||||
@ -221,6 +230,18 @@ void CollectionSettingsPage::Load() {
|
|||||||
ui_->checkbox_delete_files->hide();
|
ui_->checkbox_delete_files->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
ComboBoxLoadFromSettingsByIndex(s, ui_->combobox_iopriority, "io_priority", Utilities::IOPRIO_CLASS_IDLE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ComboBoxLoadFromSettingsByIndex(s, ui_->combobox_threadpriority, "thread_priority", QThread::Priority::IdlePriority);
|
||||||
|
|
||||||
|
int workers = s.value("tagreader_workers", qBound(1, QThread::idealThreadCount() / 2, 4)).toInt();
|
||||||
|
if (workers <= 0 || workers > 4) {
|
||||||
|
workers = 4;
|
||||||
|
}
|
||||||
|
ui_->spinbox_tagreaderworkers->setValue(workers);
|
||||||
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
DiskCacheEnable(ui_->checkbox_disk_cache->checkState());
|
DiskCacheEnable(ui_->checkbox_disk_cache->checkState());
|
||||||
@ -284,6 +305,13 @@ void CollectionSettingsPage::Save() {
|
|||||||
|
|
||||||
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());
|
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());
|
||||||
|
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
s.setValue("io_priority", ui_->combobox_iopriority->currentIndex());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
s.setValue("thread_priority", ui_->combobox_threadpriority->currentIndex());
|
||||||
|
s.setValue("tagreader_workers", ui_->spinbox_tagreaderworkers->value());
|
||||||
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>516</width>
|
<width>516</width>
|
||||||
<height>1339</height>
|
<height>1490</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -601,6 +601,86 @@ If there are no matches then it will use the largest image in the directory.</st
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupbox_advanced">
|
||||||
|
<property name="title">
|
||||||
|
<string>Advanced</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="layout_advanced">
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="combobox_threadpriority">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="combobox_iopriority">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinbox_tagreaderworkers">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_tagreaderworkers">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tagreader workers</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_threadpriority">
|
||||||
|
<property name="text">
|
||||||
|
<string>Thread priority</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_iopriority">
|
||||||
|
<property name="text">
|
||||||
|
<string>I/O priority</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_advanced">
|
||||||
|
<property name="text">
|
||||||
|
<string>Advanced settings require restart.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
@ -151,3 +151,13 @@ void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combo
|
|||||||
combobox->setCurrentIndex(i);
|
combobox->setCurrentIndex(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsPage::ComboBoxLoadFromSettingsByIndex(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value) {
|
||||||
|
|
||||||
|
if (combobox->count() == 0) return;
|
||||||
|
int i = s.value(setting, default_value).toInt();
|
||||||
|
if (i <= 0 || i >= combobox->count()) i = 0;
|
||||||
|
combobox->setCurrentIndex(i);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ class SettingsPage : public QWidget {
|
|||||||
|
|
||||||
static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
|
static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
|
||||||
static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
||||||
|
static void ComboBoxLoadFromSettingsByIndex(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void Save() = 0;
|
virtual void Save() = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user