mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Add option to disallow resizing in FramelessDialog
This commit is contained in:
parent
225c022511
commit
dd844437b6
2 changed files with 5 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue