mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Switch to helper functions for blocking dialogs (file and message)
* To continue the workaround for QTBUG-56382 we need to run our own manual message loop for dialogs as well. We only use a couple so we can just run it through a handful of thin wrappers.
This commit is contained in:
@@ -93,15 +93,15 @@ void CaptureContext::LoadLogfile(int proxyRenderer, QString replayHost, QString
|
||||
errmsg = status;
|
||||
|
||||
if(proxyRenderer >= 0)
|
||||
QMessageBox::critical(NULL, "Error opening log",
|
||||
QString("%1\nFailed to transfer and replay on remote host %2: %3.\n\n"
|
||||
"Check diagnostic log in Help menu for more details.")
|
||||
.arg(logFile, replayHost, errmsg));
|
||||
RDDialog::critical(NULL, "Error opening log",
|
||||
QString("%1\nFailed to transfer and replay on remote host %2: %3.\n\n"
|
||||
"Check diagnostic log in Help menu for more details.")
|
||||
.arg(logFile, replayHost, errmsg));
|
||||
else
|
||||
QMessageBox::critical(NULL, "Error opening log",
|
||||
QString("%1\nFailed to open logfile for replay: %1.\n\n"
|
||||
"Check diagnostic log in Help menu for more details.")
|
||||
.arg(logFile, errmsg));
|
||||
RDDialog::critical(NULL, "Error opening log",
|
||||
QString("%1\nFailed to open logfile for replay: %1.\n\n"
|
||||
"Check diagnostic log in Help menu for more details.")
|
||||
.arg(logFile, errmsg));
|
||||
|
||||
m_LoadInProgress = false;
|
||||
|
||||
@@ -268,3 +268,89 @@ void GUIInvoke::blockcall(const std::function<void()> &f)
|
||||
invoke->moveToThread(qApp->thread());
|
||||
QMetaObject::invokeMethod(invoke, "doInvoke", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
void RDDialog::show(QDialog *dialog)
|
||||
{
|
||||
dialog->setWindowModality(Qt::ApplicationModal);
|
||||
dialog->show();
|
||||
QEventLoop loop;
|
||||
while(dialog->isVisible())
|
||||
{
|
||||
loop.processEvents(QEventLoop::WaitForMoreEvents);
|
||||
QCoreApplication::sendPostedEvents();
|
||||
}
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton RDDialog::messageBox(QMessageBox::Icon icon, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton)
|
||||
{
|
||||
QMessageBox mb(icon, title, text, buttons, parent);
|
||||
mb.setDefaultButton(defaultButton);
|
||||
show(&mb);
|
||||
return mb.standardButton(mb.clickedButton());
|
||||
}
|
||||
|
||||
QString RDDialog::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QFileDialog fd(parent, caption, dir, QString());
|
||||
fd.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fd.setFileMode(QFileDialog::DirectoryOnly);
|
||||
fd.setOptions(options);
|
||||
show(&fd);
|
||||
|
||||
if(fd.result() == QFileDialog::Accepted)
|
||||
{
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
return files[0];
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString RDDialog::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir,
|
||||
const QString &filter, QString *selectedFilter,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QFileDialog fd(parent, caption, dir, filter);
|
||||
fd.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fd.setOptions(options);
|
||||
show(&fd);
|
||||
|
||||
if(fd.result() == QFileDialog::Accepted)
|
||||
{
|
||||
if(selectedFilter)
|
||||
*selectedFilter = fd.selectedNameFilter();
|
||||
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
return files[0];
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString RDDialog::getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,
|
||||
const QString &filter, QString *selectedFilter,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QFileDialog fd(parent, caption, dir, filter);
|
||||
fd.setAcceptMode(QFileDialog::AcceptSave);
|
||||
fd.setOptions(options);
|
||||
show(&fd);
|
||||
|
||||
if(fd.result() == QFileDialog::Accepted)
|
||||
{
|
||||
if(selectedFilter)
|
||||
*selectedFilter = fd.selectedNameFilter();
|
||||
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
return files[0];
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user