From 4df23e9b87f7124b59778aa02ab776e842989e0e Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 28 Feb 2009 20:16:19 +0000 Subject: enapled projectM plugin git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@812 90c681e8-e032-0410-971d-27865f9a5e38 --- CMakeLists.txt | 1 + README | 4 +- README.RUS | 4 +- qmmp.pri | 1 + src/plugins/Visual/CMakeLists.txt | 5 + src/plugins/Visual/Visual.pro | 8 ++ src/plugins/Visual/projectm/CMakeLists.txt | 62 ++++++++++ src/plugins/Visual/projectm/analyzer.cpp | 128 --------------------- src/plugins/Visual/projectm/analyzer.h | 95 --------------- src/plugins/Visual/projectm/projectm.pro | 29 +++-- src/plugins/Visual/projectm/projectmplugin.cpp | 62 ++++++++++ src/plugins/Visual/projectm/projectmplugin.h | 48 ++++++++ src/plugins/Visual/projectm/projectmwidget.cpp | 106 +++++++++++++++-- src/plugins/Visual/projectm/projectmwidget.h | 25 +++- src/plugins/Visual/projectm/qprojectm.h | 35 ------ .../projectm/translations/projectm_plugin_cs.ts | 128 +++++++++++++++++++++ .../projectm/translations/projectm_plugin_de.ts | 128 +++++++++++++++++++++ .../projectm/translations/projectm_plugin_ru.ts | 128 +++++++++++++++++++++ .../projectm/translations/projectm_plugin_uk_UA.ts | 128 +++++++++++++++++++++ .../projectm/translations/projectm_plugin_zh_CN.ts | 128 +++++++++++++++++++++ .../projectm/translations/projectm_plugin_zh_TW.ts | 128 +++++++++++++++++++++ .../Visual/projectm/translations/translations.qrc | 11 ++ .../Visual/projectm/visualprojectmfactory.cpp | 21 ++-- .../Visual/projectm/visualprojectmfactory.h | 2 +- 24 files changed, 1113 insertions(+), 302 deletions(-) create mode 100644 src/plugins/Visual/projectm/CMakeLists.txt delete mode 100644 src/plugins/Visual/projectm/analyzer.cpp delete mode 100644 src/plugins/Visual/projectm/analyzer.h create mode 100644 src/plugins/Visual/projectm/projectmplugin.cpp create mode 100644 src/plugins/Visual/projectm/projectmplugin.h delete mode 100644 src/plugins/Visual/projectm/qprojectm.h create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_cs.ts create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_de.ts create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_ru.ts create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_uk_UA.ts create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_zh_CN.ts create mode 100644 src/plugins/Visual/projectm/translations/projectm_plugin_zh_TW.ts create mode 100644 src/plugins/Visual/projectm/translations/translations.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index a918aff79..057d4a60f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,7 @@ PRINT_SUMMARY ("BS2B Plugin........................" USE_BS2B BS2B_FOUND) MESSAGE("") MESSAGE("Visual Plugins:") PRINT_SUMMARY ("Analyzer .........................." USE_ANALYZER 1) +PRINT_SUMMARY ("ProjectM .........................." USE_PROJECTM PROJECTM_FOUND) MESSAGE("") MESSAGE("General Plugins:") diff --git a/README b/README index 82de748fd..ed00aad97 100644 --- a/README +++ b/README @@ -22,6 +22,7 @@ Main opportunities: - PulseAudio output - Last.fm scrobbler - Spectrum Analyzer +- projectm visualization - sample rate conversion - bs2b dsp effect - streaming support (MP3, Vorbis via IceCast/ShoutCast) @@ -53,6 +54,7 @@ Requirements: - cdio >= 0.80 (Optional) - faad2 >= 2.6.1 (Optional) - libbs2b >= 2.2.1 (Optional) +- libprojectM >= 1.2.0 (Optional) - cmake >= 2.4.8 (for build only) @@ -74,7 +76,7 @@ cmake ./ -D USE_JACK:BOOL=FALSE Available options: USE_MAD, USE_FLAC, USE_VORBIS, USE_MPC, USE_MODPLUG, USE_SNDFILE, USE_WAVPACK, USE_FFMPEG, USE_AAC, USE_CUE, USE_MPLAYER, USE_CDA, USE_ALSA, USE_OSS, USE_JACK, USE_PULSE, USE_SRC, USE_BS2B, USE_ANALYZER, USE_MPRIS, -USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_QMMP_DIALOG +USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_QMMP_DIALOG, USE_PROJECTM Also you can use ccmake for changing plugins configuration. By default program will be installed in /usr/local. You can change default path by running: diff --git a/README.RUS b/README.RUS index 2f6ca2e03..3144641fe 100644 --- a/README.RUS +++ b/README.RUS @@ -22,6 +22,7 @@ Qmmp - Qt-based multimedia player - вывод звука через PulseAudio - скробблер Last.fm - анализатор спектра +- визуализация с помощью projectM - передискретизация - эффект bs2b - поддержка потокового вещания (MP3, Vorbis через IceCast/ShoutCast) @@ -53,6 +54,7 @@ Qmmp - Qt-based multimedia player - cdio >= 0.80 (Опционально) - faad2 >= 2.6.1 (Опционально) - libbs2b >= 2.2.1 (Опционально) +- libprojectM >= 1.2.0 (Опционально) - cmake >= 2.4.8 (только для сборки) Внимание! Для сборки Qmmp нужна утилита lrelease. Очень часто она находится в пакете qt4-linguist. @@ -72,7 +74,7 @@ cmake ./ -D USE_JACK:BOOL=FALSE Доступные опции: USE_MAD, USE_FLAC, USE_VORBIS, USE_MPC, USE_MODPLUG, USE_SNDFILE, USE_WAVPACK, USE_FFMPEG, USE_AAC, USE_CUE, USE_MPLAYER, USE_CDA, USE_ALSA, USE_OSS, USE_JACK, USE_PULSE, USE_SRC, USE_BS2B, USE_ANALYZER, USE_MPRIS, -USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_QMMP_DIALOG +USE_SCROBBLER, USE_STATICON, USE_NOTIFIER, USE_LYRICS, USE_HAL, USE_HOTKEY, USE_QMMP_DIALOG, USE_PROJECTM Также вы можете использовать ccmake для изменения конфигурации модулей. По умолчанию программа будет установлена в /usr/local. Вы можете изменить этот путь командой: diff --git a/qmmp.pri b/qmmp.pri index 60801d6b1..dadeda239 100644 --- a/qmmp.pri +++ b/qmmp.pri @@ -25,3 +25,4 @@ CONFIG += AAC_PLUGIN CONFIG += MPLAYER_PLUGIN CONFIG += CDAUDIO_PLUGIN CONFIG += BS2B_PLUGIN +CONFIG += PROJECTM_PLUGIN diff --git a/src/plugins/Visual/CMakeLists.txt b/src/plugins/Visual/CMakeLists.txt index de8652ddf..c6571092a 100644 --- a/src/plugins/Visual/CMakeLists.txt +++ b/src/plugins/Visual/CMakeLists.txt @@ -1,5 +1,10 @@ SET(USE_ANALYZER TRUE CACHE BOOL "enable/disable analyzer plugin") +SET(USE_PROJECTM TRUE CACHE BOOL "enable/disable projectm plugin") IF(USE_ANALYZER) add_subdirectory(analyzer) ENDIF(USE_ANALYZER) + +IF(USE_PROJECTM) +add_subdirectory(projectm) +ENDIF(USE_PROJECTM) diff --git a/src/plugins/Visual/Visual.pro b/src/plugins/Visual/Visual.pro index e30196780..527a03997 100644 --- a/src/plugins/Visual/Visual.pro +++ b/src/plugins/Visual/Visual.pro @@ -1,3 +1,11 @@ +include(../../../qmmp.pri) TEMPLATE = subdirs SUBDIRS += analyzer + +contains(CONFIG, PROJECTM_PLUGIN){ + SUBDIRS += projectm + message(***************************) + message(* projectM plugin enabled *) + message(***************************) +} diff --git a/src/plugins/Visual/projectm/CMakeLists.txt b/src/plugins/Visual/projectm/CMakeLists.txt new file mode 100644 index 000000000..ba0e7f808 --- /dev/null +++ b/src/plugins/Visual/projectm/CMakeLists.txt @@ -0,0 +1,62 @@ +project(libprojectm) + +cmake_minimum_required(VERSION 2.4.7) + +SET (QT_USE_QTOPENGL TRUE) +INCLUDE(FindQt4) +include(${QT_USE_FILE}) + +if(COMMAND cmake_policy) +cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +# qt plugin +ADD_DEFINITIONS( -Wall ) +ADD_DEFINITIONS(${QT_DEFINITIONS}) +ADD_DEFINITIONS(-DQT_PLUGIN) +ADD_DEFINITIONS(-DQT_NO_DEBUG) +ADD_DEFINITIONS(-DQT_SHARED) +ADD_DEFINITIONS(-DQT_THREAD) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +SET(QT_INCLUDES + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../../ +) + +# libqmmp +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) +link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) + +# projectM +pkg_search_module(PROJECTM libprojectM) + +SET(libprojectm_SRCS + projectmwidget.cpp + projectmplugin.cpp + visualprojectmfactory.cpp +) + +SET(libprojectm_MOC_HDRS + projectmwidget.h + projectmplugin.h + visualprojectmfactory.h +) + +SET(libprojectm_RCCS translations/translations.qrc) + +QT4_ADD_RESOURCES(libprojectm_RCC_SRCS ${libprojectm_RCCS}) + +QT4_WRAP_CPP(libprojectm_MOC_SRCS ${libprojectm_MOC_HDRS}) + + +# Don't forget to include output directory, otherwise +# the UI file won't be wrapped! +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +IF(PROJECTM_FOUND) +ADD_LIBRARY(projectm SHARED ${libprojectm_SRCS} ${libprojectm_MOC_SRCS} ${libprojectm_RCC_SRCS}) +add_dependencies(projectm qmmp) +target_link_libraries(projectm ${QT_LIBRARIES} -lqmmp ${PROJECTM_LDFLAGS} ${PROJECTM_CFLAGS}) +install(TARGETS projectm DESTINATION ${LIB_DIR}/qmmp/Visual) +ENDIF(PROJECTM_FOUND) diff --git a/src/plugins/Visual/projectm/analyzer.cpp b/src/plugins/Visual/projectm/analyzer.cpp deleted file mode 100644 index 86a2b4021..000000000 --- a/src/plugins/Visual/projectm/analyzer.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "projectmwidget.h" -#include "analyzer.h" - - -Analyzer::Analyzer (QWidget *parent) - : Visual (parent), m_fps ( 20 ) -{ - setlocale(LC_NUMERIC, "C"); - m_projectMWidget = new ProjectMWidget(this); - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(m_projectMWidget); - layout->setContentsMargins(0,0,0,0); - setLayout(layout); - resize(300,300); -} - -Analyzer::~Analyzer() -{ - while (!m_nodes.isEmpty()) - m_nodes.removeFirst(); - //m_window->deleteLater(); -} - -void Analyzer::clear() -{ - while (!m_nodes.isEmpty()) - m_nodes.removeFirst(); - for ( int i = 0; i< 75; ++i ) - { - m_intern_vis_data[i] = 0; - m_peaks[i] = 0; - } - update(); -} - -void Analyzer::add ( Buffer *b, unsigned long w, int c, int p ) -{ - if (m_projectMWidget->projectM()) - m_projectMWidget->projectM()->pcm()->addPCM16Data((short *)b->data, b->nbytes/4); -} - -void Analyzer::keyReleaseEvent (QKeyEvent *e) -{ - - projectMKeycode pkey; - bool ignore = FALSE; - switch (e->key()) - { - case Qt::Key_F: - { - setWindowState (windowState() ^Qt::WindowFullScreen); - return; - } - case Qt::Key_M: - pkey = PROJECTM_K_M; - break; - case Qt::Key_F4: - pkey = PROJECTM_K_F4; - break; - case Qt::Key_F3: - pkey = PROJECTM_K_F3; - break; - case Qt::Key_F2: - pkey = PROJECTM_K_F2; - break; - case Qt::Key_F1: - pkey = PROJECTM_K_F1; - break; - case Qt::Key_R: - pkey = PROJECTM_K_r; - break; - case Qt::Key_L: - pkey = PROJECTM_K_l; - ignore = true; - break; - case Qt::Key_N: - pkey = PROJECTM_K_n; - break; - case Qt::Key_P: - pkey = PROJECTM_K_p; - break; - case Qt::Key_F5: - pkey = PROJECTM_K_F5; - break; - default: - e->ignore(); - return; - } - projectMModifier modifier; - - m_projectMWidget->projectM()->key_handler(PROJECTM_KEYDOWN, pkey, modifier); - if (ignore) - e->ignore(); -} diff --git a/src/plugins/Visual/projectm/analyzer.h b/src/plugins/Visual/projectm/analyzer.h deleted file mode 100644 index 77f9b5d3a..000000000 --- a/src/plugins/Visual/projectm/analyzer.h +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef ANALYZER_H -#define ANALYZER_H - -#include -#include -#include -#include -#include -#include -#include - -class QSettings; -class QTimer; -class QMenu; -class QActionGroup; - -class Buffer; - -class ProjectMWidget; - - -class VisualNode -{ -public: - VisualNode(short *l, short *r, unsigned long n, unsigned long o) - : left(l), right(r), length(n), offset(o) - { - // left and right are allocated and then passed to this class - // the code that allocated left and right should give up all ownership - } - - ~VisualNode() - { - delete [] left; - delete [] right; - } - - short *left, *right; - long length, offset; -}; - -class Analyzer : public Visual -{ - Q_OBJECT - -public: - Analyzer(QWidget *parent = 0); - virtual ~Analyzer(); - - void add(Buffer *, unsigned long, int, int); - void clear(); - -private: - void keyReleaseEvent (QKeyEvent *e); - QPixmap m_pixmap; - QPixmap m_bg; - QList m_nodes; - QTimer *m_timer; - ProjectMWidget *m_projectMWidget; - QMutex mutex; - int m_fps; - double m_intern_vis_data[75]; - double m_peaks[75]; - double m_peaks_falloff; - double m_analyzer_falloff; - bool m_show_peaks; - //colors - QColor m_color1; - QColor m_color2; - QColor m_color3; - QColor m_bgColor; - QColor m_peakColor; -}; - - -#endif diff --git a/src/plugins/Visual/projectm/projectm.pro b/src/plugins/Visual/projectm/projectm.pro index 9f3682077..790a97e40 100644 --- a/src/plugins/Visual/projectm/projectm.pro +++ b/src/plugins/Visual/projectm/projectm.pro @@ -3,34 +3,31 @@ include(../../plugins.pri) TARGET =$$PLUGINS_PREFIX/Visual/projectm QMAKE_CLEAN =$$PLUGINS_PREFIX/Visual/libprojectm.so - -#FORMS += settingsdialog.ui -HEADERS += analyzer.h \ +HEADERS += projectmwidget.h \ visualprojectmfactory.h \ - projectmwidget.h \ - qprojectm.h -SOURCES += analyzer.cpp \ + projectmplugin.h +SOURCES += projectmplugin.cpp \ visualprojectmfactory.cpp \ - projectmwidget.cpp + projectmwidget.cpp INCLUDEPATH += ../../../ CONFIG += release \ warn_on \ plugin \ link_pkgconfig -PKGCONFIG += libprojectM-qt libprojectM -INCLUDEPATH += /usr/include/libprojectM +PKGCONFIG += libprojectM TEMPLATE = lib QMAKE_LIBDIR += ../../../../lib +QT += opengl LIBS += -lqmmp -L/usr/lib -I/usr/include -#TRANSLATIONS = translations/projectm_plugin_cs.ts -# translations/projectm_plugin_de.ts -# translations/projectm_plugin_zh_CN.ts -# translations/projectm_plugin_zh_TW.ts -# translations/projectm_plugin_ru.ts -# translations/projectm_plugin_uk_UA.ts -#RESOURCES = translations/translations.qrc +TRANSLATIONS = translations/projectm_plugin_cs.ts \ + translations/projectm_plugin_de.ts \ + translations/projectm_plugin_zh_CN.ts \ + translations/projectm_plugin_zh_TW.ts \ + translations/projectm_plugin_ru.ts \ + translations/projectm_plugin_uk_UA.ts +RESOURCES = translations/translations.qrc isEmpty(LIB_DIR){ LIB_DIR = /lib diff --git a/src/plugins/Visual/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp new file mode 100644 index 000000000..7a0f80676 --- /dev/null +++ b/src/plugins/Visual/projectm/projectmplugin.cpp @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (C) 2009 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "projectmwidget.h" +#include "projectmplugin.h" + +ProjectMPlugin::ProjectMPlugin (QWidget *parent) + : Visual (parent) +{ + setlocale(LC_NUMERIC, "C"); //fixes none-english locales problem + setWindowTitle(tr("projectM")); + m_projectMWidget = new ProjectMWidget(this); + QHBoxLayout *layout = new QHBoxLayout; + layout->addWidget(m_projectMWidget); + layout->setContentsMargins(0,0,0,0); + setLayout(layout); + resize(300,300); //TODO save/load geometry +} + +ProjectMPlugin::~ProjectMPlugin() +{} + +void ProjectMPlugin::clear() +{ + update(); +} + +void ProjectMPlugin::add ( Buffer *b, unsigned long, int, int) +{ //TODO 8 bit support + if (m_projectMWidget->projectMInstance()) + m_projectMWidget->projectMInstance()->pcm()->addPCM16Data((short *)b->data, b->nbytes/4); +} diff --git a/src/plugins/Visual/projectm/projectmplugin.h b/src/plugins/Visual/projectm/projectmplugin.h new file mode 100644 index 000000000..a3a5a7bfb --- /dev/null +++ b/src/plugins/Visual/projectm/projectmplugin.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2009 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PROJECTMPLUGIN_H +#define PROJECTMPLUGIN_H + +#include +#include +#include + +class QTimer; +class Buffer; +class ProjectMWidget; + +class ProjectMPlugin : public Visual +{ + Q_OBJECT + +public: + ProjectMPlugin(QWidget *parent = 0); + virtual ~ProjectMPlugin(); + + void add(Buffer *, unsigned long, int, int); + void clear(); + +private: + QTimer *m_timer; + ProjectMWidget *m_projectMWidget; +}; + + +#endif diff --git a/src/plugins/Visual/projectm/projectmwidget.cpp b/src/plugins/Visual/projectm/projectmwidget.cpp index 7cc7d233b..463065a73 100644 --- a/src/plugins/Visual/projectm/projectmwidget.cpp +++ b/src/plugins/Visual/projectm/projectmwidget.cpp @@ -2,6 +2,11 @@ * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * + * Copyright (C) 2007 by projectM team * + * * + * Carmelo Piccione and carmelo.piccione+projectM@gmail.com * + * carmelo.piccione+projectM@gmail.com * + * * * 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 * @@ -21,9 +26,16 @@ #include #include #include - +#include +#include +#include +#include #include "projectmwidget.h" +#ifndef PROJECTM_CONFIG +#define PROJECTM_CONFIG "/usr/share/projectM/config.inp" +#endif + ProjectMWidget::ProjectMWidget(QWidget *parent) : QGLWidget(parent) { @@ -32,6 +44,8 @@ ProjectMWidget::ProjectMWidget(QWidget *parent) QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()),SLOT(updateGL ())); timer->start(0); + m_menu = new QMenu(this); + connect(SoundCore::instance(), SIGNAL(metaDataChanged()), SLOT(updateTitle())); } @@ -42,7 +56,7 @@ ProjectMWidget::~ProjectMWidget() m_projectM = 0; } -QProjectM *ProjectMWidget::projectM() +projectM *ProjectMWidget::projectMInstance() { return m_projectM; } @@ -70,16 +84,19 @@ void ProjectMWidget::initializeGL() glLineStipple(2, 0xAAAA); if (!m_projectM) { - m_projectM = new QProjectM("/usr/share/projectM/config.inp"); - - - QString file(m_projectM->settings().presetURL.c_str()); - - foreach (QFileInfo info, QDir(file).entryInfoList()) + m_projectM = new projectM(PROJECTM_CONFIG, projectM::FLAG_DISABLE_PLAYLIST_LOAD); + QString presetPath (m_projectM->settings().presetURL.c_str()); + QDir presetDir(presetPath); + presetDir.setFilter(QDir::Files); + QStringList filters; + filters << "*.prjm" << "*.milk"; + QFileInfoList l = presetDir.entryInfoList(filters); + foreach (QFileInfo info, l) { - if (info.fileName().toLower().endsWith(".prjm") || info.fileName().toLower().endsWith(".milk")) - m_projectM->addPresetURL ( info.absoluteFilePath().toStdString(), info.fileName().toStdString(), 1); + m_projectM->addPresetURL (info.absoluteFilePath().toStdString(), info.fileName().toStdString(), 1); } + createActions(); + updateTitle(); } } @@ -97,3 +114,72 @@ void ProjectMWidget::paintGL() if (m_projectM) m_projectM->renderFrame(); } + +void ProjectMWidget::mousePressEvent (QMouseEvent *event) +{ + if (event->button () == Qt::RightButton) + m_menu->exec(event->globalPos()); +} + +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->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->addSeparator(); + m_menu->addAction(tr("&Fullscreen"), this, SLOT(fullScreen()), tr("F")); + m_menu->addSeparator(); + parentWidget()->addActions(m_menu->actions()); +} + +void ProjectMWidget::showHelp() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_F1, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::showPresetName() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_F3, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::showTitle() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_F2, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::nextPreset() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_n, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::previousPreset() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_p, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::randomPreset() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_r, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::lockPreset() +{ + m_projectM->key_handler(PROJECTM_KEYDOWN, PROJECTM_K_l, PROJECTM_KMOD_LSHIFT); +} + +void ProjectMWidget::fullScreen() +{ + parentWidget()->setWindowState (parentWidget()->windowState() ^Qt::WindowFullScreen); +} + +void ProjectMWidget::updateTitle() +{ + std::string artist = SoundCore::instance()->metaData(Qmmp::ARTIST).toLocal8Bit().constData(); + std::string title = SoundCore::instance()->metaData(Qmmp::TITLE).toLocal8Bit().constData(); + m_projectM->projectM_setTitle(artist + " - " + title); +} diff --git a/src/plugins/Visual/projectm/projectmwidget.h b/src/plugins/Visual/projectm/projectmwidget.h index 55809e80f..2cf6c9302 100644 --- a/src/plugins/Visual/projectm/projectmwidget.h +++ b/src/plugins/Visual/projectm/projectmwidget.h @@ -20,11 +20,11 @@ #ifndef PROJECTMWIDGET_H #define PROJECTMWIDGET_H - -#include "qprojectm.h" #include -class QProjectM; + +class QMenu; +class projectM; /** @@ -38,15 +38,30 @@ public: ~ProjectMWidget(); - QProjectM *projectM(); + projectM *projectMInstance(); protected: virtual void initializeGL(); virtual void resizeGL(int width, int height); virtual void paintGL(); + virtual void mousePressEvent (QMouseEvent *event); + +private slots: + void showHelp(); + void showPresetName(); + void showTitle(); + void nextPreset(); + void previousPreset(); + void randomPreset(); + void lockPreset(); + void fullScreen(); + void updateTitle(); private: - QProjectM *m_projectM; + projectM *m_projectM; + QMenu *m_menu; + void createActions(); + }; diff --git a/src/plugins/Visual/projectm/qprojectm.h b/src/plugins/Visual/projectm/qprojectm.h deleted file mode 100644 index b96280fd2..000000000 --- a/src/plugins/Visual/projectm/qprojectm.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// C++ Interface: qprojectm -// -// Description: -// -// -// Author: Carmelo Piccione , (C) 2008 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -#ifndef QPROJECTM_HPP -#define QPROJECTM_HPP -#include -#include - -class QProjectM : public QObject, public projectM -{ - - Q_OBJECT - -public: - QProjectM(const std::string & config_file) : projectM(config_file, projectM::FLAG_DISABLE_PLAYLIST_LOAD) {} - - void presetSwitchedEvent(bool hardCut, unsigned int index) const - { - presetSwitchedSignal(hardCut, index); - } - -signals: - void presetSwitchedSignal(bool hardCut, unsigned int index) const; - -}; -#endif diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_cs.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_cs.ts new file mode 100644 index 000000000..ed017c134 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_cs.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + + + + + F1 + + + + + &Show Song Title + + + + + F2 + + + + + &Show Preset Name + + + + + F3 + + + + + &Next Preset + + + + + N + + + + + &Previous Preset + + + + + P + + + + + &Random Preset + + + + + R + + + + + &Lock Preset + + + + + L + + + + + &Fullscreen + + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + + + + + Qmmp ProjectM Visual Plugin + + + + + This plugins adds projectM visualization + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + Based on llibrojectM-qt library + + + + diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_de.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_de.ts new file mode 100644 index 000000000..ed017c134 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_de.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + + + + + F1 + + + + + &Show Song Title + + + + + F2 + + + + + &Show Preset Name + + + + + F3 + + + + + &Next Preset + + + + + N + + + + + &Previous Preset + + + + + P + + + + + &Random Preset + + + + + R + + + + + &Lock Preset + + + + + L + + + + + &Fullscreen + + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + + + + + Qmmp ProjectM Visual Plugin + + + + + This plugins adds projectM visualization + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + Based on llibrojectM-qt library + + + + diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_ru.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_ru.ts new file mode 100644 index 000000000..faf6e28ec --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_ru.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + &Справка + + + + F1 + + + + + &Show Song Title + &Показать название песни + + + + F2 + + + + + &Show Preset Name + &Показать имя предустановки + + + + F3 + + + + + &Next Preset + &Следующая предустановка + + + + N + + + + + &Previous Preset + &Предыдущая предустановка + + + + P + + + + + &Random Preset + &Случайная предустановка + + + + R + + + + + &Lock Preset + &Заблокировать предустановку + + + + L + + + + + &Fullscreen + &Полноэкранный режим + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + О модуле ProjectM для Qmmp + + + + Qmmp ProjectM Visual Plugin + Модуль projectM для Qmmp + + + + This plugins adds projectM visualization + Этот модуль добавляет визуализацию projectM + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + Разработчик: Илья Котов <forkotov02@hotmail.ru> + + + + Based on llibrojectM-qt library + Основан на базе библиотеки libprojectM-qt + + + diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_uk_UA.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_uk_UA.ts new file mode 100644 index 000000000..ed017c134 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_uk_UA.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + + + + + F1 + + + + + &Show Song Title + + + + + F2 + + + + + &Show Preset Name + + + + + F3 + + + + + &Next Preset + + + + + N + + + + + &Previous Preset + + + + + P + + + + + &Random Preset + + + + + R + + + + + &Lock Preset + + + + + L + + + + + &Fullscreen + + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + + + + + Qmmp ProjectM Visual Plugin + + + + + This plugins adds projectM visualization + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + Based on llibrojectM-qt library + + + + diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_zh_CN.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_zh_CN.ts new file mode 100644 index 000000000..ed017c134 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_zh_CN.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + + + + + F1 + + + + + &Show Song Title + + + + + F2 + + + + + &Show Preset Name + + + + + F3 + + + + + &Next Preset + + + + + N + + + + + &Previous Preset + + + + + P + + + + + &Random Preset + + + + + R + + + + + &Lock Preset + + + + + L + + + + + &Fullscreen + + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + + + + + Qmmp ProjectM Visual Plugin + + + + + This plugins adds projectM visualization + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + Based on llibrojectM-qt library + + + + diff --git a/src/plugins/Visual/projectm/translations/projectm_plugin_zh_TW.ts b/src/plugins/Visual/projectm/translations/projectm_plugin_zh_TW.ts new file mode 100644 index 000000000..ed017c134 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/projectm_plugin_zh_TW.ts @@ -0,0 +1,128 @@ + + + + + ProjectMPlugin + + + projectM + + + + + ProjectMWidget + + + &Help + + + + + F1 + + + + + &Show Song Title + + + + + F2 + + + + + &Show Preset Name + + + + + F3 + + + + + &Next Preset + + + + + N + + + + + &Previous Preset + + + + + P + + + + + &Random Preset + + + + + R + + + + + &Lock Preset + + + + + L + + + + + &Fullscreen + + + + + F + + + + + VisualProjectMFactory + + + ProjectM + + + + + About ProjectM Visual Plugin + + + + + Qmmp ProjectM Visual Plugin + + + + + This plugins adds projectM visualization + + + + + Writen by: Ilya Kotov <forkotov02@hotmail.ru> + + + + + Based on llibrojectM-qt library + + + + diff --git a/src/plugins/Visual/projectm/translations/translations.qrc b/src/plugins/Visual/projectm/translations/translations.qrc new file mode 100644 index 000000000..585c94da9 --- /dev/null +++ b/src/plugins/Visual/projectm/translations/translations.qrc @@ -0,0 +1,11 @@ + + + + projectm_plugin_cs.qm + projectm_plugin_de.qm + projectm_plugin_zh_CN.qm + projectm_plugin_zh_TW.qm + projectm_plugin_uk_UA.qm + projectm_plugin_ru.qm + + diff --git a/src/plugins/Visual/projectm/visualprojectmfactory.cpp b/src/plugins/Visual/projectm/visualprojectmfactory.cpp index f3fb377db..5e1f0b961 100644 --- a/src/plugins/Visual/projectm/visualprojectmfactory.cpp +++ b/src/plugins/Visual/projectm/visualprojectmfactory.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -19,15 +19,13 @@ ***************************************************************************/ #include - -//#include "settingsdialog.h" #include "visualprojectmfactory.h" -#include "analyzer.h" +#include "projectmplugin.h" const VisualProperties VisualProjectMFactory::properties() const { VisualProperties properties; - properties.name = tr("ProjectM Plugin"); + properties.name = tr("ProjectM"); properties.shortName = "projectm"; properties.hasSettings = FALSE; properties.hasAbout = TRUE; @@ -36,26 +34,29 @@ const VisualProperties VisualProjectMFactory::properties() const Visual *VisualProjectMFactory::create(QWidget *parent) { - return new Analyzer(parent); + return new ProjectMPlugin(parent); }; QDialog *VisualProjectMFactory::createConfigDialog(QWidget *parent) { + Q_UNUSED(parent); return 0; }; void VisualProjectMFactory::showAbout(QWidget *parent) { - QMessageBox::about (parent, tr("About Analyzer Visual Plugin"), - tr("Qmmp Analyzer Visual Plugin")+"\n"+ - tr("Writen by: Ilya Kotov ")); + QMessageBox::about (parent, tr("About ProjectM Visual Plugin"), + tr("Qmmp ProjectM Visual Plugin")+"\n"+ + tr("This plugins adds projectM visualization")+"\n"+ + tr("Writen by: Ilya Kotov ")+"\n"+ + tr("Based on llibrojectM-qt library")); }; QTranslator *VisualProjectMFactory::createTranslator(QObject *parent) { QTranslator *translator = new QTranslator(parent); QString locale = QLocale::system().name(); - translator->load(QString(":/analyzer_plugin_") + locale); + translator->load(QString(":/projectm_plugin_") + locale); return translator; }; diff --git a/src/plugins/Visual/projectm/visualprojectmfactory.h b/src/plugins/Visual/projectm/visualprojectmfactory.h index be7a9ba1f..f1a21b6cb 100644 --- a/src/plugins/Visual/projectm/visualprojectmfactory.h +++ b/src/plugins/Visual/projectm/visualprojectmfactory.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * -- cgit v1.2.3-13-gbd6f