shuffle button config option

menu / full screen states are now preserved
90% done with new playlist loading framework
broke reset button even more



git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@861 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2008-03-01 05:37:27 +00:00
parent 316d1a5a46
commit b6100f891c
14 changed files with 373 additions and 172 deletions

View File

@ -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()

View File

@ -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();

View File

@ -97,8 +97,6 @@ inline std::size_t weightedRandomNormalized(std::vector<float> weights) {
inline std::size_t weightedRandom(const std::vector<int> & 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];

View File

@ -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<Preset> & targetPreset, PresetInputs & inputs, PresetOutputs & outputs) {
void projectM::switchPreset(std::auto_ptr<Preset> & 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);

View File

@ -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;
};

View File

@ -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<QProjectM **> ( 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 );

View File

@ -47,7 +47,6 @@ class QPulseAudioThread : public QThread
m_projectM = projectM;
*s_projectMPtr = m_projectM;
qDebug() << "CORKING";
s_audioMutex.unlock();
cork();
}

View File

@ -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()));

View File

@ -23,22 +23,94 @@
#define QPLAYLIST_FILEDIALOG_H
#include <QFileDialog>
#include <QStringList>
#include <QtDebug>
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]);
}
};

View File

@ -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";
}

View File

@ -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();

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>310</height>
<width>483</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle" >
@ -15,9 +15,9 @@
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>5</x>
<y>35</y>
<width>119</width>
<x>7</x>
<y>67</y>
<width>105</width>
<height>24</height>
</rect>
</property>
@ -40,8 +40,8 @@
<widget class="QToolButton" name="menuFontPathToolButton" >
<property name="geometry" >
<rect>
<x>423</x>
<y>35</y>
<x>447</x>
<y>67</y>
<width>24</width>
<height>24</height>
</rect>
@ -53,9 +53,9 @@
<widget class="QLineEdit" name="menuFontPathLineEdit" >
<property name="geometry" >
<rect>
<x>130</x>
<y>35</y>
<width>287</width>
<x>118</x>
<y>67</y>
<width>323</width>
<height>24</height>
</rect>
</property>
@ -75,9 +75,9 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_2" >
<property name="geometry" >
<rect>
<x>5</x>
<y>5</y>
<width>119</width>
<x>7</x>
<y>7</y>
<width>105</width>
<height>24</height>
</rect>
</property>
@ -94,14 +94,14 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<property name="text" >
<string>Startup Playlist</string>
<string>Playlist Directory</string>
</property>
</widget>
<widget class="QToolButton" name="startupPlaylistToolButton" >
<widget class="QToolButton" name="startupPlaylistDirectoryToolButton" >
<property name="geometry" >
<rect>
<x>423</x>
<y>5</y>
<x>447</x>
<y>7</y>
<width>24</width>
<height>24</height>
</rect>
@ -110,12 +110,12 @@ p, li { white-space: pre-wrap; }
<string>...</string>
</property>
</widget>
<widget class="QLineEdit" name="startupPlaylistLineEdit" >
<widget class="QLineEdit" name="startupPlaylistDirectoryLineEdit" >
<property name="geometry" >
<rect>
<x>130</x>
<y>5</y>
<width>287</width>
<x>118</x>
<y>7</y>
<width>323</width>
<height>24</height>
</rect>
</property>
@ -128,15 +128,15 @@ p, li { white-space: pre-wrap; }
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;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&lt;/p>&lt;/body>&lt;/html></string>
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
&lt;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. &lt;span style=" font-weight:600;">NOTE:&lt;/span> This option is overriden by a non empty value of the &lt;span style=" font-style:italic;">Playlist File &lt;/span>option.&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
<widget class="QLabel" name="label_3" >
<property name="geometry" >
<rect>
<x>5</x>
<y>95</y>
<x>7</x>
<y>129</y>
<width>119</width>
<height>24</height>
</rect>
@ -148,9 +148,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="presetDurationSpinBox" >
<property name="geometry" >
<rect>
<x>130</x>
<y>95</y>
<width>61</width>
<x>132</x>
<y>129</y>
<width>74</width>
<height>24</height>
</rect>
</property>
@ -170,8 +170,8 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_4" >
<property name="geometry" >
<rect>
<x>197</x>
<y>95</y>
<x>212</x>
<y>129</y>
<width>171</width>
<height>24</height>
</rect>
@ -183,9 +183,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="smoothPresetDurationSpinBox" >
<property name="geometry" >
<rect>
<x>374</x>
<y>95</y>
<width>73</width>
<x>389</x>
<y>129</y>
<width>82</width>
<height>24</height>
</rect>
</property>
@ -205,10 +205,10 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_5" >
<property name="geometry" >
<rect>
<x>197</x>
<y>229</y>
<x>226</x>
<y>259</y>
<width>81</width>
<height>37</height>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
@ -224,8 +224,8 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_6" >
<property name="geometry" >
<rect>
<x>197</x>
<y>125</y>
<x>212</x>
<y>159</y>
<width>171</width>
<height>24</height>
</rect>
@ -243,9 +243,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="maxFPSSpinBox" >
<property name="geometry" >
<rect>
<x>374</x>
<y>125</y>
<width>73</width>
<x>389</x>
<y>159</y>
<width>82</width>
<height>24</height>
</rect>
</property>
@ -268,9 +268,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="windowWidthSpinBox" >
<property name="geometry" >
<rect>
<x>284</x>
<y>235</y>
<width>54</width>
<x>313</x>
<y>259</y>
<width>66</width>
<height>24</height>
</rect>
</property>
@ -296,10 +296,10 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_10" >
<property name="geometry" >
<rect>
<x>344</x>
<y>185</y>
<width>43</width>
<height>38</height>
<x>385</x>
<y>225</y>
<width>16</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
@ -315,8 +315,8 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_7" >
<property name="geometry" >
<rect>
<x>5</x>
<y>155</y>
<x>7</x>
<y>189</y>
<width>119</width>
<height>24</height>
</rect>
@ -334,9 +334,9 @@ p, li { white-space: pre-wrap; }
<widget class="QComboBox" name="textureSizeComboBox" >
<property name="geometry" >
<rect>
<x>130</x>
<y>155</y>
<width>61</width>
<x>132</x>
<y>189</y>
<width>74</width>
<height>24</height>
</rect>
</property>
@ -359,10 +359,10 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_8" >
<property name="geometry" >
<rect>
<x>197</x>
<y>185</y>
<x>226</x>
<y>225</y>
<width>81</width>
<height>38</height>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
@ -378,9 +378,9 @@ p, li { white-space: pre-wrap; }
<widget class="QCheckBox" name="fullscreenOnStartupCheckBox" >
<property name="geometry" >
<rect>
<x>5</x>
<y>243</y>
<width>186</width>
<x>7</x>
<y>279</y>
<width>211</width>
<height>23</height>
</rect>
</property>
@ -391,15 +391,15 @@ p, li { white-space: pre-wrap; }
</sizepolicy>
</property>
<property name="text" >
<string>Fullscreen on Startup</string>
<string>Fullscreen on startup</string>
</property>
</widget>
<widget class="QCheckBox" name="menuOnStartupCheckBox" >
<property name="geometry" >
<rect>
<x>5</x>
<y>214</y>
<width>186</width>
<x>7</x>
<y>250</y>
<width>211</width>
<height>23</height>
</rect>
</property>
@ -410,15 +410,15 @@ p, li { white-space: pre-wrap; }
</sizepolicy>
</property>
<property name="text" >
<string>Show Menu on Startup</string>
<string>Show Menu on startup</string>
</property>
</widget>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>197</x>
<y>272</y>
<width>250</width>
<x>225</x>
<y>298</y>
<width>247</width>
<height>30</height>
</rect>
</property>
@ -435,9 +435,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="windowHeightSpinBox" >
<property name="geometry" >
<rect>
<x>393</x>
<y>235</y>
<width>54</width>
<x>405</x>
<y>259</y>
<width>66</width>
<height>24</height>
</rect>
</property>
@ -457,10 +457,10 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_11" >
<property name="geometry" >
<rect>
<x>344</x>
<y>229</y>
<width>43</width>
<height>37</height>
<x>385</x>
<y>259</y>
<width>16</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
@ -476,9 +476,9 @@ p, li { white-space: pre-wrap; }
<widget class="QCheckBox" name="useAspectCorrectionCheckBox" >
<property name="geometry" >
<rect>
<x>5</x>
<y>185</y>
<width>186</width>
<x>7</x>
<y>221</y>
<width>211</width>
<height>23</height>
</rect>
</property>
@ -501,8 +501,8 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_12" >
<property name="geometry" >
<rect>
<x>5</x>
<y>125</y>
<x>7</x>
<y>159</y>
<width>119</width>
<height>24</height>
</rect>
@ -520,8 +520,8 @@ p, li { white-space: pre-wrap; }
<widget class="QToolButton" name="titleFontPathToolButton" >
<property name="geometry" >
<rect>
<x>423</x>
<y>65</y>
<x>447</x>
<y>97</y>
<width>24</width>
<height>24</height>
</rect>
@ -533,9 +533,9 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_9" >
<property name="geometry" >
<rect>
<x>5</x>
<y>65</y>
<width>119</width>
<x>7</x>
<y>97</y>
<width>105</width>
<height>24</height>
</rect>
</property>
@ -558,9 +558,9 @@ p, li { white-space: pre-wrap; }
<widget class="QLineEdit" name="titleFontPathLineEdit" >
<property name="geometry" >
<rect>
<x>130</x>
<y>65</y>
<width>287</width>
<x>118</x>
<y>97</y>
<width>323</width>
<height>24</height>
</rect>
</property>
@ -580,9 +580,9 @@ p, li { white-space: pre-wrap; }
<widget class="QDoubleSpinBox" name="beatSensitivitySpinBox" >
<property name="geometry" >
<rect>
<x>130</x>
<y>125</y>
<width>61</width>
<x>132</x>
<y>159</y>
<width>74</width>
<height>24</height>
</rect>
</property>
@ -602,8 +602,8 @@ p, li { white-space: pre-wrap; }
<widget class="QLabel" name="label_13" >
<property name="geometry" >
<rect>
<x>197</x>
<y>155</y>
<x>212</x>
<y>189</y>
<width>171</width>
<height>24</height>
</rect>
@ -621,9 +621,9 @@ p, li { white-space: pre-wrap; }
<widget class="QDoubleSpinBox" name="easterEggParameterSpinBox" >
<property name="geometry" >
<rect>
<x>374</x>
<y>155</y>
<width>73</width>
<x>389</x>
<y>189</y>
<width>82</width>
<height>24</height>
</rect>
</property>
@ -643,9 +643,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="meshSizeWidthSpinBox" >
<property name="geometry" >
<rect>
<x>284</x>
<y>192</y>
<width>54</width>
<x>313</x>
<y>225</y>
<width>66</width>
<height>24</height>
</rect>
</property>
@ -668,9 +668,9 @@ p, li { white-space: pre-wrap; }
<widget class="QSpinBox" name="meshSizeHeightSpinBox" >
<property name="geometry" >
<rect>
<x>393</x>
<y>192</y>
<width>54</width>
<x>405</x>
<y>225</y>
<width>66</width>
<height>24</height>
</rect>
</property>
@ -687,6 +687,85 @@ p, li { white-space: pre-wrap; }
<number>1000</number>
</property>
</widget>
<widget class="QCheckBox" name="shuffleOnStartupCheckBox" >
<property name="geometry" >
<rect>
<x>7</x>
<y>308</y>
<width>211</width>
<height>23</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Shuffle on startup</string>
</property>
</widget>
<widget class="QToolButton" name="startupPlaylistFileToolButton" >
<property name="geometry" >
<rect>
<x>447</x>
<y>37</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
<widget class="QLabel" name="label_14" >
<property name="geometry" >
<rect>
<x>7</x>
<y>37</y>
<width>105</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Playlist File</string>
</property>
</widget>
<widget class="QLineEdit" name="startupPlaylistFileLineEdit" >
<property name="geometry" >
<rect>
<x>118</x>
<y>37</y>
<width>323</width>
<height>24</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
&lt;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 &lt;span style=" font-style:italic;">Playlist Directory&lt;/span> value on startup. &lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -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<QString, PlaylistItemVector*>::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()

View File

@ -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;