Begin new layout dialog redesign

This commit is contained in:
GriffinR
2024-11-19 14:52:47 -05:00
parent 724f42019c
commit bd39bcfdd2
16 changed files with 617 additions and 209 deletions

View File

@@ -0,0 +1,51 @@
#ifndef NEWLAYOUTDIALOG_H
#define NEWLAYOUTDIALOG_H
#include <QDialog>
#include <QString>
#include "editor.h"
#include "project.h"
#include "map.h"
#include "mapheaderform.h"
#include "newlayoutform.h"
#include "lib/collapsiblesection.h"
namespace Ui {
class NewLayoutDialog;
}
class NewLayoutDialog : public QDialog
{
Q_OBJECT
public:
explicit NewLayoutDialog(QWidget *parent = nullptr, Project *project = nullptr);
~NewLayoutDialog();
void init(Layout *);
void accept() override;
signals:
void applied(const QString &newLayoutId);
private:
Ui::NewLayoutDialog *ui;
Project *project;
Layout *importedLayout = nullptr;
Layout::Settings *settings = nullptr;
// Each of these validation functions will allow empty names up until `OK` is selected,
// because clearing the text during editing is common and we don't want to flash errors for this.
bool validateLayoutID(bool allowEmpty = false);
bool validateName(bool allowEmpty = false);
void saveSettings();
bool isExistingLayout() const;
void useLayoutSettings(Layout *mapLayout);
private slots:
//void on_comboBox_Layout_currentTextChanged(const QString &text);//TODO
void dialogButtonClicked(QAbstractButton *button);
void on_lineEdit_Name_textChanged(const QString &);
void on_lineEdit_LayoutID_textChanged(const QString &);
};
#endif // NEWLAYOUTDIALOG_H

View File

@@ -3,6 +3,8 @@
#include <QWidget>
#include "maplayout.h"
class Project;
namespace Ui {
@@ -19,18 +21,8 @@ public:
void initUi(Project *project);
struct Settings {
QString id; // TODO: Support in UI (toggleable line edit)
int width;
int height;
int borderWidth;
int borderHeight;
QString primaryTilesetLabel;
QString secondaryTilesetLabel;
};
void setSettings(const Settings &settings);
NewLayoutForm::Settings settings() const;
void setSettings(const Layout::Settings &settings);
Layout::Settings settings() const;
void setDisabled(bool disabled);

View File

@@ -24,7 +24,6 @@ public:
void init(int tabIndex, QString data);
void init(Layout *);
void accept() override;
static void setDefaultSettings(const Project *project);
signals:
void applied(const QString &newMapName);
@@ -35,27 +34,20 @@ private:
CollapsibleSection *headerSection;
MapHeaderForm *headerForm;
Layout *importedLayout = nullptr;
Project::NewMapSettings *settings = nullptr;
// Each of these validation functions will allow empty names up until `OK` is selected,
// because clearing the text during editing is common and we don't want to flash errors for this.
bool validateID(bool allowEmpty = false);
bool validateMapID(bool allowEmpty = false);
bool validateName(bool allowEmpty = false);
bool validateGroup(bool allowEmpty = false);
void saveSettings();
bool isExistingLayout() const;
void useLayoutSettings(Layout *mapLayout);
struct Settings {
QString group;
bool canFlyTo;
NewLayoutForm::Settings layout;
MapHeader header;
};
static struct Settings settings;
void useLayoutSettings(const Layout *mapLayout);
void useLayoutIdSettings(const QString &layoutId);
private slots:
//void on_comboBox_Layout_currentTextChanged(const QString &text);//TODO
void dialogButtonClicked(QAbstractButton *button);
void on_lineEdit_Name_textChanged(const QString &);
void on_lineEdit_MapID_textChanged(const QString &);