Fix SASL appearing active when Use SASL unchecked
authorShane Synan <digitalcircuit36939@gmail.com>
Sat, 7 Jan 2017 01:52:01 +0000 (19:52 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 12 Apr 2017 21:30:25 +0000 (23:30 +0200)
Workaround SASL contents getting enabled irrespective of Use SASL
checkbox whenever sslUpdated() determines the identity does not have
an SSL key.

Simplify SASL EXTERNAL UI hide/show logic by adding an invisible
frame inside sasl QGroupBox containing all child widgets.  Only the
frame is enabled and disabled.

Fixes SASL account and password showing up as enabled when Use SASL
was not checked.

Resolves GH-267.

src/qtui/settingspages/networkssettingspage.cpp
src/qtui/settingspages/networkssettingspage.ui

index db51da3..cc8dda2 100644 (file)
@@ -746,16 +746,21 @@ void NetworksSettingsPage::setSASLStatus(const CapSupportStatus saslStatus)
 void NetworksSettingsPage::sslUpdated()
 {
     if (_cid && !_cid->sslKey().isNull()) {
 void NetworksSettingsPage::sslUpdated()
 {
     if (_cid && !_cid->sslKey().isNull()) {
-        ui.saslAccount->setDisabled(true);
-        ui.saslAccountLabel->setDisabled(true);
-        ui.saslPassword->setDisabled(true);
-        ui.saslPasswordLabel->setDisabled(true);
+        ui.saslContents->setDisabled(true);
         ui.saslExtInfo->setHidden(false);
     } else {
         ui.saslExtInfo->setHidden(false);
     } else {
-        ui.saslAccount->setDisabled(false);
-        ui.saslAccountLabel->setDisabled(false);
-        ui.saslPassword->setDisabled(false);
-        ui.saslPasswordLabel->setDisabled(false);
+        ui.saslContents->setDisabled(false);
+        // Directly re-enabling causes the widgets to ignore the parent "Use SASL Authentication"
+        // state to indicate whether or not it's disabled.  To workaround this, keep track of
+        // whether or not "Use SASL Authentication" is enabled, then quickly uncheck/recheck the
+        // group box.
+        if (!ui.sasl->isChecked()) {
+            // SASL is not enabled, uncheck/recheck the group box to re-disable saslContents.
+            // Leaving saslContents disabled doesn't work as that prevents it from re-enabling if
+            // sasl is later checked.
+            ui.sasl->setChecked(true);
+            ui.sasl->setChecked(false);
+        }
         ui.saslExtInfo->setHidden(true);
     }
 }
         ui.saslExtInfo->setHidden(true);
     }
 }
index 5598e9a..8426dd0 100644 (file)
@@ -682,85 +682,112 @@ Note that Quassel IRC automatically rejoins channels, so /join will rarely be ne
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_11">
              <item>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_11">
              <item>
-              <layout class="QGridLayout" name="gridLayout_2">
-               <item row="0" column="1">
-                <widget class="QLineEdit" name="saslAccount">
-                 <property name="enabled">
-                  <bool>true</bool>
-                 </property>
-                 <property name="toolTip">
-                  <string>Account name, often the same as your nickname</string>
-                 </property>
-                 <property name="text">
-                  <string/>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="0">
-                <widget class="QLabel" name="saslAccountLabel">
-                 <property name="enabled">
-                  <bool>true</bool>
-                 </property>
-                 <property name="text">
-                  <string>Account:</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="1">
-                <widget class="QLineEdit" name="saslPassword">
-                 <property name="enabled">
-                  <bool>true</bool>
-                 </property>
-                 <property name="toolTip">
-                  <string>Account password</string>
-                 </property>
-                 <property name="echoMode">
-                  <enum>QLineEdit::Password</enum>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="0">
-                <widget class="QLabel" name="saslPasswordLabel">
-                 <property name="enabled">
-                  <bool>true</bool>
-                 </property>
-                 <property name="text">
-                  <string>Password:</string>
-                 </property>
-                </widget>
-               </item>
-              </layout>
-             </item>
-             <item>
-              <layout class="QHBoxLayout" name="horizontalLayout_7">
-               <item>
-                <widget class="QLabel" name="saslStatusIcon">
-                 <property name="text">
-                  <string notr="true">[icon]</string>
-                 </property>
-                </widget>
-               </item>
-               <item>
-                <widget class="QLabel" name="saslStatusLabel">
-                 <property name="sizePolicy">
-                  <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-                   <horstretch>0</horstretch>
-                   <verstretch>0</verstretch>
-                  </sizepolicy>
-                 </property>
-                 <property name="text">
-                  <string>Could not detect if supported by server</string>
-                 </property>
-                </widget>
-               </item>
-               <item>
-                <widget class="QPushButton" name="saslStatusDetails">
-                 <property name="text">
-                  <string>Details...</string>
-                 </property>
-                </widget>
-               </item>
-              </layout>
+              <widget class="QFrame" name="saslContents">
+               <property name="frameShape">
+                <enum>QFrame::NoFrame</enum>
+               </property>
+               <property name="frameShadow">
+                <enum>QFrame::Plain</enum>
+               </property>
+               <property name="lineWidth">
+                <number>0</number>
+               </property>
+               <layout class="QVBoxLayout" name="verticalLayout_12">
+                <property name="leftMargin">
+                 <number>0</number>
+                </property>
+                <property name="topMargin">
+                 <number>0</number>
+                </property>
+                <property name="rightMargin">
+                 <number>0</number>
+                </property>
+                <property name="bottomMargin">
+                 <number>0</number>
+                </property>
+                <item>
+                 <layout class="QGridLayout" name="gridLayout_2">
+                  <item row="0" column="1">
+                   <widget class="QLineEdit" name="saslAccount">
+                    <property name="enabled">
+                     <bool>true</bool>
+                    </property>
+                    <property name="toolTip">
+                     <string>Account name, often the same as your nickname</string>
+                    </property>
+                    <property name="text">
+                     <string/>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="saslAccountLabel">
+                    <property name="enabled">
+                     <bool>true</bool>
+                    </property>
+                    <property name="text">
+                     <string>Account:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="1">
+                   <widget class="QLineEdit" name="saslPassword">
+                    <property name="enabled">
+                     <bool>true</bool>
+                    </property>
+                    <property name="toolTip">
+                     <string>Account password</string>
+                    </property>
+                    <property name="echoMode">
+                     <enum>QLineEdit::Password</enum>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0">
+                   <widget class="QLabel" name="saslPasswordLabel">
+                    <property name="enabled">
+                     <bool>true</bool>
+                    </property>
+                    <property name="text">
+                     <string>Password:</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QHBoxLayout" name="horizontalLayout_7">
+                  <item>
+                   <widget class="QLabel" name="saslStatusIcon">
+                    <property name="text">
+                     <string notr="true">[icon]</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="saslStatusLabel">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="text">
+                     <string>Could not detect if supported by server</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QPushButton" name="saslStatusDetails">
+                    <property name="text">
+                     <string>Details...</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+               </layout>
+              </widget>
              </item>
             </layout>
            </widget>
              </item>
             </layout>
            </widget>