mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +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
|
||||
|
||||
@@ -40,6 +40,12 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CSetupLoadingDialog> ui;
|
||||
|
||||
//! Cached setup available?
|
||||
bool hasCachedSetup() const;
|
||||
|
||||
//! Setup reader?
|
||||
bool hasSetupReader() const;
|
||||
|
||||
//! Set info fields
|
||||
void displayBootstrapUrls();
|
||||
|
||||
@@ -51,6 +57,15 @@ namespace BlackGui
|
||||
|
||||
//! Try again without explicit bootstrap URL
|
||||
void tryAgainWithoutBootstrapUrl();
|
||||
|
||||
//! Prefill setup cache
|
||||
void prefillSetupCache();
|
||||
|
||||
//! Display the setup cache info
|
||||
void displaySetupCacheInfo();
|
||||
|
||||
//! Setup loading has been completed
|
||||
void onSetupHandlingCompleted(bool success);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -37,42 +37,52 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Details">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_CmdLine">
|
||||
<property name="text">
|
||||
<string>Cmd:</string>
|
||||
<layout class="QGridLayout" name="gl_Details" columnstretch="0,3,0,0,0">
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_SetupCache">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="pb_LoadFromDisk">
|
||||
<property name="text">
|
||||
<string> load from disk </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_CmdLine">
|
||||
<property name="text">
|
||||
<string>Command:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QLineEdit" name="le_BootstrapMode">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLabel" name="lbl_BootstrapMode">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="4">
|
||||
<item row="1" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="le_CmdLine">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_BootstrapUrl">
|
||||
<property name="toolTip">
|
||||
<string>Where the bootstrap file is located</string>
|
||||
@@ -82,24 +92,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="lbl_BootstrapMode">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_BootstrapUrl">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pb_IgnoreExplicitBootstrapUrl">
|
||||
<property name="text">
|
||||
<string>Ignore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="6">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QLabel" name="lbl_Info">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Loading the setup (aka &quot;bootstrap file&quot;) has failed!</span><span style=" font-size:9pt;"> This file is required for </span><span style=" font-size:9pt; font-style:italic;">swift</span><span style=" font-size:9pt;"> to work properly. You can try to load the file again (&quot;Retry&quot;) or give up (&quot;Cancel&quot;). If you have set an explicit bootstrap URL, you can also ignore this URL and use cached setup data (if there are any).</span></p></body></html></string>
|
||||
<string><html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Loading the setup (aka &quot;bootstrap file&quot;) has failed!</span><span style=" font-size:9pt;"> This file is required for </span><span style=" font-size:9pt; font-style:italic;">swift</span><span style=" font-size:9pt;"> to work properly. You can try to load the file again (&quot;Retry&quot;) or give up (&quot;Cancel&quot;). If you have set an explicit bootstrap URL, you can also ignore this URL and use cached setup data (if there are any). If all goes wrong, you can try to load the setup cache from disk.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
@@ -109,6 +126,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_SetupCache">
|
||||
<property name="text">
|
||||
<string>Setup cache:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user