Skip to content

Commit

Permalink
#16 #17 optimized kugou widget[012458]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed May 21, 2016
1 parent 6a3987e commit f11d000
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 7 deletions.
14 changes: 12 additions & 2 deletions TTKThirdParty/MusicExtras/kugou/kugouurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ QString KugouUrl::getRecommendUrl()
return "http://www2.kugou.kugou.com/yueku/v9/html/home.html";
}

QString KugouUrl::getRadioUrl()
{
return "http://www2.kugou.com/fm/html/index.html";
}

QString KugouUrl::getRankUrl()
{
return "http://www2.kugou.kugou.com/yueku/v9/rank/home/1-22943.html?close=1";
return "http://www2.kugou.kugou.com/yueku/v9/rank/home/1-22943.html";
}

QString KugouUrl::getSingerUrl()
Expand All @@ -27,10 +32,15 @@ QString KugouUrl::getSingerUrl()

QString KugouUrl::getCategoryUrl()
{
return "http://www2.kugou.kugou.com/yueku/v9/category/songs/1-0-0-0-0.html";
return "http://www2.kugou.kugou.com/yueku/v9/categoryv2/index.html";
}

QString KugouUrl::getShowUrl()
{
return "http://www2.kugou.kugou.com/show/v9/html/index.html";
}

QString KugouUrl::getCCTVUrl()
{
return "http://huodong.kugou.com/2015/html/CCTVArea.html";
}
10 changes: 10 additions & 0 deletions TTKThirdParty/MusicExtras/kugou/kugouurl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#ifndef KUGOUURL_H
#define KUGOUURL_H

/* =================================================
* This file is part of the TTK Music Player project
* Copyright (c) 2014 - 2016 Greedysky Studio
* All rights reserved!
* Redistribution and use of the source code or any derivative
* works are strictly forbiden.
=================================================*/

#include <QObject>
#include "musicextrasglobaldefine.h"

Expand All @@ -11,10 +19,12 @@ class MUSIC_EXTRAS_EXPORT KugouUrl

static QString getYuekuUrl();
static QString getRecommendUrl();
static QString getRadioUrl();
static QString getRankUrl();
static QString getSingerUrl();
static QString getCategoryUrl();
static QString getShowUrl();
static QString getCCTVUrl();

};

Expand Down
73 changes: 68 additions & 5 deletions TTKThirdParty/MusicExtras/kugou/kugouwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,86 @@
#include <QBoxLayout>
#include <QWebView>
#include <QWebFrame>
#include <QPushButton>
#include <QButtonGroup>

KugouWindow::KugouWindow(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);

QWebView *w = new QWebView(this);
w->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
w->setUrl(QUrl("http://www2.kugou.kugou.com/yueku/v9/html/home.html"));
const QString radioStyle = "QPushButton{ border:none; color:rgb(135, 135, 135);} \
QPushButton:hover{ color:rgb(104, 169, 236);} \
QPushButton:checked{ color:rgb(40, 143, 231);} \
QWidget{background: white;}";
QWidget *top = new QWidget(this);
top->setFixedHeight(25);
top->setStyleSheet( radioStyle );
QHBoxLayout *topLayout = new QHBoxLayout(top);
topLayout->setContentsMargins(0, 0, 0, 0);

