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

Move the favourite resource provider to the paintop box

parent 0d95e890
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
#include <QGLFormat> #include <QGLFormat>
#endif #endif
//Favorite resource Manager
#include <kis_favorite_resource_manager.h> #include <kis_favorite_resource_manager.h>
#include <kis_popup_palette.h> #include <kis_popup_palette.h>
...@@ -796,26 +795,15 @@ QPoint KisCanvas2::documentOffset() const ...@@ -796,26 +795,15 @@ QPoint KisCanvas2::documentOffset() const
return m_d->coordinatesConverter->documentOffset(); return m_d->coordinatesConverter->documentOffset();
} }
void KisCanvas2::createFavoriteResourceManager(KisPaintopBox* paintopbox) void KisCanvas2::setFavoriteResourceManager(KisFavoriteResourceManager* favoriteResourceManager)
{ {
m_d->favoriteResourceManager = new KisFavoriteResourceManager(paintopbox); m_d->favoriteResourceManager = favoriteResourceManager;
connect(view()->resourceProvider(), SIGNAL(sigFGColorUsed(KoColor)), favoriteResourceManager(), SLOT(slotAddRecentColor(KoColor)));
connect(view()->resourceProvider(), SIGNAL(sigFGColorChanged(KoColor)), favoriteResourceManager(), SLOT(slotChangeFGColorSelector(KoColor)));
connect(favoriteResourceManager(), SIGNAL(sigSetFGColor(KoColor)), view()->resourceProvider(), SLOT(slotSetFGColor(KoColor)));
connect(favoriteResourceManager(), SIGNAL(sigEnableChangeColor(bool)), view()->resourceProvider(), SLOT(slotResetEnableFGChange(bool)));
m_d->popupPalette = new KisPopupPalette(m_d->favoriteResourceManager, m_d->canvasWidget->widget()); m_d->popupPalette = new KisPopupPalette(m_d->favoriteResourceManager, m_d->canvasWidget->widget());
m_d->favoriteResourceManager->setPopupPalette(m_d->popupPalette); m_d->favoriteResourceManager->setPopupPalette(m_d->popupPalette);
} }
KisFavoriteResourceManager* KisCanvas2::favoriteResourceManager()
{
return m_d->favoriteResourceManager;
}
void KisCanvas2::setCursor(const QCursor &cursor) void KisCanvas2::setCursor(const QCursor &cursor)
{ {
canvasWidget()->setCursor(cursor); canvasWidget()->setCursor(cursor);
......
...@@ -229,8 +229,7 @@ public: ...@@ -229,8 +229,7 @@ public:
// interface for KisView2 only // interface for KisView2 only
void resetCanvas(bool useOpenGL); void resetCanvas(bool useOpenGL);
void createFavoriteResourceManager(KisPaintopBox*); void setFavoriteResourceManager(KisFavoriteResourceManager* favoriteResourceManager);
KisFavoriteResourceManager* favoriteResourceManager();
private: private:
Q_DISABLE_COPY(KisCanvas2) Q_DISABLE_COPY(KisCanvas2)
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
#include "widgets/kis_widget_chooser.h" #include "widgets/kis_widget_chooser.h"
#include "tool/kis_tool.h" #include "tool/kis_tool.h"
KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, const char * name) KisPaintopBox::KisPaintopBox(KisView2 *view, QWidget *parent, const char *name)
: QWidget(parent) : QWidget(parent)
, m_resourceProvider(view->resourceProvider()) , m_resourceProvider(view->resourceProvider())
, m_optionWidget(0) , m_optionWidget(0)
...@@ -292,9 +292,15 @@ KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, const char * name ...@@ -292,9 +292,15 @@ KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, const char * name
connect(m_sliderChooser[2]->getWidget<KisDoubleSliderSpinBox>("size") , SIGNAL(valueChanged(qreal)), SLOT(slotSlider3Changed())); connect(m_sliderChooser[2]->getWidget<KisDoubleSliderSpinBox>("size") , SIGNAL(valueChanged(qreal)), SLOT(slotSlider3Changed()));
//Needed to connect canvas to favorite resource manager //Needed to connect canvas to favorite resource manager
m_view->canvasBase()->createFavoriteResourceManager(this); m_favoriteResourceManager = new KisFavoriteResourceManager(this);
connect(m_view->resourceProvider(), SIGNAL(sigOpacityChanged(qreal)), SLOT(slotOpacityChanged(qreal))); connect(m_resourceProvider, SIGNAL(sigFGColorUsed(KoColor)), m_favoriteResourceManager, SLOT(slotAddRecentColor(KoColor)));
connect(m_view->resourceProvider(), SIGNAL(sigFGColorChanged(KoColor)), SLOT(slotUnsetEraseMode())); connect(m_resourceProvider, SIGNAL(sigFGColorChanged(KoColor)), m_favoriteResourceManager, SLOT(slotChangeFGColorSelector(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigSetFGColor(KoColor)), m_resourceProvider, SLOT(slotSetFGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigEnableChangeColor(bool)), m_resourceProvider, SLOT(slotResetEnableFGChange(bool)));
m_view->canvasBase()->setFavoriteResourceManager(m_favoriteResourceManager);
connect(m_resourceProvider, SIGNAL(sigOpacityChanged(qreal)), SLOT(slotOpacityChanged(qreal)));
connect(m_resourceProvider, SIGNAL(sigFGColorChanged(KoColor)), SLOT(slotUnsetEraseMode()));
} }
KisPaintopBox::~KisPaintopBox() KisPaintopBox::~KisPaintopBox()
...@@ -568,7 +574,7 @@ void KisPaintopBox::slotSaveActivePreset() ...@@ -568,7 +574,7 @@ void KisPaintopBox::slotSaveActivePreset()
if (!curPreset) if (!curPreset)
return; return;
m_view->canvasBase()->favoriteResourceManager()->setBlockUpdates(true); m_favoriteResourceManager->setBlockUpdates(true);
KisPaintOpPreset* newPreset = curPreset->clone(); KisPaintOpPreset* newPreset = curPreset->clone();
KoResourceServer<KisPaintOpPreset>* rServer = KisResourceServerProvider::instance()->paintOpPresetServer(); KoResourceServer<KisPaintOpPreset>* rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
...@@ -592,7 +598,7 @@ void KisPaintopBox::slotSaveActivePreset() ...@@ -592,7 +598,7 @@ void KisPaintopBox::slotSaveActivePreset()
foreach(const QString& tag, tags) { foreach(const QString& tag, tags) {
rServer->addTag(newPreset, tag); rServer->addTag(newPreset, tag);
} }
m_view->canvasBase()->favoriteResourceManager()->setBlockUpdates(false); m_favoriteResourceManager->setBlockUpdates(false);
} }
void KisPaintopBox::slotUpdatePreset() void KisPaintopBox::slotUpdatePreset()
...@@ -690,10 +696,9 @@ void KisPaintopBox::slotSetCompositeMode(int index) ...@@ -690,10 +696,9 @@ void KisPaintopBox::slotSetCompositeMode(int index)
void KisPaintopBox::slotSaveToFavouriteBrushes() void KisPaintopBox::slotSaveToFavouriteBrushes()
{ {
if(!m_view->canvasBase()->favoriteResourceManager()) if (m_favoriteResourceManager) {
m_view->canvasBase()->createFavoriteResourceManager(this); m_favoriteResourceManager->showPaletteManager();
else }
m_view->canvasBase()->favoriteResourceManager()->showPaletteManager();
} }
void KisPaintopBox::slotWatchPresetNameLineEdit(const QString& text) void KisPaintopBox::slotWatchPresetNameLineEdit(const QString& text)
...@@ -804,18 +809,16 @@ void KisPaintopBox::slotOpacityChanged(qreal opacity) ...@@ -804,18 +809,16 @@ void KisPaintopBox::slotOpacityChanged(qreal opacity)
void KisPaintopBox::slotPreviousFavoritePreset() void KisPaintopBox::slotPreviousFavoritePreset()
{ {
if (!m_view->canvasBase()->favoriteResourceManager()) { if (!m_favoriteResourceManager) return;
m_view->canvasBase()->createFavoriteResourceManager(this);
}
KisFavoriteResourceManager *mgr = m_view->canvasBase()->favoriteResourceManager();
int i = 0; int i = 0;
foreach (const QString &preset, mgr->favoritePresetList()) { foreach (const QString &preset, m_favoriteResourceManager->favoritePresetList()) {
if (m_resourceProvider->currentPreset()->name() == preset) { if (m_resourceProvider->currentPreset()->name() == preset) {
if (i > 0) { if (i > 0) {
mgr->slotChangeActivePaintop(i - 1); m_favoriteResourceManager->slotChangeActivePaintop(i - 1);
} }
else { else {
mgr->slotChangeActivePaintop(mgr->numFavoritePresets() - 1); m_favoriteResourceManager->slotChangeActivePaintop(m_favoriteResourceManager->numFavoritePresets() - 1);
} }
return; return;
} }
...@@ -826,18 +829,16 @@ void KisPaintopBox::slotPreviousFavoritePreset() ...@@ -826,18 +829,16 @@ void KisPaintopBox::slotPreviousFavoritePreset()
void KisPaintopBox::slotNextFavoritePreset() void KisPaintopBox::slotNextFavoritePreset()
{ {
if (!m_view->canvasBase()->favoriteResourceManager()) { if (!m_favoriteResourceManager) return;
m_view->canvasBase()->createFavoriteResourceManager(this);
}
KisFavoriteResourceManager *mgr = m_view->canvasBase()->favoriteResourceManager();
int i = 0; int i = 0;
foreach (const QString &preset, mgr->favoritePresetList()) { foreach (const QString &preset, m_favoriteResourceManager->favoritePresetList()) {
if (m_resourceProvider->currentPreset()->name() == preset) { if (m_resourceProvider->currentPreset()->name() == preset) {
if (i < mgr->numFavoritePresets() - 1) { if (i < m_favoriteResourceManager->numFavoritePresets() - 1) {
mgr->slotChangeActivePaintop(i + 1); m_favoriteResourceManager->slotChangeActivePaintop(i + 1);
} }
else { else {
mgr->slotChangeActivePaintop(0); m_favoriteResourceManager->slotChangeActivePaintop(0);
} }
return; return;
} }
......
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