From 409a50e8a518b10eb9d0695ed8eb8acc8b815e4c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 14 Sep 2017 03:06:26 +0200 Subject: [PATCH] Ref T156, setup loading dialog allowing to resolved issues with bootstrap loading --- .../components/setuploadingdialog.cpp | 96 +++++++++ src/blackgui/components/setuploadingdialog.h | 58 ++++++ src/blackgui/components/setuploadingdialog.ui | 186 ++++++++++++++++++ 3 files changed, 340 insertions(+) create mode 100644 src/blackgui/components/setuploadingdialog.cpp create mode 100644 src/blackgui/components/setuploadingdialog.h create mode 100644 src/blackgui/components/setuploadingdialog.ui diff --git a/src/blackgui/components/setuploadingdialog.cpp b/src/blackgui/components/setuploadingdialog.cpp new file mode 100644 index 000000000..69a1a031f --- /dev/null +++ b/src/blackgui/components/setuploadingdialog.cpp @@ -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 + +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 diff --git a/src/blackgui/components/setuploadingdialog.h b/src/blackgui/components/setuploadingdialog.h new file mode 100644 index 000000000..96f1dcff1 --- /dev/null +++ b/src/blackgui/components/setuploadingdialog.h @@ -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 + +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; + + //! 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 diff --git a/src/blackgui/components/setuploadingdialog.ui b/src/blackgui/components/setuploadingdialog.ui new file mode 100644 index 000000000..fcb1b6e8b --- /dev/null +++ b/src/blackgui/components/setuploadingdialog.ui @@ -0,0 +1,186 @@ + + + CSetupLoadingDialog + + + + 0 + 0 + 800 + 600 + + + + + 600 + 400 + + + + Loading the setup ("bootstrap file") + + + true + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Cmd: + + + + + + + true + + + + + + + Mode: + + + + + + + true + + + + + + + Where the bootstrap file is located + + + Bootstrap URL: + + + + + + + true + + + + + + + Ignore + + + + + + + <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> + + + Qt::RichText + + + true + + + + + + + + + + + 0 + 0 + + + + + 0 + 200 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Retry + + + + + + + + BlackGui::Components::CLogComponent + QFrame +
blackgui/components/logcomponent.h
+ 1 +
+
+ + + + bb_Dialog + accepted() + CSetupLoadingDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_Dialog + rejected() + CSetupLoadingDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +