From 267ad262eed65a98e7023a9da490d559bed9bdff Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 7 Feb 2017 15:15:59 +0000 Subject: [PATCH] Add dialog for suggesting remote replays for non-local captures --- .../Windows/Dialogs/SuggestRemoteDialog.cpp | 98 +++++++++++ .../Windows/Dialogs/SuggestRemoteDialog.h | 70 ++++++++ .../Windows/Dialogs/SuggestRemoteDialog.ui | 157 ++++++++++++++++++ qrenderdoc/qrenderdoc.pro | 9 +- qrenderdoc/qrenderdoc_local.vcxproj | 5 + qrenderdoc/qrenderdoc_local.vcxproj.filters | 15 ++ 6 files changed, 351 insertions(+), 3 deletions(-) create mode 100644 qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.cpp create mode 100644 qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.h create mode 100644 qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.ui diff --git a/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.cpp b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.cpp new file mode 100644 index 000000000..1254139e6 --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.cpp @@ -0,0 +1,98 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "SuggestRemoteDialog.h" +#include +#include "ui_SuggestRemoteDialog.h" + +SuggestRemoteDialog::SuggestRemoteDialog(const QString &driver, const QString &machineIdent, + QWidget *parent) + : QDialog(parent), ui(new Ui::SuggestRemoteDialog) +{ + ui->setupUi(this); + + m_WarningStart = tr("This %1 capture was originally created on a\n '%2' machine.\n\n") + .arg(driver) + .arg(machineIdent.trimmed()); + + ui->warning->setText(m_WarningStart + + tr("Currently you have no remote context selected or configured\n") + + tr("to replay on. Would you like to load the capture locally or\n") + + tr("back out to configure one in Tools > Manage Remote Servers?")); + + m_Remotes = new QMenu(this); + + ui->remote->setEnabled(false); + ui->remote->setIcon(QIcon()); + ui->remote->setText("No Remote"); + + ui->remote->setMenu(m_Remotes); +} + +SuggestRemoteDialog::~SuggestRemoteDialog() +{ + delete ui; +} + +void SuggestRemoteDialog::remotesAdded() +{ + if(m_Remotes->isEmpty()) + return; + + // update text and buttons to reflect that remote hosts are configured + ui->warning->setText(m_WarningStart + + tr("Currently you have no remote context selected, would you like\n") + + tr("to choose a remote context to replay on, or continue and load\n") + + tr("the capture locally?")); + + ui->remote->setEnabled(true); + ui->remote->setIcon(QIcon(QPixmap(QString::fromUtf8(":/Resources/down_arrow.png")))); + ui->remote->setText("Remote"); +} + +bool SuggestRemoteDialog::alwaysReplayLocally() +{ + return ui->alwaysLocal->isChecked(); +} + +void SuggestRemoteDialog::on_alwaysLocal_toggled(bool checked) +{ + ui->remote->setEnabled(!m_Remotes->isEmpty() && !checked); +} + +void SuggestRemoteDialog::on_remote_clicked() +{ +} + +void SuggestRemoteDialog::on_local_clicked() +{ + m_Choice = Local; + accept(); +} + +void SuggestRemoteDialog::on_cancel_clicked() +{ + m_Choice = Cancel; + accept(); +} diff --git a/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.h b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.h new file mode 100644 index 000000000..60c069f4c --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include + +namespace Ui +{ +class SuggestRemoteDialog; +} + +class QMenu; + +class SuggestRemoteDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SuggestRemoteDialog(const QString &driver, const QString &machineIdent, + QWidget *parent = 0); + ~SuggestRemoteDialog(); + + enum SuggestRemoteResult + { + Cancel, + Local, + Remote + }; + + QMenu *remotesMenu() { return m_Remotes; } + void remotesAdded(); + + bool alwaysReplayLocally(); + SuggestRemoteResult choice() { return m_Choice; } +private slots: + // automatic slots + void on_alwaysLocal_toggled(bool checked); + void on_remote_clicked(); + void on_local_clicked(); + void on_cancel_clicked(); + +private: + Ui::SuggestRemoteDialog *ui; + QMenu *m_Remotes; + + QString m_WarningStart; + SuggestRemoteResult m_Choice = Cancel; +}; diff --git a/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.ui b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.ui new file mode 100644 index 000000000..524d5567a --- /dev/null +++ b/qrenderdoc/Windows/Dialogs/SuggestRemoteDialog.ui @@ -0,0 +1,157 @@ + + + SuggestRemoteDialog + + + + 0 + 0 + 389 + 191 + + + + Dialog + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + background-color: #fff; + + + QFrame::NoFrame + + + QFrame::Plain + + + + 16 + + + 16 + + + 16 + + + 16 + + + + + + 0 + 0 + + + + + 0 + 120 + + + + Warning + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + Don't prompt again, +always replay locally. + + + + + + + Qt::Horizontal + + + + 127 + 20 + + + + + + + + Remote + + + + :/Resources/down_arrow.png:/Resources/down_arrow.png + + + + + + + Local + + + + + + + Cancel + + + + + + + + + + + + + diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index ffce64b9d..627882e32 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -137,7 +137,8 @@ SOURCES += Code/qrenderdoc.cpp \ Windows/StatisticsViewer.cpp \ Windows/Dialogs/SettingsDialog.cpp \ Windows/Dialogs/OrderedListEditor.cpp \ - Widgets/Extended/RDTableWidget.cpp + Widgets/Extended/RDTableWidget.cpp \ + Windows/Dialogs/SuggestRemoteDialog.cpp HEADERS += Code/CaptureContext.h \ Code/qprocessinfo.h \ @@ -179,7 +180,8 @@ HEADERS += Code/CaptureContext.h \ Windows/StatisticsViewer.h \ Windows/Dialogs/SettingsDialog.h \ Windows/Dialogs/OrderedListEditor.h \ - Widgets/Extended/RDTableWidget.h + Widgets/Extended/RDTableWidget.h \ + Windows/Dialogs/SuggestRemoteDialog.h FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/MainWindow.ui \ @@ -203,7 +205,8 @@ FORMS += Windows/Dialogs/AboutDialog.ui \ Windows/DebugMessageView.ui \ Windows/StatisticsViewer.ui \ Windows/Dialogs/SettingsDialog.ui \ - Windows/Dialogs/OrderedListEditor.ui + Windows/Dialogs/OrderedListEditor.ui \ + Windows/Dialogs/SuggestRemoteDialog.ui RESOURCES += resources.qrc diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 64810608a..de4fc3d0f 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -525,6 +525,7 @@ + @@ -557,6 +558,7 @@ + @@ -673,6 +675,7 @@ + @@ -701,6 +704,7 @@ + @@ -732,6 +736,7 @@ + diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 5312cd283..205242c11 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -499,6 +499,12 @@ Code + + Windows\Dialogs + + + Generated Files + @@ -888,6 +894,12 @@ Code + + Windows\Dialogs + + + Generated Files + @@ -1132,6 +1144,9 @@ Windows\Dialogs + + Windows\Dialogs +