Compact allocating and pushing of commands

This commit is contained in:
G.K.MacGregor
2021-05-02 12:36:37 +01:00
parent 1a7e5aff5f
commit 7a0dbcca2b
3 changed files with 7 additions and 14 deletions

View File

@@ -108,14 +108,11 @@ void PaletteDockWidget::selectColour(int colourIndex)
{
const QColor newColour = QColorDialog::getColor(m_parentMainWidget->document()->currentSubPage()->CLUTtoQColor(colourIndex), this, "Select Colour");
if (newColour.isValid()) {
QUndoCommand *setColourCommand = new SetColourCommand(m_parentMainWidget->document(), colourIndex, ((newColour.red() & 0xf0) << 4) | (newColour.green() & 0xf0) | ((newColour.blue() & 0xf0) >> 4));
m_parentMainWidget->document()->undoStack()->push(setColourCommand);
}
if (newColour.isValid())
m_parentMainWidget->document()->undoStack()->push(new SetColourCommand(m_parentMainWidget->document(), colourIndex, ((newColour.red() & 0xf0) << 4) | (newColour.green() & 0xf0) | ((newColour.blue() & 0xf0) >> 4)));
}
void PaletteDockWidget::resetCLUT(int colourTable)
{
QUndoCommand *resetCLUTCommand = new ResetCLUTCommand(m_parentMainWidget->document(), colourTable);
m_parentMainWidget->document()->undoStack()->push(resetCLUTCommand);
m_parentMainWidget->document()->undoStack()->push(new ResetCLUTCommand(m_parentMainWidget->document(), colourTable));
}