diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2014-02-16 16:23:39 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2014-02-16 16:23:39 +0000 |
| commit | 283814627de1f7e755c89b6bf1caa75589a05d16 (patch) | |
| tree | 640c34c16c2f120ab04da8b4156c0f45d4493f0a | |
| parent | 38a7f395a5598e1207b0a411bdc04638bb022f36 (diff) | |
| download | qmmp-283814627de1f7e755c89b6bf1caa75589a05d16.tar.gz qmmp-283814627de1f7e755c89b6bf1caa75589a05d16.tar.bz2 qmmp-283814627de1f7e755c89b6bf1caa75589a05d16.zip | |
projectm: added menu
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4096 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/Visual/projectm/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectm.pro | 6 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmplugin.cpp | 12 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmplugin.h | 5 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmwidget.cpp | 46 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmwidget.h | 16 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmwrapper.cpp | 47 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmwrapper.h | 48 |
8 files changed, 150 insertions, 32 deletions
diff --git a/src/plugins/Visual/projectm/CMakeLists.txt b/src/plugins/Visual/projectm/CMakeLists.txt index 75d296ee9..0d698f232 100644 --- a/src/plugins/Visual/projectm/CMakeLists.txt +++ b/src/plugins/Visual/projectm/CMakeLists.txt @@ -51,12 +51,14 @@ SET(libprojectm_SRCS projectmwidget.cpp projectmplugin.cpp visualprojectmfactory.cpp + projectmwrapper.cpp ) SET(libprojectm_MOC_HDRS projectmwidget.h projectmplugin.h visualprojectmfactory.h + projectmwrapper.h ) SET(libprojectm_RCCS translations/translations.qrc) diff --git a/src/plugins/Visual/projectm/projectm.pro b/src/plugins/Visual/projectm/projectm.pro index 8cd6b7bd3..cf30541cb 100644 --- a/src/plugins/Visual/projectm/projectm.pro +++ b/src/plugins/Visual/projectm/projectm.pro @@ -9,10 +9,12 @@ QMAKE_CLEAN =$$PLUGINS_PREFIX/Visual/libprojectm.so HEADERS += projectmwidget.h \ visualprojectmfactory.h \ - projectmplugin.h + projectmplugin.h \ + projectmwrapper.h SOURCES += projectmplugin.cpp \ visualprojectmfactory.cpp \ - projectmwidget.cpp + projectmwidget.cpp \ + projectmwrapper.cpp INCLUDEPATH += ../../../ CONFIG += warn_on \ plugin \ diff --git a/src/plugins/Visual/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp index d730ec04d..1178226c5 100644 --- a/src/plugins/Visual/projectm/projectmplugin.cpp +++ b/src/plugins/Visual/projectm/projectmplugin.cpp @@ -23,6 +23,8 @@ #include <QMenu> #include <QActionGroup> #include <QHBoxLayout> +#include <QSplitter> +#include <QListWidget> #include <math.h> #include <stdlib.h> #include <locale.h> @@ -38,11 +40,17 @@ ProjectMPlugin::ProjectMPlugin (QWidget *parent) setlocale(LC_NUMERIC, "C"); //fixes problem with none-english locales setWindowTitle(tr("ProjectM")); - m_projectMWidget = new ProjectMWidget(this); + QListWidget *listWidget = new QListWidget(this); + m_projectMWidget = new ProjectMWidget(listWidget, this); + m_splitter = new QSplitter(Qt::Horizontal, this); + m_splitter->addWidget(listWidget); + m_splitter->addWidget(m_projectMWidget); QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(m_projectMWidget); + layout->addWidget(m_splitter); layout->setContentsMargins(0,0,0,0); setLayout(layout); + addActions(m_projectMWidget->actions()); + connect(m_projectMWidget, SIGNAL(showMenuToggled(bool)), listWidget, SLOT(setVisible(bool))); resize(300,300); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); restoreGeometry(settings.value("ProjectM/geometry").toByteArray()); diff --git a/src/plugins/Visual/projectm/projectmplugin.h b/src/plugins/Visual/projectm/projectmplugin.h index c0fcf577d..f44b0d292 100644 --- a/src/plugins/Visual/projectm/projectmplugin.h +++ b/src/plugins/Visual/projectm/projectmplugin.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2013 by Ilya Kotov * + * Copyright (C) 2009-2014 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -24,13 +24,13 @@ #include <qmmp/visual.h> class QTimer; +class QSplitter; class Buffer; class ProjectMWidget; class ProjectMPlugin : public Visual { Q_OBJECT - public: ProjectMPlugin(QWidget *parent = 0); virtual ~ProjectMPlugin(); @@ -42,6 +42,7 @@ private: void closeEvent(QCloseEvent *event); QTimer *m_timer; ProjectMWidget *m_projectMWidget; + QSplitter *m_splitter; }; diff --git a/src/plugins/Visual/projectm/projectmwidget.cpp b/src/plugins/Visual/projectm/projectmwidget.cpp index eaceded3f..b43441f28 100644 --- a/src/plugins/Visual/projectm/projectmwidget.cpp +++ b/src/plugins/Visual/projectm/projectmwidget.cpp @@ -27,36 +27,35 @@ #include <QKeyEvent> #include <QMenu> #include <QApplication> -#include <libprojectM/projectM.hpp> +#include <QListWidget> #include <qmmp/soundcore.h> #include <qmmp/qmmp.h> +#include "projectmwrapper.h" #include "projectmwidget.h" #ifndef PROJECTM_CONFIG #define PROJECTM_CONFIG "/usr/share/projectM/config.inp" #endif -ProjectMWidget::ProjectMWidget(QWidget *parent) +ProjectMWidget::ProjectMWidget(QListWidget *listWidget, QWidget *parent) : QGLWidget(parent) { setMouseTracking(true); + m_listWidget = listWidget; m_projectM = 0; m_timer = new QTimer(this); - connect(m_timer, SIGNAL(timeout()),SLOT(updateGL ())); + connect(m_timer, SIGNAL(timeout()),SLOT(updateGL())); m_menu = new QMenu(this); connect(SoundCore::instance(), SIGNAL(metaDataChanged()), SLOT(updateTitle())); qDebug("ProjectMWidget: opengl version: %d.%d", context()->format().majorVersion(), context()->format().minorVersion()); + createActions(); } ProjectMWidget::~ProjectMWidget() -{ - if (m_projectM) - delete m_projectM; - m_projectM = 0; -} +{} projectM *ProjectMWidget::projectMInstance() { @@ -85,8 +84,6 @@ void ProjectMWidget::initializeGL() glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glLineStipple(2, 0xAAAA); - ; - if (!m_projectM) { #ifdef Q_OS_WIN @@ -107,9 +104,9 @@ void ProjectMWidget::initializeGL() settings.easterEgg = 1.0; settings.shuffleEnabled = false; settings.softCutRatingsEnabled = false; - m_projectM = new projectM(settings, projectM::FLAG_DISABLE_PLAYLIST_LOAD); + m_projectM = new ProjectMWrapper(settings, projectM::FLAG_DISABLE_PLAYLIST_LOAD, this); #else - m_projectM = new projectM(PROJECTM_CONFIG, projectM::FLAG_DISABLE_PLAYLIST_LOAD); + m_projectM = new ProjectMWrapper(PROJECTM_CONFIG, projectM::FLAG_DISABLE_PLAYLIST_LOAD, this); #endif QString presetPath = QString::fromLocal8Bit(m_projectM->settings().presetURL.c_str()); QDir presetDir(presetPath); @@ -129,8 +126,11 @@ void ProjectMWidget::initializeGL() #else m_projectM->addPresetURL (info.absoluteFilePath().toStdString(), info.fileName().toStdString(), 1); #endif + m_listWidget->addItem(info.fileName()); + m_listWidget->setCurrentRow(0,QItemSelectionModel::Select); } - createActions(); + connect(m_listWidget, SIGNAL(currentRowChanged(int)), m_projectM, SLOT(selectPreset(int))); + connect(m_projectM, SIGNAL(currentPresetChanged(int)), SLOT(setCurrentRow(int))); updateTitle(); m_timer->start(0); } @@ -159,18 +159,19 @@ void ProjectMWidget::mousePressEvent (QMouseEvent *event) void ProjectMWidget::createActions() { - m_menu->addAction(tr("&Help"), this, SLOT(showHelp()), tr("F1")); - m_menu->addAction(tr("&Show Song Title"), this, SLOT(showTitle()), tr("F2")); - m_menu->addAction(tr("&Show Preset Name"), this, SLOT(showPresetName()), tr("F3")); + m_menu->addAction(tr("&Help"), this, SLOT(showHelp()), tr("F1"))->setCheckable(true); + m_menu->addAction(tr("&Show Song Title"), this, SLOT(showTitle()), tr("F2"))->setCheckable(true); + m_menu->addAction(tr("&Show Preset Name"), this, SLOT(showPresetName()), tr("F3"))->setCheckable(true); + m_menu->addAction(tr("&Show Menu"), this, SIGNAL(showMenuToggled(bool)), tr("M"))->setCheckable(true); m_menu->addSeparator(); m_menu->addAction(tr("&Next Preset"), this, SLOT(nextPreset()), tr("N")); m_menu->addAction(tr("&Previous Preset"), this, SLOT(previousPreset()), tr("P")); m_menu->addAction(tr("&Random Preset"), this, SLOT(randomPreset()), tr("R")); - m_menu->addAction(tr("&Lock Preset"), this, SLOT(lockPreset()), tr("L")); + m_menu->addAction(tr("&Lock Preset"), this, SLOT(lockPreset(bool)), tr("L"))->setCheckable(true); m_menu->addSeparator(); m_menu->addAction(tr("&Fullscreen"), this, SLOT(fullScreen()), tr("F")); m_menu->addSeparator(); - parentWidget()->addActions(m_menu->actions()); + addActions(m_menu->actions()); } void ProjectMWidget::showHelp() @@ -203,9 +204,9 @@ void ProjectMWidget::randomPreset() m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_r, PROJECTM_KMOD_LSHIFT); } -void ProjectMWidget::lockPreset() +void ProjectMWidget::lockPreset(bool lock) { - m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_l, PROJECTM_KMOD_LSHIFT); + m_projectM->setPresetLock(lock); } void ProjectMWidget::fullScreen() @@ -219,3 +220,8 @@ void ProjectMWidget::updateTitle() std::string title = SoundCore::instance()->metaData(Qmmp::TITLE).toLocal8Bit().constData(); m_projectM->projectM_setTitle(artist + " - " + title); } + +void ProjectMWidget::setCurrentRow(int row) +{ + m_listWidget->setCurrentRow(row); +} diff --git a/src/plugins/Visual/projectm/projectmwidget.h b/src/plugins/Visual/projectm/projectmwidget.h index 0e9500e37..f2597ea1b 100644 --- a/src/plugins/Visual/projectm/projectmwidget.h +++ b/src/plugins/Visual/projectm/projectmwidget.h @@ -22,13 +22,12 @@ #include <QGLWidget> - class QMenu; class QTimer; +class QListWidget; +class ProjectMWrapper; class projectM; - - /** @author Ilya Kotov <forkotov02@hotmail.ru> */ @@ -36,12 +35,15 @@ class ProjectMWidget : public QGLWidget { Q_OBJECT public: - ProjectMWidget(QWidget *parent = 0); + ProjectMWidget(QListWidget *listWidget, QWidget *parent = 0); ~ProjectMWidget(); projectM *projectMInstance(); +signals: + void showMenuToggled(bool); + protected: virtual void initializeGL(); virtual void resizeGL(int width, int height); @@ -55,15 +57,17 @@ private slots: void nextPreset(); void previousPreset(); void randomPreset(); - void lockPreset(); + void lockPreset(bool lock); void fullScreen(); void updateTitle(); + void setCurrentRow(int row); private: void createActions(); - projectM *m_projectM; + ProjectMWrapper *m_projectM; QMenu *m_menu; QTimer *m_timer; + QListWidget *m_listWidget; }; #endif diff --git a/src/plugins/Visual/projectm/projectmwrapper.cpp b/src/plugins/Visual/projectm/projectmwrapper.cpp new file mode 100644 index 000000000..2241d141d --- /dev/null +++ b/src/plugins/Visual/projectm/projectmwrapper.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "projectmwrapper.h" + +ProjectMWrapper::ProjectMWrapper(std::string config_file, int flags, QObject *parent) : + QObject(parent), projectM(config_file, flags) +{ +} + +ProjectMWrapper::ProjectMWrapper(projectM::Settings settings, int flags, QObject *parent) : + QObject(parent), projectM(settings, flags) +{ +} + +ProjectMWrapper::~ProjectMWrapper() +{ +} + +void ProjectMWrapper::selectPreset(int index) +{ + if(index >= 0) + projectM::selectPreset(index); +} + +void ProjectMWrapper::presetSwitchedEvent(bool isHardCut, unsigned int index) const +{ + Q_UNUSED(isHardCut); + emit currentPresetChanged(index); +} diff --git a/src/plugins/Visual/projectm/projectmwrapper.h b/src/plugins/Visual/projectm/projectmwrapper.h new file mode 100644 index 000000000..92a4008d0 --- /dev/null +++ b/src/plugins/Visual/projectm/projectmwrapper.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2013 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef PROJECTMWRAPPER_H +#define PROJECTMWRAPPER_H + +#include <QObject> +#include <libprojectM/projectM.hpp> + +class ProjectMWrapper : public QObject, public projectM +{ + Q_OBJECT +public: + explicit ProjectMWrapper(std::string config_file, int flags, QObject *parent = 0); + explicit ProjectMWrapper(Settings settings, int flags, QObject *parent = 0); + + virtual ~ProjectMWrapper(); + +signals: + void currentPresetChanged(int index) const; + +public slots: + void selectPreset(int index); + +private: + void presetSwitchedEvent(bool isHardCut, unsigned int index) const; + + +}; + +#endif // PROJECTMWRAPPER_H |
