Add copy progress bar for copies over target control connections

This commit is contained in:
baldurk
2018-09-06 13:17:12 +01:00
parent 0fbb717803
commit 296050e298
4 changed files with 35 additions and 14 deletions
+26 -9
View File
@@ -125,8 +125,8 @@ LiveCapture::LiveCapture(ICaptureContext &ctx, const QString &hostname, const QS
ui->target->setText(QString());
ui->captureProgressLabel->setVisible(false);
ui->captureProgress->setVisible(false);
ui->progressLabel->setVisible(false);
ui->progressBar->setVisible(false);
ui->captures->setItemDelegate(new NameEditOnlyDelegate(this));
@@ -1140,7 +1140,23 @@ void LiveCapture::connectionThreadEntry()
return;
}
TargetControlMessage msg = m_Connection->ReceiveMessage();
TargetControlMessage msg = m_Connection->ReceiveMessage([this](float progress) {
GUIInvoke::call(this, [this, progress]() {
if(progress >= 0.0f && progress < 1.0f)
{
ui->progressLabel->setText(tr("Copy in Progress:"));
ui->progressLabel->setVisible(true);
ui->progressBar->setVisible(true);
ui->progressBar->setMaximum(1000);
ui->progressBar->setValue(1000 * progress);
}
else
{
ui->progressLabel->setVisible(false);
ui->progressBar->setVisible(false);
}
});
});
if(msg.type == TargetControlMessageType::RegisterAPI)
{
@@ -1168,15 +1184,16 @@ void LiveCapture::connectionThreadEntry()
if(progress >= 0.0f && progress < 1.0f)
{
ui->captureProgressLabel->setVisible(true);
ui->captureProgress->setVisible(true);
ui->captureProgress->setMaximum(1000);
ui->captureProgress->setValue(1000 * progress);
ui->progressLabel->setText(tr("Capture in Progress:"));
ui->progressLabel->setVisible(true);
ui->progressBar->setVisible(true);
ui->progressBar->setMaximum(1000);
ui->progressBar->setValue(1000 * progress);
}
else
{
ui->captureProgressLabel->setVisible(false);
ui->captureProgress->setVisible(false);
ui->progressLabel->setVisible(false);
ui->progressBar->setVisible(false);
}
});
+2 -2
View File
@@ -88,7 +88,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="captureProgressLabel">
<widget class="QLabel" name="progressLabel">
<property name="text">
<string>Capture in Progress:</string>
</property>
@@ -159,7 +159,7 @@
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QProgressBar" name="captureProgress">
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
+4 -1
View File
@@ -1297,10 +1297,13 @@ The details of the types of messages that can be received are listed under
This function will block but only to a limited degree. If no message is waiting after a small time
it will return with a No-op message to allow further processing.
:param ProgressCallback progress: A callback that will be repeatedly called with an updated progress
value when a long blocking message is coming through, e.g. a capture copy. Can be ``None`` if no
progress is desired.
:return: The message that was received.
:rtype: TargetControlMessage
)");
virtual TargetControlMessage ReceiveMessage() = 0;
virtual TargetControlMessage ReceiveMessage(RENDERDOC_ProgressCallback progress) = 0;
protected:
ITargetControl() = default;
+3 -2
View File
@@ -76,6 +76,7 @@ std::string DoStringise(const PacketType &el)
STRINGISE_ENUM_NAMED(ePacket_DeleteCapture, "Delete Capture");
STRINGISE_ENUM_NAMED(ePacket_QueueCapture, "Queue Capture");
STRINGISE_ENUM_NAMED(ePacket_NewChild, "New Child");
STRINGISE_ENUM_NAMED(ePacket_CaptureProgress, "Capture Progress");
}
END_ENUM_STRINGISE();
}
@@ -601,7 +602,7 @@ public:
SAFE_DELETE(m_Socket);
}
TargetControlMessage ReceiveMessage()
TargetControlMessage ReceiveMessage(RENDERDOC_ProgressCallback progress)
{
TargetControlMessage msg;
if(m_Socket == NULL)
@@ -762,7 +763,7 @@ public:
StreamWriter streamWriter(FileIO::fopen(msg.newCapture.path.c_str(), "wb"), Ownership::Stream);
ser.SerialiseStream(msg.newCapture.path.c_str(), streamWriter, NULL);
ser.SerialiseStream(msg.newCapture.path.c_str(), streamWriter, progress);
if(reader.IsErrored())
{