37WidgetWithInput::WidgetWithInput( QWidget* parent,
bool bUseIntSteps, QString sBaseTooltip,
int nScrollSpeed,
int nScrollSpeedFast,
float fMin,
float fMax,
bool bModifyOnChange )
39 , m_bUseIntSteps( bUseIntSteps )
40 , m_sBaseTooltip( sBaseTooltip )
41 , m_nScrollSpeed( nScrollSpeed )
42 , m_nScrollSpeedFast( nScrollSpeedFast )
45 , m_fDefaultValue( fMin )
47 , m_fMousePressValue( 0.0 )
48 , m_fMousePressY( 0.0 )
49 , m_bIgnoreMouseMove( false )
52 , m_nWidgetHeight( 20 )
53 , m_nWidgetWidth( 20 )
54 , m_sInputBuffer(
"" )
55 , m_inputBufferTimeout( 2.0 )
56 , m_bModifyOnChange( bModifyOnChange ) {
58 setAttribute( Qt::WA_Hover );
59 setFocusPolicy( Qt::ClickFocus );
72 .arg( pCommonStrings->getRangeTooltip() )
77 sTip.append( QString(
"\n%1: %2 " ).arg( pCommonStrings->getMidiTooltipHeading() )
83 sTip.append( QString(
"\n%1 [%2 : %3]" )
84 .arg( pCommonStrings->getMidiTooltipBound() )
90 sTip.append( QString(
"\n%1 [%2]" )
91 .arg( pCommonStrings->getMidiTooltipBound() )
98 sTip.append( QString(
"%1" ).arg( pCommonStrings->getMidiTooltipUnbound() ) );
117 fValue = std::round( fValue );
119 if ( std::abs( fValue ) < 1E-6 ) {
137 else if ( fValue >
m_fMax ) {
160 if ( ev->button() == Qt::LeftButton && ev->modifiers() == Qt::ControlModifier ) {
164 else if ( ev->button() == Qt::LeftButton && ev->modifiers() == Qt::ShiftModifier ) {
171 setCursor( QCursor( Qt::SizeVerCursor ) );
177 QToolTip::showText( ev->globalPos(), QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
188 setCursor( QCursor( Qt::ArrowCursor ) );
204 if ( ev->modifiers() == Qt::ControlModifier ) {
212 fDelta = fRange / 100.0;
214 if ( ev->angleDelta().y() < 0 ) {
221#
if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
222 ev->globalPosition().toPoint(),
226 QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
240 if ( ev->modifiers() == Qt::ControlModifier ) {
249 float fNewValue = (
m_fMousePressValue - fStepFactor * ( fDeltaY / 100.0 * fRange ) );
253 QToolTip::showText( ev->globalPos(), QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
281 if ( ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Up ) {
282 if ( ev->modifiers() == Qt::ControlModifier ) {
288 }
else if ( ev->key() == Qt::Key_PageUp ) {
290 }
else if ( ev->key() == Qt::Key_Home ) {
292 }
else if ( ev->key() == Qt::Key_Left || ev->key() == Qt::Key_Down ) {
293 if ( ev->modifiers() == Qt::ControlModifier ) {
299 }
else if ( ev->key() == Qt::Key_PageDown ) {
301 }
else if ( ev->key() == Qt::Key_Home ) {
303 }
else if ( ( ev->key() >= Qt::Key_0 && ev->key() <= Qt::Key_9 ) || ev->key() == Qt::Key_Minus || ev->key() == Qt::Key_Period ) {
309 if ( (
static_cast<double>( now.tv_sec ) +
310 static_cast<double>( now.tv_usec *
US_DIVIDER )) -
318 if ( ev->key() == Qt::Key_Period ) {
320 }
else if ( ev->key() == Qt::Key_Minus ) {
333 }
else if ( ev->key() == Qt::Key_Escape ) {
336 QToolTip::hideText();
343 QPoint p( mapToGlobal( QPoint( 0,0 ) ) );
344 QToolTip::showText( QPoint( p.x() + width(), p.y() ), QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ),
this, geometry(),
m_inputBufferTimeout * 1000 );
352 if (
m_bUseIntSteps && std::fmod( fMin, 1.0 ) != 0.0 && ! std::isinf( fMin ) ) {
353 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply minimal value [%1] will be rounded to [%2] " )
355 .arg( std::round( fMin ) ) );
356 fMin = std::round( fMin );
360 ___ERRORLOG( QString(
"Supplied value [%1] must be smaller than maximal one [%2]" )
361 .arg( fMin ).arg(
m_fMax ) );
380 if (
m_bUseIntSteps && std::fmod( fMax, 1.0 ) != 0.0 && ! std::isinf( fMax ) ) {
381 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply maximal value [%1] will be rounded to [%2] " )
383 .arg( std::round( fMax ) ) );
384 fMax = std::round( fMax );
388 ___ERRORLOG( QString(
"Supplied value [%1] must be bigger than the minimal one [%2]" )
389 .arg( fMax ).arg(
m_fMin ) );
410 if (
m_bUseIntSteps && std::fmod( fDefaultValue, 1.0 ) != 0.0 && ! std::isinf( fDefaultValue ) ) {
411 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply default value [%1] will be rounded to [%2] " )
412 .arg( fDefaultValue )
413 .arg( std::round( fDefaultValue ) ) );
414 fDefaultValue = std::round( fDefaultValue );
417 if ( fDefaultValue <
m_fMin ) {
420 else if ( fDefaultValue >
m_fMax ) {
int gettimeofday(struct timeval *tv, struct timezone *tz)
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
static QString EventToQString(Event event)
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()
std::vector< std::pair< H2Core::MidiMessage::Event, int > > m_registeredMidiEvents
Stores all MIDI events mapped to m_pAction.
std::shared_ptr< Action > m_pAction