diff --git a/CMakeLists.txt b/CMakeLists.txt index 9693d6962..3e146a573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,8 @@ macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/e macro_optional_find_package(QTweetLib) macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n") +macro_optional_find_package(VSXu) +macro_log_feature(VSXU_FOUND "VSXu" "Vovoid VSXu Ultra" "https://www.vsxu.com" FALSE "" "VSXu is needed for some really cool music visualization.\n") IF( NOT QuaZip_FOUND ) add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip ) diff --git a/CMakeModules/FindVSXu.cmake b/CMakeModules/FindVSXu.cmake new file mode 100644 index 000000000..f8fe8bf2e --- /dev/null +++ b/CMakeModules/FindVSXu.cmake @@ -0,0 +1,48 @@ +# Find VSXU - JSON handling library for Qt +# +# This module defines +# VSXU_FOUND - whether the qsjon library was found +# VSXU_LIBRARIES - the vsxu library +# VSXU_INCLUDE_DIRS - the include path of the vsxu library +# + +if (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES) + + # Already in cache + set (VSXU_FOUND TRUE) + +else (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES) + + if (NOT WIN32) + # use pkg-config to get the values of VSXU_INCLUDE_DIRS + # and VSXU_LIBRARY_DIRS to add as hints to the find commands. + include (FindPkgConfig) + pkg_check_modules (VSXU REQUIRED libvsxu) + endif (NOT WIN32) + + find_library (VSXU_LIBRARIES + NAMES + libvsxu_engine + PATHS + ${VSXU_LIBRARY_DIRS} + ${LIB_INSTALL_DIR} + ${KDE4_LIB_DIR} + ) + + find_path (VSXU_INCLUDE_DIRS + NAMES + vsxu_platform.h + PATHS + ${VSXU_INCLUDE_DIRS} + ${INCLUDE_INSTALL_DIR} + ${KDE4_INCLUDE_DIR} + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(VSXu DEFAULT_MSG VSXU_LIBRARIES VSXU_INCLUDE_DIRS) + + if ( UNIX AND NOT APPLE ) + set ( VSXU_LIBRARIES "${VSXU_LIBRARIES} ${VSXU_LDFLAGS}" CACHE INTERNAL "") + endif () + +endif (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES) \ No newline at end of file diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 70e933e6a..ac273441c 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -6,6 +6,10 @@ SET( QT_USE_QTNETWORK TRUE ) SET( QT_USE_QTXML TRUE ) SET( QT_USE_QTUITOOLS TRUE ) +IF(VSXU_FOUND) + SET( QT_USE_QTOPENGL TRUE ) +ENDIF(VSXU_FOUND) + include( ${QT_USE_FILE} ) add_definitions( ${QT_DEFINITIONS} ) @@ -146,6 +150,9 @@ set( libGuiSources IF(QCA2_FOUND) set( libGuiSources ${libGuiSources} utils/groovesharkparser.cpp ) ENDIF(QCA2_FOUND) +IF(VSXU_FOUND) + set(libGuiSources ${libGuiSources} nowplaying/VSXuWidget.cpp nowplaying/nowplayingpage.cpp) +ENDIF(VSXU_FOUND) set( libGuiHeaders actioncollection.h @@ -283,6 +290,9 @@ set( libGuiHeaders IF(QCA2_FOUND) set( libGuiHeaders ${libGuiHeaders} utils/groovesharkparser.h ) ENDIF(QCA2_FOUND) +IF(VSXU_FOUND) + set( libGuiHeaders ${libGuiHeaders} nowplaying/VSXuWidget.h nowplaying/nowplayingpage.h) +ENDIF(VSXU_FOUND) set( libSources tomahawksettings.cpp @@ -594,6 +604,10 @@ IF(QCA2_FOUND) INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} ) ENDIF(QCA2_FOUND) +IF(VSXU_FOUND) + INCLUDE_DIRECTORIES(${VSXU_INCLUDE_DIRS}) +ENDIF(VSXU_FOUND) + IF(LIBATTICA_FOUND) SET( libGuiSources ${libGuiSources} AtticaManager.cpp ) SET( libGuiHeaders ${libGuiHeaders} AtticaManager.h ) @@ -686,6 +700,10 @@ IF(QCA2_FOUND) SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} ) ENDIF(QCA2_FOUND) +IF(VSXU_FOUND) + SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${VSXU_LIBRARIES}) +ENDIF(VSXU_FOUND) + IF(LIBATTICA_FOUND) SET( LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} ${QuaZip_LIBRARIES} ) ENDIF(LIBATTICA_FOUND) @@ -700,9 +718,7 @@ TARGET_LINK_LIBRARIES( tomahawklib ${TAGLIB_LIBRARIES} ${CLUCENE_LIBRARIES} ${LIBECHONEST_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${QT_QTUITOOLS_LIBRARY} - ${QT_QTGUI_LIBRARY} + ${QT_LIBRARIES} #This should do as long as we use ${SET (QT_USE_QTXYZ TRUE)} ${OS_SPECIFIC_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LINK_LIBRARIES} diff --git a/src/libtomahawk/nowplaying/VSXuWidget.cpp b/src/libtomahawk/nowplaying/VSXuWidget.cpp new file mode 100644 index 000000000..2a6260d1d --- /dev/null +++ b/src/libtomahawk/nowplaying/VSXuWidget.cpp @@ -0,0 +1,80 @@ +#include + +#include "VSXuWidget.h" + +VSXuWidget::VSXuWidget(QWidget *parent): + QGLWidget(parent), + m_isActive(true) +{ + setWindowTitle("Vovoid VSXu"); + m_timer = new QTimer(this); + connect (m_timer , SIGNAL(timeout()), this, SLOT(update())); +} + +void VSXuWidget::injectSound(float soundData[]) +{ + /* uncomment for manual sound injection + for (unsigned long i = 0; i < 512; i++) + { + sound_wave_test[i] = (float)(rand()%65535-32768)*(1.0f/32768.0f); + } + for (unsigned long i = 0; i < 512; i++) + { + sound_freq_test[i] = (float)(rand()%65535)*(1.0f/65535.0f); + } + manager->set_sound_freq(&sound_freq_test[0]); + manager->set_sound_wave(&sound_wave_test[0]); + */ + + updateGL(); +} + +void VSXuWidget::initializeGL() +{ + m_manager = manager_factory(); + // init manager with the shared path and sound input type. + // manual sound injection: manager->init( path.c_str() , "media_player"); + m_manager->init(0 , "pulseaudio"); + + std::vector files = m_manager->get_visual_filenames(); + + qDebug()<format().hasOpenGL()) + qDebug()<<"You have a Valid OpenGL Context"; + if (context()->format().sampleBuffers()) + qDebug()<<"You have Sample Buffers"; + m_timer->start(20); +} + + +void VSXuWidget::paintGL() +{ + if (m_isActive){ + glViewport(0, 0, m_width, m_height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(0, m_width, 0, m_height); // set origin to bottom left corner + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (m_manager) + m_manager->render(); + } +} + + +VSXuWidget::~VSXuWidget() +{} \ No newline at end of file diff --git a/src/libtomahawk/nowplaying/VSXuWidget.h b/src/libtomahawk/nowplaying/VSXuWidget.h new file mode 100644 index 000000000..d93d921d4 --- /dev/null +++ b/src/libtomahawk/nowplaying/VSXuWidget.h @@ -0,0 +1,34 @@ +#ifndef VSXuWidget_H +#define VSXuWidget_H + +#include +#include +#include +#include + +class VSXuWidget : public QGLWidget +{ + Q_OBJECT +private: + vsx_manager_abs* m_manager; + QTimer *m_timer; // A Timer to frequently update the display + + QStringList m_visuals; + int m_width,m_height; + bool m_isActive; // To Save the CPU when we aren't using VSXu. + +protected: + void initializeGL(); + void resizeGL(int w, int h){ + m_width = w; + m_height = h; + } + void paintGL(); + +public: + VSXuWidget(QWidget *parent = NULL); + ~VSXuWidget(); + void injectSound(float soundData[]); +}; + +#endif // VSXuWidget_H diff --git a/src/libtomahawk/nowplaying/nowplayingpage.cpp b/src/libtomahawk/nowplaying/nowplayingpage.cpp new file mode 100644 index 000000000..b4c5ba339 --- /dev/null +++ b/src/libtomahawk/nowplaying/nowplayingpage.cpp @@ -0,0 +1,30 @@ +/* + Creates a Now Playing page as a place holder for Music Visuals. + Copyright (C) 2012 Dinesh + + 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 3 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, see . +*/ + +#include +#include +#include "nowplayingpage.h" + +NowPlayingPage::NowPlayingPage(QWidget* parent): + QWidget(parent) +{ + QVBoxLayout *layout = new QVBoxLayout; + m_VSXuWidget = new VSXuWidget; + layout->addWidget(m_VSXuWidget); + setLayout(layout); +} diff --git a/src/libtomahawk/nowplaying/nowplayingpage.h b/src/libtomahawk/nowplaying/nowplayingpage.h new file mode 100644 index 000000000..38d520a04 --- /dev/null +++ b/src/libtomahawk/nowplaying/nowplayingpage.h @@ -0,0 +1,44 @@ +/* + Creates a Now Playing page as a place holder for Music Visuals. + Copyright (C) 2012 Dinesh + + 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 3 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, see . +*/ + + +#ifndef NOWPLAYINGPAGE_H +#define NOWPLAYINGPAGE_H + +#include +#include +#include "VSXuWidget.h" + +class NowPlayingPage : public QWidget,public Tomahawk::ViewPage +{ + Q_OBJECT + +public: + NowPlayingPage( QWidget *parent = 0 ); + virtual bool jumpToCurrentTrack() { return false; } + virtual QString description() const { return QString("VSXu Music Visualizer"); } + virtual QString title() const{ return QString("Vovoid VSXu Ultra"); } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); } + virtual QWidget* widget(){ return this; } + +private: + VSXuWidget *m_VSXuWidget; + +}; + +#endif // NOWPLAYINGPAGE_H diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index 674043939..aab15cdee 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -52,6 +52,7 @@ #include "widgets/animatedsplitter.h" #include "utils/logger.h" +#include "nowplaying/nowplayingpage.h" #define FILTER_TIMEOUT 280 @@ -432,6 +433,14 @@ ViewManager::showTopLovedPage() return show( m_topLovedWidget ); } +Tomahawk::ViewPage* +ViewManager::showNowPlayingPage() +{ + if ( !m_nowPlayingWidget ) + m_nowPlayingWidget = new NowPlayingPage(m_widget); + + return show( m_nowPlayingWidget ); +} void ViewManager::setTableMode() diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index e61a201d4..1856aca37 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -33,6 +33,7 @@ #include "dllmacro.h" +class NowPlayingPage; class AnimatedSplitter; class AlbumModel; class AlbumView; @@ -91,6 +92,7 @@ public: Tomahawk::ViewPage* welcomeWidget() const { return m_welcomeWidget; } Tomahawk::ViewPage* whatsHotWidget() const { return m_whatsHotWidget; } Tomahawk::ViewPage* topLovedWidget() const { return m_topLovedWidget; } + Tomahawk::ViewPage* nowPlayingWidget() const { return m_nowPlayingWidget; } ArtistView* superCollectionView() const { return m_superCollectionView; } /// Get the view page for the given item. Not pretty... @@ -135,6 +137,7 @@ public slots: Tomahawk::ViewPage* showWelcomePage(); Tomahawk::ViewPage* showWhatsHotPage(); Tomahawk::ViewPage* showTopLovedPage(); + Tomahawk::ViewPage* showNowPlayingPage(); void showCurrentTrack(); // Returns the shown viewpage @@ -197,6 +200,7 @@ private: WelcomeWidget* m_welcomeWidget; WhatsHotWidget* m_whatsHotWidget; Tomahawk::ViewPage* m_topLovedWidget; + Tomahawk::ViewPage* m_nowPlayingWidget; QList< Tomahawk::collection_ptr > m_superCollections; diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp index dfe877d96..a803e81c6 100644 --- a/src/sourcetree/sourcesmodel.cpp +++ b/src/sourcetree/sourcesmodel.cpp @@ -285,6 +285,11 @@ SourcesModel::appendGroups() boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ), boost::bind( &ViewManager::whatsHotWidget, ViewManager::instance() ) ); hot->setSortValue( -300 ); + + GenericPageItem* nowPlaying = new GenericPageItem( this, browse, tr( "Now Playing" ), QIcon( RESPATH "images/charts.png" ), + boost::bind( &ViewManager::showNowPlayingPage, ViewManager::instance() ), + boost::bind( &ViewManager::nowPlayingWidget, ViewManager::instance() ) ); + hot->setSortValue( -400 ); m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 15 );