Changeset View
Changeset View
Standalone View
Standalone View
ui/formwidgets.cpp
Show First 20 Lines • Show All 1054 Lines • ▼ Show 20 Line(s) | 1054 | { | |||
---|---|---|---|---|---|
1055 | emit m_controller->requestRedo(); | 1055 | emit m_controller->requestRedo(); | ||
1056 | return true; | 1056 | return true; | ||
1057 | } | 1057 | } | ||
1058 | } | 1058 | } | ||
1059 | return QComboBox::event( e ); | 1059 | return QComboBox::event( e ); | ||
1060 | } | 1060 | } | ||
1061 | 1061 | | |||
1062 | SignatureEdit::SignatureEdit( Okular::FormFieldSignature * signature, QWidget * parent ) | 1062 | SignatureEdit::SignatureEdit( Okular::FormFieldSignature * signature, QWidget * parent ) | ||
1063 | : QAbstractButton( parent ), FormWidgetIface( this, signature ), m_lefMouseButtonPressed( false ) | 1063 | : QAbstractButton( parent ), FormWidgetIface( this, signature ), | ||
1064 | m_widgetPressed( false ), m_dummyMode( false ), m_wasVisible( false ) | ||||
1064 | { | 1065 | { | ||
1065 | setCheckable( false ); | 1066 | setCheckable( false ); | ||
1066 | setCursor( Qt::PointingHandCursor ); | 1067 | setCursor( Qt::PointingHandCursor ); | ||
1067 | connect( this, &SignatureEdit::clicked, this, &SignatureEdit::slotViewProperties ); | 1068 | connect( this, &SignatureEdit::clicked, this, &SignatureEdit::slotViewProperties ); | ||
1068 | } | 1069 | } | ||
1069 | 1070 | | |||
1071 | void SignatureEdit::setDummyMode( bool set ) | ||||
1072 | { | ||||
1073 | m_dummyMode = set; | ||||
1074 | if ( m_dummyMode ) | ||||
1075 | { | ||||
1076 | m_wasVisible = isVisible(); | ||||
1077 | //if widget was hidden then show it. | ||||
1078 | //even if it wasn't hidden calling this will still update the background. | ||||
1079 | setVisibility( true ); | ||||
1080 | } | ||||
1081 | else | ||||
1082 | { | ||||
1083 | //forms were not visible before this call so hide this widget. | ||||
1084 | if ( !m_wasVisible ) | ||||
1085 | setVisibility( false ); | ||||
1086 | //forms were visible even before this call so only update the background color. | ||||
1087 | else | ||||
1088 | update(); | ||||
1089 | } | ||||
1090 | } | ||||
1091 | | ||||
1070 | bool SignatureEdit::event( QEvent * e ) | 1092 | bool SignatureEdit::event( QEvent * e ) | ||
1071 | { | 1093 | { | ||
1094 | if ( m_dummyMode && e->type() != QEvent::Paint ) | ||||
1095 | { | ||||
1096 | e->accept(); | ||||
1097 | return true; | ||||
1098 | } | ||||
1099 | | ||||
1072 | switch ( e->type() ) | 1100 | switch ( e->type() ) | ||
1073 | { | 1101 | { | ||
1074 | case QEvent::MouseButtonPress: | 1102 | case QEvent::MouseButtonPress: | ||
1075 | { | 1103 | { | ||
1076 | QMouseEvent *ev = static_cast< QMouseEvent * >( e ); | 1104 | QMouseEvent *ev = static_cast< QMouseEvent * >( e ); | ||
1077 | if ( ev->button() == Qt::LeftButton ) | 1105 | if ( ev->button() == Qt::LeftButton ) | ||
1078 | { | 1106 | { | ||
1079 | m_lefMouseButtonPressed = true; | 1107 | m_widgetPressed = true; | ||
1080 | update(); | 1108 | update(); | ||
1081 | } | 1109 | } | ||
1082 | mousePressEvent( ev ); | 1110 | mousePressEvent( ev ); | ||
1083 | break; | 1111 | break; | ||
1084 | } | 1112 | } | ||
1085 | case QEvent::MouseButtonRelease: | 1113 | case QEvent::MouseButtonRelease: | ||
1086 | { | 1114 | { | ||
1087 | QMouseEvent *ev = static_cast< QMouseEvent * >( e ); | 1115 | QMouseEvent *ev = static_cast< QMouseEvent * >( e ); | ||
1088 | m_lefMouseButtonPressed = false; | 1116 | m_widgetPressed = false; | ||
1089 | if ( ev->button() == Qt::LeftButton) | 1117 | if ( ev->button() == Qt::LeftButton) | ||
1090 | { | 1118 | { | ||
1091 | update(); | 1119 | update(); | ||
1092 | } | 1120 | } | ||
1093 | mouseReleaseEvent( ev ); | 1121 | mouseReleaseEvent( ev ); | ||
1094 | break; | 1122 | break; | ||
1095 | } | 1123 | } | ||
1096 | default: | 1124 | default: | ||
Show All 14 Lines | 1132 | { | |||
1111 | menu->addAction( signatureProperties ); | 1139 | menu->addAction( signatureProperties ); | ||
1112 | menu->exec( event->globalPos() ); | 1140 | menu->exec( event->globalPos() ); | ||
1113 | delete menu; | 1141 | delete menu; | ||
1114 | } | 1142 | } | ||
1115 | 1143 | | |||
1116 | void SignatureEdit::paintEvent( QPaintEvent * ) | 1144 | void SignatureEdit::paintEvent( QPaintEvent * ) | ||
1117 | { | 1145 | { | ||
1118 | QPainter painter( this ); | 1146 | QPainter painter( this ); | ||
1147 | //no borders when user hasn't allowed the forms to be shown | ||||
1148 | if ( m_dummyMode && !m_wasVisible ) | ||||
1149 | { | ||||
1150 | painter.setPen( Qt::transparent ); | ||||
1151 | } | ||||
1152 | else | ||||
1153 | { | ||||
1119 | painter.setPen( Qt::black ); | 1154 | painter.setPen( Qt::black ); | ||
1120 | if ( m_lefMouseButtonPressed ) | 1155 | } | ||
1156 | | ||||
1157 | if ( m_widgetPressed || m_dummyMode ) | ||||
1121 | { | 1158 | { | ||
1122 | QColor col = palette().color( QPalette::Active, QPalette::Highlight ); | 1159 | QColor col = palette().color( QPalette::Active, QPalette::Highlight ); | ||
1123 | col.setAlpha(50); | 1160 | col.setAlpha(50); | ||
1124 | painter.setBrush( col ); | 1161 | painter.setBrush( col ); | ||
1125 | } | 1162 | } | ||
1126 | else | 1163 | else | ||
1127 | { | 1164 | { | ||
1128 | painter.setBrush( Qt::transparent ); | 1165 | painter.setBrush( Qt::transparent ); | ||
1129 | } | 1166 | } | ||
1130 | painter.drawRect( 0, 0, width()-2, height()-2 ); | 1167 | painter.drawRect( 0, 0, width()-2, height()-2 ); | ||
1131 | } | 1168 | } | ||
1132 | 1169 | | |||
1133 | void SignatureEdit::slotViewRevision() | 1170 | void SignatureEdit::slotViewRevision() | ||
1134 | { | 1171 | { | ||
1172 | if ( m_dummyMode ) | ||||
1173 | return; | ||||
1174 | | ||||
1135 | QByteArray revisionData; | 1175 | QByteArray revisionData; | ||
1136 | Okular::FormFieldSignature *formSignature = static_cast< Okular::FormFieldSignature * >( formField() ); | 1176 | Okular::FormFieldSignature *formSignature = static_cast< Okular::FormFieldSignature * >( formField() ); | ||
1137 | m_controller->m_doc->requestSignedRevisionData( formSignature->validate(), &revisionData ); | 1177 | m_controller->m_doc->requestSignedRevisionData( formSignature->validate(), &revisionData ); | ||
1138 | RevisionViewer viewer( revisionData, this ); | 1178 | RevisionViewer viewer( revisionData, this ); | ||
1139 | viewer.viewRevision(); | 1179 | viewer.viewRevision(); | ||
1140 | } | 1180 | } | ||
1141 | 1181 | | |||
1142 | void SignatureEdit::slotViewProperties() | 1182 | void SignatureEdit::slotViewProperties() | ||
1143 | { | 1183 | { | ||
1184 | if ( m_dummyMode ) | ||||
1185 | return; | ||||
1186 | | ||||
1144 | Okular::FormFieldSignature *formSignature = static_cast< Okular::FormFieldSignature * >( formField() ); | 1187 | Okular::FormFieldSignature *formSignature = static_cast< Okular::FormFieldSignature * >( formField() ); | ||
1145 | SignaturePropertiesDialog propDlg( m_controller->m_doc, formSignature, this ); | 1188 | SignaturePropertiesDialog propDlg( m_controller->m_doc, formSignature, this ); | ||
1146 | propDlg.exec(); | 1189 | propDlg.exec(); | ||
1147 | } | 1190 | } | ||
1148 | 1191 | | |||
1149 | // Code for additional action handling. | 1192 | // Code for additional action handling. | ||
1150 | // Challenge: Change preprocessor magic to C++ magic! | 1193 | // Challenge: Change preprocessor magic to C++ magic! | ||
1151 | // | 1194 | // | ||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |