Skip to content

Commit

Permalink
revert name lineedit
Browse files Browse the repository at this point in the history
  • Loading branch information
DSCaskey committed Apr 20, 2024
1 parent 36f0f69 commit 6ddbac9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
47 changes: 44 additions & 3 deletions src/libs/tools/image_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ImageDialog::ImageDialog(DraftImage image, qreal minDimension, qreal maxDimensio

updateImage();

connect(ui->name_LineEdit, &QLineEdit::textChanged, this, &ImageDialog::nameChanged);
connect(ui->xPosition_DoubleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &ImageDialog::xPosChanged);
connect(ui->yPosition_DoubleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
Expand Down Expand Up @@ -125,7 +126,7 @@ void ImageDialog::updateImage()
{
blockSignals(true);
ui->idText_Label->setNum(static_cast<double>(m_image.id));
ui->filename_Label->setText(m_image.name);
ui->name_LineEdit->setText(m_image.name);
ui->lockImage_ToolButton->setChecked(m_image.locked);
setXPos(m_image.xPos);
setYPos(m_image.yPos);
Expand Down Expand Up @@ -159,7 +160,7 @@ void ImageDialog::enableWidgets()
{
ui->lockImage_ToolButton->setEnabled(true);
ui->idText_Label->setEnabled(!m_image.locked);
ui->filename_Label->setEnabled(!m_image.locked);
ui->name_LineEdit->setEnabled(!m_image.locked);
ui->xPosition_DoubleSpinBox->setEnabled(!m_image.locked);
ui->yPosition_DoubleSpinBox->setEnabled(!m_image.locked);
ui->width_DoubleSpinBox->setEnabled(!m_image.locked);
Expand All @@ -181,7 +182,7 @@ QString ImageDialog::getName() const
void ImageDialog::setName(const QString &name)
{
m_image.name = name;
ui->filename_Label->setText(name);
ui->name_LineEdit->setText(name);
}

//---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -390,6 +391,46 @@ void ImageDialog::setOpacity(const qreal &opacity)
ui->opacity_DoubleSpinBox->blockSignals(false);
}


//---------------------------------------------------------------------------------------------------------------------
void ImageDialog::nameChanged(const QString &name)
{
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr)
bOk->setEnabled(true);

QPalette palette = ui->name_LineEdit->palette();
palette.setColor(ui->name_Label->foregroundRole(), Qt::black);
//alette.setColor(ui->name_LineEdit->foregroundRole(), Qt::black);

if (name.isEmpty())
{
bOk->setEnabled(false);
palette.setColor(ui->name_Label->foregroundRole(), Qt::red);
//palette.setColor(ui->name_LineEdit->foregroundRole(), Qt::red);
}
else
{
if (m_image.name != name)
{
QRegularExpression rx(NameRegExp());
//if (!rx.match(name).hasMatch() || !VContainer::IsUnique(name))
if (!VContainer::IsUnique(name))
{
bOk->setEnabled(false);
palette.setColor(ui->name_Label->foregroundRole(), Qt::red);
//palette.setColor(ui->name_LineEdit->foregroundRole(), Qt::red);
}
else
{
setName(name);
}
}
}
ui->name_Label->setPalette(palette);
//ui->name_LineEdit->setPalette(palette);
}

//---------------------------------------------------------------------------------------------------------------------
void ImageDialog::originChanged(const QString &text)
{
Expand Down
3 changes: 2 additions & 1 deletion src/libs/tools/image_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ImageDialog : public QDialog
QString getName() const;
void setName(const QString &name);

Position getOriginPoint() const;
Position getOriginPoint() const;
void setOriginPoint(const int &index);

qreal getXPos() const;
Expand Down Expand Up @@ -98,6 +98,7 @@ class ImageDialog : public QDialog
void setOpacity(const qreal &opacity);

private slots:
void nameChanged(const QString &name);
void originChanged(const QString &text);
void lockChanged(bool checked);
void alignmentChanged();
Expand Down
5 changes: 1 addition & 4 deletions src/libs/tools/image_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,12 @@ QToolButton:!checked {
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="filename_Label">
<widget class="QLineEdit" name="name_LineEdit">
<property name="font">
<font>
<bold>false</bold>
</font>
</property>
<property name="text">
<string notr="true">filename</string>
</property>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 6ddbac9

Please sign in to comment.