From: Simon A. Eugster Date: Thu, 9 Dec 2010 18:50:10 +0000 (+0000) Subject: Audio scopes: Mouse tracking can be disabled X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=97a640560f43d7f72c783c80ddf4fed419c4adb2;p=kdenlive Audio scopes: Mouse tracking can be disabled svn path=/trunk/kdenlive/; revision=5156 --- diff --git a/src/audioscopes/audiospectrum.cpp b/src/audioscopes/audiospectrum.cpp index ef0e3c68..6122b766 100644 --- a/src/audioscopes/audiospectrum.cpp +++ b/src/audioscopes/audiospectrum.cpp @@ -42,10 +42,13 @@ AudioSpectrum::AudioSpectrum(QWidget *parent) : m_aResetHz = new QAction(i18n("Reset maximum frequency to sampling rate"), this); + m_aTrackMouse = new QAction(i18n("Track mouse"), this); + m_aTrackMouse->setCheckable(true); m_menu->addSeparator(); m_menu->addAction(m_aResetHz); + m_menu->addAction(m_aTrackMouse); m_menu->removeAction(m_aRealtime); @@ -78,6 +81,7 @@ AudioSpectrum::~AudioSpectrum() writeConfig(); delete m_aResetHz; + delete m_aTrackMouse; } void AudioSpectrum::readConfig() @@ -89,6 +93,7 @@ void AudioSpectrum::readConfig() ui->windowSize->setCurrentIndex(scopeConfig.readEntry("windowSize", 0)); ui->windowFunction->setCurrentIndex(scopeConfig.readEntry("windowFunction", 0)); + m_aTrackMouse->setChecked(scopeConfig.readEntry("trackMouse", true)); m_dBmax = scopeConfig.readEntry("dBmax", 0); m_dBmin = scopeConfig.readEntry("dBmin", -70); m_freqMax = scopeConfig.readEntry("freqMax", 0); @@ -107,6 +112,7 @@ void AudioSpectrum::writeConfig() scopeConfig.writeEntry("windowSize", ui->windowSize->currentIndex()); scopeConfig.writeEntry("windowFunction", ui->windowFunction->currentIndex()); + scopeConfig.writeEntry("trackMouse", m_aTrackMouse->isChecked()); scopeConfig.writeEntry("dBmax", m_dBmax); scopeConfig.writeEntry("dBmin", m_dBmin); if (m_customFreq) { @@ -268,7 +274,7 @@ QImage AudioSpectrum::renderHUD(uint) } } - if (m_mouseWithinWidget && mouseX < m_innerScopeRect.width()-1) { + if (m_aTrackMouse->isChecked() && m_mouseWithinWidget && mouseX < m_innerScopeRect.width()-1) { davinci.setPen(AbstractScopeWidget::penThin); x = leftDist + mouseX; diff --git a/src/audioscopes/audiospectrum.h b/src/audioscopes/audiospectrum.h index b48d4fdb..9ab39916 100644 --- a/src/audioscopes/audiospectrum.h +++ b/src/audioscopes/audiospectrum.h @@ -56,6 +56,7 @@ private: Ui::AudioSpectrum_UI *ui; QAction *m_aResetHz; + QAction *m_aTrackMouse; FFTTools m_fftTools; QVector m_lastFFT; diff --git a/src/audioscopes/spectrogram.cpp b/src/audioscopes/spectrogram.cpp index 28ea1762..657a896c 100644 --- a/src/audioscopes/spectrogram.cpp +++ b/src/audioscopes/spectrogram.cpp @@ -44,10 +44,13 @@ Spectrogram::Spectrogram(QWidget *parent) : m_aResetHz = new QAction(i18n("Reset maximum frequency to sampling rate"), this); m_aGrid = new QAction(i18n("Draw grid"), this); m_aGrid->setCheckable(true); + m_aTrackMouse = new QAction(i18n("Track mouse"), this); + m_aTrackMouse->setCheckable(true); m_menu->addSeparator(); m_menu->addAction(m_aResetHz); + m_menu->addAction(m_aTrackMouse); m_menu->addAction(m_aGrid); m_menu->removeAction(m_aRealtime); @@ -80,6 +83,7 @@ Spectrogram::~Spectrogram() writeConfig(); delete m_aResetHz; + delete m_aTrackMouse; delete m_aGrid; } @@ -92,6 +96,7 @@ void Spectrogram::readConfig() ui->windowSize->setCurrentIndex(scopeConfig.readEntry("windowSize", 0)); ui->windowFunction->setCurrentIndex(scopeConfig.readEntry("windowFunction", 0)); + m_aTrackMouse->setChecked(scopeConfig.readEntry("trackMouse", true)); m_aGrid->setChecked(scopeConfig.readEntry("drawGrid", true)); m_dBmax = scopeConfig.readEntry("dBmax", 0); m_dBmin = scopeConfig.readEntry("dBmin", -70); @@ -111,6 +116,7 @@ void Spectrogram::writeConfig() scopeConfig.writeEntry("windowSize", ui->windowSize->currentIndex()); scopeConfig.writeEntry("windowFunction", ui->windowFunction->currentIndex()); + scopeConfig.writeEntry("trackMouse", m_aTrackMouse->isChecked()); scopeConfig.writeEntry("drawGrid", m_aGrid->isChecked()); scopeConfig.writeEntry("dBmax", m_dBmax); scopeConfig.writeEntry("dBmin", m_dBmin); @@ -174,7 +180,7 @@ QImage Spectrogram::renderHUD(uint) if (m_aGrid->isChecked()) { for (int frameNumber = 0; frameNumber < m_innerScopeRect.height(); frameNumber += minDistY) { y = topDist + m_innerScopeRect.height()-1 - frameNumber; - hideText = m_mouseWithinWidget && abs(y - mouseY) < (int)textDistY && mouseY < m_innerScopeRect.height() && mouseX < m_innerScopeRect.width(); + hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(y - mouseY) < (int)textDistY && mouseY < m_innerScopeRect.height() && mouseX < m_innerScopeRect.width(); davinci.drawLine(leftDist, y, leftDist + m_innerScopeRect.width()-1, y); if (!hideText) { @@ -183,7 +189,7 @@ QImage Spectrogram::renderHUD(uint) } } // Draw a line through the mouse position with the correct Frame number - if (m_mouseWithinWidget && mouseY < m_innerScopeRect.height() && mouseX < m_innerScopeRect.width()) { + if (m_aTrackMouse->isChecked() && m_mouseWithinWidget && mouseY < m_innerScopeRect.height() && mouseX < m_innerScopeRect.width()) { davinci.setPen(AbstractScopeWidget::penLighter); x = leftDist + mouseX; @@ -214,7 +220,7 @@ QImage Spectrogram::renderHUD(uint) x = leftDist + (m_innerScopeRect.width()-1) * ((float)hz)/m_freqMax; // Hide text if it would overlap with the text drawn at the mouse position - hideText = m_mouseWithinWidget && abs(x-(leftDist + mouseX + 20)) < (int) minDistX + 16 && mouseX < m_innerScopeRect.width(); + hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(x-(leftDist + mouseX + 20)) < (int) minDistX + 16 && mouseX < m_innerScopeRect.width(); if (x <= rightBorder) { davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height()+6); @@ -241,7 +247,7 @@ QImage Spectrogram::renderHUD(uint) } // Draw the line at the very right (maximum frequency) x = leftDist + m_innerScopeRect.width()-1; - hideText = m_mouseWithinWidget && abs(x-(leftDist + mouseX + 30)) < (int) minDistX && mouseX < m_innerScopeRect.width(); + hideText = m_aTrackMouse->isChecked() && m_mouseWithinWidget && abs(x-(leftDist + mouseX + 30)) < (int) minDistX && mouseX < m_innerScopeRect.width(); davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height()+6); if (!hideText) { davinci.drawText(x-10, y, i18n("%1 kHz").arg((double)m_freqMax/1000, 0, 'f', 1)); @@ -249,7 +255,7 @@ QImage Spectrogram::renderHUD(uint) } // Draw a line through the mouse position with the correct frequency label - if (m_mouseWithinWidget && mouseX < m_innerScopeRect.width()) { + if (m_aTrackMouse->isChecked() && m_mouseWithinWidget && mouseX < m_innerScopeRect.width()) { davinci.setPen(AbstractScopeWidget::penThin); x = leftDist + mouseX; davinci.drawLine(x, topDist, x, topDist + m_innerScopeRect.height()+6); diff --git a/src/audioscopes/spectrogram.h b/src/audioscopes/spectrogram.h index 77e9b1e8..5e11d9a7 100644 --- a/src/audioscopes/spectrogram.h +++ b/src/audioscopes/spectrogram.h @@ -60,6 +60,7 @@ private: FFTTools m_fftTools; QAction *m_aResetHz; QAction *m_aGrid; + QAction *m_aTrackMouse; QList > m_fftHistory; QImage m_fftHistoryImg;