40WidgetWithInput::WidgetWithInput( QWidget* parent,
bool bUseIntSteps, QString sBaseTooltip,
int nScrollSpeed,
int nScrollSpeedFast,
float fMin,
float fMax,
bool bModifyOnChange )
61 setAttribute( Qt::WA_Hover );
62 setFocusPolicy( Qt::ClickFocus );
75 .arg( pCommonStrings->getRangeTooltip() )
80 sTip.append( QString(
"\n%1: %2 " ).arg( pCommonStrings->getMidiTooltipHeading() )
86 sTip.append( QString(
"\n%1 [%2 : %3]" )
87 .arg( pCommonStrings->getMidiTooltipBound() )
93 sTip.append( QString(
"\n%1 [%2]" )
94 .arg( pCommonStrings->getMidiTooltipBound() )
101 sTip.append( QString(
"%1" ).arg( pCommonStrings->getMidiTooltipUnbound() ) );
120 fValue = std::round( fValue );
122 if ( std::abs( fValue ) < 1E-6 ) {
140 else if ( fValue >
m_fMax ) {
165 if ( ev->button() == Qt::LeftButton && ev->modifiers() == Qt::ControlModifier ) {
169 else if ( ev->button() == Qt::LeftButton && ev->modifiers() == Qt::ShiftModifier ) {
176 setCursor( QCursor( Qt::SizeVerCursor ) );
182 QToolTip::showText( pEv->globalPosition().toPoint(),
183 QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
194 setCursor( QCursor( Qt::ArrowCursor ) );
212 if ( ev->modifiers() == Qt::ControlModifier ) {
220 fDelta = fRange / 100.0;
222 if ( ev->angleDelta().y() < 0 ) {
228 QToolTip::showText( pEv->globalPosition().toPoint(),
229 QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
245 if ( ev->modifiers() == Qt::ControlModifier ) {
254 float fNewValue = (
m_fMousePressValue - fStepFactor * ( fDeltaY / 100.0 * fRange ) );
258 QToolTip::showText( pEv->globalPosition().toPoint(),
259 QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ) ,
this );
262#ifdef H2CORE_HAVE_QT6
291 if ( ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Up ) {
292 if ( ev->modifiers() == Qt::ControlModifier ) {
298 }
else if ( ev->key() == Qt::Key_PageUp ) {
300 }
else if ( ev->key() == Qt::Key_Home ) {
302 }
else if ( ev->key() == Qt::Key_Left || ev->key() == Qt::Key_Down ) {
303 if ( ev->modifiers() == Qt::ControlModifier ) {
309 }
else if ( ev->key() == Qt::Key_PageDown ) {
311 }
else if ( ev->key() == Qt::Key_Home ) {
313 }
else if ( ( ev->key() >= Qt::Key_0 && ev->key() <= Qt::Key_9 ) || ev->key() == Qt::Key_Minus || ev->key() == Qt::Key_Period ) {
319 if ( (
static_cast<double>( now.tv_sec ) +
320 static_cast<double>( now.tv_usec *
US_DIVIDER )) -
328 if ( ev->key() == Qt::Key_Period ) {
330 }
else if ( ev->key() == Qt::Key_Minus ) {
343 }
else if ( ev->key() == Qt::Key_Escape ) {
346 QToolTip::hideText();
353 QPoint p( mapToGlobal( QPoint( 0,0 ) ) );
354 QToolTip::showText( QPoint( p.x() + width(), p.y() ), QString(
"%1" ).arg(
m_fValue, 0,
'f', 2 ),
this, geometry(),
m_inputBufferTimeout * 1000 );
362 if (
m_bUseIntSteps && std::fmod( fMin, 1.0 ) != 0.0 && ! std::isinf( fMin ) ) {
363 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply minimal value [%1] will be rounded to [%2] " )
365 .arg( std::round( fMin ) ) );
366 fMin = std::round( fMin );
370 ___ERRORLOG( QString(
"Supplied value [%1] must be smaller than maximal one [%2]" )
371 .arg( fMin ).arg(
m_fMax ) );
390 if (
m_bUseIntSteps && std::fmod( fMax, 1.0 ) != 0.0 && ! std::isinf( fMax ) ) {
391 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply maximal value [%1] will be rounded to [%2] " )
393 .arg( std::round( fMax ) ) );
394 fMax = std::round( fMax );
398 ___ERRORLOG( QString(
"Supplied value [%1] must be bigger than the minimal one [%2]" )
399 .arg( fMax ).arg(
m_fMin ) );
420 if (
m_bUseIntSteps && std::fmod( fDefaultValue, 1.0 ) != 0.0 && ! std::isinf( fDefaultValue ) ) {
421 ___WARNINGLOG( QString(
"As widget is set to use integer values only the supply default value [%1] will be rounded to [%2] " )
422 .arg( fDefaultValue )
423 .arg( std::round( fDefaultValue ) ) );
424 fDefaultValue = std::round( fDefaultValue );
427 if ( fDefaultValue <
m_fMin ) {
430 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
Compatibility class to support QMouseEvent more esily in Qt5 and Qt6.
Compatibility class to support QWheelEvent more esily in Qt5 and Qt6.