Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 42 additions & 21 deletions src/controllers/keyboard/keyboardeventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
}

QKeySequence ks = getKeySeq(ke);
qWarning() << " > keySeq:" << ks.toString();
if (!ks.isEmpty()) {
qWarning() << " > lookup control";
ConfigValueKbd ksv(ks);
// Check if a shortcut is defined
bool result = false;
// using const_iterator here is faster than QMultiHash::values()
for (auto it = m_keySequenceToControlHash.constFind(ksv);
it != m_keySequenceToControlHash.constEnd() && it.key() == ksv; ++it) {
const ConfigKey& configKey = it.value();
qWarning() << " > found CfgKey:" << configKey.group << configKey.item;
if (configKey.group != "[KeyboardShortcuts]") {
ControlObject* control = ControlObject::getControl(configKey);
if (control) {
qWarning() << " > found control, set to 1";
//qDebug() << configKey << "MidiOpCode::NoteOn" << 1;
// Add key to active key list
m_qActiveKeyList.append(KeyDownInformation(
Expand All @@ -67,6 +71,9 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
}
}
}
if (result == false) {
qWarning() << " ! no CfgKey found";
}
return result;
}
} else if (e->type() == QEvent::KeyRelease) {
Expand Down Expand Up @@ -125,35 +132,37 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {
return {};
}

// Note: test for individual modifiers, don't use e->modifiers() for composing
// the QKeySequence because on macOS e->modifiers() would for some reason
// include the Num modifier for arrow keys which results in a key sequence
// for which there would be no match in our keyseq/control hash.
// See https://github.com/mixxxdj/mixxx/issues/13305
QString modseq;
if (e->modifiers() & Qt::ShiftModifier) {
modseq += "Shift+";
}
if (e->modifiers() & Qt::ControlModifier) {
modseq += "Ctrl+";
}
if (e->modifiers() & Qt::AltModifier) {
modseq += "Alt+";
}
if (e->modifiers() & Qt::MetaModifier) {
modseq += "Meta+";
}

const QString keyseq = QKeySequence(e->key()).toString();
const QKeySequence k = QKeySequence(modseq + keyseq);

if (CmdlineArgs::Instance().getDeveloper()) {
QString modseq;
QKeySequence k;
if (e->modifiers() & Qt::ShiftModifier) {
modseq += "Shift+";
}
if (e->modifiers() & Qt::ControlModifier) {
modseq += "Ctrl+";
}
if (e->modifiers() & Qt::AltModifier) {
modseq += "Alt+";
}
if (e->modifiers() & Qt::MetaModifier) {
modseq += "Meta+";
}
QString keyseq = QKeySequence(e->key()).toString();
k = QKeySequence(modseq + keyseq);
if (e->type() == QEvent::KeyPress) {
qDebug() << "keyboard press: " << k.toString();
} else if (e->type() == QEvent::KeyRelease) {
qDebug() << "keyboard release: " << k.toString();
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QKeySequence(e->modifiers() | e->key());
#else
return QKeySequence(e->modifiers() + e->key());
#endif
return k;
}

void KeyboardEventFilter::setKeyboardConfig(ConfigObject<ConfigValueKbd>* pKbdConfigObject) {
Expand All @@ -163,6 +172,18 @@ void KeyboardEventFilter::setKeyboardConfig(ConfigObject<ConfigValueKbd>* pKbdCo
// Mixxx.
m_keySequenceToControlHash = pKbdConfigObject->transpose();
m_pKbdConfigObject = pKbdConfigObject;

qWarning() << " m_keySequenceToControlHash:";
QHashIterator<ConfigValueKbd, ConfigKey> it(m_keySequenceToControlHash);
while (it.hasNext()) {
it.next();
const QKeySequence ks = it.key().value;
const QString kss = ks.toString();
if (kss.startsWith("Shift")) {
qWarning().noquote() << " " << ks.toString() << " "
<< it.value().group << it.value().item;
}
}
}

ConfigObject<ConfigValueKbd>* KeyboardEventFilter::getKeyboardConfig() {
Expand Down
4 changes: 4 additions & 0 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr
LoadToGroupController::~LoadToGroupController() = default;

void LoadToGroupController::slotLoadToGroup(double v) {
qWarning() << "LoadToGroupController::slotLoadToGroup" << m_group << "v:" << v;
if (v > 0) {
emit loadToGroup(m_group, false);
}
Expand Down Expand Up @@ -536,12 +537,15 @@ void LibraryControl::slotUpdateTrackMenuControl(bool visible) {
}

void LibraryControl::slotLoadSelectedTrackToGroup(const QString& group, bool play) {
qWarning() << "LibraryControl::slotLoadSelectedTrackToGroup:" << group << play;
if (!m_pLibraryWidget) {
qWarning() << " ! no WLibrary widget";
return;
}

LibraryView* pActiveView = m_pLibraryWidget->getActiveView();
if (!pActiveView) {
qWarning() << " ! no active view";
return;
}
pActiveView->loadSelectedTrackToGroup(group, play);
Expand Down
3 changes: 3 additions & 0 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ void BaseTrackPlayerImpl::loadTrack(TrackPointer pTrack) {
m_pLoadedTrack = std::move(pTrack);
if (!m_pLoadedTrack) {
// nothing to
qWarning() << " ! no track to load";
return;
}
qWarning() << " >> load track";

// Clear loop
// It seems that the trick is to first clear the loop out point, and then
Expand Down Expand Up @@ -489,6 +491,7 @@ void BaseTrackPlayerImpl::slotLoadTrack(TrackPointer pNewTrack, bool bPlay) {
auto fileInfo = pNewTrack->getFileInfo();
if (!Sandbox::askForAccess(&fileInfo)) {
// We don't have access.
qWarning() << " ! can't read" << fileInfo.location();
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ template <class ValueType> bool ConfigObject<ValueType>::parse() {
qDebug() << "ConfigObject: Could not read" << m_filename;
return false;
} else {
//qDebug() << "ConfigObject: Parse" << m_filename;
qDebug() << "ConfigObject: Parse" << m_filename;
// Parse the file
int group = 0;
QString groupStr, line;
Expand All @@ -210,7 +210,7 @@ template <class ValueType> bool ConfigObject<ValueType>::parse() {
QTextStream(&line) >> key;
QString val = line.right(line.length() - key.length()); // finds the value string
val = val.trimmed();
//qDebug() << "control:" << key << "value:" << val;
qWarning().noquote() << "control:" << groupStr << key << " " << val;
ConfigKey k(groupStr, key);
ValueType m(val);
set(k, m);
Expand Down
16 changes: 13 additions & 3 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,10 @@ void WTrackTableView::activateSelectedTrack() {
}

void WTrackTableView::loadSelectedTrackToGroup(const QString& group, bool play) {
qDebug() << "WTrackTableView::loadSelectedTrackToGroup:" << group << play;
auto indices = selectionModel()->selectedRows();
if (indices.isEmpty()) {
qWarning() << " ! indices empty";
return;
}
bool allowLoadTrackIntoPlayingDeck = false;
Expand All @@ -1032,15 +1034,23 @@ void WTrackTableView::loadSelectedTrackToGroup(const QString& group, bool play)
// TODO(XXX): Check for other than just the first preview deck.
if (group != "[PreviewDeck1]" &&
ControlObject::get(ConfigKey(group, "play")) > 0.0) {
qWarning() << " ! not allowed to load to this deck, might be playing";
return;
}
}
auto index = indices.at(0);
auto* trackModel = getTrackModel();
TrackPointer pTrack;
if (trackModel &&
(pTrack = trackModel->getTrack(index))) {
emit loadTrackToPlayer(pTrack, group, play);
if (trackModel) {
pTrack = trackModel->getTrack(index);
if (pTrack) {
qWarning() << " > emit loadTrackToPlayer, deck:" << group;
emit loadTrackToPlayer(pTrack, group, play);
} else {
qWarning() << " ! track is nullptr";
}
} else {
qWarning() << " ! no track model";
}
}

Expand Down