mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-17 23:11:48 +00:00
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
This commit is contained in:
parent
14c936ea1b
commit
aa2c28bc51
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue