Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 358:2da91cceed64 tonioni
Some tidying & fixing compiler warnings
author | Chris Cannam |
---|---|
date | Thu, 12 Jun 2014 18:52:52 +0100 |
parents | 337cdb5e5b06 |
children | 1f2a4ad79967 |
comparison
equal
deleted
inserted
replaced
357:337cdb5e5b06 | 358:2da91cceed64 |
---|---|
281 if (menu) finaliseMenu(menu); | 281 if (menu) finaliseMenu(menu); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 void | 285 void |
286 MainWindowBase::finaliseMenu(QMenu *menu) | 286 MainWindowBase::finaliseMenu(QMenu * |
287 #ifdef Q_OS_MAC | |
288 menu | |
289 #endif | |
290 ) | |
287 { | 291 { |
288 #ifdef Q_OS_MAC | 292 #ifdef Q_OS_MAC |
289 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and | 293 // See https://bugreports.qt-project.org/browse/QTBUG-38256 and |
290 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 -- | 294 // our issue #890 http://code.soundsoftware.ac.uk/issues/890 -- |
291 // single-key shortcuts that are associated only with a menu | 295 // single-key shortcuts that are associated only with a menu |
368 | 372 |
369 QString | 373 QString |
370 MainWindowBase::getOpenFileName(FileFinder::FileType type) | 374 MainWindowBase::getOpenFileName(FileFinder::FileType type) |
371 { | 375 { |
372 FileFinder *ff = FileFinder::getInstance(); | 376 FileFinder *ff = FileFinder::getInstance(); |
373 switch (type) { | 377 |
374 case FileFinder::SessionFile: | 378 if (type == FileFinder::AnyFile) { |
375 return ff->getOpenFileName(type, m_sessionFile); | |
376 case FileFinder::AudioFile: | |
377 return ff->getOpenFileName(type, m_audioFile); | |
378 case FileFinder::LayerFile: | |
379 return ff->getOpenFileName(type, m_sessionFile); | |
380 case FileFinder::LayerFileNoMidi: | |
381 return ff->getOpenFileName(type, m_sessionFile); | |
382 case FileFinder::LayerFileNonSV: | |
383 return ff->getOpenFileName(type, m_sessionFile); | |
384 case FileFinder::LayerFileNoMidiNonSV: | |
385 return ff->getOpenFileName(type, m_sessionFile); | |
386 case FileFinder::SessionOrAudioFile: | |
387 return ff->getOpenFileName(type, m_sessionFile); | |
388 case FileFinder::ImageFile: | |
389 return ff->getOpenFileName(type, m_sessionFile); | |
390 case FileFinder::CSVFile: | |
391 return ff->getOpenFileName(type, m_sessionFile); | |
392 case FileFinder::AnyFile: | |
393 if (getMainModel() != 0 && | 379 if (getMainModel() != 0 && |
394 m_paneStack != 0 && | 380 m_paneStack != 0 && |
395 m_paneStack->getCurrentPane() != 0) { // can import a layer | 381 m_paneStack->getCurrentPane() != 0) { // can import a layer |
396 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile); | 382 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile); |
397 } else { | 383 } else { |
398 return ff->getOpenFileName(FileFinder::SessionOrAudioFile, | 384 return ff->getOpenFileName(FileFinder::SessionOrAudioFile, |
399 m_sessionFile); | 385 m_sessionFile); |
400 } | 386 } |
401 } | 387 } |
402 return ""; | 388 |
389 QString lastPath = m_sessionFile; | |
390 | |
391 if (type == FileFinder::AudioFile) { | |
392 lastPath = m_audioFile; | |
393 } | |
394 | |
395 return ff->getOpenFileName(type, lastPath); | |
403 } | 396 } |
404 | 397 |
405 QString | 398 QString |
406 MainWindowBase::getSaveFileName(FileFinder::FileType type) | 399 MainWindowBase::getSaveFileName(FileFinder::FileType type) |
407 { | 400 { |
401 QString lastPath = m_sessionFile; | |
402 | |
403 if (type == FileFinder::AudioFile) { | |
404 lastPath = m_audioFile; | |
405 } | |
406 | |
408 FileFinder *ff = FileFinder::getInstance(); | 407 FileFinder *ff = FileFinder::getInstance(); |
409 switch (type) { | 408 return ff->getSaveFileName(type, lastPath); |
410 case FileFinder::SessionFile: | |
411 return ff->getSaveFileName(type, m_sessionFile); | |
412 case FileFinder::AudioFile: | |
413 return ff->getSaveFileName(type, m_audioFile); | |
414 case FileFinder::LayerFile: | |
415 return ff->getSaveFileName(type, m_sessionFile); | |
416 case FileFinder::LayerFileNoMidi: | |
417 return ff->getSaveFileName(type, m_sessionFile); | |
418 case FileFinder::LayerFileNonSV: | |
419 return ff->getSaveFileName(type, m_sessionFile); | |
420 case FileFinder::LayerFileNoMidiNonSV: | |
421 return ff->getSaveFileName(type, m_sessionFile); | |
422 case FileFinder::SessionOrAudioFile: | |
423 return ff->getSaveFileName(type, m_sessionFile); | |
424 case FileFinder::ImageFile: | |
425 return ff->getSaveFileName(type, m_sessionFile); | |
426 case FileFinder::CSVFile: | |
427 return ff->getSaveFileName(type, m_sessionFile); | |
428 case FileFinder::AnyFile: | |
429 return ff->getSaveFileName(type, m_sessionFile); | |
430 } | |
431 return ""; | |
432 } | 409 } |
433 | 410 |
434 void | 411 void |
435 MainWindowBase::registerLastOpenedFilePath(FileFinder::FileType type, QString path) | 412 MainWindowBase::registerLastOpenedFilePath(FileFinder::FileType type, QString path) |
436 { | 413 { |
822 if (!clipboard.empty()) { | 799 if (!clipboard.empty()) { |
823 long firstEventFrame = clipboard.getPoints()[0].getFrame(); | 800 long firstEventFrame = clipboard.getPoints()[0].getFrame(); |
824 long offset = 0; | 801 long offset = 0; |
825 if (firstEventFrame < 0) { | 802 if (firstEventFrame < 0) { |
826 offset = (long)pos - firstEventFrame; | 803 offset = (long)pos - firstEventFrame; |
827 } else if (firstEventFrame < pos) { | 804 } else if ((unsigned long)firstEventFrame < pos) { |
828 offset = pos - (unsigned long)firstEventFrame; | 805 offset = pos - (unsigned long)firstEventFrame; |
829 } else { | 806 } else { |
830 offset = -((unsigned long)firstEventFrame - pos); | 807 offset = -((unsigned long)firstEventFrame - pos); |
831 } | 808 } |
832 pasteRelative(offset); | 809 pasteRelative(offset); |
1848 if (!source.isAvailable()) return FileOpenFailed; | 1825 if (!source.isAvailable()) return FileOpenFailed; |
1849 source.waitForData(); | 1826 source.waitForData(); |
1850 | 1827 |
1851 QXmlInputSource *inputSource = 0; | 1828 QXmlInputSource *inputSource = 0; |
1852 QFile *file = 0; | 1829 QFile *file = 0; |
1853 bool isTemplate = false; | |
1854 | 1830 |
1855 file = new QFile(source.getLocalFilename()); | 1831 file = new QFile(source.getLocalFilename()); |
1856 inputSource = new QXmlInputSource(file); | 1832 inputSource = new QXmlInputSource(file); |
1857 | 1833 |
1858 if (!checkSaveModified()) { | 1834 if (!checkSaveModified()) { |
2574 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); | 2550 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); |
2575 } | 2551 } |
2576 | 2552 |
2577 m_viewManager->setPlaybackFrame(frame); | 2553 m_viewManager->setPlaybackFrame(frame); |
2578 | 2554 |
2579 if (frame == getMainModel()->getEndFrame() && | 2555 if (frame == (int)getMainModel()->getEndFrame() && |
2580 m_playSource && | 2556 m_playSource && |
2581 m_playSource->isPlaying() && | 2557 m_playSource->isPlaying() && |
2582 !m_viewManager->getPlayLoopMode()) { | 2558 !m_viewManager->getPlayLoopMode()) { |
2583 stop(); | 2559 stop(); |
2584 } | 2560 } |
2611 | 2587 |
2612 Layer *layer = getSnapLayer(); | 2588 Layer *layer = getSnapLayer(); |
2613 if (!layer) { ffwd(); return; } | 2589 if (!layer) { ffwd(); return; } |
2614 | 2590 |
2615 Pane *pane = m_paneStack->getCurrentPane(); | 2591 Pane *pane = m_paneStack->getCurrentPane(); |
2616 size_t sr = getMainModel()->getSampleRate(); | |
2617 | |
2618 int frame = m_viewManager->getPlaybackFrame(); | 2592 int frame = m_viewManager->getPlaybackFrame(); |
2619 | 2593 |
2620 size_t resolution = 0; | 2594 size_t resolution = 0; |
2621 if (pane) frame = pane->alignFromReference(frame); | 2595 if (pane) frame = pane->alignFromReference(frame); |
2622 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), | 2596 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), |
2632 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); | 2606 frame = m_viewManager->constrainFrameToSelection(size_t(frame)); |
2633 } | 2607 } |
2634 | 2608 |
2635 m_viewManager->setPlaybackFrame(frame); | 2609 m_viewManager->setPlaybackFrame(frame); |
2636 | 2610 |
2637 if (frame == getMainModel()->getEndFrame() && | 2611 if (frame == (int)getMainModel()->getEndFrame() && |
2638 m_playSource && | 2612 m_playSource && |
2639 m_playSource->isPlaying() && | 2613 m_playSource->isPlaying() && |
2640 !m_viewManager->getPlayLoopMode()) { | 2614 !m_viewManager->getPlayLoopMode()) { |
2641 stop(); | 2615 stop(); |
2642 } | 2616 } |
2649 | 2623 |
2650 int frame = m_viewManager->getPlaybackFrame(); | 2624 int frame = m_viewManager->getPlaybackFrame(); |
2651 if (frame > 0) --frame; | 2625 if (frame > 0) --frame; |
2652 | 2626 |
2653 Pane *pane = m_paneStack->getCurrentPane(); | 2627 Pane *pane = m_paneStack->getCurrentPane(); |
2628 size_t sr = getMainModel()->getSampleRate(); | |
2629 | |
2654 Layer *layer = getSnapLayer(); | 2630 Layer *layer = getSnapLayer(); |
2655 size_t sr = getMainModel()->getSampleRate(); | |
2656 | 2631 |
2657 // when rewinding during playback, we want to allow a period | 2632 // when rewinding during playback, we want to allow a period |
2658 // following a rewind target point at which the rewind will go to | 2633 // following a rewind target point at which the rewind will go to |
2659 // the prior point instead of the immediately neighbouring one | 2634 // the prior point instead of the immediately neighbouring one |
2660 if (m_playSource && m_playSource->isPlaying()) { | 2635 if (m_playSource && m_playSource->isPlaying()) { |
2714 | 2689 |
2715 Layer *layer = getSnapLayer(); | 2690 Layer *layer = getSnapLayer(); |
2716 if (!layer) { rewind(); return; } | 2691 if (!layer) { rewind(); return; } |
2717 | 2692 |
2718 Pane *pane = m_paneStack->getCurrentPane(); | 2693 Pane *pane = m_paneStack->getCurrentPane(); |
2719 size_t sr = getMainModel()->getSampleRate(); | |
2720 | |
2721 int frame = m_viewManager->getPlaybackFrame(); | 2694 int frame = m_viewManager->getPlaybackFrame(); |
2722 | 2695 |
2723 size_t resolution = 0; | 2696 size_t resolution = 0; |
2724 if (pane) frame = pane->alignFromReference(frame); | 2697 if (pane) frame = pane->alignFromReference(frame); |
2725 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), | 2698 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), |
3316 #ifdef Q_OS_MAC | 3289 #ifdef Q_OS_MAC |
3317 args.append(url); | 3290 args.append(url); |
3318 process->start("open", args); | 3291 process->start("open", args); |
3319 #else | 3292 #else |
3320 #ifdef Q_OS_WIN32 | 3293 #ifdef Q_OS_WIN32 |
3321 | 3294 QString pf(getenv("ProgramFiles")); |
3322 QString pf(getenv("ProgramFiles")); | 3295 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE"); |
3323 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE"); | 3296 |
3324 | 3297 args.append(url); |
3325 args.append(url); | 3298 process->start(command, args); |
3326 process->start(command, args); | |
3327 | |
3328 #else | 3299 #else |
3329 #ifdef Q_WS_X11 | |
3330 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { | 3300 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { |
3331 args.append("exec"); | 3301 args.append("exec"); |
3332 args.append(url); | 3302 args.append(url); |
3333 process->start("kfmclient", args); | 3303 process->start("kfmclient", args); |
3334 } else if (!qgetenv("BROWSER").isEmpty()) { | 3304 } else if (!qgetenv("BROWSER").isEmpty()) { |
3338 args.append(url); | 3308 args.append(url); |
3339 process->start("firefox", args); | 3309 process->start("firefox", args); |
3340 } | 3310 } |
3341 #endif | 3311 #endif |
3342 #endif | 3312 #endif |
3343 #endif | |
3344 } | 3313 } |
3345 | 3314 |
3346 | 3315 |