Skip to content

Commit

Permalink
Move enum to file
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Oct 4, 2020
1 parent 33e03d5 commit c6fd5e9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/artistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ArtistView::ArtistView(spt::Spotify &spotify, const QString &artistId, const Set
.arg(artist.followers == 1 ? "" : "s");

// Artist name title
auto follows = spotify.isFollowing(spt::Spotify::FollowType::Artist, {artistId});
auto follows = spotify.isFollowing(FollowType::Artist, {artistId});
auto isFollowing = follows.isEmpty() ? false : follows[0];
auto title = new QHBoxLayout();
followButton = new QPushButton(this);
Expand Down Expand Up @@ -163,9 +163,9 @@ void ArtistView::follow(bool)
.replace(isFollowing ? "Unfollow" : "Follow",
isFollowing ? "Follow" : "Unfollow"));
if (isFollowing)
spotify.unfollow(spt::Spotify::FollowType::Artist, {artistId});
spotify.unfollow(FollowType::Artist, {artistId});
else
spotify.follow(spt::Spotify::FollowType::Artist, {artistId});
spotify.follow(FollowType::Artist, {artistId});
}

void ArtistView::trackClick(QListWidgetItem *item)
Expand Down
1 change: 1 addition & 0 deletions src/artistview.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "enum/followtype.hpp"
#include "mainwindow.hpp"
#include "menu/albummenu.hpp"
#include "menu/songmenu.hpp"
Expand Down
7 changes: 7 additions & 0 deletions src/enum/followtype.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

enum class FollowType
{
Artist,
User
};
4 changes: 2 additions & 2 deletions src/spotify/spotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,13 @@ QString Spotify::followTypeString(FollowType type)
return QString();
}

void Spotify::follow(Spotify::FollowType type, const QStringList &ids)
void Spotify::follow(FollowType type, const QStringList &ids)
{
put(QString("me/following?type=%1&ids=%2")
.arg(followTypeString(type)).arg(ids.join(',')));
}

void Spotify::unfollow(Spotify::FollowType type, const QStringList &ids)
void Spotify::unfollow(FollowType type, const QStringList &ids)
{
del(QString("me/following?type=%1&ids=%2")
.arg(followTypeString(type)).arg(ids.join(',')), {});
Expand Down
9 changes: 2 additions & 7 deletions src/spotify/spotify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace spt
}

#include "../dialog/deviceselectdialog.hpp"
#include "../enum/followtype.hpp"
#include "../settings.hpp"
#include "artist.hpp"
#include "audiofeatures.hpp"
#include "device.hpp"
#include "playback.hpp"
#include "playlist.hpp"
#include "searchresults.hpp"
#include "../settings.hpp"
#include "user.hpp"

#include <QCoreApplication>
Expand All @@ -33,12 +34,6 @@ namespace spt
Q_OBJECT

public:
enum class FollowType
{
Artist,
User
};

explicit Spotify(Settings &settings, QObject *parent = nullptr);

QJsonObject getAsObject(const QString &url);
Expand Down

0 comments on commit c6fd5e9

Please sign in to comment.