Wed, 25 May 2022 20:36:34 +0300
Fix pick() picking from weird places on the screen with high DPI scaling
glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account
16 | 1 | #include <QAction> |
2 | #include "keyboardshortcutseditor.h" | |
3 | #include "uiutilities.h" | |
4 | ||
5 | KeyboardShortcutsEditor::KeyboardShortcutsEditor(QObject* subject, QObject* parent) : | |
6 | QAbstractTableModel{parent}, | |
7 | actions{uiutilities::collectActions(subject)} | |
8 | { | |
9 | } | |
10 | ||
11 | int KeyboardShortcutsEditor::rowCount(const QModelIndex&) const | |
12 | { | |
13 | return this->actions.size(); | |
14 | } | |
15 | ||
16 | int KeyboardShortcutsEditor::columnCount(const QModelIndex&) const | |
17 | { | |
18 | return 2; | |
19 | } | |
20 | ||
21 | QVariant KeyboardShortcutsEditor::data( | |
22 | const QModelIndex& index, | |
23 | int role) const | |
24 | { | |
25 | QAction* const action = this->actions[index.row()]; | |
26 | const Column column = static_cast<Column>(index.column()); | |
27 | switch(role) | |
28 | { | |
29 | case Qt::DisplayRole: | |
30 | switch (column) { | |
31 | case TitleColumn: | |
32 | return action->text(); | |
33 | case ShortcutColumn: | |
34 | return action->shortcut().toString(QKeySequence::NativeText); | |
35 | } | |
36 | break; | |
37 | } | |
38 | return {}; | |
39 | } | |
40 | ||
41 | QVariant KeyboardShortcutsEditor::headerData( | |
42 | int section, | |
43 | Qt::Orientation orientation, | |
44 | int role) const | |
45 | { | |
46 | if (orientation == Qt::Horizontal and role == Qt::DisplayRole) | |
47 | { | |
48 | switch (static_cast<Column>(section)) | |
49 | { | |
50 | case TitleColumn: | |
51 | return tr("Action"); | |
52 | case ShortcutColumn: | |
53 | return tr("Shortcut"); | |
54 | } | |
55 | } | |
56 | return {}; | |
57 | } | |
58 |