Commit f53408fc authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove the canvas widget parameter from the constructor of KisFavoriteResourceManager

parent e44aa3be
......@@ -386,6 +386,10 @@ void KisCanvas2::createCanvas(bool useOpenGL)
#endif
createQPainterCanvas();
}
if (m_d->favoriteResourceManager) {
m_d->favoriteResourceManager->resetPopupPaletteParent(m_d->canvasWidget->widget());
}
}
void KisCanvas2::initializeImage()
......@@ -790,11 +794,14 @@ QPoint KisCanvas2::documentOffset() const
void KisCanvas2::createFavoriteResourceManager(KisPaintopBox* paintopbox)
{
m_d->favoriteResourceManager = new KisFavoriteResourceManager(paintopbox, canvasWidget());
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->resetPopupPaletteParent(m_d->canvasWidget->widget());
}
KisFavoriteResourceManager* KisCanvas2::favoriteResourceManager()
......
......@@ -40,7 +40,7 @@ const int KisFavoriteResourceManager::MAX_FAVORITE_PRESETS;
//const int KisFavoriteResourceManager::MAX_RECENT_COLORS;
#endif
KisFavoriteResourceManager::KisFavoriteResourceManager(KisPaintopBox *paintopBox, QWidget* popupParent)
KisFavoriteResourceManager::KisFavoriteResourceManager(KisPaintopBox *paintopBox)
: m_favoriteBrushManager(0)
, m_popupPalette(0)
, m_paintopBox(paintopBox)
......@@ -50,9 +50,9 @@ KisFavoriteResourceManager::KisFavoriteResourceManager(KisPaintopBox *paintopBox
//take favorite brushes from a file then append to QList
KConfigGroup group(KGlobal::config(), "favoriteList");
m_favoritePresetsList = (group.readEntry("favoritePresets")).split(',', QString::SkipEmptyParts);
m_popupPalette = new KisPopupPalette(this);
//m_popupPalette->showPopupPalette(false);
m_popupPalette = new KisPopupPalette(this, popupParent);
m_popupPalette->showPopupPalette(false);
m_colorList = new KisColorDataList();
KoResourceServer<KisPaintOpPreset>* rServer = KisResourceServerProvider::instance()->paintOpPresetServer();
......@@ -80,14 +80,17 @@ QStringList KisFavoriteResourceManager::favoritePresetList()
//Popup Palette
void KisFavoriteResourceManager::slotShowPopupPalette(const QPoint &p)
{
if (!m_popupPalette) return;
else m_popupPalette->showPopupPalette(p);
if (!m_popupPalette) {
return;
}
else {
m_popupPalette->showPopupPalette(p);
}
}
void KisFavoriteResourceManager::resetPopupPaletteParent(QWidget* w)
{
if (m_popupPalette)
{
if (m_popupPalette) {
m_popupPalette->setParent(w);
}
}
......
......@@ -43,7 +43,7 @@ class KisFavoriteResourceManager : public QObject, public KoResourceServerObserv
public:
KisFavoriteResourceManager(KisPaintopBox*, QWidget* = 0);
KisFavoriteResourceManager(KisPaintopBox *paintopBox);
~KisFavoriteResourceManager();
virtual void unsetResourceServer();
......
......@@ -51,8 +51,7 @@ class KisPaintOpSettingsWidget;
class KisPaintOpListWidget;
class KisCompositeOpComboBox;
class KisWidgetChooser;
class KisFavoriteResourceManager;
/**
* This widget presents all paintops that a user can paint with.
* Paintops represent real-world tools or the well-known Shoup
......@@ -150,6 +149,7 @@ private:
KisPopupButton* m_workspaceWidget;
KisWidgetChooser* m_sliderChooser[3];
QMap<KoID,KisPaintOpSettingsWidget*> m_paintopOptionWidgets;
KisFavoriteResourceManager* m_favoriteResourceManager;
// KisPaintOpPresetSP m_activePreset;
// KisPaintOpPresetSP m_previousPreset;
......@@ -192,6 +192,8 @@ private:
TabletToolID m_currTabletToolID;
bool m_presetsEnabled;
bool m_blockUpdate;
};
#endif //KIS_PAINTOP_BOX_H_
......@@ -160,22 +160,21 @@ void KisPopupPalette::slotEnableChangeFGColor()
void KisPopupPalette::showPopupPalette (const QPoint &p)
{
if (!isVisible())
{
if (!isVisible() && parentWidget()) {
QSize parentSize(parentWidget()->size());
QPoint pointPalette(p.x() - width()/2, p.y() - height()/2);
//setting offset point in case the widget is shown outside of canvas region
int offsetX = 0, offsetY=0;
if ((offsetX = pointPalette.x() + width() - parentSize.width()) > 0 || (offsetX = pointPalette.x()) < 0)
{
if ((offsetX = pointPalette.x() + width() - parentSize.width()) > 0 || (offsetX = pointPalette.x()) < 0) {
pointPalette.setX(pointPalette.x() - offsetX);
}
if ((offsetY = pointPalette.y() + height() - parentSize.height()) > 0 || (offsetY = pointPalette.y()) < 0)
{
if ((offsetY = pointPalette.y() + height() - parentSize.height()) > 0 || (offsetY = pointPalette.y()) < 0) {
pointPalette.setY(pointPalette.y() - offsetY);
}
move(pointPalette);
}
......@@ -185,17 +184,14 @@ void KisPopupPalette::showPopupPalette (const QPoint &p)
void KisPopupPalette::showPopupPalette(bool show)
{
if (show)
{
if (show){
emit sigEnableChangeFGColor(!show);
QApplication::setOverrideCursor(Qt::ArrowCursor);
}
else
{
else {
emit sigTriggerTimer();
QApplication::restoreOverrideCursor();
}
setVisible(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