From db36b4b0d0b26b98ee4ff73ef2aedd110ee55d13 Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 13 Feb 2012 21:05:19 +0000 Subject: [PATCH] Set placeholder text to original artist/album/etc --- gui/tageditor.cpp | 27 +++++++++++++++++++++++++++ gui/tageditor.h | 1 + widgets/completioncombo.h | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/gui/tageditor.cpp b/gui/tageditor.cpp index f3ed5ef08..e2b286b7a 100644 --- a/gui/tageditor.cpp +++ b/gui/tageditor.cpp @@ -442,6 +442,7 @@ void TagEditor::setIndex(int idx) Song s=edited.at(!haveMultiple || idx==0 ? 0 : idx); setSong(s); currentSongIndex=idx; + setPlaceholderTexts(); bool isMultiple=haveMultiple && 0==idx; title->setEnabled(!isMultiple); @@ -496,6 +497,32 @@ void TagEditor::applyUpdates() } } +void TagEditor::setPlaceholderTexts() +{ + bool isAll=0==currentSongIndex && original.count()>1; + + if (isAll) { + Song all=original.at(0); + if (!all.artist.isEmpty()) { + artist->setPlaceholderText(all.artist); + } + if (!all.album.isEmpty()) { + album->setPlaceholderText(all.album); + } + if (!all.albumartist.isEmpty()) { + albumArtist->setPlaceholderText(all.albumartist); + } + if (!all.genre.isEmpty()) { + genre->setPlaceholderText(all.genre); + } + } else { + artist->setPlaceholderText(QString()); + album->setPlaceholderText(QString()); + albumArtist->setPlaceholderText(QString()); + genre->setPlaceholderText(QString()); + } +} + #ifdef ENABLE_KDE_SUPPORT void TagEditor::slotButtonClicked(int button) { diff --git a/gui/tageditor.h b/gui/tageditor.h index 6cd3b5193..41a1a2171 100644 --- a/gui/tageditor.h +++ b/gui/tageditor.h @@ -65,6 +65,7 @@ private: void updateTrackName(int index, bool edited); void updateEditedStatus(int index); void applyUpdates(); + void setPlaceholderTexts(); private Q_SLOTS: void applyVa(); diff --git a/widgets/completioncombo.h b/widgets/completioncombo.h index e5cb8f66f..e0215f511 100644 --- a/widgets/completioncombo.h +++ b/widgets/completioncombo.h @@ -61,6 +61,10 @@ public: QString text() const { return qobject_cast(lineEdit())->text(); } + + void setPlaceholderText(const QString &text) { + qobject_cast(lineEdit())->setPlaceholderText(text); + } }; #else #include @@ -83,6 +87,10 @@ public: QString text() const { return qobject_cast(lineEdit())->text(); } + + void setPlaceholderText(const QString &text) { + qobject_cast(lineEdit())->setPlaceholderText(text); + } }; #endif