Add ResizableWidget

When manual resizing is enabled, the vertical widget size can be changed
by dragging the widget in the lower right corner.
This commit is contained in:
WarmUpTill
2025-07-04 19:41:54 +02:00
committed by WarmUpTill
parent 5f963b5b7d
commit be8f7bd70f
3 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#pragma once
#include <QMouseEvent>
#include <QPainter>
#include <QWidget>
namespace advss {
class ResizableWidget : public QWidget {
Q_OBJECT
public:
ResizableWidget(QWidget *parent = nullptr);
protected:
void SetResizingEnabled(bool enable);
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
QSize sizeHint() const override;
int GetCustomHeight() const { return _customHeight; }
void SetCustomHeight(int value) { _customHeight = value; }
private:
bool IsInResizeArea(const QPoint &pos) const;
bool _resizingEnabled = false;
bool _resizing = false;
QPoint _lastMousePos;
int _customHeight = 0;
const int _gripSize = 15;
};
} // namespace advss