parent
595877445b
commit
e1c44cdc77
@ -13,6 +13,7 @@ set(CLEMENTINE-SOURCES
|
|||||||
analyzers/analyzerbase.cpp
|
analyzers/analyzerbase.cpp
|
||||||
fht.cpp
|
fht.cpp
|
||||||
analyzers/blockanalyzer.cpp
|
analyzers/blockanalyzer.cpp
|
||||||
|
analyzers/analyzercontainer.cpp
|
||||||
sliderwidget.cpp
|
sliderwidget.cpp
|
||||||
playlistview.cpp
|
playlistview.cpp
|
||||||
librarywatcher.cpp
|
librarywatcher.cpp
|
||||||
@ -104,6 +105,10 @@ set(CLEMENTINE-MOC-HEADERS
|
|||||||
m3uparser.h
|
m3uparser.h
|
||||||
playlistsequence.h
|
playlistsequence.h
|
||||||
xspfparser.h
|
xspfparser.h
|
||||||
|
analyzers/analyzercontainer.h
|
||||||
|
analyzers/baranalyzer.h
|
||||||
|
analyzers/blockanalyzer.h
|
||||||
|
analyzers/analyzerbase.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# UI files
|
# UI files
|
||||||
|
@ -36,14 +36,17 @@ typedef std::vector<float> Scope;
|
|||||||
|
|
||||||
class Base : public QWidget
|
class Base : public QWidget
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~Base() { delete m_fht; }
|
||||||
|
|
||||||
uint timeout() const { return m_timeout; }
|
uint timeout() const { return m_timeout; }
|
||||||
|
|
||||||
void set_engine(EngineBase* engine) { m_engine = engine; }
|
void set_engine(EngineBase* engine) { m_engine = engine; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Base( QWidget*, uint timeout, uint scopeSize = 7 );
|
Base( QWidget*, uint timeout, uint scopeSize = 7 );
|
||||||
~Base() { delete m_fht; }
|
|
||||||
|
|
||||||
void hideEvent(QHideEvent *);
|
void hideEvent(QHideEvent *);
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
91
src/analyzers/analyzercontainer.cpp
Normal file
91
src/analyzers/analyzercontainer.cpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#include "analyzercontainer.h"
|
||||||
|
#include "baranalyzer.h"
|
||||||
|
#include "blockanalyzer.h"
|
||||||
|
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
const char* AnalyzerContainer::kSettingsGroup = "Analyzer";
|
||||||
|
|
||||||
|
AnalyzerContainer::AnalyzerContainer(QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
context_menu_(new QMenu(this)),
|
||||||
|
group_(new QActionGroup(this)),
|
||||||
|
mapper_(new QSignalMapper(this)),
|
||||||
|
current_analyzer_(NULL),
|
||||||
|
engine_(NULL)
|
||||||
|
{
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
AddAnalyzerType<BarAnalyzer>();
|
||||||
|
AddAnalyzerType<BlockAnalyzer>();
|
||||||
|
connect(mapper_, SIGNAL(mapped(int)), SLOT(ChangeAnalyzer(int)));
|
||||||
|
|
||||||
|
context_menu_->addSeparator();
|
||||||
|
|
||||||
|
disable_action_ =
|
||||||
|
context_menu_->addAction(tr("No analyzer"), this, SLOT(DisableAnalyzer()));
|
||||||
|
disable_action_->setCheckable(true);
|
||||||
|
group_->addAction(disable_action_);
|
||||||
|
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
|
context_menu_->popup(e->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::set_engine(EngineBase *engine) {
|
||||||
|
if (current_analyzer_)
|
||||||
|
current_analyzer_->set_engine(engine);
|
||||||
|
engine_ = engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::DisableAnalyzer() {
|
||||||
|
delete current_analyzer_;
|
||||||
|
current_analyzer_ = NULL;
|
||||||
|
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::ChangeAnalyzer(int id) {
|
||||||
|
delete current_analyzer_;
|
||||||
|
current_analyzer_ = qobject_cast<Analyzer::Base*>(
|
||||||
|
analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this)));
|
||||||
|
current_analyzer_->set_engine(engine_);
|
||||||
|
|
||||||
|
layout()->addWidget(current_analyzer_);
|
||||||
|
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::Load() {
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
|
QString type = s.value("type", "BlockAnalyzer").toString();
|
||||||
|
if (type.isEmpty()) {
|
||||||
|
DisableAnalyzer();
|
||||||
|
disable_action_->setChecked(true);
|
||||||
|
} else {
|
||||||
|
for (int i=0 ; i<analyzer_types_.count() ; ++i) {
|
||||||
|
if (type == analyzer_types_[i]->className()) {
|
||||||
|
ChangeAnalyzer(i);
|
||||||
|
actions_[i]->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalyzerContainer::Save() {
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
|
s.setValue("type", current_analyzer_ ?
|
||||||
|
current_analyzer_->metaObject()->className() :
|
||||||
|
QVariant());
|
||||||
|
}
|
60
src/analyzers/analyzercontainer.h
Normal file
60
src/analyzers/analyzercontainer.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef ANALYZERCONTAINER_H
|
||||||
|
#define ANALYZERCONTAINER_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QSignalMapper>
|
||||||
|
|
||||||
|
#include "analyzerbase.h"
|
||||||
|
#include "engine_fwd.h"
|
||||||
|
|
||||||
|
class AnalyzerContainer : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AnalyzerContainer(QWidget* parent);
|
||||||
|
|
||||||
|
void set_engine(EngineBase* engine);
|
||||||
|
|
||||||
|
static const char* kSettingsGroup;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void contextMenuEvent(QContextMenuEvent *);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ChangeAnalyzer(int id);
|
||||||
|
void DisableAnalyzer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Load();
|
||||||
|
void Save();
|
||||||
|
template <typename T>
|
||||||
|
void AddAnalyzerType();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMenu* context_menu_;
|
||||||
|
QActionGroup* group_;
|
||||||
|
QSignalMapper* mapper_;
|
||||||
|
|
||||||
|
QList<const QMetaObject*> analyzer_types_;
|
||||||
|
QList<QAction*> actions_;
|
||||||
|
QAction* disable_action_;
|
||||||
|
|
||||||
|
Analyzer::Base* current_analyzer_;
|
||||||
|
EngineBase* engine_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void AnalyzerContainer::AddAnalyzerType() {
|
||||||
|
int id = analyzer_types_.count();
|
||||||
|
analyzer_types_ << &T::staticMetaObject;
|
||||||
|
|
||||||
|
QAction* action = context_menu_->addAction(tr(T::kName), mapper_, SLOT(map()));
|
||||||
|
group_->addAction(action);
|
||||||
|
mapper_->setMapping(action, id);
|
||||||
|
action->setCheckable(true);
|
||||||
|
actions_ << action;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -16,6 +16,8 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
const char* BarAnalyzer::kName = QT_TR_NOOP("Bar analyzer");
|
||||||
|
|
||||||
|
|
||||||
BarAnalyzer::BarAnalyzer( QWidget *parent )
|
BarAnalyzer::BarAnalyzer( QWidget *parent )
|
||||||
: Analyzer::Base( parent, 12, 8 )
|
: Analyzer::Base( parent, 12, 8 )
|
||||||
|
@ -13,8 +13,9 @@ typedef std::vector<uint> aroofMemVec;
|
|||||||
|
|
||||||
class BarAnalyzer : public Analyzer::Base
|
class BarAnalyzer : public Analyzer::Base
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
BarAnalyzer( QWidget* );
|
Q_INVOKABLE BarAnalyzer( QWidget* );
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
virtual void analyze( QPainter& p, const Scope& );
|
virtual void analyze( QPainter& p, const Scope& );
|
||||||
@ -34,6 +35,8 @@ class BarAnalyzer : public Analyzer::Base
|
|||||||
static const uint NUM_ROOFS = 16;
|
static const uint NUM_ROOFS = 16;
|
||||||
static const uint COLUMN_WIDTH = 4;
|
static const uint COLUMN_WIDTH = 4;
|
||||||
|
|
||||||
|
static const char* kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPixmap m_pixRoof[NUM_ROOFS];
|
QPixmap m_pixRoof[NUM_ROOFS];
|
||||||
//vector<uint> m_roofMem[BAND_COUNT];
|
//vector<uint> m_roofMem[BAND_COUNT];
|
||||||
|
@ -21,6 +21,8 @@ const uint BlockAnalyzer::MIN_COLUMNS = 32; //arbituary
|
|||||||
const uint BlockAnalyzer::MAX_COLUMNS = 256; //must be 2**n
|
const uint BlockAnalyzer::MAX_COLUMNS = 256; //must be 2**n
|
||||||
const uint BlockAnalyzer::FADE_SIZE = 90;
|
const uint BlockAnalyzer::FADE_SIZE = 90;
|
||||||
|
|
||||||
|
const char* BlockAnalyzer::kName = QT_TR_NOOP("Block analyzer");
|
||||||
|
|
||||||
BlockAnalyzer::BlockAnalyzer( QWidget *parent )
|
BlockAnalyzer::BlockAnalyzer( QWidget *parent )
|
||||||
: Analyzer::Base( parent, 20, 9 )
|
: Analyzer::Base( parent, 20, 9 )
|
||||||
, m_columns( 0 ) //uint
|
, m_columns( 0 ) //uint
|
||||||
|
@ -19,8 +19,9 @@ class QPalette;
|
|||||||
|
|
||||||
class BlockAnalyzer : public Analyzer::Base
|
class BlockAnalyzer : public Analyzer::Base
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
BlockAnalyzer( QWidget* );
|
Q_INVOKABLE BlockAnalyzer( QWidget* );
|
||||||
~BlockAnalyzer();
|
~BlockAnalyzer();
|
||||||
|
|
||||||
static const uint HEIGHT;
|
static const uint HEIGHT;
|
||||||
@ -30,6 +31,8 @@ public:
|
|||||||
static const uint MAX_COLUMNS;
|
static const uint MAX_COLUMNS;
|
||||||
static const uint FADE_SIZE;
|
static const uint FADE_SIZE;
|
||||||
|
|
||||||
|
static const char* kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void transform( Scope& );
|
virtual void transform( Scope& );
|
||||||
virtual void analyze( QPainter& p, const Scope& );
|
virtual void analyze( QPainter& p, const Scope& );
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlockAnalyzer" name="analyzer" native="true">
|
<widget class="AnalyzerContainer" name="analyzer" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>100</horstretch>
|
<horstretch>100</horstretch>
|
||||||
@ -747,12 +747,6 @@
|
|||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header>lineedit.h</header>
|
<header>lineedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>BlockAnalyzer</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>analyzers/blockanalyzer.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>Amarok::VolumeSlider</class>
|
<class>Amarok::VolumeSlider</class>
|
||||||
<extends>QSlider</extends>
|
<extends>QSlider</extends>
|
||||||
@ -779,6 +773,12 @@
|
|||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header>radioview.h</header>
|
<header>radioview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AnalyzerContainer</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>analyzers/analyzercontainer.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../data/data.qrc"/>
|
<include location="../data/data.qrc"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user