Qt: Properly handle modifier keys for input
This commit is contained in:
@@ -3,10 +3,15 @@
|
||||
#include <initializer_list>
|
||||
#include <optional>
|
||||
|
||||
class QKeyEvent;
|
||||
class QTableView;
|
||||
class QWidget;
|
||||
|
||||
namespace QtUtils {
|
||||
|
||||
/// Returns the greatest parent of a widget, i.e. its dialog/window.
|
||||
QWidget* GetRootWidget(QWidget* widget, bool stop_at_window_or_dialog = true);
|
||||
|
||||
/// Resizes columns of the table view to at the specified widths. A width of -1 will stretch the column to use the
|
||||
/// remaining space.
|
||||
void ResizeColumnsForTableView(QTableView* view, const std::initializer_list<int>& widths);
|
||||
@@ -17,4 +22,13 @@ QString GetKeyIdentifier(int key);
|
||||
/// Returns the integer Qt key ID for an identifier.
|
||||
std::optional<int> GetKeyIdForIdentifier(const QString& key_identifier);
|
||||
|
||||
/// Stringizes a key event.
|
||||
QString KeyEventToString(const QKeyEvent* ke);
|
||||
|
||||
/// Returns an integer id for a stringized key event. Modifiers are in the upper bits.
|
||||
std::optional<int> ParseKeyString(const QString& key_str);
|
||||
|
||||
/// Returns a key id for a key event, including any modifiers.
|
||||
int KeyEventToInt(const QKeyEvent* ke);
|
||||
|
||||
} // namespace QtUtils
|
||||
Reference in New Issue
Block a user