summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-02-27 21:21:15 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-02-27 21:21:15 +0000
commit5524994708ff00769777f423c681faaa3c2af314 (patch)
tree910a59d34f1c546b313f8c3413618918d72fbf5d /muse2
parent1a4f5609b180772326e48aaca43b0ac02ff8f268 (diff)
D&D fixes ...dungeons and dragons?! better check the changelog
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog2
-rw-r--r--muse2/muse/arranger/pcanvas.cpp53
-rw-r--r--muse2/muse/globals.cpp47
-rw-r--r--muse2/muse/globals.h2
-rw-r--r--muse2/muse/mixer/rack.cpp35
-rw-r--r--muse2/muse/waveedit/waveview.cpp50
-rw-r--r--muse2/muse/waveedit/waveview.h2
-rw-r--r--muse2/muse/widgets/filedialog.cpp7
-rw-r--r--muse2/muse/widgets/filedialog.h2
9 files changed, 121 insertions, 79 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index ddf700ba..d7fc5dc1 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,5 +1,7 @@
27.02.2011:
- Fixed piano roll controller graph text drawing (finally!). (Tim)
+ - Fixed crashes in drag & drop for plugins and drag presets from outside muse into a plugin (rj)
+ - Support for multiple drops of files to arranger, e.g easy import of a bunch of wave files (rj)
26.02.2011:
- Fixed some piano roll controller graph drawing issues. (Tim)
Draw velocities on top of grid, but draw non-velocity items behind grid.
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 189c7b76..43045987 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -462,6 +462,8 @@ bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t)
}
if (ntrack >= tracks->size()) {
ntrack = tracks->size();
+ if (debugMsg)
+ printf("PartCanvas::moveItem - add new track\n");
Track* newTrack = song->addTrack(int(type));
if (type == Track::WAVE) {
WaveTrack* st = (WaveTrack*) track;
@@ -471,7 +473,6 @@ bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t)
emit tracklistChanged();
}
Track* dtrack = tracks->index(ntrack);
-
if (dtrack->type() != type) {
QMessageBox::critical(this, QString("MusE"),
tr("Cannot copy/move/clone to different Track-Type"));
@@ -525,16 +526,19 @@ bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t)
else if (t == MOVE_MOVE) {
dpart->setSelected(spart->selected());
// These will increment ref count if not a clone, and will chain clones...
- if (dtrack->type() == Track::WAVE)
+
+ if (dtrack->type() == Track::WAVE) {
// Indicate no undo, and do not do port controller values and clone parts.
//audio->msgChangePart((WavePart*)spart, (WavePart*)dpart,false);
audio->msgChangePart((WavePart*)spart, (WavePart*)dpart, false, false, false);
- else
+ }
+ else {
// Indicate no undo, and do port controller values but not clone parts.
//audio->msgChangePart(spart, dpart, false);
audio->msgChangePart(spart, dpart, false, true, false);
-
+ }
spart->setSelected(false);
+
}
//printf("PartCanvas::moveItem after add/changePart spart:%p events:%p refs:%d Arefs:%d dpart:%p events:%p refs:%d Arefs:%d\n", spart, spart->events(), spart->events()->refCount(), spart->events()->arefCount(), dpart, dpart->events(), dpart->events()->refCount(), dpart->events()->arefCount());
@@ -2686,7 +2690,8 @@ void PartCanvas::dragLeaveEvent(QDragLeaveEvent*)
void PartCanvas::viewDropEvent(QDropEvent* event)
{
- //printf("void PartCanvas::viewDropEvent(QDropEvent* event)\n");
+ if (debugMsg)
+ printf("void PartCanvas::viewDropEvent(QDropEvent* event)\n");
if (event->source() == this) {
printf("local DROP\n");
//event->ignore(); // TODO CHECK Tim.
@@ -2718,6 +2723,7 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
if (type == 1)
{
+ printf("type1\n");
text = QString(event->mimeData()->data("text/partlist"));
int x = AL::sigmap.raster(event->pos().x(), *_raster);
@@ -2735,23 +2741,32 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
}
else if (type == 2)
{
- // Multiple urls not supported here. Grab the first one.
- text = event->mimeData()->urls()[0].path();
+ unsigned trackNo = y2pitch(event->pos().y());
+ Track* track = 0;
+ if (trackNo < tracks->size())
+ track = tracks->index(trackNo);
+ printf("trackNo=%d\n, trackNo track=%d\n", trackNo, track);
+ int x = AL::sigmap.raster(event->pos().x(), *_raster);
+ if (x < 0)
+ x = 0;
+
+ foreach(QUrl url, event->mimeData()->urls())
+ {
+ text = url.path();
if (text.endsWith(".wav",Qt::CaseInsensitive) ||
text.endsWith(".ogg",Qt::CaseInsensitive) ||
text.endsWith(".mpt", Qt::CaseInsensitive) )
{
- int x = AL::sigmap.raster(event->pos().x(), *_raster);
- if (x < 0)
- x = 0;
- unsigned trackNo = y2pitch(event->pos().y());
- Track* track = 0;
- if (trackNo < tracks->size())
- track = tracks->index(trackNo);
- if (track)
- {
- if (track->type() == Track::WAVE &&
+
+ if (!track) { // we need to create a track for this drop
+ if (text.endsWith(".mpt", Qt::CaseInsensitive)) {
+ track = song->addTrack((Track::MIDI));
+ } else {
+ track = song->addTrack((Track::WAVE));
+ }
+ }
+ if (track->type() == Track::WAVE &&
(text.endsWith(".wav", Qt::CaseInsensitive) ||
(text.endsWith(".ogg", Qt::CaseInsensitive))))
{
@@ -2764,11 +2779,11 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
unsigned tick = x;
muse->importPartToTrack(text, tick, track);
}
- }
}
else if(text.endsWith(".med",Qt::CaseInsensitive))
{
emit dropSongFile(text);
+ break; // we only support ONE drop of this kind
}
else if(text.endsWith(".mid",Qt::CaseInsensitive))
{
@@ -2778,6 +2793,8 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
{
printf("dropped... something... no hable...\n");
}
+ track=0;
+ }
}
// Restore backup of the clone list, to retain any 'copy' items,
diff --git a/muse2/muse/globals.cpp b/muse2/muse/globals.cpp
index f53846f9..80990f0e 100644
--- a/muse2/muse/globals.cpp
+++ b/muse2/muse/globals.cpp
@@ -397,3 +397,50 @@ void undoSetuid()
#endif
}
+//---------------------------------------------------------
+// getUniqueTmpfileName
+//---------------------------------------------------------
+bool getUniqueTmpfileName(QString subDir, QString ext,QString& newFilename)
+ {
+ // Check if tmp-directory exists under project path
+ QString tmpInDir = museProject + "/" + subDir;
+ QFileInfo tmpdirfi(tmpInDir);
+ if (!tmpdirfi.isDir()) {
+ // Try to create a tmpdir
+ QDir projdir(museProject);
+ if (!projdir.mkdir(subDir)) {
+ printf("Could not create tmp dir %s!\n", tmpInDir.toLatin1().data() );
+ return false;
+ }
+ }
+
+
+ tmpdirfi.setFile(tmpInDir);
+
+ if (!tmpdirfi.isWritable()) {
+ printf("Temp directory is not writable - aborting\n");
+ return false;
+ }
+
+ QDir tmpdir = tmpdirfi.dir();
+
+ // Find a new filename
+ for (int i=0; i<10000; i++) {
+ QString filename = "muse_tmp";
+ filename.append(QString::number(i));
+ if (!ext.startsWith("."))
+ filename.append(".");
+ filename.append(ext);
+
+ if (!tmpdir.exists(tmpInDir +"/" + filename)) {
+ newFilename = tmpInDir + "/" + filename;
+ if (debugMsg)
+ printf("returning temporary filename %s\n", newFilename.toLatin1().data());
+ return true;
+ }
+
+ }
+
+ printf("Could not find a suitable tmpfilename (more than 10000 tmpfiles in tmpdir - clean up!\n");
+ return false;
+ }
diff --git a/muse2/muse/globals.h b/muse2/muse/globals.h
index cb4da0c5..151e7800 100644
--- a/muse2/muse/globals.h
+++ b/muse2/muse/globals.h
@@ -187,5 +187,7 @@ extern uid_t euid, ruid;
extern void doSetuid();
extern void undoSetuid();
extern bool checkAudioDevice();
+extern bool getUniqueTmpfileName(QString subDir, QString ext, QString& newFilename);
+
#endif
diff --git a/muse2/muse/mixer/rack.cpp b/muse2/muse/mixer/rack.cpp
index 54cc75b2..7cc5b077 100644
--- a/muse2/muse/mixer/rack.cpp
+++ b/muse2/muse/mixer/rack.cpp
@@ -375,7 +375,18 @@ void EffectRack::savePreset(int idx)
void EffectRack::startDrag(int idx)
{
- FILE* tmp = tmpfile();
+ if (idx < 0) {
+ printf("illegal to drag index %d\n",idx);
+ return;
+ }
+ FILE *tmp;
+ if (debugMsg) {
+ QString fileName;
+ getUniqueTmpfileName("tmp","preset", fileName);
+ tmp = fopen(fileName.toLatin1().data(), "w+");
+ }
+ else
+ tmp = tmpfile();
if (tmp == 0) {
fprintf(stderr, "EffectRack::startDrag fopen failed: %s\n",
strerror(errno));
@@ -416,12 +427,15 @@ void EffectRack::startDrag(int idx)
Qt::DropActions EffectRack::supportedDropActions () const
{
- return Qt::CopyAction;
+ return Qt::CopyAction | Qt::MoveAction;
}
QStringList EffectRack::mimeTypes() const
{
- return QStringList("text/x-muse-plugin");
+ QStringList mTypes;
+ mTypes << "text/uri-list";
+ mTypes << "text/x-muse-plugin";
+ return mTypes;
}
void EffectRack::dropEvent(QDropEvent *event)
@@ -501,8 +515,7 @@ void EffectRack::dropEvent(QDropEvent *event)
void EffectRack::dragEnterEvent(QDragEnterEvent *event)
{
- ///event->accept(Q3TextDrag::canDecode(event));
- event->acceptProposedAction(); // TODO CHECK Tim.
+ event->acceptProposedAction(); // TODO CHECK Tim.
}
void EffectRack::mousePressEvent(QMouseEvent *event)
@@ -525,7 +538,7 @@ void EffectRack::mousePressEvent(QMouseEvent *event)
}
void EffectRack::mouseMoveEvent(QMouseEvent *event)
- {
+{
if (event->buttons() & Qt::LeftButton) {
Pipeline* pipe = track->efxPipe();
if(!pipe)
@@ -539,12 +552,14 @@ void EffectRack::mouseMoveEvent(QMouseEvent *event)
int distance = (dragPos-event->pos()).manhattanLength();
if (distance > QApplication::startDragDistance()) {
QListWidgetItem *i = itemAt( event->pos() );
- int idx = row(i);
- startDrag(idx);
- }
+ if (i) {
+ int idx = row(i);
+ startDrag(idx);
+ }
}
- QListWidget::mouseMoveEvent(event);
}
+ QListWidget::mouseMoveEvent(event);
+}
void EffectRack::initPlugin(Xml xml, int idx)
diff --git a/muse2/muse/waveedit/waveview.cpp b/muse2/muse/waveedit/waveview.cpp
index fab731ba..f83ae1d5 100644
--- a/muse2/muse/waveedit/waveview.cpp
+++ b/muse2/muse/waveedit/waveview.cpp
@@ -674,7 +674,7 @@ void WaveView::modifySelection(int operation, unsigned startpos, unsigned stoppo
unsigned file_channels = file.channels();
QString tmpWavFile = QString::null;
- if (!getUniqueTmpfileName(tmpWavFile)) {
+ if (!getUniqueTmpfileName("tmp_musewav",".wav", tmpWavFile)) {
break;
}
@@ -780,7 +780,7 @@ void WaveView::copySelection(unsigned file_channels, float** tmpdata, unsigned l
if (copiedPart!="") {
QFile::remove(copiedPart);
}
- if (!getUniqueTmpfileName(copiedPart)) {
+ if (!getUniqueTmpfileName("tmp_musewav",".wav", copiedPart)) {
return;
}
@@ -897,7 +897,7 @@ void WaveView::editExternal(unsigned file_format, unsigned file_samplerate, unsi
{
// Create yet another tmp-file
QString exttmpFileName;
- if (!getUniqueTmpfileName(exttmpFileName)) {
+ if (!getUniqueTmpfileName("tmp_musewav",".wav", exttmpFileName)) {
printf("Could not create temp file - aborting...\n");
return;
}
@@ -963,48 +963,4 @@ void WaveView::editExternal(unsigned file_format, unsigned file_samplerate, unsi
}
}
-//---------------------------------------------------------
-// getUniqueTmpfileName
-//---------------------------------------------------------
-bool WaveView::getUniqueTmpfileName(QString& newFilename)
- {
- // Check if tmp-directory exists under project path
- QString tmpWavDir = museProject + "/tmp_musewav"; //!@TODO: Don't hardcode like this
- QFileInfo tmpdirfi(tmpWavDir);
- if (!tmpdirfi.isDir()) {
- // Try to create a tmpdir
- QDir projdir(museProject);
- if (!projdir.mkdir("tmp_musewav")) {
- printf("Could not create undo dir!\n");
- return false;
- }
- }
-
-
- tmpdirfi.setFile(tmpWavDir);
-
- if (!tmpdirfi.isWritable()) {
- printf("Temp directory is not writable - aborting\n");
- return false;
- }
-
- QDir tmpdir = tmpdirfi.dir();
-
- // Find a new filename
- for (int i=0; i<10000; i++) {
- QString filename = "muse_tmp";
- filename.append(QString::number(i));
- filename.append(".wav");
-
- if (!tmpdir.exists(tmpWavDir +"/" + filename)) {
- newFilename = tmpWavDir + "/" + filename;
- return true;
- }
-
- }
-
- printf("Could not find a suitable tmpfilename (more than 10000 tmpfiles in tmpdir - clean up!\n");
- return false;
- }
-
diff --git a/muse2/muse/waveedit/waveview.h b/muse2/muse/waveedit/waveview.h
index 53b0c76f..3ee0d5f8 100644
--- a/muse2/muse/waveedit/waveview.h
+++ b/muse2/muse/waveedit/waveview.h
@@ -58,7 +58,7 @@ class WaveView : public View {
virtual void viewMouseReleaseEvent(QMouseEvent*);
virtual void wheelEvent(QWheelEvent*);
- bool getUniqueTmpfileName(QString& newFilename); //!< Generates unique filename for temporary SndFile
+ //bool getUniqueTmpfileName(QString& newFilename); //!< Generates unique filename for temporary SndFile
WaveSelectionList getSelection(unsigned startpos, unsigned stoppos);
int lastGainvalue; //!< Stores the last used gainvalue when specifiying gain value in the editgain dialog
diff --git a/muse2/muse/widgets/filedialog.cpp b/muse2/muse/widgets/filedialog.cpp
index d2b189b6..3bfc9bef 100644
--- a/muse2/muse/widgets/filedialog.cpp
+++ b/muse2/muse/widgets/filedialog.cpp
@@ -19,8 +19,8 @@
#include "gconfig.h"
MFileDialog::ViewType MFileDialog::lastViewUsed = GLOBAL_VIEW;
-QString MFileDialog::lastUserDir = "";
-QString MFileDialog::lastGlobalDir = "";
+//QString MFileDialog::lastUserDir = "";
+//QString MFileDialog::lastGlobalDir = "";
//---------------------------------------------------------
// createDir
@@ -155,6 +155,9 @@ MFileDialog::MFileDialog(const QString& dir,
: QFileDialog(parent, QString(), QString("."), filter)
{
showButtons = false;
+ lastUserDir = "";
+ lastGlobalDir = "";
+
if (dir.length() > 0 && dir[0] == QChar('/')) {
setDirectory(dir);
}
diff --git a/muse2/muse/widgets/filedialog.h b/muse2/muse/widgets/filedialog.h
index 0d3dfc8c..6aaf091c 100644
--- a/muse2/muse/widgets/filedialog.h
+++ b/muse2/muse/widgets/filedialog.h
@@ -33,7 +33,7 @@ class FileDialogButtonsWidget : public QWidget, public Ui::FileDialogButtons
class MFileDialog : public QFileDialog {
Q_OBJECT
- static QString lastUserDir, lastGlobalDir;
+ QString lastUserDir, lastGlobalDir;
bool showButtons;
QString baseDir;