I added a clear button to the color history shortcut

I can’t write code, so I made a request here.
First, I cleared the patch code for the clear color history button existing in “kis_color_selector_ng_docker_widget.cpp” and “kis_color_selector_ng_docker_widget.h" and restored it before the clear color history button was added,then I followed ”kis_common_colors.cpp“ and ”kis_common_colors.h“ for ”kis_ color_ history.cpp" and “kis_ color_ history.h” added the clear color history button:

#include <QToolButton>
#include <QColor>
#include <QList>
#include <kis_icon.h>

KisColorHistory::KisColorHistory(QWidget *parent)
    : KisColorPatches("lastUsedColors", parent)
    , m_resourceProvider(0)
{
    m_clearButton = new QToolButton();
    m_clearButton->setIcon(KisIconUtils::loadIcon("dialog-cancel"));
    m_clearButton->setToolTip(i18n("Clear all color history"));
    m_clearButton->setAutoRaise(true);
    connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearColorHistory()));

    QList<QWidget*> tmpList;
    tmpList.append(m_clearButton);
    setAdditionalButtons(tmpList);
}

class QToolButton;

class KisCanvasResourceProvider;

class KisColorHistory : public KisColorPatches
{
    Q_OBJECT
public:
    explicit KisColorHistory(QWidget *parent = 0);
    void setCanvas(KisCanvas2 *canvas) override;
    void unsetCanvas() override;

protected:
    KisColorSelectorBase* createPopup() const override;

public Q_SLOTS:
    void addColorToHistory(const KoColor& color);
    void clearColorHistory();

private:
    QToolButton* m_clearButton;
    QList<KoColor> m_colorHistory;
    KisCanvasResourceProvider  *m_resourceProvider; // to disconnect...
};

Finally, I changed the QPushButton in ”kis_common_colors.cpp“ and ”kis_common_colors.h“ to QToolButton

In this way, the shortcut keys of the color history can also have the clear button, and the layout will not have errors.My English is not good, so these are from the translation software. If there is a problem with the expression, I’m sorry!

2 Likes

Can you submit a Merge request with this?

Sure, but I’m not a programmer. I’ll try

OK, I have submitted it

I would suggest to change the icon to a sweeping brush. It is more intuitive as for me.

2 Likes

OK, thank you for your suggestion, but I have just submitted this merge request, and I haven’t found the icon about sweeping brush yet… I 'm sorry

Sure :slight_smile:
You can add new commits to the request anyways :slight_smile:

OK, I’ll try, but I don’t know the location and name of the icon sweeping brush. Can you tell me? thank you!

Screenshots are OK in krita, and I’ll try to find it

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.