Commit 6dc2aa4a authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove KisPopupPalette member from KisFavoriteResourceManager

parent 3c726ee2
......@@ -795,7 +795,7 @@ QPoint KisCanvas2::documentOffset() const
void KisCanvas2::setFavoriteResourceManager(KisFavoriteResourceManager* favoriteResourceManager)
{
m_d->popupPalette = new KisPopupPalette(favoriteResourceManager, m_d->canvasWidget->widget());
favoriteResourceManager->setPopupPalette(m_d->popupPalette);
m_d->popupPalette->showPopupPalette(false);
}
void KisCanvas2::setCursor(const QCursor &cursor)
......
......@@ -168,7 +168,6 @@ private:
KisFavoriteResourceManager::KisFavoriteResourceManager(KisPaintopBox *paintopBox)
: m_favoriteBrushManager(0)
, m_popupPalette(0)
, m_paintopBox(paintopBox)
, m_colorList(0)
, m_blockUpdates(false)
......@@ -191,12 +190,6 @@ KisFavoriteResourceManager::~KisFavoriteResourceManager()
delete m_colorList;
}
void KisFavoriteResourceManager::setPopupPalette(QWidget *palette)
{
m_popupPalette = qobject_cast<KisPopupPalette*>(palette);
m_popupPalette->showPopupPalette(false);
}
void KisFavoriteResourceManager::unsetResourceServer()
{
// ...
......@@ -229,10 +222,7 @@ void KisFavoriteResourceManager::slotChangeActivePaintop(int pos)
KoResourceServer<KisPaintOpPreset>* rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
KoResource* resource = rServer->resourceByName(m_favoritePresetsList.at(pos));
m_paintopBox->resourceSelected(resource);
if (m_popupPalette) {
m_popupPalette->showPopupPalette(false); //automatically close the palette after a button is clicked.
}
emit hidePalettes();
}
......@@ -263,7 +253,7 @@ int KisFavoriteResourceManager::addFavoritePreset(const QString& name)
} else {
m_favoritePresetsList.append(name);
saveFavoritePresets();
m_popupPalette->update();
emit updatePalettes();
return -1;
}
}
......@@ -281,7 +271,7 @@ void KisFavoriteResourceManager::removeFavoritePreset(int pos)
} else {
m_favoritePresetsList.removeAt(pos);
saveFavoritePresets();
m_popupPalette->update();
emit updatePalettes();
}
}
......@@ -318,27 +308,16 @@ void KisFavoriteResourceManager::slotUpdateRecentColor(int pos)
// to update the colour priority when we select it.
m_colorList->updateKey(pos);
if (m_popupPalette) {
m_popupPalette->setSelectedColor(pos);
m_popupPalette->update();
}
emit setSelectedColor(pos);
emit sigSetFGColor(m_colorList->guiColor(pos));
if (m_popupPalette) {
m_popupPalette->showPopupPalette(false); //automatically close the palette after a button is clicked.
}
emit hidePalettes();
}
void KisFavoriteResourceManager::slotAddRecentColor(const KoColor& color)
{
m_colorList->append(color);
int pos = m_colorList->findPos(color);
if (m_popupPalette) {
m_popupPalette->setSelectedColor(pos);
m_popupPalette->update();
}
emit setSelectedColor(pos);
}
void KisFavoriteResourceManager::slotChangeFGColorSelector(KoColor c)
......
......@@ -33,7 +33,6 @@ class QStringList;
class QToolButton;
class QPoint;
class KoID;
class KisPopupPalette;
class KisPaintopBox;
class KisPaletteManager;
class KisView2;
......@@ -101,6 +100,12 @@ signals:
void sigChangeFGColorSelector(const QColor&);
void setSelectedColor(int);
void updatePalettes();
void hidePalettes();
public slots:
void slotChangeActivePaintop(int);
......@@ -116,7 +121,6 @@ public slots:
private:
KisPaletteManager *m_favoriteBrushManager;
KisPopupPalette *m_popupPalette;
KisPaintopBox *m_paintopBox;
QStringList m_favoritePresetsList;
......
......@@ -99,6 +99,9 @@ KisPopupPalette::KisPopupPalette(KisFavoriteResourceManager* manager, QWidget *p
connect(this, SIGNAL(sigUpdateRecentColor(int)), m_resourceManager, SLOT(slotUpdateRecentColor(int)));
connect(this, SIGNAL(sigChangefGColor(KoColor)), m_resourceManager, SIGNAL(sigSetFGColor(KoColor)));
connect(m_resourceManager, SIGNAL(sigChangeFGColorSelector(QColor)), m_triangleColorSelector, SLOT(setQColor(QColor)));
connect(m_resourceManager, SIGNAL(setSelectedColor(int)), SLOT(slotSetSelectedColor(int)));
connect(m_resourceManager, SIGNAL(updatePalettes()), SLOT(slotUpdate()));
connect(m_resourceManager, SIGNAL(hidePalettes()), SLOT(slotHide()));
// This is used to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
......
......@@ -33,6 +33,7 @@ class KoColor;
class KisPopupPalette : public QWidget
{
Q_OBJECT
Q_PROPERTY(int hoveredPreset READ hoveredPreset WRITE setHoveredPreset)
Q_PROPERTY(int hoveredColor READ hoveredColor WRITE setHoveredColor)
Q_PROPERTY(int selectedColor READ selectedColor WRITE setSelectedColor)
......@@ -53,6 +54,7 @@ public:
int selectedColor() const;
protected:
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent*);
void mouseReleaseEvent(QMouseEvent*);
......@@ -83,6 +85,7 @@ private:
QPainterPath pathFromPresetIndex(int index);
private:
int m_hoveredPreset;
int m_hoveredColor;
int m_selectedColor;
......@@ -106,11 +109,14 @@ signals:
void sigTriggerTimer();
private slots:
void slotChangefGColor(const QColor& newColor);
void slotColorChangeTimeout();
void slotSetSelectedColor(int x) { setSelectedColor(x); update(); }
void slotTriggerTimer();
void slotEnableChangeFGColor();
void slotUpdate() { update(); }
void slotHide() { showPopupPalette(false); }
};
#endif // KIS_POPUP_PALETTE_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