From dd844437b6acf4f6a1ac8d43177ceee59ce37926 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 25 Apr 2014 10:11:22 -0700 Subject: [PATCH] Add option to disallow resizing in FramelessDialog --- interface/src/ui/FramelessDialog.cpp | 3 ++- interface/src/ui/FramelessDialog.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index 4919e99db6..ad4b511645 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -16,6 +16,7 @@ const int RESIZE_HANDLE_WIDTH = 7; FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags, Position position) : QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint), + _allowResize(true), _isResizing(false), _resizeInitialWidth(0), _selfHidden(false), @@ -107,7 +108,7 @@ void FramelessDialog::resizeAndPosition(bool resizeParent) { } void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) { - if (mouseEvent->button() == Qt::LeftButton) { + if (_allowResize && mouseEvent->button() == Qt::LeftButton) { bool hitLeft = _position == POSITION_LEFT && abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH; bool hitRight = _position == POSITION_RIGHT && mouseEvent->pos().x() < RESIZE_HANDLE_WIDTH; if (hitLeft || hitRight) { diff --git a/interface/src/ui/FramelessDialog.h b/interface/src/ui/FramelessDialog.h index 828602a5db..450ae5333f 100644 --- a/interface/src/ui/FramelessDialog.h +++ b/interface/src/ui/FramelessDialog.h @@ -23,6 +23,8 @@ public: FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT); void setStyleSheetFile(const QString& fileName); + void setAllowResize(bool allowResize) { _allowResize = allowResize; }; + bool getAllowResize() { return _allowResize; }; protected: virtual void mouseMoveEvent(QMouseEvent* mouseEvent); @@ -35,6 +37,7 @@ protected: private: void resizeAndPosition(bool resizeParent = true); + bool _allowResize; bool _isResizing; int _resizeInitialWidth; bool _selfHidden; ///< true when the dialog itself because of a window event (deactivation or minimization)