diff options
Diffstat (limited to 'krita/plugins/viewplugins/shearimage')
-rw-r--r-- | krita/plugins/viewplugins/shearimage/Makefile.am | 24 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/dlg_shearimage.cc | 96 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/dlg_shearimage.h | 54 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/kritashearimage.desktop | 37 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/shearimage.cc | 113 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/shearimage.h | 46 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/shearimage.rc | 13 | ||||
-rw-r--r-- | krita/plugins/viewplugins/shearimage/wdg_shearimage.ui | 102 |
8 files changed, 485 insertions, 0 deletions
diff --git a/krita/plugins/viewplugins/shearimage/Makefile.am b/krita/plugins/viewplugins/shearimage/Makefile.am new file mode 100644 index 00000000..3c085d45 --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/Makefile.am @@ -0,0 +1,24 @@ +kritarcdir = $(kde_datadir)/kritaplugins +kritarc_DATA = shearimage.rc + +EXTRA_DIST = $(kritarc_DATA) + + +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../kritacolor/ \ + -I$(srcdir)/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +kde_module_LTLIBRARIES = kritashearimage.la + +kde_services_DATA = kritashearimage.desktop + +kritashearimage_la_SOURCES = wdg_shearimage.ui shearimage.cc dlg_shearimage.cc +noinst_HEADERS = wdg_shearimage.h dlg_shearimage.h shearimage.h + +kritashearimage_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kritashearimage_la_LIBADD = ../../../libkritacommon.la + +kritashearimage_la_METASOURCES = AUTO diff --git a/krita/plugins/viewplugins/shearimage/dlg_shearimage.cc b/krita/plugins/viewplugins/shearimage/dlg_shearimage.cc new file mode 100644 index 00000000..9a6a2f66 --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/dlg_shearimage.cc @@ -0,0 +1,96 @@ +/* + * dlg_shearimage.cc - part of KimageShop^WKrayon^WKrita + * + * Copyright (c) 2004 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 <qlabel.h> +#include <qlayout.h> + +#include <klocale.h> +#include <knuminput.h> +#include <kdebug.h> + +#include "dlg_shearimage.h" +#include "wdg_shearimage.h" + + +DlgShearImage::DlgShearImage( QWidget * parent, + const char * name) + : super (parent, name, true, i18n("Shear Image"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgShearImage(this, "shear_image"); + m_page->layout()->setMargin(0); + Q_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, SIGNAL(okClicked()), + this, SLOT(okClicked())); + +} + +DlgShearImage::~DlgShearImage() +{ + delete m_page; +} + +void DlgShearImage::setAngleX(Q_UINT32 angle) +{ + m_page->shearAngleX->setValue(angle); + m_oldAngle = angle; + +} + +void DlgShearImage::setAngleY(Q_UINT32 angle) +{ + m_page->shearAngleY->setValue(angle); + m_oldAngle = angle; + +} + +Q_INT32 DlgShearImage::angleX() +{ + return (Q_INT32)qRound(m_page->shearAngleX->value()); +} + +Q_INT32 DlgShearImage::angleY() +{ + return (Q_INT32)qRound(m_page->shearAngleY->value()); +} + +// SLOTS + +void DlgShearImage::okClicked() +{ + accept(); +} + +#include "dlg_shearimage.moc" diff --git a/krita/plugins/viewplugins/shearimage/dlg_shearimage.h b/krita/plugins/viewplugins/shearimage/dlg_shearimage.h new file mode 100644 index 00000000..183f166a --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/dlg_shearimage.h @@ -0,0 +1,54 @@ +/* + * dlg_shearimage.h -- part of KimageShop^WKrayon^WKrita + * + * Copyright (c) 2004 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_SHEARIMAGE +#define DLG_SHEARIMAGE + +#include <kdialogbase.h> + +class WdgShearImage; + +class DlgShearImage: public KDialogBase { + typedef KDialogBase super; + Q_OBJECT + +public: + + DlgShearImage(QWidget * parent = 0, + const char* name = 0); + ~DlgShearImage(); + + void setAngleX(Q_UINT32 w); + void setAngleY(Q_UINT32 w); + Q_INT32 angleX(); + Q_INT32 angleY(); + +private slots: + + void okClicked(); + +private: + + WdgShearImage * m_page; + double m_oldAngle; + bool m_lock; + +}; + +#endif // DLG_SHEARIMAGE diff --git a/krita/plugins/viewplugins/shearimage/kritashearimage.desktop b/krita/plugins/viewplugins/shearimage/kritashearimage.desktop new file mode 100644 index 00000000..1b1e8ad0 --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/kritashearimage.desktop @@ -0,0 +1,37 @@ +[Desktop Entry] +Name=Shear Image Plugin +Name[bg]=Приставка за отрязване на изображение +Name[ca]=Connector de tall d'imatge +Name[da]=Plugin for skævvrid billede +Name[de]="Bild scheren"-Modul +Name[el]=Πρόσθετο στρέβλωσης εικόνας +Name[es]=Complemento para cortar la imagen +Name[et]=Pildinihke plugin +Name[fa]=اشتراک وصلۀ تصویر +Name[fr]=Module de rognage d'images +Name[fy]=Ofbylding skeanlûke plugin +Name[gl]=Plugin de Inclinación da Imaxe +Name[hu]=Képnyíró modul +Name[is]=Klippa mynd íforrit +Name[it]=Plugin di distorsione delle immagini +Name[ja]=画像剪断変形プラグイン +Name[km]=កម្មវិធីជំនួយដើម្បីកាត់រូបភាព +Name[nb]=Programtillegg for bildeskjæring +Name[nds]=Bildscheer-Moduul +Name[ne]=छवि प्लगइन अपूर्ण गर्नुहोस् +Name[nl]=Afbeelding schuintrekken +Name[pl]=Wtyczka obcinania obrazków +Name[pt]='Plugin' de Inclinação da Imagem +Name[pt_BR]=Plugin de Inclinação da Imagem +Name[ru]=Сдвиг +Name[sk]=Modul roztrhnutie obrázku +Name[sl]=Vstavek Ostriži sliko +Name[sr]=Прикључак за смицање слике +Name[sr@Latn]=Priključak za smicanje slike +Name[sv]=Insticksprogram för skjuva bild +Name[uk]=Втулок перекошення зображення +Name[zh_TW]=修剪圖片外掛程式 +ServiceTypes=Krita/ViewPlugin +Type=Service +X-KDE-Library=kritashearimage +X-Krita-Version=2 diff --git a/krita/plugins/viewplugins/shearimage/shearimage.cc b/krita/plugins/viewplugins/shearimage/shearimage.cc new file mode 100644 index 00000000..d8c839ce --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/shearimage.cc @@ -0,0 +1,113 @@ +/* + * shearimage.cc -- Part of Krita + * + * Copyright (c) 2004 Michael Thaler + * + * 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 <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 "shearimage.h" +#include "dlg_shearimage.h" + +typedef KGenericFactory<ShearImage> ShearImageFactory; +K_EXPORT_COMPONENT_FACTORY( kritashearimage, ShearImageFactory( "krita" ) ) + +// XXX: this plugin could also provide layer scaling/resizing +ShearImage::ShearImage(QObject *parent, const char *name, const QStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(ShearImageFactory::instance()); + setXMLFile(locate("data","kritaplugins/shearimage.rc"), true); + + (void) new KAction(i18n("&Shear Image..."), 0, 0, this, SLOT(slotShearImage()), actionCollection(), "shearimage"); + (void) new KAction(i18n("&Shear Layer..."), 0, 0, this, SLOT(slotShearLayer()), actionCollection(), "shearlayer"); + + m_view = (KisView*) parent; + } +} + +ShearImage::~ShearImage() +{ + m_view = 0; +} + +void ShearImage::slotShearImage() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearImage"); + Q_CHECK_PTR(dlgShearImage); + + dlgShearImage->setCaption(i18n("Shear Image")); + + if (dlgShearImage->exec() == QDialog::Accepted) { + Q_INT32 angleX = dlgShearImage->angleX(); + Q_INT32 angleY = dlgShearImage->angleY(); + m_view->shearCurrentImage(angleX, angleY); + } + delete dlgShearImage; +} + +void ShearImage::slotShearLayer() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearLayer"); + Q_CHECK_PTR(dlgShearImage); + + dlgShearImage->setCaption(i18n("Shear Layer")); + + if (dlgShearImage->exec() == QDialog::Accepted) { + Q_INT32 angleX = dlgShearImage->angleX(); + Q_INT32 angleY = dlgShearImage->angleY(); + m_view->shearLayer(angleX, angleY); + + } + delete dlgShearImage; +} + +#include "shearimage.moc" diff --git a/krita/plugins/viewplugins/shearimage/shearimage.h b/krita/plugins/viewplugins/shearimage/shearimage.h new file mode 100644 index 00000000..bfff2ac2 --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/shearimage.h @@ -0,0 +1,46 @@ +/* + * shearimage.h -- Part of Krita + * + * Copyright (c) 2004 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 SHEARIMAGE_H +#define SHEARIMAGE_H + +#include <kparts/plugin.h> + +class KisView; + +class ShearImage : public KParts::Plugin +{ + Q_OBJECT +public: + ShearImage(QObject *parent, const char *name, const QStringList &); + virtual ~ShearImage(); + +private slots: + + void slotShearImage(); + void slotShearLayer(); + +private: + + KisView * m_view; + KisPainter * m_painter; + +}; + +#endif // SHEARIMAGE_H diff --git a/krita/plugins/viewplugins/shearimage/shearimage.rc b/krita/plugins/viewplugins/shearimage/shearimage.rc new file mode 100644 index 00000000..c13e341f --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/shearimage.rc @@ -0,0 +1,13 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui library="kritashearimage" version="6"> +<MenuBar> + <Menu name="Image"><text>&Image</text> + <Separator/> + <Action name="shearimage"/> + </Menu> + <Menu name="Layer"><text>La&yer</text> + <Separator/> + <Action name="shearlayer"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/krita/plugins/viewplugins/shearimage/wdg_shearimage.ui b/krita/plugins/viewplugins/shearimage/wdg_shearimage.ui new file mode 100644 index 00000000..20de0b6b --- /dev/null +++ b/krita/plugins/viewplugins/shearimage/wdg_shearimage.ui @@ -0,0 +1,102 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>WdgShearImage</class> +<widget class="QWidget"> + <property name="name"> + <cstring>WdgShearImage</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>323</width> + <height>114</height> + </rect> + </property> + <property name="caption"> + <string>Shear Image</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup" row="0" column="0"> + <property name="name"> + <cstring>grpPixelDimensions</cstring> + </property> + <property name="title"> + <string>&Shear Image</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>shearAngleX</cstring> + </property> + <property name="minValue"> + <number>-45</number> + </property> + <property name="maxValue"> + <number>45</number> + </property> + <property name="suffix"> + <string>°</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>lblShearAngelY</cstring> + </property> + <property name="text"> + <string>Shear angle Y:</string> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>shearAngleY</cstring> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>100</height> + </size> + </property> + <property name="minValue"> + <number>-45</number> + </property> + <property name="maxValue"> + <number>45</number> + </property> + <property name="suffix"> + <string>°</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lblShearAngleX</cstring> + </property> + <property name="text"> + <string>Shear angle X:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>intWidth</cstring> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<tabstops> + <tabstop>shearAngleX</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> |