Skip to content

Commit

Permalink
KeyboardEventFilter: move menubar toggle connection to WMainMenubar
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Oct 13, 2024
1 parent 44f47e9 commit 19b4434
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
13 changes: 13 additions & 0 deletions src/controllers/keyboard/keyboardeventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,21 @@ QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {
}

void KeyboardEventFilter::setEnabled(bool enabled) {
if (enabled) {
kLogger.debug() << "Enable keyboard shortcuts/mappings";
} else {
kLogger.debug() << "Disable keyboard shortcuts/mappings";
}
m_enabled = enabled;
m_pConfig->setValue(ConfigKey("[Keyboard]", "Enabled"), enabled);
// Shortcuts may be toggled off and on again to make Mixxx discover a new
// Custom.kbd.cfg, so reload now.
// Note: the other way around (removing a loaded Custom.kbd.cfg) is covered
// by the auto-reloader and we'll try to load a built-in mapping then.
if (enabled) {
reloadKeyboardConfig();
}
// Update widget tooltips
emit shortcutsEnabled(enabled);
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/keyboard/keyboardeventfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class KeyboardEventFilter : public QObject {
// Returns a valid QString with modifier keys from a QKeyEvent
static QKeySequence getKeySeq(QKeyEvent* e);

void setEnabled(bool enabled);
bool isEnabled() {
return m_enabled;
}
Expand All @@ -51,6 +50,7 @@ class KeyboardEventFilter : public QObject {
void updateMenuBarActionShortcuts();

public slots:
void setEnabled(bool enabled);
void reloadKeyboardConfig();

signals:
Expand Down
10 changes: 0 additions & 10 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,16 +507,6 @@ std::shared_ptr<ConfigObject<ConfigValueKbd>> CoreServices::getKeyboardConfig()
return m_pKeyboardEventFilter->getKeyboardConfig();
}

void CoreServices::slotOptionsKeyboard(bool toggle) {
UserSettingsPointer pConfig = m_pSettingsManager->settings();
if (toggle) {
qDebug() << "Enable keyboard shortcuts/mappings";
} else {
qDebug() << "Disable keyboard shortcuts/mappings";
}
m_pKeyboardEventFilter->setEnabled(toggle);
}

bool CoreServices::initializeDatabase() {
kLogger.info() << "Connecting to database";
QSqlDatabase dbConnection = mixxx::DbConnectionPooled(m_pDbConnectionPool);
Expand Down
3 changes: 0 additions & 3 deletions src/coreservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class CoreServices : public QObject {
signals:
void initializationProgressUpdate(int progress, const QString& serviceName);

public slots:
void slotOptionsKeyboard(bool toggle);

private:
bool initializeDatabase();
void initializeKeyboard();
Expand Down
7 changes: 0 additions & 7 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,13 +834,6 @@ void MixxxMainWindow::connectMenuBar() {
// Refresh the Fullscreen checkbox for the case we went fullscreen earlier
m_pMenuBar->onFullScreenStateChange(isFullScreen());

// Keyboard shortcuts
connect(m_pMenuBar,
&WMainMenuBar::toggleKeyboardShortcuts,
m_pCoreServices.get(),
&mixxx::CoreServices::slotOptionsKeyboard,
Qt::UniqueConnection);

// Help
connect(m_pMenuBar,
&WMainMenuBar::showAbout,
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wmainmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void WMainMenuBar::initialize() {
pOptionsKeyboard->setChecked(keyboardShortcutsEnabled);
pOptionsKeyboard->setStatusTip(keyboardShortcutText);
pOptionsKeyboard->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
connect(pOptionsKeyboard, &QAction::triggered, this, &WMainMenuBar::toggleKeyboardShortcuts);
connect(pOptionsKeyboard, &QAction::triggered, m_pKeyboard, &KeyboardEventFilter::setEnabled);

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

no matching function for call to ‘WMainMenuBar::connect(QAction*&, void (QAction::*)(bool), std::shared_ptr<KeyboardEventFilter>&, void (KeyboardEventFilter::*)(bool))’

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / clazy

no matching member function for call to 'connect'

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / macOS 12 x64

no matching member function for call to 'connect'

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / macOS 12 arm64

no matching member function for call to 'connect'

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / coverage

no matching function for call to ‘WMainMenuBar::connect(QAction*&, void (QAction::*)(bool), std::shared_ptr<KeyboardEventFilter>&, void (KeyboardEventFilter::*)(bool))’

Check failure on line 461 in src/widget/wmainmenubar.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'QMetaObject::Connection QObject::connect<void(__cdecl QAction::* )(bool),void(__cdecl KeyboardEventFilter::* )(bool)>(const QAction *,Func1,const KeyboardEventFilter *,Func2,Qt::ConnectionType)': cannot convert argument 3 from 'std::shared_ptr<KeyboardEventFilter>' to 'const KeyboardEventFilter *'

pOptionsMenu->addAction(pOptionsKeyboard);

Expand Down

0 comments on commit 19b4434

Please sign in to comment.