Basic visualisation selector dialog.

This commit is contained in:
David Sansome 2010-06-07 01:55:21 +00:00
parent f3d53b741b
commit 2986b27fd7
36 changed files with 1115 additions and 0 deletions

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1248,12 +1248,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Zkopírovat do knihovny..."

View File

@ -1251,12 +1251,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Kopiér til bibliotek..."

View File

@ -1252,12 +1252,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "In die Musiksammlung kopieren..."

View File

@ -1254,12 +1254,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Αντιγραφή στην βιβλιοθήκη..."

View File

@ -1249,12 +1249,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copy to library..."

View File

@ -1246,12 +1246,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copy to library..."

View File

@ -1260,12 +1260,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copiar a la colección..."

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Kopioi kirjastoon"

View File

@ -1256,12 +1256,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copier dans la bilbiothèque..."

View File

@ -1244,12 +1244,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copiar para a biblioteca"

View File

@ -1257,12 +1257,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copia nella raccolta..."

View File

@ -1244,12 +1244,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1248,12 +1248,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Kopier til bibliotek..."

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1246,12 +1246,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Skopiuj do biblioteki..."

View File

@ -1251,12 +1251,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copiar para a biblioteca..."

View File

@ -1254,12 +1254,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copiar para biblioteca..."

View File

@ -1243,12 +1243,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Copiază în bibliotecă..."

View File

@ -1251,12 +1251,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Копировать в коллекцию..."

View File

@ -1251,12 +1251,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Skopírovať do zbierky..."

View File

@ -1251,12 +1251,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr "Kopiera till bibliotek..."

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1233,12 +1233,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -1242,12 +1242,36 @@ msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Select visualisations..."
msgstr ""
msgid "Close visualisation"
msgstr ""
msgid "Select All"
msgstr ""
msgid "Select None"
msgstr ""
msgid "Visualisations Settings"
msgstr ""
msgid "Select visualisations"
msgstr ""
msgid "Visualisation mode"
msgstr ""
msgid "Random visualisation"
msgstr ""
msgid "Choose from the list"
msgstr ""
msgid "Delay between visualisations"
msgstr ""
msgid "Copy to library..."
msgstr ""

View File

@ -4,19 +4,24 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include_directories("../../3rdparty/libprojectm")
set(SOURCES
projectmpresetmodel.cpp
projectmvisualisation.cpp
visualisationcontainer.cpp
visualisationoverlay.cpp
visualisationselector.cpp
)
set(HEADERS
projectmpresetmodel.h
projectmvisualisation.h
visualisationcontainer.h
visualisationoverlay.h
visualisationselector.h
)
set(UI
visualisationoverlay.ui
visualisationselector.ui
)
qt4_wrap_cpp(MOC ${HEADERS})

View File

@ -0,0 +1,92 @@
/* This file is part of Clementine.
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/>.
*/
#include "projectmpresetmodel.h"
#include "projectmvisualisation.h"
#include <projectM.hpp>
#include <QtDebug>
ProjectMPresetModel::ProjectMPresetModel(ProjectMVisualisation* vis, QObject *parent)
: QAbstractItemModel(parent),
vis_(vis)
{
}
int ProjectMPresetModel::rowCount(const QModelIndex&) const {
if (!vis_)
return 0;
return vis_->projectm()->getPlaylistSize();
}
int ProjectMPresetModel::columnCount(const QModelIndex&) const {
return 1;
}
QModelIndex ProjectMPresetModel::index(int row, int column, const QModelIndex&) const {
return createIndex(row, column);
}
QModelIndex ProjectMPresetModel::parent(const QModelIndex &child) const {
return QModelIndex();
}
QVariant ProjectMPresetModel::data(const QModelIndex &index, int role) const {
switch (role) {
case Qt::DisplayRole:
return QString::fromStdString(vis_->projectm()->getPresetName(index.row()));
case Qt::CheckStateRole: {
bool selected = vis_->is_selected(index.row());
return selected ? Qt::Checked : Qt::Unchecked;
}
case Role_Url:
return QString::fromStdString(vis_->projectm()->getPresetURL(index.row()));
default:
return QVariant();
}
}
Qt::ItemFlags ProjectMPresetModel::flags(const QModelIndex &index) const {
if (!index.isValid())
return QAbstractItemModel::flags(index);
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable |
Qt::ItemIsEnabled;
}
bool ProjectMPresetModel::setData(const QModelIndex &index,
const QVariant &value, int role) {
if (role == Qt::CheckStateRole) {
vis_->set_selected(index.row(), value.toBool());
return true;
}
return false;
}
void ProjectMPresetModel::SetImmediatePreset(const QModelIndex& index) {
vis_->projectm()->selectPreset(index.row(), true);
}
void ProjectMPresetModel::SelectAll() {
vis_->set_all_selected(true);
emit dataChanged(index(0, 0), index(rowCount()-1, 0));
}
void ProjectMPresetModel::SelectNone() {
vis_->set_all_selected(false);
emit dataChanged(index(0, 0), index(rowCount()-1, 0));
}

