qt5: Fix optional content handling with exclusive layers

We were setting the "ui" value correctly, but not the "backend" one
because we were shortcuting on obeyRadioGroups for the off state

Update test to check also for the backend value
diff --git a/qt5/src/poppler-optcontent-private.h b/qt5/src/poppler-optcontent-private.h
index a134cd5..611c287 100644
--- a/qt5/src/poppler-optcontent-private.h
+++ b/qt5/src/poppler-optcontent-private.h
@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2007, Brad Hards <bradh@kde.org>
  * Copyright (C) 2008, Pino Toscano <pino@kde.org>
- * Copyright (C) 2016, 2018, Albert Astals Cid <aacid@kde.org>
+ * Copyright (C) 2016, 2018, 2019, Albert Astals Cid <aacid@kde.org>
  * Copyright (C) 2017, Hubert Figuière <hub@figuiere.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -77,6 +77,8 @@
 
     QSet<OptContentItem*> recurseListChildren(bool includeMe = false) const;
 
+    OptionalContentGroup *group() const { return m_group; }
+
     private:
     OptionalContentGroup *m_group;
     QString m_name;
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index ebae31f..49acd4a 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -131,14 +131,16 @@
       child->m_enabled = state == OptContentItem::On;
       child->m_stateBackup = oldState;
     }
-    if (!m_group || !obeyRadioGroups) {
+    if (!m_group) {
       return;
     }
     if ( state == OptContentItem::On ) {
       m_group->setState( OptionalContentGroup::On );
-      for (int i = 0; i < m_rbGroups.size(); ++i) {
-        RadioButtonGroup *rbgroup = m_rbGroups.at(i);
-        changedItems += rbgroup->setItemOn( this );
+      if (obeyRadioGroups) {
+	for (int i = 0; i < m_rbGroups.size(); ++i) {
+	  RadioButtonGroup *rbgroup = m_rbGroups.at(i);
+	  changedItems += rbgroup->setItemOn( this );
+	}
       }
     } else if ( state == OptContentItem::Off ) {
       m_group->setState( OptionalContentGroup::Off );
diff --git a/qt5/tests/check_optcontent.cpp b/qt5/tests/check_optcontent.cpp
index eb5282e..d137230 100644
--- a/qt5/tests/check_optcontent.cpp
+++ b/qt5/tests/check_optcontent.cpp
@@ -4,6 +4,7 @@
 #include "GlobalParams.h"
 
 #include <poppler-qt5.h>
+#include <poppler-optcontent-private.h>
 
 class TestOptionalContent: public QObject
 {
@@ -399,14 +400,17 @@
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::On );
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     // and turning on French should turn off Japanese
     QVERIFY( optContent->setData( subindex, QVariant( true ), Qt::CheckStateRole ) );
@@ -414,14 +418,17 @@
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Checked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::On );
 
 
     // and turning off French should leave them all off
@@ -430,14 +437,17 @@
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem *>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off );
 
     delete doc;
 }