#include "ServicesDialog.h" #include "ServiceWidget.h" #include "Configurator.h" #include #include ServicesDialog::ServicesDialog(QWidget *parent):QDialog(parent),_layout(this) { int y = 0; _welcome = new QLabel(tr("Welcome to your Federated Computer\n" "We can automatically configure these services for you:"), this); _layout.addWidget(_welcome, y, 0); _knownServicesScroller = new QScrollArea(this); _knownServices = new QWidget(this); QBoxLayout *ksLayout = new QBoxLayout(QBoxLayout::TopToBottom, _knownServices); _layout.addWidget(_knownServicesScroller, ++y, 0); _usLabel = new QLabel(tr("Your subscription also includes the following services, which can not currently be auto-configured, but you can configure them manually:"), this); _layout.addWidget(_usLabel, ++y, 0); _unknownServicesScroller = new QScrollArea(this); _unknownServices = new QWidget(this); QBoxLayout *usLayout = new QBoxLayout(QBoxLayout::TopToBottom, _unknownServices); _layout.addWidget(_unknownServicesScroller, ++y, 0); int k = 0, u = 0; for(auto i : app->services()) { if(i.title == "Nextcloud" || i.title == "Panel") { ServiceWidget *w=new ServiceWidget(i, _knownServices); ksLayout->addWidget(w, ++k); } else { ServiceWidget *w=new ServiceWidget(i, _unknownServices); usLayout->addWidget(w, ++u); } } _knownServicesScroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); _unknownServicesScroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); _knownServicesScroller->setWidget(_knownServices); _unknownServicesScroller->setWidget(_unknownServices); _buttons = new ButtonRow(this); QPushButton *ok = new QPushButton(tr("&OK"), _buttons); connect(ok, &QPushButton::clicked, this, &QDialog::accept); ok->setDefault(true); QPushButton *cancel = new QPushButton(tr("&Cancel"), _buttons); connect(cancel, &QPushButton::clicked, this, &QDialog::reject); _buttons->add(ok); _buttons->add(cancel); _layout.addWidget(_buttons, ++y, 0); resizeEvent(0); } void ServicesDialog::resizeEvent(QResizeEvent *e) { // Make sure the known services and unknown services // lists always use the full width available if(e) QDialog::resizeEvent(e); int const w = _knownServicesScroller->width(); _knownServices->setFixedWidth(w); _unknownServices->setFixedWidth(w); }