View File

@ -0,0 +1,52 @@
/* This file is part of Clementine.
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/>.
*/
#ifndef PROJECTMPRESETMODEL_H
#define PROJECTMPRESETMODEL_H
#include <QAbstractItemModel>
class ProjectMVisualisation;
class ProjectMPresetModel : public QAbstractItemModel {
Q_OBJECT
public:
ProjectMPresetModel(ProjectMVisualisation* vis, QObject* parent = 0);
enum {
Role_Url = Qt::UserRole,
};
// QAbstractItemModel
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
public slots:
void SetImmediatePreset(const QModelIndex& index);
void SelectAll();
void SelectNone();
private:
ProjectMVisualisation* vis_;
};
#endif // PROJECTMPRESETMODEL_H

View File

@ -15,6 +15,7 @@
*/
#include "projectmvisualisation.h"
#include "visualisationcontainer.h"
#include <QTimerEvent>
#include <QPainter>
@ -22,6 +23,7 @@
#include <QtDebug>
#include <QGLWidget>
#include <QGraphicsView>
#include <QSettings>
#include <projectM.hpp>
#include <GL/gl.h>
@ -29,6 +31,7 @@
ProjectMVisualisation::ProjectMVisualisation(QObject *parent)
: QGraphicsScene(parent),
projectm_(NULL),
mode_(0),
texture_size_(512)
{
connect(this, SIGNAL(sceneRectChanged(QRectF)), SLOT(SceneRectChanged(QRectF)));
@ -43,6 +46,7 @@ void ProjectMVisualisation::drawBackground(QPainter* p, const QRectF&) {
if (!projectm_) {
projectm_.reset(new projectM("/usr/share/projectM/config.inp"));
projectm_->changeTextureSize(texture_size_);
Load();
}
projectm_->projectM_resetGL(sceneRect().width(), sceneRect().height());
@ -71,3 +75,62 @@ void ProjectMVisualisation::ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*)
projectm_->pcm()->addPCM16Data(data, samples_per_channel);
gst_buffer_unref(buffer);
}
void ProjectMVisualisation::set_selected(int preset, bool selected) {
if (selected)
selected_indices_.insert(preset);
else
selected_indices_.remove(preset);
Save();
}
void ProjectMVisualisation::set_all_selected(bool selected) {
selected_indices_.clear();
if (selected) {
int count = projectm_->getPlaylistSize();
for (int i=0 ; i<count ; ++i) {
selected_indices_ << i;
}
}
Save();
}
void ProjectMVisualisation::Load() {
QSettings s;
s.beginGroup(VisualisationContainer::kSettingsGroup);
QVariantList presets(s.value("presets").toList());
int count = projectm_->getPlaylistSize();
selected_indices_.clear();
if (presets.isEmpty()) {
for (int i=0 ; i<count ; ++i)
selected_indices_ << i;
} else {
foreach (const QVariant& var, presets)
if (var.toInt() < count)
selected_indices_ << var.toInt();
}
mode_ = s.value("mode", 0).toInt();
}
void ProjectMVisualisation::Save() {
QVariantList list;
foreach (int index, selected_indices_.values()) {
list << index;
}
QSettings s;
s.beginGroup(VisualisationContainer::kSettingsGroup);
s.setValue("presets", list);
s.setValue("mode", mode_);
}
void ProjectMVisualisation::set_mode(int mode) {
mode_ = mode;
Save();
}

View File

@ -19,6 +19,7 @@
#include <QGraphicsScene>
#include <QBasicTimer>
#include <QSet>
#include <boost/scoped_ptr.hpp>
@ -32,6 +33,16 @@ public:
ProjectMVisualisation(QObject *parent = 0);
~ProjectMVisualisation();
projectM* projectm() const { return projectm_.get(); }
QSet<int> selected_indices() const { return selected_indices_; }
bool is_selected(int preset) { return selected_indices_.contains(preset); }
void set_selected(int preset, bool selected);
void set_all_selected(bool selected);
int mode() const { return mode_; }
void set_mode(int mode);
// BufferConsumer
void ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*);
@ -45,8 +56,14 @@ protected:
private slots:
void SceneRectChanged(const QRectF& rect);
private:
void Load();
void Save();
private:
boost::scoped_ptr<projectM> projectm_;
int mode_;
QSet<int> selected_indices_;
int texture_size_;
};

View File

