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