kdeplasma-addons: change the native widget icon regardless if the color is in the menu history

when picking the same color twice (or more) the icon was not changing to
the currently picked color (as if no pixel was grabbed)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-12 11:30:31 +03:00
parent 1cc12738f4
commit 57d542804f

View file

@ -389,19 +389,19 @@ void Kolourpicker::installFilter()
void Kolourpicker::addColor(const QColor &color, bool save)
{
ColorIcon colorIcon(color);
m_configAndHistory->nativeWidget()->setIcon(colorIcon);
QHash<QColor, QAction *>::ConstIterator it = m_menus.constFind(color);
if (it != m_menus.constEnd()) {
return;
}
KMenu *newmenu = buildMenuForColor(color);
QAction *act = newmenu->menuAction();
ColorIcon colorIcon(color);
act->setIcon(colorIcon);
act->setText(QString("%1, %2, %3").arg(color.red()).arg(color.green()).arg(color.blue()));
connect(newmenu, SIGNAL(triggered(QAction*)), this, SLOT(colorActionTriggered(QAction*)));
m_configAndHistoryMenu->insertMenu(m_configAndHistoryMenu->actions().at(1), newmenu);
m_configAndHistory->nativeWidget()->setIcon(colorIcon);
m_menus.insert(color, act);
m_colors.append(color.name());
m_configAndHistory->setEnabled(true);