+/*** Authentication Selection Page ***/
+
+AuthenticationSelectionPage::AuthenticationSelectionPage(const QVariantList &authInfos, QWidget *parent)
+ : QWizardPage(parent)
+{
+ ui.setupUi(this);
+
+ setTitle(tr("Select Authentication Backend"));
+ setSubTitle(tr("Please select a backend for Quassel Core to use for authenticating users."));
+
+ registerField("authentication.backend", ui.backendList);
+
+ for (auto &&authInfo : authInfos) {
+ auto props = authInfo.toMap();
+ // Extract field infos to avoid having to reparse the list
+ std::vector<FieldInfo> fields;
+ const auto &list = props["SetupData"].toList();
+ for (int i = 0; i + 2 < list.size(); i += 3) {
+ fields.emplace_back(std::make_tuple(list[i].toString(), list[i+1].toString(), list[i+2]));
+ }
+ props.remove("SetupData");
+
+ _authProperties.emplace_back(std::move(props));
+ _authFields.emplace_back(std::move(fields));
+
+ // Create widgets
+ ui.backendList->addItem(_authProperties.back()["DisplayName"].toString(), _authProperties.back()["BackendId"].toString());
+ ui.descriptionStack->addWidget(createDescriptionBox(_authProperties.back()["Description"].toString()));
+ ui.authSettingsStack->addWidget(createFieldBox(tr("Authentication Settings"), _authFields.back()));
+ }
+
+ // Do some trickery to make the page large enough
+ setSizePolicy({QSizePolicy::Fixed, QSizePolicy::Fixed});
+
+ QSizePolicy sp{QSizePolicy::MinimumExpanding, QSizePolicy::Fixed};
+#if QT_VERSION >= 0x050200
+ sp.setRetainSizeWhenHidden(true);
+#else
+ ui.authSettingsStack->setVisible(true); // ugly hack that will show an empty box, but we'll deprecate Qt4 soon anyway
+#endif
+ ui.descriptionStack->setSizePolicy(sp);
+ ui.authSettingsStack->setSizePolicy(sp);
+
+ ui.descriptionStack->adjustSize();
+ ui.authSettingsStack->adjustSize();
+
+ ui.backendList->setCurrentIndex(0);
+}
+
+
+int AuthenticationSelectionPage::nextId() const
+{
+ return CoreConfigWizard::StorageSelectionPage;
+}
+
+
+QString AuthenticationSelectionPage::displayName() const
+{
+ return ui.backendList->currentText();
+}
+
+
+QString AuthenticationSelectionPage::authenticator() const
+{
+#if QT_VERSION >= 0x050200
+ return ui.backendList->currentData().toString();
+#else
+ return ui.backendList->itemData(ui.backendList->currentIndex()).toString();
+#endif
+}
+
+
+QVariantMap AuthenticationSelectionPage::authProperties() const
+{
+ return propertiesFromFieldWidgets(qobject_cast<QGroupBox *>(ui.authSettingsStack->currentWidget()),
+ _authFields[ui.backendList->currentIndex()]);
+}
+
+
+void AuthenticationSelectionPage::on_backendList_currentIndexChanged(int index)
+{
+ ui.descriptionStack->setCurrentIndex(index);
+ ui.authSettingsStack->setCurrentIndex(index);
+ ui.authSettingsStack->setVisible(!_authFields[index].empty());
+}