diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.cpp b/src/plugins/remotelinux/publickeydeploymentdialog.cpp index e8e341cc43b..38cdf4fb168 100644 --- a/src/plugins/remotelinux/publickeydeploymentdialog.cpp +++ b/src/plugins/remotelinux/publickeydeploymentdialog.cpp @@ -57,20 +57,20 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog( [this] { d->m_done ? accept() : reject(); }); connect(&d->m_process, &Process::done, this, [this] { const bool succeeded = d->m_process.result() == ProcessResult::FinishedWithSuccess; - QString finalMessage; + Result result = Result::Ok; if (!succeeded) { const QString errorString = d->m_process.errorString(); const QString errorMessage = errorString.isEmpty() ? d->m_process.cleanedStdErr() : errorString; - finalMessage = Utils::joinStrings({Tr::tr("Key deployment failed."), - Utils::trimBack(errorMessage, '\n')}, '\n'); + result = Result::Error(Utils::joinStrings({Tr::tr("Key deployment failed."), + Utils::trimBack(errorMessage, '\n')}, '\n')); } - handleDeploymentDone(succeeded, finalMessage); + handleDeploymentDone(result); }); FileReader reader; if (!reader.fetch(publicKeyFileName)) { - handleDeploymentDone(false, Tr::tr("Public key error: %1").arg(reader.errorString())); + handleDeploymentDone(Result::Error(Tr::tr("Public key error: %1").arg(reader.errorString()))); return; } @@ -111,16 +111,16 @@ PublicKeyDeploymentDialog::~PublicKeyDeploymentDialog() delete d; } -void PublicKeyDeploymentDialog::handleDeploymentDone(bool succeeded, const QString &errorMessage) +void PublicKeyDeploymentDialog::handleDeploymentDone(const Result &result) { - QString buttonText = succeeded ? Tr::tr("Deployment finished successfully.") : errorMessage; + QString buttonText = result ? Tr::tr("Deployment finished successfully.") : result.error(); const QString textColor = creatorColor( - succeeded ? Theme::TextColorNormal : Theme::TextColorError).name(); + result ? Theme::TextColorNormal : Theme::TextColorError).name(); setLabelText(QString::fromLatin1("%2") .arg(textColor, buttonText.replace("\n", "
"))); setCancelButtonText(Tr::tr("Close")); - if (!succeeded) + if (!result) return; setValue(1); diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.h b/src/plugins/remotelinux/publickeydeploymentdialog.h index 68b023e8133..fef4fe14a3f 100644 --- a/src/plugins/remotelinux/publickeydeploymentdialog.h +++ b/src/plugins/remotelinux/publickeydeploymentdialog.h @@ -7,7 +7,10 @@ #include -namespace Utils { class FilePath; } +namespace Utils { +class FilePath; +class Result; +} namespace RemoteLinux::Internal { @@ -28,7 +31,7 @@ public: ~PublicKeyDeploymentDialog() override; private: - void handleDeploymentDone(bool succeeded, const QString &errorMessage); + void handleDeploymentDone(const Utils::Result &result); Internal::PublicKeyDeploymentDialogPrivate * const d; };