Changeset View
Standalone View
ui/formwidgets.cpp
Show First 20 Lines • Show All 1050 Lines • ▼ Show 20 Line(s) | 1043 | { | |||
---|---|---|---|---|---|
1051 | { | 1051 | { | ||
1052 | emit m_controller->requestRedo(); | 1052 | emit m_controller->requestRedo(); | ||
1053 | return true; | 1053 | return true; | ||
1054 | } | 1054 | } | ||
1055 | } | 1055 | } | ||
1056 | return QComboBox::event( e ); | 1056 | return QComboBox::event( e ); | ||
1057 | } | 1057 | } | ||
1058 | 1058 | | |||
1059 | // Code for additional action handling. | ||||
1060 | // Challenge: Change preprocessor magic to C++ magic! | ||||
1061 | | ||||
1062 | #define DEFINE_ADDITIONAL_ACTIONS(FormClass, BaseClass) \ | ||||
1063 | void FormClass::mousePressEvent( QMouseEvent *event ) \ | ||||
1064 | { \ | ||||
1065 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::MousePressed ); \ | ||||
1066 | if (act) \ | ||||
1067 | { \ | ||||
1068 | emit m_controller->signalAction( act ); \ | ||||
1069 | } \ | ||||
1070 | BaseClass::mousePressEvent( event ); \ | ||||
1071 | } \ | ||||
1072 | void FormClass::mouseReleaseEvent( QMouseEvent *event ) \ | ||||
1073 | { \ | ||||
1074 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::MouseReleased ); \ | ||||
1075 | if (act) \ | ||||
1076 | { \ | ||||
1077 | emit m_controller->signalAction( act ); \ | ||||
1078 | } \ | ||||
1079 | BaseClass::mouseReleaseEvent( event ); \ | ||||
1080 | } \ | ||||
aacid: This still triggers if you press the button inside a form, move the mouse outside the form and… | |||||
Right. I also tested with Acrobat and it only triggers if the mouse is released in the annotation area. aheinecke: > This still triggers if you press the button inside a form, move the mouse outside the form… | |||||
1081 | void FormClass::focusInEvent( QFocusEvent *event ) \ | ||||
1082 | { \ | ||||
1083 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::FocusIn ); \ | ||||
1084 | if (act) \ | ||||
1085 | { \ | ||||
Are you sure this should be an else? Why should activation action only be signaled if there's no mouse release action? Also, before we only did activation action for buttons, but now we do for lots of other forms, is that on purpose? aacid: Are you sure this should be an else? Why should activation action only be signaled if there's… | |||||
Good question. I checked in the spec and it should be the other way around. I was confused because Adobe Acrobat DC sets the "Mouse Released" action as the "A" entry of the annotation dictonary. This is parsed by poppler as the "Additional Action" Page 649 (Table 8.44) in the spec Says about the mouse released event: So it should be the other way around. Only execute the mouseReleased action if there is no activation action and execute the activation action otherwise. Checkboxes are handled differently because they trigger in the "doActivateAction" so that the action can also be triggered by scripts changing the checked state.
Yes this is on purpose. The activation action is not bound to buttons. I did not find it clearly stated in the spec but If I add a Mouse Release action on a textfield in Acrobat DC it is added as a Mouse Release action. And the Example from bug306818 uses a mouse action on a read only text field to hide the warning in there. aheinecke: > Are you sure this should be an else? Why should activation action only be signaled if there's… | |||||
Can you please add that explanation either as a comment somewhere in the code or as part of the git commit? It'll make it easier to find next time someone looks at the code and wonders why it has an "else " like i did. aacid: Can you please add that explanation either as a comment somewhere in the code or as part of the… | |||||
In the comment in line 1052ff I tried to do just that. A problem with the macros is that you cant properly do inline comments. aheinecke: In the comment in line 1052ff I tried to do just that. A problem with the macros is that you… | |||||
1086 | emit m_controller->signalAction( act ); \ | ||||
1087 | } \ | ||||
1088 | BaseClass::focusInEvent( event ); \ | ||||
1089 | } \ | ||||
1090 | void FormClass::focusOutEvent( QFocusEvent *event ) \ | ||||
1091 | { \ | ||||
1092 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::FocusOut ); \ | ||||
1093 | if (act) \ | ||||
1094 | { \ | ||||
1095 | emit m_controller->signalAction( act ); \ | ||||
1096 | } \ | ||||
1097 | BaseClass::focusOutEvent( event ); \ | ||||
1098 | } \ | ||||
1099 | void FormClass::leaveEvent( QEvent *event ) \ | ||||
1100 | { \ | ||||
1101 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::CursorLeaving ); \ | ||||
1102 | if (act) \ | ||||
1103 | { \ | ||||
1104 | emit m_controller->signalAction( act ); \ | ||||
1105 | } \ | ||||
1106 | BaseClass::leaveEvent( event ); \ | ||||
1107 | } \ | ||||
1108 | void FormClass::enterEvent( QEvent *event ) \ | ||||
1109 | { \ | ||||
1110 | Okular::Action *act = m_ff->additionalAction( Okular::FormField::CursorEntering ); \ | ||||
1111 | if (act) \ | ||||
1112 | { \ | ||||
1113 | emit m_controller->signalAction( act ); \ | ||||
1114 | } \ | ||||
1115 | BaseClass::enterEvent( event ); \ | ||||
1116 | } | ||||
1117 | | ||||
1118 | DEFINE_ADDITIONAL_ACTIONS(PushButtonEdit, QPushButton) | ||||
1119 | DEFINE_ADDITIONAL_ACTIONS(CheckBoxEdit, QCheckBox) | ||||
1120 | DEFINE_ADDITIONAL_ACTIONS(RadioButtonEdit, QRadioButton) | ||||
1121 | DEFINE_ADDITIONAL_ACTIONS(FormLineEdit, QLineEdit) | ||||
1122 | DEFINE_ADDITIONAL_ACTIONS(TextAreaEdit, KTextEdit) | ||||
1123 | DEFINE_ADDITIONAL_ACTIONS(FileEdit, KUrlRequester) | ||||
1124 | DEFINE_ADDITIONAL_ACTIONS(ListEdit, QListWidget) | ||||
1125 | DEFINE_ADDITIONAL_ACTIONS(ComboEdit, QComboBox) | ||||
1126 | | ||||
1127 | #undef DEFINE_ADDITIONAL_ACTIONS | ||||
1128 | | ||||
1059 | #include "moc_formwidgets.cpp" | 1129 | #include "moc_formwidgets.cpp" |
This still triggers if you press the button inside a form, move the mouse outside the form and release, not sure this is "according to spec", it says "An action to be performed when the mouse button is released inside the annotation’s active area."