-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX(client): Fix using the keyboad to change local volume adjustment #6238
Merged
Hartmnt
merged 1 commit into
mumble-voip:master
from
Hartmnt:fix_volume_slider_keyboard
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2023 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#include "EventFilters.h" | ||
|
||
#include <algorithm> | ||
|
||
#include <QKeyEvent> | ||
#include <QWheelEvent> | ||
#include <QWidget> | ||
|
||
KeyEventObserver::KeyEventObserver(QObject *parent, QEvent::Type eventType, bool consume, std::vector< Qt::Key > keys) | ||
: QObject(parent), m_eventType(eventType), m_consume(consume), m_keys(std::move(keys)) { | ||
} | ||
|
||
bool KeyEventObserver::eventFilter(QObject *obj, QEvent *event) { | ||
QWidget *widget = static_cast< QWidget * >(obj); | ||
|
||
if (!widget || !widget->hasFocus()) { | ||
return false; | ||
} | ||
|
||
QKeyEvent *keyEvent = static_cast< QKeyEvent * >(event); | ||
|
||
if (!keyEvent || keyEvent->type() != m_eventType) { | ||
return false; | ||
} | ||
|
||
Qt::Key key = static_cast< Qt::Key >(keyEvent->key()); | ||
|
||
if (std::find(m_keys.begin(), m_keys.end(), key) == m_keys.end()) { | ||
return false; | ||
} | ||
|
||
emit keyEventObserved(); | ||
|
||
return m_consume; | ||
} | ||
|
||
MouseWheelEventObserver::MouseWheelEventObserver(QObject *parent, std::vector< Qt::ScrollPhase > phases, bool consume) | ||
: QObject(parent), m_phases(std::move(phases)), m_consume(consume) { | ||
} | ||
|
||
bool MouseWheelEventObserver::eventFilter(QObject *obj, QEvent *event) { | ||
QWidget *widget = static_cast< QWidget * >(obj); | ||
|
||
if (!widget || !widget->isVisible()) { | ||
return false; | ||
} | ||
|
||
QWheelEvent *wheelEvent = static_cast< QWheelEvent * >(event); | ||
|
||
if (!wheelEvent) { | ||
return false; | ||
} | ||
|
||
Qt::ScrollPhase phase = wheelEvent->phase(); | ||
|
||
if (std::find(m_phases.begin(), m_phases.end(), phase) == m_phases.end()) { | ||
return false; | ||
} | ||
|
||
emit wheelEventObserved(wheelEvent->pixelDelta()); | ||
|
||
return m_consume; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#ifndef MUMBLE_MUMBLE_WIDGETS_EVENTFILTERS_H_ | ||
#define MUMBLE_MUMBLE_WIDGETS_EVENTFILTERS_H_ | ||
|
||
#include <vector> | ||
|
||
#include <QEvent> | ||
#include <QObject> | ||
#include <QPoint> | ||
|
||
class KeyEventObserver : public QObject { | ||
Q_OBJECT | ||
|
||
public: | ||
KeyEventObserver(QObject *parent, QEvent::Type eventType, bool consume, std::vector< Qt::Key > keys); | ||
|
||
protected: | ||
bool eventFilter(QObject *obj, QEvent *event) override; | ||
|
||
signals: | ||
void keyEventObserved(); | ||
|
||
private: | ||
QEvent::Type m_eventType; | ||
bool m_consume; | ||
std::vector< Qt::Key > m_keys; | ||
}; | ||
|
||
class MouseWheelEventObserver : public QObject { | ||
Hartmnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Q_OBJECT | ||
|
||
public: | ||
MouseWheelEventObserver(QObject *parent, std::vector< Qt::ScrollPhase > phases, bool consume); | ||
|
||
protected: | ||
bool eventFilter(QObject *obj, QEvent *event) override; | ||
|
||
signals: | ||
void wheelEventObserved(QPoint delta); | ||
|
||
private: | ||
std::vector< Qt::ScrollPhase > m_phases; | ||
bool m_consume; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 2s would probably also be sufficient. But I'm also fine with leaving this at 3s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh, I have excessively tested all the timings for 3s now. And I really do not feel like going over that all over again with 2s :/