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:
hjk
2022-07-11 12:29:52 +02:00
parent a85e19cf19
commit 4da20913bb
5 changed files with 96 additions and 168 deletions

View File

@@ -9,7 +9,7 @@ add_qtc_plugin(Qnx
qnxconfigurationmanager.cpp qnxconfigurationmanager.h qnxconfigurationmanager.cpp qnxconfigurationmanager.h
qnxconstants.h qnxconstants.h
qnxdebugsupport.cpp qnxdebugsupport.h qnxdebugsupport.cpp qnxdebugsupport.h
qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h qnxdeployqtlibrariesdialog.ui qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h
qnxdevice.cpp qnxdevice.h qnxdevice.cpp qnxdevice.h
qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h
qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h

View File

@@ -16,7 +16,6 @@ QtcPlugin {
files: [ files: [
"qnxdeployqtlibrariesdialog.cpp", "qnxdeployqtlibrariesdialog.cpp",
"qnxdeployqtlibrariesdialog.h", "qnxdeployqtlibrariesdialog.h",
"qnxdeployqtlibrariesdialog.ui",
"qnxtoolchain.cpp", "qnxtoolchain.cpp",
"qnxtoolchain.h", "qnxtoolchain.h",
"qnx.qrc", "qnx.qrc",

View File

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

View File

@@ -30,14 +30,20 @@
#include <projectexplorer/devicesupport/idevicefwd.h> #include <projectexplorer/devicesupport/idevicefwd.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
QT_BEGIN_NAMESPACE
class QComboBox;
class QLabel;
class QLineEdit;
class QPlainTextEdit;
class QProgressBar;
QT_END_NAMESPACE
namespace ProjectExplorer { class DeployableFile; } namespace ProjectExplorer { class DeployableFile; }
namespace RemoteLinux { class GenericDirectUploadService; } namespace RemoteLinux { class GenericDirectUploadService; }
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
namespace Ui { class QnxDeployQtLibrariesDialog; }
class QnxDeployQtLibrariesDialog : public QDialog class QnxDeployQtLibrariesDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@@ -79,7 +85,13 @@ private:
QString fullRemoteDirectory() const; QString fullRemoteDirectory() const;
void startUpload(); void startUpload();
Ui::QnxDeployQtLibrariesDialog *m_ui; QComboBox *m_qtLibraryCombo;
QPushButton *m_deployButton;
QLabel *m_basePathLabel;
QLineEdit *m_remoteDirectory;
QProgressBar *m_deployProgress;
QPlainTextEdit *m_deployLogWindow;
QPushButton *m_closeButton;
Utils::QtcProcess m_checkDirProcess; Utils::QtcProcess m_checkDirProcess;
Utils::QtcProcess m_removeDirProcess; Utils::QtcProcess m_removeDirProcess;

View File

@@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Qnx::Internal::QnxDeployQtLibrariesDialog</class>
<widget class="QDialog" name="Qnx::Internal::QnxDeployQtLibrariesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<height>479</height>
</rect>
</property>
<property name="windowTitle">
<string>Deploy Qt to QNX Device</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Qt library to deploy:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="qtLibraryCombo"/>
</item>
<item>
<widget class="QPushButton" name="deployButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Deploy</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Remote directory:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="basePathLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="remoteDirectory">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="deployProgress">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="deployLogWindow"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>218</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>qtLibraryCombo</tabstop>
<tabstop>deployButton</tabstop>
<tabstop>remoteDirectory</tabstop>
<tabstop>deployLogWindow</tabstop>
<tabstop>closeButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>