Commit 4ae83a2e authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make the eraser end eraser by default

And try really hard to remember the last used preset for all input
devices.
parent b80cfdd9
......@@ -89,7 +89,7 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
, m_brushChooser(0)
, m_viewManager(view)
, m_previousNode(0)
, m_currTabletToolID(KoToolManager::instance()->currentInputDevice())
, m_currTabletToolID(KoInputDevice::invalid())
, m_presetsEnabled(true)
, m_blockUpdate(false)
, m_dirtyPresetsEnabled(false)
......@@ -357,10 +357,22 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
connect(view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(slotUpdateSelectionIcon()));
slotInputDeviceChanged(KoToolManager::instance()->currentInputDevice());
}
KisPaintopBox::~KisPaintopBox()
{
KisConfig cfg;
QMapIterator<TabletToolID, TabletToolData> iter(m_tabletToolMap);
while (iter.hasNext()) {
iter.next();
if ((iter.key().pointer) == QTabletEvent::Eraser) {
cfg.writeEntry(QString("LastEraser_%1").arg(iter.key().uniqueID) , iter.value().preset->name());
}
else {
cfg.writeEntry(QString("LastPreset_%1").arg(iter.key().uniqueID) , iter.value().preset->name());
}
}
// Do not delete the widget, since it it is global to the application, not owned by the view
m_presetsPopup->setPaintOpSettingsWidget(0);
qDeleteAll(m_paintopOptionWidgets);
......@@ -591,13 +603,21 @@ void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice)
TabletToolMap::iterator toolData = m_tabletToolMap.find(inputDevice);
if (toolData == m_tabletToolMap.end()) {
if (m_resourceProvider->currentPreset()) {
KisPaintOpPresetSP preset =
m_resourceProvider->currentPreset()->clone();
m_resourceProvider->setPaintOpPreset(preset);
setCurrentPaintop(preset->paintOp(), preset);
KisConfig cfg;
KisPaintOpPresetResourceServer *rserver = KisResourceServerProvider::instance()->paintOpPresetServer();
KisPaintOpPresetSP preset;
if (inputDevice.pointer() == QTabletEvent::Eraser) {
preset = rserver->resourceByName(cfg.readEntry<QString>(QString("LastEraser_%1").arg(inputDevice.uniqueTabletId()), "Eraser_circle"));
}
} else {
else {
preset = rserver->resourceByName(cfg.readEntry<QString>(QString("LastPreset_%1").arg(inputDevice.uniqueTabletId()), "Basic_tip_default"));
}
if (!preset) {
preset = rserver->resourceByName("Basic_tip_default");
}
setCurrentPaintop(preset->paintOp(), preset);
}
else {
setCurrentPaintop(toolData->paintOpID, toolData->preset);
}
......
......@@ -199,7 +199,11 @@ private:
struct TabletToolID {
TabletToolID(const KoInputDevice& dev) {
uniqueID = dev.uniqueTabletId();
pointer = (dev.pointer() == QTabletEvent::UnknownPointer) ? QTabletEvent::Cursor : dev.pointer();
// Only the eraser is special, and we don't look at Cursor
pointer = QTabletEvent::Pen;
if (dev.pointer() == QTabletEvent::Eraser) {
pointer = QTabletEvent::Eraser;
}
}
bool operator == (const TabletToolID& id) const {
......
......@@ -100,6 +100,14 @@ KoInputDevice & KoInputDevice::operator=(const KoInputDevice & other)
}
// static
KoInputDevice KoInputDevice::invalid()
{
KoInputDevice id(QTabletEvent::NoDevice, QTabletEvent::UnknownPointer);
return id;
}
KoInputDevice KoInputDevice::mouse()
{
KoInputDevice id;
......
......@@ -82,6 +82,7 @@ public:
/// assignment
KoInputDevice & operator=(const KoInputDevice &);
static KoInputDevice invalid(); ///< invalid input device
static KoInputDevice mouse(); ///< Standard mouse
static KoInputDevice stylus(); ///< Wacom style/pen
static KoInputDevice eraser(); ///< Wacom eraser
......
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