diff --git a/qrenderdoc/Widgets/Extended/RDTextEdit.cpp b/qrenderdoc/Widgets/Extended/RDTextEdit.cpp new file mode 100644 index 000000000..82c4956c1 --- /dev/null +++ b/qrenderdoc/Widgets/Extended/RDTextEdit.cpp @@ -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 +#include + +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)); +} diff --git a/qrenderdoc/Widgets/Extended/RDTextEdit.h b/qrenderdoc/Widgets/Extended/RDTextEdit.h new file mode 100644 index 000000000..cfde8d808 --- /dev/null +++ b/qrenderdoc/Widgets/Extended/RDTextEdit.h @@ -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 + +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); +}; diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index 6c9f59703..34676ebce 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -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 \ diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index f553df3db..a6433e794 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -650,6 +650,7 @@ + @@ -730,6 +731,7 @@ Level3 + @@ -950,6 +952,12 @@ MOC %(Filename).h $(IntDir)generated\moc_%(Filename).cpp + + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) + $(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 + MOC %(Filename).h + $(IntDir)generated\moc_%(Filename).cpp + %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) $(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 diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 065aebe56..13cefc644 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -576,6 +576,12 @@ Code + + Widgets\Extended + + + Generated Files + @@ -1328,5 +1334,8 @@ Code\pyrenderdoc + + Widgets\Extended + \ No newline at end of file