Commit c4b1e05c authored by Alexander Wiebel's avatar Alexander Wiebel

[ADD #198] buttons for changing min and max of double sliders

Added also a possibility to hide the buttons through a setting
... this can make the interface less cluttered.

Int sliders will follow
parent 0015a20b
......@@ -135,6 +135,10 @@ void WMainWindow::setupGUI()
"Auto-Display",
"If enabled, the best matching module is automatically added if some data was loaded.",
true );
m_sliderMinMaxEditSetting = new WSettingAction( this, std::string( "qt4gui/" ) + std::string( "sliderMinMaxEdit" ),
"Slider Min/Max Editing",
"If enabled, the maximum and minimum values of slider can be edited.",
false );
WSettingAction* mtViews = new WSettingAction( this, "qt4gui/ge/multiThreadedViewer",
"Multi-Threaded Views",
......@@ -348,6 +352,7 @@ void WMainWindow::setupGUI()
m_settingsAction = new QAction( "Settings", this );
m_settingsMenu = m_menuBar->addMenu( "Settings" );
m_settingsMenu->addAction( m_autoDisplaySetting );
m_settingsMenu->addAction( m_sliderMinMaxEditSetting );
m_settingsMenu->addAction( m_controlPanel->getModuleConfig().getConfigureAction() );
m_settingsMenu->addSeparator();
m_settingsMenu->addAction( mtViews );
......
......@@ -441,6 +441,11 @@ private:
*/
WSettingAction* m_autoDisplaySetting;
/**
* The action for allowing editing min and max of sliders.
*/
WSettingAction* m_sliderMinMaxEditSetting;
/**
* Called whenever a async load has finished. Used by \ref asyncProjectLoad. It might be called from outside the GUI thread.
*
......
......@@ -23,13 +23,16 @@
//---------------------------------------------------------------------------
#include <cmath>
#include <limits>
#include <sstream>
#include <string>
#include <QtGui/QInputDialog>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
#include "core/common/WLogger.h"
#include "core/common/WPropertyVariable.h"
#include "../WGuiConsts.h"
#include "WPropertyDoubleWidget.h"
#include "WPropertyDoubleWidget.moc"
......@@ -39,16 +42,44 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout*
m_doubleProperty( property ),
m_slider( Qt::Horizontal, &m_parameterWidgets ),
m_edit( &m_parameterWidgets ),
m_minButton( &m_parameterWidgets ),
m_maxButton( &m_parameterWidgets ),
m_layout( &m_parameterWidgets ),
m_asText( &m_informationWidgets ),
m_infoLayout( &m_informationWidgets )
{
// layout both against each other
if( WQt4Gui::getSettings().value( "qt4gui/sliderMinMaxEdit", false ).toBool() )
{
m_layout.addWidget( &m_minButton );
m_minButton.setToolTip( "Set minimum of slider.\n Be aware that strange values can cause errors." );
m_minButton.setMinimumWidth( 5 );
m_minButton.setMaximumWidth( 5 );
}
else
{
m_minButton.hide();
}
m_layout.addWidget( &m_slider );
if( WQt4Gui::getSettings().value( "qt4gui/sliderMinMaxEdit", false ).toBool() )
{
m_layout.addWidget( &m_maxButton );
m_maxButton.setToolTip( "Set maximum of slider.\n Be aware that strange values can cause errors." );
m_maxButton.setMinimumWidth( 5 );
m_maxButton.setMaximumWidth( 5 );
}
else
{
m_maxButton.hide();
}
m_layout.addWidget( &m_edit );
m_layout.setMargin( WGLOBAL_MARGIN );
m_layout.setSpacing( WGLOBAL_SPACING );
m_parameterWidgets.setLayout( &m_layout );
// Information Output ( Property Purpose = PV_PURPOSE_INFORMATION )
......@@ -65,6 +96,8 @@ WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout*
connect( &m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderChanged( int ) ) );
connect( &m_edit, SIGNAL( editingFinished() ), this, SLOT( editChanged() ) );
connect( &m_edit, SIGNAL( textEdited( const QString& ) ), this, SLOT( textEdited( const QString& ) ) );
connect( &m_maxButton, SIGNAL( pressed() ), this, SLOT( maxPressed() ) );
connect( &m_minButton, SIGNAL( pressed() ), this, SLOT( minPressed() ) );
}
WPropertyDoubleWidget::~WPropertyDoubleWidget()
......@@ -160,3 +193,38 @@ void WPropertyDoubleWidget::textEdited( const QString& text )
invalidate( !m_doubleProperty->accept( value ) );
}
void WPropertyDoubleWidget::maxPressed()
{
bool ok;
double newMax = QInputDialog::getDouble( this, "Setting Maximum of Slider",
"Maximum", m_max, m_min, std::numeric_limits< double >::max(), 18, &ok );
if( ok )
{
m_max = newMax;
if( m_doubleProperty->get() > newMax )
{
m_doubleProperty->set( newMax );
m_slider.setValue( toPercent( newMax ) );
}
m_doubleProperty->setMax( newMax );
}
}
void WPropertyDoubleWidget::minPressed()
{
bool ok;
double newMin = QInputDialog::getDouble( this, "Setting Minimum of Slider",
"Minimum", m_min, -std::numeric_limits< double >::max(), m_max, 18, &ok );
if( ok )
{
m_min = newMin;
if( m_doubleProperty->get() < newMin )
{
m_doubleProperty->set( newMin );
m_slider.setValue( toPercent( newMin ) );
}
m_doubleProperty->setMin( newMin );
}
}
......@@ -30,6 +30,7 @@
#include <QtGui/QLineEdit>
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include "WPropertyWidget.h"
......@@ -75,6 +76,16 @@ protected:
*/
QLineEdit m_edit;
/**
* The button bringing up the dialog for modifying min of the slider
*/
QToolButton m_minButton;
/**
* The button bringing up the dialog for modifying max of the slider
*/
QToolButton m_maxButton;
/**
* Layout used to position the label and the checkbox
*/
......@@ -139,6 +150,16 @@ public slots:
* \param text
*/
void textEdited( const QString& text );
/**
* Called when the maxMin button is pressed to open maxMinDialog.
*/
void maxPressed();
/**
* Called when the maxMin button is pressed to open maxMinDialog.
*/
void minPressed();
};
#endif // WPROPERTYDOUBLEWIDGET_H
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment