Commit 77aedcef authored by Michael Thaler's avatar Michael Thaler

Port grow, shrink, border selection dialogs from krita-1.6 branch to trunk

svn path=/trunk/koffice/; revision=522654
parent ca4d214e
kritarcdir = $(kde_datadir)/kritaplugins
kritarc_DATA = modify_selection.rc
EXTRA_DIST = $(kritarc_DATA)
kde_services_DATA = kritamodifyselection.desktop
INCLUDES = -I$(srcdir)/../../../sdk \
-I$(srcdir)/../../../core \
-I$(srcdir)/../../../kritacolor/ \
-I$(srcdir)/../../../ui \
$(KOFFICE_INCLUDES) \
$(all_includes)
kritamodifyselection_la_SOURCES = wdg_grow_selection.ui wdg_shrink_selection.ui wdg_border_selection.ui \
dlg_grow_selection.cc dlg_shrink_selection.cc dlg_border_selection.cc modify_selection.cc
noinst_HEADERS = wdg_grow_selection.h wdg_shrink_selection.h wdg_border_selection.h dlg_grow_selection.h \
dlg_shrink_selection.h dlg_border_selection.h modify_selection.h
kde_module_LTLIBRARIES = kritamodifyselection.la
kritamodifyselection_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
kritamodifyselection_la_LIBADD = ../../../libkritacommon.la
kritamodifyselection_la_METASOURCES = AUTO
/*
* dlg_border_selection.cc - part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 <config.h>
#include <math.h>
#include <iostream>
using namespace std;
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <klocale.h>
#include <knuminput.h>
#include <kdebug.h>
#include "dlg_border_selection.h"
#include "wdg_border_selection.h"
DlgBorderSelection::DlgBorderSelection( QWidget * parent, const char * name) : super (parent, name, true, i18n("Border Selection"), Ok | Cancel, Ok)
{
m_page = new WdgBorderSelection(this, "border_selection");
Q_CHECK_PTR(m_page);
setMainWidget(m_page);
resize(m_page->sizeHint());
connect(this, SIGNAL(okClicked()), this, SLOT(okClicked()));
}
DlgBorderSelection::~DlgBorderSelection()
{
delete m_page;
}
Q_INT32 DlgBorderSelection::xradius()
{
return m_page->radiusSpinBox->value();
}
Q_INT32 DlgBorderSelection::yradius()
{
return m_page->radiusSpinBox->value();
}
// SLOTS
void DlgBorderSelection::okClicked()
{
accept();
}
#include "dlg_border_selection.moc"
/*
* dlg_border_selection.h -- part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 DLG_BORDER_SELECTION_H
#define DLG_BORDER_SELECTION_H
#include <kdialogbase.h>
class WdgBorderSelection;
class DlgBorderSelection: public KDialogBase {
typedef KDialogBase super;
Q_OBJECT
public:
DlgBorderSelection(QWidget * parent = 0, const char* name = 0);
~DlgBorderSelection();
Q_INT32 xradius();
Q_INT32 yradius();
private slots:
void okClicked();
private:
WdgBorderSelection * m_page;
};
#endif // DLG_BORDER_SELECTION_H
/*
* dlg_grow_selection.cc - part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 <config.h>
#include <math.h>
#include <iostream>
using namespace std;
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <klocale.h>
#include <knuminput.h>
#include <kdebug.h>
#include "dlg_grow_selection.h"
#include "wdg_grow_selection.h"
DlgGrowSelection::DlgGrowSelection( QWidget * parent, const char * name) : super (parent, name, true, i18n("Grow Selection"), Ok | Cancel, Ok)
{
m_page = new WdgGrowSelection(this, "grow_selection");
Q_CHECK_PTR(m_page);
setMainWidget(m_page);
resize(m_page->sizeHint());
connect(this, SIGNAL(okClicked()), this, SLOT(okClicked()));
}
DlgGrowSelection::~DlgGrowSelection()
{
delete m_page;
}
Q_INT32 DlgGrowSelection::xradius()
{
return m_page->radiusSpinBox->value();
}
Q_INT32 DlgGrowSelection::yradius()
{
return m_page->radiusSpinBox->value();
}
// SLOTS
void DlgGrowSelection::okClicked()
{
accept();
}
#include "dlg_grow_selection.moc"
/*
* dlg_grow_selection.h -- part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 DLG_GROW_SELECTION_H
#define DLG_GROW_SELECTION_H
#include <kdialogbase.h>
class WdgGrowSelection;
class DlgGrowSelection: public KDialogBase {
typedef KDialogBase super;
Q_OBJECT
public:
DlgGrowSelection(QWidget * parent = 0, const char* name = 0);
~DlgGrowSelection();
Q_INT32 xradius();
Q_INT32 yradius();
private slots:
void okClicked();
private:
WdgGrowSelection * m_page;
};
#endif // DLG_GROW_SELECTION_H
/*
* dlg_shrink_selection.cc - part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 <config.h>
#include <math.h>
#include <iostream>
using namespace std;
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <klocale.h>
#include <knuminput.h>
#include <kdebug.h>
#include "dlg_shrink_selection.h"
#include "wdg_shrink_selection.h"
DlgShrinkSelection::DlgShrinkSelection( QWidget * parent, const char * name) : super (parent, name, true, i18n("Shrink Selection"), Ok | Cancel, Ok)
{
m_page = new WdgShrinkSelection(this, "shrink_selection");
Q_CHECK_PTR(m_page);
setMainWidget(m_page);
resize(m_page->sizeHint());
connect(this, SIGNAL(okClicked()), this, SLOT(okClicked()));
}
DlgShrinkSelection::~DlgShrinkSelection()
{
delete m_page;
}
Q_INT32 DlgShrinkSelection::xradius()
{
return m_page->radiusSpinBox->value();
}
Q_INT32 DlgShrinkSelection::yradius()
{
return m_page->radiusSpinBox->value();
}
bool DlgShrinkSelection::shrinkFromImageBorder()
{
return m_page->shrinkFromImageBorderCheckBox->isChecked();
}
// SLOTS
void DlgShrinkSelection::okClicked()
{
accept();
}
#include "dlg_shrink_selection.moc"
/*
* dlg_shrink_selection.h -- part of Krita
*
* Copyright (c) 2006 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
*
* 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 DLG_SHRINK_SELECTION_H
#define DLG_SHRINK_SELECTION_H
#include <kdialogbase.h>
class WdgShrinkSelection;
class DlgShrinkSelection: public KDialogBase {
typedef KDialogBase super;
Q_OBJECT
public:
DlgShrinkSelection(QWidget * parent = 0, const char* name = 0);
~DlgShrinkSelection();
Q_INT32 xradius();
Q_INT32 yradius();
bool shrinkFromImageBorder();
private slots:
void okClicked();
private:
WdgShrinkSelection * m_page;
};
#endif // DLG_SHRINK_SELECTION_H
[Desktop Entry]
Encoding=UTF-8
Name=Modify Selection
ServiceTypes=Krita/ViewPlugin
Type=Service
X-KDE-Library=kritamodifyselection
X-Krita-Version=2
/*
* modify_selection.cc -- Part of Krita
*
* Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de)
*
* 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 <math.h>
#include <stdlib.h>
#include <qslider.h>
#include <qpoint.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kinstance.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <ktempfile.h>
#include <kdebug.h>
#include <kgenericfactory.h>
#include <kstdaction.h>
#include <kis_doc.h>
#include <kis_config.h>
#include <kis_image.h>
#include <kis_layer.h>
#include <kis_global.h>
#include <kis_types.h>
#include <kis_view.h>
#include <kis_selection.h>
#include <kis_selection_manager.h>
#include <kis_transaction.h>
#include "modify_selection.h"
#include "dlg_grow_selection.h"
#include "dlg_shrink_selection.h"
#include "dlg_border_selection.h"
typedef KGenericFactory<ModifySelection> ModifySelectionFactory;
K_EXPORT_COMPONENT_FACTORY( kritamodifyselection, ModifySelectionFactory( "krita" ) )
ModifySelection::ModifySelection(QObject *parent, const char *name, const QStringList &)
: KParts::Plugin(parent, name)
{
if ( parent->inherits("KisView") )
{
setInstance(ModifySelectionFactory::instance());
setXMLFile(locate("data","kritaplugins/modify_selection.rc"), true);
m_view = (KisView*) parent;
// Selection manager takes ownership?
KAction* a = new KAction(i18n("Grow selection..."), 0, 0, this, SLOT(slotGrowSelection()), actionCollection(), "growselection");
KAction* b = new KAction(i18n("Shrink selection..."), 0, 0, this, SLOT(slotShrinkSelection()), actionCollection(), "shrinkselection");
KAction* c = new KAction(i18n("Border selection..."), 0, 0, this, SLOT(slotBorderSelection()), actionCollection(), "borderselection");
Q_CHECK_PTR(a);
Q_CHECK_PTR(b);
Q_CHECK_PTR(c);
m_view ->canvasSubject()-> selectionManager()->addSelectionAction(a);
m_view ->canvasSubject()-> selectionManager()->addSelectionAction(b);
m_view ->canvasSubject()-> selectionManager()->addSelectionAction(c);
}
}
ModifySelection::~ModifySelection()
{
m_view = 0;
}
void ModifySelection::slotGrowSelection()
{
KisImageSP image = m_view->canvasSubject()->currentImg();
if (!image) return;
DlgGrowSelection * dlgGrowSelection = new DlgGrowSelection(m_view, "GrowSelection");
Q_CHECK_PTR(dlgGrowSelection);
dlgGrowSelection->setCaption(i18n("Grow Selection"));
KisConfig cfg;
if (dlgGrowSelection->exec() == QDialog::Accepted) {
Q_INT32 xradius = dlgGrowSelection->xradius();
Q_INT32 yradius = dlgGrowSelection->yradius();
m_view ->canvasSubject()-> selectionManager()->grow(xradius, yradius);
}
delete dlgGrowSelection;
}
void ModifySelection::slotShrinkSelection()
{
KisImageSP image = m_view->canvasSubject()->currentImg();
if (!image) return;
DlgShrinkSelection * dlgShrinkSelection = new DlgShrinkSelection(m_view, "ShrinkSelection");
Q_CHECK_PTR(dlgShrinkSelection);
dlgShrinkSelection->setCaption(i18n("Shrink Selection"));
KisConfig cfg;
if (dlgShrinkSelection->exec() == QDialog::Accepted) {
Q_INT32 xradius = dlgShrinkSelection->xradius();
Q_INT32 yradius = dlgShrinkSelection->yradius();
bool shrinkFromImageBorder = dlgShrinkSelection->shrinkFromImageBorder();
m_view ->canvasSubject()-> selectionManager()->shrink(xradius, yradius, shrinkFromImageBorder);
}
delete dlgShrinkSelection;
}
void ModifySelection::slotBorderSelection()
{
KisImageSP image = m_view->canvasSubject()->currentImg();
if (!image) return;
DlgBorderSelection * dlgBorderSelection = new DlgBorderSelection(m_view, "BorderSelection");
Q_CHECK_PTR(dlgBorderSelection);
dlgBorderSelection->setCaption(i18n("Border Selection"));
KisConfig cfg;
if (dlgBorderSelection->exec() == QDialog::Accepted) {
Q_INT32 xradius = dlgBorderSelection->xradius();
Q_INT32 yradius = dlgBorderSelection->yradius();
m_view ->canvasSubject()-> selectionManager()->border(xradius, yradius);
}
delete dlgBorderSelection;
}
#include "modify_selection.moc"
/*
* modify_selection.h -- Part of Krita
*
* Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de)
*
* 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 MODIFY_SELECTION_H
#define MODIFY_SELECTION_H
#include <kparts/plugin.h>
class KisView;
class ModifySelection : public KParts::Plugin
{
Q_OBJECT
public:
ModifySelection(QObject *parent, const char *name, const QStringList &);
virtual ~ModifySelection();
private slots:
void slotGrowSelection();
void slotShrinkSelection();
void slotBorderSelection();
private:
KisView * m_view;
};
#endif // MODIFY_SELECTION_H
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui library="kritamodifyselection" version="6">
<MenuBar>
<Menu name="Select"><text>&amp;Select</text>
<Action name="growselection"/>
<Action name="shrinkselection"/>
<Action name="borderselection"/>
</Menu>
</MenuBar>
</kpartgui>
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>WdgBorderSelection</class>
<widget class="QWidget">
<property name="name">
<cstring>WdgBorderSelection</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>101</height>
</rect>
</property>
<property name="caption">
<string>WdgBorderSelection</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Border selection by</string>
</property>