Commit 125aa2ac authored by Silvio Heinrich's avatar Silvio Heinrich

Made sure the composite op ComboBox gets properly initialized.

Also improved the process of association presets with
a tablet device tool ID
parent c2ec9596
...@@ -257,9 +257,9 @@ QPixmap KisPaintopBox::paintopPixmap(const KoID& paintop) ...@@ -257,9 +257,9 @@ QPixmap KisPaintopBox::paintopPixmap(const KoID& paintop)
return QPixmap(KisFactory2::componentData().dirs()->findResource("kis_images", pixmapName)); return QPixmap(KisFactory2::componentData().dirs()->findResource("kis_images", pixmapName));
} }
const KoID& KisPaintopBox::currentPaintop() KoID KisPaintopBox::currentPaintop()
{ {
return m_currPaintOp; return m_activePreset->paintOp();
} }
void KisPaintopBox::slotSetPaintop(const QString& paintOpId) void KisPaintopBox::slotSetPaintop(const QString& paintOpId)
...@@ -272,16 +272,17 @@ void KisPaintopBox::slotSetPaintop(const QString& paintOpId) ...@@ -272,16 +272,17 @@ void KisPaintopBox::slotSetPaintop(const QString& paintOpId)
void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice) void KisPaintopBox::slotInputDeviceChanged(const KoInputDevice& inputDevice)
{ {
m_tabletToolMap[m_currTabletToolID].paintOpID = m_currPaintOp; m_tabletToolMap[m_currTabletToolID].paintOpID = currentPaintop();
m_tabletToolMap[m_currTabletToolID].preset = m_activePreset; m_tabletToolMap[m_currTabletToolID].preset = m_activePreset;
m_currTabletToolID = TabletToolID(inputDevice);
TabletToolMap::iterator toolData = m_tabletToolMap.find(inputDevice); TabletToolMap::iterator toolData = m_tabletToolMap.find(inputDevice);
if(toolData == m_tabletToolMap.end()) if(toolData == m_tabletToolMap.end())
setCurrentPaintop(m_currPaintOp); setCurrentPaintop(currentPaintop());
else else
setCurrentPaintop(toolData->paintOpID, toolData->preset); setCurrentPaintop(toolData->paintOpID, toolData->preset);
m_currTabletToolID = TabletToolID(inputDevice);
} }
void KisPaintopBox::slotCurrentNodeChanged(KisNodeSP node) void KisPaintopBox::slotCurrentNodeChanged(KisNodeSP node)
...@@ -294,10 +295,16 @@ void KisPaintopBox::slotCurrentNodeChanged(KisNodeSP node) ...@@ -294,10 +295,16 @@ void KisPaintopBox::slotCurrentNodeChanged(KisNodeSP node)
void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset) void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset)
{ {
if (m_activePreset && m_optionWidget) { if(m_activePreset) {
m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_activePreset->settings().data())); if(m_optionWidget) {
m_optionWidget->disconnect(this); m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_activePreset->settings().data()));
m_optionWidget->hide(); m_optionWidget->disconnect(this);
m_optionWidget->hide();
}
m_paintOpPresetMap[m_activePreset->paintOp()] = m_activePreset->clone();
m_tabletToolMap[m_currTabletToolID].preset = m_activePreset->clone();
m_tabletToolMap[m_currTabletToolID].paintOpID = m_activePreset->paintOp();
} }
preset = (!preset) ? activePreset(paintop) : preset; preset = (!preset) ? activePreset(paintop) : preset;
...@@ -334,12 +341,7 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP pr ...@@ -334,12 +341,7 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP pr
kWarning() << "current paintop " << paintop.name() << " was not set, not supported by colorspace"; kWarning() << "current paintop " << paintop.name() << " was not set, not supported by colorspace";
} }
m_activePreset = preset; m_activePreset = preset;
m_paintOpPresetMap[paintop] = preset->clone();
m_tabletToolMap[m_currTabletToolID].preset = preset->clone();
m_tabletToolMap[m_currTabletToolID].paintOpID = paintop;
m_currPaintOp = paintop;
emit signalPaintopChanged(preset); emit signalPaintopChanged(preset);
} }
...@@ -467,26 +469,23 @@ void KisPaintopBox::updateCompositeOp(QString compositeOpID) ...@@ -467,26 +469,23 @@ void KisPaintopBox::updateCompositeOp(QString compositeOpID)
if(!node->paintDevice()->colorSpace()->hasCompositeOp(compositeOpID)) if(!node->paintDevice()->colorSpace()->hasCompositeOp(compositeOpID))
compositeOpID = KoCompositeOpRegistry::instance().getDefaultCompositeOp().id(); compositeOpID = KoCompositeOpRegistry::instance().getDefaultCompositeOp().id();
if(compositeOpID == m_currCompositeOpID) int index = m_cmbCompositeOp->indexOf(KoID(compositeOpID));
return;
m_prevCompositeOpID = m_currCompositeOpID;
m_currCompositeOpID = compositeOpID;
int index = m_cmbCompositeOp->indexOf(KoID(m_currCompositeOpID));
bool isEraseModeSet = (m_currCompositeOpID == COMPOSITE_ERASE);
m_cmbCompositeOp->blockSignals(true); m_cmbCompositeOp->blockSignals(true);
m_cmbCompositeOp->setCurrentIndex(index); m_cmbCompositeOp->setCurrentIndex(index);
m_cmbCompositeOp->blockSignals(false); m_cmbCompositeOp->blockSignals(false);
m_eraseModeButton->blockSignals(true); m_eraseModeButton->blockSignals(true);
m_eraseModeButton->setChecked(isEraseModeSet); m_eraseModeButton->setChecked(compositeOpID == COMPOSITE_ERASE);
m_eraseModeButton->blockSignals(false); m_eraseModeButton->blockSignals(false);
m_activePreset->settings()->setProperty("CompositeOp", compositeOpID); if(compositeOpID != m_currCompositeOpID) {
m_optionWidget->setConfiguration(m_activePreset->settings().data()); m_activePreset->settings()->setProperty("CompositeOp", compositeOpID);
m_resourceProvider->setCurrentCompositeOp(m_currCompositeOpID); m_optionWidget->setConfiguration(m_activePreset->settings().data());
m_resourceProvider->setCurrentCompositeOp(compositeOpID);
m_prevCompositeOpID = m_currCompositeOpID;
m_currCompositeOpID = compositeOpID;
}
} }
} }
......
...@@ -70,7 +70,7 @@ class KisPaintopBox : public QWidget ...@@ -70,7 +70,7 @@ class KisPaintopBox : public QWidget
public: public:
KisPaintopBox(KisView2* view, QWidget* parent, const char* name); KisPaintopBox(KisView2* view, QWidget* parent, const char* name);
KisPaintOpPresetSP paintOpPresetSP(KoID * = 0); KisPaintOpPresetSP paintOpPresetSP(KoID * = 0);
const KoID& currentPaintop(); KoID currentPaintop();
void setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset=0); void setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset=0);
QPixmap paintopPixmap(const KoID& paintop); QPixmap paintopPixmap(const KoID& paintop);
~KisPaintopBox(); ~KisPaintopBox();
...@@ -161,7 +161,6 @@ private: ...@@ -161,7 +161,6 @@ private:
TabletToolMap m_tabletToolMap; TabletToolMap m_tabletToolMap;
PaintOpPresetMap m_paintOpPresetMap; PaintOpPresetMap m_paintOpPresetMap;
TabletToolID m_currTabletToolID; TabletToolID m_currTabletToolID;
KoID m_currPaintOp;
}; };
#endif //KIS_PAINTOP_BOX_H_ #endif //KIS_PAINTOP_BOX_H_
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