mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 13:00:32 +00:00
Filter out previous/next drawcall shortcuts when text editing.
Closes #911 editing. path. 'ad0678a'.
This commit is contained in:
@@ -98,13 +98,16 @@ DECLARE_REFLECTION_STRUCT(CaptureSettings);
|
||||
|
||||
DOCUMENT(R"(The main parent window of the application.
|
||||
|
||||
.. function:: ShortcutCallback()
|
||||
.. function:: ShortcutCallback(QWidget focusWidget)
|
||||
|
||||
Not a member function - the signature for any ``ShortcutCallback`` callbacks.
|
||||
|
||||
:param QWidget focusWidget: The widget with focus at the time this shortcut was detected. May be
|
||||
``None``.
|
||||
)");
|
||||
struct IMainWindow
|
||||
{
|
||||
typedef std::function<void()> ShortcutCallback;
|
||||
typedef std::function<void(QWidget *focusWidget)> ShortcutCallback;
|
||||
|
||||
DOCUMENT(
|
||||
"Retrieves the QWidget for this :class:`MainWindow` if PySide2 is available, or otherwise a "
|
||||
|
||||
@@ -34,6 +34,8 @@ TEMPLATE_ARRAY_DECLARE(rdcarray);
|
||||
|
||||
extern "C" QWidget *QWidgetFromPy(PyObject *widget);
|
||||
extern "C" PyObject *QWidgetToPy(QWidget *widget);
|
||||
|
||||
DECLARE_STRINGISE_TYPE(QWidget);
|
||||
%}
|
||||
|
||||
%typemap(in) QWidget * {
|
||||
|
||||
@@ -23,12 +23,17 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "EventBrowser.h"
|
||||
#include <QAbstractSpinBox>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QKeyEvent>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QShortcut>
|
||||
#include <QTextEdit>
|
||||
#include <QTimer>
|
||||
#include "3rdparty/flowlayout/FlowLayout.h"
|
||||
#include "3rdparty/scintilla/include/qt/ScintillaEdit.h"
|
||||
#include "Code/QRDUtils.h"
|
||||
#include "Code/Resources.h"
|
||||
#include "Widgets/Extended/RDHeaderView.h"
|
||||
@@ -59,6 +64,21 @@ enum
|
||||
COL_COUNT,
|
||||
};
|
||||
|
||||
static bool textEditControl(QWidget *sender)
|
||||
{
|
||||
if(qobject_cast<QLineEdit *>(sender) || qobject_cast<QTextEdit *>(sender) ||
|
||||
qobject_cast<QAbstractSpinBox *>(sender) || qobject_cast<ScintillaEditBase *>(sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QComboBox *combo = qobject_cast<QComboBox *>(sender);
|
||||
if(combo && combo->isEditable())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
|
||||
: QFrame(parent), ui(new Ui::EventBrowser), m_Ctx(ctx)
|
||||
{
|
||||
@@ -133,19 +153,33 @@ EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent)
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
ctx.GetMainWindow()->RegisterShortcut(QKeySequence(keys[i] | Qt::ControlModifier).toString(),
|
||||
NULL, [this, i]() { jumpToBookmark(i); });
|
||||
NULL, [this, i](QWidget *) { jumpToBookmark(i); });
|
||||
}
|
||||
|
||||
ctx.GetMainWindow()->RegisterShortcut(QKeySequence(Qt::Key_Left | Qt::ControlModifier).toString(),
|
||||
NULL, [this]() { on_stepPrev_clicked(); });
|
||||
NULL, [this](QWidget *sender) {
|
||||
// don't apply this shortcut if we're in a text edit type
|
||||
// control
|
||||
if(textEditControl(sender))
|
||||
return;
|
||||
|
||||
ctx.GetMainWindow()->RegisterShortcut(QKeySequence(Qt::Key_Right | Qt::ControlModifier).toString(),
|
||||
NULL, [this]() { on_stepNext_clicked(); });
|
||||
on_stepPrev_clicked();
|
||||
});
|
||||
|
||||
ctx.GetMainWindow()->RegisterShortcut(
|
||||
QKeySequence(Qt::Key_Right | Qt::ControlModifier).toString(), NULL, [this](QWidget *sender) {
|
||||
// don't apply this shortcut if we're in a text edit type
|
||||
// control
|
||||
if(textEditControl(sender))
|
||||
return;
|
||||
|
||||
on_stepNext_clicked();
|
||||
});
|
||||
|
||||
ctx.GetMainWindow()->RegisterShortcut(QKeySequence(Qt::Key_Escape).toString(), ui->findStrip,
|
||||
[this]() { on_HideFindJump(); });
|
||||
[this](QWidget *) { on_HideFindJump(); });
|
||||
ctx.GetMainWindow()->RegisterShortcut(QKeySequence(Qt::Key_Escape).toString(), ui->jumpStrip,
|
||||
[this]() { on_HideFindJump(); });
|
||||
[this](QWidget *) { on_HideFindJump(); });
|
||||
|
||||
ui->events->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
QObject::connect(ui->events, &RDTreeWidget::customContextMenuRequested, this,
|
||||
|
||||
@@ -380,7 +380,7 @@ MainWindow::MainWindow(ICaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Mai
|
||||
QKeySequence ks = a->shortcut();
|
||||
if(!ks.isEmpty())
|
||||
{
|
||||
m_GlobalShortcutCallbacks[ks] = [a]() {
|
||||
m_GlobalShortcutCallbacks[ks] = [a](QWidget *) {
|
||||
if(a->isEnabled())
|
||||
a->trigger();
|
||||
};
|
||||
@@ -1942,7 +1942,7 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
// then use that callback
|
||||
if(widgets.contains(focus))
|
||||
{
|
||||
callbacks[focus]();
|
||||
callbacks[focus](focus);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
@@ -1952,10 +1952,12 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
focus = QApplication::focusWidget();
|
||||
|
||||
// if we didn't find matches or no such shortcut is registered, try global shortcuts
|
||||
if(m_GlobalShortcutCallbacks.contains(pressed))
|
||||
{
|
||||
m_GlobalShortcutCallbacks[pressed]();
|
||||
m_GlobalShortcutCallbacks[pressed](focus);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ void ShaderViewer::editShader(bool customShader, const QString &entryPoint, cons
|
||||
});
|
||||
|
||||
m_Ctx.GetMainWindow()->RegisterShortcut(QKeySequence(QKeySequence::Refresh).toString(), this,
|
||||
[this]() { on_refresh_clicked(); });
|
||||
[this](QWidget *) { on_refresh_clicked(); });
|
||||
ui->refresh->setToolTip(ui->refresh->toolTip() +
|
||||
lit(" (%1)").arg(QKeySequence(QKeySequence::Refresh).toString()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user