mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +08:00
Ref T367, Ref T400 global setup loading dialog adjustments
* little delay before retry is triggered * check for sGui
This commit is contained in:
@@ -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; }
|
||||||
for (const CUrl &url : bootstrapUrls)
|
const CGlobalSetup setup = sApp->getGlobalSetup();
|
||||||
|
if (setup.wasLoadedFromWeb())
|
||||||
{
|
{
|
||||||
const CStatusMessage msg = CNetworkUtils::canConnect(url) ?
|
QPointer<CSetupLoadingDialog> myself(this);
|
||||||
CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() :
|
QTimer::singleShot(250, this, [ = ]
|
||||||
CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
|
{
|
||||||
|
const CUrlList bootstrapUrls = setup.getSwiftBootstrapFileUrls();
|
||||||
|
for (const CUrl &url : bootstrapUrls)
|
||||||
|
{
|
||||||
|
const 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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; }
|
||||||
retry->click();
|
|
||||||
|
QPointer<CSetupLoadingDialog> myself(this);
|
||||||
|
QTimer::singleShot(2000, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!sApp || !myself) { return; }
|
||||||
|
retry->click();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSetupLoadingDialog::prefillSetupCache()
|
void CSetupLoadingDialog::prefillSetupCache()
|
||||||
|
|||||||
@@ -825,27 +825,35 @@ namespace BlackGui
|
|||||||
const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs);
|
const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs);
|
||||||
if (msgs.hasErrorMessages())
|
if (msgs.hasErrorMessages())
|
||||||
{
|
{
|
||||||
static const QString style = sGui->getStyleSheetUtility().styles(
|
|
||||||
{
|
|
||||||
CStyleSheetUtility::fileNameFonts(),
|
|
||||||
CStyleSheetUtility::fileNameStandardWidget()
|
|
||||||
});
|
|
||||||
CSetupLoadingDialog dialog(msgs, this->mainApplicationWidget());
|
CSetupLoadingDialog dialog(msgs, this->mainApplicationWidget());
|
||||||
dialog.setStyleSheet(style);
|
if (sGui)
|
||||||
|
{
|
||||||
|
static const QString style = sGui->getStyleSheetUtility().styles(
|
||||||
|
{
|
||||||
|
CStyleSheetUtility::fileNameFonts(),
|
||||||
|
CStyleSheetUtility::fileNameStandardWidget()
|
||||||
|
});
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user