Commit d4ca530d authored by Adrian Page's avatar Adrian Page

Let each input device have its own paint op.

svn path=/trunk/koffice/; revision=503056
parent 74b8b94d
......@@ -82,7 +82,6 @@ R * Add direct/incremental option to shape tools
? * Disable tools that don't work with group layers when the current layer is
a group layer.
P * implement the checkboxes in the brush op
A * Make each tablet device remember its own paint op setting
Plugins
......
......@@ -44,12 +44,14 @@
KisPaintopBox::KisPaintopBox (KisView * view, QWidget *parent, const char * name)
: super (parent, name),
m_view(view)
m_canvasController(view->getCanvasController())
{
#if KDE_VERSION >= KDE_MAKE_VERSION(3,3,90)
KAcceleratorManager::setNoAccel(this);
#endif
Q_ASSERT(m_canvasController != 0);
setCaption(i18n("Painter's Toolchest"));
m_optionWidget = 0;
m_paintops = new QValueList<KisID>();
......@@ -59,7 +61,7 @@ KisPaintopBox::KisPaintopBox (KisView * view, QWidget *parent, const char * name
m_layout = new QHBoxLayout(this, 1, 1);
m_layout->addWidget(m_cmbPaintops);
connect(this, SIGNAL(selected(const KisID &)), m_view, SLOT(paintopActivated(const KisID &)));
connect(this, SIGNAL(selected(const KisID &)), view, SLOT(paintopActivated(const KisID &)));
connect(m_cmbPaintops, SIGNAL(activated(int)), this, SLOT(slotItemSelected(int)));
// XXX: Let's see... Are all paintops loaded and ready?
......@@ -69,12 +71,12 @@ KisPaintopBox::KisPaintopBox (KisView * view, QWidget *parent, const char * name
addItem(*it);
}
m_currentID = KisID("paintbrush","");
connect(m_view, SIGNAL(currentColorSpaceChanged(KisColorSpace*)),
connect(view, SIGNAL(currentColorSpaceChanged(KisColorSpace*)),
this, SLOT(colorSpaceChanged(KisColorSpace*)));
connect(m_view, SIGNAL(sigInputDeviceChanged(const KisInputDevice&)),
connect(view, SIGNAL(sigInputDeviceChanged(const KisInputDevice&)),
this, SLOT(slotInputDeviceChanged(const KisInputDevice&)));
setCurrentPaintop(defaultPaintop(m_canvasController->currentInputDevice()));
}
KisPaintopBox::~KisPaintopBox()
......@@ -94,10 +96,9 @@ void KisPaintopBox::slotItemSelected(int index)
return;
}
m_currentID = *m_displayedOps->at(index);
updateOptionWidget();
KisID paintop = *m_displayedOps->at(index);
emit selected(m_currentID);
setCurrentPaintop(paintop);
}
void KisPaintopBox::colorSpaceChanged(KisColorSpace *cs)
......@@ -122,7 +123,7 @@ void KisPaintopBox::colorSpaceChanged(KisColorSpace *cs)
}
}
const int index = m_displayedOps->findIndex ( m_currentID );
const int index = m_displayedOps->findIndex(currentPaintop());
m_cmbPaintops->setCurrentItem( index );
slotItemSelected( index );
}
......@@ -140,9 +141,20 @@ QPixmap KisPaintopBox::paintopPixmap(const KisID & paintop)
return QPixmap(fname);
}
void KisPaintopBox::slotInputDeviceChanged(const KisInputDevice & /*inputDevice*/)
void KisPaintopBox::slotInputDeviceChanged(const KisInputDevice & inputDevice)
{
updateOptionWidget();
KisID paintop;
InputDevicePaintopMap::iterator it = m_currentID.find(inputDevice);
if (it == m_currentID.end()) {
paintop = defaultPaintop(inputDevice);
} else {
paintop = (*it).second;
}
const int index = m_displayedOps->findIndex(paintop);
m_cmbPaintops->setCurrentItem(index);
setCurrentPaintop(paintop);
}
void KisPaintopBox::updateOptionWidget()
......@@ -153,11 +165,7 @@ void KisPaintopBox::updateOptionWidget()
m_layout->invalidate();
}
KisCanvasController *canvasController = m_view->getCanvasController();
Q_ASSERT(canvasController != 0);
KisInputDevice inputDevice = canvasController->currentInputDevice();
m_optionWidget = KisPaintOpRegistry::instance()->configWidget( m_currentID, this, inputDevice );
m_optionWidget = KisPaintOpRegistry::instance()->configWidget( currentPaintop(), this, m_canvasController->currentInputDevice() );
if (m_optionWidget != 0) {
m_layout->addWidget(m_optionWidget);
......@@ -166,4 +174,27 @@ void KisPaintopBox::updateOptionWidget()
}
}
const KisID& KisPaintopBox::currentPaintop()
{
return m_currentID[m_canvasController->currentInputDevice()];
}
void KisPaintopBox::setCurrentPaintop(const KisID & paintop)
{
m_currentID[m_canvasController->currentInputDevice()] = paintop;
updateOptionWidget();
emit selected(paintop);
}
KisID KisPaintopBox::defaultPaintop(const KisInputDevice& inputDevice)
{
if (inputDevice == KisInputDevice::eraser()) {
return KisID("eraser","");
} else {
return KisID("paintbrush","");
}
}
#include "kis_paintop_box.moc"
......@@ -21,14 +21,20 @@
#ifndef KIS_PAINTOP_BOX_H_
#define KIS_PAINTOP_BOX_H_
#include <map>
#include <qwidget.h>
#include <qcombobox.h>
#include <qvaluelist.h>
#include "kis_input_device.h"
class QString;
class KWidgetAction;
class KisView;
class KisCanvasController;
class KisID;
class QString;
class KisColorSpace;
/**
......@@ -70,18 +76,21 @@ private slots:
private:
QPixmap paintopPixmap(const KisID & paintop);
void updateOptionWidget();
const KisID & currentPaintop();
void setCurrentPaintop(const KisID & paintop);
KisID defaultPaintop(const KisInputDevice& inputDevice);
private:
KisView * m_view;
KisCanvasController *m_canvasController;
QComboBox * m_cmbPaintops;
QHBoxLayout * m_layout;
QWidget * m_optionWidget;
QValueList<KisID> * m_paintops;
QValueList<KisID> * m_displayedOps;
KisID m_currentID;
typedef std::map<KisInputDevice, KisID> InputDevicePaintopMap;
InputDevicePaintopMap m_currentID;
};
......
......@@ -1017,17 +1017,7 @@ void KisView::setInputDevice(KisInputDevice inputDevice)
m_toolManager->setToolForInputDevice(m_inputDevice, inputDevice);
// XXX: This is incorrect
// On initialisation for an input device, set to eraser if the current input device
// is a wacom eraser, else to brush.
if (m_toolManager->currentTool() == 0) {
if (m_inputDevice == KisInputDevice::eraser()) {
m_paintop = KisID("eraser", "");
// XXX: Set the right entry in the paintop box
} else {
m_paintop = KisID("paintbrush", "");
// XXX: Set the right entry in the paintop box
}
m_toolManager->setCurrentTool(m_toolManager->findTool("tool_brush", m_inputDevice));
}
else {
......
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