Skip to content

Commit

Permalink
#24 #16 update similar song found and optimized some details[300147]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed May 2, 2016
1 parent bb0156d commit d0bb91f
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 33 deletions.
2 changes: 2 additions & 0 deletions TTKCore/musicCore/musiccryptographichash.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "musicglobaldefine.h"

#define DOWNLOAD_KEY "5024FRSDF40"

#ifdef Q_CC_GNU
#pragma GCC diagnostic ignored "-Wparentheses"
#endif
Expand Down
1 change: 1 addition & 0 deletions TTKCore/musicCore/musicobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define LRC_FILE ".lrc"
#define KRC_FILE ".krc"
#define MP3_FILE ".mp3"
#define TMP_FILE ".ttk"

#define MAKE_TRANSFORM "MPlugins/avconv.dll"
#define MAKE_KRC2LRC "MPlugins/avk2l.dll"
Expand Down
3 changes: 3 additions & 0 deletions TTKCore/musicCore/network/musicdownloadquerythreadabstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
=================================================*/

#include <QObject>
#include <QSslError>
#include <QNetworkReply>
#include "musicglobaldefine.h"
#include "musicobject.h"
Expand All @@ -27,7 +28,9 @@ typedef struct DownloadData{
void clear()
{
m_songName.clear();
m_songArtist.clear();
m_songUrl.clear();
m_picUrl.clear();
m_time.clear();
m_format.clear();
}
Expand Down
1 change: 1 addition & 0 deletions TTKCore/musicCore/network/musicdownloadthreadabstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#if defined Q_OS_UNIX || defined Q_CC_MINGW
# include <unistd.h>
#endif
#include <QSslError>

MusicDownLoadThreadAbstract::MusicDownLoadThreadAbstract(const QString &url,
const QString &save, Download_Type type, QObject *parent)
Expand Down
3 changes: 2 additions & 1 deletion TTKCore/musicCore/network/musicdownloadthreadabstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
* works are strictly forbiden.
=================================================*/

#include <QNetworkReply>
#include <QFile>
#include <QTimer>
#include <QNetworkReply>
#include <QSslConfiguration>
#include "musicobject.h"
#include "musicglobaldefine.h"

Expand Down
2 changes: 2 additions & 0 deletions TTKCore/musicCore/network/musicnetworkoperator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "musicnetworkoperator.h"
#include "musicsourcedownloadthread.h"

#include <QStringList>

const QString IP_CHECK_URL = "http://1212.ip138.com/ic.asp";

MusicNetworkOperator::MusicNetworkOperator(QObject *parent)
Expand Down
1 change: 1 addition & 0 deletions TTKCore/musicCore/network/musicradiothreadabstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
=================================================*/

#include <QNetworkReply>
#include <QSslConfiguration>
#include "musicobject.h"
#include "musicglobaldefine.h"

Expand Down
2 changes: 2 additions & 0 deletions TTKCore/musicCore/network/musicsourcedownloadthread.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "musicsourcedownloadthread.h"

#include <QSslConfiguration>

MusicSourceDownloadThread::MusicSourceDownloadThread(QObject *parent)
: QObject(parent)
{
Expand Down
6 changes: 4 additions & 2 deletions TTKCore/musicToolswidget/musicsongssummarizied.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "musicconnectionpool.h"
#include "musicsongtag.h"
#include "musicprogresswidget.h"
#include "musiccryptographichash.h"
#include "musicsongssummariziedfloatwidget.h"

#include <QScrollBar>
Expand Down Expand Up @@ -292,8 +293,9 @@ void MusicSongsSummarizied::removeMusicSongToLovestListAt(int row)
void MusicSongsSummarizied::addNetMusicSongToList(const QString &name, const QString &time,
const QString &format)
{
const QString path = QString("%1%2.%3").arg(MUSIC_DOWNLOAD_AL).arg(name).arg(format);
m_musicFileNames[MUSIC_NETWORK_LIST] << MusicSong(path, 0, time, name);
QString musicSong = MusicCryptographicHash().decrypt(name, DOWNLOAD_KEY);
const QString path = QString("%1%2.%3").arg(DATA_CACHED_AL).arg(name).arg(format);
m_musicFileNames[MUSIC_NETWORK_LIST] << MusicSong(path, 0, time, musicSong);
m_mainSongLists[MUSIC_NETWORK_LIST]->updateSongsFileName(m_musicFileNames[MUSIC_NETWORK_LIST]);
if(m_currentIndexs == MUSIC_NETWORK_LIST)
{
Expand Down
54 changes: 42 additions & 12 deletions TTKCore/musicWidget/musicsimilarfoundwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include "musicsimilarfoundwidget.h"
#include "musicsourcedownloadthread.h"
#include "musicdownloadmgmtwidget.h"
#include "musicdatadownloadthread.h"
#include "musiccryptographichash.h"
#include "musicnetworkthread.h"
#include "musicuiobject.h"

#include <QBoxLayout>
#include <QGridLayout>
#include <QPushButton>
#include <QCheckBox>
#include <QDebug>

MusicSimilarFoundWidget::MusicSimilarFoundWidget(QWidget *parent)
: QWidget(parent)
Expand Down Expand Up @@ -102,7 +105,7 @@ void MusicSimilarFoundWidget::createLabels()

QLabel *firstLabel = new QLabel(m_mainWindow);
firstLabel->setText(tr("Like \"<font color=blue> %1 </font>\" also like this").arg(m_songNameFull));
grid->addWidget(firstLabel, index++, 0, 1, 5);
grid->addWidget(firstLabel, index++, 0, 1, 7);
////////////////////////////////////////////////////////////////////////////
QCheckBox *allCheckBox = new QCheckBox(tr("all"), m_mainWindow);
QPushButton *playButton = new QPushButton(tr("play"), m_mainWindow);
Expand Down Expand Up @@ -147,7 +150,7 @@ void MusicSimilarFoundWidget::createLabels()
QString artName = m_downloadThread->getSearchedText();
QLabel *secondLabel = new QLabel(m_mainWindow);
secondLabel->setText(tr("Other \"<font color=blue> %1 </font>\" things").arg(artName));
grid->addWidget(secondLabel, index++, 0, 1, 5);
grid->addWidget(secondLabel, index++, 0, 1, 7);
////////////////////////////////////////////////////////////////////////////
QLabel *picLabel1 = new QLabel(m_mainWindow);
picLabel1->setPixmap(QPixmap(":/share/warning"));
Expand All @@ -163,9 +166,10 @@ void MusicSimilarFoundWidget::createLabels()
grid->addWidget(picLabel1, index, 0, 1, 2);
grid->addWidget(picLabel2, index, 3, 1, 2);
grid->addWidget(picLabel3, index++, 6, 1, 2);
grid->addWidget(new QLabel(artName, m_mainWindow), index, 0, 1, 2, Qt::AlignCenter);
grid->addWidget(new QLabel(artName, m_mainWindow), index, 3, 1, 2, Qt::AlignCenter);
grid->addWidget(new QLabel(artName, m_mainWindow), index++, 6, 1, 2, Qt::AlignCenter);
QString artLimitString = QFontMetrics(font()).elidedText(artName, Qt::ElideRight, 90);
grid->addWidget(new QLabel(artLimitString, m_mainWindow), index, 0, 1, 2, Qt::AlignCenter);
grid->addWidget(new QLabel(artLimitString, m_mainWindow), index, 3, 1, 2, Qt::AlignCenter);
grid->addWidget(new QLabel(artLimitString, m_mainWindow), index++, 6, 1, 2, Qt::AlignCenter);

int downloadCounter = 0;
foreach(DownloadData *data, m_likeDownloadDatas)
Expand Down Expand Up @@ -219,18 +223,44 @@ void MusicSimilarFoundWidget::selectAllItems(bool all)

void MusicSimilarFoundWidget::playButtonClicked()
{
MIntList list = foundCheckedItem();
qDebug() << list.count();
foreach(int index, foundCheckedItem())
{
downloadDataFrom(index);
}
}

void MusicSimilarFoundWidget::downloadButtonClicked()
{
MIntList list = foundCheckedItem();
qDebug() << list.count();
foreach(int index, foundCheckedItem())
{
MusicDownloadMgmtWidget mgmt(this);
DownloadData *data = m_likeDownloadDatas[index];
mgmt.setSongName(data->m_songArtist + " - " + data->m_songName, MusicDownLoadQueryThreadAbstract::MusicQuery);
}
}

void MusicSimilarFoundWidget::addButtonClicked()
{
MIntList list = foundCheckedItem();
qDebug() << list.count();
playButtonClicked();
}

void MusicSimilarFoundWidget::downloadDataFrom(int row)
{
if(!M_NETWORK->isOnline() || row < 0)
{
return;
}

DownloadData *data = m_likeDownloadDatas[row];
QString musicEnSong = MusicCryptographicHash().encrypt(data->m_songArtist + " - " + data->m_songName, DOWNLOAD_KEY);
QString downloadName = QString("%1%2.%3").arg(DATA_CACHED_AL).arg(musicEnSong).arg(data->m_format);
MusicDataDownloadThread *downSong = new MusicDataDownloadThread( data->m_songUrl, downloadName,
MusicDownLoadThreadAbstract::Download_Music, this);
connect(downSong, SIGNAL(musicDownLoadFinished(QString)), SLOT(downloadDataFinished()));
downSong->startToDownload();
}

void MusicSimilarFoundWidget::downloadDataFinished()
{

}
26 changes: 26 additions & 0 deletions TTKCore/musicWidget/musicsimilarfoundwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,39 @@ public Q_SLOTS:
* Send recieved data from net.
*/
void selectAllItems(bool all);
/*!
* Select all items or not.
*/
void playButtonClicked();
/*!
* Play button clicked now.
*/
void downloadButtonClicked();
/*!
* Download button clicked now.
*/
void addButtonClicked();
/*!
* Add button clicked now.
*/
void downloadDataFinished();
/*!
* Download data finished.
*/

protected:
void createLabels();
/*!
* Create init interface lables.
*/
MIntList foundCheckedItem();
/*!
* Found which items is checked.
*/
void downloadDataFrom(int row);
/*!
* Download data from net by index.
*/

QString m_songNameFull;
QWidget *m_mainWindow;
Expand Down
8 changes: 4 additions & 4 deletions TTKCore/musicWidget/musicsongsearchonlinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "musiccoremplayer.h"
#include "musicdownloadmgmtwidget.h"
#include "musicitemdelegate.h"
#include "musiccryptographichash.h"

#include <QDateTime>
#include <QVBoxLayout>
Expand Down Expand Up @@ -232,9 +233,8 @@ void MusicSongSearchOnlineTableWidget::addSearchMusicToPlayList(int row)
MusicSongInfomation musicSongInfo = musicSongInfos[row];
MusicSongAttribute musicSongAttr = musicSongInfo.m_songAttrs.first();
QString musicSong = item(row, 2)->toolTip() + " - " + item(row, 1)->toolTip();
QString downloadName = QString("%1%2.%3").arg(MUSIC_DOWNLOAD_AL)
.arg(musicSong).arg(musicSongAttr.m_format);

QString musicEnSong = MusicCryptographicHash().encrypt(musicSong, DOWNLOAD_KEY);
QString downloadName = QString("%1%2.%3").arg(DATA_CACHED_AL).arg(musicEnSong).arg(musicSongAttr.m_format);
MusicDataDownloadThread *downSong = new MusicDataDownloadThread( musicSongAttr.m_url, downloadName,
MusicDownLoadThreadAbstract::Download_Music, this);
connect(downSong, SIGNAL(musicDownLoadFinished(QString)), SLOT(searchDataDwonloadFinished()));
Expand All @@ -253,7 +253,7 @@ void MusicSongSearchOnlineTableWidget::addSearchMusicToPlayList(int row)
(new MusicBackgroundDownload(musicSongInfo.m_singerName, musicSongInfo.m_singerName, this))->startToDownload();

m_downloadData.clear();
m_downloadData.m_songName = musicSong;
m_downloadData.m_songName = musicEnSong;
m_downloadData.m_time = item(row, 3)->text();
m_downloadData.m_format = musicSongAttr.m_format;
}
Expand Down
26 changes: 13 additions & 13 deletions TTKCore/musicapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MusicApplication::MusicApplication(QWidget *parent)
ui->setupUi(this);
M_CONNECTION->setValue("MusicApplication", this);

m_object = new MusicApplicationObject(this);
m_applicationObject = new MusicApplicationObject(this);
setAttribute(Qt::WA_TranslucentBackground, true);
// drawWindowShadow(false);

Expand Down Expand Up @@ -94,21 +94,21 @@ MusicApplication::~MusicApplication()
delete m_topAreaWidget;
delete m_rightAreaWidget;
delete m_leftAreaWidget;
delete m_object;
delete m_applicationObject;
delete ui;
}

#if defined(Q_OS_WIN)
# ifdef MUSIC_QT_5
bool MusicApplication::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
m_object->nativeEvent(eventType, message, result);
m_applicationObject->nativeEvent(eventType, message, result);
return QWidget::nativeEvent(eventType, message, result);
}
# else
bool MusicApplication::winEvent(MSG *message, long *result)
{
m_object->winEvent(message, result);
m_applicationObject->winEvent(message, result);
return QWidget::winEvent(message, result);
}
# endif
Expand Down Expand Up @@ -200,8 +200,8 @@ void MusicApplication::contextMenuEvent(QContextMenuEvent *event)
musicRemoteControl.addAction(tr("DeleteRemote"), m_topAreaWidget, SLOT(musicDeleteRemote()));

rightClickMenu.addAction(QIcon(":/contextMenu/equalizer"), tr("Equalizer"), this, SLOT(musicSetEqualizer()));
rightClickMenu.addAction(tr("AudioRecorder"), m_object, SLOT(musicAudioRecorder()));
rightClickMenu.addAction(tr("TimingSettings"), m_object, SLOT(musicTimerWidget()));
rightClickMenu.addAction(tr("AudioRecorder"), m_applicationObject, SLOT(musicAudioRecorder()));
rightClickMenu.addAction(tr("TimingSettings"), m_applicationObject, SLOT(musicTimerWidget()));
QMenu spectrumControl(tr("ShowingSpectrum"), &rightClickMenu);
spectrumControl.addAction(tr("AnalyzerSpectrum"), m_leftAreaWidget, SLOT(musicAnalyzerSpectrumWidget()));
spectrumControl.addAction(tr("ProjectMSpectrum"), m_leftAreaWidget, SLOT(musicProjectMSpectrumWidget()))->setEnabled(
Expand All @@ -213,16 +213,16 @@ void MusicApplication::contextMenuEvent(QContextMenuEvent *event)
rightClickMenu.addMenu(&spectrumControl);
rightClickMenu.addSeparator();

QAction *window = rightClickMenu.addAction(tr("WindowTop"), m_object, SLOT(musicSetWindowToTop()));
window->setIcon(QIcon(m_object->getWindowToTop() ? ":/share/selected" : QString()));
QAction *window = rightClickMenu.addAction(tr("WindowTop"), m_applicationObject, SLOT(musicSetWindowToTop()));
window->setIcon(QIcon(m_applicationObject->getWindowToTop() ? ":/share/selected" : QString()));

rightClickMenu.addAction(QIcon(":/contextMenu/setting"), tr("Setting"), this, SLOT(musicSetting()));
rightClickMenu.addAction(QIcon(":/contextMenu/location"), tr("musicLocation"), this, SLOT(musicCurrentPlayLocation()));

QMenu musicInfo(tr("musicAbout"), &rightClickMenu);
rightClickMenu.addMenu(&musicInfo)->setIcon(QIcon(":/contextMenu/about"));
musicInfo.addAction(QIcon(":/contextMenu/about"), tr("Version") + TTKMUSIC_VERSION_STR, m_object, SLOT(musicAboutUs()));
musicInfo.addAction(QIcon(":/contextMenu/update"), tr("Update"), m_object, SLOT(musicVersionUpdate()));
musicInfo.addAction(QIcon(":/contextMenu/about"), tr("Version") + TTKMUSIC_VERSION_STR, m_applicationObject, SLOT(musicAboutUs()));
musicInfo.addAction(QIcon(":/contextMenu/update"), tr("Update"), m_applicationObject, SLOT(musicVersionUpdate()));

rightClickMenu.addSeparator();
rightClickMenu.addAction(QIcon(":/contextMenu/quit"), tr("quit"), this, SLOT(quitWindowClose()));
Expand Down Expand Up @@ -412,7 +412,7 @@ void MusicApplication::quitWindowClose()
{
//Write configuration files
writeXMLConfigToText();
m_object->windowCloseAnimationOpacity();
m_applicationObject->windowCloseAnimationOpacity();
}

void MusicApplication::positionChanged(qint64 position)
Expand Down Expand Up @@ -832,7 +832,7 @@ void MusicApplication::setDeleteItemAt(const MIntList &index, bool remove)

void MusicApplication::getParameterSetting()
{
m_object->getParameterSetting();
m_applicationObject->getParameterSetting();
m_rightAreaWidget->getParameterSetting();
bool config = M_SETTING->value(MusicSettingManager::CloseEventChoiced).toBool();
m_bottomAreaWidget->setSystemCloseConfig(config);
Expand All @@ -843,7 +843,7 @@ void MusicApplication::getParameterSetting()

void MusicApplication::musicSetEqualizer()
{
m_object->musicSetEqualizer();
m_applicationObject->musicSetEqualizer();
}

void MusicApplication::musicSearchIndexChanged(int, int index)
Expand Down
2 changes: 1 addition & 1 deletion TTKCore/musicapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public Q_SLOTS:
MusicTopAreaWidget *m_topAreaWidget;
MusicRightAreaWidget *m_rightAreaWidget;
MusicLeftAreaWidget *m_leftAreaWidget;
MusicApplicationObject *m_object;
MusicApplicationObject *m_applicationObject;

};

Expand Down

0 comments on commit d0bb91f

Please sign in to comment.