summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2016-01-15 00:02:11 (GMT)
committerAlbert Vaca <albertvaka@gmail.com>2016-02-22 10:54:04 (GMT)
commitaa2c28bc51b715433a6ad18fe08b748ba55d9a4c (patch)
tree230296dd3005a08bdd75568d9fed287d6c87fb2d
parent14c936ea1b0a9094b476da45160ebb23614f3a39 (diff)
Forms: Let checkboxes be unchecked
At least in PDF which is the only backend with form support Radio buttons are a bit of a mess since they're supposedly also uncheckable if NoToggleToOff is not set but in Adobe Reader they never are BUGS: 357743
-rw-r--r--ui/formwidgets.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/ui/formwidgets.cpp b/ui/formwidgets.cpp
index db95bf0..3d1b98d 100644
--- a/ui/formwidgets.cpp
+++ b/ui/formwidgets.cpp
@@ -83,8 +83,6 @@ QButtonGroup* FormWidgetsController::registerRadioButton( QAbstractButton *butto
if ( !button )
return 0;
-
-
QList< RadioData >::iterator it = m_radios.begin(), itEnd = m_radios.end();
const int id = formButton->id();
m_formButtons.insert( id, formButton );
@@ -147,6 +145,14 @@ void FormWidgetsController::slotButtonClicked( QAbstractButton *button )
int pageNumber = -1;
if ( CheckBoxEdit *check = qobject_cast< CheckBoxEdit * >( button ) )
{
+ // Checkboxes need to be uncheckable so if clicking a checked one
+ // disable the exclusive status temporarily and uncheck it
+ if (m_formButtons[check->formField()->id()]->state()) {
+ const bool wasExclusive = button->group()->exclusive();
+ button->group()->setExclusive(false);
+ check->setChecked(false);
+ button->group()->setExclusive(wasExclusive);
+ }
pageNumber = check->pageItem()->pageNumber();
}
else if ( RadioButtonEdit *radio = qobject_cast< RadioButtonEdit * >( button ) )
@@ -176,8 +182,14 @@ void FormWidgetsController::slotFormButtonsChangedByUndoRedo( int pageNumber, co
{
int id = formButton->id();
QAbstractButton* button = m_buttons[id];
+ // temporarily disable exclusiveness of the button group
+ // since it breaks doing/redoing steps into which all the checkboxes
+ // are unchecked
+ const bool wasExclusive = button->group()->exclusive();
+ button->group()->setExclusive(false);
bool checked = formButton->state();
button->setChecked( checked );
+ button->group()->setExclusive(wasExclusive);
button->setFocus();
}
emit changed( pageNumber );