mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-07 23:38:48 +01:00
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_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_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_task_manager(app_->task_manager());
|
||||
@ -176,6 +183,8 @@ void SCollection::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
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_ratings_to_files_ = s.value("save_ratings", false).toBool();
|
||||
s.endGroup();
|
||||
|
@ -28,10 +28,10 @@
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
#include "core/utilities.h"
|
||||
|
||||
class Application;
|
||||
class Thread;
|
||||
@ -99,6 +99,8 @@ class SCollection : public QObject {
|
||||
|
||||
QList<QObject*> wait_for_exit_;
|
||||
|
||||
Utilities::IoPriority io_priority_;
|
||||
QThread::Priority thread_priority_;
|
||||
bool save_playcounts_to_files_;
|
||||
bool save_ratings_to_files_;
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QSettings>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "core/logging.h"
|
||||
@ -36,6 +37,7 @@
|
||||
|
||||
#include "song.h"
|
||||
#include "tagreaderclient.h"
|
||||
#include "settings/collectionsettingspage.h"
|
||||
|
||||
const char *TagReaderClient::kWorkerExecutableName = "strawberry-tagreader";
|
||||
TagReaderClient *TagReaderClient::sInstance = nullptr;
|
||||
@ -45,8 +47,15 @@ TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool
|
||||
sInstance = this;
|
||||
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_->SetWorkerCount(qBound(1, QThread::idealThreadCount() / 2, 4));
|
||||
worker_pool_->SetWorkerCount(workers);
|
||||
QObject::connect(worker_pool_, &WorkerPool<HandlerType>::WorkerFailedToStart, this, &TagReaderClient::WorkerFailedToStart);
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,13 @@
|
||||
#include "utilities.h"
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <QThread>
|
||||
#include <QStandardPaths>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemSelectionModel>
|
||||
@ -78,6 +79,9 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
||||
ui_->combobox_cache_size->addItems({"KB", "MB"});
|
||||
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_->remove, &QPushButton::clicked, this, &CollectionSettingsPage::Remove);
|
||||
|
||||
@ -102,6 +106,11 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
||||
ui_->song_tracking->hide();
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
ui_->label_iopriority->hide();
|
||||
ui_->combobox_iopriority->hide();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
||||
@ -221,6 +230,18 @@ void CollectionSettingsPage::Load() {
|
||||
ui_->checkbox_delete_files->hide();
|
||||
#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();
|
||||
|
||||
DiskCacheEnable(ui_->checkbox_disk_cache->checkState());
|
||||
@ -284,6 +305,13 @@ void CollectionSettingsPage::Save() {
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>516</width>
|
||||
<height>1339</height>
|
||||
<height>1490</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -601,6 +601,86 @@ If there are no matches then it will use the largest image in the directory.</st
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
@ -151,3 +151,13 @@ void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combo
|
||||
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 int default_value);
|
||||
static void ComboBoxLoadFromSettingsByIndex(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
|
||||
|
||||
private:
|
||||
virtual void Save() = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user