comparison main/MainWindow.cpp @ 116:99d65ba33c88

* More useful status bar text -- show the current play time and the extents of the visible area * Add update-i18n.sh to update the i18n/ts and qm files -- I can't get qmake to do the right thing now that the project file has been split up into several project files * Fix missing Q_OBJECTs, etc, reported by lupdate * Update Russian translation from AlexandrE
author Chris Cannam
date Wed, 07 Mar 2007 17:07:02 +0000
parents a46d68ae3c3e
children 8089a394829a
comparison
equal deleted inserted replaced
115:c9930ec7a3f9 116:99d65ba33c88
158 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)), 158 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)),
159 this, SLOT(rightButtonMenuRequested(Pane *, QPoint))); 159 this, SLOT(rightButtonMenuRequested(Pane *, QPoint)));
160 connect(m_paneStack, SIGNAL(propertyStacksResized()), 160 connect(m_paneStack, SIGNAL(propertyStacksResized()),
161 this, SLOT(propertyStacksResized())); 161 this, SLOT(propertyStacksResized()));
162 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)), 162 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)),
163 statusBar(), SLOT(showMessage(const QString &))); 163 this, SLOT(contextHelpChanged(const QString &)));
164 164
165 m_overview = new Overview(frame); 165 m_overview = new Overview(frame);
166 m_overview->setViewManager(m_viewManager); 166 m_overview->setViewManager(m_viewManager);
167 m_overview->setFixedHeight(40); 167 m_overview->setFixedHeight(40);
168 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)), 168 connect(m_overview, SIGNAL(contextHelpChanged(const QString &)),
169 statusBar(), SLOT(showMessage(const QString &))); 169 this, SLOT(contextHelpChanged(const QString &)));
170 170
171 m_panLayer = new WaveformLayer; 171 m_panLayer = new WaveformLayer;
172 m_panLayer->setChannelMode(WaveformLayer::MergeChannels); 172 m_panLayer->setChannelMode(WaveformLayer::MergeChannels);
173 // m_panLayer->setScale(WaveformLayer::MeterScale); 173 // m_panLayer->setScale(WaveformLayer::MeterScale);
174 // m_panLayer->setAutoNormalize(true); 174 // m_panLayer->setAutoNormalize(true);
245 245
246 frame->setLayout(layout); 246 frame->setLayout(layout);
247 247
248 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)), 248 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)),
249 this, SLOT(outputLevelsChanged(float, float))); 249 this, SLOT(outputLevelsChanged(float, float)));
250
251 connect(m_viewManager, SIGNAL(playbackFrameChanged(unsigned long)),
252 this, SLOT(playbackFrameChanged(unsigned long)));
253
254 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(unsigned long)),
255 this, SLOT(globalCentreFrameChanged(unsigned long)));
256
257 connect(m_viewManager, SIGNAL(viewCentreFrameChanged(View *, unsigned long)),
258 this, SLOT(viewCentreFrameChanged(View *, unsigned long)));
259
260 connect(m_viewManager, SIGNAL(viewZoomLevelChanged(View *, unsigned long, bool)),
261 this, SLOT(viewZoomLevelChanged(View *, unsigned long, bool)));
250 262
251 connect(Preferences::getInstance(), 263 connect(Preferences::getInstance(),
252 SIGNAL(propertyChanged(PropertyContainer::PropertyName)), 264 SIGNAL(propertyChanged(PropertyContainer::PropertyName)),
253 this, 265 this,
254 SLOT(preferenceChanged(PropertyContainer::PropertyName))); 266 SLOT(preferenceChanged(PropertyContainer::PropertyName)));
1697 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode()); 1709 m_viewManager->setPlaySelectionMode(!m_viewManager->getPlaySelectionMode());
1698 } 1710 }
1699 } 1711 }
1700 1712
1701 void 1713 void
1702 MainWindow::currentPaneChanged(Pane *) 1714 MainWindow::currentPaneChanged(Pane *p)
1703 { 1715 {
1704 updateMenuStates(); 1716 updateMenuStates();
1705 } 1717 updateVisibleRangeDisplay(p);
1706 1718 }
1707 void 1719
1708 MainWindow::currentLayerChanged(Pane *, Layer *) 1720 void
1721 MainWindow::currentLayerChanged(Pane *p, Layer *)
1709 { 1722 {
1710 updateMenuStates(); 1723 updateMenuStates();
1724 updateVisibleRangeDisplay(p);
1711 } 1725 }
1712 1726
1713 void 1727 void
1714 MainWindow::toolNavigateSelected() 1728 MainWindow::toolNavigateSelected()
1715 { 1729 {
2405 { 2419 {
2406 if (!m_document) return 0; 2420 if (!m_document) return 0;
2407 return m_document->getMainModel(); 2421 return m_document->getMainModel();
2408 } 2422 }
2409 2423
2424 const WaveFileModel *
2425 MainWindow::getMainModel() const
2426 {
2427 if (!m_document) return 0;
2428 return m_document->getMainModel();
2429 }
2430
2410 void 2431 void
2411 MainWindow::newSession() 2432 MainWindow::newSession()
2412 { 2433 {
2413 if (!checkSaveModified()) return; 2434 if (!checkSaveModified()) return;
2414 2435
2416 createDocument(); 2437 createDocument();
2417 2438
2418 Pane *pane = m_paneStack->addPane(); 2439 Pane *pane = m_paneStack->addPane();
2419 2440
2420 connect(pane, SIGNAL(contextHelpChanged(const QString &)), 2441 connect(pane, SIGNAL(contextHelpChanged(const QString &)),
2421 statusBar(), SLOT(showMessage(const QString &))); 2442 this, SLOT(contextHelpChanged(const QString &)));
2422 2443
2423 if (!m_timeRulerLayer) { 2444 if (!m_timeRulerLayer) {
2424 m_timeRulerLayer = m_document->createMainModelLayer 2445 m_timeRulerLayer = m_document->createMainModelLayer
2425 (LayerFactory::TimeRuler); 2446 (LayerFactory::TimeRuler);
2426 } 2447 }
3113 3134
3114 void 3135 void
3115 MainWindow::play() 3136 MainWindow::play()
3116 { 3137 {
3117 if (m_playSource->isPlaying()) { 3138 if (m_playSource->isPlaying()) {
3118 m_playSource->stop(); 3139 stop();
3119 } else { 3140 } else {
3141 playbackFrameChanged(m_viewManager->getPlaybackFrame());
3120 m_playSource->play(m_viewManager->getPlaybackFrame()); 3142 m_playSource->play(m_viewManager->getPlaybackFrame());
3121 } 3143 }
3122 } 3144 }
3123 3145
3124 void 3146 void
3185 3207
3186 void 3208 void
3187 MainWindow::stop() 3209 MainWindow::stop()
3188 { 3210 {
3189 m_playSource->stop(); 3211 m_playSource->stop();
3212
3213 if (m_paneStack && m_paneStack->getCurrentPane()) {
3214 updateVisibleRangeDisplay(m_paneStack->getCurrentPane());
3215 } else {
3216 m_myStatusMessage = "";
3217 statusBar()->showMessage("");
3218 }
3190 } 3219 }
3191 3220
3192 void 3221 void
3193 MainWindow::addPane() 3222 MainWindow::addPane()
3194 { 3223 {
3311 if (!m_pane) { 3340 if (!m_pane) {
3312 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane(); 3341 m_prevCurrentPane = m_mw->m_paneStack->getCurrentPane();
3313 m_pane = m_mw->m_paneStack->addPane(); 3342 m_pane = m_mw->m_paneStack->addPane();
3314 3343
3315 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)), 3344 connect(m_pane, SIGNAL(contextHelpChanged(const QString &)),
3316 m_mw->statusBar(), SLOT(showMessage(const QString &))); 3345 m_mw, SLOT(contextHelpChanged(const QString &)));
3317 } else { 3346 } else {
3318 m_mw->m_paneStack->showPane(m_pane); 3347 m_mw->m_paneStack->showPane(m_pane);
3319 } 3348 }
3320 3349
3321 m_mw->m_paneStack->setCurrentPane(m_pane); 3350 m_mw->m_paneStack->setCurrentPane(m_pane);
3608 settings.setValue("playmono", m_playMono->isChecked()); 3637 settings.setValue("playmono", m_playMono->isChecked());
3609 settings.endGroup(); 3638 settings.endGroup();
3610 3639
3611 playSpeedChanged(m_playSpeed->value()); 3640 playSpeedChanged(m_playSpeed->value());
3612 } 3641 }
3642
3643 void
3644 MainWindow::playbackFrameChanged(unsigned long frame)
3645 {
3646 if (!(m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3647
3648 RealTime now = RealTime::frame2RealTime
3649 (frame, getMainModel()->getSampleRate());
3650
3651 if (now.sec == m_lastPlayStatusSec) return;
3652
3653 RealTime then = RealTime::frame2RealTime
3654 (m_playSource->getPlayEndFrame(), getMainModel()->getSampleRate());
3655
3656 QString nowStr;
3657 QString thenStr;
3658 QString remainingStr;
3659
3660 if (then.sec > 10) {
3661 nowStr = now.toSecText().c_str();
3662 thenStr = then.toSecText().c_str();
3663 remainingStr = (then - now).toSecText().c_str();
3664 m_lastPlayStatusSec = now.sec;
3665 } else {
3666 nowStr = now.toText(true).c_str();
3667 thenStr = then.toText(true).c_str();
3668 remainingStr = (then - now).toText(true).c_str();
3669 }
3670
3671 m_myStatusMessage = tr("Playing: %1 of %2 (%3 remaining)")
3672 .arg(nowStr).arg(thenStr).arg(remainingStr);
3673
3674 statusBar()->showMessage(m_myStatusMessage);
3675 }
3676
3677 void
3678 MainWindow::globalCentreFrameChanged(unsigned long frame)
3679 {
3680 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3681 Pane *p = 0;
3682 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3683 if (!p->getFollowGlobalPan()) return;
3684 updateVisibleRangeDisplay(p);
3685 }
3686
3687 void
3688 MainWindow::viewCentreFrameChanged(View *v, unsigned long frame)
3689 {
3690 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3691 Pane *p = 0;
3692 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3693 if (v == p) updateVisibleRangeDisplay(p);
3694 }
3695
3696 void
3697 MainWindow::viewZoomLevelChanged(View *v, unsigned long zoom, bool locked)
3698 {
3699 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3700 Pane *p = 0;
3701 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3702 if (v == p) updateVisibleRangeDisplay(p);
3703 }
3704
3705 void
3706 MainWindow::updateVisibleRangeDisplay(Pane *p) const
3707 {
3708 if (!getMainModel() || !p) {
3709 return;
3710 }
3711
3712 RealTime start = RealTime::frame2RealTime
3713 (p->getFirstVisibleFrame(), getMainModel()->getSampleRate());
3714
3715 RealTime end = RealTime::frame2RealTime
3716 (p->getLastVisibleFrame(), getMainModel()->getSampleRate());
3717
3718 RealTime duration = end - start;
3719
3720 QString startStr, endStr, durationStr;
3721 startStr = start.toText(true).c_str();
3722 endStr = end.toText(true).c_str();
3723 durationStr = duration.toText(true).c_str();
3724
3725 m_myStatusMessage = tr("Visible: %1 to %2 (duration %3)")
3726 .arg(startStr).arg(endStr).arg(durationStr);
3727
3728 statusBar()->showMessage(m_myStatusMessage);
3729 }
3613 3730
3614 void 3731 void
3615 MainWindow::outputLevelsChanged(float left, float right) 3732 MainWindow::outputLevelsChanged(float left, float right)
3616 { 3733 {
3617 m_fader->setPeakLeft(left); 3734 m_fader->setPeakLeft(left);
4308 { 4425 {
4309 QWidget *w = dynamic_cast<QWidget *>(sender()); 4426 QWidget *w = dynamic_cast<QWidget *>(sender());
4310 if (!w) return; 4427 if (!w) return;
4311 4428
4312 if (w == m_fader) { 4429 if (w == m_fader) {
4313 statusBar()->showMessage(tr("Adjust the master playback level")); 4430 contextHelpChanged(tr("Adjust the master playback level"));
4314 } else if (w == m_playSpeed) { 4431 } else if (w == m_playSpeed) {
4315 statusBar()->showMessage(tr("Adjust the master playback speed")); 4432 contextHelpChanged(tr("Adjust the master playback speed"));
4316 } else if (w == m_playSharpen && w->isEnabled()) { 4433 } else if (w == m_playSharpen && w->isEnabled()) {
4317 statusBar()->showMessage(tr("Toggle transient sharpening for playback time scaling")); 4434 contextHelpChanged(tr("Toggle transient sharpening for playback time scaling"));
4318 } else if (w == m_playMono && w->isEnabled()) { 4435 } else if (w == m_playMono && w->isEnabled()) {
4319 statusBar()->showMessage(tr("Toggle mono mode for playback time scaling")); 4436 contextHelpChanged(tr("Toggle mono mode for playback time scaling"));
4320 } 4437 }
4321 } 4438 }
4322 4439
4323 void 4440 void
4324 MainWindow::mouseLeftWidget() 4441 MainWindow::mouseLeftWidget()
4325 { 4442 {
4326 statusBar()->showMessage(""); 4443 contextHelpChanged("");
4444 }
4445
4446 void
4447 MainWindow::contextHelpChanged(const QString &s)
4448 {
4449 if (s == "" && m_myStatusMessage != "") {
4450 statusBar()->showMessage(m_myStatusMessage);
4451 return;
4452 }
4453 statusBar()->showMessage(s);
4327 } 4454 }
4328 4455
4329 void 4456 void
4330 MainWindow::website() 4457 MainWindow::website()
4331 { 4458 {