From 96e6252fcadf6c09cc0158a51d5a97b79fc4b5cc Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Sun, 26 Jan 2014 16:51:19 +0100 Subject: [PATCH 1/5] Style the Rip cd dialog Set a specific tab order in the dialog. Add a Clementine window icon. Add a header for the first column in the table widget. Change the button box to a cancel and a close button and make these behave as in the transcoder dialog. Move the rip button to the button box. Hide the progress bar if no cd has been ripped. --- src/ui/ripcd.cpp | 25 +++++- src/ui/ripcd.h | 3 + src/ui/ripcd.ui | 201 ++++++++++++++++++++++------------------------- 3 files changed, 119 insertions(+), 110 deletions(-) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 81d64bacd..0542d0aa4 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -76,10 +76,20 @@ RipCD::RipCD(QWidget* parent) : // Init ui_->setupUi(this); - cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel); - connect(ui_->ripButton, SIGNAL(clicked()), this, SLOT(ClickedRipButton())); + // Add a rip button + rip_button_ = ui_->button_box->addButton( + tr("Start ripping"), QDialogButtonBox::ActionRole); + cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel); + close_button_ = ui_->button_box->button(QDialogButtonBox::Close); + + // Hide elements + cancel_button_->hide(); + ui_->progress_group->hide(); + + connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton())); connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel())); + connect(close_button_, SIGNAL(clicked()), SLOT(hide())); connect(transcoder_, SIGNAL(JobComplete(QString, bool)), SLOT(JobComplete(QString, bool))); connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete())); @@ -303,6 +313,7 @@ void RipCD::ThreadedTranscoding() { } void RipCD::ClickedRipButton() { + SetWorking(true); QtConcurrent::run(this, &RipCD::ThreadClickedRipButton); } @@ -333,6 +344,8 @@ void RipCD::AllJobsComplete() { // Resets lists generated_files_.clear(); tracks_to_rip_.clear(); + + SetWorking(false); } void RipCD::AppendOutput(const QString& filename) { @@ -381,8 +394,16 @@ void RipCD::AddDestination() { void RipCD::Cancel() { transcoder_->Cancel(); + SetWorking(false); } bool RipCD::CDIOIsValid() const { return (cdio_); } + +void RipCD::SetWorking(bool working) { + rip_button_->setVisible(!working); + cancel_button_->setVisible(working); + close_button_->setVisible(!working); + ui_->progress_group->setVisible(true); +} diff --git a/src/ui/ripcd.h b/src/ui/ripcd.h index bc998ab22..060e7956d 100644 --- a/src/ui/ripcd.h +++ b/src/ui/ripcd.h @@ -55,6 +55,8 @@ class RipCD: public QDialog { QList track_names_; QString last_add_dir_; QPushButton* cancel_button_; + QPushButton* close_button_; + QPushButton* rip_button_; void WriteWAVHeader(QFile *stream, int32_t i_bytecount); int NumTracksToRip(); @@ -63,6 +65,7 @@ class RipCD: public QDialog { QString GetOutputFileName(const QString& input, const TranscoderPreset& preset) const; QString ParseFileFormatString(const QString& file_format, int track_no) const; + void SetWorking(bool working); signals: void RippingComplete(); diff --git a/src/ui/ripcd.ui b/src/ui/ripcd.ui index 149e0e681..22f0f53fc 100644 --- a/src/ui/ripcd.ui +++ b/src/ui/ripcd.ui @@ -16,6 +16,10 @@ Dialog + + + :/icon.png:/icon.png + @@ -29,7 +33,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Close @@ -133,7 +137,7 @@ - + Rip @@ -155,29 +159,6 @@ - - - - 10 - 480 - 98 - 27 - - - - &Rip - - - - - - 120 - 480 - 455 - 25 - - - @@ -191,55 +172,6 @@ Output options - - - - Audio format - - - - - - - - 0 - 0 - - - - - - - - Options... - - - - - - - Destination - - - - - - - true - - - - 0 - 0 - - - - - Alongside the originals - - - - @@ -261,42 +193,95 @@ + + + + Destination + + + + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + + Alongside the originals + + + + + + + + Options... + + + + + + + Audio format + + + + + + + 10 + 450 + 571 + 41 + + + + Progress + + + + + 10 + 20 + 551 + 23 + + + + + + tableWidget + albumLineEdit + artistLineEdit + genreLineEdit + yearLineEdit + discLineEdit + format_filename + format + options + destination + select + button_box + - - - button_box - accepted() - RipCD - accept() - - - 248 - 254 - - - 157 - 274 - - - - - button_box - rejected() - RipCD - reject() - - - 316 - 260 - - - 286 - 274 - - - - + From 27b1bf7014240a88143874759c08f7f6309b7aa6 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Sun, 26 Jan 2014 19:12:05 +0100 Subject: [PATCH 2/5] Add buttons 'select all', 'select none' and 'invert selection' buttons to the rip cd dialog. --- src/ui/ripcd.cpp | 26 ++++++++++++++++++++++++ src/ui/ripcd.h | 3 +++ src/ui/ripcd.ui | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 0542d0aa4..5aaccec5c 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -87,6 +87,10 @@ RipCD::RipCD(QWidget* parent) : cancel_button_->hide(); ui_->progress_group->hide(); + connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll())); + connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone())); + connect(ui_->invert_selection_button, SIGNAL(clicked()), + SLOT(InvertSelection())); connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton())); connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel())); connect(close_button_, SIGNAL(clicked()), SLOT(hide())); @@ -407,3 +411,25 @@ void RipCD::SetWorking(bool working) { close_button_->setVisible(!working); ui_->progress_group->setVisible(true); } + +void RipCD::SelectAll() { + foreach (QCheckBox* checkbox, checkboxes_) { + checkbox->setCheckState(Qt::Checked); + } +} + +void RipCD::SelectNone() { + foreach (QCheckBox* checkbox, checkboxes_) { + checkbox->setCheckState(Qt::Unchecked); + } +} + +void RipCD::InvertSelection() { + foreach (QCheckBox* checkbox, checkboxes_) { + if (checkbox->isChecked()) { + checkbox->setCheckState(Qt::Unchecked); + } else { + checkbox->setCheckState(Qt::Checked); + } + } +} diff --git a/src/ui/ripcd.h b/src/ui/ripcd.h index 060e7956d..06f9370e8 100644 --- a/src/ui/ripcd.h +++ b/src/ui/ripcd.h @@ -80,6 +80,9 @@ class RipCD: public QDialog { void Options(); void AddDestination(); void Cancel(); + void SelectAll(); + void SelectNone(); + void InvertSelection(); }; #endif // SRC_UI_RIPCD_H_ diff --git a/src/ui/ripcd.ui b/src/ui/ripcd.ui index 22f0f53fc..e70330f78 100644 --- a/src/ui/ripcd.ui +++ b/src/ui/ripcd.ui @@ -40,7 +40,7 @@ 10 - 197 + 210 571 101 @@ -267,9 +267,58 @@ + + + + 10 + 180 + 571 + 31 + + + + + + + Select All + + + + + + + Select None + + + + + + + Invert Selection + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + tableWidget + select_all_button + select_none_button + invert_selection_button albumLineEdit artistLineEdit genreLineEdit From 76a91ded887fc6a9382cd5226c78bca55736ba01 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Sun, 26 Jan 2014 20:34:38 +0100 Subject: [PATCH 3/5] Remove the 'Alongside the originals' destination in the CD rip dialog since it doesn't make sense in this context. Use the home directory as initial destination instead. --- src/ui/ripcd.cpp | 27 ++++++++++++++++----------- src/ui/ripcd.h | 1 + src/ui/ripcd.ui | 5 ----- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 5aaccec5c..7113555dc 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -106,6 +106,7 @@ RipCD::RipCD(QWidget* parent) : connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination())); setWindowTitle(tr("Rip CD")); + AddDestinationDirectory(QDir::homePath()); cdio_ = cdio_open(NULL, DRIVER_UNKNOWN); if(!cdio_) { @@ -380,19 +381,23 @@ void RipCD::AddDestination() { if (!dir.isEmpty()) { // Keep only a finite number of items in the box. while (ui_->destination->count() >= kMaxDestinationItems) { - ui_->destination->removeItem(1); // The oldest folder item. + ui_->destination->removeItem(0); // The oldest item. } + AddDestinationDirectory(dir); + } +} - QIcon icon = IconLoader::Load("folder"); - QVariant data = QVariant::fromValue(dir); - // Do not insert duplicates. - int duplicate_index = ui_->destination->findData(data); - if (duplicate_index == -1) { - ui_->destination->addItem(icon, dir, data); - ui_->destination->setCurrentIndex(ui_->destination->count() - 1); - } else { - ui_->destination->setCurrentIndex(duplicate_index); - } +// Adds a directory to the 'destination' combo box. +void RipCD::AddDestinationDirectory(QString dir) { + QIcon icon = IconLoader::Load("folder"); + QVariant data = QVariant::fromValue(dir); + // Do not insert duplicates. + int duplicate_index = ui_->destination->findData(data); + if (duplicate_index == -1) { + ui_->destination->addItem(icon, dir, data); + ui_->destination->setCurrentIndex(ui_->destination->count() - 1); + } else { + ui_->destination->setCurrentIndex(duplicate_index); } } diff --git a/src/ui/ripcd.h b/src/ui/ripcd.h index 06f9370e8..0203ed37c 100644 --- a/src/ui/ripcd.h +++ b/src/ui/ripcd.h @@ -66,6 +66,7 @@ class RipCD: public QDialog { const TranscoderPreset& preset) const; QString ParseFileFormatString(const QString& file_format, int track_no) const; void SetWorking(bool working); + void AddDestinationDirectory(QString dir); signals: void RippingComplete(); diff --git a/src/ui/ripcd.ui b/src/ui/ripcd.ui index e70330f78..555e2b304 100644 --- a/src/ui/ripcd.ui +++ b/src/ui/ripcd.ui @@ -221,11 +221,6 @@ 0 - - - Alongside the originals - - From a31223e45c51123080661b24ce31cc39e8d958fe Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Sun, 26 Jan 2014 21:14:42 +0100 Subject: [PATCH 4/5] Group the input options in the rip cd dialog. Disable input and output groups when there is a ripping in progress. --- src/ui/ripcd.cpp | 2 + src/ui/ripcd.ui | 550 ++++++++++++++++++++++------------------------- 2 files changed, 262 insertions(+), 290 deletions(-) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 7113555dc..592721d1f 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -414,6 +414,8 @@ void RipCD::SetWorking(bool working) { rip_button_->setVisible(!working); cancel_button_->setVisible(working); close_button_->setVisible(!working); + ui_->input_group->setEnabled(!working); + ui_->output_group->setEnabled(!working); ui_->progress_group->setVisible(true); } diff --git a/src/ui/ripcd.ui b/src/ui/ripcd.ui index 555e2b304..a6831d95b 100644 --- a/src/ui/ripcd.ui +++ b/src/ui/ripcd.ui @@ -9,8 +9,8 @@ 0 0 - 601 - 575 + 522 + 563 @@ -20,294 +20,264 @@ :/icon.png:/icon.png - - - - 240 - 530 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Close - - - - - - 10 - 210 - 571 - 101 - - - - - 0 - - - - - Year - - - - - - - Disc - - - - - - - Album - - - - - - - - - - - 0 - 0 - - - - - - - - - - - Artist - - - - - - - - - - Genre - - - - - - - - - - - - 10 - 10 - 571 - 171 - - - - - - - 4 - - - true - - - 10 - - - false - - - false - - - - Rip - - - - - Track - - - - - Title - - - - - Duration - - - - - - - - - - 10 - 320 - 571 - 131 - - - - Output options - - - - - - Select... - - - - - - - File Format - - - - - - - %tracknum% - %artist% - %track% - - - - - - - Destination - - - - - - - - 0 - 0 - - - - - - - - true - - - - 0 - 0 - - - - - - - - Options... - - - - - - - Audio format - - - - - - - - - 10 - 450 - 571 - 41 - - - - Progress - - - - - 10 - 20 - 551 - 23 - - - - - - - - 10 - 180 - 571 - 31 - - - - - - - Select All - - - - - - - Select None - - - - - - - Invert Selection - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + + + + Input options + + + + + + + + + 0 + 0 + + + + 4 + + + true + + + 10 + + + false + + + false + + + + Rip + + + + + Track + + + + + Title + + + + + Duration + + + + + + + + + + Select All + + + + + + + Select None + + + + + + + Invert Selection + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 + + + + + Year + + + + + + + Disc + + + + + + + Album + + + + + + + + + + + 0 + 0 + + + + + + + + + + + Artist + + + + + + + + + + Genre + + + + + + + + + + + + + + + Output options + + + + + + Select... + + + + + + + File Format + + + + + + + %tracknum% - %artist% - %track% + + + + + + + Destination + + + + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + + + + + Options... + + + + + + + Audio format + + + + + + + + + + Progress + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Close + + + + tableWidget From 333b1636fa5884042f69c4912d344374ed7c30b4 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Mon, 27 Jan 2014 00:13:33 +0100 Subject: [PATCH 5/5] Adjust column widths. --- src/ui/ripcd.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 592721d1f..2146bd228 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -77,6 +77,14 @@ RipCD::RipCD(QWidget* parent) : // Init ui_->setupUi(this); + // Set column widths in the QTableWidget. + ui_->tableWidget->horizontalHeader()->setResizeMode( + kCheckboxColumn, QHeaderView::ResizeToContents); + ui_->tableWidget->horizontalHeader()->setResizeMode( + kTrackNumberColumn, QHeaderView::ResizeToContents); + ui_->tableWidget->horizontalHeader()->setResizeMode( + kTrackTitleColumn, QHeaderView::Stretch); + // Add a rip button rip_button_ = ui_->button_box->addButton( tr("Start ripping"), QDialogButtonBox::ActionRole);