make format

This commit is contained in:
Vlad Maltsev 2014-08-03 19:40:06 +07:00
parent bff79664bc
commit e65596cba6
8 changed files with 117 additions and 127 deletions

View File

@ -30,33 +30,31 @@
static const QUrl kVkOAuthEndpoint("https://oauth.vk.com/authorize"); static const QUrl kVkOAuthEndpoint("https://oauth.vk.com/authorize");
static const QUrl kVkOAuthTokenEndpoint("https://oauth.vk.com/access_token"); static const QUrl kVkOAuthTokenEndpoint("https://oauth.vk.com/access_token");
static const QUrl kApiUrl("https://api.vk.com/method/"); static const QUrl kApiUrl("https://api.vk.com/method/");
static const char *kScopeNames[] = { "notify", "friends", "photos", "audio", static const char* kScopeNames[] = {
"video", "docs", "notes", "pages", "status", "offers", "questions", "wall", "notify", "friends", "photos", "audio", "video", "docs",
"groups", "messages", "notifications", "stats", "ads", "offline" }; "notes", "pages", "status", "offers", "questions", "wall",
"groups", "messages", "notifications", "stats", "ads", "offline"};
static const QString kAppID = "3421812"; static const QString kAppID = "3421812";
static const QString kAppSecret = "cY7KMyX46Fq3nscZlbdo"; static const QString kAppSecret = "cY7KMyX46Fq3nscZlbdo";
static const VkConnection::Scopes kScopes = static const VkConnection::Scopes kScopes =
VkConnection::Offline | VkConnection::Offline | VkConnection::Audio | VkConnection::Friends |
VkConnection::Audio | VkConnection::Groups | VkConnection::Status;
VkConnection::Friends |
VkConnection::Groups |
VkConnection::Status;
static const char* kSettingsGroup = "Vk.com/oauth"; static const char* kSettingsGroup = "Vk.com/oauth";
VkConnection::VkConnection(QObject* parent) VkConnection::VkConnection(QObject* parent)
: Connection(parent), : Connection(parent),
state_(Vreen::Client::StateOffline), state_(Vreen::Client::StateOffline),
expires_in_(0), expires_in_(0),
uid_(0) { uid_(0) {
loadToken(); loadToken();
} }
VkConnection::~VkConnection() { VkConnection::~VkConnection() {}
}
void VkConnection::connectToHost(const QString& login, const QString& password) { void VkConnection::connectToHost(const QString& login,
const QString& password) {
Q_UNUSED(login) Q_UNUSED(login)
Q_UNUSED(password) Q_UNUSED(password)
if (hasAccount()) { if (hasAccount()) {
@ -85,16 +83,17 @@ void VkConnection::clear() {
} }
bool VkConnection::hasAccount() { bool VkConnection::hasAccount() {
return !access_token_.isNull() return !access_token_.isNull() &&
&& (expires_in_ > static_cast<time_t>(QDateTime::currentDateTime().toTime_t())); (expires_in_ >
static_cast<time_t>(QDateTime::currentDateTime().toTime_t()));
} }
QNetworkRequest VkConnection::makeRequest(const QString& method, const QVariantMap& args) { QNetworkRequest VkConnection::makeRequest(const QString& method,
const QVariantMap& args) {
QUrl url = kApiUrl; QUrl url = kApiUrl;
url.setPath(url.path() % QLatin1Literal("/") % method); url.setPath(url.path() % QLatin1Literal("/") % method);
for (auto it = args.constBegin(); it != args.constEnd(); ++it) { for (auto it = args.constBegin(); it != args.constEnd(); ++it) {
url.addQueryItem(it.key(), url.addQueryItem(it.key(), it.value().toString());
it.value().toString());
} }
url.addEncodedQueryItem("access_token", access_token_); url.addEncodedQueryItem("access_token", access_token_);
return QNetworkRequest(url); return QNetworkRequest(url);
@ -119,9 +118,9 @@ void VkConnection::requestAccessToken() {
qLog(Debug) << "Try to login to Vk.com" << url; qLog(Debug) << "Try to login to Vk.com" << url;
NewClosure(server, SIGNAL(Finished()), NewClosure(server, SIGNAL(Finished()), this,
this, SLOT(codeRecived(LocalRedirectServer*, QUrl)), SLOT(codeRecived(LocalRedirectServer*, QUrl)), server,
server, server->url()); server->url());
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }

View File

@ -25,17 +25,16 @@
#include "core/taskmanager.h" #include "core/taskmanager.h"
VkMusicCache::VkMusicCache(Application* app, VkService* service) VkMusicCache::VkMusicCache(Application* app, VkService* service)
: QObject(service), : QObject(service),
app_(app), app_(app),
service_(service), service_(service),
current_song_index(0), current_song_index(0),
is_downloading(false), is_downloading(false),
is_aborted(false), is_aborted(false),
task_id(0), task_id(0),
file_(NULL), file_(NULL),
network_manager_(new QNetworkAccessManager), network_manager_(new QNetworkAccessManager),
reply_(NULL) { reply_(NULL) {}
}
QUrl VkMusicCache::Get(const QUrl& url) { QUrl VkMusicCache::Get(const QUrl& url) {
QUrl result; QUrl result;
@ -47,7 +46,8 @@ QUrl VkMusicCache::Get(const QUrl& url) {
return result; return result;
} }
void VkMusicCache::AddToCache(const QUrl& url, const QUrl&media_url, bool force) { void VkMusicCache::AddToCache(const QUrl& url, const QUrl& media_url,
bool force) {
AddToQueue(CachedFilename(url), media_url); AddToQueue(CachedFilename(url), media_url);
if (!force) { if (!force) {
current_song_index = queue_.size(); current_song_index = queue_.size();
@ -71,7 +71,8 @@ void VkMusicCache::BreakCurrentCaching() {
* Queue operations * Queue operations
*/ */
void VkMusicCache::AddToQueue(const QString& filename, const QUrl& download_url) { void VkMusicCache::AddToQueue(const QString& filename,
const QUrl& download_url) {
DownloadItem item; DownloadItem item;
item.filename = filename; item.filename = filename;
item.url = download_url; item.url = download_url;
@ -93,7 +94,8 @@ void VkMusicCache::DownloadNext() {
// Check file path and file existance first // Check file path and file existance first
if (QFile::exists(current_download.filename)) { if (QFile::exists(current_download.filename)) {
qLog(Warning) << "Tried to overwrite already cached file" << current_download.filename; qLog(Warning) << "Tried to overwrite already cached file"
<< current_download.filename;
return; return;
} }
@ -113,14 +115,15 @@ void VkMusicCache::DownloadNext() {
// Start downloading // Start downloading
is_aborted = false; is_aborted = false;
is_downloading = true; is_downloading = true;
task_id = app_->task_manager()-> task_id = app_->task_manager()->StartTask(
StartTask(tr("Caching %1") tr("Caching %1").arg(QFileInfo(current_download.filename).baseName()));
.arg(QFileInfo(current_download.filename).baseName()));
reply_ = network_manager_->get(QNetworkRequest(current_download.url)); reply_ = network_manager_->get(QNetworkRequest(current_download.url));
connect(reply_, SIGNAL(finished()), SLOT(Downloaded())); connect(reply_, SIGNAL(finished()), SLOT(Downloaded()));
connect(reply_, SIGNAL(readyRead()), SLOT(DownloadReadyToRead())); connect(reply_, SIGNAL(readyRead()), SLOT(DownloadReadyToRead()));
connect(reply_, SIGNAL(downloadProgress(qint64, qint64)), SLOT(DownloadProgress(qint64, qint64))); connect(reply_, SIGNAL(downloadProgress(qint64, qint64)),
qLog(Info)<< "Start cashing" << current_download.filename << "from" << current_download.url; SLOT(DownloadProgress(qint64, qint64)));
qLog(Info) << "Start cashing" << current_download.filename << "from"
<< current_download.url;
} }
} }
@ -150,13 +153,13 @@ void VkMusicCache::Downloaded() {
QString path = service_->cacheDir(); QString path = service_->cacheDir();
if (file_->size() > 0) { if (file_->size() > 0) {
QDir(path).mkpath(QFileInfo(current_download.filename).path()); QDir(path).mkpath(QFileInfo(current_download.filename).path());
if (file_->copy(current_download.filename)) { if (file_->copy(current_download.filename)) {
qLog(Info) << "Cached" << current_download.filename; qLog(Info) << "Cached" << current_download.filename;
} else { } else {
qLog(Error) << "Unable to save" << current_download.filename qLog(Error) << "Unable to save" << current_download.filename << ":"
<< ":" << file_->errorString(); << file_->errorString();
} }
} else { } else {
qLog(Error) << "File" << current_download.filename << "is empty"; qLog(Error) << "File" << current_download.filename << "is empty";
@ -190,7 +193,8 @@ QString VkMusicCache::CachedFilename(const QUrl& url) {
cache_filename.replace("%artist", args[2]); cache_filename.replace("%artist", args[2]);
cache_filename.replace("%title", args[3]); cache_filename.replace("%title", args[3]);
} else { } else {
qLog(Warning) << "Song url with args" << args << "does not contain artist and title" qLog(Warning) << "Song url with args" << args
<< "does not contain artist and title"
<< "use id as file name for cache."; << "use id as file name for cache.";
cache_filename = args[1]; cache_filename = args[1];
} }
@ -201,5 +205,5 @@ QString VkMusicCache::CachedFilename(const QUrl& url) {
return ""; return "";
} }
// TODO(Vk): Maybe use extenstion from link? Seems it's always mp3. // TODO(Vk): Maybe use extenstion from link? Seems it's always mp3.
return cache_dir+QDir::separator()+cache_filename+".mp3"; return cache_dir + QDir::separator() + cache_filename + ".mp3";
} }

View File

@ -30,7 +30,7 @@ class Application;
class VkMusicCache : public QObject { class VkMusicCache : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit VkMusicCache(Application* app, VkService* service); explicit VkMusicCache(Application* app, VkService* service);
~VkMusicCache() {} ~VkMusicCache() {}
// Return file path if file in cache otherwise // Return file path if file in cache otherwise
@ -40,19 +40,19 @@ public:
void BreakCurrentCaching(); void BreakCurrentCaching();
bool InCache(const QUrl& url); bool InCache(const QUrl& url);
private slots: private slots:
void AddToQueue(const QString& filename, const QUrl& download_url); void AddToQueue(const QString& filename, const QUrl& download_url);
void DownloadNext(); void DownloadNext();
void DownloadProgress(qint64 bytesReceived, qint64 bytesTotal); void DownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void DownloadReadyToRead(); void DownloadReadyToRead();
void Downloaded(); void Downloaded();
private: private:
struct DownloadItem { struct DownloadItem {
QString filename; QString filename;
QUrl url; QUrl url;
bool operator ==(const DownloadItem& rhv) { bool operator==(const DownloadItem& rhv) {
return filename == rhv.filename; return filename == rhv.filename;
} }
}; };

View File

@ -1026,7 +1026,7 @@ Vreen::AudioItem VkService::GetAudioItemFromUrl(const QUrl& url) {
return Vreen::AudioItem(); return Vreen::AudioItem();
} }
UrlHandler::LoadResult VkService::GetSongResult(const QUrl&url) { UrlHandler::LoadResult VkService::GetSongResult(const QUrl& url) {
// Try get from cache // Try get from cache
QUrl media_url = cache_->Get(url); QUrl media_url = cache_->Get(url);
if (media_url.isValid()) { if (media_url.isValid()) {
@ -1093,13 +1093,13 @@ void VkService::SongStarting(const QUrl& url) {
SongStarting(SongFromUrl(url)); SongStarting(SongFromUrl(url));
} }
void VkService::SongStarting(const Song &song) void VkService::SongStarting(const Song& song) {
{
current_song_ = song; current_song_ = song;
if (isBroadcasting() && HasAccount()) { if (isBroadcasting() && HasAccount()) {
auto id = ExtractIds(song.url()); auto id = ExtractIds(song.url());
auto reply = audio_provider_->setBroadcast(id.audio_id, id.owner_id, IdList()); auto reply =
audio_provider_->setBroadcast(id.audio_id, id.owner_id, IdList());
NewClosure(reply, SIGNAL(resultReady(QVariant)), this, NewClosure(reply, SIGNAL(resultReady(QVariant)), this,
SLOT(BroadcastChangeReceived(Vreen::IntReply*)), reply); SLOT(BroadcastChangeReceived(Vreen::IntReply*)), reply);
connect(app_->player(), SIGNAL(Stopped()), this, SLOT(SongStoped()), connect(app_->player(), SIGNAL(Stopped()), this, SLOT(SongStoped()),
@ -1113,8 +1113,7 @@ void VkService::SongSkiped() {
cache_->BreakCurrentCaching(); cache_->BreakCurrentCaching();
} }
void VkService::SongStoped() void VkService::SongStoped() {
{
current_song_.set_valid(false); current_song_.set_valid(false);
if (isBroadcasting() && HasAccount()) { if (isBroadcasting() && HasAccount()) {
@ -1126,8 +1125,7 @@ void VkService::SongStoped()
} }
} }
void VkService::BroadcastChangeReceived(Vreen::IntReply *reply) void VkService::BroadcastChangeReceived(Vreen::IntReply* reply) {
{
qLog(Debug) << "Broadcast changed for " << reply->result(); qLog(Debug) << "Broadcast changed for " << reply->result();
} }
@ -1298,8 +1296,8 @@ void VkService::ReloadSettings() {
groups_in_global_search_ = s.value("groups_in_global_search", false).toBool(); groups_in_global_search_ = s.value("groups_in_global_search", false).toBool();
if (!s.contains("enable_broadcast")) { if (!s.contains("enable_broadcast")) {
// Need to update premissions // Need to update premissions
Logout(); Logout();
} }
enable_broadcast_ = s.value("enable_broadcast", false).toBool(); enable_broadcast_ = s.value("enable_broadcast", false).toBool();
} }

View File

@ -44,11 +44,8 @@ class VkSearchDialog;
* using in bookmarks. * using in bookmarks.
*/ */
class MusicOwner { class MusicOwner {
public: public:
MusicOwner() : MusicOwner() : songs_count_(0), id_(0) {}
songs_count_(0),
id_(0)
{}
explicit MusicOwner(const QUrl& group_url); explicit MusicOwner(const QUrl& group_url);
Song toOwnerRadio() const; Song toOwnerRadio() const;
@ -58,7 +55,7 @@ public:
int song_count() const { return songs_count_; } int song_count() const { return songs_count_; }
static QList<MusicOwner> parseMusicOwnerList(const QVariant& request_result); static QList<MusicOwner> parseMusicOwnerList(const QVariant& request_result);
private: private:
friend QDataStream& operator<<(QDataStream& stream, const MusicOwner& val); friend QDataStream& operator<<(QDataStream& stream, const MusicOwner& val);
friend QDataStream& operator>>(QDataStream& stream, MusicOwner& val); friend QDataStream& operator>>(QDataStream& stream, MusicOwner& val);
friend QDebug operator<<(QDebug d, const MusicOwner& owner); friend QDebug operator<<(QDebug d, const MusicOwner& owner);
@ -66,7 +63,8 @@ private:
int songs_count_; int songs_count_;
int id_; // if id > 0 is user otherwise id group int id_; // if id > 0 is user otherwise id group
QString name_; QString name_;
// name used in url http://vk.com/<screen_name> for example: http://vk.com/shedward // name used in url http://vk.com/<screen_name> for example:
// http://vk.com/shedward
QString screen_name_; QString screen_name_;
QUrl photo_; QUrl photo_;
}; };
@ -84,20 +82,13 @@ QDebug operator<<(QDebug d, const MusicOwner& owner);
* how to react to the received request or quickly skip unwanted. * how to react to the received request or quickly skip unwanted.
*/ */
struct SearchID { struct SearchID {
enum Type { enum Type { GlobalSearch, LocalSearch, MoreLocalSearch, UserOrGroup };
GlobalSearch,
LocalSearch,
MoreLocalSearch,
UserOrGroup
};
explicit SearchID(Type type) explicit SearchID(Type type) : type_(type) { id_ = last_id_++; }
: type_(type) {
id_= last_id_++;
}
int id() const { return id_; } int id() const { return id_; }
Type type() const { return type_; } Type type() const { return type_; }
private:
private:
static uint last_id_; static uint last_id_;
int id_; int id_;
Type type_; Type type_;
@ -109,7 +100,7 @@ private:
class VkService : public InternetService { class VkService : public InternetService {
Q_OBJECT Q_OBJECT
public: public:
explicit VkService(Application* app, InternetModel* parent); explicit VkService(Application* app, InternetModel* parent);
~VkService(); ~VkService();
@ -133,8 +124,10 @@ public:
Type_Search Type_Search
}; };
enum Role { Role_MusicOwnerMetadata = InternetModel::RoleCount, enum Role {
Role_AlbumMetadata }; Role_MusicOwnerMetadata = InternetModel::RoleCount,
Role_AlbumMetadata
};
Application* app() const { return app_; } Application* app() const { return app_; }
@ -165,7 +158,8 @@ public:
// Return random song result from group playlist. // Return random song result from group playlist.
UrlHandler::LoadResult GetGroupNextSongUrl(const QUrl& url); UrlHandler::LoadResult GetGroupNextSongUrl(const QUrl& url);
void SongSearch(SearchID id, const QString& query, int count = 50, int offset = 0); void SongSearch(SearchID id, const QString& query, int count = 50,
int offset = 0);
void GroupSearch(SearchID id, const QString& query); void GroupSearch(SearchID id, const QString& query);
/* Settings */ /* Settings */
@ -184,15 +178,16 @@ signals:
void LoginSuccess(bool success); void LoginSuccess(bool success);
void SongSearchResult(const SearchID& id, const SongList& songs); void SongSearchResult(const SearchID& id, const SongList& songs);
void GroupSearchResult(const SearchID& id, const MusicOwnerList& groups); void GroupSearchResult(const SearchID& id, const MusicOwnerList& groups);
void UserOrGroupSearchResult(const SearchID& id, const MusicOwnerList& owners); void UserOrGroupSearchResult(const SearchID& id,
const MusicOwnerList& owners);
void StopWaiting(); void StopWaiting();
public slots: public slots:
void UpdateRoot(); void UpdateRoot();
void ShowConfig(); void ShowConfig();
void FindUserOrGroup(const QString& q); void FindUserOrGroup(const QString& q);
private slots: private slots:
/* Interface */ /* Interface */
void UpdateItem(); void UpdateItem();
@ -231,9 +226,10 @@ private slots:
void RecommendationsLoaded(Vreen::AudioItemListReply* reply); void RecommendationsLoaded(Vreen::AudioItemListReply* reply);
void SearchResultLoaded(const SearchID& id, const SongList& songs); void SearchResultLoaded(const SearchID& id, const SongList& songs);
private: private:
/* Interface */ /* Interface */
QStandardItem* CreateAndAppendRow(QStandardItem* parent, VkService::ItemType type); QStandardItem* CreateAndAppendRow(QStandardItem* parent,
VkService::ItemType type);
void ClearStandardItem(QStandardItem* item); void ClearStandardItem(QStandardItem* item);
QStandardItem* GetBookmarkItemById(int id); QStandardItem* GetBookmarkItemById(int id);
void EnsureMenuCreated(); void EnsureMenuCreated();
@ -286,7 +282,7 @@ private:
uint last_search_id_; uint last_search_id_;
QString last_query_; QString last_query_;
Song selected_song_; // Store for context menu actions. Song selected_song_; // Store for context menu actions.
Song current_song_; // Store for actions with now playing song. Song current_song_; // Store for actions with now playing song.
// Store current group url for actions with it. // Store current group url for actions with it.
QUrl current_group_url_; QUrl current_group_url_;

View File

@ -25,22 +25,17 @@
#include "core/logging.h" #include "core/logging.h"
#include "internet/vkservice.h" #include "internet/vkservice.h"
VkSettingsPage::VkSettingsPage(SettingsDialog *parent) VkSettingsPage::VkSettingsPage(SettingsDialog* parent)
: SettingsPage(parent), : SettingsPage(parent),
ui_(new Ui::VkSettingsPage), ui_(new Ui::VkSettingsPage),
service_(dialog()->app()->internet_model()->Service<VkService>()) { service_(dialog()->app()->internet_model()->Service<VkService>()) {
ui_->setupUi(this); ui_->setupUi(this);
connect(service_, SIGNAL(LoginSuccess(bool)), connect(service_, SIGNAL(LoginSuccess(bool)), SLOT(LoginSuccess(bool)));
SLOT(LoginSuccess(bool))); connect(ui_->choose_path, SIGNAL(clicked()), SLOT(CacheDirBrowse()));
connect(ui_->choose_path, SIGNAL(clicked()), connect(ui_->reset, SIGNAL(clicked()), SLOT(ResetCasheFilenames()));
SLOT(CacheDirBrowse()));
connect(ui_->reset, SIGNAL(clicked()),
SLOT(ResetCasheFilenames()));
} }
VkSettingsPage::~VkSettingsPage() { VkSettingsPage::~VkSettingsPage() { delete ui_; }
delete ui_;
}
void VkSettingsPage::Load() { void VkSettingsPage::Load() {
service_->ReloadSettings(); service_->ReloadSettings();
@ -49,7 +44,8 @@ void VkSettingsPage::Load() {
ui_->enable_caching->setChecked(service_->isCachingEnabled()); ui_->enable_caching->setChecked(service_->isCachingEnabled());
ui_->cache_dir->setText(service_->cacheDir()); ui_->cache_dir->setText(service_->cacheDir());
ui_->cache_filename->setText(service_->cacheFilename()); ui_->cache_filename->setText(service_->cacheFilename());
ui_->love_button_is_add_to_mymusic->setChecked(service_->isLoveAddToMyMusic()); ui_->love_button_is_add_to_mymusic->setChecked(
service_->isLoveAddToMyMusic());
ui_->groups_in_global_search->setChecked(service_->isGroupsInGlobalSearch()); ui_->groups_in_global_search->setChecked(service_->isGroupsInGlobalSearch());
ui_->enable_broadcast->setChecked(service_->isBroadcasting()); ui_->enable_broadcast->setChecked(service_->isBroadcasting());
@ -68,8 +64,10 @@ void VkSettingsPage::Save() {
s.setValue("cache_enabled", ui_->enable_caching->isChecked()); s.setValue("cache_enabled", ui_->enable_caching->isChecked());
s.setValue("cache_dir", ui_->cache_dir->text()); s.setValue("cache_dir", ui_->cache_dir->text());
s.setValue("cache_filename", ui_->cache_filename->text()); s.setValue("cache_filename", ui_->cache_filename->text());
s.setValue("love_is_add_to_my_music", ui_->love_button_is_add_to_mymusic->isChecked()); s.setValue("love_is_add_to_my_music",
s.setValue("groups_in_global_search", ui_->groups_in_global_search->isChecked()); ui_->love_button_is_add_to_mymusic->isChecked());
s.setValue("groups_in_global_search",
ui_->groups_in_global_search->isChecked());
s.setValue("enable_broadcast", ui_->enable_broadcast->isChecked()); s.setValue("enable_broadcast", ui_->enable_broadcast->isChecked());
service_->ReloadSettings(); service_->ReloadSettings();
@ -96,7 +94,7 @@ void VkSettingsPage::Logout() {
void VkSettingsPage::CacheDirBrowse() { void VkSettingsPage::CacheDirBrowse() {
QString directory = QFileDialog::getExistingDirectory( QString directory = QFileDialog::getExistingDirectory(
this, tr("Choose Vk.com cache directory"), ui_->cache_dir->text()); this, tr("Choose Vk.com cache directory"), ui_->cache_dir->text());
if (directory.isEmpty()) { if (directory.isEmpty()) {
return; return;
} }
@ -113,10 +111,9 @@ void VkSettingsPage::LoginWidgets() {
ui_->name->setText(""); ui_->name->setText("");
ui_->login_button->setEnabled(true); ui_->login_button->setEnabled(true);
connect(ui_->login_button, SIGNAL(clicked()), connect(ui_->login_button, SIGNAL(clicked()), SLOT(Login()),
SLOT(Login()), Qt::UniqueConnection); Qt::UniqueConnection);
disconnect(ui_->login_button, SIGNAL(clicked()), disconnect(ui_->login_button, SIGNAL(clicked()), this, SLOT(Logout()));
this, SLOT(Logout()));
} }
void VkSettingsPage::LogoutWidgets() { void VkSettingsPage::LogoutWidgets() {
@ -124,12 +121,11 @@ void VkSettingsPage::LogoutWidgets() {
ui_->name->setText(tr("Loading...")); ui_->name->setText(tr("Loading..."));
ui_->login_button->setEnabled(true); ui_->login_button->setEnabled(true);
connect(service_, SIGNAL(NameUpdated(QString)), connect(service_, SIGNAL(NameUpdated(QString)), ui_->name,
ui_->name, SLOT(setText(QString)), Qt::UniqueConnection); SLOT(setText(QString)), Qt::UniqueConnection);
service_->RequestUserProfile(); service_->RequestUserProfile();
connect(ui_->login_button, SIGNAL(clicked()), connect(ui_->login_button, SIGNAL(clicked()), SLOT(Logout()),
SLOT(Logout()), Qt::UniqueConnection); Qt::UniqueConnection);
disconnect(ui_->login_button, SIGNAL(clicked()), disconnect(ui_->login_button, SIGNAL(clicked()), this, SLOT(Login()));
this, SLOT(Login()));
} }

View File

@ -25,18 +25,17 @@
#include "vkmusiccache.h" #include "vkmusiccache.h"
VkUrlHandler::VkUrlHandler(VkService* service, QObject* parent) VkUrlHandler::VkUrlHandler(VkService* service, QObject* parent)
: UrlHandler(parent), : UrlHandler(parent), service_(service) {}
service_(service) {
}
UrlHandler::LoadResult VkUrlHandler::StartLoading(const QUrl& url) { UrlHandler::LoadResult VkUrlHandler::StartLoading(const QUrl& url) {
QStringList args = url.path().split("/"); QStringList args = url.path().split("/");
LoadResult result; LoadResult result;
if (args.size() < 2) { if (args.size() < 2) {
qLog(Error) << "Invalid Vk.com URL: " << url qLog(Error)
<< "Url format should be vk://<source>/<id>." << "Invalid Vk.com URL: " << url
<< "For example vk://song/61145020_166946521/Daughtry/Gone Too Soon"; << "Url format should be vk://<source>/<id>."
<< "For example vk://song/61145020_166946521/Daughtry/Gone Too Soon";
} else { } else {
QString action = url.host(); QString action = url.host();
@ -52,9 +51,7 @@ UrlHandler::LoadResult VkUrlHandler::StartLoading(const QUrl& url) {
return result; return result;
} }
void VkUrlHandler::TrackSkipped() { void VkUrlHandler::TrackSkipped() { service_->SongSkiped(); }
service_->SongSkiped();
}
UrlHandler::LoadResult VkUrlHandler::LoadNext(const QUrl& url) { UrlHandler::LoadResult VkUrlHandler::LoadNext(const QUrl& url) {
if (url.host() == "group") { if (url.host() == "group") {

View File

@ -28,7 +28,7 @@ class VkMusicCache;
class VkUrlHandler : public UrlHandler { class VkUrlHandler : public UrlHandler {
Q_OBJECT Q_OBJECT
public: public:
VkUrlHandler(VkService* service, QObject* parent); VkUrlHandler(VkService* service, QObject* parent);
QString scheme() const { return "vk"; } QString scheme() const { return "vk"; }
QIcon icon() const { return QIcon(":providers/vk.png"); } QIcon icon() const { return QIcon(":providers/vk.png"); }
@ -36,7 +36,7 @@ public:
void TrackSkipped(); void TrackSkipped();
LoadResult LoadNext(const QUrl& url); LoadResult LoadNext(const QUrl& url);
private: private:
VkService* service_; VkService* service_;
}; };