Skip to content

Commit

Permalink
Position new colors at bottom, and renaming immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlamhauge authored and chchwy committed Jul 20, 2020
1 parent 8ca63af commit 1031d5c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/src/colorpalettewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,31 @@ void ColorPaletteWidget::addItem()
QSignalBlocker b(ui->colorListWidget);
QColor newColor = mEditor->color()->frontColor();

// add in front of selected color
int colorIndex = ui->colorListWidget->currentRow()+1;
// add at bottom
int colorIndex = ui->colorListWidget->count();

ColorRef ref(newColor);

mObject->addColorAtIndex(colorIndex, ref);
refreshColorList();

if (mFitSwatches)
{
fitSwatchSize();
}

bool ok;
QString text = QInputDialog::getText(this,
tr("Color name"),
tr("Color name"),
QLineEdit::Normal,
mObject->getColor(colorIndex).name,
&ok);
if (ok && !text.isEmpty())
{
mObject->renameColor(colorIndex, text);
refreshColorList();
}
}

void ColorPaletteWidget::replaceItem()
Expand Down

0 comments on commit 1031d5c

Please sign in to comment.