2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-03-20 23:45:54 +01:00
|
|
|
#ifndef ANALYZERCONTAINER_H
|
|
|
|
#define ANALYZERCONTAINER_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QSignalMapper>
|
|
|
|
|
|
|
|
#include "analyzerbase.h"
|
2010-04-04 19:50:11 +02:00
|
|
|
#include "engines/engine_fwd.h"
|
2010-03-20 23:45:54 +01:00
|
|
|
|
|
|
|
class AnalyzerContainer : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
AnalyzerContainer(QWidget* parent);
|
|
|
|
|
2010-06-23 17:52:56 +02:00
|
|
|
void SetEngine(EngineBase* engine);
|
|
|
|
void SetActions(QAction* visualisation);
|
2010-03-20 23:45:54 +01:00
|
|
|
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
|
|
|
protected:
|
2010-03-21 17:20:27 +01:00
|
|
|
void mouseReleaseEvent(QMouseEvent *);
|
2010-06-23 17:52:56 +02:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent *);
|
2010-03-20 23:45:54 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ChangeAnalyzer(int id);
|
|
|
|
void DisableAnalyzer();
|
2010-06-23 17:52:56 +02:00
|
|
|
void ShowPopupMenu();
|
2010-03-20 23:45:54 +01:00
|
|
|
|
|
|
|
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_;
|
|
|
|
|
2010-06-23 17:52:56 +02:00
|
|
|
QAction* visualisation_action_;
|
|
|
|
QTimer* double_click_timer_;
|
|
|
|
QPoint last_click_pos_;
|
|
|
|
bool ignore_next_click_;
|
|
|
|
|
2010-08-28 20:48:16 +02:00
|
|
|
Analyzer::Base* current_analyzer_;
|
2010-03-20 23:45:54 +01:00
|
|
|
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
|
|
|
|
|