layout->addWidget(w);
QButtonGroup *buttonGroup = new QButtonGroup(this);
QPushButton *bt = new QPushButton(tr(" Recommend "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 0);
bt = new QPushButton(tr(" Radio "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 1);
bt = new QPushButton(tr(" Rank "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 2);
bt = new QPushButton(tr(" Singer "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 3);
bt = new QPushButton(tr(" Category "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 4);
bt = new QPushButton(tr(" Show "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 5);
bt = new QPushButton(tr(" CCTV "), top);
bt->setCursor(QCursor(Qt::PointingHandCursor));
buttonGroup->addButton(bt, 6);
connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(differButtonIndexChanged(int)));

topLayout->addStretch(1);
topLayout->addWidget(buttonGroup->button(0));
topLayout->addWidget(buttonGroup->button(1));
topLayout->addWidget(buttonGroup->button(2));
topLayout->addWidget(buttonGroup->button(3));
topLayout->addWidget(buttonGroup->button(4));
topLayout->addWidget(buttonGroup->button(5));
topLayout->addWidget(buttonGroup->button(6));
topLayout->addStretch(1);

m_webView = new QWebView(this);
m_webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
m_webView->setUrl(QUrl( KugouUrl::getRecommendUrl() ));

layout->addWidget(top);
layout->addWidget(m_webView);
setLayout(layout);
}

KugouWindow::~KugouWindow()
{
delete m_webView;
}

void KugouWindow::differButtonIndexChanged(int index)
{
QString url = KugouUrl::getRecommendUrl();
switch(index)
{
case 0: url = KugouUrl::getRecommendUrl(); break;
case 1: url = KugouUrl::getRadioUrl(); break;
case 2: url = KugouUrl::getRankUrl(); break;
case 3: url = KugouUrl::getSingerUrl(); break;
case 4: url = KugouUrl::getCategoryUrl(); break;
case 5: url = KugouUrl::getShowUrl(); break;
case 6: url = KugouUrl::getCCTVUrl(); break;
}
m_webView->setUrl(QUrl( url ));
}
16 changes: 16 additions & 0 deletions TTKThirdParty/MusicExtras/kugou/kugouwindow.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
#ifndef KUGOUWINDOW_H
#define KUGOUWINDOW_H

/* =================================================
* This file is part of the TTK Music Player project
* Copyright (c) 2014 - 2016 Greedysky Studio
* All rights reserved!
* Redistribution and use of the source code or any derivative
* works are strictly forbiden.
=================================================*/

#include <QWidget>
#include "kugouurl.h"

class QWebView;

class MUSIC_EXTRAS_EXPORT KugouWindow : public QWidget
{
Q_OBJECT
public:
explicit KugouWindow(QWidget *parent = 0);
~KugouWindow();

public Q_SLOTS:
void differButtonIndexChanged(int index);

protected:
QWebView *m_webView;

};

#endif // KUGOUWINDOW_H
8 changes: 8 additions & 0 deletions TTKThirdParty/MusicExtras/shortcut/qxtglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
#ifndef QXTGLOBAL_H
#define QXTGLOBAL_H

/* =================================================
* This file is part of the TTK Music Player project
* Copyright (c) 2014 - 2016 Greedysky Studio
* All rights reserved!
* Redistribution and use of the source code or any derivative
* works are strictly forbiden.
=================================================*/

#include "musicextrasglobaldefine.h"

#define QXT_VERSION 0x000600
Expand Down
8 changes: 8 additions & 0 deletions TTKThirdParty/MusicExtras/shortcut/qxtglobalshortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#ifndef QXTGLOBALSHORTCUT_H
#define QXTGLOBALSHORTCUT_H

/* =================================================
* This file is part of the TTK Music Player project
* Copyright (c) 2014 - 2016 Greedysky Studio
* All rights reserved!
* Redistribution and use of the source code or any derivative
* works are strictly forbiden.
=================================================*/

#include "qxtglobal.h"
#include <QObject>
#include <QKeySequence>
Expand Down
8 changes: 8 additions & 0 deletions TTKThirdParty/MusicExtras/shortcut/qxtglobalshortcut_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
#ifndef QXTGLOBALSHORTCUT_P_H
#define QXTGLOBALSHORTCUT_P_H

/* =================================================
* This file is part of the TTK Music Player project
* Copyright (c) 2014 - 2016 Greedysky Studio
* All rights reserved!
* Redistribution and use of the source code or any derivative
* works are strictly forbiden.
=================================================*/

#include "qxtglobalshortcut.h"
#include <QAbstractEventDispatcher>
#include <QKeySequence>
Expand Down

0 comments on commit f11d000

Please sign in to comment.