From f63ffc040e854db4da59542ebfbb62696f5af2e2 Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 13 Feb 2012 21:30:30 +0000 Subject: [PATCH] Better tag editor usabability - Enable 'ok' when claear a non-empty 'all tracks' field - Use red text for labels of changed items --- gui/tageditor.cpp | 51 +++++++++++++++++++++++++++++++++++++++++--- gui/tageditor.h | 1 + gui/tageditor.ui | 23 ++++++++++++-------- widgets/statelabel.h | 48 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 widgets/statelabel.h diff --git a/gui/tageditor.cpp b/gui/tageditor.cpp index 6addd0afd..fd70aeef2 100644 --- a/gui/tageditor.cpp +++ b/gui/tageditor.cpp @@ -129,7 +129,6 @@ TagEditor::TagEditor(QWidget *parent, const QList &songs, trackName->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); trackName->view()->setTextElideMode(Qt::ElideLeft); resize(500, 200); - original=songs; if (original.count()>1) { QSet songArtists; @@ -233,6 +232,22 @@ void TagEditor::enableOkButton() enableButton(Reset, isButtonEnabled(Ok)); } +void TagEditor::setLabelStates() +{ + Song o=original.at(currentSongIndex); + Song e=edited.at(currentSongIndex); + bool isAll=0==currentSongIndex && original.count()>1; + + titleLabel->setOn(!isAll && o.title!=e.title); + artistLabel->setOn(o.artist!=e.artist); + albumArtistLabel->setOn(o.albumartist!=e.albumartist); + albumLabel->setOn(o.album!=e.album); + trackLabel->setOn(o.track!=e.track); + discLabel->setOn(!isAll && o.disc!=e.disc); + genreLabel->setOn(o.genre!=e.genre); + yearLabel->setOn(o.year!=e.year); +} + void TagEditor::applyVa() { bool isAll=0==currentSongIndex && original.count()>1; @@ -346,6 +361,7 @@ void TagEditor::checkChanged() updateEdited(); enableOkButton(); + setLabelStates(); bool allEdited=editedIndexes.contains(0); bool isAll=0==currentSongIndex && original.count()>1; @@ -414,7 +430,25 @@ void TagEditor::updateEdited(bool isFromAll) { Song s=edited.at(currentSongIndex); bool isAll=0==currentSongIndex && original.count()>1; - fillSong(s, isFromAll || isAll, isFromAll); + fillSong(s, isFromAll || isAll, /*isFromAll*/false); + + if (!isAll && isFromAll && original.count()>1) { + Song all=original.at(0); + Song o=original.at(currentSongIndex); + if (all.artist.isEmpty() && s.artist.isEmpty() && !o.artist.isEmpty()) { + s.artist=o.artist; + } + if (all.albumartist.isEmpty() && s.albumartist.isEmpty() && !o.albumartist.isEmpty()) { + s.albumartist=o.albumartist; + } + if (all.album.isEmpty() && s.album.isEmpty() && !o.album.isEmpty()) { + s.album=o.album; + } + if (all.genre.isEmpty() && s.genre.isEmpty() && !o.genre.isEmpty()) { + s.genre=o.genre; + } + } + if (equalTags(s, original.at(currentSongIndex), isFromAll || isAll)) { if (editedIndexes.contains(currentSongIndex)) { editedIndexes.remove(currentSongIndex); @@ -474,6 +508,7 @@ void TagEditor::setIndex(int idx) } enableOkButton(); trackName->setCurrentIndex(idx); + setLabelStates(); updating=false; } @@ -521,7 +556,17 @@ void TagEditor::slotButtonClicked(int button) break; } case Reset: // Reset - setSong(original.at(currentSongIndex)); + if (0==currentSongIndex && original.count()>1) { + for (int i=0; i - + Track: @@ -25,7 +25,7 @@ - + Title: @@ -38,7 +38,7 @@ - + Artist: @@ -51,7 +51,7 @@ - + Album artist: @@ -64,7 +64,7 @@ - + Album: @@ -77,7 +77,7 @@ - + Track number: @@ -90,7 +90,7 @@ - + Disc number: @@ -103,7 +103,7 @@ - + Genre: @@ -116,7 +116,7 @@ - + Year: @@ -146,6 +146,11 @@ QSpinBox
clearspinbox.h
+ + StateLabel + QLabel +
statelabel.h
+
trackName diff --git a/widgets/statelabel.h b/widgets/statelabel.h new file mode 100644 index 000000000..86419e8c7 --- /dev/null +++ b/widgets/statelabel.h @@ -0,0 +1,48 @@ +/* + * Cantata + * + * Copyright (c) 2011-2012 Craig Drummond + * + * ---- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef STATELABEL_H +#define STATELABEL_H + +#include + +class StateLabel : public QLabel +{ +public: + StateLabel(QWidget *parent=0) + : QLabel(parent) + , on(false) { + } + + void setOn(bool o) { + if (o!=on) { + setStyleSheet(o ? QLatin1String("QLabel { color : red; }") : QString()); + on=o; + } + } + +private: + bool on; +}; + +#endif \ No newline at end of file