Add linking buttons to grid settings
This commit is contained in:
parent
274d95eef5
commit
a277e19334
6 changed files with 147 additions and 43 deletions
|
@ -86,30 +86,60 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Dimensions (in pixels)</string>
|
<string>Dimensions (in pixels)</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,1,5">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" rowspan="2">
|
||||||
<widget class="QLabel" name="label_Width">
|
<widget class="QToolButton" name="button_LinkDimensions">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Width</string>
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/link_broken.ico</normaloff>
|
||||||
|
<normalon>:/icons/link.ico</normalon>:/icons/link_broken.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="label_Height">
|
<widget class="NoScrollSpinBox" name="spinBox_Height">
|
||||||
<property name="text">
|
|
||||||
<string>Height</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Width">
|
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Height">
|
<widget class="QLabel" name="label_Height">
|
||||||
|
<property name="text">
|
||||||
|
<string>Height</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_Width">
|
||||||
|
<property name="text">
|
||||||
|
<string>Width</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_Width">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -123,26 +153,56 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Offset (in pixels)</string>
|
<string>Offset (in pixels)</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,1,5">
|
||||||
<item row="0" column="0">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="label_X">
|
|
||||||
<property name="text">
|
|
||||||
<string>X</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_Y">
|
<widget class="QLabel" name="label_Y">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Y</string>
|
<string>Y</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_X">
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_Y"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_X"/>
|
<widget class="NoScrollSpinBox" name="spinBox_X"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="0" rowspan="2">
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Y"/>
|
<widget class="QToolButton" name="button_LinkOffsets">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/link_broken.ico</normaloff>
|
||||||
|
<normalon>:/icons/link.ico</normalon>:/icons/link_broken.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -188,6 +248,8 @@
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../resources/images.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -24,8 +24,14 @@ private:
|
||||||
Ui::GridSettingsDialog *ui;
|
Ui::GridSettingsDialog *ui;
|
||||||
GridSettings *settings;
|
GridSettings *settings;
|
||||||
GridSettings originalSettings;
|
GridSettings originalSettings;
|
||||||
|
bool dimensionsLinked = true;
|
||||||
|
bool offsetsLinked = true;
|
||||||
|
|
||||||
void reset(bool force = false);
|
void reset(bool force = false);
|
||||||
|
void setWidth(int value);
|
||||||
|
void setHeight(int value);
|
||||||
|
void setOffsetX(int value);
|
||||||
|
void setOffsetY(int value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void dialogButtonClicked(QAbstractButton *button);
|
void dialogButtonClicked(QAbstractButton *button);
|
||||||
|
|
BIN
resources/icons/link.ico
Executable file
BIN
resources/icons/link.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/icons/link_broken.ico
Executable file
BIN
resources/icons/link_broken.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -17,6 +17,8 @@
|
||||||
<file>icons/folder_map.ico</file>
|
<file>icons/folder_map.ico</file>
|
||||||
<file>icons/folder.ico</file>
|
<file>icons/folder.ico</file>
|
||||||
<file>icons/help.ico</file>
|
<file>icons/help.ico</file>
|
||||||
|
<file>icons/link_broken.ico</file>
|
||||||
|
<file>icons/link.ico</file>
|
||||||
<file>icons/map_edited.ico</file>
|
<file>icons/map_edited.ico</file>
|
||||||
<file>icons/map_opened.ico</file>
|
<file>icons/map_opened.ico</file>
|
||||||
<file>icons/map.ico</file>
|
<file>icons/map.ico</file>
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "ui_gridsettingsdialog.h"
|
#include "ui_gridsettingsdialog.h"
|
||||||
#include "gridsettingsdialog.h"
|
#include "gridsettingsdialog.h"
|
||||||
|
|
||||||
// TODO: Add linking chain button to width/height
|
|
||||||
// TODO: Add "snap to metatile" check box?
|
|
||||||
// TODO: Save settings in config
|
// TODO: Save settings in config
|
||||||
// TODO: Look into custom painting to improve performance
|
// TODO: Look into custom painting to improve performance
|
||||||
// TODO: Add tooltips
|
// TODO: Add tooltips
|
||||||
|
@ -31,6 +29,9 @@ GridSettingsDialog::GridSettingsDialog(GridSettings *settings, QWidget *parent)
|
||||||
ui->spinBox_X->setMaximum(INT_MAX);
|
ui->spinBox_X->setMaximum(INT_MAX);
|
||||||
ui->spinBox_Y->setMaximum(INT_MAX);
|
ui->spinBox_Y->setMaximum(INT_MAX);
|
||||||
|
|
||||||
|
ui->button_LinkDimensions->setChecked(this->dimensionsLinked);
|
||||||
|
ui->button_LinkOffsets->setChecked(this->offsetsLinked);
|
||||||
|
|
||||||
// Initialize the settings
|
// Initialize the settings
|
||||||
if (!this->settings)
|
if (!this->settings)
|
||||||
this->settings = new GridSettings; // TODO: Don't leak this
|
this->settings = new GridSettings; // TODO: Don't leak this
|
||||||
|
@ -38,6 +39,8 @@ GridSettingsDialog::GridSettingsDialog(GridSettings *settings, QWidget *parent)
|
||||||
reset(true);
|
reset(true);
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &GridSettingsDialog::dialogButtonClicked);
|
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &GridSettingsDialog::dialogButtonClicked);
|
||||||
|
connect(ui->button_LinkDimensions, &QAbstractButton::toggled, [this](bool on) { this->dimensionsLinked = on; });
|
||||||
|
connect(ui->button_LinkOffsets, &QAbstractButton::toggled, [this](bool on) { this->offsetsLinked = on; });
|
||||||
connect(ui->colorInput, &ColorInputWidget::colorChanged, this, &GridSettingsDialog::onColorChanged);
|
connect(ui->colorInput, &ColorInputWidget::colorChanged, this, &GridSettingsDialog::onColorChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,20 +53,15 @@ void GridSettingsDialog::reset(bool force) {
|
||||||
return;
|
return;
|
||||||
*this->settings = this->originalSettings;
|
*this->settings = this->originalSettings;
|
||||||
|
|
||||||
// Avoid sending changedGridSettings multiple times
|
setWidth(this->settings->width);
|
||||||
const QSignalBlocker b_Width(ui->spinBox_Width);
|
setHeight(this->settings->height);
|
||||||
const QSignalBlocker b_Height(ui->spinBox_Height);
|
setOffsetX(this->settings->offsetX);
|
||||||
const QSignalBlocker b_X(ui->spinBox_X);
|
setOffsetY(this->settings->offsetY);
|
||||||
const QSignalBlocker b_Y(ui->spinBox_Y);
|
|
||||||
const QSignalBlocker b_Style(ui->comboBox_Style);
|
|
||||||
const QSignalBlocker b_Color(ui->colorInput);
|
|
||||||
|
|
||||||
ui->spinBox_Width->setValue(this->settings->width);
|
const QSignalBlocker b_Color(ui->colorInput);
|
||||||
ui->spinBox_Height->setValue(this->settings->height);
|
|
||||||
ui->spinBox_X->setValue(this->settings->offsetX);
|
|
||||||
ui->spinBox_Y->setValue(this->settings->offsetY);
|
|
||||||
ui->colorInput->setColor(this->settings->color.rgb());
|
ui->colorInput->setColor(this->settings->color.rgb());
|
||||||
|
|
||||||
|
const QSignalBlocker b_Style(ui->comboBox_Style);
|
||||||
// TODO: Debug
|
// TODO: Debug
|
||||||
//ui->comboBox_Style->setCurrentIndex(ui->comboBox_Style->findData(static_cast<int>(this->settings->style)));
|
//ui->comboBox_Style->setCurrentIndex(ui->comboBox_Style->findData(static_cast<int>(this->settings->style)));
|
||||||
for (const auto &pair : penStyleMap) {
|
for (const auto &pair : penStyleMap) {
|
||||||
|
@ -76,23 +74,59 @@ void GridSettingsDialog::reset(bool force) {
|
||||||
emit changedGridSettings();
|
emit changedGridSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridSettingsDialog::on_spinBox_Width_valueChanged(int value) {
|
void GridSettingsDialog::setWidth(int value) {
|
||||||
|
const QSignalBlocker b(ui->spinBox_Width);
|
||||||
|
ui->spinBox_Width->setValue(value);
|
||||||
this->settings->width = value;
|
this->settings->width = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridSettingsDialog::setHeight(int value) {
|
||||||
|
const QSignalBlocker b(ui->spinBox_Height);
|
||||||
|
ui->spinBox_Height->setValue(value);
|
||||||
|
this->settings->height = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridSettingsDialog::setOffsetX(int value) {
|
||||||
|
const QSignalBlocker b(ui->spinBox_X);
|
||||||
|
ui->spinBox_X->setValue(value);
|
||||||
|
this->settings->offsetX = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridSettingsDialog::setOffsetY(int value) {
|
||||||
|
const QSignalBlocker b(ui->spinBox_Y);
|
||||||
|
ui->spinBox_Y->setValue(value);
|
||||||
|
this->settings->offsetY = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridSettingsDialog::on_spinBox_Width_valueChanged(int value) {
|
||||||
|
setWidth(value);
|
||||||
|
if (this->dimensionsLinked)
|
||||||
|
setHeight(value);
|
||||||
|
|
||||||
emit changedGridSettings();
|
emit changedGridSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridSettingsDialog::on_spinBox_Height_valueChanged(int value) {
|
void GridSettingsDialog::on_spinBox_Height_valueChanged(int value) {
|
||||||
this->settings->height = value;
|
setHeight(value);
|
||||||
|
if (this->dimensionsLinked)
|
||||||
|
setWidth(value);
|
||||||
|
|
||||||
emit changedGridSettings();
|
emit changedGridSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridSettingsDialog::on_spinBox_X_valueChanged(int value) {
|
void GridSettingsDialog::on_spinBox_X_valueChanged(int value) {
|
||||||
this->settings->offsetX = value;
|
setOffsetX(value);
|
||||||
|
if (this->offsetsLinked)
|
||||||
|
setOffsetY(value);
|
||||||
|
|
||||||
emit changedGridSettings();
|
emit changedGridSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridSettingsDialog::on_spinBox_Y_valueChanged(int value) {
|
void GridSettingsDialog::on_spinBox_Y_valueChanged(int value) {
|
||||||
this->settings->offsetY = value;
|
setOffsetY(value);
|
||||||
|
if (this->offsetsLinked)
|
||||||
|
setOffsetX(value);
|
||||||
|
|
||||||
emit changedGridSettings();
|
emit changedGridSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue