Skip to content

Commit

Permalink
Introduce getOSSpecificModifierKey
Browse files Browse the repository at this point in the history
Introduce `getOSSpecificModifierKey` to get rid of some more ifdefs.
  • Loading branch information
michaelgregorius committed Jan 12, 2025
1 parent 740d044 commit 85e4128
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
11 changes: 11 additions & 0 deletions include/OperatingSystemHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "lmmsconfig.h"

#include "qnamespace.h"


namespace lmms
{
Expand Down Expand Up @@ -62,6 +64,15 @@ constexpr const char* getOSSppecificModifierKeyString()
#endif
}

constexpr Qt::KeyboardModifier getOSSpecificModifierKey()
{
#ifdef LMMS_BUILD_APPLE
return Qt::AltModifier;
#else
return Qt::ControlModifier;
#endif
}

} // namespace lmms

#endif // LMMS_OPERATINGSYSTEMHELPERS_H
8 changes: 2 additions & 6 deletions src/gui/AutomatableModelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "embed.h"
#include "GuiApplication.h"
#include "MainWindow.h"
#include "OperatingSystemHelpers.h"
#include "StringPairDrag.h"
#include "Clipboard.h"

Expand Down Expand Up @@ -171,12 +172,7 @@ void AutomatableModelView::unsetModel()

void AutomatableModelView::mousePressEvent( QMouseEvent* event )
{
if( event->button() == Qt::LeftButton &&
#ifdef LMMS_BUILD_APPLE
event->modifiers() & Qt::AltModifier )
#else
event->modifiers() & Qt::ControlModifier )
#endif
if (event->button() == Qt::LeftButton && event->modifiers() & getOSSpecificModifierKey())
{
new gui::StringPairDrag( "automatable_model", QString::number( modelUntyped()->id() ), QPixmap(), widget() );
event->accept();
Expand Down
13 changes: 2 additions & 11 deletions src/gui/clips/ClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,7 @@ void ClipView::mousePressEvent( QMouseEvent * me )
auto pClip = dynamic_cast<PatternClip*>(m_clip);
const bool knifeMode = m_trackView->trackContainerView()->knifeMode();

#ifdef LMMS_BUILD_APPLE
if ( me->modifiers() & Qt::AltModifier &&
#else
if ( me->modifiers() & Qt::ControlModifier &&
#endif
!(sClip && knifeMode) )
if (me->modifiers() & getOSSpecificModifierKey() && !(sClip && knifeMode))
{
if( isSelected() )
{
Expand Down Expand Up @@ -830,11 +825,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me )
}
}

#ifdef LMMS_BUILD_APPLE
if( me->modifiers() & Qt::AltModifier )
#else
if( me->modifiers() & Qt::ControlModifier )
#endif
if (me->modifiers() & getOSSpecificModifierKey())
{
delete m_hint;
m_hint = nullptr;
Expand Down
9 changes: 2 additions & 7 deletions src/gui/tracks/TrackOperationsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,8 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) :
*/
void TrackOperationsWidget::mousePressEvent( QMouseEvent * me )
{
if( me->button() == Qt::LeftButton &&
#ifdef LMMS_BUILD_APPLE
me->modifiers() & Qt::AltModifier &&
#else
me->modifiers() & Qt::ControlModifier &&
#endif
m_trackView->getTrack()->type() != Track::Type::Pattern)
if (me->button() == Qt::LeftButton && me->modifiers() & getOSSpecificModifierKey() &&
m_trackView->getTrack()->type() != Track::Type::Pattern)
{
DataFile dataFile( DataFile::Type::DragNDropData );
m_trackView->getTrack()->saveState( dataFile, dataFile.content() );
Expand Down

0 comments on commit 85e4128

Please sign in to comment.