X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fcoresessionwidget.cpp;h=d31122db21db2f2177ca0b96f808fb55d229cb69;hb=924ed0da8578d43bf21c9155b9bf439108e74988;hp=f3f987db0ff7dc68f769254dfb929d817a5e08b2;hpb=91c69d07871f2c081f8eb7d5e199b7997070f185;p=quassel.git diff --git a/src/qtui/coresessionwidget.cpp b/src/qtui/coresessionwidget.cpp index f3f987db..d31122db 100644 --- a/src/qtui/coresessionwidget.cpp +++ b/src/qtui/coresessionwidget.cpp @@ -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,35 @@ void CoreSessionWidget::setData(QMap 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(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 { + // 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("

%1

%2
%3

").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("

%1

%2

").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 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); }