disabled real time apply button. save button instead (cop out, sorry).

added tooltip to config dialog button box.
lots of stuff I forgot about



git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@895 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2008-03-21 03:15:24 +00:00
parent b9c7554808
commit cc4c90eaed
12 changed files with 645 additions and 845 deletions

View File

@ -25,7 +25,7 @@
#include <fcntl.h>
#include <QSettings>
#include "qprojectm_mainwindow.hpp"
#include "qprojectm_mainwindow.hpp"
#define TIME_EVENT_USEC 50000
@ -155,7 +155,7 @@ void QPulseAudioThread::cleanup()
void QPulseAudioThread::connectHelper (SourceContainer::const_iterator pos)
{
assert(stream);
Q_ASSERT(stream);
pa_stream_flags_t flags = ( pa_stream_flags_t ) 0;
// qDebug() << "start2 ";
assert (pos != s_sourceList.end());
@ -373,7 +373,7 @@ void QPulseAudioThread::stream_state_callback ( pa_stream *s, void *userdata )
void QPulseAudioThread::stream_moved_callback(pa_stream *s, void *userdata) {
assert(s);
Q_ASSERT(s);
if (verbose)
fprintf(stderr, "Stream moved to device %s (%u, %ssuspended).\n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not ");
@ -458,9 +458,9 @@ void QPulseAudioThread::stdout_callback ( pa_mainloop_api*a, pa_io_event *e, int
QProjectM ** prjmPtr = static_cast<QProjectM **> ( userdata );
QProjectM * prjm = *prjmPtr;
assert(prjm);
assert(prjm->pcm());
assert(buffer);
Q_ASSERT(prjm);
Q_ASSERT(prjm->pcm());
Q_ASSERT(buffer);
prjm->pcm()->addPCMfloat
( buffer+buffer_index, buffer_length / ( sizeof ( float ) ) );
@ -667,7 +667,7 @@ void QPulseAudioThread::run()
signal ( SIGPIPE, SIG_IGN );
#endif
assert(m_projectM);
Q_ASSERT(m_projectM);
if ( ! ( stdio_event = mainloop_api->io_new ( mainloop_api,
STDOUT_FILENO,
PA_IO_EVENT_OUTPUT,

View File

@ -12,7 +12,6 @@ else(${CMAKE_PROJECT_NAME} MATCHES "PROJECTM_ROOT")
pkg_search_module(LIBPROJECTM REQUIRED libprojectM)
endif(${CMAKE_PROJECT_NAME} MATCHES "PROJECTM_ROOT")
find_package(Qt4 REQUIRED) # find and setup Qt4 for this project
include(${QT_USE_FILE})

View File

@ -297,11 +297,12 @@ bool QPlaylistModel::readPlaylist ( const QString & file )
{
if (QFileInfo(file).isDir()) {
if (!QDir(file).isReadable()) {
QMessageBox::warning (0, "Playlist Directory Error", QString(tr("There was a problem trying to open the playlist directory \"%1\". You may not have permission to open the directory.")).arg(file));
return false;
}
foreach (QFileInfo info, QDir(file).entryInfoList()) {
if (!QDir(file).isReadable()) {
QMessageBox::warning (0, "Playlist Directory Error", QString(tr("There was a problem trying to open the playlist directory \"%1\". The directory doesn't exist or you may not have permission to open it. ")).arg(file));
return false;
}
foreach (QFileInfo info, QDir(file).entryInfoList()) {
if (info.fileName().toLower().endsWith(".prjm") || info.fileName().toLower().endsWith(".milk"))
appendRow(info.absoluteFilePath(), info.fileName(), 3);
}

View File

@ -40,8 +40,7 @@ class QPlaylistTableView : public QTableView
void resized(QResizeEvent * event);
void deletesRequested(const QModelIndexList & items);
void internalDragAndDropRequested(const QModelIndexList & items, const QModelIndex & target = QModelIndex());
void presetEditorRequested(const QModelIndexList &);
public slots:
void dropEvent ( QDropEvent * event ) {
@ -106,13 +105,6 @@ class QPlaylistTableView : public QTableView
emit(deletesRequested(selectedIndexes()));
break;
case Qt::Key_E:
if (event->modifiers() & Qt::ControlModifier) {
emit(presetEditorRequested(selectedIndexes()));
}
break;
default:
event->ignore();
break;

View File

@ -7,14 +7,14 @@ QPresetEditorDialog::QPresetEditorDialog(QProjectMWidget * widget, QWidget * par
_ui.setupUi(this);
connect(_ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonBoxHandler(QAbstractButton*)));
}
void QPresetEditorDialog::setPreset(QString url, const QModelIndex & index) {
m_index = index;
void QPresetEditorDialog::setPreset(QString url, int rowIndex) {
disconnect(_ui.presetTextEdit, 0, this, 0);
m_index = rowIndex;
m_presetUrl = url;
_ui.presetTextEdit->loadPresetText(url);

View File

@ -9,14 +9,14 @@ class QPresetEditorDialog : public QDialog {
public:
QPresetEditorDialog(QProjectMWidget * widget, QWidget * parent = 0, Qt::WindowFlags f = 0);
void setPreset(QString url, const QModelIndex &index);
void setPreset(QString url, int rowIndex);
const QString & presetUrl() const;
inline const QModelIndex & presetIndex() const {
inline int presetIndex() const {
return m_index;
}
signals:
void presetModified(const QModelIndex &);
void presetModified(int rowIndex);
protected:
//void keyReleaseEvent(QKeyEvent * e);
public slots:
@ -29,7 +29,7 @@ class QPresetEditorDialog : public QDialog {
void updateWindowTitle();
private:
QModelIndex m_index;
int m_index;
void revertBuffer();
QProjectMWidget * _qprojectMWidget;
Ui::QPresetEditorDialog _ui;

View File

@ -18,40 +18,40 @@
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<widget class="QPresetTextEdit" name="presetTextEdit" >
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>1</x>
<y>11</y>
<width>366</width>
<height>289</height>
<width>451</width>
<height>291</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>373</x>
<y>11</y>
<width>77</width>
<height>289</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::NoButton|QDialogButtonBox::Reset</set>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QPresetTextEdit" name="presetTextEdit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::NoButton|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>

View File

@ -29,15 +29,15 @@ class QPresetTextEdit: public QTextEdit
Q_OBJECT // must include this if you use Qt signals/slots
public:
inline QPresetTextEdit(QWidget * parent = 0): QTextEdit(parent) {}
bool loadPresetText(QString url);
inline QPresetTextEdit(QWidget * parent = 0): QTextEdit(parent) {}
bool loadPresetText(QString url);
void keyReleaseEvent(QKeyEvent * e);
signals:
void applyRequested();
public slots:
private:

View File

@ -198,8 +198,15 @@ void QProjectM_MainWindow::selectPlaylistItem ( const QModelIndex & index )
if ( index.column() > 0 )
return;
qprojectM()->selectPreset ( index.row() );
*activePresetIndex = index.row();
selectPlaylistItem(index.row());
}
void QProjectM_MainWindow::selectPlaylistItem ( int rowIndex)
{
qprojectM()->selectPreset (rowIndex);
*activePresetIndex = rowIndex;
playlistModel->updateItemHighlights();
@ -259,8 +266,6 @@ void QProjectM_MainWindow::postProjectM_Initialize()
disconnect(ui->tableView);
connect ( ui->tableView, SIGNAL (presetEditorRequested(const QModelIndexList &)),
this, SLOT(openPresetEditorDialog(const QModelIndexList &)), Qt::DirectConnection);
connect(ui->tableView, SIGNAL(deletesRequested(const QModelIndexList&)),
this, SLOT(removePlaylistItems(const QModelIndexList&)));
@ -272,35 +277,29 @@ void QProjectM_MainWindow::postProjectM_Initialize()
}
void QProjectM_MainWindow::openPresetEditorDialog(const QModelIndexList indices) {
void QProjectM_MainWindow::openPresetEditorDialog(int rowIndex) {
if (indices.empty())
return;
QModelIndex firstIndex = indices[0];
selectPlaylistItem(firstIndex);
qprojectMWidget()->seizePresetLock();
Qt::CheckState stateBackup = ui->lockPresetCheckBox->checkState();
ui->lockPresetCheckBox->setCheckState(Qt::Checked);
if (!m_QPresetEditorDialog) {
m_QPresetEditorDialog = new QPresetEditorDialog(qprojectMWidget());
connect(m_QPresetEditorDialog, SIGNAL(presetModified(const QModelIndex &)),
this, SLOT(selectPlaylistItem(const QModelIndex&)));
connect(m_QPresetEditorDialog, SIGNAL(presetModified(int)),
this, SLOT(selectPlaylistItem(int)));
}
QString url = playlistModel->data( firstIndex, QPlaylistModel::URLInfoRole).toString() ;
m_QPresetEditorDialog->setPreset(url, firstIndex);
Q_ASSERT(historyHash.contains(previousFilter));
Q_ASSERT(playlistItemMetaDataHash.contains((*historyHash[previousFilter])[rowIndex]));
QString url = playlistItemMetaDataHash[(*historyHash[previousFilter])[rowIndex]].url;
m_QPresetEditorDialog->setPreset(url, rowIndex);
if (m_QPresetEditorDialog->exec()) {
}
ui->lockPresetCheckBox->setCheckState(stateBackup);
qprojectMWidget()->releasePresetLock();
}
@ -330,7 +329,8 @@ void QProjectM_MainWindow::dragAndDropPlaylistItems(const QModelIndexList & indi
}
else
{
abort();
// Self drag event ignored
// abort();
return;
}
@ -387,6 +387,13 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e )
QModelIndex modelIndex;
switch ( e->key() )
{
case Qt::Key_E:
if (e->modifiers() & Qt::ControlModifier) {
if (activePresetIndex->hasValue())
openPresetEditorDialog(historyHash[previousFilter]->indexOf(activePresetIndex->value()));
} else
e->ignore();
case Qt::Key_L:
if (!(e->modifiers() & Qt::ControlModifier)) {
@ -651,8 +658,11 @@ void QProjectM_MainWindow::openPlaylistDialog()
QString url = m_QPlaylistFileDialog->selectedFiles() [0];
if ( !playlistModel->readPlaylist ( url ) )
if ( !playlistModel->readPlaylist ( url ) ) {
qDebug() << "could not open playlist";
url = QString();
}
qDebug() << "url: " << url;
updatePlaylistUrl(url);
@ -660,7 +670,7 @@ void QProjectM_MainWindow::openPlaylistDialog()
ui->presetSearchBarLineEdit->setText(searchText);
updateFilteredPlaylist ( ui->presetSearchBarLineEdit->text() );
}
}
}
void QProjectM_MainWindow::copyPlaylist()
{
@ -695,6 +705,7 @@ void QProjectM_MainWindow::copyPlaylist()
activePresetIndex->nullify();
qDebug() << "NULLIFIED";
}
qprojectMWidget()->releasePresetLock();
}
@ -950,7 +961,7 @@ void QProjectM_MainWindow::updateFilteredPlaylist ( const QString & text )
/// NEED A MUTEX TO STOP PROJECTM FROM SWITCHING PRESETS
playlistModel->clearItems();
assert(!qprojectM()->presetPositionValid());
Q_ASSERT(!qprojectM()->presetPositionValid());
bool presetExistsWithinFilter = false;
qDebug() << "preset position valid (preloop):" << qprojectM()->presetPositionValid();
@ -997,7 +1008,7 @@ void QProjectM_MainWindow::updateFilteredPlaylist ( const QString & text )
}
qDebug() << "preset exists within filter: " << presetExistsWithinFilter;
qDebug() << "preset position valid:" << qprojectM()->presetPositionValid();
assert(presetExistsWithinFilter == qprojectM()->presetPositionValid());
Q_ASSERT(presetExistsWithinFilter == qprojectM()->presetPositionValid());
previousFilter = filter;
qprojectMWidget()->releasePresetLock();

View File

@ -91,10 +91,9 @@ class QProjectMWidget : public QGLWidget
}
inline void releasePresetLock() {
qprojectM()->setPresetLock(m_presetWasLocked);
m_presetSeizeMutex.unlock();
inline void releasePresetLock() {
qprojectM()->setPresetLock(m_presetWasLocked);
m_presetSeizeMutex.unlock();
}
inline QProjectM * qprojectM() { return m_projectM; }
@ -326,8 +325,10 @@ protected:
void closeEvent(QCloseEvent *event);
private slots:
void selectPlaylistItem ( int rowIndex);
void clearPlaylistModel();
void openPresetEditorDialog(const QModelIndexList indices);
void openPresetEditorDialog(int rowIndex);
void aboutQt();
void clearPlaylist();
void addPresetsDialog();

View File

@ -4,6 +4,7 @@
#include "qplaylistfiledialog.hpp"
#include <QSettings>
QProjectMConfigDialog::QProjectMConfigDialog(const std::string & configFile, QProjectMWidget * qprojectMWidget, QWidget * parent, Qt::WindowFlags f) : QDialog(parent, f), _configFile(configFile), _qprojectMWidget(qprojectMWidget), _settings("projectM", "qprojectM") {
_ui.setupUi(this);
@ -22,9 +23,11 @@ void QProjectMConfigDialog::buttonBoxHandler(QAbstractButton * button) {
case QDialogButtonBox::Close:
this->hide();
break;
case QDialogButtonBox::Apply:
case QDialogButtonBox::Save:
saveConfig();
#ifdef PROJECTM_RESET_IS_THREAD_SAFE
emit(projectM_Reset());
#endif
break;
case QDialogButtonBox::Reset:
loadConfig();
@ -43,7 +46,7 @@ void QProjectMConfigDialog::openPlaylistFileDialog() {
if (dialog.exec())
{
assert(!dialog.selectedFiles().empty());
Q_ASSERT(!dialog.selectedFiles().empty());
_ui.startupPlaylistFileLineEdit->setText(dialog.selectedFiles()[0]);
}
@ -59,7 +62,7 @@ void QProjectMConfigDialog::openPlaylistDirectoryDialog() {
if (dialog.exec())
{
assert(!dialog.selectedFiles().empty());
Q_ASSERT(!dialog.selectedFiles().empty());
_ui.startupPlaylistDirectoryLineEdit->setText(dialog.selectedFiles()[0]);
}
@ -71,7 +74,7 @@ void QProjectMConfigDialog::openMenuFontFileDialog() {
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec()) {
assert(!dialog.selectedFiles().empty());
Q_ASSERT(!dialog.selectedFiles().empty());
_ui.menuFontPathLineEdit->setText(dialog.selectedFiles()[0]);
_settings.setValue("Menu Font Directory", dialog.directory().absolutePath());
@ -85,7 +88,7 @@ void QProjectMConfigDialog::openTitleFontFileDialog() {
dialog.setFileMode(QFileDialog::ExistingFile);
if (dialog.exec()) {
assert(!dialog.selectedFiles().empty());
Q_ASSERT(!dialog.selectedFiles().empty());
_ui.titleFontPathLineEdit->setText(dialog.selectedFiles()[0]);
_settings.setValue("Title Font Directory", dialog.directory().absolutePath());
}

File diff suppressed because it is too large Load Diff