qtui: Hide "fallback" and "Override" if no system theme is configured
[quassel.git] / src / qtui / coresessionwidget.cpp
index f3f987d..97993f4 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -44,8 +44,26 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> map)
     }
     ui.labelSecure->setText(map["secure"].toBool() ? tr("Yes") : tr("No"));
 
-    auto features = Quassel::Features(map["features"].toInt());
-    ui.disconnectButton->setVisible(features.testFlag(Quassel::Feature::RemoteDisconnect));
+    auto features = Quassel::Features{map["featureList"].toStringList(), static_cast<Quassel::LegacyFeatures>(map["features"].toUInt())};
+    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 {
+        // 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);
+        // 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;
     _peerId = map["id"].toInt(&success);
@@ -54,5 +72,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);
 }