# HG changeset patch # User Chris Cannam # Date 1199466490 0 # Node ID 832d246b327b99fe3ea960b60c6d716cf2e7ee95 # Parent 1b6879d03cb6103eda82f962fa74782111a175a9 * better progress reporting in FileSource * fix set-to-default for audio dials with mappers diff -r 1b6879d03cb6 -r 832d246b327b layer/ImageLayer.cpp --- a/layer/ImageLayer.cpp Tue Dec 18 10:35:55 2007 +0000 +++ b/layer/ImageLayer.cpp Fri Jan 04 17:08:10 2008 +0000 @@ -880,7 +880,7 @@ return; } - FileSource *rf = new FileSource(img, true); + FileSource *rf = new FileSource(img, FileSource::ProgressDialog); if (rf->isOK()) { std::cerr << "ok, adding it (local filename = " << rf->getLocalFilename().toStdString() << ")" << std::endl; m_remoteFiles[img] = rf; diff -r 1b6879d03cb6 -r 832d246b327b widgets/AudioDial.cpp --- a/widgets/AudioDial.cpp Tue Dec 18 10:35:55 2007 +0000 +++ b/widgets/AudioDial.cpp Fri Jan 04 17:08:10 2008 +0000 @@ -75,6 +75,7 @@ m_knobColor(Qt::black), m_meterColor(Qt::white), m_defaultValue(0), + m_defaultMappedValue(0), m_mappedValue(0), m_noMappedUpdate(false), m_showTooltip(true), @@ -334,15 +335,24 @@ void AudioDial::setDefaultValue(int defaultValue) { m_defaultValue = defaultValue; + if (m_rangeMapper) { + m_defaultMappedValue = m_rangeMapper->getValueForPosition(defaultValue); + } } - void AudioDial::setValue(int value) { QDial::setValue(value); updateMappedValue(value); } +void AudioDial::setDefaultMappedValue(float value) +{ + m_defaultMappedValue = value; + if (m_rangeMapper) { + m_defaultValue = m_rangeMapper->getPositionForValue(value); + } +} void AudioDial::setMappedValue(float mappedValue) { @@ -407,6 +417,18 @@ } } +void +AudioDial::setToDefault() +{ + if (m_rangeMapper) { + setMappedValue(m_defaultMappedValue); + return; + } + int dv = m_defaultValue; + if (dv < minimum()) dv = minimum(); + if (dv > maximum()) dv = maximum(); + setValue(m_defaultValue); +} // Alternate mouse behavior event handlers. void AudioDial::mousePressEvent(QMouseEvent *mouseEvent) @@ -416,10 +438,7 @@ } else if (mouseEvent->button() == Qt::MidButton || ((mouseEvent->button() == Qt::LeftButton) && (mouseEvent->modifiers() & Qt::ControlModifier))) { - int dv = m_defaultValue; - if (dv < minimum()) dv = minimum(); - if (dv > maximum()) dv = maximum(); - setValue(m_defaultValue); + setToDefault(); } else if (mouseEvent->button() == Qt::LeftButton) { m_mousePressed = true; m_posMouse = mouseEvent->pos(); diff -r 1b6879d03cb6 -r 832d246b327b widgets/AudioDial.h --- a/widgets/AudioDial.h Tue Dec 18 10:35:55 2007 +0000 +++ b/widgets/AudioDial.h Fri Jan 04 17:08:10 2008 +0000 @@ -107,8 +107,12 @@ void setValue(int value); + void setDefaultMappedValue(float mappedValue); + void setMappedValue(float mappedValue); + void setToDefault(); + protected: void drawTick(QPainter &paint, float angle, int size, bool internal); virtual void paintEvent(QPaintEvent *); @@ -129,6 +133,7 @@ QColor m_meterColor; int m_defaultValue; + float m_defaultMappedValue; float m_mappedValue; bool m_noMappedUpdate; diff -r 1b6879d03cb6 -r 832d246b327b widgets/ImageDialog.cpp --- a/widgets/ImageDialog.cpp Tue Dec 18 10:35:55 2007 +0000 +++ b/widgets/ImageDialog.cpp Fri Jan 04 17:08:10 2008 +0000 @@ -186,7 +186,7 @@ tr("The URL scheme \"%1\" is not supported") .arg(url.scheme())); } else { - m_remoteFile = new FileSource(url, true); + m_remoteFile = new FileSource(url, FileSource::ProgressDialog); m_remoteFile->waitForData(); if (!m_remoteFile->isOK()) { QMessageBox::critical(this, tr("File download failed"),