mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T156, setup loading dialog allowing to resolved issues with bootstrap loading
This commit is contained in:
committed by
Mathew Sutcliffe
parent
428ba0975c
commit
409a50e8a5
96
src/blackgui/components/setuploadingdialog.cpp
Normal file
96
src/blackgui/components/setuploadingdialog.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "setuploadingdialog.h"
|
||||
#include "ui_setuploadingdialog.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/network/urllist.h"
|
||||
#include "blackcore/setupreader.h"
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CSetupLoadingDialog::CSetupLoadingDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CSetupLoadingDialog)
|
||||
{
|
||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
|
||||
if (sApp->hasSetupReader())
|
||||
{
|
||||
// reset if it was temp.ignored
|
||||
sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(false);
|
||||
}
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl);
|
||||
QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry);
|
||||
retry->setDefault(true);
|
||||
|
||||
this->displayCmdBoostrapUrl();
|
||||
this->displayBootstrapUrls();
|
||||
this->displayGlobalSetup();
|
||||
}
|
||||
|
||||
CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent)
|
||||
{
|
||||
ui->comp_Messages->appendStatusMessagesToList(msgs);
|
||||
}
|
||||
|
||||
CSetupLoadingDialog::~CSetupLoadingDialog()
|
||||
{ }
|
||||
|
||||
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();
|
||||
}
|
||||
ui->comp_Messages->appendStatusMessageToList(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::displayCmdBoostrapUrl()
|
||||
{
|
||||
if (!sApp->hasSetupReader()) { return; }
|
||||
ui->le_CmdLine->setText(sApp->cmdLineArgumentsAsString());
|
||||
ui->le_BootstrapMode->setText(sApp->getSetupReader()->getBootstrapModeAsString());
|
||||
|
||||
const QString bsUrl = sApp->getSetupReader()->getCmdLineBootstrapUrl();
|
||||
ui->pb_IgnoreExplicitBootstrapUrl->setVisible(!bsUrl.isEmpty());
|
||||
ui->le_BootstrapUrl->setText(bsUrl);
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::displayGlobalSetup()
|
||||
{
|
||||
const QString gs = sApp->getGlobalSetup().convertToQString("\n", true);
|
||||
ui->comp_Messages->appendPlainTextToConsole(gs);
|
||||
}
|
||||
|
||||
void CSetupLoadingDialog::tryAgainWithoutBootstrapUrl()
|
||||
{
|
||||
if (!sApp->hasSetupReader()) { return; }
|
||||
sApp->getSetupReader()->setIgnoreCmdLineBootstrapUrl(true);
|
||||
this->accept();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
Reference in New Issue
Block a user