forked from qt-creator/qt-creator
Qnx: Inline QnxDeployQtLibrariesDialog
Change-Id: Ia3b31ab630affc2069831ed377bc8c1bb19aa410 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnxdeployqtlibrariesdialog.h"
|
||||
#include "ui_qnxdeployqtlibrariesdialog.h"
|
||||
|
||||
#include "qnxconstants.h"
|
||||
#include "qnxqtversion.h"
|
||||
@@ -37,8 +36,20 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QDir>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QProgressBar>
|
||||
#include <QPushButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace QtSupport;
|
||||
@@ -51,38 +62,74 @@ namespace Internal {
|
||||
QnxDeployQtLibrariesDialog::QnxDeployQtLibrariesDialog(const IDevice::ConstPtr &device,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::QnxDeployQtLibrariesDialog)
|
||||
, m_device(device)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowTitle(tr("Deploy Qt to QNX Device"));
|
||||
|
||||
m_qtLibraryCombo = new QComboBox(this);
|
||||
const QList<QtVersion*> qtVersions = QtVersionManager::sortVersions(
|
||||
QtVersionManager::versions(QtVersion::isValidPredicate(
|
||||
equal(&QtVersion::type, QString::fromLatin1(Constants::QNX_QNX_QT)))));
|
||||
for (QtVersion *v : qtVersions)
|
||||
m_ui->qtLibraryCombo->addItem(v->displayName(), v->uniqueId());
|
||||
m_qtLibraryCombo->addItem(v->displayName(), v->uniqueId());
|
||||
|
||||
m_ui->basePathLabel->setText(QString());
|
||||
m_ui->remoteDirectory->setText(QLatin1String("/qt"));
|
||||
m_deployButton = new QPushButton(tr("Deploy"), this);
|
||||
m_deployButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
m_basePathLabel = new QLabel(this);
|
||||
|
||||
m_remoteDirectory = new QLineEdit(this);
|
||||
m_remoteDirectory->setText(QLatin1String("/qt"));
|
||||
|
||||
m_deployProgress = new QProgressBar(this);
|
||||
m_deployProgress->setValue(0);
|
||||
m_deployProgress->setTextVisible(true);
|
||||
|
||||
m_deployLogWindow = new QPlainTextEdit(this);
|
||||
|
||||
m_closeButton = new QPushButton(tr("Close"), this);
|
||||
|
||||
m_uploadService = new GenericDirectUploadService(this);
|
||||
m_uploadService->setDevice(m_device);
|
||||
|
||||
auto horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->addWidget(m_qtLibraryCombo);
|
||||
horizontalLayout->addWidget(m_deployButton);
|
||||
|
||||
auto horizontalLayout_3 = new QHBoxLayout();
|
||||
horizontalLayout_3->setSpacing(0);
|
||||
horizontalLayout_3->addWidget(m_basePathLabel);
|
||||
horizontalLayout_3->addWidget(m_remoteDirectory);
|
||||
|
||||
auto formLayout = new QFormLayout();
|
||||
formLayout->addRow(tr("Qt library to deploy:"), horizontalLayout);
|
||||
formLayout->addRow(tr("Remote directory:"), horizontalLayout_3);
|
||||
|
||||
auto horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->addItem(new QSpacerItem(218, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
horizontalLayout_2->addWidget(m_closeButton);
|
||||
|
||||
auto verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->addLayout(formLayout);
|
||||
verticalLayout->addWidget(m_deployProgress);
|
||||
verticalLayout->addWidget(m_deployLogWindow);
|
||||
verticalLayout->addLayout(horizontalLayout_2);
|
||||
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::progressMessage,
|
||||
this, &QnxDeployQtLibrariesDialog::updateProgress);
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::progressMessage,
|
||||
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
m_deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::errorMessage,
|
||||
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
m_deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::warningMessage,
|
||||
this, [this](const QString &message) {
|
||||
if (!message.contains("stat:"))
|
||||
m_ui->deployLogWindow->appendPlainText(message);
|
||||
m_deployLogWindow->appendPlainText(message);
|
||||
});
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::stdOutData,
|
||||
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
m_deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::stdErrData,
|
||||
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
m_deployLogWindow, &QPlainTextEdit::appendPlainText);
|
||||
connect(m_uploadService, &AbstractRemoteLinuxDeployService::finished,
|
||||
this, &QnxDeployQtLibrariesDialog::handleUploadFinished);
|
||||
|
||||
@@ -91,21 +138,18 @@ QnxDeployQtLibrariesDialog::QnxDeployQtLibrariesDialog(const IDevice::ConstPtr &
|
||||
connect(&m_removeDirProcess, &QtcProcess::done,
|
||||
this, &QnxDeployQtLibrariesDialog::handleRemoveDirDone);
|
||||
|
||||
connect(m_ui->deployButton, &QAbstractButton::clicked,
|
||||
connect(m_deployButton, &QAbstractButton::clicked,
|
||||
this, &QnxDeployQtLibrariesDialog::deployLibraries);
|
||||
connect(m_ui->closeButton, &QAbstractButton::clicked,
|
||||
connect(m_closeButton, &QAbstractButton::clicked,
|
||||
this, &QWidget::close);
|
||||
}
|
||||
|
||||
QnxDeployQtLibrariesDialog::~QnxDeployQtLibrariesDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
QnxDeployQtLibrariesDialog::~QnxDeployQtLibrariesDialog() = default;
|
||||
|
||||
int QnxDeployQtLibrariesDialog::execAndDeploy(int qtVersionId, const QString &remoteDirectory)
|
||||
{
|
||||
m_ui->remoteDirectory->setText(remoteDirectory);
|
||||
m_ui->qtLibraryCombo->setCurrentIndex(m_ui->qtLibraryCombo->findData(qtVersionId));
|
||||
m_remoteDirectory->setText(remoteDirectory);
|
||||
m_qtLibraryCombo->setCurrentIndex(m_qtLibraryCombo->findData(qtVersionId));
|
||||
|
||||
deployLibraries();
|
||||
return exec();
|
||||
@@ -114,7 +158,7 @@ int QnxDeployQtLibrariesDialog::execAndDeploy(int qtVersionId, const QString &re
|
||||
void QnxDeployQtLibrariesDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// A disabled Deploy button indicates the upload is still running
|
||||
if (!m_ui->deployButton->isEnabled()) {
|
||||
if (!m_deployButton->isEnabled()) {
|
||||
const int answer = QMessageBox::question(this, windowTitle(),
|
||||
tr("Closing the dialog will stop the deployment. Are you sure you want to do this?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
@@ -129,7 +173,7 @@ void QnxDeployQtLibrariesDialog::deployLibraries()
|
||||
{
|
||||
QTC_ASSERT(m_state == Inactive, return);
|
||||
|
||||
if (m_ui->remoteDirectory->text().isEmpty()) {
|
||||
if (m_remoteDirectory->text().isEmpty()) {
|
||||
QMessageBox::warning(this, windowTitle(),
|
||||
tr("Please input a remote directory to deploy to."));
|
||||
return;
|
||||
@@ -138,11 +182,11 @@ void QnxDeployQtLibrariesDialog::deployLibraries()
|
||||
QTC_ASSERT(!m_device.isNull(), return);
|
||||
|
||||
m_progressCount = 0;
|
||||
m_ui->deployProgress->setValue(0);
|
||||
m_ui->remoteDirectory->setEnabled(false);
|
||||
m_ui->deployButton->setEnabled(false);
|
||||
m_ui->qtLibraryCombo->setEnabled(false);
|
||||
m_ui->deployLogWindow->clear();
|
||||
m_deployProgress->setValue(0);
|
||||
m_remoteDirectory->setEnabled(false);
|
||||
m_deployButton->setEnabled(false);
|
||||
m_qtLibraryCombo->setEnabled(false);
|
||||
m_deployLogWindow->clear();
|
||||
|
||||
startCheckDirProcess();
|
||||
}
|
||||
@@ -155,7 +199,7 @@ void QnxDeployQtLibrariesDialog::startUpload()
|
||||
|
||||
QList<DeployableFile> filesToUpload = gatherFiles();
|
||||
|
||||
m_ui->deployProgress->setRange(0, filesToUpload.count());
|
||||
m_deployProgress->setRange(0, filesToUpload.count());
|
||||
|
||||
m_uploadService->setDeployableFiles(filesToUpload);
|
||||
m_uploadService->start();
|
||||
@@ -168,15 +212,15 @@ void QnxDeployQtLibrariesDialog::updateProgress(const QString &progressMessage)
|
||||
const int progress = progressMessage.count("sftp> put") + progressMessage.count("sftp> ln -s");
|
||||
if (progress != 0) {
|
||||
m_progressCount += progress;
|
||||
m_ui->deployProgress->setValue(m_progressCount);
|
||||
m_deployProgress->setValue(m_progressCount);
|
||||
}
|
||||
}
|
||||
|
||||
void QnxDeployQtLibrariesDialog::handleUploadFinished()
|
||||
{
|
||||
m_ui->remoteDirectory->setEnabled(true);
|
||||
m_ui->deployButton->setEnabled(true);
|
||||
m_ui->qtLibraryCombo->setEnabled(true);
|
||||
m_remoteDirectory->setEnabled(true);
|
||||
m_deployButton->setEnabled(true);
|
||||
m_qtLibraryCombo->setEnabled(true);
|
||||
|
||||
m_state = Inactive;
|
||||
}
|
||||
@@ -185,9 +229,7 @@ QList<DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles()
|
||||
{
|
||||
QList<DeployableFile> result;
|
||||
|
||||
const int qtVersionId =
|
||||
m_ui->qtLibraryCombo->itemData(m_ui->qtLibraryCombo->currentIndex()).toInt();
|
||||
|
||||
const int qtVersionId = m_qtLibraryCombo->itemData(m_qtLibraryCombo->currentIndex()).toInt();
|
||||
|
||||
auto qtVersion = dynamic_cast<const QnxQtVersion *>(QtVersionManager::version(qtVersionId));
|
||||
|
||||
@@ -253,14 +295,14 @@ QList<DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles(
|
||||
|
||||
QString QnxDeployQtLibrariesDialog::fullRemoteDirectory() const
|
||||
{
|
||||
return m_ui->remoteDirectory->text();
|
||||
return m_remoteDirectory->text();
|
||||
}
|
||||
|
||||
void QnxDeployQtLibrariesDialog::startCheckDirProcess()
|
||||
{
|
||||
QTC_CHECK(m_state == Inactive);
|
||||
m_state = CheckingRemoteDirectory;
|
||||
m_ui->deployLogWindow->appendPlainText(tr("Checking existence of \"%1\"")
|
||||
m_deployLogWindow->appendPlainText(tr("Checking existence of \"%1\"")
|
||||
.arg(fullRemoteDirectory()));
|
||||
m_checkDirProcess.setCommand({m_device->filePath("test"),
|
||||
{"-d", fullRemoteDirectory()}});
|
||||
@@ -271,7 +313,7 @@ void QnxDeployQtLibrariesDialog::startRemoveDirProcess()
|
||||
{
|
||||
QTC_CHECK(m_state == CheckingRemoteDirectory);
|
||||
m_state = RemovingRemoteDirectory;
|
||||
m_ui->deployLogWindow->appendPlainText(tr("Removing \"%1\"").arg(fullRemoteDirectory()));
|
||||
m_deployLogWindow->appendPlainText(tr("Removing \"%1\"").arg(fullRemoteDirectory()));
|
||||
m_removeDirProcess.setCommand({m_device->filePath("rm"),
|
||||
{"-rf", fullRemoteDirectory()}});
|
||||
m_removeDirProcess.start();
|
||||
@@ -314,11 +356,10 @@ bool QnxDeployQtLibrariesDialog::handleError(const QtcProcess &process)
|
||||
if (process.result() == ProcessResult::FinishedWithSuccess)
|
||||
return false;
|
||||
|
||||
m_ui->deployLogWindow->appendPlainText(tr("Connection failed: %1").arg(process.errorString()));
|
||||
m_deployLogWindow->appendPlainText(tr("Connection failed: %1").arg(process.errorString()));
|
||||
handleUploadFinished();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
Reference in New Issue
Block a user