fix bug with adding new widget to event frame outside of a paint event
This commit is contained in:
parent
b5adbe782d
commit
ccccb7cec0
4 changed files with 28 additions and 17 deletions
|
@ -1,6 +1,8 @@
|
||||||
#ifndef EVENTPROPERTIESFRAME_H
|
#ifndef EVENTPROPERTIESFRAME_H
|
||||||
#define EVENTPROPERTIESFRAME_H
|
#define EVENTPROPERTIESFRAME_H
|
||||||
|
|
||||||
|
#include "event.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -12,11 +14,16 @@ class EventPropertiesFrame : public QFrame
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EventPropertiesFrame(QWidget *parent = nullptr);
|
explicit EventPropertiesFrame(Event *event, QWidget *parent = nullptr);
|
||||||
~EventPropertiesFrame();
|
~EventPropertiesFrame();
|
||||||
|
void paintEvent(QPaintEvent*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ui::EventPropertiesFrame *ui;
|
Ui::EventPropertiesFrame *ui;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Event *event;
|
||||||
|
bool firstShow = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EVENTPROPERTIESFRAME_H
|
#endif // EVENTPROPERTIESFRAME_H
|
||||||
|
|
|
@ -51,8 +51,6 @@ private:
|
||||||
void paintSmartPath(int x, int y);
|
void paintSmartPath(int x, int y);
|
||||||
static QList<int> smartPathTable;
|
static QList<int> smartPathTable;
|
||||||
|
|
||||||
void paint_object(QGraphicsSceneMouseEvent*);// ?
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||||
void endPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
void endPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "ui_eventpropertiesframe.h"
|
#include "ui_eventpropertiesframe.h"
|
||||||
#include "bordermetatilespixmapitem.h"
|
#include "bordermetatilespixmapitem.h"
|
||||||
#include "currentselectedmetatilespixmapitem.h"
|
#include "currentselectedmetatilespixmapitem.h"
|
||||||
#include "customattributestable.h"
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
|
@ -80,12 +79,12 @@ void MainWindow::initExtraShortcuts() {
|
||||||
|
|
||||||
void MainWindow::initCustomUI() {
|
void MainWindow::initCustomUI() {
|
||||||
// Set up the tab bar
|
// Set up the tab bar
|
||||||
ui->mainTabBar->addTab("Map"); // add the icon
|
ui->mainTabBar->addTab("Map");
|
||||||
ui->mainTabBar->setTabIcon(0, QIcon(QStringLiteral(":/icons/map.ico")));
|
ui->mainTabBar->setTabIcon(0, QIcon(QStringLiteral(":/icons/map.ico")));
|
||||||
ui->mainTabBar->addTab("Events");
|
ui->mainTabBar->addTab("Events");
|
||||||
ui->mainTabBar->addTab("Header");
|
ui->mainTabBar->addTab("Header");
|
||||||
ui->mainTabBar->addTab("Connections");
|
ui->mainTabBar->addTab("Connections");
|
||||||
ui->mainTabBar->addTab("Wild Pokemon"); // add the icon
|
ui->mainTabBar->addTab("Wild Pokemon");
|
||||||
ui->mainTabBar->setTabIcon(4, QIcon(QStringLiteral(":/icons/tall_grass.ico")));
|
ui->mainTabBar->setTabIcon(4, QIcon(QStringLiteral(":/icons/tall_grass.ico")));
|
||||||
|
|
||||||
// Right-clicking on items in the map list tree view brings up a context menu.
|
// Right-clicking on items in the map list tree view brings up a context menu.
|
||||||
|
@ -455,7 +454,7 @@ void MainWindow::redrawMapScene()
|
||||||
if (!editor->displayMap())
|
if (!editor->displayMap())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
on_mainTabBar_tabBarClicked(ui->mainStackedWidget->currentIndex());
|
on_mainTabBar_tabBarClicked(ui->mainTabBar->currentIndex());
|
||||||
|
|
||||||
double base = editor->scale_base;
|
double base = editor->scale_base;
|
||||||
double exp = editor->scale_exp;
|
double exp = editor->scale_exp;
|
||||||
|
@ -1440,7 +1439,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
|
|
||||||
bool pokefirered = projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered;
|
bool pokefirered = projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered;
|
||||||
for (DraggablePixmapItem *item : *events) {
|
for (DraggablePixmapItem *item : *events) {
|
||||||
EventPropertiesFrame *frame = new EventPropertiesFrame;
|
EventPropertiesFrame *frame = new EventPropertiesFrame(item->event);
|
||||||
// frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
// frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
|
|
||||||
QSpinBox *x = frame->ui->spinBox_x;
|
QSpinBox *x = frame->ui->spinBox_x;
|
||||||
|
@ -1746,13 +1745,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
item->bind(combo, key);
|
item->bind(combo, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom fields table.
|
|
||||||
if (event_type != EventType::HealLocation) {
|
|
||||||
CustomAttributesTable *customAttributes = new CustomAttributesTable(item->event, frame);
|
|
||||||
frame->layout()->addWidget(customAttributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
frames.append(frame);
|
frames.append(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2054,7 +2046,7 @@ void MainWindow::on_toolButton_Paint_clicked()
|
||||||
void MainWindow::on_toolButton_Select_clicked()
|
void MainWindow::on_toolButton_Select_clicked()
|
||||||
{
|
{
|
||||||
editor->map_edit_mode = "select";
|
editor->map_edit_mode = "select";
|
||||||
editor->settings->mapCursor = QCursor();//QPixmap(":/icons/cursor.ico"), 0, 0);
|
editor->settings->mapCursor = QCursor();
|
||||||
editor->cursorMapTileRect->setSingleTileMode();
|
editor->cursorMapTileRect->setSingleTileMode();
|
||||||
|
|
||||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
#include "eventpropertiesframe.h"
|
#include "eventpropertiesframe.h"
|
||||||
|
#include "customattributestable.h"
|
||||||
|
|
||||||
#include "ui_eventpropertiesframe.h"
|
#include "ui_eventpropertiesframe.h"
|
||||||
|
|
||||||
EventPropertiesFrame::EventPropertiesFrame(QWidget *parent) :
|
EventPropertiesFrame::EventPropertiesFrame(Event *event, QWidget *parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
ui(new Ui::EventPropertiesFrame)
|
ui(new Ui::EventPropertiesFrame)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->event = event;
|
||||||
|
this->firstShow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventPropertiesFrame::~EventPropertiesFrame()
|
EventPropertiesFrame::~EventPropertiesFrame()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventPropertiesFrame::paintEvent(QPaintEvent *painter) {
|
||||||
|
// Custom fields table.
|
||||||
|
if (firstShow && event->get("event_type") != EventType::HealLocation) {
|
||||||
|
CustomAttributesTable *customAttributes = new CustomAttributesTable(event, this);
|
||||||
|
this->layout()->addWidget(customAttributes);
|
||||||
|
}
|
||||||
|
QFrame::paintEvent(painter);
|
||||||
|
firstShow = false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue