mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-20 07:36:31 -05:00
Use collapsible section for header data in new map dialog
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>526</height>
|
||||
<height>520</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
@@ -39,24 +39,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_ID">
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_NameError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 0, 0)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="lineEdit_Name">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the new map. The name cannot be the same as any other existing map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<item row="5" column="3">
|
||||
<widget class="QLabel" name="label_GroupError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
@@ -72,7 +71,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<item row="7" column="0" colspan="4" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QGroupBox" name="groupBox_BorderDimensions">
|
||||
<property name="title">
|
||||
<string>Border Dimensions</string>
|
||||
@@ -127,115 +126,14 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_Group">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_ID">
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
<string>ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_NameError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 0, 0)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_CanFlyTo">
|
||||
<property name="text">
|
||||
<string>Can Fly To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="3" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QGroupBox" name="groupBox_Tilesets">
|
||||
<property name="title">
|
||||
<string>Tilesets</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_PrimaryTileset">
|
||||
<property name="text">
|
||||
<string>Primary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The primary tileset for the new map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_SecondaryTileset">
|
||||
<property name="text">
|
||||
<string>Secondary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The secondary tileset for the new map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_TilesetsError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 0, 0)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<item row="6" column="0" colspan="4" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QGroupBox" name="groupBox_MapDimensions">
|
||||
<property name="title">
|
||||
<string>Map Dimensions</string>
|
||||
@@ -306,14 +204,102 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="4" column="3">
|
||||
<widget class="NoScrollComboBox" name="comboBox_Group">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the group this map will be added to.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="lineEdit_ID">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The constant that will be used to refer to this map. It cannot be the same as any other existing map, and it must start with the specified prefix.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="lineEdit_Name">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the new map. The name cannot be the same as any other existing map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="4" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QGroupBox" name="groupBox_Tilesets">
|
||||
<property name="title">
|
||||
<string>Tilesets</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_PrimaryTileset">
|
||||
<property name="text">
|
||||
<string>Primary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The primary tileset for the new map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_SecondaryTileset">
|
||||
<property name="text">
|
||||
<string>Secondary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The secondary tileset for the new map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_TilesetsError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 0, 0)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_IDError">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
@@ -329,28 +315,45 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_HeaderData">
|
||||
<property name="title">
|
||||
<string>Header Data</string>
|
||||
<item row="14" column="0" colspan="4">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layout_HeaderData"/>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="NoScrollComboBox" name="comboBox_Group">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The name of the group this map will be added to.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertPolicy::NoInsert</enum>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_Group">
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="13" column="0" colspan="4">
|
||||
<widget class="QWidget" name="widget_HeaderData" native="true">
|
||||
<layout class="QVBoxLayout" name="layout_HeaderData">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="3">
|
||||
<widget class="QCheckBox" name="checkBox_CanFlyTo">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked, a Heal Location will be added to this map automatically.</p></body></html></string>
|
||||
@@ -360,6 +363,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_CanFlyTo">
|
||||
<property name="text">
|
||||
<string>Can Fly To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
this->showTilesetEditorLayerGrid = true;
|
||||
this->monitorFiles = true;
|
||||
this->tilesetCheckerboardFill = true;
|
||||
this->newMapHeaderSectionExpanded = false;
|
||||
this->theme = "default";
|
||||
this->wildMonChartTheme = "";
|
||||
this->textEditorOpenFolder = "";
|
||||
@@ -121,6 +122,7 @@ public:
|
||||
bool showTilesetEditorLayerGrid;
|
||||
bool monitorFiles;
|
||||
bool tilesetCheckerboardFill;
|
||||
bool newMapHeaderSectionExpanded;
|
||||
QString theme;
|
||||
QString wildMonChartTheme;
|
||||
QString textEditorOpenFolder;
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Elypson/qt-collapsible-section. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
PORYMAP NOTE: Modified to support having the section expanded by default, to stop the contents
|
||||
squashing during the collapse animation, and to add some guard rails against crashes.
|
||||
*/
|
||||
|
||||
#ifndef COLLAPSIBLESECTION_H
|
||||
@@ -24,6 +28,7 @@
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QScrollArea>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
@@ -31,32 +36,33 @@
|
||||
class CollapsibleSection : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollapsibleSection(const QString& title = "", const bool expanded = false, const int animationDuration = 0, QWidget* parent = 0);
|
||||
|
||||
void setContentLayout(QLayout* contentLayout);
|
||||
void setTitle(QString title);
|
||||
bool isExpanded() const { return this->expanded; }
|
||||
|
||||
public slots:
|
||||
void toggle(bool collapsed);
|
||||
|
||||
private:
|
||||
QGridLayout* mainLayout;
|
||||
QToolButton* toggleButton;
|
||||
QFrame* headerLine;
|
||||
QParallelAnimationGroup* toggleAnimation;
|
||||
QSet<QPropertyAnimation*> sectionAnimations;
|
||||
QPropertyAnimation* contentAnimation;
|
||||
QScrollArea* contentArea;
|
||||
int animationDuration;
|
||||
int collapsedHeight;
|
||||
bool isExpanded = false;
|
||||
|
||||
public slots:
|
||||
void toggle(bool collapsed);
|
||||
bool expanded;
|
||||
|
||||
public:
|
||||
// initialize section
|
||||
explicit CollapsibleSection(const QString& title = "", const int animationDuration = 0, QWidget* parent = 0);
|
||||
void updateToggleButton();
|
||||
void updateAnimationTargets();
|
||||
int getContentHeight() const;
|
||||
|
||||
// set layout of content
|
||||
void setContentLayout(QLayout& contentLayout);
|
||||
|
||||
// set title
|
||||
void setTitle(QString title);
|
||||
|
||||
// update animations and their heights
|
||||
void updateHeights();
|
||||
};
|
||||
|
||||
#endif // COLLAPSIBLESECTION_H
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "project.h"
|
||||
#include "map.h"
|
||||
#include "mapheaderform.h"
|
||||
#include "lib/collapsiblesection.h"
|
||||
|
||||
namespace Ui {
|
||||
class NewMapDialog;
|
||||
@@ -24,7 +25,7 @@ public:
|
||||
bool importedMap;
|
||||
QString layoutId;
|
||||
void init();
|
||||
//void initUi();
|
||||
//void initUi();//TODO
|
||||
void init(int tabIndex, QString data);
|
||||
void init(Layout *);
|
||||
static void setDefaultSettings(Project *project);
|
||||
@@ -35,6 +36,7 @@ signals:
|
||||
private:
|
||||
Ui::NewMapDialog *ui;
|
||||
Project *project;
|
||||
CollapsibleSection *headerSection;
|
||||
MapHeaderForm *headerData;
|
||||
|
||||
bool validateMapDimensions();
|
||||
|
||||
@@ -371,6 +371,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||
this->monitorFiles = getConfigBool(key, value);
|
||||
} else if (key == "tileset_checkerboard_fill") {
|
||||
this->tilesetCheckerboardFill = getConfigBool(key, value);
|
||||
} else if (key == "new_map_header_section_expanded") {
|
||||
this->newMapHeaderSectionExpanded = getConfigBool(key, value);
|
||||
} else if (key == "theme") {
|
||||
this->theme = value;
|
||||
} else if (key == "wild_mon_chart_theme") {
|
||||
@@ -453,6 +455,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||
map.insert("show_tileset_editor_layer_grid", this->showTilesetEditorLayerGrid ? "1" : "0");
|
||||
map.insert("monitor_files", this->monitorFiles ? "1" : "0");
|
||||
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
|
||||
map.insert("new_map_header_section_expanded", this->newMapHeaderSectionExpanded ? "1" : "0");
|
||||
map.insert("theme", this->theme);
|
||||
map.insert("wild_mon_chart_theme", this->wildMonChartTheme);
|
||||
map.insert("text_editor_open_directory", this->textEditorOpenFolder);
|
||||
|
||||
@@ -16,13 +16,15 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Elypson/qt-collapsible-section. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
PORYMAP NOTE: Modified to support having the section expanded by default, to stop the contents
|
||||
squashing during the collapse animation, and to add some guard rails against crashes.
|
||||
*/
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
#include "collapsiblesection.h"
|
||||
CollapsibleSection::CollapsibleSection(const QString& title, const int animationDuration, QWidget* parent)
|
||||
: QWidget(parent), animationDuration(animationDuration)
|
||||
CollapsibleSection::CollapsibleSection(const QString& title, const bool expanded, const int animationDuration, QWidget* parent)
|
||||
: QWidget(parent), animationDuration(animationDuration), expanded(expanded)
|
||||
{
|
||||
toggleButton = new QToolButton(this);
|
||||
headerLine = new QFrame(this);
|
||||
@@ -32,25 +34,24 @@ CollapsibleSection::CollapsibleSection(const QString& title, const int animation
|
||||
|
||||
toggleButton->setStyleSheet("QToolButton {border: none;}");
|
||||
toggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
toggleButton->setArrowType(Qt::ArrowType::RightArrow);
|
||||
toggleButton->setText(title);
|
||||
toggleButton->setCheckable(true);
|
||||
toggleButton->setChecked(false);
|
||||
updateToggleButton();
|
||||
|
||||
headerLine->setFrameShape(QFrame::HLine);
|
||||
headerLine->setFrameShadow(QFrame::Sunken);
|
||||
headerLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||
|
||||
contentArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
// start out collapsed
|
||||
contentArea->setMaximumHeight(0);
|
||||
contentArea->setMinimumHeight(0);
|
||||
|
||||
// let the entire widget grow and shrink with its content
|
||||
toggleAnimation->addAnimation(new QPropertyAnimation(this, "maximumHeight"));
|
||||
toggleAnimation->addAnimation(new QPropertyAnimation(this, "minimumHeight"));
|
||||
toggleAnimation->addAnimation(new QPropertyAnimation(contentArea, "maximumHeight"));
|
||||
sectionAnimations.insert(new QPropertyAnimation(this, "minimumHeight"));
|
||||
sectionAnimations.insert(new QPropertyAnimation(this, "maximumHeight"));
|
||||
for (const auto &anim : sectionAnimations)
|
||||
toggleAnimation->addAnimation(anim);
|
||||
contentAnimation = new QPropertyAnimation(contentArea, "maximumHeight");
|
||||
toggleAnimation->addAnimation(contentAnimation);
|
||||
|
||||
mainLayout->setVerticalSpacing(0);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -64,22 +65,58 @@ CollapsibleSection::CollapsibleSection(const QString& title, const int animation
|
||||
connect(toggleButton, &QToolButton::toggled, this, &CollapsibleSection::toggle);
|
||||
}
|
||||
|
||||
void CollapsibleSection::toggle(bool expanded)
|
||||
void CollapsibleSection::updateToggleButton()
|
||||
{
|
||||
toggleButton->setArrowType(expanded ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
|
||||
toggleAnimation->setDirection(expanded ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
|
||||
toggleAnimation->start();
|
||||
|
||||
this->isExpanded = expanded;
|
||||
toggleButton->setChecked(this->expanded);
|
||||
toggleButton->setArrowType(this->expanded ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
|
||||
}
|
||||
|
||||
void CollapsibleSection::setContentLayout(QLayout& contentLayout)
|
||||
void CollapsibleSection::toggle(bool expand)
|
||||
{
|
||||
if (toggleAnimation->state() != QAbstractAnimation::Stopped)
|
||||
return;
|
||||
if (this->expanded == expand)
|
||||
return;
|
||||
this->expanded = expand;
|
||||
|
||||
updateToggleButton();
|
||||
|
||||
if (expand) {
|
||||
// Opening animation. Set the contents to their maximum size immediately,
|
||||
// and they will be revealed slowly by the section animation.
|
||||
int contentHeight = getContentHeight();
|
||||
contentArea->setMinimumHeight(contentHeight);
|
||||
contentArea->setMaximumHeight(contentHeight);
|
||||
toggleAnimation->setDirection(QAbstractAnimation::Forward);
|
||||
} else {
|
||||
// Closing animation. Keep the contents at their current size, allowing
|
||||
// them to be hidden slowly by the section animation, then change their size
|
||||
// once the animation is complete so they aren't visible just below the title.
|
||||
auto ctx = new QObject();
|
||||
connect(toggleAnimation, &QAbstractAnimation::finished, ctx, [this, ctx]() {
|
||||
// This is a single-shot connection. Qt6 has built-in support for this kind of thing.
|
||||
contentArea->setMinimumHeight(0);
|
||||
contentArea->setMaximumHeight(0);
|
||||
ctx->deleteLater();
|
||||
});
|
||||
toggleAnimation->setDirection(QAbstractAnimation::Backward);
|
||||
}
|
||||
toggleAnimation->start();
|
||||
}
|
||||
|
||||
void CollapsibleSection::setContentLayout(QLayout* contentLayout)
|
||||
{
|
||||
if (contentArea->layout() == contentLayout)
|
||||
return;
|
||||
delete contentArea->layout();
|
||||
contentArea->setLayout(&contentLayout);
|
||||
contentArea->setLayout(contentLayout);
|
||||
collapsedHeight = sizeHint().height() - contentArea->maximumHeight();
|
||||
|
||||
updateHeights();
|
||||
|
||||
int contentHeight = this->expanded ? getContentHeight() : 0;
|
||||
contentArea->setMinimumHeight(contentHeight);
|
||||
contentArea->setMaximumHeight(contentHeight);
|
||||
|
||||
updateAnimationTargets();
|
||||
}
|
||||
|
||||
void CollapsibleSection::setTitle(QString title)
|
||||
@@ -87,23 +124,20 @@ void CollapsibleSection::setTitle(QString title)
|
||||
toggleButton->setText(std::move(title));
|
||||
}
|
||||
|
||||
void CollapsibleSection::updateHeights()
|
||||
int CollapsibleSection::getContentHeight() const
|
||||
{
|
||||
int contentHeight = contentArea->layout()->sizeHint().height();
|
||||
return contentArea->layout() ? contentArea->layout()->sizeHint().height() : 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < toggleAnimation->animationCount() - 1; ++i)
|
||||
{
|
||||
QPropertyAnimation* SectionAnimation = static_cast<QPropertyAnimation *>(toggleAnimation->animationAt(i));
|
||||
SectionAnimation->setDuration(animationDuration);
|
||||
SectionAnimation->setStartValue(collapsedHeight);
|
||||
SectionAnimation->setEndValue(collapsedHeight + contentHeight);
|
||||
void CollapsibleSection::updateAnimationTargets()
|
||||
{
|
||||
const int contentHeight = getContentHeight();
|
||||
for (auto anim : sectionAnimations) {
|
||||
anim->setDuration(animationDuration);
|
||||
anim->setStartValue(collapsedHeight);
|
||||
anim->setEndValue(collapsedHeight + contentHeight);
|
||||
}
|
||||
|
||||
QPropertyAnimation* contentAnimation = static_cast<QPropertyAnimation *>(toggleAnimation->animationAt(toggleAnimation->animationCount() - 1));
|
||||
contentAnimation->setDuration(animationDuration);
|
||||
contentAnimation->setStartValue(0);
|
||||
contentAnimation->setEndValue(contentHeight);
|
||||
|
||||
toggleAnimation->setDirection(isExpanded ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
|
||||
toggleAnimation->start();
|
||||
}
|
||||
|
||||
@@ -86,11 +86,27 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
// Some config settings are updated as subwindows are destroyed (e.g. their geometry),
|
||||
// so we need to ensure that the configs are saved after this happens.
|
||||
saveGlobalConfigs();
|
||||
|
||||
delete label_MapRulerStatus;
|
||||
delete editor;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::saveGlobalConfigs() {
|
||||
porymapConfig.setMainGeometry(
|
||||
this->saveGeometry(),
|
||||
this->saveState(),
|
||||
this->ui->splitter_map->saveState(),
|
||||
this->ui->splitter_main->saveState(),
|
||||
this->ui->splitter_Metatiles->saveState()
|
||||
);
|
||||
porymapConfig.save();
|
||||
shortcutsConfig.save();
|
||||
}
|
||||
|
||||
void MainWindow::setWindowDisabled(bool disabled) {
|
||||
for (auto action : findChildren<QAction *>())
|
||||
action->setDisabled(disabled);
|
||||
@@ -1739,12 +1755,14 @@ void MainWindow::on_action_Save_Project_triggered() {
|
||||
editor->saveProject();
|
||||
updateWindowTitle();
|
||||
updateMapList();
|
||||
saveGlobalConfigs();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Save_triggered() {
|
||||
editor->save();
|
||||
updateWindowTitle();
|
||||
updateMapList();
|
||||
saveGlobalConfigs();
|
||||
}
|
||||
|
||||
void MainWindow::duplicate() {
|
||||
@@ -3282,24 +3300,9 @@ bool MainWindow::closeProject() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::saveGlobalConfigs() {
|
||||
porymapConfig.setMainGeometry(
|
||||
this->saveGeometry(),
|
||||
this->saveState(),
|
||||
this->ui->splitter_map->saveState(),
|
||||
this->ui->splitter_main->saveState(),
|
||||
this->ui->splitter_Metatiles->saveState()
|
||||
);
|
||||
porymapConfig.save();
|
||||
shortcutsConfig.save();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Exit_triggered() {
|
||||
if (!closeProject())
|
||||
return;
|
||||
|
||||
saveGlobalConfigs();
|
||||
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
@@ -3308,8 +3311,5 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
saveGlobalConfigs();
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <QSet>
|
||||
#include <QStringList>
|
||||
|
||||
// TODO: Make ui->groupBox_HeaderData collapsible
|
||||
|
||||
const QString lineEdit_ErrorStylesheet = "QLineEdit { background-color: rgba(255, 0, 0, 25%) }";
|
||||
|
||||
struct NewMapDialog::Settings NewMapDialog::settings = {};
|
||||
@@ -31,8 +29,15 @@ NewMapDialog::NewMapDialog(QWidget *parent, Project *project) :
|
||||
ui->lineEdit_Name->setValidator(validator);
|
||||
ui->lineEdit_ID->setValidator(validator);
|
||||
|
||||
// Create a collapsible section that has all the map header data.
|
||||
this->headerData = new MapHeaderForm();
|
||||
ui->layout_HeaderData->addWidget(this->headerData);
|
||||
auto sectionLayout = new QVBoxLayout();
|
||||
sectionLayout->addWidget(this->headerData);
|
||||
|
||||
this->headerSection = new CollapsibleSection("Header Data", porymapConfig.newMapHeaderSectionExpanded, 150, this);
|
||||
this->headerSection->setContentLayout(sectionLayout);
|
||||
ui->layout_HeaderData->addWidget(this->headerSection);
|
||||
ui->layout_HeaderData->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::Expanding));
|
||||
|
||||
connect(ui->spinBox_MapWidth, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){validateMapDimensions();});
|
||||
connect(ui->spinBox_MapHeight, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){validateMapDimensions();});
|
||||
@@ -162,6 +167,7 @@ void NewMapDialog::saveSettings() {
|
||||
settings.allowEscaping = this->headerData->ui->checkBox_AllowEscaping->isChecked();
|
||||
settings.floorNumber = this->headerData->ui->spinBox_FloorNumber->value();
|
||||
settings.canFlyTo = ui->checkBox_CanFlyTo->isChecked();
|
||||
porymapConfig.newMapHeaderSectionExpanded = this->headerSection->isExpanded();
|
||||
}
|
||||
|
||||
void NewMapDialog::useLayoutSettings(Layout *layout) {
|
||||
|
||||
Reference in New Issue
Block a user