mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add an extended RDTextEdit control subclassed from QTextEdit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016-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 "RDTextEdit.h"
|
||||
#include <QKeyEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
RDTextEdit::RDTextEdit(QWidget *parent) : QTextEdit(parent)
|
||||
{
|
||||
}
|
||||
|
||||
RDTextEdit::~RDTextEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void RDTextEdit::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
QTextEdit::focusInEvent(e);
|
||||
emit(enter());
|
||||
}
|
||||
|
||||
void RDTextEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
QTextEdit::focusOutEvent(e);
|
||||
emit(leave());
|
||||
}
|
||||
|
||||
void RDTextEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
// add ctrl-end and ctrl-home shortcuts, which aren't implemented for read-only edits
|
||||
if(e->key() == Qt::Key_End && e->modifiers() && Qt::ControlModifier)
|
||||
{
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
else if(e->key() == Qt::Key_Home && e->modifiers() && Qt::ControlModifier)
|
||||
{
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->minimum());
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextEdit::keyPressEvent(e);
|
||||
}
|
||||
emit(keyPress(e));
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016-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 <QTextEdit>
|
||||
|
||||
class RDTextEdit : public QTextEdit
|
||||
{
|
||||
private:
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RDTextEdit(QWidget *parent = 0);
|
||||
~RDTextEdit();
|
||||
|
||||
signals:
|
||||
void enter();
|
||||
void leave();
|
||||
void keyPress(QKeyEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
void focusOutEvent(QFocusEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
};
|
||||
@@ -165,6 +165,7 @@ SOURCES += Code/qrenderdoc.cpp \
|
||||
Windows/EventBrowser.cpp \
|
||||
Windows/TextureViewer.cpp \
|
||||
Widgets/Extended/RDLineEdit.cpp \
|
||||
Widgets/Extended/RDTextEdit.cpp \
|
||||
Widgets/Extended/RDLabel.cpp \
|
||||
Widgets/Extended/RDDoubleSpinBox.cpp \
|
||||
Widgets/Extended/RDListView.cpp \
|
||||
@@ -221,6 +222,7 @@ HEADERS += Code/CaptureContext.h \
|
||||
Windows/EventBrowser.h \
|
||||
Windows/TextureViewer.h \
|
||||
Widgets/Extended/RDLineEdit.h \
|
||||
Widgets/Extended/RDTextEdit.h \
|
||||
Widgets/Extended/RDLabel.h \
|
||||
Widgets/Extended/RDDoubleSpinBox.h \
|
||||
Widgets/Extended/RDListView.h \
|
||||
|
||||
@@ -650,6 +650,7 @@
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDSplitter.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDLabel.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDLineEdit.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDTextEdit.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_MainWindow.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDListView.cpp" />
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDListWidget.cpp" />
|
||||
@@ -730,6 +731,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Widgets\Extended\RDLineEdit.cpp" />
|
||||
<ClCompile Include="Widgets\Extended\RDTextEdit.cpp" />
|
||||
<ClCompile Include="Windows\MainWindow.cpp" />
|
||||
<ClCompile Include="Code\ReplayManager.cpp" />
|
||||
<ClCompile Include="Windows\PipelineState\D3D11PipelineStateViewer.cpp" />
|
||||
@@ -950,6 +952,12 @@
|
||||
<Message>MOC %(Filename).h</Message>
|
||||
<Outputs>$(IntDir)generated\moc_%(Filename).cpp</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="Widgets\Extended\RDTextEdit.h">
|
||||
<AdditionalInputs>%(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Command>$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I$(ProjectDir) -I$(SolutionDir)\renderdoc\api\replay -I$(ProjectDir)3rdparty\qt\$(Platform)\mkspecs/win32-msvc2015 -I$(ProjectDir)3rdparty\qt\$(Platform)\include -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtWidgets -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtGui -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtCore %(Fullpath) -o $(IntDir)generated\moc_%(Filename).cpp</Command>
|
||||
<Message>MOC %(Filename).h</Message>
|
||||
<Outputs>$(IntDir)generated\moc_%(Filename).cpp</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="Widgets\Extended\RDListView.h">
|
||||
<AdditionalInputs>%(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Command>$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe -DUNICODE -DWIN32 -DWIN64 -D_WIN32 -D_WIN64 -DRENDERDOC_PLATFORM_WIN32 -DSCINTILLA_QT=1 -DSCI_LEXER=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_MSC_VER=1900 -I$(ProjectDir) -I$(SolutionDir)\renderdoc\api\replay -I$(ProjectDir)3rdparty\qt\$(Platform)\mkspecs/win32-msvc2015 -I$(ProjectDir)3rdparty\qt\$(Platform)\include -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtWidgets -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtGui -I$(ProjectDir)3rdparty\qt\$(Platform)\include\QtCore %(Fullpath) -o $(IntDir)generated\moc_%(Filename).cpp</Command>
|
||||
|
||||
@@ -576,6 +576,12 @@
|
||||
<ClCompile Include="Code\ReplayManager.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Widgets\Extended\RDTextEdit.cpp">
|
||||
<Filter>Widgets\Extended</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(IntDir)generated\moc_RDTextEdit.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="3rdparty\flowlayout\FlowLayout.h">
|
||||
@@ -1328,5 +1334,8 @@
|
||||
<CustomBuild Include="Code\pyrenderdoc\qrenderdoc.i">
|
||||
<Filter>Code\pyrenderdoc</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="Widgets\Extended\RDTextEdit.h">
|
||||
<Filter>Widgets\Extended</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user