Commit c74087e1 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove disabled (since 2013) palette docker

parent 386df2f7
set(kritadefaultdockers_PART_SRCS
kis_palette_docker.cc
kis_layer_box.cpp
defaultdockers.cpp
)
set(kritadefaultdockers_PART_HEADERS
kis_palette_docker.h
kis_layer_box.h
defaultdockers.h
)
......
......@@ -25,7 +25,6 @@
#include "kis_debug.h"
#include "kis_layer_box.h"
#include "kis_palette_docker.h"
K_PLUGIN_FACTORY(KritaDefaultDockersPluginFactory, registerPlugin<KritaDefaultDockersPlugin>();)
K_EXPORT_PLUGIN(KritaDefaultDockersPluginFactory("krita"))
......@@ -34,7 +33,6 @@ KritaDefaultDockersPlugin::KritaDefaultDockersPlugin(QObject *parent, const QVar
: QObject(parent)
{
KoDockRegistry::instance()->add(new KisLayerBoxFactory());
// KoDockRegistry::instance()->add(new KisPaletteDockerFactory());
}
KritaDefaultDockersPlugin::~KritaDefaultDockersPlugin()
......
/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_palette_docker.h"
#include <QComboBox>
#include <QVBoxLayout>
#include <QTimer>
#include <KoCanvasBase.h>
#include <KoResource.h>
#include <KoColorSet.h>
#include <KoColorSetWidget.h>
#include <KoCanvasResourceManager.h>
#include <KoResourceServerProvider.h>
#include <kis_config.h>
#include <kis_workspace_resource.h>
#include <kis_canvas_resource_provider.h>
#include <KisViewManager.h>
#include <kis_canvas2.h>
KisPaletteDocker::KisPaletteDocker()
: QDockWidget(i18n("Palettes"))
, m_currentPalette(0)
, m_canvas(0)
{
QWidget* mainWidget = new QWidget(this);
setWidget(mainWidget);
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
m_chooser = new KoColorSetWidget(this);
layout->addWidget(m_chooser);
mainWidget->setLayout(layout);
connect(m_chooser, SIGNAL(colorChanged(const KoColor&, bool)), SLOT(colorSelected(const KoColor&, bool)));
KisConfig cfg;
m_defaultPalette = cfg.defaultPalette();
KoResourceServer<KoColorSet>* rServer = KoResourceServerProvider::instance()->paletteServer();
m_serverAdapter = QSharedPointer<KoAbstractResourceServerAdapter>(new KoResourceServerAdapter<KoColorSet>(rServer));
connect(m_serverAdapter.data(), SIGNAL(resourceAdded(KoResource*)), this, SLOT(resourceAddedToServer(KoResource*)));
m_serverAdapter->connectToResourceServer();
checkForDefaultResource();
}
KisPaletteDocker::~KisPaletteDocker()
{
KoColorSet* colorSet = m_chooser->colorSet();
if (colorSet) {
KisConfig cfg;
cfg.setDefaultPalette(colorSet->name());
}
}
void KisPaletteDocker::setCanvas(KoCanvasBase * canvas)
{
setEnabled(canvas != 0);
m_canvas = canvas;
KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas);
if (kisCanvas && kisCanvas->viewManager()) {
KisViewManager* view = kisCanvas->viewManager();
connect(view->resourceProvider(), SIGNAL(sigSavingWorkspace(KisWorkspaceResource*)), SLOT(saveToWorkspace(KisWorkspaceResource*)));
connect(view->resourceProvider(), SIGNAL(sigLoadingWorkspace(KisWorkspaceResource*)), SLOT(loadFromWorkspace(KisWorkspaceResource*)));
}
}
void KisPaletteDocker::colorSelected(const KoColor& c, bool final)
{
if (final && m_canvas) {
m_canvas->resourceManager()->setForegroundColor(c);
}
}
QString KisPaletteDockerFactory::id() const
{
return QString("KisPaletteDocker");
}
QDockWidget* KisPaletteDockerFactory::createDockWidget()
{
KisPaletteDocker* dockWidget = new KisPaletteDocker();
dockWidget->setObjectName(id());
return dockWidget;
}
void KisPaletteDocker::resourceAddedToServer(KoResource* resource)
{
Q_UNUSED(resource);
// Avoiding resource mutex deadlock
QTimer::singleShot( 0, this, SLOT( checkForDefaultResource() ) );
}
void KisPaletteDocker::checkForDefaultResource()
{
foreach(KoResource* resource, m_serverAdapter->resources()) {
if (resource->name() == m_defaultPalette) {
KoColorSet* colorSet = static_cast<KoColorSet*>(resource);
m_chooser->setColorSet(colorSet);
}
}
}
void KisPaletteDocker::saveToWorkspace(KisWorkspaceResource* workspace)
{
KoColorSet* colorSet = m_chooser->colorSet();
if (colorSet) {
workspace->setProperty("palette", colorSet->name());
}
}
void KisPaletteDocker::loadFromWorkspace(KisWorkspaceResource* workspace)
{
if (workspace->hasProperty("palette")) {
KoResourceServer<KoColorSet>* rServer = KoResourceServerProvider::instance()->paletteServer();
KoColorSet* colorSet = rServer->resourceByName(workspace->getString("palette"));
if (colorSet) {
m_chooser->setColorSet(colorSet);
}
}
}
#include "kis_palette_docker.moc"
/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __KIS_PALETTE_DOCKER_H__
#define __KIS_PALETTE_DOCKER_H__
#include <QDockWidget>
#include <klocale.h>
#include <KoDockFactoryBase.h>
#include <KoColorSet.h>
#include <KoCanvasObserverBase.h>
#include <KoResourceServerAdapter.h>
class KisWorkspaceResource;
class KoColorSetWidget;
class KoColor;
class KisViewManager;
/**
* A color palette in table form.
*
* This is copied, mostly, from KPaletteTable in KColorDialog, original
* @author was Waldo Bastian <bastian@kde.org> -- much has changed, though,
* to work with KisPalettes and the resource server.
*/
class KisPaletteDocker : public QDockWidget, public KoCanvasObserverBase
{
Q_OBJECT
public:
KisPaletteDocker();
QString observerName() { return "KisPaletteDocker"; }
virtual ~KisPaletteDocker();
QString palette() const;
/// reimplemented from KoCanvasObserverBase
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);}
private slots:
void colorSelected(const KoColor& color, bool final);
void resourceAddedToServer(KoResource* resource);
void checkForDefaultResource();
void saveToWorkspace(KisWorkspaceResource* workspace);
void loadFromWorkspace(KisWorkspaceResource* workspace);
private:
void readNamedColor(void);
protected:
KoColorSet* m_currentPalette;
KoCanvasBase* m_canvas;
KoColorSetWidget* m_chooser;
QSharedPointer<KoAbstractResourceServerAdapter> m_serverAdapter;
QString m_defaultPalette;
};
class KisPaletteDockerFactory : public KoDockFactoryBase
{
public:
KisPaletteDockerFactory() {}
~KisPaletteDockerFactory() {}
virtual QString id() const;
QDockWidget * createDockWidget();
DockPosition defaultDockPosition() const {
return DockMinimized;
}
};
#endif
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