+void NetworksSettingsPage::on_saslStatusDetails_clicked()
+{
+ if (ui.networkList->selectedItems().count()) {
+ NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
+ QString& netName = networkInfos[netid].networkName;
+
+ // If these strings are visible, one of the status messages wasn't detected below.
+ QString saslStatusHeader = "[header unintentionally left blank]";
+ QString saslStatusExplanation = "[explanation unintentionally left blank]";
+
+ // If true, show a warning icon instead of an information icon
+ bool useWarningIcon = false;
+
+ // Determine which explanation to show
+ switch (_saslStatusSelected) {
+ case CapSupportStatus::Unknown:
+ saslStatusHeader = tr("Could not check if SASL supported by network");
+ saslStatusExplanation = tr("Quassel could not check if \"%1\" supports SASL. This may "
+ "be due to unsaved changes or an older Quassel core. You "
+ "can still try using SASL.")
+ .arg(netName);
+ break;
+ case CapSupportStatus::Disconnected:
+ saslStatusHeader = tr("Cannot check if SASL supported when disconnected");
+ saslStatusExplanation = tr("Quassel cannot check if \"%1\" supports SASL when "
+ "disconnected. Connect to the network, or try using SASL "
+ "anyways.")
+ .arg(netName);
+ break;
+ case CapSupportStatus::MaybeUnsupported:
+ saslStatusHeader = tr("SASL not currently supported by network");
+ saslStatusExplanation = tr("The network \"%1\" does not currently support SASL. "
+ "However, support might be added later on.")
+ .arg(netName);
+ useWarningIcon = true;
+ break;
+ case CapSupportStatus::MaybeSupported:
+ saslStatusHeader = tr("SASL supported by network");
+ saslStatusExplanation = tr("The network \"%1\" supports SASL. In most cases, you "
+ "should use SASL instead of NickServ identification.")
+ .arg(netName);
+ break;
+ }
+
+ // Process this in advance for reusability below
+ const QString saslStatusMsgTitle = tr("SASL support for \"%1\"").arg(netName);
+ const QString saslStatusMsgText = QString("<p><b>%1</b></p></br><p>%2</p></br><p><i>%3</i></p>")
+ .arg(saslStatusHeader,
+ saslStatusExplanation,
+ tr("SASL is a standardized way to log in and identify yourself to "
+ "IRC servers."));
+
+ if (useWarningIcon) {
+ // Show as a warning dialog box
+ QMessageBox::warning(this, saslStatusMsgTitle, saslStatusMsgText);
+ }
+ else {
+ // Show as an information dialog box
+ QMessageBox::information(this, saslStatusMsgTitle, saslStatusMsgText);
+ }
+ }
+}
+
+void NetworksSettingsPage::on_enableCapsStatusDetails_clicked()
+{
+ if (!Client::isConnected() || Client::isCoreFeatureEnabled(Quassel::Feature::SkipIrcCaps)) {
+ // Either disconnected or IRCv3 capability skippping supported
+
+ // Try to get a list of currently enabled features
+ QStringList sortedCapsEnabled;
+ // Check if a network is selected
+ if (ui.networkList->selectedItems().count()) {
+ // Get the underlying Network from the selected network
+ NetworkId netid = ui.networkList->selectedItems()[0]->data(Qt::UserRole).value<NetworkId>();
+ const Network* net = Client::network(netid);
+ if (net && Client::isCoreFeatureEnabled(Quassel::Feature::CapNegotiation)) {
+ // Capability negotiation is supported, network exists.
+ // If the network is disconnected, the list of enabled capabilities will be empty,
+ // no need to check for that specifically.
+ // Sorting isn't required, but it looks nicer.
+ sortedCapsEnabled = net->capsEnabled();
+ sortedCapsEnabled.sort();
+ }
+ }
+
+ // Try to explain IRCv3 network features in a friendly way, including showing the currently
+ // enabled features if available
+ auto messageText = QString("<p>%1</p></br><p>%2</p>")
+ .arg(tr("Quassel makes use of newer IRC features when supported by the IRC network."
+ " If desired, you can disable unwanted or problematic features here."),
+ tr("The <a href=\"https://ircv3.net/irc/\">IRCv3 website</a> provides more "
+ "technical details on the IRCv3 capabilities powering these features."));
+
+ if (!sortedCapsEnabled.isEmpty()) {
+ // Format the capabilities within <code></code> blocks
+ auto formattedCaps = QString("<code>%1</code>")
+ .arg(sortedCapsEnabled.join("</code>, <code>"));
+
+ // Add the currently enabled capabilities to the list
+ // This creates a new QString, but this code is not performance-critical.
+ messageText = messageText.append(QString("<p><i>%1</i></p>").arg(
+ tr("Currently enabled IRCv3 capabilities for this "
+ "network: %1").arg(formattedCaps)));
+ }
+
+ QMessageBox::information(this, tr("Configuring network features"), messageText);
+ }
+ else {
+ // Core does not IRCv3 capability skipping, show warning
+ QMessageBox::warning(this, tr("Configuring network features unsupported"),
+ QString("<p><b>%1</b></p></br><p>%2</p>")
+ .arg(tr("Your Quassel core is too old to configure IRCv3 network features"),
+ tr("You need a Quassel core v0.14.0 or newer to control what network "
+ "features Quassel will use.")));
+ }
+}
+
+void NetworksSettingsPage::on_enableCapsAdvanced_clicked()
+{
+ if (currentId == 0)
+ return;
+
+ CapsEditDlg dlg(networkInfos[currentId].skipCapsToString(), this);
+ if (dlg.exec() == QDialog::Accepted) {
+ networkInfos[currentId].skipCapsFromString(dlg.skipCapsString());
+ displayNetwork(currentId);
+ widgetHasChanged();
+ }
+}