diff --git a/src/projectM-engine/PresetLoader.cpp b/src/projectM-engine/PresetLoader.cpp index f4face104..cb4eea053 100644 --- a/src/projectM-engine/PresetLoader.cpp +++ b/src/projectM-engine/PresetLoader.cpp @@ -29,10 +29,11 @@ extern "C" const std::string PresetLoader::PROJECTM_FILE_EXTENSION(".prjm"); const std::string PresetLoader::MILKDROP_FILE_EXTENSION(".milk"); -PresetLoader::PresetLoader(std::string dirname) :m_dirname(dirname), m_dir(0), m_ratingsSum(0) +PresetLoader::PresetLoader(std::string dirname = std::string()) :m_dirname(dirname), m_dir(0), m_ratingsSum(0) { // Do one scan - rescan(); + if (m_dirname != std::string()) + rescan(); } PresetLoader::~PresetLoader() diff --git a/src/projectM-engine/PresetLoader.hpp b/src/projectM-engine/PresetLoader.hpp index fbe60533c..356535ecf 100644 --- a/src/projectM-engine/PresetLoader.hpp +++ b/src/projectM-engine/PresetLoader.hpp @@ -30,7 +30,7 @@ class PresetLoader { /** Initializes the preset loader with the target directory specified */ PresetLoader(std::string dirname); - + /** Destructor will remove all alllocated presets */ ~PresetLoader(); diff --git a/src/projectM-engine/RandomNumberGenerators.hpp b/src/projectM-engine/RandomNumberGenerators.hpp index ece418f0a..52a50aa86 100644 --- a/src/projectM-engine/RandomNumberGenerators.hpp +++ b/src/projectM-engine/RandomNumberGenerators.hpp @@ -97,8 +97,6 @@ inline std::size_t weightedRandomNormalized(std::vector weights) { inline std::size_t weightedRandom(const std::vector & weights, int weightTotalHint = 0) { - std::cerr << "weight size:" << weights.size() << std::endl; - if (weightTotalHint <= 0) for (std::size_t i = 0; i < weights.size();i++) weightTotalHint += weights[i]; diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index bd93de679..b845b2a3f 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -99,8 +99,9 @@ DLLEXPORT void projectM::projectM_resetTextures() renderer->ResetTextures(); } -DLLEXPORT projectM::projectM ( std::string config_file ) : - beatDetect ( 0 ), renderer ( 0 ), m_presetQueuePos(0), _pcm(0), m_presetPos(0), m_shuffleEnabled(true) + +DLLEXPORT projectM::projectM ( std::string config_file, int flags) : + beatDetect ( 0 ), renderer ( 0 ), m_presetQueuePos(0), _pcm(0), m_presetPos(0), m_flags(flags) { readConfig ( config_file ); projectM_reset(); @@ -677,7 +678,9 @@ int projectM::initPresetTools() /* Set the seed to the current time in seconds */ srand ( time ( NULL ) ); - if ( ( m_presetLoader = new PresetLoader ( settings().presetURL ) ) == 0 ) + std::string url = (m_flags & FLAG_DISABLE_PLAYLIST_LOAD) ? std::string() : settings().presetURL; + + if ( ( m_presetLoader = new PresetLoader ( url) ) == 0 ) { m_presetLoader = 0; std::cerr << "[projectM] error allocating preset loader" << std::endl; @@ -709,12 +712,13 @@ int projectM::initPresetTools() //std::cerr << "[projectM] Allocating idle preset..." << std::endl; m_activePreset = IdlePreset::allocate ( presetInputs, presetOutputs ); - // Case where no valid presets exist in directory - if ( m_presetChooser->empty() ) - { - std::cerr << "[projectM] warning: no valid files found in preset directory \"" - << m_presetLoader->directoryName() << "\"" << std::endl; - } + // Case where no valid presets exist in directory. Could also mean + // playlist initialization was deferred + //if ( m_presetChooser->empty() ) + //{ + //std::cerr << "[projectM] warning: no valid files found in preset directory \"" + //<< m_presetLoader->directoryName() << "\"" << std::endl; + //} //std::cerr << "[projectM] Idle preset allocated." << std::endl; @@ -819,12 +823,12 @@ void projectM::selectPreset ( unsigned int index ) timeKeeper->StartPreset(); } -void projectM::switchPreset(std::auto_ptr & targetPreset, PresetInputs & inputs, PresetOutputs & outputs) { +void projectM::switchPreset(std::auto_ptr & targetPreset, PresetInputs & inputs, PresetOutputs & outputs) { - // If queue not specified, roll with usual random behavior +// // If queue not specified, roll with usual random behavior if (m_presetQueuePos == 0) { - if (m_shuffleEnabled) + if (_settings.shuffleEnabled) *m_presetPos = m_presetChooser->weightedRandom(); else m_presetChooser->nextPreset(*m_presetPos); diff --git a/src/projectM-engine/projectM.hpp b/src/projectM-engine/projectM.hpp index 04e1c8c28..64a46e6a9 100755 --- a/src/projectM-engine/projectM.hpp +++ b/src/projectM-engine/projectM.hpp @@ -115,10 +115,11 @@ class RandomizerFunctor { class projectM { public: - + static const int FLAG_DISABLE_PLAYLIST_LOAD = 1 << 0; + static const int FLAG_NONE = 1 << 1; + + DLLEXPORT projectM(std::string config_file, int flags = FLAG_NONE); - - DLLEXPORT projectM(std::string config_file); DLLEXPORT projectM(int gx, int gy, int fps, int texsize, int width, int height,std::string preset_url,std::string title_fonturl, std::string title_menuurl); DLLEXPORT void projectM_resetGL( int width, int height ); @@ -147,6 +148,7 @@ public: float beatSensitivity; bool aspectCorrection; float easterEgg; + bool shuffleEnabled; }; @@ -217,7 +219,7 @@ public: inline void setShuffleEnabled(bool value) { - m_shuffleEnabled = value; + _settings.shuffleEnabled = value; /// idea@ call a virtualfunction shuffleChanged() } @@ -225,7 +227,7 @@ public: inline bool isShuffleEnabled() const { - return m_shuffleEnabled; + return _settings.shuffleEnabled; } /// Occurs when active preset has switched. Switched to index is returned @@ -300,7 +302,8 @@ private: TimeKeeper *timeKeeper; PCM * _pcm; - bool m_shuffleEnabled; + int m_flags; + }; diff --git a/src/qprojectM-pulseaudio/QPulseAudioThread.cpp b/src/qprojectM-pulseaudio/QPulseAudioThread.cpp index c87a580dd..aab399ec2 100644 --- a/src/qprojectM-pulseaudio/QPulseAudioThread.cpp +++ b/src/qprojectM-pulseaudio/QPulseAudioThread.cpp @@ -252,15 +252,18 @@ case PA_STREAM_TERMINATED:// The stream has been terminated cleanly. } -void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, void *userdata) { +void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, void * data) { static bool pausedFlag = true; if (pausedFlag) qDebug() << "pause"; - else + else { qDebug() << "play"; - + s_audioMutex.unlock(); + qDebug() << "UNLOCK: success callback"; + } + pausedFlag = !pausedFlag; @@ -270,14 +273,13 @@ void QPulseAudioThread::pa_stream_success_callback(pa_stream *s, int success, vo QMutex * QPulseAudioThread::mutex() { - return &s_audioMutex; +return &s_audioMutex; } void QPulseAudioThread::cork() { int b = 0; - //s_audioMutex.lock(); pa_operation* op = pa_stream_cork(stream, b, pa_stream_success_callback, this); @@ -453,6 +455,7 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int { //int * int_buf = (int *) buffer; + //qDebug() << "LOCK: add pcm"; s_audioMutex.lock(); QProjectM ** prjmPtr = static_cast ( userdata ); QProjectM * prjm = *prjmPtr; @@ -464,7 +467,7 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int prjm->pcm()->addPCMfloat ( buffer+buffer_index, buffer_length / ( sizeof ( float ) ) ); s_audioMutex.unlock(); - + //qDebug() << "UNLOCK: add pcm"; assert ( buffer_length ); pa_xfree ( buffer ); diff --git a/src/qprojectM-pulseaudio/QPulseAudioThread.hpp b/src/qprojectM-pulseaudio/QPulseAudioThread.hpp index 52f26871b..d09b9e77c 100644 --- a/src/qprojectM-pulseaudio/QPulseAudioThread.hpp +++ b/src/qprojectM-pulseaudio/QPulseAudioThread.hpp @@ -47,7 +47,6 @@ class QPulseAudioThread : public QThread m_projectM = projectM; *s_projectMPtr = m_projectM; qDebug() << "CORKING"; - s_audioMutex.unlock(); cork(); } diff --git a/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp b/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp index f36ae1b3c..903f9019e 100644 --- a/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp +++ b/src/qprojectM-pulseaudio/qprojectM-pulseaudio.cpp @@ -111,7 +111,7 @@ int main ( int argc, char*argv[] ) QApplication::connect (mainWindow->qprojectMWidget(), SIGNAL(projectM_Initialized(QProjectM *)), pulseThread, SLOT(projectM_New(QProjectM*))); QApplication::connect - (mainWindow->qprojectMWidget(), SIGNAL(projectM_BeforeDestroy()), pulseThread, SLOT(cork())); + (mainWindow->qprojectMWidget(), SIGNAL(projectM_BeforeDestroy()), pulseThread, SLOT(cork()), Qt::DirectConnection); QPulseAudioDeviceChooser devChooser(pulseThread, mainWindow); QApplication::connect(&pulseAction, SIGNAL(triggered()), &devChooser, SLOT(open())); diff --git a/src/qprojectM/QPlaylistFileDialog.hpp b/src/qprojectM/QPlaylistFileDialog.hpp index e0774ac67..1d8ae0275 100644 --- a/src/qprojectM/QPlaylistFileDialog.hpp +++ b/src/qprojectM/QPlaylistFileDialog.hpp @@ -23,22 +23,94 @@ #define QPLAYLIST_FILEDIALOG_H #include +#include +#include class QPlaylistFileDialog : public QFileDialog { Q_OBJECT // must include this if you use Qt signals/slots - public: inline QPlaylistFileDialog(QWidget * parent = 0): - QFileDialog(parent, "Open a playlist file or directory", QString(), "Preset Playlists (*.ppl)" ) { + QFileDialog(parent, "Open a playlist file or directory", QString()) { - this->setFileMode(QFileDialog::ExistingFiles); + updateFileMode(selectedFiles()); + + //connect(this, SIGNAL(filesSelected(const QStringList&)), + // this, SLOT(updateFileMode(const QStringList&))); + + connect(this, SIGNAL(currentChanged(const QString&)), + this, SLOT(updateFileMode(const QString&))); } - - ~QPlaylistFileDialog() { } - private: + void setAllowDirectorySelect(bool isAllowed) { + m_directorySelectAllowed = isAllowed; + updateFileMode(selectedFiles()); + + } + + + void setAllowFileSelect(bool isAllowed) { + m_fileSelectAllowed = isAllowed; + updateFileMode(selectedFiles()); + } + + + bool isFileSelectAllowed() const { + return m_fileSelectAllowed; + } + + + bool isDirectorySelectAllowed() const { + return m_directorySelectAllowed; + } + + ~QPlaylistFileDialog() { } + + private: + bool m_directorySelectAllowed; + bool m_fileSelectAllowed; + + private slots: + + void updateFileMode(const QString & fileName) { + + QString filter; + + if (isDirectorySelectAllowed()) { + + filter += "Directories"; + } + + if (isFileSelectAllowed()) { + if (filter != QString()) + filter += " and "; + + filter += "Preset Playlists (*.ppl)"; + //this->setFileMode(QFileDialog::ExistingFiles); + } + + + if (QFileInfo(fileName).isDir()) + if (isDirectorySelectAllowed()) + this->setFileMode(QFileDialog::Directory); + else + ; + else + if (isFileSelectAllowed()) + this->setFileMode(QFileDialog::ExistingFiles); + else + ; + + this->setFilter(filter); + } + + void updateFileMode(const QStringList & selectedFiles) { + qDebug() << "in update"; + if (selectedFiles.empty()) + return; + updateFileMode(selectedFiles[0]); + } }; diff --git a/src/qprojectM/QProjectMConfigDialog.cpp b/src/qprojectM/QProjectMConfigDialog.cpp index daaa6f961..ae13b3146 100644 --- a/src/qprojectM/QProjectMConfigDialog.cpp +++ b/src/qprojectM/QProjectMConfigDialog.cpp @@ -9,7 +9,8 @@ QProjectMConfigDialog::QProjectMConfigDialog(const std::string & configFile, QPr _ui.setupUi(this); connect(_ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonBoxHandler(QAbstractButton*))); connect(this, SIGNAL(projectM_Reset()), _qprojectMWidget, SLOT(resetProjectM())); - connect (_ui.startupPlaylistToolButton, SIGNAL(clicked()), this, SLOT(openPlaylistFileDialog())); + connect (_ui.startupPlaylistFileToolButton, SIGNAL(clicked()), this, SLOT(openPlaylistFileDialog())); + connect (_ui.startupPlaylistDirectoryToolButton, SIGNAL(clicked()), this, SLOT(openPlaylistDirectoryDialog())); connect (_ui.titleFontPathToolButton, SIGNAL(clicked()), this, SLOT(openTitleFontFileDialog())); connect (_ui.menuFontPathToolButton, SIGNAL(clicked()), this, SLOT(openMenuFontFileDialog())); loadConfig(); @@ -23,7 +24,6 @@ void QProjectMConfigDialog::buttonBoxHandler(QAbstractButton * button) { break; case QDialogButtonBox::Apply: saveConfig(); - qDebug() << "emitting!"; emit(projectM_Reset()); break; case QDialogButtonBox::Reset: @@ -38,15 +38,32 @@ void QProjectMConfigDialog::openPlaylistFileDialog() { QPlaylistFileDialog dialog(this); + dialog.setAllowFileSelect(true); + dialog.setAllowDirectorySelect(false); + if (dialog.exec()) { assert(!dialog.selectedFiles().empty()); - _ui.startupPlaylistLineEdit->setText(dialog.selectedFiles()[0]); + _ui.startupPlaylistFileLineEdit->setText(dialog.selectedFiles()[0]); } } +void QProjectMConfigDialog::openPlaylistDirectoryDialog() { + + QPlaylistFileDialog dialog(this); + + dialog.setAllowFileSelect(false); + dialog.setAllowDirectorySelect(true); + + if (dialog.exec()) + { + assert(!dialog.selectedFiles().empty()); + _ui.startupPlaylistDirectoryLineEdit->setText(dialog.selectedFiles()[0]); + + } +} void QProjectMConfigDialog::openMenuFontFileDialog() { @@ -86,7 +103,7 @@ void QProjectMConfigDialog::saveConfig() { settings.windowWidth = _ui.windowWidthSpinBox->value(); settings.titleFontURL = _ui.titleFontPathLineEdit->text().toStdString(); settings.menuFontURL = _ui.menuFontPathLineEdit->text().toStdString(); - settings.presetURL = _ui.startupPlaylistLineEdit->text().toStdString(); + settings.presetURL = _ui.startupPlaylistDirectoryLineEdit->text().toStdString(); settings.textureSize = _ui.textureSizeComboBox->itemData(_ui.textureSizeComboBox->currentIndex()).toInt(); settings.smoothPresetDuration = _ui.smoothPresetDurationSpinBox->value(); settings.presetDuration = _ui.presetDurationSpinBox->value(); @@ -94,12 +111,15 @@ void QProjectMConfigDialog::saveConfig() { settings.aspectCorrection = _ui.useAspectCorrectionCheckBox->checkState() == Qt::Checked; settings.beatSensitivity = _ui.beatSensitivitySpinBox->value(); settings.easterEgg = _ui.easterEggParameterSpinBox->value(); + settings.shuffleEnabled = _ui.shuffleOnStartupCheckBox->checkState() == Qt::Checked; projectM::writeConfig(_configFile, settings); QSettings qSettings("projectM", "qprojectM"); qSettings.setValue("FullscreenOnStartup", _ui.fullscreenOnStartupCheckBox->checkState() == Qt::Checked); qSettings.setValue("MenuOnStartup", _ui.menuOnStartupCheckBox->checkState() == Qt::Checked); + + qSettings.setValue("PlaylistFile", _ui.startupPlaylistFileLineEdit->text()); qDebug() << "save end"; } @@ -124,13 +144,13 @@ void QProjectMConfigDialog::loadConfig() { _ui.titleFontPathLineEdit->setText(settings.titleFontURL.c_str()); _ui.menuFontPathLineEdit->setText(settings.menuFontURL.c_str()); - _ui.startupPlaylistLineEdit->setText(settings.presetURL.c_str()); + _ui.startupPlaylistDirectoryLineEdit->setText(settings.presetURL.c_str()); _ui.useAspectCorrectionCheckBox->setCheckState(settings.aspectCorrection ? Qt::Checked : Qt::Unchecked); _ui.maxFPSSpinBox->setValue(settings.fps); _ui.beatSensitivitySpinBox->setValue(settings.beatSensitivity); _ui.windowHeightSpinBox->setValue(settings.windowHeight); _ui.windowWidthSpinBox->setValue(settings.windowWidth); - + _ui.shuffleOnStartupCheckBox->setCheckState(settings.shuffleEnabled ? Qt::Checked : Qt::Unchecked); populateTextureSizeComboBox(); _ui.textureSizeComboBox->insertItem(0, QString("%1").arg(settings.textureSize), settings.textureSize); _ui.textureSizeComboBox->setCurrentIndex(0); @@ -138,6 +158,13 @@ void QProjectMConfigDialog::loadConfig() { _ui.smoothPresetDurationSpinBox->setValue(settings.smoothPresetDuration); _ui.presetDurationSpinBox->setValue(settings.presetDuration); _ui.easterEggParameterSpinBox->setValue(settings.easterEgg); + + + QSettings qSettings("projectM", "qprojectM"); + _ui.fullscreenOnStartupCheckBox->setCheckState(qSettings.value("FullscreenOnStartup", false).toBool() ? Qt::Checked : Qt::Unchecked); + _ui.menuOnStartupCheckBox->setCheckState(qSettings.value("MenuOnStartup", false).toBool() ? Qt::Checked : Qt::Unchecked); + _ui.startupPlaylistFileLineEdit->setText(qSettings.value("PlaylistFile", QString()).toString() ); + qDebug() << "load config END"; } diff --git a/src/qprojectM/QProjectMConfigDialog.hpp b/src/qprojectM/QProjectMConfigDialog.hpp index 6ca642941..7c7689e1c 100644 --- a/src/qprojectM/QProjectMConfigDialog.hpp +++ b/src/qprojectM/QProjectMConfigDialog.hpp @@ -12,7 +12,9 @@ class QProjectMConfigDialog : public QDialog { private: void loadConfig(); private slots: - void openPlaylistFileDialog(); + void openPlaylistFileDialog(); + void openPlaylistDirectoryDialog(); + void openMenuFontFileDialog(); void openTitleFontFileDialog(); void saveConfig(); diff --git a/src/qprojectM/QProjectMConfigDialog.ui b/src/qprojectM/QProjectMConfigDialog.ui index f4b829d31..7436d2ca9 100644 --- a/src/qprojectM/QProjectMConfigDialog.ui +++ b/src/qprojectM/QProjectMConfigDialog.ui @@ -5,8 +5,8 @@ 0 0 - 455 - 310 + 483 + 334 @@ -15,9 +15,9 @@ - 5 - 35 - 119 + 7 + 67 + 105 24 @@ -40,8 +40,8 @@ - 423 - 35 + 447 + 67 24 24 @@ -53,9 +53,9 @@ - 130 - 35 - 287 + 118 + 67 + 323 24 @@ -75,9 +75,9 @@ p, li { white-space: pre-wrap; } - 5 - 5 - 119 + 7 + 7 + 105 24 @@ -94,14 +94,14 @@ p, li { white-space: pre-wrap; } - Startup Playlist + Playlist Directory - + - 423 - 5 + 447 + 7 24 24 @@ -110,12 +110,12 @@ p, li { white-space: pre-wrap; } ... - + - 130 - 5 - 287 + 118 + 7 + 323 24 @@ -128,15 +128,15 @@ 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;">This sets the default preset playlist when qprojectM starts up. This can be either a directory path or preset playlist file. If unspecified then projectM uses a default preset directory</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; 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; font-size:9pt;">This sets the default preset playlist directory when projectM starts up. Every valid preset file in the specified directory will be loaded into the playlist upon initialization. <span style=" font-weight:600;">NOTE:</span> This option is overriden by a non empty value of the <span style=" font-style:italic;">Playlist File </span>option.</p></body></html> - 5 - 95 + 7 + 129 119 24 @@ -148,9 +148,9 @@ p, li { white-space: pre-wrap; } - 130 - 95 - 61 + 132 + 129 + 74 24 @@ -170,8 +170,8 @@ p, li { white-space: pre-wrap; } - 197 - 95 + 212 + 129 171 24 @@ -183,9 +183,9 @@ p, li { white-space: pre-wrap; } - 374 - 95 - 73 + 389 + 129 + 82 24 @@ -205,10 +205,10 @@ p, li { white-space: pre-wrap; } - 197 - 229 + 226 + 259 81 - 37 + 24 @@ -224,8 +224,8 @@ p, li { white-space: pre-wrap; } - 197 - 125 + 212 + 159 171 24 @@ -243,9 +243,9 @@ p, li { white-space: pre-wrap; } - 374 - 125 - 73 + 389 + 159 + 82 24 @@ -268,9 +268,9 @@ p, li { white-space: pre-wrap; } - 284 - 235 - 54 + 313 + 259 + 66 24 @@ -296,10 +296,10 @@ p, li { white-space: pre-wrap; } - 344 - 185 - 43 - 38 + 385 + 225 + 16 + 24 @@ -315,8 +315,8 @@ p, li { white-space: pre-wrap; } - 5 - 155 + 7 + 189 119 24 @@ -334,9 +334,9 @@ p, li { white-space: pre-wrap; } - 130 - 155 - 61 + 132 + 189 + 74 24 @@ -359,10 +359,10 @@ p, li { white-space: pre-wrap; } - 197 - 185 + 226 + 225 81 - 38 + 24 @@ -378,9 +378,9 @@ p, li { white-space: pre-wrap; } - 5 - 243 - 186 + 7 + 279 + 211 23 @@ -391,15 +391,15 @@ p, li { white-space: pre-wrap; } - Fullscreen on Startup + Fullscreen on startup - 5 - 214 - 186 + 7 + 250 + 211 23 @@ -410,15 +410,15 @@ p, li { white-space: pre-wrap; } - Show Menu on Startup + Show Menu on startup - 197 - 272 - 250 + 225 + 298 + 247 30 @@ -435,9 +435,9 @@ p, li { white-space: pre-wrap; } - 393 - 235 - 54 + 405 + 259 + 66 24 @@ -457,10 +457,10 @@ p, li { white-space: pre-wrap; } - 344 - 229 - 43 - 37 + 385 + 259 + 16 + 24 @@ -476,9 +476,9 @@ p, li { white-space: pre-wrap; } - 5 - 185 - 186 + 7 + 221 + 211 23 @@ -501,8 +501,8 @@ p, li { white-space: pre-wrap; } - 5 - 125 + 7 + 159 119 24 @@ -520,8 +520,8 @@ p, li { white-space: pre-wrap; } - 423 - 65 + 447 + 97 24 24 @@ -533,9 +533,9 @@ p, li { white-space: pre-wrap; } - 5 - 65 - 119 + 7 + 97 + 105 24 @@ -558,9 +558,9 @@ p, li { white-space: pre-wrap; } - 130 - 65 - 287 + 118 + 97 + 323 24 @@ -580,9 +580,9 @@ p, li { white-space: pre-wrap; } - 130 - 125 - 61 + 132 + 159 + 74 24 @@ -602,8 +602,8 @@ p, li { white-space: pre-wrap; } - 197 - 155 + 212 + 189 171 24 @@ -621,9 +621,9 @@ p, li { white-space: pre-wrap; } - 374 - 155 - 73 + 389 + 189 + 82 24 @@ -643,9 +643,9 @@ p, li { white-space: pre-wrap; } - 284 - 192 - 54 + 313 + 225 + 66 24 @@ -668,9 +668,9 @@ p, li { white-space: pre-wrap; } - 393 - 192 - 54 + 405 + 225 + 66 24 @@ -687,6 +687,85 @@ p, li { white-space: pre-wrap; } 1000 + + + + 7 + 308 + 211 + 23 + + + + + 0 + 0 + + + + Shuffle on startup + + + + + + 447 + 37 + 24 + 24 + + + + ... + + + + + + 7 + 37 + 105 + 24 + + + + + 0 + 0 + + + + + 50 + 0 + + + + Playlist File + + + + + + 118 + 37 + 323 + 24 + + + + + 2 + 0 + + + + <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:10pt; 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; font-size:9pt;">This sets the default preset playlist file when qprojectM starts up. The file must be a valid preset playlist (of type *.ppl). If specified, this overrides the <span style=" font-style:italic;">Playlist Directory</span> value on startup. </p></body></html> + + diff --git a/src/qprojectM/QProjectM_MainWindow.cpp b/src/qprojectM/QProjectM_MainWindow.cpp index 9034f5fd4..95fc431a7 100644 --- a/src/qprojectM/QProjectM_MainWindow.cpp +++ b/src/qprojectM/QProjectM_MainWindow.cpp @@ -161,7 +161,7 @@ void QProjectM_MainWindow::clearPlaylist() playlistModel->clear(); ui->dockWidgetContents->setWindowTitle ( "Preset Playlist" ); ui->dockWidgetContents->setWindowModified(false); - m_currentPlaylistFile = ""; + m_currentPlaylistUrl = ""; for ( QHash::iterator pos = historyHash.begin(); pos != historyHash.end(); ++pos ) { @@ -205,8 +205,10 @@ void QProjectM_MainWindow::selectPlaylistItem ( const QModelIndex & index ) void QProjectM_MainWindow::postProjectM_Initialize() { + QSettings qSettings("projectM", "qprojectM"); + qDebug() << "QProjectM_MainWindow::postProjectM_Initialize()"; - ui->tableView->setModel(0); + //ui->tableView->setModel(0); if (playlistModel) delete(playlistModel); @@ -215,13 +217,19 @@ void QProjectM_MainWindow::postProjectM_Initialize() ui->tableView->setModel ( playlistModel ); - /// @bug only do this at startup? - static bool firstOfRefreshPlaylist = true; + /// @bug only do this at startup? fix me + //static bool firstOfRefreshPlaylist = true; - if (firstOfRefreshPlaylist) { + //if (firstOfRefreshPlaylist) { + QString playlistFile; + if ((playlistFile = qSettings.value("PlaylistFile", QString()).toString()) == QString()) + playlistModel->readPlaylist(QString(qprojectM()->settings().presetURL.c_str())); + else + playlistModel->readPlaylist(playlistFile); + refreshPlaylist(); - firstOfRefreshPlaylist = false; - } +// firstOfRefreshPlaylist = false; + //} if (!configDialog) { configDialog = new QProjectMConfigDialog(m_QProjectMWidget->configFile(), m_QProjectMWidget, this); @@ -319,7 +327,6 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e ) ui->lockPresetCheckBox->setCheckState ( Qt::Checked ); } - // the projectM widget handles the actual lock //e->ignore(); //m_QProjectMWidget->keyReleaseEvent(e); @@ -415,9 +422,9 @@ void QProjectM_MainWindow::addPresets() void QProjectM_MainWindow::savePlaylist() { - //m_currentPlaylistFile = file; + //m_currentPlaylistUrl = file; - if ( m_currentPlaylistFile == QString() ) + if ( m_currentPlaylistUrl == QString() ) { qDebug() << "current playlist file null!" ; return; @@ -425,16 +432,16 @@ void QProjectM_MainWindow::savePlaylist() /// @idea add ability to save filtered list #if 0 - if ( playlistModel->writePlaylist ( m_currentPlaylistFile ) ) { - this->ui->statusbar->showMessage ( QString ( "Saved cropped preset playlist \"%1\" successfully." ).arg ( m_currentPlaylistFile ), 3000 ); + if ( playlistModel->writePlaylist ( m_currentPlaylistUrl ) ) { + this->ui->statusbar->showMessage ( QString ( "Saved cropped preset playlist \"%1\" successfully." ).arg ( m_currentPlaylistUrl ), 3000 ); this->ui->presetPlayListDockWidget->setWindowModified ( false ); } #endif - QFile qfile(m_currentPlaylistFile); + QFile qfile(m_currentPlaylistUrl); if (!qfile.open(QIODevice::WriteOnly)) { - QMessageBox::warning (0, "Playlist Save Error", QString("There was a problem trying to save the playlist \"%1\". You may not have permission to modify this file.").arg(m_currentPlaylistFile)); + QMessageBox::warning (0, "Playlist Save Error", QString("There was a problem trying to save the playlist \"%1\". You may not have permission to modify this file.").arg(m_currentPlaylistUrl)); return ; } @@ -447,7 +454,7 @@ void QProjectM_MainWindow::savePlaylist() QXmlPlaylistHandler::writePlaylist(&qfile, writeFunctor); - this->ui->statusbar->showMessage ( QString ( "Saved preset playlist \"%1\" successfully." ).arg ( m_currentPlaylistFile ), 3000 ); + this->ui->statusbar->showMessage ( QString ( "Saved preset playlist \"%1\" successfully." ).arg ( m_currentPlaylistUrl ), 3000 ); this->ui->presetPlayListDockWidget->setWindowModified ( false ); @@ -455,20 +462,28 @@ void QProjectM_MainWindow::savePlaylist() void QProjectM_MainWindow::openPlaylist() { - + m_QPlaylistFileDialog->setAllowDirectorySelect(true); + m_QPlaylistFileDialog->setAllowFileSelect(true); + if ( m_QPlaylistFileDialog->exec() ) { - + qDebug() << "open playlist exec"; + + if (m_QPlaylistFileDialog->selectedFiles().empty()) + return; + QString searchText = ui->presetSearchBarLineEdit->text(); clearPlaylist(); - const QString file = m_QPlaylistFileDialog->selectedFiles() [0]; + + const QString url = m_QPlaylistFileDialog->selectedFiles() [0]; - if ( playlistModel->readPlaylist ( file ) ) + qDebug() << "url: " << url; + if ( playlistModel->readPlaylist ( url ) ) { ui->presetPlayListDockWidget->setWindowTitle ( QString ( "Preset Playlist - %1 [*]" ).arg ( playlistModel->playlistName() ) ); - m_currentPlaylistFile = file; + m_currentPlaylistUrl = url; } else { @@ -600,7 +615,7 @@ void QProjectM_MainWindow::about() } void QProjectM_MainWindow::openSettingsDialog() { - + if (configDialog->exec()) { } @@ -628,7 +643,6 @@ void QProjectM_MainWindow::registerSettingsAction(QAction * action) { ui->menuSettings->addAction(action); } - void QProjectM_MainWindow::unregisterSettingsAction(QAction * action) { ui->menuSettings->removeAction(action); } @@ -636,7 +650,6 @@ void QProjectM_MainWindow::unregisterSettingsAction(QAction * action) { void QProjectM_MainWindow::createMenus() { ui->menuBar->hide(); - } void QProjectM_MainWindow::createToolBars() diff --git a/src/qprojectM/QProjectM_MainWindow.hpp b/src/qprojectM/QProjectM_MainWindow.hpp index 63cb52125..d34a2bd1e 100644 --- a/src/qprojectM/QProjectM_MainWindow.hpp +++ b/src/qprojectM/QProjectM_MainWindow.hpp @@ -57,7 +57,7 @@ class QProjectM : public QObject, public projectM { Q_OBJECT public: - QProjectM(const std::string & config_file):projectM(config_file) {} + 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); @@ -107,9 +107,9 @@ public slots: // waiting on it's mutex // s_audioMutex.tryLock(20000); if (m_audioMutex) { - qDebug() << "lock set start!"; + qDebug() << "LOCK: projectM Reset"; m_audioMutex->lock(); - qDebug() << "lock set end!"; + } // Now destroy the projectM instance destroyProjectM(); @@ -351,7 +351,7 @@ private slots: QHeaderView * hHeader; QHeaderView * vHeader; - QString m_currentPlaylistFile; + QString m_currentPlaylistUrl; QPlaylistModel * playlistModel; Ui::QProjectM_MainWindow * ui;