Album art fix for [#6370] Album art fails to load on first track
authordruid23 <usr@dru-id.co.uk>
Mon, 6 Sep 2010 19:45:13 +0000 (20:45 +0100)
committerdruid23 <usr@dru-id.co.uk>
Mon, 6 Sep 2010 19:45:13 +0000 (20:45 +0100)
Additional settings refactoring and preparation for dialog.
modified:   src/appsettings.cpp
modified:   src/appsettings.h
modified:   src/playermainwindow.cpp
modified:   src/playermainwindow.h

src/appsettings.cpp
src/appsettings.h
src/playermainwindow.cpp
src/playermainwindow.h

index e280c70..23f1598 100644 (file)
@@ -125,6 +125,12 @@ int AppSettings::getRetryNetworkTimeout() {
 bool AppSettings::getShowUnknownFileTypes() {
     return SHOW_UNKNOWN_FILETYPES;
 }
+bool AppSettings::getShowAlbumArt() {
+    return SHOW_ALBUM_ART;
+}
+bool AppSettings::getAlertOnClose() {
+    return ALERT_ON_CLOSE;
+}
 Orientation AppSettings::setOrientation(Orientation orientation) {
     QSettings sets;
     sets.setValue("config/orientation", (int)orientation);
index 35af82b..47ff5a0 100644 (file)
 #define SHOW_UNKNOWN_FILETYPES false
 #endif
 
+#ifndef SHOW_ALBUM_ART
+#define SHOW_ALBUM_ART true
+#endif
+
+#ifndef ALERT_ON_CLOSE
+#define ALERT_ON_CLOSE false
+#endif
+
 
 struct VlcDirectory {
     QString name;
@@ -73,6 +81,9 @@ public:
     static int getRetrieveArtTimeout();
     static int getRetryNetworkTimeout();
     static bool getShowUnknownFileTypes();
+    static bool getShowAlbumArt();
+    static bool getAlertOnClose();
+
 };
 
 #endif // APPSETTINGS_H
index 9e5363b..a400cd7 100644 (file)
@@ -35,7 +35,7 @@
       ui->setupUi(this);
       setWindowTitle("Vlc remote");
 
-
+      mIsFirstStatusCall = true;
 
       mTimer = new QTimer(this);
       mNetManager = new QNetworkAccessManager(this);
       doc.setContent(reply->readAll());
       delete reply;
       QDomElement docElem = doc.documentElement();
+      VlcStatusState oldState = mCurrentStatus.state;
       // Get the raw values
       int volume = docElem.namedItem("volume").toElement().text().toInt();
       int length = docElem.namedItem("length").toElement().text().toInt();
           }
           else {
             mCurrentStatus.state = UNKNOWN;
+            mIsFirstStatusCall = true;
           }
       }
       else {
           mCurrentStatus.state = UNKNOWN;
+          mIsFirstStatusCall = true;
       }
       mCurrentStatus.newtrack = true;
-      if ( (0 == mCurrentStatus.length || STOP == mCurrentStatus.state) // stopped or null
-              || // same track as current playing
-           (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && !title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) ){
-        mCurrentStatus.newtrack = false;
+      if (mIsFirstStatusCall) {
+          mIsFirstStatusCall = false;
+          mCurrentStatus.newtrack = true; // unneeded but self-documenting
+      }
+      else if (STOP == oldState && STOP != mCurrentStatus.state) {
+          mCurrentStatus.newtrack = true; // unneeded but self-documenting
+      }
+      else {
+          if ( (0 == mCurrentStatus.length || STOP == mCurrentStatus.state) // stopped or null
+                  || // same track as current playing
+               (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && !title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) ){
+            mCurrentStatus.newtrack = false;
+          }
       }
       mCurrentStatus.volume = volume;
       mCurrentStatus.length = length;
           ui->playpauseButton->setIcon(QIcon::fromTheme("camera_playback"));
       }
 
-      if (mCurrentStatus.newtrack) {
+      if (STOP == mCurrentStatus.state) {
+          ui->labelArtPortrait->setVisible(false);
+          ui->labelArtLandscape->setVisible(false);
+      }
+
+      if (mCurrentStatus.newtrack && STOP != mCurrentStatus.state) {
           // potential actions:
           //   rebuild display layout
           //   retrieve album art
index 84bcbf4..85eada0 100644 (file)
@@ -87,6 +87,7 @@ private:
     QByteArray mResponse;
     bool mIsLandscape;
     bool mHasImage;
+    bool mIsFirstStatusCall;
 
 };