2010-06-07 03:55:21 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-07 03:55:21 +02: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-07-10 22:21:06 +02:00
|
|
|
#include "config.h"
|
2010-06-07 03:55:21 +02:00
|
|
|
#include "projectmpresetmodel.h"
|
|
|
|
#include "projectmvisualisation.h"
|
|
|
|
#include "visualisationselector.h"
|
|
|
|
#include "ui_visualisationselector.h"
|
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2010-07-10 22:21:06 +02:00
|
|
|
#ifdef USE_SYSTEM_PROJECTM
|
|
|
|
# include <libprojectM/projectM.hpp>
|
|
|
|
#else
|
|
|
|
# include "projectM.hpp"
|
|
|
|
#endif
|
2010-06-07 15:29:57 +02:00
|
|
|
|
2010-06-07 03:55:21 +02:00
|
|
|
VisualisationSelector::VisualisationSelector(QWidget *parent)
|
|
|
|
: QDialog(parent),
|
|
|
|
ui_(new Ui_VisualisationSelector),
|
2010-06-07 15:29:57 +02:00
|
|
|
vis_(NULL)
|
2010-06-07 03:55:21 +02:00
|
|
|
{
|
|
|
|
ui_->setupUi(this);
|
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
select_all_ =
|
2010-06-07 03:55:21 +02:00
|
|
|
ui_->buttonBox->addButton(tr("Select All"), QDialogButtonBox::ActionRole);
|
2010-06-07 15:29:57 +02:00
|
|
|
select_none_ =
|
2010-06-07 03:55:21 +02:00
|
|
|
ui_->buttonBox->addButton(tr("Select None"), QDialogButtonBox::ActionRole);
|
2010-06-07 15:29:57 +02:00
|
|
|
connect(select_all_, SIGNAL(clicked()), SLOT(SelectAll()));
|
|
|
|
connect(select_none_, SIGNAL(clicked()), SLOT(SelectNone()));
|
|
|
|
select_all_->setEnabled(false);
|
|
|
|
select_none_->setEnabled(false);
|
2010-06-07 03:55:21 +02:00
|
|
|
|
|
|
|
connect(ui_->mode, SIGNAL(currentIndexChanged(int)), SLOT(ModeChanged(int)));
|
|
|
|
}
|
|
|
|
|
|
|
|
VisualisationSelector::~VisualisationSelector() {
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualisationSelector::showEvent(QShowEvent *) {
|
|
|
|
if (!ui_->list->model()) {
|
2010-06-07 15:29:57 +02:00
|
|
|
ui_->list->setModel(vis_->preset_model());
|
2010-06-07 03:55:21 +02:00
|
|
|
connect(ui_->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
2010-06-07 15:29:57 +02:00
|
|
|
vis_->preset_model(), SLOT(SetImmediatePreset(QModelIndex)));
|
2010-06-07 15:36:50 +02:00
|
|
|
connect(ui_->delay, SIGNAL(valueChanged(int)), vis_, SLOT(SetDuration(int)));
|
2010-06-07 03:55:21 +02:00
|
|
|
|
|
|
|
ui_->mode->setCurrentIndex(vis_->mode());
|
|
|
|
}
|
2010-06-07 15:29:57 +02:00
|
|
|
|
|
|
|
vis_->Lock(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualisationSelector::hideEvent(QHideEvent *) {
|
|
|
|
vis_->Lock(false);
|
2010-06-07 03:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualisationSelector::ModeChanged(int mode) {
|
2010-06-07 15:29:57 +02:00
|
|
|
bool enabled = mode == 1;
|
|
|
|
ui_->list->setEnabled(enabled);
|
|
|
|
select_all_->setEnabled(enabled);
|
|
|
|
select_none_->setEnabled(enabled);
|
|
|
|
|
|
|
|
vis_->SetMode(ProjectMVisualisation::Mode(mode));
|
2010-06-07 03:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualisationSelector::SelectAll() {
|
2010-06-07 15:29:57 +02:00
|
|
|
vis_->preset_model()->SelectAll();
|
2010-06-07 03:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualisationSelector::SelectNone() {
|
2010-06-07 15:29:57 +02:00
|
|
|
vis_->preset_model()->SelectNone();
|
2010-06-07 03:55:21 +02:00
|
|
|
}
|