diff --git a/src/projectM-engine/PresetLoader.hpp b/src/projectM-engine/PresetLoader.hpp index 440ccca35..ffa4fb2c0 100644 --- a/src/projectM-engine/PresetLoader.hpp +++ b/src/projectM-engine/PresetLoader.hpp @@ -43,6 +43,9 @@ class PresetLoader { /// \param url an url referencing the preset /// \returns The unique index assigned to the preset in the collection. Used with loadPreset unsigned int addPresetURL ( const std::string & url, const std::string & presetName); + + /// Clears all presets from the collection + void clear() { m_entries.clear(); m_presetNames.clear(); } void removePreset(unsigned int index); diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 37156849b..5aa75c893 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -884,7 +884,12 @@ std::string projectM::getPresetName ( unsigned int index ) const return m_presetLoader->getPresetName(index); } -unsigned int projectM::getPlayListSize() const +void projectM::clearPlaylist ( ) +{ + m_presetLoader->clear(); +} + +unsigned int projectM::getPlaylistSize() const { return m_presetLoader->getNumPresets(); } diff --git a/src/projectM-engine/projectM.hpp b/src/projectM-engine/projectM.hpp index a63351ee0..6bd303625 100755 --- a/src/projectM-engine/projectM.hpp +++ b/src/projectM-engine/projectM.hpp @@ -135,6 +135,10 @@ public: /// If the preset is locked the queued item will be not switched to until the lock is released void queuePreset(unsigned int index); + + /// Removes entire playlist, The currently loaded preset will end up sticking until new presets are added + void clearPlaylist(); + /// Turn on or off a lock that prevents projectM from switching to another preset void setPresetLock(bool isLocked); @@ -151,7 +155,7 @@ public: std::string getPresetName ( unsigned int index ) const; /// Returns the size of the play list - unsigned int getPlayListSize() const; + unsigned int getPlaylistSize() const; /// Occurs when active preset has switched. Switched to index is returned virtual void presetSwitchedEvent(bool isHardCut, unsigned int index) const {}; diff --git a/src/qprojectM/src/QProjectM_MainWindow.cpp b/src/qprojectM/src/QProjectM_MainWindow.cpp index d26f4eb50..ce7ce5f05 100644 --- a/src/qprojectM/src/QProjectM_MainWindow.cpp +++ b/src/qprojectM/src/QProjectM_MainWindow.cpp @@ -41,6 +41,9 @@ QProjectM_MainWindow::QProjectM_MainWindow(const std::string & config_file) connect(ui.lockPresetCheckBox, SIGNAL(stateChanged(int)), m_QProjectMWidget, SLOT(setPresetLock(int))); + connect(ui.clearPresetList_PushButton, SIGNAL(pressed()), + this, SLOT(clearPlaylist())); + connect(m_QProjectMWidget, SIGNAL(projectM_Initialized()), this, SLOT(postProjectM_Initialize())); @@ -65,6 +68,12 @@ QProjectM_MainWindow::QProjectM_MainWindow(const std::string & config_file) } +void QProjectM_MainWindow::clearPlaylist() { + + getQProjectM()->clearPlaylist(); + playlistModel.clear(); +} + QProjectM * QProjectM_MainWindow::getQProjectM() { return m_QProjectMWidget->getQProjectM(); } @@ -170,7 +179,8 @@ void QProjectM_MainWindow::open() loadFile(*pos); } } - + + playlistModel.setHeaderData(0, Qt::Horizontal, tr("Preset"));//, Qt::DisplayRole); } @@ -178,7 +188,7 @@ void QProjectM_MainWindow::refreshPlaylist() { playlistModel.clear(); - for (unsigned int i = 0; i < getQProjectM()->getPlayListSize(); i++) { + for (unsigned int i = 0; i < getQProjectM()->getPlaylistSize(); i++) { const std::string & presetURL = getQProjectM()->getPresetURL(i); const std::string & presetName = getQProjectM()->getPresetName(i); diff --git a/src/qprojectM/src/QProjectM_MainWindow.hpp b/src/qprojectM/src/QProjectM_MainWindow.hpp index c0e071d33..9701ae536 100644 --- a/src/qprojectM/src/QProjectM_MainWindow.hpp +++ b/src/qprojectM/src/QProjectM_MainWindow.hpp @@ -68,6 +68,7 @@ class QProjectMWidget : public QGLWidget QProjectM * getQProjectM() { return m_projectM; } public slots: + void setPresetLock(int state) { m_projectM->setPresetLock((bool)state); } @@ -77,8 +78,11 @@ class QProjectMWidget : public QGLWidget private: std::string config_file; QProjectM * m_projectM; + protected: + + void keyReleaseEvent ( QKeyEvent * e ) { projectMKeycode pkey; @@ -212,6 +216,7 @@ protected: void closeEvent(QCloseEvent *event); private slots: + void clearPlaylist(); void open(); void about(); void postProjectM_Initialize(); diff --git a/src/qprojectM/src/QProjectM_MainWindow.ui b/src/qprojectM/src/QProjectM_MainWindow.ui index fd22e51d4..6ad68b4e4 100644 --- a/src/qprojectM/src/QProjectM_MainWindow.ui +++ b/src/qprojectM/src/QProjectM_MainWindow.ui @@ -164,7 +164,7 @@ p, li { white-space: pre-wrap; } <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears <span style=" font-style:italic;">all</span> items if <span style=" font-style:italic;">none are selected</span> and the currently selected items otherwise.</p></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears<span style=" font-style:italic;"> all </span>presets<span style=" font-style:italic;"> </span>in the playlist.</p></body></html>