From 441d1361778501fdedd36fc49b5695bfe3bdf719 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 10 May 2017 16:49:29 +0100 Subject: [PATCH] Add extended RDToolButton --- qrenderdoc/Widgets/Extended/RDToolButton.cpp | 49 ++++++++++++++++++++ qrenderdoc/Widgets/Extended/RDToolButton.h | 47 +++++++++++++++++++ qrenderdoc/qrenderdoc.pro | 2 + qrenderdoc/qrenderdoc_local.vcxproj | 8 ++++ qrenderdoc/qrenderdoc_local.vcxproj.filters | 9 ++++ 5 files changed, 115 insertions(+) create mode 100644 qrenderdoc/Widgets/Extended/RDToolButton.cpp create mode 100644 qrenderdoc/Widgets/Extended/RDToolButton.h diff --git a/qrenderdoc/Widgets/Extended/RDToolButton.cpp b/qrenderdoc/Widgets/Extended/RDToolButton.cpp new file mode 100644 index 000000000..078e379ad --- /dev/null +++ b/qrenderdoc/Widgets/Extended/RDToolButton.cpp @@ -0,0 +1,49 @@ +/****************************************************************************** + * 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 "RDToolButton.h" +#include + +RDToolButton::RDToolButton(QWidget *parent) : QToolButton(parent) +{ +} + +RDToolButton::~RDToolButton() +{ +} + +void RDToolButton::mousePressEvent(QMouseEvent *event) +{ + emit(mouseClicked(event)); +} + +void RDToolButton::mouseMoveEvent(QMouseEvent *event) +{ + emit(mouseMoved(event)); +} + +void RDToolButton::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit(doubleClicked(event)); +} diff --git a/qrenderdoc/Widgets/Extended/RDToolButton.h b/qrenderdoc/Widgets/Extended/RDToolButton.h new file mode 100644 index 000000000..0af7bb08c --- /dev/null +++ b/qrenderdoc/Widgets/Extended/RDToolButton.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * 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 + +class RDToolButton : public QToolButton +{ +private: + Q_OBJECT +public: + explicit RDToolButton(QWidget *parent = 0); + ~RDToolButton(); + +signals: + void mouseClicked(QMouseEvent *event); + void doubleClicked(QMouseEvent *event); + void mouseMoved(QMouseEvent *event); + +public slots: + +protected: + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; +}; diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index 6c2af0d3c..0c600d033 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -170,6 +170,7 @@ SOURCES += Code/qrenderdoc.cpp \ Widgets/Extended/RDLineEdit.cpp \ Widgets/Extended/RDTextEdit.cpp \ Widgets/Extended/RDLabel.cpp \ + Widgets/Extended/RDToolButton.cpp \ Widgets/Extended/RDDoubleSpinBox.cpp \ Widgets/Extended/RDListView.cpp \ Widgets/CustomPaintWidget.cpp \ @@ -228,6 +229,7 @@ HEADERS += Code/CaptureContext.h \ Widgets/Extended/RDLineEdit.h \ Widgets/Extended/RDTextEdit.h \ Widgets/Extended/RDLabel.h \ + Widgets/Extended/RDToolButton.h \ Widgets/Extended/RDDoubleSpinBox.h \ Widgets/Extended/RDListView.h \ Widgets/CustomPaintWidget.h \ diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 3d6099836..f41d8317a 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -595,6 +595,7 @@ + @@ -652,6 +653,7 @@ + @@ -904,6 +906,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 9be6f4f29..ac9633f5a 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -594,6 +594,12 @@ PCH + + Widgets\Extended + + + Generated Files + @@ -1361,5 +1367,8 @@ Windows + + Widgets\Extended + \ No newline at end of file