Skip to content

Commit 0714165

Browse files
committed
feat: add preferences dialog for shortcut configuration
- recording of key sequences amd mouse/stylus buttons - collect actions, filtering, collision detection - persist shortcut settings
1 parent a7685ae commit 0714165

File tree

4 files changed

+459
-2
lines changed

4 files changed

+459
-2
lines changed

resources/forms/preferences.ui

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,175 @@
10951095
</item>
10961096
</layout>
10971097
</widget>
1098+
<widget class="QWidget" name="shortcutTab">
1099+
<attribute name="title">
1100+
<string>Shortcut</string>
1101+
</attribute>
1102+
<layout class="QVBoxLayout" name="verticalLayout_4">
1103+
<item>
1104+
<widget class="QLineEdit" name="filter">
1105+
<property name="placeholderText">
1106+
<string>Filter</string>
1107+
</property>
1108+
</widget>
1109+
</item>
1110+
<item>
1111+
<widget class="QScrollArea" name="shortcutScrollArea">
1112+
<property name="widgetResizable">
1113+
<bool>true</bool>
1114+
</property>
1115+
<widget class="QWidget" name="scrollAreaWidgetContents">
1116+
<property name="geometry">
1117+
<rect>
1118+
<x>0</x>
1119+
<y>0</y>
1120+
<width>789</width>
1121+
<height>447</height>
1122+
</rect>
1123+
</property>
1124+
<layout class="QVBoxLayout" name="verticalLayout_41">
1125+
<item>
1126+
<widget class="QTableView" name="shortcutTableView">
1127+
<property name="editTriggers">
1128+
<set>QAbstractItemView::NoEditTriggers</set>
1129+
</property>
1130+
<property name="showDropIndicator" stdset="0">
1131+
<bool>false</bool>
1132+
</property>
1133+
<property name="selectionMode">
1134+
<enum>QAbstractItemView::SingleSelection</enum>
1135+
</property>
1136+
<property name="selectionBehavior">
1137+
<enum>QAbstractItemView::SelectRows</enum>
1138+
</property>
1139+
<property name="showGrid">
1140+
<bool>false</bool>
1141+
</property>
1142+
<property name="wordWrap">
1143+
<bool>false</bool>
1144+
</property>
1145+
<attribute name="horizontalHeaderCascadingSectionResizes">
1146+
<bool>true</bool>
1147+
</attribute>
1148+
<attribute name="verticalHeaderVisible">
1149+
<bool>false</bool>
1150+
</attribute>
1151+
<attribute name="verticalHeaderMinimumSectionSize">
1152+
<number>25</number>
1153+
</attribute>
1154+
<attribute name="verticalHeaderDefaultSectionSize">
1155+
<number>25</number>
1156+
</attribute>
1157+
</widget>
1158+
</item>
1159+
</layout>
1160+
</widget>
1161+
</widget>
1162+
</item>
1163+
<item>
1164+
<layout class="QHBoxLayout" name="horizontalLayout_11">
1165+
<item>
1166+
<widget class="QCheckBox" name="noCtrl">
1167+
<property name="text">
1168+
<string>Active keyboard shortcuts without pressing Ctrl key</string>
1169+
</property>
1170+
</widget>
1171+
</item>
1172+
</layout>
1173+
</item>
1174+
<item>
1175+
<widget class="QGroupBox" name="shortcutsGroupBox">
1176+
<property name="enabled">
1177+
<bool>false</bool>
1178+
</property>
1179+
<property name="title">
1180+
<string>Shortcuts</string>
1181+
</property>
1182+
<property name="alignment">
1183+
<set>Qt::AlignCenter</set>
1184+
</property>
1185+
<layout class="QGridLayout" name="gridLayout_20">
1186+
<item row="3" column="0" colspan="2">
1187+
<widget class="QLabel" name="report">
1188+
<property name="styleSheet">
1189+
<string notr="true">color: red;</string>
1190+
</property>
1191+
<property name="textFormat">
1192+
<enum>Qt::PlainText</enum>
1193+
</property>
1194+
</widget>
1195+
</item>
1196+
<item row="2" column="1">
1197+
<widget class="QLineEdit" name="stylusButton">
1198+
<property name="readOnly">
1199+
<bool>true</bool>
1200+
</property>
1201+
</widget>
1202+
</item>
1203+
<item row="1" column="2">
1204+
<widget class="QPushButton" name="abortButton">
1205+
<property name="text">
1206+
<string>Abort</string>
1207+
</property>
1208+
</widget>
1209+
</item>
1210+
<item row="0" column="2">
1211+
<widget class="QPushButton" name="recordButton">
1212+
<property name="text">
1213+
<string>Record</string>
1214+
</property>
1215+
<property name="checkable">
1216+
<bool>true</bool>
1217+
</property>
1218+
</widget>
1219+
</item>
1220+
<item row="2" column="0">
1221+
<widget class="QLabel" name="label_5">
1222+
<property name="text">
1223+
<string>Stylus Button</string>
1224+
</property>
1225+
</widget>
1226+
</item>
1227+
<item row="1" column="0">
1228+
<widget class="QLabel" name="label_2">
1229+
<property name="text">
1230+
<string>Mouse Button</string>
1231+
</property>
1232+
</widget>
1233+
</item>
1234+
<item row="1" column="1">
1235+
<widget class="QLineEdit" name="mouseButton">
1236+
<property name="readOnly">
1237+
<bool>true</bool>
1238+
</property>
1239+
</widget>
1240+
</item>
1241+
<item row="0" column="1">
1242+
<widget class="QLineEdit" name="keySequence">
1243+
<property name="readOnly">
1244+
<bool>true</bool>
1245+
</property>
1246+
</widget>
1247+
</item>
1248+
<item row="2" column="2">
1249+
<widget class="QPushButton" name="resetButton">
1250+
<property name="text">
1251+
<string>Reset</string>
1252+
</property>
1253+
</widget>
1254+
</item>
1255+
<item row="0" column="0">
1256+
<widget class="QLabel" name="label_4">
1257+
<property name="text">
1258+
<string>Key Sequence</string>
1259+
</property>
1260+
</widget>
1261+
</item>
1262+
</layout>
1263+
</widget>
1264+
</item>
1265+
</layout>
1266+
</widget>
10981267
<widget class="QWidget" name="thirdPartyLicence">
10991268
<property name="enabled">
11001269
<bool>true</bool>

src/core/UBApplication.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,34 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event)
704704
|| result;
705705
}
706706

707+
else if (event->type() == QEvent::MouseButtonPress)
708+
{
709+
// intercept special mouse buttons for shortcut handler
710+
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
711+
Qt::MouseButton button = mouseEvent->button();
712+
713+
if (button != Qt::LeftButton && button != Qt::RightButton)
714+
{
715+
return mPreferencesController->handleMouseEvent(mouseEvent)
716+
|| UBShortcutManager::shortcutManager()->handleMouseEvent(mouseEvent)
717+
|| result;
718+
}
719+
}
720+
721+
else if (event->type() == QEvent::TabletPress)
722+
{
723+
// intercept special tablet buttons for shortcut handler
724+
QTabletEvent *tabletEvent = static_cast<QTabletEvent *>(event);
725+
Qt::MouseButton button = tabletEvent->button();
726+
727+
if (button != Qt::LeftButton)
728+
{
729+
return mPreferencesController->handleTabletEvent(tabletEvent)
730+
|| UBShortcutManager::shortcutManager()->handleTabletEvent(tabletEvent)
731+
|| result;
732+
}
733+
}
734+
707735
return result;
708736
}
709737

0 commit comments

Comments
 (0)