mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 00:17:25 +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) :
|
FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags, Position position) :
|
||||||
QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint),
|
QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint),
|
||||||
|
_allowResize(true),
|
||||||
_isResizing(false),
|
_isResizing(false),
|
||||||
_resizeInitialWidth(0),
|
_resizeInitialWidth(0),
|
||||||
_selfHidden(false),
|
_selfHidden(false),
|
||||||
|
@ -107,7 +108,7 @@ void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) {
|
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 hitLeft = _position == POSITION_LEFT && abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH;
|
||||||
bool hitRight = _position == POSITION_RIGHT && mouseEvent->pos().x() < RESIZE_HANDLE_WIDTH;
|
bool hitRight = _position == POSITION_RIGHT && mouseEvent->pos().x() < RESIZE_HANDLE_WIDTH;
|
||||||
if (hitLeft || hitRight) {
|
if (hitLeft || hitRight) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ public:
|
||||||
|
|
||||||
FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT);
|
FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0, Position position = POSITION_LEFT);
|
||||||
void setStyleSheetFile(const QString& fileName);
|
void setStyleSheetFile(const QString& fileName);
|
||||||
|
void setAllowResize(bool allowResize) { _allowResize = allowResize; };
|
||||||
|
bool getAllowResize() { return _allowResize; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent(QMouseEvent* mouseEvent);
|
virtual void mouseMoveEvent(QMouseEvent* mouseEvent);
|
||||||
|
@ -35,6 +37,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void resizeAndPosition(bool resizeParent = true);
|
void resizeAndPosition(bool resizeParent = true);
|
||||||
|
|
||||||
|
bool _allowResize;
|
||||||
bool _isResizing;
|
bool _isResizing;
|
||||||
int _resizeInitialWidth;
|
int _resizeInitialWidth;
|
||||||
bool _selfHidden; ///< true when the dialog itself because of a window event (deactivation or minimization)
|
bool _selfHidden; ///< true when the dialog itself because of a window event (deactivation or minimization)
|
||||||
|
|
Loading…
Reference in a new issue