Commit b05f91de authored by Boudewijn Rempt's avatar Boudewijn Rempt

Synchronize the pattern docker and the pattern popup.

parent 02b99b37
......@@ -39,6 +39,7 @@ PatternDockerDock::PatternDockerDock( )
{
m_patternChooser = new KisPatternChooser(this);
m_patternChooser->setPreviewOrientation(Qt::Vertical);
m_patternChooser->setCurrentItem(0,0);
m_patternChooser->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setWidget(m_patternChooser);
}
......@@ -47,25 +48,25 @@ void PatternDockerDock::setCanvas(KoCanvasBase * canvas)
{
if (m_canvas) {
m_canvas->disconnectCanvasObserver(this);
m_patternChooser->disconnect(m_canvas->view()->paintOpBox());
m_patternChooser->disconnect(m_canvas->view()->resourceProvider());
m_canvas->view()->resourceProvider()->disconnect(this);
}
m_canvas = dynamic_cast<KisCanvas2*>(canvas);
Q_ASSERT(m_canvas);
if (!m_canvas) return;
connect(m_canvas->resourceManager(), SIGNAL(resourceChanged(int, const QVariant&)),
this, SLOT(resourceChanged(int, const QVariant&)));
connect(m_canvas->view()->resourceProvider(), SIGNAL(sigPatternChanged(KisPattern*)),
this, SLOT(patternChanged(KisPattern*)));
connect(m_patternChooser, SIGNAL(resourceSelected(KoResource*)),
m_canvas->view()->paintOpBox(), SLOT(resourceSelected(KoResource*)));
m_canvas->view()->resourceProvider(), SLOT(slotPatternActivated(KoResource*)));
}
void PatternDockerDock::resourceChanged(int /*key*/, const QVariant& /*v*/)
void PatternDockerDock::patternChanged(KisPattern *pattern)
{
// if (m_canvas) {
// KisPattern *pattern = m_canvas->resourceManager()->resource(KisCanvasResourceProvider::CurrentPattern).value<KisPattern*>();
// }
m_patternChooser->setCurrentPattern(pattern);
}
#include "patterndocker_dock.moc"
......@@ -22,6 +22,7 @@
#include <KoColor.h>
#include <KoCanvasObserverBase.h>
class KisPattern;
class KisPatternChooser;
class KisCanvas2;
......@@ -32,8 +33,9 @@ public:
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; }
public slots:
void resourceChanged(int, const QVariant&);
void patternChanged(KisPattern *pattern);
private slots:
private:
KisCanvas2* m_canvas;
KisPatternChooser* m_patternChooser;
......
......@@ -124,6 +124,7 @@ KisControlFrame::KisControlFrame(KisView2 * view, const char* name)
void KisControlFrame::slotSetPattern(KisPattern * pattern)
{
m_patternWidget->slotSetItem(pattern);
m_patternChooser->setCurrentPattern(pattern);
}
void KisControlFrame::slotSetGradient(KoAbstractGradient * gradient)
......@@ -147,16 +148,16 @@ void KisControlFrame::createPatternsChooser(KisView2 * view)
m_patternsTab->setContentsMargins(1, 1, 1, 1);
l2->addWidget(m_patternsTab);
KisPatternChooser * chooser = new KisPatternChooser(m_patternChooserPopup);
chooser->setFont(m_font);
m_patternsTab->addTab(chooser, i18n("Patterns"));
m_patternChooser = new KisPatternChooser(m_patternChooserPopup);
m_patternChooser->setFont(m_font);
m_patternsTab->addTab(m_patternChooser, i18n("Patterns"));
KisCustomPattern* customPatterns = new KisCustomPattern(0, "custompatterns",
i18n("Custom Pattern"), m_view);
customPatterns->setFont(m_font);
m_patternsTab->addTab(customPatterns, i18n("Custom Pattern"));
connect(chooser, SIGNAL(resourceSelected(KoResource*)),
connect(m_patternChooser, SIGNAL(resourceSelected(KoResource*)),
view->resourceProvider(), SLOT(slotPatternActivated(KoResource*)));
connect(customPatterns, SIGNAL(activatedResource(KoResource*)),
......@@ -165,9 +166,9 @@ void KisControlFrame::createPatternsChooser(KisView2 * view)
connect(view->resourceProvider(), SIGNAL(sigPatternChanged(KisPattern *)),
this, SLOT(slotSetPattern(KisPattern *)));
chooser->setCurrentItem(0, 0);
if (chooser->currentResource())
view->resourceProvider()->slotPatternActivated(chooser->currentResource());
m_patternChooser->setCurrentItem(0, 0);
if (m_patternChooser->currentResource())
view->resourceProvider()->slotPatternActivated(m_patternChooser->currentResource());
}
......
......@@ -34,11 +34,9 @@ class QPushButton;
class KToolBar;
class KoResourceItem;
class KoAbstractGradient;
class KisGradientChooser;
class KoResourceItemChooser;
class KisPatternChooser;
class KisPaintopBox;
class KisView2;
class KisIconWidget;
......@@ -83,12 +81,13 @@ private:
KisIconWidget *m_patternWidget;
KisIconWidget *m_gradientWidget;
QWidget * m_patternChooserPopup;
QWidget * m_gradientChooserPopup;
QWidget *m_patternChooserPopup;
QWidget *m_gradientChooserPopup;
KisGradientChooser * m_gradientChooser;
KisGradientChooser *m_gradientChooser;
KisPatternChooser *m_patternChooser;
KisPaintopBox * m_paintopBox;
KisPaintopBox *m_paintopBox;
};
......
......@@ -74,6 +74,11 @@ KoResource * KisPatternChooser::currentResource()
return m_itemChooser->currentResource();
}
void KisPatternChooser::setCurrentPattern(KoResource *resource)
{
m_itemChooser->setCurrentResource(resource);
}
void KisPatternChooser::setCurrentItem(int row, int column)
{
m_itemChooser->setCurrentItem(row, column);
......
......@@ -36,7 +36,7 @@ public:
/// Gets the currently selected resource
/// @returns the selected resource, 0 is no resource is selected
KoResource *currentResource();
void setCurrentPattern(KoResource *resource);
void setCurrentItem(int row, int column);
/// determines whether the preview right or below the splitter
......
......@@ -328,6 +328,7 @@ void KoResourceItemChooser::setCurrentResource(KoResource* resource)
d->view->setCurrentIndex(index);
setTagOpLineEdit(d->model->resourceServerAdapter()->getAssignedTagsList(resource));
updatePreview(resource);
}
void KoResourceItemChooser::showPreview(bool show)
......
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