diff options
author | Florian Jung <flo@windfisch.org> | 2011-05-16 12:16:44 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-05-16 12:16:44 +0000 |
commit | 2cf9d99932d8f45d5508c45729bea7af4e6ec8fd (patch) | |
tree | ea423f965efa83e841e267778f537af8de28a953 /muse2 | |
parent | 4e1ca61b03bab50d5e71e6da433503ac3b4470c0 (diff) | |
parent | 38988a37365c8772da11f3f41d49e5c1fd083084 (diff) |
set focus policy to strong in all editors
merged with trunk
Diffstat (limited to 'muse2')
24 files changed, 499 insertions, 39 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog index edf65b0b..fce03eb0 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,5 +1,19 @@ +15.05.2011: + - Changed mouse wheel behaviour in graphical editors except the score editor (rj) + * wheel scrolls left-right + * shift+wheel scrolls up-down + * control+wheel zooms horizontally + TODO: + - score editor + - zoom to where the mouse is located +14.05.2011: + - Fixed problem with project save dialog missing a forward slash '/'. (Tim) + ~/.config was being polluted with wrong folders. Fixed ProjectCreateImpl::updateDirectoryPath(). 13.05.2011: - New spanish translation from Cristian Ramos (rj) + - Added dialog to remove unused wave files (rj) + - Changed default imported midi song type to GM. (Tim) + - Added GM drums patch in MidiInstrument::populatePatchPopup() for GM songs on ch 10. (Tim) 12.05.2011: - Changed template song "default.med" song type from NO to GM, to help new users. (Tim) 10.05.2011: diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 4ec64edf..adac840a 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -53,6 +53,7 @@ #include "widgets/menutitleitem.h" #include "tools.h" #include "visibletracks.h" +#include "widgets/unusedwavefiles.h" #ifdef DSSI_SUPPORT #include "dssihost.h" @@ -964,6 +965,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() fileImportPartAction = new QAction(tr("Import Part"), this); fileImportWaveAction = new QAction(tr("Import Wave File"), this); + fileMoveWaveFiles = new QAction(tr("Find unused wave files"), this); quitAction = new QAction(tr("&Quit"), this); @@ -998,10 +1000,9 @@ MusE::MusE(int argc, char** argv) : QMainWindow() scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this); scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this); - scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); - scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); - - updateScoreMenus(); + scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); + scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); + updateScoreMenus(); startScoreEditAction = new QAction(*scoreIconSet, tr("New score window"), this); startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this); @@ -1072,6 +1073,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() autoClearAction = new QAction(QIcon(*automation_clear_dataIcon), tr("Clear Automation Data"), this); autoClearAction->setEnabled(false); + //-------- Settings Actions settingsGlobalAction = new QAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings"), this); settingsShortcutsAction = new QAction(QIcon(*settings_configureshortcutsIcon), tr("Configure Shortcuts"), this); @@ -1113,6 +1115,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() connect(fileImportPartAction, SIGNAL(activated()), SLOT(importPart())); connect(fileImportWaveAction, SIGNAL(activated()), SLOT(importWave())); + connect(fileMoveWaveFiles, SIGNAL(activated()), SLOT(findUnusedWaveFiles())); connect(quitAction, SIGNAL(activated()), SLOT(quitDoc())); //-------- Edit connections @@ -1338,6 +1341,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() menu_file->addSeparator(); menu_file->addAction(fileImportWaveAction); menu_file->addSeparator(); + menu_file->addAction(fileMoveWaveFiles); + menu_file->addSeparator(); menu_file->addAction(quitAction); menu_file->addSeparator(); @@ -5081,6 +5086,7 @@ void MusE::execDeliveredScript(int id) //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id]; song->executeScript(song->getScriptPath(id, true).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger } + //--------------------------------------------------------- // execUserScript //--------------------------------------------------------- @@ -5088,3 +5094,12 @@ void MusE::execUserScript(int id) { song->executeScript(song->getScriptPath(id, false).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger } + +//--------------------------------------------------------- +// findUnusedWaveFiles +//--------------------------------------------------------- +void MusE::findUnusedWaveFiles() +{ + UnusedWaveFiles unused(muse); + unused.exec(); +} diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 0cca50b3..70aac8fc 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -104,7 +104,8 @@ class MusE : public QMainWindow // File menu actions QAction *fileSaveAction, *fileOpenAction, *fileNewAction, *testAction; - QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction, *fileImportPartAction, *fileImportWaveAction, *quitAction; + QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction; + QAction *fileImportPartAction, *fileImportWaveAction, *fileMoveWaveFiles, *quitAction; // Edit Menu actions QAction *editCutAction, *editCopyAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction; @@ -159,7 +160,7 @@ class MusE : public QMainWindow QMenu *menu_file, *menuView, *menuSettings, *menu_help; QMenu *menuEdit, *menuStructure; - QMenu* menu_audio, *menuAutomation; + QMenu* menu_audio, *menuAutomation, *menuUtils; QMenu* menu_functions, *menuScriptPlugins; QMenu* select, *master, *midiEdit, *addTrack; @@ -246,6 +247,7 @@ class MusE : public QMainWindow void importWave(); void importPart(); void exportMidi(); + void findUnusedWaveFiles(); void toggleTransport(bool); void toggleMarker(bool); @@ -373,6 +375,7 @@ class MusE : public QMainWindow bool seqStart(); void setHeartBeat(); void importController(int, MidiPort*, int); + QString projectName() { return project.fileName(); } //QWidget* mixerWindow(); QWidget* mixer1Window(); QWidget* mixer2Window(); diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index 495c4cb8..d74bed78 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -384,6 +384,8 @@ Arranger::Arranger(QMainWindow* parent, const char* name) connect(list, SIGNAL(keyPressExt(QKeyEvent*)), canvas, SLOT(redirKeypress(QKeyEvent*))); connect(canvas, SIGNAL(selectTrackAbove()), list, SLOT(selectTrackAbove())); connect(canvas, SIGNAL(selectTrackBelow()), list, SLOT(selectTrackBelow())); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); @@ -1078,27 +1080,39 @@ void Arranger::keyPressEvent(QKeyEvent* event) key+= Qt::CTRL; if (key == shortcuts[SHRT_ZOOM_IN].key) { - int mag = hscroll->mag(); - int zoomlvl = ScrollScale::getQuickZoomLevel(mag); - if (zoomlvl < 23) - zoomlvl++; - - int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); - - hscroll->setMag(newmag); + horizontalZoomIn(); return; } else if (key == shortcuts[SHRT_ZOOM_OUT].key) { - int mag = hscroll->mag(); - int zoomlvl = ScrollScale::getQuickZoomLevel(mag); - if (zoomlvl > 1) - zoomlvl--; - - int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); - - hscroll->setMag(newmag); + horizontalZoomOut(); return; } QWidget::keyPressEvent(event); } + +void Arranger::horizontalZoomIn() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void Arranger::horizontalZoomOut() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h index 0143afd5..262d7464 100644 --- a/muse2/muse/arranger/arranger.h +++ b/muse2/muse/arranger/arranger.h @@ -122,6 +122,8 @@ class Arranger : public QWidget { void setTempo200(); //void seek(); void verticalScrollSetYpos(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); signals: void redirectWheelEvent(QWheelEvent*); diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp index 9e52498f..4fde7bf3 100644 --- a/muse2/muse/instruments/minstrument.cpp +++ b/muse2/muse/instruments/minstrument.cpp @@ -891,7 +891,13 @@ void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, b case MT_GS: mask = 2; break; case MT_GM: if(drumchan) + { + int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch + QAction* act = menu->addAction(gmdrumname); + //act->setCheckable(true); + act->setData(id); return; + } mask = 1; break; case MT_UNKNOWN: mask = 7; break; diff --git a/muse2/muse/master/lmaster.cpp b/muse2/muse/master/lmaster.cpp index 2f921cdc..9083c024 100644 --- a/muse2/muse/master/lmaster.cpp +++ b/muse2/muse/master/lmaster.cpp @@ -125,6 +125,7 @@ LMaster::LMaster() setWindowTitle(tr("MusE: Mastertrack")); setMinimumHeight(100); setFixedWidth(400); + setFocusPolicy(Qt::StrongFocus); //---------Pulldown Menu---------------------------- menuEdit = menuBar()->addMenu(tr("&Edit")); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index b5ff9447..b8d97283 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -157,6 +157,7 @@ void DrumEdit::closeEvent(QCloseEvent* e) DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned initPos) : MidiEditor(_rasterInit, pl, parent, name) { + setFocusPolicy(Qt::StrongFocus); split1w1 = 0; resize(_widthInit, _heightInit); selPart = 0; @@ -379,6 +380,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini canvas->setCanvasTools(drumeditTools); canvas->setFocus(); connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); time->setOrigin(offset, 0); QList<int> mops; diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp index 2a2bad5b..840bd1c7 100644 --- a/muse2/muse/midiedit/pianoroll.cpp +++ b/muse2/muse/midiedit/pianoroll.cpp @@ -358,6 +358,8 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i canvas->setCanvasTools(pianorollTools); canvas->setFocus(); connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); time->setOrigin(offset, 0); gridS1->setRowStretch(2, 100); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 0b4111cd..67325b75 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4126,7 +4126,6 @@ void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed) * * CURRENT TODO * o let the user change velocity of already existent notes - * o save dialog-window's values * * IMPORTANT TODO * o add a select-clef-toolbox for tracks diff --git a/muse2/muse/midieditor.cpp b/muse2/muse/midieditor.cpp index 2a6d8750..f4d21320 100644 --- a/muse2/muse/midieditor.cpp +++ b/muse2/muse/midieditor.cpp @@ -226,3 +226,30 @@ void MidiEditor::setCurCanvasPart(Part* part) canvas->setCurrentPart(part); } +void MidiEditor::horizontalZoomIn() +{ + printf("zoom in \n"); + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void MidiEditor::horizontalZoomOut() +{ + printf("zoom out \n"); + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/midieditor.h b/muse2/muse/midieditor.h index 00272529..78873a6a 100644 --- a/muse2/muse/midieditor.h +++ b/muse2/muse/midieditor.h @@ -55,7 +55,9 @@ class MidiEditor : public TopWin { public slots: void songChanged(int type); void setCurDrumInstrument(int instr); - + void horizontalZoomIn(); + void horizontalZoomOut(); + virtual void updateHScrollRange() { }; signals: void curDrumInstrumentChanged(int); diff --git a/muse2/muse/midifile.cpp b/muse2/muse/midifile.cpp index 21e3e882..65cb6d25 100644 --- a/muse2/muse/midifile.cpp +++ b/muse2/muse/midifile.cpp @@ -60,7 +60,7 @@ MidiFile::MidiFile(FILE* f) { fp = f; curPos = 0; - _mtype = MT_GM; + _mtype = MT_GM; // MT_UNKNOWN; _error = MF_NO_ERROR; _tracks = new MidiFileTrackList; } diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp index 99dfd5f1..7a5ad815 100644 --- a/muse2/muse/waveedit/waveedit.cpp +++ b/muse2/muse/waveedit/waveedit.cpp @@ -65,6 +65,7 @@ WaveEdit::WaveEdit(PartList* pl) : MidiEditor(1, pl) { resize(_widthInit, _heightInit); + setFocusPolicy(Qt::StrongFocus); QSignalMapper* mapper = new QSignalMapper(this); QAction* act; @@ -223,6 +224,9 @@ WaveEdit::WaveEdit(PartList* pl) ymag->setFixedWidth(16); connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int))); connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int))); + connect(view, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(view, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); + time->setOrigin(0, 0); mainGrid->setRowStretch(0, 100); @@ -247,6 +251,8 @@ WaveEdit::WaveEdit(PartList* pl) // connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); connect(view, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); + connect(view, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned))); + connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange())); connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); @@ -526,3 +532,29 @@ void WaveEdit::moveVerticalSlider(int val) ymag->setValue(ymag->value() + val); } + +void WaveEdit::horizontalZoomIn() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void WaveEdit::horizontalZoomOut() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/waveedit/waveedit.h b/muse2/muse/waveedit/waveedit.h index 5c06d37f..e966a635 100644 --- a/muse2/muse/waveedit/waveedit.h +++ b/muse2/muse/waveedit/waveedit.h @@ -71,6 +71,9 @@ class WaveEdit : public MidiEditor { void configChanged(); virtual void updateHScrollRange(); + void horizontalZoomIn(); + void horizontalZoomOut(); + signals: void deleted(unsigned long); diff --git a/muse2/muse/waveedit/waveview.cpp b/muse2/muse/waveedit/waveview.cpp index f83ae1d5..0c387f72 100644 --- a/muse2/muse/waveedit/waveview.cpp +++ b/muse2/muse/waveedit/waveview.cpp @@ -25,6 +25,7 @@ #include "waveedit.h" #include "audio.h" #include "gconfig.h" +#include "fastlog.h" bool modifyWarnedYet = false; //--------------------------------------------------------- @@ -381,14 +382,52 @@ void WaveView::viewMousePressEvent(QMouseEvent* event) viewMouseMoveEvent(event); } - +#define WHEEL_STEPSIZE 40 +#define WHEEL_DELTA 120 //--------------------------------------------------------- // wheelEvent //--------------------------------------------------------- -void WaveView::wheelEvent(QWheelEvent* event) - { - emit mouseWheelMoved(event->delta() / 10); - } +void WaveView::wheelEvent(QWheelEvent* ev) +{ + int keyState = ev->modifiers(); + + bool shift = keyState & Qt::ShiftModifier; + bool alt = keyState & Qt::AltModifier; + bool ctrl = keyState & Qt::ControlModifier; + + if (shift) { // scroll vertically + emit mouseWheelMoved(ev->delta() / 10); + + } else if (ctrl) { // zoom horizontally + if (ev->delta()>0) + emit horizontalZoomIn(); + else + emit horizontalZoomOut(); + + } else { // scroll horizontally + int delta = ev->delta() / WHEEL_DELTA; + int xpixelscale = 5*fast_log10(rmapxDev(1)); + + + if (xpixelscale <= 0) + xpixelscale = 1; + + int scrollstep = WHEEL_STEPSIZE * (delta); + ///if (ev->state() == Qt::ShiftModifier) +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 10; + + int newXpos = xpos + xpixelscale * scrollstep; + + if (newXpos < 0) + newXpos = 0; + + //setYPos(newYpos); + emit horizontalScroll((unsigned)newXpos); + + } + +} //--------------------------------------------------------- // viewMouseReleaseEvent diff --git a/muse2/muse/waveedit/waveview.h b/muse2/muse/waveedit/waveview.h index 3ee0d5f8..c7992952 100644 --- a/muse2/muse/waveedit/waveview.h +++ b/muse2/muse/waveedit/waveview.h @@ -88,6 +88,9 @@ class WaveView : public View { void followEvent(int); void timeChanged(unsigned); void mouseWheelMoved(int); + void horizontalScroll(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); public: WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale); diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt index feb86816..0ca33d5a 100644 --- a/muse2/muse/widgets/CMakeLists.txt +++ b/muse2/muse/widgets/CMakeLists.txt @@ -75,7 +75,8 @@ QT4_WRAP_CPP (widget_mocs tools.h # ttoolbar.h ttoolbutton.h - velocity.h + unusedwavefiles.h + velocity.h quantize.h move.h remove.h @@ -115,7 +116,8 @@ file (GLOB widgets_ui_files songinfo.ui synthconfigbase.ui transformbase.ui - transposebase.ui + transposebase.ui + unusedwavefiles.ui velocitybase.ui quantbase.ui movebase.ui @@ -187,7 +189,8 @@ file (GLOB widgets_source_files tools.cpp ttoolbar.cpp ttoolbutton.cpp - utils.cpp + unusedwavefiles.cpp + utils.cpp velocity.cpp quantize.cpp move.cpp diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp index c12ac956..18de985b 100644 --- a/muse2/muse/widgets/canvas.cpp +++ b/muse2/muse/widgets/canvas.cpp @@ -24,6 +24,7 @@ #include "icons.h" #include "../marker/marker.h" #include "part.h" +#include "fastlog.h" #define ABS(x) ((x) < 0) ? -(x) : (x) @@ -338,7 +339,13 @@ void Canvas::draw(QPainter& p, const QRect& rect) // wheelEvent //--------------------------------------------------------- void Canvas::wheelEvent(QWheelEvent* ev) - { +{ + int keyState = ev->modifiers(); + + bool shift = keyState & Qt::ShiftModifier; + bool ctrl = keyState & Qt::ControlModifier; + + if (shift) { // scroll vertically int delta = ev->delta() / WHEEL_DELTA; int ypixelscale = rmapyDev(1); @@ -347,8 +354,8 @@ void Canvas::wheelEvent(QWheelEvent* ev) int scrollstep = WHEEL_STEPSIZE * (-delta); ///if (ev->state() == Qt::ShiftModifier) - if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) - scrollstep = scrollstep / 10; +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 2; int newYpos = ypos + ypixelscale * scrollstep; @@ -358,7 +365,36 @@ void Canvas::wheelEvent(QWheelEvent* ev) //setYPos(newYpos); emit verticalScroll((unsigned)newYpos); - } + } else if (ctrl) { // zoom horizontally + if (ev->delta()>0) + emit horizontalZoomIn(); + else + emit horizontalZoomOut(); + + } else { // scroll horizontally + int delta = ev->delta() / WHEEL_DELTA; + int xpixelscale = 5*fast_log10(rmapxDev(1)); + + + if (xpixelscale <= 0) + xpixelscale = 1; + + int scrollstep = WHEEL_STEPSIZE * (delta); + ///if (ev->state() == Qt::ShiftModifier) +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 10; + + int newXpos = xpos + xpixelscale * scrollstep; + + if (newXpos < 0) + newXpos = 0; + + //setYPos(newYpos); + emit horizontalScroll((unsigned)newXpos); + + } + +} void Canvas::redirectedWheelEvent(QWheelEvent* ev) { diff --git a/muse2/muse/widgets/canvas.h b/muse2/muse/widgets/canvas.h index 97392f1e..6e8b9fa8 100644 --- a/muse2/muse/widgets/canvas.h +++ b/muse2/muse/widgets/canvas.h @@ -174,6 +174,8 @@ class Canvas : public View { void verticalScroll(unsigned); void horizontalScroll(unsigned); void horizontalScrollNoLimit(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); public: Canvas(QWidget* parent, int sx, int sy, const char* name = 0); bool isSingleSelection(); diff --git a/muse2/muse/widgets/projectcreateimpl.cpp b/muse2/muse/widgets/projectcreateimpl.cpp index d455c917..369e806a 100644 --- a/muse2/muse/widgets/projectcreateimpl.cpp +++ b/muse2/muse/widgets/projectcreateimpl.cpp @@ -45,12 +45,13 @@ void ProjectCreateImpl::updateDirectoryPath() if (createFolderCheckbox->isChecked()) { if (!projectNameEdit->text().isEmpty()) name = projectNameEdit->text() + "/" + projectNameEdit->text() + ".med"; - storageDirEdit->setText(directoryPath + name ); + //storageDirEdit->setText(directoryPath + name ); } else { if (!projectNameEdit->text().isEmpty()) name = projectNameEdit->text() + ".med"; - storageDirEdit->setText(directoryPath +"/" + name); + //storageDirEdit->setText(directoryPath +"/" + name); } + storageDirEdit->setText(directoryPath +"/" + name ); // Tim } QString ProjectCreateImpl::getProjectPath() diff --git a/muse2/muse/widgets/unusedwavefiles.cpp b/muse2/muse/widgets/unusedwavefiles.cpp new file mode 100644 index 00000000..5a2e620b --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.cpp @@ -0,0 +1,97 @@ +#include <stdio.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <qstringlist.h> +#include <qtextstream.h> +#include <qmessagebox.h> +#include "unusedwavefiles.h" +#include "ui_unusedwavefiles.h" +#include "globals.h" +#include "app.h" + +UnusedWaveFiles::UnusedWaveFiles(QWidget *parent) : + QDialog(parent), + ui(new Ui::UnusedWaveFiles) +{ + + ui->setupUi(this); + ui->currentProjRadioButton->setChecked(true); + connect(ui->currentProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles())); + connect(ui->allProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles())); + findWaveFiles(); + +} + +void UnusedWaveFiles::findWaveFiles() +{ + ui->filelistWidget->clear(); + //printf("museProject =%s\n", museProject.toLatin1().data()); +// QFileInfo proj(museProject); +// QString projPath = proj.absolutePath(); + QDir dir(museProject); + QStringList filter; + filter.append("*.wav"); + filter.append("*.ogg"); + allWaveFiles= dir.entryList(filter); + if (!allWaveFiles.count()) + return; + // get med files + QStringList medFiles; + if (ui->currentProjRadioButton->isChecked()) { + medFiles.append(muse->projectName()); + } else { + //printf("get ALLL *.med files!\n"); + QStringList medFilter("*.med"); + medFiles = dir.entryList(medFilter); + } + foreach (QString medFile, medFiles) { + QString fname = museProject+"/"+ medFile; + //printf("fopen %s\n", fname.toLatin1().data()); + FILE *fp =fopen(fname.toLatin1().data(),"r"); + QTextStream fileContent(fp); + while (!fileContent.atEnd()) { + QString line = fileContent.readLine(); + if (line.contains(".wav") || line.contains(".ogg")) { // optimization + foreach (QString wav, allWaveFiles) { + //printf("checking wav [%s]\n", wav.toLatin1().data() ); + if (line.contains(wav)) { + //int beforeSize=allWaveFiles.size(); + allWaveFiles.removeOne(wav); + //printf("removed one from list, %d %d\n", beforeSize, allWaveFiles.size()); + break; + } + } + } + } + fclose(fp); + } + + ui->filelistWidget->addItems(allWaveFiles); + update(); +} + +UnusedWaveFiles::~UnusedWaveFiles() +{ + delete ui; +} + +void UnusedWaveFiles::accept() +{ + int ret = QMessageBox::question(this,"Move files", "Are you sure you want to move away the unused files?", + QMessageBox::Ok, QMessageBox::Cancel); + if (ret == QMessageBox::Ok) { + QDir currDir(museProject); + currDir.mkdir("unused"); + + foreach(QString file, allWaveFiles) { + QFile::rename(museProject+ "/"+file, museProject + "/unused/" +file); + // move the wca file if it exists + QFileInfo wf(museProject + "/" + file); + if (QFile::exists(museProject + "/" + wf.baseName()+".wca")) { + QFile::rename(museProject + "/" + wf.baseName()+".wca", museProject + "/unused/" +wf.baseName()+".wca"); + + } + } + } + QDialog::accept(); +} diff --git a/muse2/muse/widgets/unusedwavefiles.h b/muse2/muse/widgets/unusedwavefiles.h new file mode 100644 index 00000000..fd1f524c --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.h @@ -0,0 +1,25 @@ +#ifndef UNUSEDWAVEFILES_H +#define UNUSEDWAVEFILES_H + +#include <QDialog> + +namespace Ui { + class UnusedWaveFiles; +} + +class UnusedWaveFiles : public QDialog +{ + Q_OBJECT + QStringList allWaveFiles; +public: + explicit UnusedWaveFiles(QWidget *parent = 0); + ~UnusedWaveFiles(); + +public slots: + void accept(); + void findWaveFiles(); +private: + Ui::UnusedWaveFiles *ui; +}; + +#endif // UNUSEDWAVEFILES_H diff --git a/muse2/muse/widgets/unusedwavefiles.ui b/muse2/muse/widgets/unusedwavefiles.ui new file mode 100644 index 00000000..65c8c804 --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.ui @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UnusedWaveFiles</class> + <widget class="QDialog" name="UnusedWaveFiles"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>508</width> + <height>241</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>List of unused audio files in current project directory:</string> + </property> + </widget> + </item> + <item row="0" column="1" rowspan="2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="currentProjRadioButton"> + <property name="text"> + <string>Current project</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="allProjRadioButton"> + <property name="text"> + <string>All .med files +in current + directory</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QListWidget" name="filelistWidget"/> + </item> + <item row="2" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>98</width> + <height>17</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="moveButton"> + <property name="text"> + <string>Move files to 'unused' subdir</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>UnusedWaveFiles</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>416</x> + <y>331</y> + </hint> + <hint type="destinationlabel"> + <x>305</x> + <y>183</y> + </hint> + </hints> + </connection> + <connection> + <sender>moveButton</sender> + <signal>clicked()</signal> + <receiver>UnusedWaveFiles</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>266</x> + <y>321</y> + </hint> + <hint type="destinationlabel"> + <x>305</x> + <y>183</y> + </hint> + </hints> + </connection> + </connections> +</ui> |