comparison framework/MainWindowBase.cpp @ 368:f1cab64363d7 warnfix_no_size_t

Merge from branch tony_integration
author Chris Cannam
date Wed, 18 Jun 2014 08:45:13 +0100
parents 0876ea394902 88bf6cc73275
children 024226dd9f51
comparison
equal deleted inserted replaced
367:1e4fa2007e61 368:f1cab64363d7
150 m_recentTransforms("RecentTransforms", 20), 150 m_recentTransforms("RecentTransforms", 20),
151 m_documentModified(false), 151 m_documentModified(false),
152 m_openingAudioFile(false), 152 m_openingAudioFile(false),
153 m_abandoning(false), 153 m_abandoning(false),
154 m_labeller(0), 154 m_labeller(0),
155 m_lastPlayStatusSec(0) 155 m_lastPlayStatusSec(0),
156 m_initialDarkBackground(false),
157 m_defaultFfwdRwdStep(2, 0)
156 { 158 {
157 Profiler profiler("MainWindowBase::MainWindowBase"); 159 Profiler profiler("MainWindowBase::MainWindowBase");
158 160
159 #ifdef Q_WS_X11 161 #ifdef Q_WS_X11
160 XSetErrorHandler(handle_x11_error); 162 XSetErrorHandler(handle_x11_error);
370 372
371 QString 373 QString
372 MainWindowBase::getOpenFileName(FileFinder::FileType type) 374 MainWindowBase::getOpenFileName(FileFinder::FileType type)
373 { 375 {
374 FileFinder *ff = FileFinder::getInstance(); 376 FileFinder *ff = FileFinder::getInstance();
375 switch (type) { 377
376 case FileFinder::SessionFile: 378 if (type == FileFinder::AnyFile) {
377 return ff->getOpenFileName(type, m_sessionFile);
378 case FileFinder::AudioFile:
379 return ff->getOpenFileName(type, m_audioFile);
380 case FileFinder::LayerFile:
381 return ff->getOpenFileName(type, m_sessionFile);
382 case FileFinder::LayerFileNoMidi:
383 return ff->getOpenFileName(type, m_sessionFile);
384 case FileFinder::LayerFileNonSV:
385 return ff->getOpenFileName(type, m_sessionFile);
386 case FileFinder::LayerFileNoMidiNonSV:
387 return ff->getOpenFileName(type, m_sessionFile);
388 case FileFinder::SessionOrAudioFile:
389 return ff->getOpenFileName(type, m_sessionFile);
390 case FileFinder::ImageFile:
391 return ff->getOpenFileName(type, m_sessionFile);
392 case FileFinder::CSVFile:
393 return ff->getOpenFileName(type, m_sessionFile);
394 case FileFinder::AnyFile:
395 if (getMainModel() != 0 && 379 if (getMainModel() != 0 &&
396 m_paneStack != 0 && 380 m_paneStack != 0 &&
397 m_paneStack->getCurrentPane() != 0) { // can import a layer 381 m_paneStack->getCurrentPane() != 0) { // can import a layer
398 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile); 382 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile);
399 } else { 383 } else {
400 return ff->getOpenFileName(FileFinder::SessionOrAudioFile, 384 return ff->getOpenFileName(FileFinder::SessionOrAudioFile,
401 m_sessionFile); 385 m_sessionFile);
402 } 386 }
403 } 387 }
404 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);
405 } 396 }
406 397
407 QString 398 QString
408 MainWindowBase::getSaveFileName(FileFinder::FileType type) 399 MainWindowBase::getSaveFileName(FileFinder::FileType type)
409 { 400 {
401 QString lastPath = m_sessionFile;
402
403 if (type == FileFinder::AudioFile) {
404 lastPath = m_audioFile;
405 }
406
410 FileFinder *ff = FileFinder::getInstance(); 407 FileFinder *ff = FileFinder::getInstance();
411 switch (type) { 408 return ff->getSaveFileName(type, lastPath);
412 case FileFinder::SessionFile:
413 return ff->getSaveFileName(type, m_sessionFile);
414 case FileFinder::AudioFile:
415 return ff->getSaveFileName(type, m_audioFile);
416 case FileFinder::LayerFile:
417 return ff->getSaveFileName(type, m_sessionFile);
418 case FileFinder::LayerFileNoMidi:
419 return ff->getSaveFileName(type, m_sessionFile);
420 case FileFinder::LayerFileNonSV:
421 return ff->getSaveFileName(type, m_sessionFile);
422 case FileFinder::LayerFileNoMidiNonSV:
423 return ff->getSaveFileName(type, m_sessionFile);
424 case FileFinder::SessionOrAudioFile:
425 return ff->getSaveFileName(type, m_sessionFile);
426 case FileFinder::ImageFile:
427 return ff->getSaveFileName(type, m_sessionFile);
428 case FileFinder::CSVFile:
429 return ff->getSaveFileName(type, m_sessionFile);
430 case FileFinder::AnyFile:
431 return ff->getSaveFileName(type, m_sessionFile);
432 }
433 return "";
434 } 409 }
435 410
436 void 411 void
437 MainWindowBase::registerLastOpenedFilePath(FileFinder::FileType type, QString path) 412 MainWindowBase::registerLastOpenedFilePath(FileFinder::FileType type, QString path)
438 { 413 {
551 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection); 526 emit canRenumberInstants(haveCurrentTimeInstantsLayer && haveSelection);
552 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection); 527 emit canPlaySelection(haveMainModel && havePlayTarget && haveSelection);
553 emit canClearSelection(haveSelection); 528 emit canClearSelection(haveSelection);
554 emit canEditSelection(haveSelection && haveCurrentEditableLayer); 529 emit canEditSelection(haveSelection && haveCurrentEditableLayer);
555 emit canSave(m_sessionFile != "" && m_documentModified); 530 emit canSave(m_sessionFile != "" && m_documentModified);
531 emit canSaveAs(haveMainModel);
556 emit canSelectPreviousPane(havePrevPane); 532 emit canSelectPreviousPane(havePrevPane);
557 emit canSelectNextPane(haveNextPane); 533 emit canSelectNextPane(haveNextPane);
558 emit canSelectPreviousLayer(havePrevLayer); 534 emit canSelectPreviousLayer(havePrevLayer);
559 emit canSelectNextLayer(haveNextLayer); 535 emit canSelectNextLayer(haveNextLayer);
560 } 536 }
1241 1217
1242 m_openingAudioFile = true; 1218 m_openingAudioFile = true;
1243 1219
1244 int rate = 0; 1220 int rate = 0;
1245 1221
1246 if (Preferences::getInstance()->getResampleOnLoad()) { 1222 if (Preferences::getInstance()->getFixedSampleRate() != 0) {
1223 rate = Preferences::getInstance()->getFixedSampleRate();
1224 } else if (Preferences::getInstance()->getResampleOnLoad()) {
1247 rate = m_playSource->getSourceSampleRate(); 1225 rate = m_playSource->getSourceSampleRate();
1248 } 1226 }
1249 1227
1250 WaveFileModel *newModel = new WaveFileModel(source, rate); 1228 WaveFileModel *newModel = new WaveFileModel(source, rate);
1251 1229
2550 int sr = getMainModel()->getSampleRate(); 2528 int sr = getMainModel()->getSampleRate();
2551 2529
2552 if (!layer) { 2530 if (!layer) {
2553 2531
2554 frame = RealTime::realTime2Frame 2532 frame = RealTime::realTime2Frame
2555 (RealTime::frame2RealTime(frame, sr) + RealTime(2, 0), sr); 2533 (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep, sr);
2556 if (frame > int(getMainModel()->getEndFrame())) { 2534 if (frame > int(getMainModel()->getEndFrame())) {
2557 frame = getMainModel()->getEndFrame(); 2535 frame = getMainModel()->getEndFrame();
2558 } 2536 }
2559 2537
2560 } else { 2538 } else {
2575 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2553 frame = m_viewManager->constrainFrameToSelection(int(frame));
2576 } 2554 }
2577 2555
2578 m_viewManager->setPlaybackFrame(frame); 2556 m_viewManager->setPlaybackFrame(frame);
2579 2557
2580 if (frame == getMainModel()->getEndFrame() && 2558 if (frame == (int)getMainModel()->getEndFrame() &&
2581 m_playSource && 2559 m_playSource &&
2582 m_playSource->isPlaying() && 2560 m_playSource->isPlaying() &&
2583 !m_viewManager->getPlayLoopMode()) { 2561 !m_viewManager->getPlayLoopMode()) {
2584 stop(); 2562 stop();
2585 } 2563 }
2612 2590
2613 Layer *layer = getSnapLayer(); 2591 Layer *layer = getSnapLayer();
2614 if (!layer) { ffwd(); return; } 2592 if (!layer) { ffwd(); return; }
2615 2593
2616 Pane *pane = m_paneStack->getCurrentPane(); 2594 Pane *pane = m_paneStack->getCurrentPane();
2617
2618 int frame = m_viewManager->getPlaybackFrame(); 2595 int frame = m_viewManager->getPlaybackFrame();
2619 2596
2620 int resolution = 0; 2597 int resolution = 0;
2621 if (pane) frame = pane->alignFromReference(frame); 2598 if (pane) frame = pane->alignFromReference(frame);
2622 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), 2599 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(),
2632 frame = m_viewManager->constrainFrameToSelection(int(frame)); 2609 frame = m_viewManager->constrainFrameToSelection(int(frame));
2633 } 2610 }
2634 2611
2635 m_viewManager->setPlaybackFrame(frame); 2612 m_viewManager->setPlaybackFrame(frame);
2636 2613
2637 if (frame == getMainModel()->getEndFrame() && 2614 if (frame == (int)getMainModel()->getEndFrame() &&
2638 m_playSource && 2615 m_playSource &&
2639 m_playSource->isPlaying() && 2616 m_playSource->isPlaying() &&
2640 !m_viewManager->getPlayLoopMode()) { 2617 !m_viewManager->getPlayLoopMode()) {
2641 stop(); 2618 stop();
2642 } 2619 }
2657 // when rewinding during playback, we want to allow a period 2634 // when rewinding during playback, we want to allow a period
2658 // following a rewind target point at which the rewind will go to 2635 // following a rewind target point at which the rewind will go to
2659 // the prior point instead of the immediately neighbouring one 2636 // the prior point instead of the immediately neighbouring one
2660 if (m_playSource && m_playSource->isPlaying()) { 2637 if (m_playSource && m_playSource->isPlaying()) {
2661 RealTime ct = RealTime::frame2RealTime(frame, sr); 2638 RealTime ct = RealTime::frame2RealTime(frame, sr);
2662 ct = ct - RealTime::fromSeconds(0.25); 2639 ct = ct - RealTime::fromSeconds(0.15);
2663 if (ct < RealTime::zeroTime) ct = RealTime::zeroTime; 2640 if (ct < RealTime::zeroTime) ct = RealTime::zeroTime;
2664 frame = RealTime::realTime2Frame(ct, sr); 2641 frame = RealTime::realTime2Frame(ct, sr);
2665 } 2642 }
2666 2643
2667 if (!layer) { 2644 if (!layer) {
2668 2645
2669 frame = RealTime::realTime2Frame 2646 frame = RealTime::realTime2Frame
2670 (RealTime::frame2RealTime(frame, sr) - RealTime(2, 0), sr); 2647 (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep, sr);
2671 if (frame < int(getMainModel()->getStartFrame())) { 2648 if (frame < int(getMainModel()->getStartFrame())) {
2672 frame = getMainModel()->getStartFrame(); 2649 frame = getMainModel()->getStartFrame();
2673 } 2650 }
2674 2651
2675 } else { 2652 } else {
2714 2691
2715 Layer *layer = getSnapLayer(); 2692 Layer *layer = getSnapLayer();
2716 if (!layer) { rewind(); return; } 2693 if (!layer) { rewind(); return; }
2717 2694
2718 Pane *pane = m_paneStack->getCurrentPane(); 2695 Pane *pane = m_paneStack->getCurrentPane();
2719
2720 int frame = m_viewManager->getPlaybackFrame(); 2696 int frame = m_viewManager->getPlaybackFrame();
2721 2697
2722 int resolution = 0; 2698 int resolution = 0;
2723 if (pane) frame = pane->alignFromReference(frame); 2699 if (pane) frame = pane->alignFromReference(frame);
2724 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), 2700 if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(),
3212 MainWindowBase::mainModelChanged(WaveFileModel *model) 3188 MainWindowBase::mainModelChanged(WaveFileModel *model)
3213 { 3189 {
3214 // SVDEBUG << "MainWindowBase::mainModelChanged(" << model << ")" << endl; 3190 // SVDEBUG << "MainWindowBase::mainModelChanged(" << model << ")" << endl;
3215 updateDescriptionLabel(); 3191 updateDescriptionLabel();
3216 if (model) m_viewManager->setMainModelSampleRate(model->getSampleRate()); 3192 if (model) m_viewManager->setMainModelSampleRate(model->getSampleRate());
3217 if (model && !m_playTarget && m_audioOutput) createPlayTarget(); 3193 if (model && !m_playTarget && m_audioOutput) {
3194 createPlayTarget();
3195 }
3218 } 3196 }
3219 3197
3220 void 3198 void
3221 MainWindowBase::modelAboutToBeDeleted(Model *model) 3199 MainWindowBase::modelAboutToBeDeleted(Model *model)
3222 { 3200 {
3315 #ifdef Q_OS_MAC 3293 #ifdef Q_OS_MAC
3316 args.append(url); 3294 args.append(url);
3317 process->start("open", args); 3295 process->start("open", args);
3318 #else 3296 #else
3319 #ifdef Q_OS_WIN32 3297 #ifdef Q_OS_WIN32
3320 3298 QString pf(getenv("ProgramFiles"));
3321 QString pf(getenv("ProgramFiles")); 3299 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE");
3322 QString command = pf + QString("\\Internet Explorer\\IEXPLORE.EXE"); 3300
3323 3301 args.append(url);
3324 args.append(url); 3302 process->start(command, args);
3325 process->start(command, args);
3326
3327 #else 3303 #else
3328 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { 3304 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
3329 args.append("exec"); 3305 args.append("exec");
3330 args.append(url); 3306 args.append(url);
3331 process->start("kfmclient", args); 3307 process->start("kfmclient", args);