Better tag editor usabability

- Enable 'ok' when claear a non-empty 'all tracks' field
- Use red text for labels of changed items
This commit is contained in:
craig
2012-02-13 21:30:30 +00:00
committed by craig
parent ef22ee923a
commit f63ffc040e
4 changed files with 111 additions and 12 deletions

View File

@@ -129,7 +129,6 @@ TagEditor::TagEditor(QWidget *parent, const QList<Song> &songs,
trackName->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
trackName->view()->setTextElideMode(Qt::ElideLeft);
resize(500, 200);
original=songs;
if (original.count()>1) {
QSet<QString> 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<original.count(); ++i) {
edited.replace(i, original.at(i));
updateTrackName(i, false);
}
editedIndexes.clear();
setSong(original.at(currentSongIndex));
} else {
setSong(original.at(currentSongIndex));
}
enableOkButton();
break;
case User1: // Next
setIndex(currentSongIndex+1);

View File

@@ -58,6 +58,7 @@ Q_SIGNALS:
private:
void enableOkButton();
void setLabelStates();
void fillSong(Song &s, bool isAll, bool skipEmpty) const;
#ifdef ENABLE_KDE_SUPPORT
void slotButtonClicked(int button);

View File

@@ -12,7 +12,7 @@
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<widget class="StateLabel" name="trackNameLabel">
<property name="text">
<string>Track:</string>
</property>
@@ -25,7 +25,7 @@
<widget class="QComboBox" name="trackName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="titleLabel">
<widget class="StateLabel" name="titleLabel">
<property name="text">
<string>Title:</string>
</property>
@@ -38,7 +38,7 @@
<widget class="LineEdit" name="title"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<widget class="StateLabel" name="artistLabel">
<property name="text">
<string>Artist:</string>
</property>
@@ -51,7 +51,7 @@
<widget class="CompletionCombo" name="artist"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<widget class="StateLabel" name="albumArtistLabel">
<property name="text">
<string>Album artist:</string>
</property>
@@ -64,7 +64,7 @@
<widget class="CompletionCombo" name="albumArtist"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<widget class="StateLabel" name="albumLabel">
<property name="text">
<string>Album:</string>
</property>
@@ -77,7 +77,7 @@
<widget class="CompletionCombo" name="album"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="trackLabel">
<widget class="StateLabel" name="trackLabel">
<property name="text">
<string>Track number:</string>
</property>
@@ -90,7 +90,7 @@
<widget class="ClearSpinBox" name="track"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<widget class="StateLabel" name="discLabel">
<property name="text">
<string>Disc number:</string>
</property>
@@ -103,7 +103,7 @@
<widget class="ClearSpinBox" name="disc"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<widget class="StateLabel" name="genreLabel">
<property name="text">
<string>Genre:</string>
</property>
@@ -116,7 +116,7 @@
<widget class="CompletionCombo" name="genre"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<widget class="StateLabel" name="yearLabel">
<property name="text">
<string>Year:</string>
</property>
@@ -146,6 +146,11 @@
<extends>QSpinBox</extends>
<header>clearspinbox.h</header>
</customwidget>
<customwidget>
<class>StateLabel</class>
<extends>QLabel</extends>
<header>statelabel.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>trackName</tabstop>

48
widgets/statelabel.h Normal file
View File

@@ -0,0 +1,48 @@
/*
* Cantata
*
* Copyright (c) 2011-2012 Craig Drummond <craig.p.drummond@gmail.com>
*
* ----
*
* 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 <QtGui/QLabel>
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