Ref T367, Ref T400 global setup loading dialog adjustments

* little delay before retry is triggered
* check for sGui
This commit is contained in:
Klaus Basan
2018-10-13 01:17:15 +02:00
parent 47b12b66cf
commit 1fbe914cdc
2 changed files with 47 additions and 16 deletions

View File

@@ -11,16 +11,20 @@
#include "copymodelsfromotherswiftversionsdialog.h" #include "copymodelsfromotherswiftversionsdialog.h"
#include "ui_setuploadingdialog.h" #include "ui_setuploadingdialog.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/data/globalsetup.h"
#include "blackcore/setupreader.h" #include "blackcore/setupreader.h"
#include "blackmisc/directoryutils.h" #include "blackmisc/directoryutils.h"
#include "blackmisc/network/urllist.h" #include "blackmisc/network/urllist.h"
#include <QPushButton> #include <QPushButton>
#include <QDesktopServices> #include <QDesktopServices>
#include <QTimer>
#include <QPointer>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Data;
namespace BlackGui namespace BlackGui
{ {
@@ -57,7 +61,7 @@ namespace BlackGui
ui->comp_Messages->hideFilterBar(); // saves space, we only expect aview messages ui->comp_Messages->hideFilterBar(); // saves space, we only expect aview messages
} }
CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent) CSetupLoadingDialog::CSetupLoadingDialog(const CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent)
{ {
ui->comp_Messages->appendStatusMessagesToList(msgs); ui->comp_Messages->appendStatusMessagesToList(msgs);
} }
@@ -77,12 +81,25 @@ namespace BlackGui
void CSetupLoadingDialog::displayBootstrapUrls() void CSetupLoadingDialog::displayBootstrapUrls()
{ {
const CUrlList bootstrapUrls = sApp->getGlobalSetup().getSwiftBootstrapFileUrls(); if (!sApp || sApp->isShuttingDown()) { return; }
const CGlobalSetup setup = sApp->getGlobalSetup();
if (setup.wasLoadedFromWeb())
{
QPointer<CSetupLoadingDialog> myself(this);
QTimer::singleShot(250, this, [ = ]
{
const CUrlList bootstrapUrls = setup.getSwiftBootstrapFileUrls();
for (const CUrl &url : bootstrapUrls) for (const CUrl &url : bootstrapUrls)
{ {
const CStatusMessage msg = CNetworkUtils::canConnect(url) ? const CStatusMessage msg = CNetworkUtils::canConnect(url) ?
CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() : CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() : CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl(); ui->comp_Messages->appendStatusMessageToList(msg);
}
});
}
else
{
const CStatusMessage msg = CStatusMessage(this).warning("No loaded bootstrap setup available");
ui->comp_Messages->appendStatusMessageToList(msg); ui->comp_Messages->appendStatusMessageToList(msg);
} }
} }
@@ -123,7 +140,13 @@ namespace BlackGui
this->prefillSetupCache(); this->prefillSetupCache();
QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry); QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry);
if (!retry) { return; } if (!retry) { return; }
QPointer<CSetupLoadingDialog> myself(this);
QTimer::singleShot(2000, this, [ = ]
{
if (!sApp || !myself) { return; }
retry->click(); retry->click();
});
} }
void CSetupLoadingDialog::prefillSetupCache() void CSetupLoadingDialog::prefillSetupCache()

View File

@@ -824,28 +824,36 @@ namespace BlackGui
{ {
const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs); const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs);
if (msgs.hasErrorMessages()) if (msgs.hasErrorMessages())
{
CSetupLoadingDialog dialog(msgs, this->mainApplicationWidget());
if (sGui)
{ {
static const QString style = sGui->getStyleSheetUtility().styles( static const QString style = sGui->getStyleSheetUtility().styles(
{ {
CStyleSheetUtility::fileNameFonts(), CStyleSheetUtility::fileNameFonts(),
CStyleSheetUtility::fileNameStandardWidget() CStyleSheetUtility::fileNameStandardWidget()
}); });
CSetupLoadingDialog dialog(msgs, this->mainApplicationWidget());
dialog.setStyleSheet(style); dialog.setStyleSheet(style);
}
const int r = dialog.exec(); const int r = dialog.exec();
if (r == QDialog::Rejected) if (r == QDialog::Rejected)
{ {
ok = false; break; // exit with false state, as file was not loaded
break; }
else
{
// run loop again and sync again
} }
} }
else else
{ {
// setup loaded
ok = true; ok = true;
break; break;
} }
} }
while (true); while (!ok);
return ok; return ok;
} }