mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Follow up of T156, improved setup loading dialog
* allow to load the delivered setup file if there are no other data * display setup cache information
This commit is contained in:
committed by
Mathew Sutcliffe
parent
bdbf2e75b4
commit
071f327fca
@@ -27,22 +27,25 @@ namespace BlackGui
|
||||
ui(new Ui::CSetupLoadingDialog)
|
||||
{
|
||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
|
||||
if (sApp->hasSetupReader())
|
||||
if (this->hasSetupReader())
|
||||
{
|
||||
// reset if it was temp.ignored
|
||||
// reset if it was temporarily ignored
|
||||
sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(false);
|
||||
connect(sApp, &CGuiApplication::setupHandlingCompleted, this, &CSetupLoadingDialog::onSetupHandlingCompleted);
|
||||
}
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl);
|
||||
connect(ui->pb_LoadFromDisk, &QPushButton::clicked, this, &CSetupLoadingDialog::prefillSetupCache);
|
||||
|
||||
QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry);
|
||||
retry->setDefault(true);
|
||||
|
||||
this->displaySetupCacheInfo();
|
||||
this->displayCmdBoostrapUrl();
|
||||
this->displayBootstrapUrls();
|
||||
this->displayGlobalSetup();
|
||||
}
|
||||
|
||||
CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent)
|
||||
{
|
||||
ui->comp_Messages->appendStatusMessagesToList(msgs);
|
||||
@@ -51,20 +54,24 @@ namespace BlackGui
|
||||
CSetupLoadingDialog::~CSetupLoadingDialog()
|
||||
{ }
|
||||
|
||||
bool CSetupLoadingDialog::hasCachedSetup() const
|
||||
{
|
||||
return this->hasSetupReader() && sApp->getSetupReader()->hasCachedSetup();
|
||||
}
|
||||
|
||||
bool CSetupLoadingDialog::hasSetupReader() const
|
||||
{
|
||||
return sApp && sApp->hasSetupReader();
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::displayBootstrapUrls()
|
||||
{
|
||||
const CUrlList bootstrapUrls = sApp->getGlobalSetup().getSwiftBootstrapFileUrls();
|
||||
for (const CUrl &url : bootstrapUrls)
|
||||
{
|
||||
CStatusMessage msg;
|
||||
if (CNetworkUtils::canConnect(url))
|
||||
{
|
||||
msg = CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl();
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
|
||||
}
|
||||
CStatusMessage msg = CNetworkUtils::canConnect(url) ?
|
||||
CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() :
|
||||
CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
|
||||
ui->comp_Messages->appendStatusMessageToList(msg);
|
||||
}
|
||||
}
|
||||
@@ -92,5 +99,39 @@ namespace BlackGui
|
||||
sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(true);
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::prefillSetupCache()
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
if (!this->hasSetupReader()) { return; }
|
||||
sApp->getSetupReader()->prefillCacheWithLocalResourceBootstrapFile();
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::displaySetupCacheInfo()
|
||||
{
|
||||
if (this->hasSetupReader())
|
||||
{
|
||||
// reset if it was temporarily ignored
|
||||
const CSetupReader *sr = sApp->getSetupReader();
|
||||
const QDateTime setupTs = sr->getSetupCacheTimestamp();
|
||||
ui->le_SetupCache->setText(setupTs.isValid() ?
|
||||
setupTs.toString(Qt::ISODateWithMs) :
|
||||
"No cache timestamp");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->le_SetupCache->setText("No setup reader");
|
||||
}
|
||||
|
||||
const bool hasCachedSetup = this->hasCachedSetup();
|
||||
ui->pb_LoadFromDisk->setEnabled(!hasCachedSetup);
|
||||
ui->pb_LoadFromDisk->setVisible(!hasCachedSetup);
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::onSetupHandlingCompleted(bool success)
|
||||
{
|
||||
Q_UNUSED(success);
|
||||
this->displaySetupCacheInfo();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user