From fcdfb0b300c0354624f2d7ba4d38de7490898399 Mon Sep 17 00:00:00 2001 From: Michel Mastriani Date: Tue, 21 May 2019 19:15:45 -0300 Subject: [PATCH] Removed duplicated code --- Source/Fractorium/FractoriumPalette.cpp | 50 ++++++------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/Source/Fractorium/FractoriumPalette.cpp b/Source/Fractorium/FractoriumPalette.cpp index 7f4fda2..2979d95 100644 --- a/Source/Fractorium/FractoriumPalette.cpp +++ b/Source/Fractorium/FractoriumPalette.cpp @@ -383,53 +383,25 @@ template void FractoriumEmberController::PaletteEditorButtonClicked() { size_t i = 0; - auto ed = m_Fractorium->m_PaletteEditor; - Palette edPal; - Palette prevPal = m_TempPalette; + auto ed = m_Fractorium->m_PaletteEditor; map colorIndices; - bool forceFinal = m_Fractorium->HaveFinal(); - ed->SetPalette(m_TempPalette); + bool forceFinal = m_Fractorium->HaveFinal(); + + m_PreviosTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor + + ed->SetPalette(m_TempPalette); while (auto xform = m_Ember.GetTotalXform(i, forceFinal)) colorIndices[i++] = xform->m_ColorX; ed->SetColorIndices(colorIndices); + ed->SetPreviousColorIndices(colorIndices); // also necessary because the colors are changed in palette editor ed->SetPaletteFile(m_CurrentPaletteFilePath); -#ifdef __linux__ - m_PreviosTempPalette = m_TempPalette; - ed->SetPreviousColorIndices(colorIndices); +#ifndef __linux__ ed->show(); -#else - - //ed->setpal - if (ed->exec() == QDialog::Accepted) - { - //Copy all just to be safe, because they may or may not have synced. - colorIndices = ed->GetColorIndices(); - - for (auto& index : colorIndices) - if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal)) - xform->m_ColorX = index.second; - - edPal = ed->GetPalette(int(prevPal.Size())); - SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls. - - if (edPal.m_Filename.get() && !edPal.m_Filename->empty()) - m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename); - } - else if (m_Fractorium->PaletteChanged())//They clicked cancel, but synced at least once, restore the previous palette. - { - for (auto& index : colorIndices) - if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal)) - xform->m_ColorX = index.second; - - SetBasePaletteAndAdjust(prevPal);//This will take care of updating the color index controls. - } - - //Whether the current palette file was changed or not, if it's modifiable then reload it just to be safe (even though it might be overkill). - if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath)) - m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath)); +#else + SyncPalette(ed->exec() == QDialog::Accepted); #endif } @@ -455,7 +427,7 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked) connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection); connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection); connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection); -#ifdef __linux__ +#ifndef __linux__ connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection); #endif }