mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 21:05:34 +08:00
Ref T199, setup loading widget can display a "copy from other swift versions" dialog
This commit is contained in:
@@ -8,11 +8,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "setuploadingdialog.h"
|
#include "setuploadingdialog.h"
|
||||||
|
#include "copyconfigurationdialog.h"
|
||||||
#include "ui_setuploadingdialog.h"
|
#include "ui_setuploadingdialog.h"
|
||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackmisc/network/urllist.h"
|
|
||||||
#include "blackcore/setupreader.h"
|
#include "blackcore/setupreader.h"
|
||||||
|
#include "blackmisc/directoryutils.h"
|
||||||
|
#include "blackmisc/network/urllist.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
@@ -37,6 +41,9 @@ namespace BlackGui
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl);
|
connect(ui->pb_IgnoreExplicitBootstrapUrl, &QPushButton::clicked, this, &CSetupLoadingDialog::tryAgainWithoutBootstrapUrl);
|
||||||
connect(ui->pb_LoadFromDisk, &QPushButton::clicked, this, &CSetupLoadingDialog::prefillSetupCache);
|
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);
|
QPushButton *retry = ui->bb_Dialog->button(QDialogButtonBox::Retry);
|
||||||
retry->setDefault(true);
|
retry->setDefault(true);
|
||||||
@@ -45,6 +52,7 @@ namespace BlackGui
|
|||||||
this->displayCmdBoostrapUrl();
|
this->displayCmdBoostrapUrl();
|
||||||
this->displayBootstrapUrls();
|
this->displayBootstrapUrls();
|
||||||
this->displayGlobalSetup();
|
this->displayGlobalSetup();
|
||||||
|
this->displayOtherVersionsInfo();
|
||||||
}
|
}
|
||||||
CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent)
|
CSetupLoadingDialog::CSetupLoadingDialog(const BlackMisc::CStatusMessageList &msgs, QWidget *parent) : CSetupLoadingDialog(parent)
|
||||||
{
|
{
|
||||||
@@ -69,9 +77,9 @@ namespace BlackGui
|
|||||||
const CUrlList bootstrapUrls = sApp->getGlobalSetup().getSwiftBootstrapFileUrls();
|
const CUrlList bootstrapUrls = sApp->getGlobalSetup().getSwiftBootstrapFileUrls();
|
||||||
for (const CUrl &url : bootstrapUrls)
|
for (const CUrl &url : bootstrapUrls)
|
||||||
{
|
{
|
||||||
CStatusMessage msg = CNetworkUtils::canConnect(url) ?
|
const CStatusMessage msg = CNetworkUtils::canConnect(url) ?
|
||||||
CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() :
|
CStatusMessage(this).info("Can connect to '%1'") << url.getFullUrl() :
|
||||||
CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
|
CStatusMessage(this).warning("Cannot connect to '%1'") << url.getFullUrl();
|
||||||
ui->comp_Messages->appendStatusMessageToList(msg);
|
ui->comp_Messages->appendStatusMessageToList(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,6 +101,13 @@ namespace BlackGui
|
|||||||
ui->comp_Messages->appendPlainTextToConsole(gs);
|
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()
|
void CSetupLoadingDialog::tryAgainWithoutBootstrapUrl()
|
||||||
{
|
{
|
||||||
if (!sApp->hasSetupReader()) { return; }
|
if (!sApp->hasSetupReader()) { return; }
|
||||||
@@ -126,7 +141,34 @@ namespace BlackGui
|
|||||||
|
|
||||||
const bool hasCachedSetup = this->hasCachedSetup();
|
const bool hasCachedSetup = this->hasCachedSetup();
|
||||||
ui->pb_LoadFromDisk->setEnabled(!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)
|
void CSetupLoadingDialog::onSetupHandlingCompleted(bool success)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
class CCopyConfigurationDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup dialog, if something goes wrong
|
* Setup dialog, if something goes wrong
|
||||||
*/
|
*/
|
||||||
@@ -39,6 +41,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSetupLoadingDialog> ui;
|
QScopedPointer<Ui::CSetupLoadingDialog> ui;
|
||||||
|
QScopedPointer<CCopyConfigurationDialog> m_copyFromOtherSwiftVersion;
|
||||||
|
|
||||||
//! Cached setup available?
|
//! Cached setup available?
|
||||||
bool hasCachedSetup() const;
|
bool hasCachedSetup() const;
|
||||||
@@ -55,6 +58,9 @@ namespace BlackGui
|
|||||||
//! Display global setup
|
//! Display global setup
|
||||||
void displayGlobalSetup();
|
void displayGlobalSetup();
|
||||||
|
|
||||||
|
//! Open the help page
|
||||||
|
void openHelpPage();
|
||||||
|
|
||||||
//! Try again without explicit bootstrap URL
|
//! Try again without explicit bootstrap URL
|
||||||
void tryAgainWithoutBootstrapUrl();
|
void tryAgainWithoutBootstrapUrl();
|
||||||
|
|
||||||
@@ -64,6 +70,15 @@ namespace BlackGui
|
|||||||
//! Display the setup cache info
|
//! Display the setup cache info
|
||||||
void displaySetupCacheInfo();
|
void displaySetupCacheInfo();
|
||||||
|
|
||||||
|
//! Display other versions info
|
||||||
|
void displayOtherVersionsInfo();
|
||||||
|
|
||||||
|
//! Open directory
|
||||||
|
void openDirectory();
|
||||||
|
|
||||||
|
//! Copy from other swift versions
|
||||||
|
void copyFromOtherSwiftVersions();
|
||||||
|
|
||||||
//! Setup loading has been completed
|
//! Setup loading has been completed
|
||||||
void onSetupHandlingCompleted(bool success);
|
void onSetupHandlingCompleted(bool success);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,10 +67,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QLabel" name="lbl_BootstrapMode">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mode:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" 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="2" column="4">
|
<item row="2" column="4">
|
||||||
<widget class="QLineEdit" name="le_BootstrapMode">
|
<widget class="QLineEdit" name="le_BootstrapMode">
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string><html><head/><body><p>The mode, implicit means no URL is provided and the value is obtained from an existing setup.</p></body></html></string>
|
<string><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></string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_BootstrapUrl">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string><html><head/><body><p>The bootstrap URL provided by command line options. This is where the setup data are loaded from.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -87,40 +114,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" 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="2" column="3">
|
|
||||||
<widget class="QLabel" name="lbl_BootstrapMode">
|
|
||||||
<property name="text">
|
|
||||||
<string>Mode:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="le_BootstrapUrl">
|
|
||||||
<property name="whatsThis">
|
|
||||||
<string><html><head/><body><p>The bootstrap URL provided by command line options. This is where the setup data are loaded from.</p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QPushButton" name="pb_IgnoreExplicitBootstrapUrl">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ignore</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="5">
|
<item row="0" column="0" colspan="5">
|
||||||
<widget class="QLabel" name="lbl_Info">
|
<widget class="QLabel" name="lbl_Info">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -134,6 +127,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_CopyOver">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy over:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="lbl_SetupCache">
|
<widget class="QLabel" name="lbl_SetupCache">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -143,8 +143,55 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QPushButton" name="pb_LoadFromDisk">
|
<widget class="QPushButton" name="pb_LoadFromDisk">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string>load the cache data from disk, i.e. from the file which came with the installer</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string> load from disk </string>
|
<string>from disk</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="pb_IgnoreExplicitBootstrapUrl">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string>ignore the bootstrap URL and try to read from cache</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ignore</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QPushButton" name="pb_CopyFromSwift">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string>copy cache data from another swift version</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>copy over</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_OtherSwiftVersions">
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string>Info about other swift versions installed</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="4">
|
||||||
|
<widget class="QPushButton" name="pb_OpemDirectory">
|
||||||
|
<property name="text">
|
||||||
|
<string>open dir.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="4">
|
||||||
|
<widget class="QPushButton" name="pb_Help">
|
||||||
|
<property name="text">
|
||||||
|
<string>help page</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user