From ee1e5e8e95aaa220d059f5c787a35cdf652bf1d3 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 25 Dec 2017 13:15:53 +0100 Subject: [PATCH] Ref T199, setup loading widget can display a "copy from other swift versions" dialog --- .../components/setuploadingdialog.cpp | 52 +++++++- src/blackgui/components/setuploadingdialog.h | 15 +++ src/blackgui/components/setuploadingdialog.ui | 119 ++++++++++++------ 3 files changed, 145 insertions(+), 41 deletions(-) diff --git a/src/blackgui/components/setuploadingdialog.cpp b/src/blackgui/components/setuploadingdialog.cpp index d993b2046..b4e67b700 100644 --- a/src/blackgui/components/setuploadingdialog.cpp +++ b/src/blackgui/components/setuploadingdialog.cpp @@ -8,11 +8,15 @@ */ #include "setuploadingdialog.h" +#include "copyconfigurationdialog.h" #include "ui_setuploadingdialog.h" #include "blackgui/guiapplication.h" -#include "blackmisc/network/urllist.h" #include "blackcore/setupreader.h" +#include "blackmisc/directoryutils.h" +#include "blackmisc/network/urllist.h" + #include +#include using namespace BlackMisc; using namespace BlackMisc::Network; @@ -37,6 +41,9 @@ namespace BlackGui ui->setupUi(this); connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl); connect(ui->pb_LoadFromDisk, &QPushButton::clicked, this, &CSetupLoadingDialog::prefillSetupCache); + connect(ui->pb_Help, &QPushButton::clicked, this, &CSetupLoadingDialog::openHelpPage); + connect(ui->pb_CopyFromSwift, &QPushButton::clicked, this, &CSetupLoadingDialog::copyFromOtherSwiftVersions); + connect(ui->pb_OpemDirectory, &QPushButton::clicked, this, &CSetupLoadingDialog::openDirectory); QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry); retry->setDefault(true); @@ -45,6 +52,7 @@ namespace BlackGui this->displayCmdBoostrapUrl(); this->displayBootstrapUrls(); this->displayGlobalSetup(); + this->displayOtherVersionsInfo(); } CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent) { @@ -69,9 +77,9 @@ namespace BlackGui const CUrlList bootstrapUrls = sApp->getGlobalSetup().getSwiftBootstrapFileUrls(); for (const CUrl &url : bootstrapUrls) { - CStatusMessage msg = CNetworkUtils::canConnect(url) ? - CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() : - CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl(); + 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); } } @@ -93,6 +101,13 @@ namespace BlackGui ui->comp_Messages->appendPlainTextToConsole(gs); } + void CSetupLoadingDialog::openHelpPage() + { + const CUrl url = sApp->getGlobalSetup().getHelpPageUrl("bootstrap"); + if (url.isEmpty()) { return; } + QDesktopServices::openUrl(url); + } + void CSetupLoadingDialog::tryAgainWithoutBootstrapUrl() { if (!sApp->hasSetupReader()) { return; } @@ -126,7 +141,34 @@ namespace BlackGui const bool hasCachedSetup = this->hasCachedSetup(); ui->pb_LoadFromDisk->setEnabled(!hasCachedSetup); - ui->pb_LoadFromDisk->setVisible(!hasCachedSetup); + ui->pb_LoadFromDisk->setToolTip(hasCachedSetup ? "Cached setup already available" : "No cached setup"); + } + + void CSetupLoadingDialog::displayOtherVersionsInfo() + { + const int other = CDirectoryUtils::applicationDataDirectoriesCount() - 1 ; + ui->le_OtherSwiftVersions->setText(QString("There is/are %1 other swift version(s) installed").arg(other)); + ui->pb_CopyFromSwift->setEnabled(other > 0); + } + + void CSetupLoadingDialog::openDirectory() + { + const QUrl url = QUrl::fromLocalFile(CDirectoryUtils::normalizedApplicationDataDirectory()); + QDesktopServices::openUrl(url); + } + + void CSetupLoadingDialog::copyFromOtherSwiftVersions() + { + if (!m_copyFromOtherSwiftVersion) + { + CCopyConfigurationDialog *d = new CCopyConfigurationDialog(this); + d->setModal(true); + d->setCacheCode(); + m_copyFromOtherSwiftVersion.reset(d); + } + + const int r = m_copyFromOtherSwiftVersion->exec(); + Q_UNUSED(r); } void CSetupLoadingDialog::onSetupHandlingCompleted(bool success) diff --git a/src/blackgui/components/setuploadingdialog.h b/src/blackgui/components/setuploadingdialog.h index 9a0f8cc39..4da499d02 100644 --- a/src/blackgui/components/setuploadingdialog.h +++ b/src/blackgui/components/setuploadingdialog.h @@ -20,6 +20,8 @@ namespace BlackGui { namespace Components { + class CCopyConfigurationDialog; + /** * Setup dialog, if something goes wrong */ @@ -39,6 +41,7 @@ namespace BlackGui private: QScopedPointer ui; + QScopedPointer m_copyFromOtherSwiftVersion; //! Cached setup available? bool hasCachedSetup() const; @@ -55,6 +58,9 @@ namespace BlackGui //! Display global setup void displayGlobalSetup(); + //! Open the help page + void openHelpPage(); + //! Try again without explicit bootstrap URL void tryAgainWithoutBootstrapUrl(); @@ -64,6 +70,15 @@ namespace BlackGui //! Display the setup cache info void displaySetupCacheInfo(); + //! Display other versions info + void displayOtherVersionsInfo(); + + //! Open directory + void openDirectory(); + + //! Copy from other swift versions + void copyFromOtherSwiftVersions(); + //! Setup loading has been completed void onSetupHandlingCompleted(bool success); }; diff --git a/src/blackgui/components/setuploadingdialog.ui b/src/blackgui/components/setuploadingdialog.ui index fa986ba36..08575c465 100644 --- a/src/blackgui/components/setuploadingdialog.ui +++ b/src/blackgui/components/setuploadingdialog.ui @@ -67,10 +67,37 @@ + + + + Mode: + + + + + + + Where the bootstrap file is located + + + Bootstrap URL: + + + - <html><head/><body><p>The mode, implicit means no URL is provided and the value is obtained from an existing setup.</p></body></html> + <html><head/><body><p>The mode: 'implicit' means no URL is provided and the value is obtained from an existing setup. 'explicit' means an URL is provided via command line arguments.</p></body></html> + + + true + + + + + + + <html><head/><body><p>The bootstrap URL provided by command line options. This is where the setup data are loaded from.</p></body></html> true @@ -87,40 +114,6 @@ - - - - Where the bootstrap file is located - - - Bootstrap URL: - - - - - - - Mode: - - - - - - - <html><head/><body><p>The bootstrap URL provided by command line options. This is where the setup data are loaded from.</p></body></html> - - - true - - - - - - - Ignore - - - @@ -134,6 +127,13 @@ + + + + Copy over: + + + @@ -143,8 +143,55 @@ + + load the cache data from disk, i.e. from the file which came with the installer + - load from disk + from disk + + + + + + + ignore the bootstrap URL and try to read from cache + + + ignore + + + + + + + copy cache data from another swift version + + + copy over + + + + + + + Info about other swift versions installed + + + true + + + + + + + open dir. + + + + + + + help page