Skip to content

Commit f11d000

Browse files
committed
#16 #17 optimized kugou widget[012458]
1 parent 6a3987e commit f11d000

File tree

7 files changed

+130
-7
lines changed

7 files changed

+130
-7
lines changed

TTKThirdParty/MusicExtras/kugou/kugouurl.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ QString KugouUrl::getRecommendUrl()
1515
return "http://www2.kugou.kugou.com/yueku/v9/html/home.html";
1616
}
1717

18+
QString KugouUrl::getRadioUrl()
19+
{
20+
return "http://www2.kugou.com/fm/html/index.html";
21+
}
22+
1823
QString KugouUrl::getRankUrl()
1924
{
20-
return "http://www2.kugou.kugou.com/yueku/v9/rank/home/1-22943.html?close=1";
25+
return "http://www2.kugou.kugou.com/yueku/v9/rank/home/1-22943.html";
2126
}
2227

2328
QString KugouUrl::getSingerUrl()
@@ -27,10 +32,15 @@ QString KugouUrl::getSingerUrl()
2732

2833
QString KugouUrl::getCategoryUrl()
2934
{
30-
return "http://www2.kugou.kugou.com/yueku/v9/category/songs/1-0-0-0-0.html";
35+
return "http://www2.kugou.kugou.com/yueku/v9/categoryv2/index.html";
3136
}
3237

3338
QString KugouUrl::getShowUrl()
3439
{
3540
return "http://www2.kugou.kugou.com/show/v9/html/index.html";
3641
}
42+
43+
QString KugouUrl::getCCTVUrl()
44+
{
45+
return "http://huodong.kugou.com/2015/html/CCTVArea.html";
46+
}

TTKThirdParty/MusicExtras/kugou/kugouurl.h

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#ifndef KUGOUURL_H
22
#define KUGOUURL_H
33

4+
/* =================================================
5+
* This file is part of the TTK Music Player project
6+
* Copyright (c) 2014 - 2016 Greedysky Studio
7+
* All rights reserved!
8+
* Redistribution and use of the source code or any derivative
9+
* works are strictly forbiden.
10+
=================================================*/
11+
412
#include <QObject>
513
#include "musicextrasglobaldefine.h"
614

@@ -11,10 +19,12 @@ class MUSIC_EXTRAS_EXPORT KugouUrl
1119

1220
static QString getYuekuUrl();
1321
static QString getRecommendUrl();
22+
static QString getRadioUrl();
1423
static QString getRankUrl();
1524
static QString getSingerUrl();
1625
static QString getCategoryUrl();
1726
static QString getShowUrl();
27+
static QString getCCTVUrl();
1828

1929
};
2030

TTKThirdParty/MusicExtras/kugou/kugouwindow.cpp

+68-5
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,86 @@
33
#include <QBoxLayout>
44
#include <QWebView>
55
#include <QWebFrame>
6+
#include <QPushButton>
7+
#include <QButtonGroup>
68

79
KugouWindow::KugouWindow(QWidget *parent)
810
: QWidget(parent)
911
{
10-
QHBoxLayout *layout = new QHBoxLayout(this);
12+
QVBoxLayout *layout = new QVBoxLayout(this);
1113
layout->setSpacing(0);
1214
layout->setContentsMargins(0, 0, 0, 0);
1315

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

18-
layout->addWidget(w);
26+
QButtonGroup *buttonGroup = new QButtonGroup(this);
27+
QPushButton *bt = new QPushButton(tr(" Recommend "), top);
28+
bt->setCursor(QCursor(Qt::PointingHandCursor));
29+
buttonGroup->addButton(bt, 0);
30+
bt = new QPushButton(tr(" Radio "), top);
31+
bt->setCursor(QCursor(Qt::PointingHandCursor));
32+
buttonGroup->addButton(bt, 1);
33+
bt = new QPushButton(tr(" Rank "), top);
34+
bt->setCursor(QCursor(Qt::PointingHandCursor));
35+
buttonGroup->addButton(bt, 2);
36+
bt = new QPushButton(tr(" Singer "), top);
37+
bt->setCursor(QCursor(Qt::PointingHandCursor));
38+
buttonGroup->addButton(bt, 3);
39+
bt = new QPushButton(tr(" Category "), top);
40+
bt->setCursor(QCursor(Qt::PointingHandCursor));
41+
buttonGroup->addButton(bt, 4);
42+
bt = new QPushButton(tr(" Show "), top);
43+
bt->setCursor(QCursor(Qt::PointingHandCursor));
44+
buttonGroup->addButton(bt, 5);
45+
bt = new QPushButton(tr(" CCTV "), top);
46+
bt->setCursor(QCursor(Qt::PointingHandCursor));
47+
buttonGroup->addButton(bt, 6);
48+
connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(differButtonIndexChanged(int)));
49+
50+
topLayout->addStretch(1);
51+
topLayout->addWidget(buttonGroup->button(0));
52+
topLayout->addWidget(buttonGroup->button(1));
53+
topLayout->addWidget(buttonGroup->button(2));
54+
topLayout->addWidget(buttonGroup->button(3));
55+
topLayout->addWidget(buttonGroup->button(4));
56+
topLayout->addWidget(buttonGroup->button(5));
57+
topLayout->addWidget(buttonGroup->button(6));
58+
topLayout->addStretch(1);
59+
60+
m_webView = new QWebView(this);
61+
m_webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
62+
m_webView->setUrl(QUrl( KugouUrl::getRecommendUrl() ));
63+
64+
layout->addWidget(top);
65+
layout->addWidget(m_webView);
1966
setLayout(layout);
2067
}
2168

2269
KugouWindow::~KugouWindow()
2370
{
71+
delete m_webView;
72+
}
2473

74+
void KugouWindow::differButtonIndexChanged(int index)
75+
{
76+
QString url = KugouUrl::getRecommendUrl();
77+
switch(index)
78+
{
79+
case 0: url = KugouUrl::getRecommendUrl(); break;
80+
case 1: url = KugouUrl::getRadioUrl(); break;
81+
case 2: url = KugouUrl::getRankUrl(); break;
82+
case 3: url = KugouUrl::getSingerUrl(); break;
83+
case 4: url = KugouUrl::getCategoryUrl(); break;
84+
case 5: url = KugouUrl::getShowUrl(); break;
85+
case 6: url = KugouUrl::getCCTVUrl(); break;
86+
}
87+
m_webView->setUrl(QUrl( url ));
2588
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
#ifndef KUGOUWINDOW_H
22
#define KUGOUWINDOW_H
33

4+
/* =================================================
5+
* This file is part of the TTK Music Player project
6+
* Copyright (c) 2014 - 2016 Greedysky Studio
7+
* All rights reserved!
8+
* Redistribution and use of the source code or any derivative
9+
* works are strictly forbiden.
10+
=================================================*/
11+
412
#include <QWidget>
513
#include "kugouurl.h"
614

15+
class QWebView;
16+
717
class MUSIC_EXTRAS_EXPORT KugouWindow : public QWidget
818
{
919
Q_OBJECT
1020
public:
1121
explicit KugouWindow(QWidget *parent = 0);
1222
~KugouWindow();
1323

24+
public Q_SLOTS:
25+
void differButtonIndexChanged(int index);
26+
27+
protected:
28+
QWebView *m_webView;
29+
1430
};
1531

1632
#endif // KUGOUWINDOW_H

TTKThirdParty/MusicExtras/shortcut/qxtglobal.h

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
#ifndef QXTGLOBAL_H
2727
#define QXTGLOBAL_H
2828

29+
/* =================================================
30+
* This file is part of the TTK Music Player project
31+
* Copyright (c) 2014 - 2016 Greedysky Studio
32+
* All rights reserved!
33+
* Redistribution and use of the source code or any derivative
34+
* works are strictly forbiden.
35+
=================================================*/
36+
2937
#include "musicextrasglobaldefine.h"
3038

3139
#define QXT_VERSION 0x000600

TTKThirdParty/MusicExtras/shortcut/qxtglobalshortcut.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
#ifndef QXTGLOBALSHORTCUT_H
2626
#define QXTGLOBALSHORTCUT_H
2727

28+
/* =================================================
29+
* This file is part of the TTK Music Player project
30+
* Copyright (c) 2014 - 2016 Greedysky Studio
31+
* All rights reserved!
32+
* Redistribution and use of the source code or any derivative
33+
* works are strictly forbiden.
34+
=================================================*/
35+
2836
#include "qxtglobal.h"
2937
#include <QObject>
3038
#include <QKeySequence>

TTKThirdParty/MusicExtras/shortcut/qxtglobalshortcut_p.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
#ifndef QXTGLOBALSHORTCUT_P_H
2626
#define QXTGLOBALSHORTCUT_P_H
2727

28+
/* =================================================
29+
* This file is part of the TTK Music Player project
30+
* Copyright (c) 2014 - 2016 Greedysky Studio
31+
* All rights reserved!
32+
* Redistribution and use of the source code or any derivative
33+
* works are strictly forbiden.
34+
=================================================*/
35+
2836
#include "qxtglobalshortcut.h"
2937
#include <QAbstractEventDispatcher>
3038
#include <QKeySequence>

0 commit comments

Comments
 (0)