/* * This file is part of Chalk * * Copyright (c) 2005 Cyrille Berger * * 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 "filters_gallery.h" #include #include #include #include #include #include #include "kis_progress_display_interface.h" #include #include #include #include #include #include #include #include #include namespace Chalk { namespace Plugins { namespace FiltersGallery { typedef KGenericFactory ChalkFiltersGalleryFactory; K_EXPORT_COMPONENT_FACTORY( chalkfiltersgallery, ChalkFiltersGalleryFactory( "chalk" ) ) ChalkFiltersGallery::ChalkFiltersGallery(TQObject *parent, const char *name, const TQStringList &) : KParts::Plugin(parent, name) { if ( parent->inherits("KisView") ) { setInstance(ChalkFiltersGallery::instance()); setXMLFile(locate("data","chalkplugins/chalkfiltersgallery.rc"), true); m_view = (KisView*) parent; (void) new KAction(i18n("&Filters Gallery"), 0, 0, this, TQT_SLOT(showFiltersGalleryDialog()), actionCollection(), "chalk_filters_gallery"); // Add a docker with the list of filters // TQImage img; // if(img.load(locate("data","chalk/images/previewfilter.png"))) // { // KisPaintDeviceSP preview = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); // preview->convertFromTQImage(img,""); // m_view->canvasSubject()->paletteManager()->addWidget(new KisFiltersListView(preview,m_view),"filterslist",chalk::EFFECTSBOX, 0); // } } } ChalkFiltersGallery::~ChalkFiltersGallery() { } void ChalkFiltersGallery::showFiltersGalleryDialog() { KisDlgFiltersGallery dlg(m_view, m_view); if (dlg.exec()) { TQApplication::setOverrideCursor( TQt::waitCursor ); KisFilter* filter = dlg.currentFilter(); if(filter ) { KisImageSP img = m_view->canvasSubject()->currentImg(); if (!img) return; KisPaintDeviceSP dev = img->activeDevice(); if (!dev) return; TQRect r1 = dev->exactBounds(); TQRect r2 = img->bounds(); TQRect rect = r1.intersect(r2); if (dev->hasSelection()) { TQRect r3 = dev->selection()->selectedExactRect(); rect = rect.intersect(r3); } KisFilterConfiguration* config = filter->configuration( dlg.currentConfigWidget()); filter->enableProgress(); m_view->canvasSubject()->progressDisplay()->setSubject(filter, true, true); filter->setProgressDisplay(m_view->canvasSubject()->progressDisplay()); KisTransaction * cmd = new KisTransaction(filter->id().name(), dev); filter->process(dev,dev, config, rect); delete config; if (filter->cancelRequested()) { cmd->unexecute(); delete cmd; } else { dev->setDirty(rect); if (img->undo()) img->undoAdapter()->addCommand(cmd); else delete cmd; } filter->disableProgress(); TQApplication::restoreOverrideCursor(); } } } } } } #include "filters_gallery.moc"