client: Fix core sessions unsupported warning
authorShane Synan <digitalcircuit36939@gmail.com>
Mon, 14 May 2018 06:00:19 +0000 (01:00 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Jun 2018 17:37:44 +0000 (19:37 +0200)
Move core session supported check to CoreInfoDlg, and show a
warning bar if sessions aren't supported.  A "Details" button
offers additional information on needing to upgrade.

Older core versions didn't provide any core session information, so
the individual session widgets would have never shown up.

Thanks to @justjanne for reporting this.

src/qtui/coreinfodlg.cpp
src/qtui/coreinfodlg.h
src/qtui/coresessionwidget.cpp
src/qtui/ui/coreinfodlg.ui

index 2f8736c..299a94f 100644 (file)
@@ -18,6 +18,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include <QMessageBox>
+
 #include "coreinfodlg.h"
 
 #include "client.h"
 #include "coreinfodlg.h"
 
 #include "client.h"
@@ -30,6 +32,9 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) {
 
     coreInfoChanged(coreInfo->coreData());
 
 
     coreInfoChanged(coreInfo->coreData());
 
+    // Warning icon
+    ui.coreUnsupportedIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16));
+
     updateUptime();
     startTimer(1000);
 }
     updateUptime();
     startTimer(1000);
 }
@@ -73,6 +78,9 @@ void CoreInfoDlg::coreInfoChanged(const QVariantMap &coreInfo) {
     }
 
     ui.coreSessionScrollArea->setVisible(coreSessionSupported);
     }
 
     ui.coreSessionScrollArea->setVisible(coreSessionSupported);
+
+    // Hide the information bar when core sessions are supported
+    ui.coreUnsupportedWidget->setVisible(!coreSessionSupported);
 }
 
 
 }
 
 
@@ -102,3 +110,13 @@ void CoreInfoDlg::updateUptime() {
 void CoreInfoDlg::disconnectClicked(int peerId) {
     Client::kickClient(peerId);
 }
 void CoreInfoDlg::disconnectClicked(int peerId) {
     Client::kickClient(peerId);
 }
+
+void CoreInfoDlg::on_coreUnsupportedDetails_clicked()
+{
+    QMessageBox::warning(this,
+                         tr("Active sessions unsupported"),
+                         QString("<p><b>%1</b></p></br><p>%2</p>"
+                                 ).arg(tr("Your Quassel core is too old to show active sessions"),
+                                       tr("You need a Quassel core v0.13.0 or newer to view and "
+                                          "disconnect other connected clients.")));
+}
index 85a9211..15140f7 100644 (file)
@@ -43,6 +43,11 @@ private slots:
     void updateUptime();
     void disconnectClicked(int peerId);
 
     void updateUptime();
     void disconnectClicked(int peerId);
 
+    /**
+      * Event handler for core unspported Details button
+      */
+    void on_coreUnsupportedDetails_clicked();
+
 private:
     Ui::CoreInfoDlg ui;
     QMap<int, CoreSessionWidget *> _widgets;
 private:
     Ui::CoreInfoDlg ui;
     QMap<int, CoreSessionWidget *> _widgets;
index d31122d..97993f4 100644 (file)
@@ -50,28 +50,19 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> map)
         ui.disconnectButton->setEnabled(true);
         ui.disconnectButton->setToolTip(tr("End the client's session, disconnecting it"));
     } else {
         ui.disconnectButton->setEnabled(true);
         ui.disconnectButton->setToolTip(tr("End the client's session, disconnecting it"));
     } else {
+        // For any active sessions to be displayed, the core must support this feature.  We can
+        // assume the client doesn't support being remotely disconnected.
+        //
+        // (During the development of 0.13, there was a period of time where active sessions existed
+        //  but did not provide the disconnect option.  We can overlook this.)
+
         // Either core or client doesn't support it, disable the option
         ui.disconnectButton->setEnabled(false);
         // Either core or client doesn't support it, disable the option
         ui.disconnectButton->setEnabled(false);
-        if (!Client::isCoreFeatureEnabled(Quassel::Feature::RemoteDisconnect)) {
-            // Until RemoteDisconnect was implemented, the Quassel core didn't forward client
-            // features.  A client might support features and we'll never hear about it.
-            // This check shouldn't be necessary for later features if the core supports at least
-            // RemoteDisconnect.
-
-            // Core doesn't support this feature (we don't know about the client)
-            ui.disconnectButton->setToolTip(
-                        QString("<p>%1</p><p><b>%2</b><br/>%3</p>").arg(
-                            tr("End the client's session, disconnecting it"),
-                            tr("Your Quassel core does not support this feature"),
-                            tr("You need a Quassel core v0.13.0 or newer in order to end connected "
-                               "sessions.")));
-        } else {
-            // Client doesn't support this feature
-            ui.disconnectButton->setToolTip(
-                        QString("<p>%1</p><p><b>%2</b></p>").arg(
-                            tr("End the client's session, disconnecting it"),
-                            tr("This client does not support being remotely disconnected")));
-        }
+        // Assuming the client lacks support, set the tooltip accordingly
+        ui.disconnectButton->setToolTip(
+                QString("<p>%1</p><p><b>%2</b></p>").arg(
+                        tr("End the client's session, disconnecting it"),
+                        tr("This client does not support being remotely disconnected")));
     }
 
     bool success = false;
     }
 
     bool success = false;
index 57f2428..11b6dcd 100644 (file)
@@ -13,7 +13,7 @@
   <property name="windowTitle">
    <string>Core Information</string>
   </property>
   <property name="windowTitle">
    <string>Core Information</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,0">
+  <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0,0">
    <item>
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
    <item>
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
      </item>
     </layout>
    </item>
      </item>
     </layout>
    </item>
+   <item>
+    <widget class="QFrame" name="coreUnsupportedWidget">
+     <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="QHBoxLayout">
+      <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>
+       <widget class="QLabel" name="coreUnsupportedIcon">
+        <property name="text">
+         <string notr="true">[icon]</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="coreUnsupportedLabel">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Your Quassel core is too old to show active sessions</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="coreUnsupportedDetails">
+        <property name="text">
+         <string>Details...</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item>
     <widget class="QScrollArea" name="coreSessionScrollArea">
      <property name="sizePolicy">
    <item>
     <widget class="QScrollArea" name="coreSessionScrollArea">
      <property name="sizePolicy">
        <rect>
         <x>0</x>
         <y>0</y>
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>550</width>
-        <height>187</height>
+        <width>546</width>
+        <height>161</height>
        </rect>
       </property>
       <property name="sizePolicy">
        </rect>
       </property>
       <property name="sizePolicy">