Commit 21a3682c authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG:374957 Fix confusion when saving per-stylus presets between sessions

parent f6926db4
......@@ -130,7 +130,6 @@ KoInputDevice KoInputDevice::eraser()
QDebug operator<<(QDebug dbg, const KoInputDevice &device)
{
#ifndef NDEBUG
if (device.isMouse())
dbg.nospace() << "mouse";
else {
......@@ -173,8 +172,5 @@ QDebug operator<<(QDebug dbg, const KoInputDevice &device)
}
dbg.space() << "(id: " << device.uniqueTabletId() << ")";
}
#else
Q_UNUSED(device);
#endif
return dbg.space();
}
......@@ -511,6 +511,7 @@ KisPaintopBox::~KisPaintopBox()
QMapIterator<TabletToolID, TabletToolData> iter(m_tabletToolMap);
while (iter.hasNext()) {
iter.next();
//qDebug() << "Writing last used preset for" << iter.key().pointer << iter.key().uniqueID << iter.value().preset->name();
if ((iter.key().pointer) == QTabletEvent::Eraser) {
cfg.writeEntry(QString("LastEraser_%1").arg(iter.key().uniqueID) , iter.value().preset->name());
}
......@@ -531,6 +532,7 @@ KisPaintopBox::~KisPaintopBox()
void KisPaintopBox::restoreResource(KoResource* resource)
{
KisPaintOpPreset* preset = dynamic_cast<KisPaintOpPreset*>(resource);
//qDebug() << "restoreResource" << resource << preset;
if (preset) {
setCurrentPaintop(preset);
......@@ -559,7 +561,7 @@ void KisPaintopBox::resourceSelected(KoResource* resource)
warnKrita << "failed to load the preset.";
}
}
//qDebug() << "resourceSelected" << resource->name();
setCurrentPaintop(preset);
m_presetsPopup->setPresetImage(preset->image());
......@@ -571,11 +573,15 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop)
{
KisPaintOpPresetSP preset = activePreset(paintop);
Q_ASSERT(preset && preset->settings());
//qDebug() << "setCurrentPaintop();" << paintop << preset;
setCurrentPaintop(preset);
}
void KisPaintopBox::setCurrentPaintop(KisPaintOpPresetSP preset)
{
//qDebug() << "setCurrentPaintop(); " << preset->name();
if (preset == m_resourceProvider->currentPreset()) {
return;
}
......@@ -591,9 +597,6 @@ void KisPaintopBox::setCurrentPaintop(KisPaintOpPresetSP preset)
m_optionWidget->hide();
}
m_paintOpPresetMap[m_resourceProvider->currentPreset()->paintOp()] = m_resourceProvider->currentPreset();
m_tabletToolMap[m_currTabletToolID].preset = m_resourceProvider->currentPreset();
m_tabletToolMap[m_currTabletToolID].paintOpID = m_resourceProvider->currentPreset()->paintOp();
}
if (!m_paintopOptionWidgets.contains(paintop))
......@@ -626,6 +629,12 @@ void KisPaintopBox::setCurrentPaintop(KisPaintOpPresetSP preset)
m_brushEditorPopupButton->setIcon(QIcon(pixFilename));
m_presetsPopup->setCurrentPaintOp(paintop.id());
////qDebug() << "\tsetting the new preset for" << m_currTabletToolID.uniqueID << "to" << preset->name();
m_paintOpPresetMap[m_resourceProvider->currentPreset()->paintOp()] = preset;
m_tabletToolMap[m_currTabletToolID].preset = preset;
m_tabletToolMap[m_currTabletToolID].paintOpID = preset->paintOp();
if (m_presetsPopup->currentPaintOp() != paintop.id()) {
// Must change the paintop as the current one is not supported
// by the new colorspace.
......@@ -735,6 +744,7 @@ void KisPaintopBox::slotSetPaintop(const QString& paintOpId)
{
if (KisPaintOpRegistry::instance()->get(paintOpId) != 0) {
KoID id(paintOpId, KisPaintOpRegistry::instance()->get(paintOpId)->name());
//qDebug() << "slotsetpaintop" << id;
setCurrentPaintop(id);
}
}
......@@ -743,6 +753,8 @@ void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice)
{
TabletToolMap::iterator toolData = m_tabletToolMap.find(inputDevice);
//qDebug() << "slotInputDeviceChanged()" << inputDevice.device() << inputDevice.uniqueTabletId();
if (toolData == m_tabletToolMap.end()) {
KisConfig cfg;
KisPaintOpPresetResourceServer *rserver = KisResourceServerProvider::instance()->paintOpPresetServer(false);
......@@ -752,19 +764,26 @@ void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice)
}
else {
preset = rserver->resourceByName(cfg.readEntry<QString>(QString("LastPreset_%1").arg(inputDevice.uniqueTabletId()), "Basic_tip_default"));
//if (preset)
//qDebug() << "found stored preset " << preset->name() << "for" << inputDevice.uniqueTabletId();
//else
//qDebug() << "no preset fcound for" << inputDevice.uniqueTabletId();
}
if (!preset) {
preset = rserver->resourceByName("Basic_tip_default");
}
if (preset) {
//qDebug() << "inputdevicechanged 1" << preset;
setCurrentPaintop(preset);
}
}
else {
if (toolData->preset) {
//qDebug() << "inputdevicechanged 2" << toolData->preset;
setCurrentPaintop(toolData->preset);
}
else {
//qDebug() << "inputdevicechanged 3" << toolData->paintOpID;
setCurrentPaintop(toolData->paintOpID);
}
}
......@@ -1112,6 +1131,7 @@ void KisPaintopBox::slotNextFavoritePreset()
void KisPaintopBox::slotSwitchToPreviousPreset()
{
if (m_resourceProvider->previousPreset()) {
//qDebug() << "slotSwitchToPreviousPreset();" << m_resourceProvider->previousPreset();
setCurrentPaintop(m_resourceProvider->previousPreset());
}
}
......
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