Commit 441a6fa5 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use the highlight color for the selected tool

BUG:360895

This also 'fixes' the setting of the highlight color in
the toolbar, we should be taking the app's palette, not the
one set on the current widget.
parent 101185c2
......@@ -30,6 +30,7 @@
#include <QToolButton>
#include <QPixmap>
#include <QWidgetAction>
#include <QApplication>
#include <kis_debug.h>
......@@ -1064,7 +1065,7 @@ void KisPaintopBox::slotToggleAlphaLockMode(bool checked)
void KisPaintopBox::toggleHighlightedButton(QToolButton* m_tool)
{
QPalette p = palette();
QPalette p = qApp->palette();
if (m_tool->isChecked()) {
QPalette palette_highlight(p);
palette_highlight.setColor(QPalette::Button, p.color(QPalette::Highlight));
......
......@@ -166,9 +166,11 @@ void KoToolBox::addButton(KoToolAction *toolAction)
void KoToolBox::setActiveTool(KoCanvasController *canvas, int id)
{
Q_UNUSED(canvas);
QAbstractButton *button = d->buttonGroup->button(id);
if (button) {
button->setChecked(true);
(qobject_cast<KoToolBoxButton*>(button))->setHighlightColor();
}
else {
warnWidgets << "KoToolBox::setActiveTool(" << id << "): no such button found";
......
......@@ -21,6 +21,8 @@
#include <KoToolManager.h>
#include <QIcon>
#include <QPalette>
#include <QApplication>
#include <klocalizedstring.h>
#include <QKeySequence>
#include <KoIcon.h>
......@@ -41,6 +43,19 @@ KoToolBoxButton::KoToolBoxButton(KoToolAction *toolAction, QWidget *parent)
connect(m_toolAction, SIGNAL(changed()), SLOT(setDataFromToolAction()));
}
void KoToolBoxButton::setHighlightColor()
{
QPalette p = qApp->palette();
if (isChecked()) {
QPalette palette_highlight(p);
QColor c = p.color(QPalette::Highlight);
palette_highlight.setColor(QPalette::Button, c);
setPalette(palette_highlight);
}
else {
setPalette(p);
}
}
void KoToolBoxButton::setDataFromToolAction()
{
......
......@@ -29,6 +29,7 @@ class KoToolBoxButton : public QToolButton
Q_OBJECT
public:
explicit KoToolBoxButton(KoToolAction *toolAction, QWidget * parent);
void setHighlightColor();
private Q_SLOTS:
void setDataFromToolAction();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment