Fixes from code review for PR #7037
This commit is contained in:
parent
6fa9cbcc65
commit
57b5911f13
|
@ -22,7 +22,7 @@
|
||||||
#include "library/librarybackend.h"
|
#include "library/librarybackend.h"
|
||||||
#include "library/librarymodel.h"
|
#include "library/librarymodel.h"
|
||||||
|
|
||||||
const int CddaDevice::kDiscChangePollingIntervalMs = 500;
|
const int kDiscChangePollingIntervalMs = 500;
|
||||||
|
|
||||||
CddaDevice::CddaDevice(const QUrl& url, DeviceLister* lister,
|
CddaDevice::CddaDevice(const QUrl& url, DeviceLister* lister,
|
||||||
const QString& unique_id, DeviceManager* manager,
|
const QString& unique_id, DeviceManager* manager,
|
||||||
|
@ -68,7 +68,7 @@ bool CddaDevice::IsValid() const { return (cdio_ != nullptr); }
|
||||||
|
|
||||||
void CddaDevice::WatchForDiscChanges(bool watch) {
|
void CddaDevice::WatchForDiscChanges(bool watch) {
|
||||||
if (watch && !disc_changed_timer_.isActive())
|
if (watch && !disc_changed_timer_.isActive())
|
||||||
disc_changed_timer_.start(CddaDevice::kDiscChangePollingIntervalMs);
|
disc_changed_timer_.start(kDiscChangePollingIntervalMs);
|
||||||
else if (!watch && disc_changed_timer_.isActive())
|
else if (!watch && disc_changed_timer_.isActive())
|
||||||
disc_changed_timer_.stop();
|
disc_changed_timer_.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ class CddaDevice : public ConnectedDevice {
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
void WatchForDiscChanges(bool watch);
|
void WatchForDiscChanges(bool watch);
|
||||||
|
|
||||||
static const int kDiscChangePollingIntervalMs;
|
|
||||||
static QStringList url_schemes() { return QStringList() << "cdda"; }
|
static QStringList url_schemes() { return QStringList() << "cdda"; }
|
||||||
|
|
||||||
// QUrl interprets a single number as an ip address, so the QString cdda://1
|
// QUrl interprets a single number as an ip address, so the QString cdda://1
|
||||||
|
|
|
@ -54,15 +54,16 @@ const int kTrackDurationColumn = 3;
|
||||||
const char* RipCDDialog::kSettingsGroup = "Transcoder";
|
const char* RipCDDialog::kSettingsGroup = "Transcoder";
|
||||||
const int RipCDDialog::kMaxDestinationItems = 10;
|
const int RipCDDialog::kMaxDestinationItems = 10;
|
||||||
|
|
||||||
RipCDDialog::RipCDDialog(DeviceManager& device_manager, QWidget* parent)
|
RipCDDialog::RipCDDialog(DeviceManager* device_manager, QWidget* parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui_(new Ui_RipCDDialog),
|
ui_(new Ui_RipCDDialog),
|
||||||
device_manager_(device_manager),
|
device_manager_(device_manager),
|
||||||
cdda_devices_(
|
cdda_devices_(
|
||||||
device_manager.FindDevicesByUrlSchemes(CddaDevice::url_schemes())),
|
device_manager->FindDevicesByUrlSchemes(CddaDevice::url_schemes())),
|
||||||
working_(false),
|
working_(false),
|
||||||
cdda_device_(),
|
cdda_device_(),
|
||||||
loader_(nullptr) {
|
loader_(nullptr) {
|
||||||
|
Q_ASSERT(device_manager);
|
||||||
// Init
|
// Init
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
|
@ -179,8 +180,10 @@ void RipCDDialog::ClickedRipButton() {
|
||||||
Ripper* ripper = new Ripper(cdda_device_->raw_cdio(), this);
|
Ripper* ripper = new Ripper(cdda_device_->raw_cdio(), this);
|
||||||
connect(cancel_button_, SIGNAL(clicked()), ripper, SLOT(Cancel()));
|
connect(cancel_button_, SIGNAL(clicked()), ripper, SLOT(Cancel()));
|
||||||
|
|
||||||
connect(ripper, SIGNAL(Finished()), SLOT(Finished()));
|
connect(ripper, &Ripper::Finished, this,
|
||||||
connect(ripper, SIGNAL(Cancelled()), SLOT(Cancelled()));
|
[this, ripper]() { this->Finished(ripper); });
|
||||||
|
connect(ripper, &Ripper::Cancelled, this,
|
||||||
|
[this, ripper]() { this->Cancelled(ripper); });
|
||||||
connect(ripper, SIGNAL(ProgressInterval(int, int)),
|
connect(ripper, SIGNAL(ProgressInterval(int, int)),
|
||||||
SLOT(SetupProgressBarLimits(int, int)));
|
SLOT(SetupProgressBarLimits(int, int)));
|
||||||
connect(ripper, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));
|
connect(ripper, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));
|
||||||
|
@ -279,7 +282,7 @@ void RipCDDialog::DeviceSelected(int device_index) {
|
||||||
|
|
||||||
DeviceInfo* device_info = cdda_devices_[device_index];
|
DeviceInfo* device_info = cdda_devices_[device_index];
|
||||||
std::shared_ptr<ConnectedDevice> device =
|
std::shared_ptr<ConnectedDevice> device =
|
||||||
device_manager_.Connect(device_info);
|
device_manager_->Connect(device_info);
|
||||||
cdda_device_ = std::dynamic_pointer_cast<CddaDevice>(device);
|
cdda_device_ = std::dynamic_pointer_cast<CddaDevice>(device);
|
||||||
if (!cdda_device_) {
|
if (!cdda_device_) {
|
||||||
rip_button_->setEnabled(false);
|
rip_button_->setEnabled(false);
|
||||||
|
@ -307,16 +310,14 @@ void RipCDDialog::DeviceSelected(int device_index) {
|
||||||
rip_button_->setEnabled(true);
|
rip_button_->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RipCDDialog::Finished() {
|
void RipCDDialog::Finished(Ripper* ripper) {
|
||||||
SetWorking(false);
|
SetWorking(false);
|
||||||
Ripper* ripper = dynamic_cast<Ripper*>(sender());
|
|
||||||
Q_ASSERT(ripper);
|
|
||||||
ripper->deleteLater();
|
ripper->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RipCDDialog::Cancelled() {
|
void RipCDDialog::Cancelled(Ripper* ripper) {
|
||||||
ui_->progress_bar->setValue(0);
|
ui_->progress_bar->setValue(0);
|
||||||
Finished();
|
Finished(ripper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RipCDDialog::SetupProgressBarLimits(int min, int max) {
|
void RipCDDialog::SetupProgressBarLimits(int min, int max) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class RipCDDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RipCDDialog(DeviceManager& device_manager,
|
explicit RipCDDialog(DeviceManager* device_manager,
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
~RipCDDialog();
|
~RipCDDialog();
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ class RipCDDialog : public QDialog {
|
||||||
void SelectNone();
|
void SelectNone();
|
||||||
void InvertSelection();
|
void InvertSelection();
|
||||||
void DeviceSelected(int device_index);
|
void DeviceSelected(int device_index);
|
||||||
void Finished();
|
void Finished(Ripper* ripper);
|
||||||
void Cancelled();
|
void Cancelled(Ripper* ripper);
|
||||||
void SetupProgressBarLimits(int min, int max);
|
void SetupProgressBarLimits(int min, int max);
|
||||||
void UpdateProgressBar(int progress);
|
void UpdateProgressBar(int progress);
|
||||||
// Initializes track list table based on preliminary song list with durations
|
// Initializes track list table based on preliminary song list with durations
|
||||||
|
@ -90,7 +90,7 @@ class RipCDDialog : public QDialog {
|
||||||
QPushButton* close_button_;
|
QPushButton* close_button_;
|
||||||
QPushButton* rip_button_;
|
QPushButton* rip_button_;
|
||||||
std::unique_ptr<Ui_RipCDDialog> ui_;
|
std::unique_ptr<Ui_RipCDDialog> ui_;
|
||||||
DeviceManager& device_manager_;
|
DeviceManager* device_manager_;
|
||||||
QList<DeviceInfo*> cdda_devices_;
|
QList<DeviceInfo*> cdda_devices_;
|
||||||
bool working_;
|
bool working_;
|
||||||
std::shared_ptr<CddaDevice> cdda_device_;
|
std::shared_ptr<CddaDevice> cdda_device_;
|
||||||
|
|
|
@ -2221,7 +2221,7 @@ void MainWindow::OpenRipCDDialog() {
|
||||||
#ifdef HAVE_AUDIOCD
|
#ifdef HAVE_AUDIOCD
|
||||||
if (!rip_cd_dialog_) {
|
if (!rip_cd_dialog_) {
|
||||||
Q_ASSERT(app_->device_manager());
|
Q_ASSERT(app_->device_manager());
|
||||||
rip_cd_dialog_.reset(new RipCDDialog(*(app_->device_manager())));
|
rip_cd_dialog_.reset(new RipCDDialog(app_->device_manager()));
|
||||||
}
|
}
|
||||||
rip_cd_dialog_->show();
|
rip_cd_dialog_->show();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue