macOS: Change drag copy shortcut from Command to Option (#7325)
macOS: Replace Command + Drag shortcut key with Option + Drag Add new header `KeyboardShortcuts.h` for platform-specific keyboard mappings --------- Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
This commit is contained in:
77
include/KeyboardShortcuts.h
Normal file
77
include/KeyboardShortcuts.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* KeyboardShortcuts.h - Cross-platform handling of keyboard modifier keys
|
||||
*
|
||||
* Copyright (c) 2025 Michael Gregorius
|
||||
* Copyright (c) 2025 Tres Finocchiaro <tres.finocchiaro/at/gmail.com>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LMMS_KEYBOARDSHORTCUTS_H
|
||||
#define LMMS_KEYBOARDSHORTCUTS_H
|
||||
|
||||
#include "lmmsconfig.h"
|
||||
|
||||
#include "qnamespace.h"
|
||||
|
||||
|
||||
namespace lmms
|
||||
{
|
||||
|
||||
// Qt on macOS maps:
|
||||
// - ControlModifier --> Command keys
|
||||
// - MetaModifier value --> Control keys
|
||||
// - Qt::AltModifier --> Option keys
|
||||
//
|
||||
// Our UI hints need to be adjusted to accommodate for this
|
||||
constexpr const char* UI_CTRL_KEY =
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘";
|
||||
#else
|
||||
"Ctrl";
|
||||
#endif
|
||||
|
||||
constexpr const char* UI_ALT_KEY =
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"Option";
|
||||
#else
|
||||
"Alt";
|
||||
#endif
|
||||
|
||||
// UI hint for copying OR linking a UI component
|
||||
// this MUST be consistent with KBD_COPY_MODIFIER
|
||||
constexpr const char* UI_COPY_KEY =
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
UI_ALT_KEY;
|
||||
#else
|
||||
UI_CTRL_KEY;
|
||||
#endif
|
||||
|
||||
// Shortcut for copying OR linking a UI component
|
||||
// this MUST be consistent with UI_COPY_KEY
|
||||
constexpr Qt::KeyboardModifier KBD_COPY_MODIFIER =
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
Qt::AltModifier;
|
||||
#else
|
||||
Qt::ControlModifier;
|
||||
#endif
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
#endif // LMMS_KEYBOARDSHORTCUTS_H
|
||||
@@ -69,15 +69,6 @@ constexpr char LADSPA_PATH_SEPERATOR =
|
||||
#define LMMS_STRINGIFY(s) LMMS_STR(s)
|
||||
#define LMMS_STR(PN) #PN
|
||||
|
||||
// Abstract away GUI CTRL key (linux/windows) vs ⌘ (apple)
|
||||
constexpr const char* UI_CTRL_KEY =
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
"⌘";
|
||||
#else
|
||||
"Ctrl";
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
#endif // LMMS_TYPES_H
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "AutomationNode.h"
|
||||
#include "AutomationClipView.h"
|
||||
#include "AutomationTrack.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "LocaleHelper.h"
|
||||
#include "Note.h"
|
||||
#include "PatternStore.h"
|
||||
@@ -952,7 +953,7 @@ QString AutomationClip::name() const
|
||||
{
|
||||
return m_objects.front()->fullDisplayName();
|
||||
}
|
||||
return tr( "Drag a control while pressing <%1>" ).arg(UI_CTRL_KEY);
|
||||
return tr( "Drag a control while pressing <%1>" ).arg(UI_COPY_KEY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "ControllerConnection.h"
|
||||
#include "embed.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MainWindow.h"
|
||||
#include "StringPairDrag.h"
|
||||
#include "Clipboard.h"
|
||||
@@ -171,7 +172,7 @@ void AutomatableModelView::unsetModel()
|
||||
|
||||
void AutomatableModelView::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
if( event->button() == Qt::LeftButton && event->modifiers() & Qt::ControlModifier )
|
||||
if (event->button() == Qt::LeftButton && event->modifiers() & KBD_COPY_MODIFIER)
|
||||
{
|
||||
new gui::StringPairDrag( "automatable_model", QString::number( modelUntyped()->id() ), QPixmap(), widget() );
|
||||
event->accept();
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "Instrument.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "InstrumentTrackWindow.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PatternStore.h"
|
||||
#include "PluginFactory.h"
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Song.h"
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ StringPairDrag::StringPairDrag( const QString & _key, const QString & _value,
|
||||
auto m = new QMimeData();
|
||||
m->setData( mimeType( MimeType::StringPair ), txt.toUtf8() );
|
||||
setMimeData( m );
|
||||
exec( Qt::LinkAction, Qt::LinkAction );
|
||||
exec( Qt::CopyAction, Qt::CopyAction );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "GuiApplication.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "InstrumentTrackView.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MidiClip.h"
|
||||
#include "MidiClipView.h"
|
||||
#include "Note.h"
|
||||
@@ -633,7 +634,7 @@ void ClipView::mousePressEvent( QMouseEvent * me )
|
||||
auto pClip = dynamic_cast<PatternClip*>(m_clip);
|
||||
const bool knifeMode = m_trackView->trackContainerView()->knifeMode();
|
||||
|
||||
if ( me->modifiers() & Qt::ControlModifier && !(sClip && knifeMode) )
|
||||
if (me->modifiers() & KBD_COPY_MODIFIER && !(sClip && knifeMode))
|
||||
{
|
||||
if( isSelected() )
|
||||
{
|
||||
@@ -726,7 +727,7 @@ void ClipView::mousePressEvent( QMouseEvent * me )
|
||||
QString hint = m_action == Action::Move || m_action == Action::MoveSelection
|
||||
? tr( "Press <%1> and drag to make a copy." )
|
||||
: tr( "Press <%1> for free resizing." );
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ), hint.arg(UI_CTRL_KEY),
|
||||
m_hint = TextFloat::displayMessage( tr( "Hint" ), hint.arg(UI_COPY_KEY),
|
||||
embed::getIconPixmap( "hint" ), 0 );
|
||||
}
|
||||
}
|
||||
@@ -824,7 +825,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me )
|
||||
}
|
||||
}
|
||||
|
||||
if( me->modifiers() & Qt::ControlModifier )
|
||||
if (me->modifiers() & KBD_COPY_MODIFIER)
|
||||
{
|
||||
delete m_hint;
|
||||
m_hint = nullptr;
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "GuiApplication.h"
|
||||
#include "FontHelper.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MidiClip.h"
|
||||
#include "PatternStore.h"
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "ConfigManager.h"
|
||||
#include "embed.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "NStateButton.h"
|
||||
#include "TextFloat.h"
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "InstrumentTrackView.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "Song.h"
|
||||
#include "StringPairDrag.h"
|
||||
@@ -180,9 +181,8 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) :
|
||||
*/
|
||||
void TrackOperationsWidget::mousePressEvent( QMouseEvent * me )
|
||||
{
|
||||
if( me->button() == Qt::LeftButton &&
|
||||
me->modifiers() & Qt::ControlModifier &&
|
||||
m_trackView->getTrack()->type() != Track::Type::Pattern)
|
||||
if (me->button() == Qt::LeftButton && me->modifiers() & KBD_COPY_MODIFIER &&
|
||||
m_trackView->getTrack()->type() != Track::Type::Pattern)
|
||||
{
|
||||
DataFile dataFile( DataFile::Type::DragNDropData );
|
||||
m_trackView->getTrack()->saveState( dataFile, dataFile.content() );
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "embed.h"
|
||||
#include "CaptionMenu.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "SimpleTextFloat.h"
|
||||
|
||||
namespace lmms::gui
|
||||
@@ -125,7 +126,7 @@ void Fader::mouseMoveEvent(QMouseEvent* mouseEvent)
|
||||
void Fader::mousePressEvent(QMouseEvent* mouseEvent)
|
||||
{
|
||||
if (mouseEvent->button() == Qt::LeftButton &&
|
||||
!(mouseEvent->modifiers() & Qt::ControlModifier))
|
||||
!(mouseEvent->modifiers() & KBD_COPY_MODIFIER))
|
||||
{
|
||||
AutomatableModel* thisModel = model();
|
||||
if (thisModel)
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "CaptionMenu.h"
|
||||
#include "ControllerConnection.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "LocaleHelper.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ProjectJournal.h"
|
||||
@@ -155,7 +156,7 @@ void FloatModelEditorBase::dropEvent(QDropEvent * de)
|
||||
void FloatModelEditorBase::mousePressEvent(QMouseEvent * me)
|
||||
{
|
||||
if (me->button() == Qt::LeftButton &&
|
||||
! (me->modifiers() & Qt::ControlModifier) &&
|
||||
! (me->modifiers() & KBD_COPY_MODIFIER) &&
|
||||
! (me->modifiers() & Qt::ShiftModifier))
|
||||
{
|
||||
AutomatableModel *thisModel = model();
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "embed.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "FontHelper.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "MainWindow.h"
|
||||
#include "lmms_math.h"
|
||||
|
||||
@@ -139,7 +140,7 @@ void LcdFloatSpinBox::mousePressEvent(QMouseEvent* event)
|
||||
m_intStep = event->x() < m_wholeDisplay.width();
|
||||
|
||||
if (event->button() == Qt::LeftButton &&
|
||||
!(event->modifiers() & Qt::ControlModifier) &&
|
||||
!(event->modifiers() & KBD_COPY_MODIFIER) &&
|
||||
event->y() < m_wholeDisplay.cellHeight() + 2)
|
||||
{
|
||||
m_mouseMoving = true;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "LcdSpinBox.h"
|
||||
#include "KeyboardShortcuts.h"
|
||||
#include "CaptionMenu.h"
|
||||
|
||||
|
||||
@@ -79,7 +80,7 @@ void LcdSpinBox::contextMenuEvent(QContextMenuEvent* event)
|
||||
void LcdSpinBox::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
if( event->button() == Qt::LeftButton &&
|
||||
! ( event->modifiers() & Qt::ControlModifier ) &&
|
||||
! (event->modifiers() & KBD_COPY_MODIFIER) &&
|
||||
event->y() < cellHeight() + 2 )
|
||||
{
|
||||
m_mouseMoving = true;
|
||||
|
||||
Reference in New Issue
Block a user