allow current widget to dictate size of stacked widget for metatile/collision and events pages

This commit is contained in:
garakmon 2020-04-30 19:44:54 -04:00 committed by huderlem
parent ac92534576
commit 37c849f9b5
4 changed files with 33 additions and 1 deletions

View file

@ -677,7 +677,7 @@
</item>
</layout>
</widget>
<widget class="QStackedWidget" name="stackedWidget_MapEvents">
<widget class="AdjustingStackedWidget" name="stackedWidget_MapEvents">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@ -3036,6 +3036,11 @@
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
<customwidget>
<class>AdjustingStackedWidget</class>
<extends>QStackedWidget</extends>
<header>adjustingstackedwidget.h</header>
</customwidget>
<customwidget>
<class>GraphicsView</class>
<extends>QGraphicsView</extends>

View file

@ -0,0 +1,25 @@
#ifndef ADJUSTINGSTACKEDWIDGET_H
#define ADJUSTINGSTACKEDWIDGET_H
#include <QStackedWidget>
class AdjustingStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
AdjustingStackedWidget(QWidget *parent = nullptr) : QStackedWidget(parent) {}
// override this to allow the stacked widget's current page to dictate size
virtual void setCurrentIndex(int index) {
QStackedWidget::setCurrentIndex(index);
for (int i = 0; i < this->count(); ++i) {
this->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
this->widget(index)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
};
#endif // ADJUSTINGSTACKEDWIDGET_H

View file

@ -119,6 +119,7 @@ HEADERS += include/core/block.h \
include/ui/noscrollcombobox.h \
include/ui/noscrollspinbox.h \
include/ui/montabwidget.h \
include/ui/adjustingstackedwidget.h \
include/ui/paletteeditor.h \
include/ui/selectablepixmapitem.h \
include/ui/tileseteditor.h \

View file

@ -8,6 +8,7 @@
#include "ui_eventpropertiesframe.h"
#include "bordermetatilespixmapitem.h"
#include "currentselectedmetatilespixmapitem.h"
#include "adjustingstackedwidget.h"
#include <QFileDialog>
#include <QDirIterator>