From 4e2e6ca7598ece1ed724fb36fdd4f850e8dd7263 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Wed, 29 Jan 2014 19:17:43 +0000 Subject: [PATCH] Add URL label if mopidy is used --- devices/actiondialog.cpp | 20 ++++++++++++++++++++ devices/actiondialog.h | 1 + devices/actiondialog.ui | 23 +++++++++++++++-------- tags/tageditor.cpp | 26 ++++++++++++++++++-------- tags/tageditor.h | 1 + tags/tageditor.ui | 12 ++++++++++++ tags/trackorganiser.cpp | 34 +++++++++++++++++++++++----------- tags/trackorganiser.h | 4 ++-- tags/trackorganiser.ui | 12 ++++++++++++ 9 files changed, 104 insertions(+), 29 deletions(-) diff --git a/devices/actiondialog.cpp b/devices/actiondialog.cpp index 39e290708..d2839b6c4 100644 --- a/devices/actiondialog.cpp +++ b/devices/actiondialog.cpp @@ -55,6 +55,11 @@ #include #endif +#define REMOVE(w) \ + w->setVisible(false); \ + w->deleteLater(); \ + w=0 + static int iCount=0; int ActionDialog::instanceCount() @@ -175,6 +180,15 @@ void ActionDialog::showSongs() songDialog->show(); } +void ActionDialog::showMopidyMessage() +{ + MessageBox::information(this, i18n("Cantata has detected that you are connected to a Mopidy server.\n\n" + "Currently it is not possible for Cantata to force Mopidy to refresh its local " + "music listing. Therefore, you will need to stop Cantata, manually refresh " + "Mopidy's database, and restart Cantata for any changes to be active."), + QLatin1String("Mopidy")); +} + void ActionDialog::hideSongs() { if (songDialog) { @@ -369,6 +383,12 @@ void ActionDialog::init(const QString &srcUdi, const QString &dstUdi, const QLis albumsWithoutRgTags.clear(); #endif updateUnity(false); + + if ((Remove==m && srcUdi.isEmpty()) || (Copy==m && !srcUdi.isEmpty())) { + connect(mopidyNote, SIGNAL(leftClickedUrl()), SLOT(showMopidyMessage())); + } else { + REMOVE(mopidyNote); + } } void ActionDialog::slotButtonClicked(int button) diff --git a/devices/actiondialog.h b/devices/actiondialog.h index c4f22b747..5da7c4aa5 100644 --- a/devices/actiondialog.h +++ b/devices/actiondialog.h @@ -76,6 +76,7 @@ private Q_SLOTS: void cacheSaved(); void controlInfoLabel(); void showSongs(); + void showMopidyMessage(); private: void hideSongs(); diff --git a/devices/actiondialog.ui b/devices/actiondialog.ui index b2ade19b9..2d7829e96 100644 --- a/devices/actiondialog.ui +++ b/devices/actiondialog.ui @@ -143,28 +143,35 @@ - + Destination format: - + - + + + + Overwrite songs + + + + To copy: - + @@ -174,10 +181,10 @@ - - - - Overwrite songs + + + + <i><b>NOTE:</b> Connected to a Mopidy server (manual update required).</i> diff --git a/tags/tageditor.cpp b/tags/tageditor.cpp index ceaccd072..3a498e10a 100644 --- a/tags/tageditor.cpp +++ b/tags/tageditor.cpp @@ -104,10 +104,12 @@ TagEditor::TagEditor(QWidget *parent, const QList &songs, return; } + bool isMopidy=false; #ifdef ENABLE_DEVICES_SUPPORT if (deviceUdi.isEmpty()) { baseDir=MPDConnection::self()->getDetails().dir; composerSupport=MPDConnection::self()->composerTagSupported(); + isMopidy=MPDConnection::self()->isMopdidy(); } else { Device *dev=getDevice(udi, parentWidget()); @@ -121,6 +123,7 @@ TagEditor::TagEditor(QWidget *parent, const QList &songs, #else baseDir=MPDConnection::self()->getDetails().dir; composerSupport=MPDConnection::self()->composerTagSupported(); + isMopidy=MPDConnection::self()->isMopdidy(); #endif qSort(original); @@ -130,6 +133,11 @@ TagEditor::TagEditor(QWidget *parent, const QList &songs, QWidget *mainWidet = new QWidget(this); setupUi(mainWidet); + if (isMopidy) { + connect(mopidyNote, SIGNAL(leftClickedUrl()), SLOT(showMopidyMessage())); + } else { + REMOVE(mopidyNote); + } setMainWidget(mainWidet); ButtonCodes buttons=Ok|Cancel|Reset|User3; if (songs.count()>1) { @@ -700,6 +708,15 @@ void TagEditor::setIndex(int idx) updating=false; } +void TagEditor::showMopidyMessage() +{ + MessageBox::information(this, i18n("Cantata has detected that you are connected to a Mopidy server.\n\n" + "Currently it is not possible for Cantata to force Mopidy to refresh its local " + "music listing. Therefore, you will need to stop Cantata, manually refresh " + "Mopidy's database, and restart Cantata for any changes to be active."), + QLatin1String("Mopidy")); +} + bool TagEditor::applyUpdates() { bool skipFirst=original.count()>1; @@ -806,17 +823,10 @@ bool TagEditor::applyUpdates() emit update(); } - if (MPDConnection::self()->isMopdidy()) { - MessageBox::information(this, i18n("Cantata has detected that you are connected to a Mopidy server.\n\n" - "In order for Mopidy to notice the changes you have made, you will need " - "to manually update its database. After this, restart Cantata.")); - MusicLibraryModel::self()->removeCache(); - } - if (renameFiles && MessageBox::Yes==MessageBox::questionYesNo(this, i18n("Would you also like to rename your song files, so as to match your tags?"), i18n("Rename Files"), GuiItem(i18n("Rename")), StdGuiItem::cancel())) { - TrackOrganiser *dlg=new TrackOrganiser(parentWidget(), false); + TrackOrganiser *dlg=new TrackOrganiser(parentWidget()); dlg->show(updatedSongs, udi); } } diff --git a/tags/tageditor.h b/tags/tageditor.h index 591113859..70187bf88 100644 --- a/tags/tageditor.h +++ b/tags/tageditor.h @@ -74,6 +74,7 @@ private Q_SLOTS: void updateEdited(bool isFromAll=false); void setSong(const Song &s); void setIndex(int idx); + void showMopidyMessage(); private: QString baseDir; diff --git a/tags/tageditor.ui b/tags/tageditor.ui index a73df0ef5..7ed54dd9e 100644 --- a/tags/tageditor.ui +++ b/tags/tageditor.ui @@ -151,6 +151,13 @@ + + + + <i><b>NOTE:</b> Connected to a Mopidy server (manual update required).</i> + + + @@ -182,6 +189,11 @@ QLabel
statelabel.h
+ + UrlLabel + QLabel +
urllabel.h
+
trackName diff --git a/tags/trackorganiser.cpp b/tags/trackorganiser.cpp index 4fe32da66..713a57b7e 100644 --- a/tags/trackorganiser.cpp +++ b/tags/trackorganiser.cpp @@ -42,6 +42,11 @@ #include #include +#define REMOVE(w) \ + w->setVisible(false); \ + w->deleteLater(); \ + w=0; + static int iCount=0; int TrackOrganiser::instanceCount() @@ -49,13 +54,12 @@ int TrackOrganiser::instanceCount() return iCount; } -TrackOrganiser::TrackOrganiser(QWidget *parent, bool showMopidyWarning) +TrackOrganiser::TrackOrganiser(QWidget *parent) : SongDialog(parent, "TrackOrganiser", QSize(800, 500)) , schemeDlg(0) , autoSkip(false) , paused(false) , updated(false) - , warnIfMopidy(showMopidyWarning) { iCount++; setButtons(Ok|Cancel); @@ -98,10 +102,12 @@ void TrackOrganiser::show(const QList &songs, const QString &udi) } QString musicFolder; + bool isMopidy=false; #ifdef ENABLE_DEVICES_SUPPORT if (udi.isEmpty()) { musicFolder=MPDConnection::self()->getDetails().dir; opts.load(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true); + isMopidy=MPDConnection::self()->isMopdidy(); } else { deviceUdi=udi; Device *dev=getDevice(parentWidget()); @@ -117,6 +123,7 @@ void TrackOrganiser::show(const QList &songs, const QString &udi) #else opts.load(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true); musicFolder=MPDConnection::self()->getDetails().dir; + isMopidy=MPDConnection::self()->isMopdidy(); #endif qSort(origSongs); @@ -135,7 +142,11 @@ void TrackOrganiser::show(const QList &songs, const QString &udi) if (!songsOk(origSongs, musicFolder, udi.isEmpty())) { return; } - + if (isMopidy) { + connect(mopidyNote, SIGNAL(leftClickedUrl()), SLOT(showMopidyMessage())); + } else { + REMOVE(mopidyNote); + } Dialog::show(); enableButtonOk(false); updateView(); @@ -428,17 +439,18 @@ void TrackOrganiser::removeItems() } } +void TrackOrganiser::showMopidyMessage() +{ + MessageBox::information(this, i18n("Cantata has detected that you are connected to a Mopidy server.\n\n" + "Currently it is not possible for Cantata to force Mopidy to refresh its local " + "music listing. Therefore, you will need to stop Cantata, manually refresh " + "Mopidy's database, and restart Cantata for any changes to be active."), + QLatin1String("Mopidy")); +} + void TrackOrganiser::finish(bool ok) { if (updated) { - if (warnIfMopidy && MPDConnection::self()->isMopdidy()) { - MessageBox::information(this, i18n("Cantata has detected that you are connected to a Mopidy server.\n\n" - "In order for Mopidy to notice the changes you have made, you will need " - "to manually update its database. After this, restart Cantata.")); - MusicLibraryModel::self()->removeCache(); - DirViewModel::self()->removeCache(); - } - if (deviceUdi.isEmpty()) { emit update(); } diff --git a/tags/trackorganiser.h b/tags/trackorganiser.h index 6d6ce8796..a7114bf72 100644 --- a/tags/trackorganiser.h +++ b/tags/trackorganiser.h @@ -43,7 +43,7 @@ class TrackOrganiser : public SongDialog, Ui::TrackOrganiser public: static int instanceCount(); - TrackOrganiser(QWidget *parent, bool showMopidyWarning=true); + TrackOrganiser(QWidget *parent); virtual ~TrackOrganiser(); void show(const QList &songs, const QString &udi); @@ -59,6 +59,7 @@ private Q_SLOTS: void renameFile(); void controlRemoveAct(); void removeItems(); + void showMopidyMessage(); private: void slotButtonClicked(int button); @@ -77,7 +78,6 @@ private: bool autoSkip; bool paused; bool updated; - bool warnIfMopidy; DeviceOptions opts; }; diff --git a/tags/trackorganiser.ui b/tags/trackorganiser.ui index a78acc657..c35cd0615 100644 --- a/tags/trackorganiser.ui +++ b/tags/trackorganiser.ui @@ -124,6 +124,13 @@
+ + + + <i><b>NOTE:</b> Connected to a Mopidy server (manual update required).</i> + + + @@ -140,6 +147,11 @@ QLabel
buddylabel.h
+ + UrlLabel + QLabel +
urllabel.h
+
vfatSafe