diff --git a/qml/ConnectionPage.qml b/qml/ConnectionPage.qml index e4e5ea6..a88db95 100644 --- a/qml/ConnectionPage.qml +++ b/qml/ConnectionPage.qml @@ -8,6 +8,14 @@ Item { objectName: "ConnectionPage" signal qmlSignalAuth() +// Component.onCompleted: { +// settings.initialize() +// settings.onUrlChanged(onUrlChanged) +// settings.onUsernameChanged(onUsernameChanged) +// settings.onPasswordChanged(onPasswordChanged) +//// playingTrack.coverChanged.connect(filling) +// } + // settings.onUrlChanged: connectionPage.onUrlChanged() Column { @@ -18,31 +26,31 @@ Item { TextField { id: hostInput -// onAccepted: passwordInput.forceActiveFocus() + onAccepted: portInput.forceActiveFocus() placeholderText: "owncloud host" -// KeyNavigation.tab: nameInput - text: "http://192.168.1.15" + KeyNavigation.tab: portInput + text: "http://" } TextField { id: portInput -// onAccepted: passwordInput.forceActiveFocus() + onAccepted: pathInput.forceActiveFocus() placeholderText: "owncloud port" -// KeyNavigation.tab: nameInput + KeyNavigation.tab: pathInput text: "80" } TextField { id: pathInput -// onAccepted: passwordInput.forceActiveFocus() + onAccepted: nameInput.forceActiveFocus() placeholderText: "owncloud path to index.php" -// KeyNavigation.tab: nameInput + KeyNavigation.tab: nameInput text: "/owncloud/index.php" } TextField { id: nameInput -// onAccepted: passwordInput.forceActiveFocus() + onAccepted: passwordInput.forceActiveFocus() placeholderText: "Username" KeyNavigation.tab: passwordInput } @@ -121,7 +129,9 @@ Item { function onInitFields() { console.log("on init fields") - urlInput.text = settings.url + hostInput.text = settings.url + portInput.text = settings.url_port + pathInput.text = settings.url_path nameInput.text = settings.username passwordInput.text = settings.password } diff --git a/qml/main.qml b/qml/main.qml index 53ebe9b..cec632f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -58,23 +58,23 @@ ApplicationWindow { } //Костыль ToFix - onUrlChanged: { - if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { - mainForm.stackCurrentItem().onUrlChanged() - } - } - - onUsernameChanged: { - if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { - mainForm.stackCurrentItem().onUsernameChanged() - } - } - - onPasswordChanged: { - if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { - mainForm.stackCurrentItem().onPasswordChanged() - } - } +// onUrlChanged: { +// if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { +// mainForm.stackCurrentItem().onUrlChanged() +// } +// } + +// onUsernameChanged: { +// if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { +// mainForm.stackCurrentItem().onUsernameChanged() +// } +// } + +// onPasswordChanged: { +// if (mainForm.stackCurrentItem().objectName === "ConnectionPage") { +// mainForm.stackCurrentItem().onPasswordChanged() +// } +// } // onSignalSettingsFilled: cloudClient.auth() } @@ -115,7 +115,7 @@ ApplicationWindow { property string track: "No track name" property string artist: "No artist name" property string album: "No album name" - property string coverId: -1 + property int coverId: -1 property string connectionState: "Disconnected" diff --git a/src/Album.cpp b/src/Album.cpp index 468027c..374b24f 100644 --- a/src/Album.cpp +++ b/src/Album.cpp @@ -2,6 +2,7 @@ Album::Album(const QString& name, const quint32 year, + const quint32 owncloudId, const QString& cover, const quint64& artistId, QObject* parent) @@ -10,6 +11,7 @@ Album::Album(const QString& name, { m_name = name; m_year = year; + m_owncloudId = owncloudId; m_cover = cover; m_globalId = GlobalAlbumIndex::instance()->getIndex(); m_artistId = artistId; @@ -42,6 +44,11 @@ quint64 Album::getArtistId() const return m_artistId; } +quint32 Album::getOwncloudId() const +{ + return m_owncloudId; +} + void Album::addTrack(Track* track) { m_tracksModel->appendRow(track); @@ -67,6 +74,8 @@ QVariant Album::data(int role) const return getCover(); case albumArtistId: return getArtistId(); + case albumOwncloudId: + return getOwncloudId(); default: return QVariant(); } @@ -82,6 +91,7 @@ QHash Album::roleNames() const roles[albumTracks] = "albumTracks"; roles[albumCover] = "albumCover"; roles[albumArtistId] = "albumArtistId"; + roles[albumOwncloudId] = "albumOwncloudId"; return roles; } diff --git a/src/Album.h b/src/Album.h index 191bcb0..4dc3370 100644 --- a/src/Album.h +++ b/src/Album.h @@ -22,13 +22,16 @@ class Album : public Models::SubListedListItem quint64 m_globalId; // album quint64 m_artistId; + quint32 m_owncloudId; + enum AlbumModelItemRoles { albumId = Qt::UserRole + 1, albumName, albumYear, albumTracks, albumCover, - albumArtistId + albumArtistId, + albumOwncloudId }; QSharedPointer m_tracksModel; @@ -36,6 +39,7 @@ class Album : public Models::SubListedListItem public: explicit Album(const QString& name, const quint32 year, + const quint32 owncloudId, const QString& cover, const quint64& artistId, QObject *parent = NULL); @@ -45,7 +49,7 @@ class Album : public Models::SubListedListItem QVariant getTracks() const; QString getCover() const; quint64 getArtistId() const; - + quint32 getOwncloudId() const; void addTrack(Track* track); // ListItem interface diff --git a/src/Artist.cpp b/src/Artist.cpp index c05d830..2145a05 100644 --- a/src/Artist.cpp +++ b/src/Artist.cpp @@ -7,7 +7,7 @@ Artist::Artist(const QString& name, QObject* parent) m_name = name; m_globalId = GlobalArtistIndex::instance()->getIndex(); - m_albumsModel = QSharedPointer(new Models::SubListedListModel(new Album("empty", 0, "empty", 0, NULL))); + m_albumsModel = QSharedPointer(new Models::SubListedListModel(new Album("empty", 0, 0, "empty", 0, NULL))); m_albumsModel->setSorting(true); } diff --git a/src/QwnImageProvider.cpp b/src/QwnImageProvider.cpp index 724ad3d..5bdf6a4 100644 --- a/src/QwnImageProvider.cpp +++ b/src/QwnImageProvider.cpp @@ -17,11 +17,11 @@ QImage QwnImageProvider::requestImage(const QString& id, QSize* size, const QSiz QUrl url(SettingsManager::instance()->getOwnCloudHost()); url.setPort(SettingsManager::instance()->getOwnCloudPort().toInt()); -// QString path = SettingsManager::instance()->getOwnCloudPath() -// + SettingsManager::instance()->getApiCover() -// + id -// + "/cover"; - url.setPath(id); + QString path = SettingsManager::instance()->getOwnCloudPath() + + SettingsManager::instance()->getApiCover() + + id + + "/cover"; + url.setPath(path); url.setUserName(SettingsManager::instance()->getUserName()); url.setPassword(SettingsManager::instance()->getUserPassword()); diff --git a/src/QwnMediaPlayer.cpp b/src/QwnMediaPlayer.cpp index cdf6811..e62e7a2 100644 --- a/src/QwnMediaPlayer.cpp +++ b/src/QwnMediaPlayer.cpp @@ -120,8 +120,8 @@ void QwnMediaPlayer::slotCurrentIndexChanged(int index) quint64 artistId = album->getArtistId(); Artist* artist = m_musicLibrary->getArtist(artistId); - qint32 coverId = -1; - QString coverPath = album->getCover(); + qint32 coverId = album->getOwncloudId(); +// QString coverPath = album->getCover(); // if (!coverPath.isNull()) { // QStringList stringList = coverPath.split("/"); // QString strTemp = stringList.at(7); @@ -129,7 +129,7 @@ void QwnMediaPlayer::slotCurrentIndexChanged(int index) // } emit signalPlayingTrackChanged(trackTitle, artist->getName(), album->getName()); - emit signalCoverChanged(coverPath); + emit signalCoverChanged(coverId); emit signalCurrentTrackIndexChanged(index); } diff --git a/src/QwnMediaPlayer.h b/src/QwnMediaPlayer.h index a554e6b..edeb7b2 100644 --- a/src/QwnMediaPlayer.h +++ b/src/QwnMediaPlayer.h @@ -40,7 +40,7 @@ class QwnMediaPlayer : public QObject void signalDurationChanged(qint64 duration); void signalPlayingTrackChanged(QString title, QString artist, QString album); void signalPlayingStateChanged(QMediaPlayer::State state); - void signalCoverChanged(QString coverPath); + void signalCoverChanged(quint32 coverId); void signalCurrentTrackIndexChanged(qint32 index); // connections with qmediaplayer diff --git a/src/ResponseDecoder.cpp b/src/ResponseDecoder.cpp index 29915ab..0360a56 100644 --- a/src/ResponseDecoder.cpp +++ b/src/ResponseDecoder.cpp @@ -61,6 +61,8 @@ Album* ResponseDecoder::createAlbum(const QJsonObject& jsonObject, Artist* artis jsonObject["name"].toString(), // Year jsonObject["year"].toInt(), + // Owncloud ID (for cover) + jsonObject["id"].toInt(), // Cover jsonObject["cover"].toString(), // Artist ID