client: Show when End Session unavailable, polish
authorShane Synan <digitalcircuit36939@gmail.com>
Wed, 28 Mar 2018 21:42:02 +0000 (16:42 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Jun 2018 17:37:44 +0000 (19:37 +0200)
Show when the End Session option is unavailable, adding a tooltip to
either point out an outdated core, or a client that doesn't support
it.

Before RemoteDisconnect was added to the core, it didn't share any
client features with other connected clients, so there's no way to
tell if a client supports a feature or not.

See 78b37c1a0610d9a4fb26ba0dec7337d6f7960041
"Transmit feature flag for remote disconnecting with peer info"

Disable and rename the End Session button when clicked, giving
immediate feedback when Quassel's used with a high-latency connection.

src/qtui/coresessionwidget.cpp

index 68adfe5..d31122d 100644 (file)
@@ -45,7 +45,34 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> map)
     ui.labelSecure->setText(map["secure"].toBool() ? tr("Yes") : tr("No"));
 
     auto features = Quassel::Features{map["featureList"].toStringList(), static_cast<Quassel::LegacyFeatures>(map["features"].toUInt())};
-    ui.disconnectButton->setVisible(features.isEnabled(Quassel::Feature::RemoteDisconnect));
+    if (features.isEnabled(Quassel::Feature::RemoteDisconnect)) {
+        // Both client and core support it, enable the button
+        ui.disconnectButton->setEnabled(true);
+        ui.disconnectButton->setToolTip(tr("End the client's session, disconnecting it"));
+    } else {
+        // 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")));
+        }
+    }
 
     bool success = false;
     _peerId = map["id"].toInt(&success);
@@ -54,5 +81,10 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> map)
 
 void CoreSessionWidget::disconnectClicked()
 {
+    // Don't allow the End Session button to be spammed; Quassel's protocol isn't lossy and it
+    // should reach the destination eventually...
+    ui.disconnectButton->setEnabled(false);
+    ui.disconnectButton->setText(tr("Ending session..."));
+
     emit disconnectClicked(_peerId);
 }