Ref T156, setup loading dialog allowing to resolved issues with bootstrap loading

This commit is contained in:
Klaus Basan
2017-09-14 03:06:26 +02:00
committed by Mathew Sutcliffe
parent 428ba0975c
commit 409a50e8a5
3 changed files with 340 additions and 0 deletions

View 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

View File

@@ -0,0 +1,58 @@
/* 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.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_SETUPLOADINGDIALOG_H
#define BLACKGUI_COMPONENTS_SETUPLOADINGDIALOG_H
#include "blackmisc/statusmessagelist.h"
#include <QDialog>
namespace Ui { class CSetupLoadingDialog; }
namespace BlackGui
{
namespace Components
{
/**
* Setup dialog, if something goes wrong
*/
class CSetupLoadingDialog : public QDialog
{
Q_OBJECT
public:
//! Ctor
explicit CSetupLoadingDialog(QWidget *parent = nullptr);
//! Ctor with messages
CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent = nullptr);
//! Dtor
virtual ~CSetupLoadingDialog();
private:
QScopedPointer<Ui::CSetupLoadingDialog> ui;
//! Set info fields
void displayBootstrapUrls();
//! Display bootstrap URL
void displayCmdBoostrapUrl();
//! Display global setup
void displayGlobalSetup();
//! Try again without explicit bootstrap URL
void tryAgainWithoutBootstrapUrl();
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CSetupLoadingDialog</class>
<widget class="QDialog" name="CSetupLoadingDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>Loading the setup (&quot;bootstrap file&quot;)</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vl_SetupDialog">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</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>
</property>
</widget>
</item>
<item row="3" column="5">
<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">
<widget class="QLineEdit" name="le_CmdLine">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_BootstrapUrl">
<property name="toolTip">
<string>Where the bootstrap file is located</string>
</property>
<property name="text">
<string>Bootstrap URL:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="le_BootstrapUrl">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pb_IgnoreExplicitBootstrapUrl">
<property name="text">
<string>Ignore</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6">
<widget class="QLabel" name="lbl_Info">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt; font-weight:600;&quot;&gt;Loading the setup (aka &amp;quot;bootstrap file&amp;quot;) has failed!&lt;/span&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt; This file is required for &lt;/span&gt;&lt;span style=&quot; font-size:9pt; font-style:italic;&quot;&gt;swift&lt;/span&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt; to work properly. You can try to load the file again (&amp;quot;Retry&amp;quot;) or give up (&amp;quot;Cancel&amp;quot;). If you have set an explicit bootstrap URL, you can also ignore this URL and use cached setup data (if there are any).&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="BlackGui::Components::CLogComponent" name="comp_Messages">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_Dialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Retry</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CLogComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/logcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_Dialog</sender>
<signal>accepted()</signal>
<receiver>CSetupLoadingDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_Dialog</sender>
<signal>rejected()</signal>
<receiver>CSetupLoadingDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>