Skip to content

Commit

Permalink
feat: add preferences dialog for shortcut configuration
Browse files Browse the repository at this point in the history
- recording of key sequences amd mouse/stylus buttons
- collect actions, filtering, collision detection
- persist shortcut settings
  • Loading branch information
letsfindaway committed Sep 30, 2024
1 parent 6d9fb28 commit 7c3442d
Show file tree
Hide file tree
Showing 4 changed files with 459 additions and 2 deletions.
169 changes: 169 additions & 0 deletions resources/forms/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,175 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="shortcutTab">
<attribute name="title">
<string>Shortcut</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLineEdit" name="filter">
<property name="placeholderText">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="shortcutScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>789</width>
<height>447</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_41">
<item>
<widget class="QTableView" name="shortcutTableView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QCheckBox" name="noCtrl">
<property name="text">
<string>Active keyboard shortcuts without pressing Ctrl key</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="shortcutsGroupBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Shortcuts</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_20">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="report">
<property name="styleSheet">
<string notr="true">color: red;</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="stylusButton">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="abortButton">
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="recordButton">
<property name="text">
<string>Record</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Stylus Button</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mouse Button</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mouseButton">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="keySequence">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="resetButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Key Sequence</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="thirdPartyLicence">
<property name="enabled">
<bool>true</bool>
Expand Down
28 changes: 28 additions & 0 deletions src/core/UBApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,34 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event)
|| result;
}

else if (event->type() == QEvent::MouseButtonPress)
{
// intercept special mouse buttons for shortcut handler
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
Qt::MouseButton button = mouseEvent->button();

if (button != Qt::LeftButton && button != Qt::RightButton)
{
return mPreferencesController->handleMouseEvent(mouseEvent)
|| UBShortcutManager::shortcutManager()->handleMouseEvent(mouseEvent)
|| result;
}
}

else if (event->type() == QEvent::TabletPress)
{
// intercept special tablet buttons for shortcut handler
QTabletEvent *tabletEvent = static_cast<QTabletEvent *>(event);
Qt::MouseButton button = tabletEvent->button();

if (button != Qt::LeftButton)
{
return mPreferencesController->handleTabletEvent(tabletEvent)
|| UBShortcutManager::shortcutManager()->handleTabletEvent(tabletEvent)
|| result;
}
}

return result;
}

Expand Down
Loading

0 comments on commit 7c3442d

Please sign in to comment.