@ -17,6 +17,7 @@
#include "projectmvisualisation.h"
#include "visualisationcontainer.h"
#include "visualisationoverlay.h"
#include "visualisationselector.h"
#include "engines/gstengine.h"
#include "ui/iconloader.h"
@ -41,6 +42,8 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
engine_(NULL),
vis_(new ProjectMVisualisation(this)),
overlay_(new VisualisationOverlay),
selector_(new VisualisationSelector(this)),
overlay_proxy_(NULL),
menu_(new QMenu(this)),
fps_(kDefaultFps),
size_(kDefaultTextureSize)
@ -73,6 +76,9 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
SizeChanged();
vis_->SetTextureSize(size_);
// Selector
selector_->SetVisualisation(vis_);
// Settings menu
menu_->addAction(IconLoader::Load("view-fullscreen"), tr("Toggle fullscreen"),
this, SLOT(ToggleFullscreen()));
@ -96,6 +102,8 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
quality_menu->addActions(quality_group->actions());
connect(quality_mapper, SIGNAL(mapped(int)), SLOT(SetQuality(int)));
menu_->addAction(tr("Select visualisations..."), selector_, SLOT(show()));
menu_->addSeparator();
menu_->addAction(IconLoader::Load("application-exit"), tr("Close visualisation"),
this, SLOT(hide()));

View File

@ -25,6 +25,7 @@
class GstEngine;
class ProjectMVisualisation;
class VisualisationOverlay;
class VisualisationSelector;
class QMenu;
class QSignalMapper;
@ -81,6 +82,8 @@ private:
VisualisationOverlay* overlay_;
QBasicTimer update_timer_;
VisualisationSelector* selector_;
QGraphicsProxyWidget* overlay_proxy_;
QMenu* menu_;

View File

@ -0,0 +1,68 @@
/* This file is part of Clementine.
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/>.
*/
#include "projectmpresetmodel.h"
#include "projectmvisualisation.h"
#include "visualisationselector.h"
#include "ui_visualisationselector.h"
#include <QPushButton>
VisualisationSelector::VisualisationSelector(QWidget *parent)
: QDialog(parent),
ui_(new Ui_VisualisationSelector),
vis_(NULL),
preset_model_(NULL)
{
ui_->setupUi(this);
QPushButton* select_all =
ui_->buttonBox->addButton(tr("Select All"), QDialogButtonBox::ActionRole);
QPushButton* select_none =
ui_->buttonBox->addButton(tr("Select None"), QDialogButtonBox::ActionRole);
connect(select_all, SIGNAL(clicked()), SLOT(SelectAll()));
connect(select_none, SIGNAL(clicked()), SLOT(SelectNone()));
connect(ui_->mode, SIGNAL(currentIndexChanged(int)), SLOT(ModeChanged(int)));
}
VisualisationSelector::~VisualisationSelector() {
delete ui_;
}
void VisualisationSelector::showEvent(QShowEvent *) {
if (!ui_->list->model()) {
preset_model_ = new ProjectMPresetModel(vis_, this);
ui_->list->setModel(preset_model_);
connect(ui_->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
preset_model_, SLOT(SetImmediatePreset(QModelIndex)));
ui_->mode->setCurrentIndex(vis_->mode());
}
}
void VisualisationSelector::ModeChanged(int mode) {
ui_->list->setEnabled(mode == 1);
vis_->set_mode(mode);
}
void VisualisationSelector::SelectAll() {
preset_model_->SelectAll();
}
void VisualisationSelector::SelectNone() {
preset_model_->SelectNone();
}

View File

@ -0,0 +1,49 @@
/* This file is part of Clementine.
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/>.
*/
#ifndef VISUALISATIONSELECTOR_H
#define VISUALISATIONSELECTOR_H
#include <QDialog>
class ProjectMPresetModel;
class ProjectMVisualisation;
class Ui_VisualisationSelector;
class VisualisationSelector : public QDialog {
Q_OBJECT
public:
VisualisationSelector(QWidget* parent = 0);
~VisualisationSelector();
void SetVisualisation(ProjectMVisualisation* vis) { vis_ = vis; }
protected:
void showEvent(QShowEvent *);
private slots:
void ModeChanged(int mode);
void SelectAll();
void SelectNone();
private:
Ui_VisualisationSelector* ui_;
ProjectMVisualisation* vis_;
ProjectMPresetModel* preset_model_;
};
#endif // VISUALISATIONSELECTOR_H

View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VisualisationSelector</class>
<widget class="QDialog" name="VisualisationSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>595</width>
<height>475</height>
</rect>
</property>
<property name="windowTitle">
<string>Select visualisations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Visualisation mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mode">
<item>
<property name="text">
<string>Random visualisation</string>
</property>
</item>
<item>
<property name="text">
<string>Choose from the list</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Delay between visualisations</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="delay">
<property name="suffix">
<string> seconds</string>
</property>
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>120</number>
</property>
<property name="value">
<number>15</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListView" name="list">
<property name="enabled">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>mode</tabstop>
<tabstop>delay</tabstop>
<tabstop>list</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>VisualisationSelector</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>VisualisationSelector</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>