mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Most of the new Settings sections filled with widgets.
Some animations added: new scale slider, widget_slide_wrap<TWidget>. Any TWidget now can resizeToWidth() with overriden resizeGetHeight().
This commit is contained in:
@@ -206,7 +206,19 @@ public:
|
||||
return QPointer<const TWidget>(this);
|
||||
}
|
||||
|
||||
virtual ~TWidget() {
|
||||
// Get the size of the widget as it should be.
|
||||
// Negative return value means no default width.
|
||||
virtual int naturalWidth() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Count new height for width=newWidth and resize to it.
|
||||
void resizeToWidth(int newWidth) {
|
||||
auto newSize = QSize(newWidth, resizeGetHeight(newWidth));
|
||||
if (newSize != size()) {
|
||||
resize(newSize);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -217,6 +229,11 @@ protected:
|
||||
return QWidget::leaveEvent(e);
|
||||
}
|
||||
|
||||
// Resizes content and counts natural widget height for the desired width.
|
||||
virtual int resizeGetHeight(int newWidth) {
|
||||
return height();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void myEnsureResized(QWidget *target);
|
||||
|
Reference in New Issue
Block a user