mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 16:02:07 +02:00
Add support for Variety
This commit is contained in:
parent
d077a21a0a
commit
4413dbc85f
@ -101,6 +101,7 @@ set( libSources
|
||||
playlist/dynamic/widgets/DynamicControlWidget.cpp
|
||||
playlist/dynamic/widgets/DynamicControlList.cpp
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.cpp
|
||||
playlist/dynamic/widgets/MiscControlWidgets.cpp
|
||||
|
||||
|
||||
network/bufferiodevice.cpp
|
||||
@ -230,6 +231,7 @@ set( libHeaders
|
||||
playlist/dynamic/widgets/DynamicControlWidget.h
|
||||
playlist/dynamic/widgets/DynamicControlList.h
|
||||
playlist/dynamic/widgets/ReadOrWriteWidget.h
|
||||
playlist/dynamic/widgets/MiscControlWidgets.h
|
||||
|
||||
utils/querylabel.h
|
||||
utils/elidedlabel.h
|
||||
|
@ -16,10 +16,13 @@
|
||||
|
||||
#include "dynamic/echonest/EchonestControl.h"
|
||||
|
||||
#include "dynamic/widgets/MiscControlWidgets.h"
|
||||
|
||||
#include <echonest/Playlist.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
|
||||
@ -132,6 +135,27 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
connect( input, SIGNAL( editingFinished() ), this, SLOT( editingFinished() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_editingTimer, SLOT( stop() ) );
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( input );
|
||||
} else if( selectedType() == "Variety" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Variety;
|
||||
|
||||
QLabel* match = new QLabel( tr( "is" ) );
|
||||
LabeledSlider* input = new LabeledSlider( tr( "Less" ), tr( "More" ) );
|
||||
input->slider()->setRange( 0, 10000 );
|
||||
input->slider()->setTickInterval( 1 );
|
||||
input->slider()->setTracking( false );
|
||||
|
||||
m_matchString = match->text();
|
||||
m_matchData = match->text();
|
||||
|
||||
|
||||
connect( input->slider(), SIGNAL( valueChanged( int ) ), this, SLOT( updateData() ) );
|
||||
connect( input->slider(), SIGNAL( sliderMoved( int ) ), this, SLOT( editingFinished() ) );
|
||||
connect( input->slider(), SIGNAL( sliderMoved( int ) ), &m_editingTimer, SLOT( stop() ) );
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
@ -160,6 +184,12 @@ Tomahawk::EchonestControl::updateData()
|
||||
m_data.first = m_currentType;
|
||||
m_data.second = edit->text();
|
||||
}
|
||||
} else if( selectedType() == "Variety" ) {
|
||||
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
||||
if( s ) {
|
||||
m_data.first = m_currentType;
|
||||
m_data.second = (qreal)s->slider()->value() / 10000.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,6 +204,10 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||
if( edit )
|
||||
edit->setText( m_data.second.toString() );
|
||||
} else if( selectedType() == "Variety" ) {
|
||||
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
||||
if( s )
|
||||
s->slider()->setValue( m_data.second.toDouble() * 10000 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,9 @@ EchonestGenerator::determineRadioType() const throw( std::runtime_error )
|
||||
/**
|
||||
* so we try to match the best type of echonest playlist, based on the controls
|
||||
* the types are artist, artist-radio, artist-description, catalog, catalog-radio, song-radio. we don't care about the catalog ones.
|
||||
*/
|
||||
*
|
||||
* Fallback is artist-radio
|
||||
*/
|
||||
|
||||
/// 1. artist: If all the artist controls are Limit-To. If some were but not all, error out.
|
||||
bool artistOnly = true;
|
||||
|
@ -0,0 +1,38 @@
|
||||
/****************************************************************************************
|
||||
* Copyright (c) 2011 Leo Franchi <lfranchi@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify it under *
|
||||
* the terms of the GNU General Public License as published by the Free Software *
|
||||
* Foundation; either version 2 of the License, or (at your option) any later *
|
||||
* version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License along with *
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "MiscControlWidgets.h"
|
||||
|
||||
#include <QSlider>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
LabeledSlider::LabeledSlider( const QString& leftT, const QString& rightT, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
setLayout( new QHBoxLayout );
|
||||
|
||||
m_leftLabel = new QLabel( leftT, this );
|
||||
layout()->addWidget( m_leftLabel );
|
||||
|
||||
m_slider = new QSlider( Qt::Horizontal, this );
|
||||
layout()->addWidget( m_slider );
|
||||
|
||||
m_rightLabel = new QLabel( rightT, this );
|
||||
layout()->addWidget( m_rightLabel );
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/****************************************************************************************
|
||||
* Copyright (c) 2011 Leo Franchi <lfranchi@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify it under *
|
||||
* the terms of the GNU General Public License as published by the Free Software *
|
||||
* Foundation; either version 2 of the License, or (at your option) any later *
|
||||
* version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License along with *
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef MISC_CONTROL_WIDGETS_H
|
||||
#define MISC_CONTROL_WIDGETS_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QSlider;
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class LabeledSlider : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LabeledSlider( const QString& leftT, const QString& rightT, QWidget* parent = 0 );
|
||||
|
||||
QSlider* slider() { return m_slider; }
|
||||
|
||||
private:
|
||||
QSlider* m_slider;
|
||||
QLabel* m_leftLabel;
|
||||
QLabel* m_rightLabel;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user