├── distr
├── deb
│ ├── debian
│ │ ├── compat
│ │ ├── docs
│ │ ├── source
│ │ │ └── format
│ │ ├── rules
│ │ ├── changelog
│ │ ├── control
│ │ └── copyright
│ └── make_deb.sh
└── rpm
│ ├── _service
│ └── easypaint.spec
├── sources
├── media
│ ├── logo
│ │ ├── easypaint_512.png
│ │ ├── easypaint_64.png
│ │ └── easypaint_srs.cdr
│ ├── actions-icons
│ │ ├── zoom-in.png
│ │ ├── edit-copy.png
│ │ ├── edit-cut.png
│ │ ├── edit-redo.png
│ │ ├── edit-undo.png
│ │ ├── zoom-out.png
│ │ ├── clear-gray.png
│ │ ├── document-new.png
│ │ ├── edit-paste.png
│ │ ├── help-about.png
│ │ ├── window-close.png
│ │ ├── document-open.png
│ │ ├── document-print.png
│ │ ├── document-save.png
│ │ ├── application-exit.png
│ │ ├── document-save-as.png
│ │ ├── document-properties.png
│ │ ├── object-rotate-left.png
│ │ └── object-rotate-right.png
│ ├── textures
│ │ └── transparent.jpg
│ └── instruments-icons
│ │ ├── curve.png
│ │ ├── fill.png
│ │ ├── line.png
│ │ ├── loupe.png
│ │ ├── spray.png
│ │ ├── text.png
│ │ ├── cursor.png
│ │ ├── ellipse.png
│ │ ├── lastic.png
│ │ ├── pencil.png
│ │ ├── pipette.png
│ │ ├── rectangle.png
│ │ ├── cursor_fill.png
│ │ ├── cursor_loupe.png
│ │ ├── cursor_spray.png
│ │ └── cursor_pipette.png
├── widgets
│ ├── palettebutton.h
│ ├── palettebutton.cpp
│ ├── abstracteffectsettings.h
│ ├── imagepreview.h
│ ├── sharpenfiltersettings.h
│ ├── imagepreview.cpp
│ ├── gaussianblurfiltersettings.h
│ ├── shortcutedit.h
│ ├── customfiltersettings.h
│ ├── palettebar.h
│ ├── sharpenfiltersettings.cpp
│ ├── gaussianblurfiltersettings.cpp
│ ├── colorchooser.h
│ ├── colorchooser.cpp
│ ├── customfiltersettings.cpp
│ ├── toolbar.h
│ ├── shortcutedit.cpp
│ └── palettebar.cpp
├── effects
│ ├── abstracteffect.cpp
│ ├── grayeffect.h
│ ├── negativeeffect.cpp
│ ├── negativeeffect.h
│ ├── customeffect.h
│ ├── gammaeffect.h
│ ├── sharpeneffect.h
│ ├── binarizationeffect.h
│ ├── effectwithsettings.cpp
│ ├── gaussianblureffect.h
│ ├── effectwithsettings.h
│ ├── grayeffect.cpp
│ ├── abstracteffect.h
│ ├── binarizationeffect.cpp
│ └── gammaeffect.cpp
├── instruments
│ ├── abstractinstrument.cpp
│ ├── lineinstrument.h
│ ├── sprayinstrument.h
│ ├── eraserinstrument.h
│ ├── pencilinstrument.h
│ ├── ellipseinstrument.h
│ ├── magnifierinstrument.h
│ ├── rectangleinstrument.h
│ ├── colorpickerinstrument.h
│ ├── fillinstrument.h
│ ├── curvelineinstrument.h
│ ├── magnifierinstrument.cpp
│ ├── textinstrument.h
│ ├── abstractinstrument.h
│ ├── selectioninstrument.h
│ ├── abstractselection.h
│ ├── colorpickerinstrument.cpp
│ ├── eraserinstrument.cpp
│ ├── textinstrument.cpp
│ ├── ellipseinstrument.cpp
│ ├── rectangleinstrument.cpp
│ ├── pencilinstrument.cpp
│ ├── lineinstrument.cpp
│ ├── fillinstrument.cpp
│ ├── sprayinstrument.cpp
│ └── curvelineinstrument.cpp
├── undocommand.cpp
├── undocommand.h
├── dialogs
│ ├── textdialog.h
│ ├── effectsettingsdialog.h
│ ├── resizedialog.h
│ ├── settingsdialog.h
│ ├── textdialog.cpp
│ └── effectsettingsdialog.cpp
├── easypaintenums.h
├── resources.qrc
├── additionaltools.h
├── main.cpp
├── easypaint.pro
├── additionaltools.cpp
└── mainwindow.h
├── AUTHORS
├── .gitignore
├── README.md
├── THANKS
└── COPYING
/distr/deb/debian/compat:
--------------------------------------------------------------------------------
1 | 8
2 |
--------------------------------------------------------------------------------
/distr/deb/debian/docs:
--------------------------------------------------------------------------------
1 | README.md
2 |
--------------------------------------------------------------------------------
/distr/deb/debian/source/format:
--------------------------------------------------------------------------------
1 | 3.0 (quilt)
2 |
--------------------------------------------------------------------------------
/sources/media/logo/easypaint_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/logo/easypaint_512.png
--------------------------------------------------------------------------------
/sources/media/logo/easypaint_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/logo/easypaint_64.png
--------------------------------------------------------------------------------
/sources/media/logo/easypaint_srs.cdr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/logo/easypaint_srs.cdr
--------------------------------------------------------------------------------
/sources/media/actions-icons/zoom-in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/zoom-in.png
--------------------------------------------------------------------------------
/sources/media/textures/transparent.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/textures/transparent.jpg
--------------------------------------------------------------------------------
/sources/media/actions-icons/edit-copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/edit-copy.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/edit-cut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/edit-cut.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/edit-redo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/edit-redo.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/edit-undo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/edit-undo.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/zoom-out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/zoom-out.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/curve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/curve.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/fill.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/line.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/line.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/loupe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/loupe.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/spray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/spray.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/text.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/clear-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/clear-gray.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-new.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/edit-paste.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/edit-paste.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/help-about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/help-about.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/window-close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/window-close.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/cursor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/cursor.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/ellipse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/ellipse.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/lastic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/lastic.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/pencil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/pencil.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/pipette.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/pipette.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-open.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-print.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-print.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-save.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/rectangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/rectangle.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/application-exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/application-exit.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-save-as.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-save-as.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/cursor_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/cursor_fill.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/cursor_loupe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/cursor_loupe.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/cursor_spray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/cursor_spray.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/document-properties.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/document-properties.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/object-rotate-left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/object-rotate-left.png
--------------------------------------------------------------------------------
/sources/media/actions-icons/object-rotate-right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/actions-icons/object-rotate-right.png
--------------------------------------------------------------------------------
/sources/media/instruments-icons/cursor_pipette.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gr1N/EasyPaint/HEAD/sources/media/instruments-icons/cursor_pipette.png
--------------------------------------------------------------------------------
/distr/rpm/_service:
--------------------------------------------------------------------------------
1 |
2 | gitgit://github.com/Gr1N/EasyPaint.git0.1.1
3 | bz2*.tar
--------------------------------------------------------------------------------
/AUTHORS:
--------------------------------------------------------------------------------
1 | Developers:
2 | -----------
3 |
4 | Nikita Grishko (Gr1N)
5 | Artem Stepanyuk (faulknercs)
6 | Denis Klimenko (DenisKlimenko)
7 | BahdanSiamionau (Bahdan)
8 | Alexander Shlemin
9 |
--------------------------------------------------------------------------------
/sources/widgets/palettebutton.h:
--------------------------------------------------------------------------------
1 | #ifndef QPALETTEBUTTON_H
2 | #define QPALETTEBUTTON_H
3 |
4 | #include "../datasingleton.h"
5 |
6 | #include
7 |
8 | class PaletteButton : public QToolButton
9 | {
10 | Q_OBJECT
11 |
12 | public:
13 | PaletteButton(const QColor &color);
14 |
15 | signals:
16 | void colorPicked();
17 |
18 | private:
19 | QColor mColor;
20 |
21 | protected:
22 | void mousePressEvent(QMouseEvent *event);
23 | };
24 |
25 | #endif // QPALETTEBUTTON_H
26 |
--------------------------------------------------------------------------------
/distr/deb/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 | # -*- makefile -*-
3 | # Sample debian/rules that uses debhelper.
4 | # This file was originally written by Joey Hess and Craig Small.
5 | # As a special exception, when this file is copied by dh-make into a
6 | # dh-make output file, you may use that output file without restriction.
7 | # This special exception was added by Craig Small in version 0.37 of dh-make.
8 |
9 | # Uncomment this to turn on verbose mode.
10 | #export DH_VERBOSE=1
11 |
12 | %:
13 | dh $@
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build dirs and files #
2 | ########################
3 | easypaint.pro.user
4 | easypaint-build-*
5 |
6 | # Compiled source #
7 | ###################
8 | *.dll
9 | *.exe
10 | *.o
11 | *.so
12 |
13 | # Packages #
14 | ############
15 | # it's better to unpack these files and commit the raw source
16 | # git has its own built in compression methods
17 | *.7z
18 | *.dmg
19 | *.gz
20 | *.iso
21 | *.jar
22 | *.rar
23 | *.tar
24 | *.zip
25 |
26 | # OS generated files #
27 | ######################
28 | .DS_Store*
29 | ehthumbs.db
30 | Icon?
31 | Thumbs.db
32 |
--------------------------------------------------------------------------------
/distr/deb/debian/changelog:
--------------------------------------------------------------------------------
1 | easypaint (0.1.1-1) stable; urgency=low
2 |
3 | * Added Qt5 support
4 |
5 | -- Nikita Grishko Fri, 24 May 2013 23:35:00 +0300
6 |
7 |
8 | easypaint (0.1.0-1) stable; urgency=low
9 |
10 | * First release
11 |
12 | -- Nikita Grishko Thu, 10 Apr 2012 17:19:00 +0300
13 |
14 |
15 | easypaint (0.0.1-1) unstable; urgency=low
16 |
17 | * Initial release (Closes: #0001)
18 |
19 | -- Artem Stepanyuk Sun, 01 Apr 2012 01:11:33 +0300
20 |
--------------------------------------------------------------------------------
/distr/deb/debian/control:
--------------------------------------------------------------------------------
1 | Source: easypaint
2 | Section: graphics
3 | Priority: optional
4 | Maintainer: Artem Stepanyuk
5 | Build-Depends: debhelper (>= 8.0.0), cmake, gcc, make, libqt4-dev
6 | Standards-Version: 3.9.2
7 | Homepage: https://github.com/Gr1N/EasyPaint/
8 | Vcs-Git: git://github.com/Gr1N/EasyPaint.git
9 |
10 | Package: easypaint
11 | Architecture: any
12 | Depends: ${shlibs:Depends}, ${misc:Depends}, libqtcore4, libqtgui4
13 | Description: EasyPaint is a simple graphics painting program.
14 | EasyPaint is a simple graphics painting program written with Qt.
15 |
--------------------------------------------------------------------------------
/sources/widgets/palettebutton.cpp:
--------------------------------------------------------------------------------
1 | #include "palettebutton.h"
2 |
3 | #include
4 |
5 | PaletteButton::PaletteButton(const QColor &color)
6 | {
7 | mColor = color;
8 | setMinimumSize(QSize(30, 30));
9 | setMaximumSize(QSize(30, 30));
10 | QPixmap pixmap(20, 20);
11 | pixmap.fill(color);
12 | setIcon(pixmap);
13 | setStatusTip(color.name());
14 | }
15 |
16 | void PaletteButton::mousePressEvent(QMouseEvent *event)
17 | {
18 | if(event->button() == Qt::LeftButton)
19 | DataSingleton::Instance()->setPrimaryColor(mColor);
20 | else if(event->button() == Qt::RightButton)
21 | DataSingleton::Instance()->setSecondaryColor(mColor);
22 |
23 | emit colorPicked();
24 | }
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | EasyPaint
2 | =========
3 |
4 | EasyPaint is a simple graphics painting program
5 |
6 | You may watch screenshots [here](http://qt-apps.org/content/show.php?content=140877).
7 |
8 | EasyPaint is a part of QtDesktop project.
9 |
10 | EasyPaint is a part of [Razor-qt's](https://github.com/Razor-qt) [3rd party applications](https://github.com/Razor-qt/razor-qt/wiki/3rd-party-applications).
11 |
12 | Installing
13 | ----------
14 |
15 | Install EasyPaint using the commands, if you use CMake:
16 |
17 | cd ./EasyPaint
18 | cmake -DCMAKE_INSTALL_PREFIX=/usr
19 | make
20 | make install
21 |
22 | Install EasyPaint using the commands, if you use qmake:
23 |
24 | cd ./EasyPaint/sources
25 | lrelease easypaint.pro
26 | qmake
27 | make
28 | make install
29 |
30 | Also you could find packages for linux distributions [here](http://qt-apps.org/content/show.php?content=140877).
31 |
32 | License
33 | -------
34 |
35 | EasyPaint is distributed under the [MIT license](http://www.opensource.org/licenses/MIT).
36 |
--------------------------------------------------------------------------------
/THANKS:
--------------------------------------------------------------------------------
1 | What's this file about?
2 | -----------------------
3 | This file lists all external people that have contributed to this project.
4 | If any contributors are missing, please email the developers - see the AUTHORS file.
5 |
6 | Testers and contributors:
7 | -------------------------
8 | These people have contributed to EasyPaint by testing the software,
9 | reporting problems, sending patches and making useful suggestions:
10 |
11 | Jerome Leclanche
12 | TI_Eugene
13 | bruceoutdoors
14 |
15 | Translators:
16 | ------------
17 | These people have translated EasyPaint to foreign languages:
18 |
19 | Pavel Fric - cs_CZ
20 | Jerome Leclanche - fr_FR
21 | Congxian Qiu - zh_CN
22 |
23 | Graphical part:
24 | ---------------
25 | These people have done work on graphical part of EasyPaint:
26 |
27 | Darya Mankevich - created logo
28 |
29 | Projects:
30 | ---------
31 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 EasyPaint
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included
12 | in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/distr/rpm/easypaint.spec:
--------------------------------------------------------------------------------
1 | # norootforbuild
2 |
3 | Name: easypaint
4 | Version: 0.1.1
5 | Release: 0
6 | License: MIT
7 | Vendor: Nikita Grishko
8 | Source: EasyPaint-%{version}.tar.bz2
9 | Group: Graphics
10 | Summary: Easy graphic editing program
11 | BuildRequires: gcc-c++, cmake, pkgconfig(QtGui)
12 | %if 0%{?suse_version}
13 | BuildRequires: update-desktop-files
14 | %endif
15 | BuildRoot: %{_tmppath}/%{name}-%{version}-build
16 |
17 | %description
18 | %{summary}
19 |
20 | %prep
21 | %setup -q -n EasyPaint-%{version}
22 |
23 | %build
24 | mkdir build
25 | pushd build
26 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=release
27 | make
28 | popd
29 |
30 | %install
31 | %{__rm} -rf %{buildroot}
32 | pushd build
33 | make DESTDIR=%{buildroot} install
34 | popd
35 | %if 0%{?suse_version}
36 | %suse_update_desktop_file %{name}
37 | %endif
38 |
39 | %clean
40 | %{__rm} -rf %{buildroot}
41 |
42 | %files
43 | %defattr(-,root,root,-)
44 | %{_bindir}/%{name}
45 | %{_datadir}/%{name}/
46 | %{_datadir}/applications/%{name}.desktop
47 | %{_datadir}/pixmaps/%{name}_64.png
48 |
49 | %changelog
50 | * Thu Apr 10 2012 Gr1N
51 | - 0.1.0, first release
52 | * Fri Apr 15 2011 TI_Eugene
53 | - 0.0.1, initial OBS release
54 |
--------------------------------------------------------------------------------
/sources/effects/abstracteffect.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "abstracteffect.h"
27 | #include "../undocommand.h"
28 | #include "../imagearea.h"
29 |
30 | AbstractEffect::AbstractEffect(QObject *parent) :
31 | QObject(parent)
32 | {
33 | }
34 |
35 | void AbstractEffect::makeUndoCommand(ImageArea &imageArea)
36 | {
37 | imageArea.pushUndoCommand(new UndoCommand(imageArea.getImage(), imageArea));
38 | }
39 |
--------------------------------------------------------------------------------
/sources/instruments/abstractinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "abstractinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../undocommand.h"
29 |
30 | AbstractInstrument::AbstractInstrument(QObject *parent) :
31 | QObject(parent)
32 | {
33 | }
34 |
35 | void AbstractInstrument::makeUndoCommand(ImageArea &imageArea)
36 | {
37 | imageArea.pushUndoCommand(new UndoCommand(imageArea.getImage(), imageArea));
38 | }
39 |
--------------------------------------------------------------------------------
/sources/effects/grayeffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef GRAYEFFECT_H
27 | #define GRAYEFFECT_H
28 |
29 | #include "abstracteffect.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Gray effect class.
35 | *
36 | */
37 | class GrayEffect : public AbstractEffect
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit GrayEffect(QObject *parent = 0);
42 |
43 | void applyEffect(ImageArea &imageArea);
44 |
45 | };
46 |
47 | #endif // GRAYEFFECT_H
48 |
--------------------------------------------------------------------------------
/sources/widgets/abstracteffectsettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ABSTRACTEFFECTWIDGET_H
27 | #define ABSTRACTEFFECTWIDGET_H
28 |
29 | #include
30 |
31 | class AbstractEffectSettings : public QWidget
32 | {
33 | Q_OBJECT
34 | signals:
35 | void matrixChanged();
36 | public:
37 | explicit AbstractEffectSettings(QWidget *parent = 0) : QWidget(parent) {}
38 |
39 | QList virtual getConvolutionMatrix() = 0;
40 | };
41 |
42 | #endif // ABSTRACTEFFECTWIDGET_H
43 |
--------------------------------------------------------------------------------
/sources/widgets/imagepreview.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef IMAGEPREVIEW_H
27 | #define IMAGEPREVIEW_H
28 |
29 | #include
30 |
31 | class ImagePreview : public QWidget
32 | {
33 | Q_OBJECT
34 | public:
35 | explicit ImagePreview(QImage *image, QWidget *parent);
36 |
37 | signals:
38 |
39 | public slots:
40 |
41 | protected:
42 | virtual void paintEvent(QPaintEvent *event);
43 |
44 | private:
45 | QImage *mImage;
46 | };
47 |
48 | #endif // IMAGEPREVIEW_H
49 |
--------------------------------------------------------------------------------
/sources/effects/negativeeffect.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "negativeeffect.h"
27 | #include "../imagearea.h"
28 |
29 | NegativeEffect::NegativeEffect(QObject *parent) :
30 | AbstractEffect(parent)
31 | {
32 | }
33 |
34 | void NegativeEffect::applyEffect(ImageArea &imageArea)
35 | {
36 | imageArea.clearSelection();
37 | makeUndoCommand(imageArea);
38 |
39 | imageArea.getImage()->invertPixels(QImage::InvertRgb);
40 | imageArea.setEdited(true);
41 | imageArea.update();
42 | }
43 |
--------------------------------------------------------------------------------
/sources/effects/negativeeffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef NEGATIVEEFFECT_H
27 | #define NEGATIVEEFFECT_H
28 |
29 | #include "abstracteffect.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Negative effect class.
35 | *
36 | */
37 | class NegativeEffect : public AbstractEffect
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit NegativeEffect(QObject *parent = 0);
43 |
44 | void applyEffect(ImageArea &imageArea);
45 |
46 | };
47 |
48 | #endif // NEGATIVEEFFECT_H
49 |
--------------------------------------------------------------------------------
/sources/effects/customeffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef CUSTOMEFFECT_H
27 | #define CUSTOMEFFECT_H
28 |
29 | #include "effectwithsettings.h"
30 | #include "../widgets/customfiltersettings.h"
31 |
32 | class CustomEffect : public EffectWithSettings
33 | {
34 | Q_OBJECT
35 | public:
36 | explicit CustomEffect(QObject *parent = 0) : EffectWithSettings(parent) {}
37 |
38 | protected:
39 | virtual AbstractEffectSettings* getSettingsWidget() { return new CustomFilterSettings(); }
40 | };
41 |
42 | #endif // CUSTOMEFFECT_H
43 |
--------------------------------------------------------------------------------
/sources/widgets/sharpenfiltersettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SHARPENFILTERSETTINGS_H
27 | #define SHARPENFILTERSETTINGS_H
28 |
29 | #include
30 |
31 | #include "abstracteffectsettings.h"
32 |
33 | class SharpenFilterSettings : public AbstractEffectSettings
34 | {
35 | Q_OBJECT
36 | public:
37 | explicit SharpenFilterSettings(QWidget *parent = 0);
38 |
39 | protected:
40 | virtual QList getConvolutionMatrix();
41 |
42 | private:
43 | QSlider *mIntensitySlider;
44 | };
45 |
46 | #endif // SHARPENFILTERSETTINGS_H
47 |
--------------------------------------------------------------------------------
/sources/effects/gammaeffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef GAMMAEFFECT_H
27 | #define GAMMAEFFECT_H
28 |
29 | #include "abstracteffect.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Gray effect class.
35 | *
36 | */
37 | class GammaEffect : public AbstractEffect
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit GammaEffect(QObject *parent = 0);
42 |
43 | void applyEffect(ImageArea &imageArea);
44 |
45 | private:
46 | void makeGamma(ImageArea &imageArea, float modificator);
47 | };
48 |
49 | #endif // GAMMAEFFECT_H
50 |
--------------------------------------------------------------------------------
/sources/widgets/imagepreview.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include "imagepreview.h"
31 |
32 | ImagePreview::ImagePreview(QImage *image, QWidget *parent) :
33 | QWidget(parent)
34 | {
35 | mImage = image;
36 | }
37 |
38 | void ImagePreview::paintEvent(QPaintEvent *event)
39 | {
40 | if(mImage)
41 | {
42 | QPainter *painter = new QPainter(this);
43 |
44 | painter->drawImage(event->rect(), *mImage, event->rect());
45 |
46 | painter->end();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sources/widgets/gaussianblurfiltersettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef GAUSSIANBLURFILTERSETTINGS_H
27 | #define GAUSSIANBLURFILTERSETTINGS_H
28 |
29 | #include
30 |
31 | #include "abstracteffectsettings.h"
32 |
33 | class GaussianBlurFilterSettings : public AbstractEffectSettings
34 | {
35 | Q_OBJECT
36 | public:
37 | explicit GaussianBlurFilterSettings(QWidget *parent = 0);
38 |
39 | protected:
40 | virtual QList getConvolutionMatrix();
41 |
42 | private:
43 | QSlider *mIntensitySlider;
44 |
45 | };
46 |
47 | #endif // GAUSSIANBLURFILTERSETTINGS_H
48 |
--------------------------------------------------------------------------------
/sources/effects/sharpeneffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SHARPENEFFECT_H
27 | #define SHARPENEFFECT_H
28 |
29 | #include "effectwithsettings.h"
30 | #include "../widgets/sharpenfiltersettings.h"
31 |
32 | #include
33 |
34 | class SharpenEffect : public EffectWithSettings
35 | {
36 | Q_OBJECT
37 | public:
38 | explicit SharpenEffect(QObject *parent = 0) : EffectWithSettings(parent) {}
39 |
40 | protected:
41 | // TODO: change type of widget
42 | virtual AbstractEffectSettings *getSettingsWidget() { return new SharpenFilterSettings(); }
43 | };
44 |
45 | #endif // SHARPENEFFECT_H
46 |
--------------------------------------------------------------------------------
/sources/effects/binarizationeffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef BINARIZATIONEFFECT_H
27 | #define BINARIZATIONEFFECT_H
28 |
29 | #include "abstracteffect.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Binarization effect class.
35 | *
36 | */
37 | class BinarizationEffect : public AbstractEffect
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit BinarizationEffect(QObject *parent = 0);
42 |
43 | void applyEffect(ImageArea &imageArea);
44 |
45 | private:
46 | void makeBinarization(ImageArea &imageArea, int coeff1, int coeff2);
47 |
48 | };
49 |
50 | #endif // BINARIZATIONEFFECT_H
51 |
--------------------------------------------------------------------------------
/sources/undocommand.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "undocommand.h"
27 |
28 | UndoCommand::UndoCommand(const QImage *img, ImageArea &imgArea, QUndoCommand *parent)
29 | : QUndoCommand(parent), mPrevImage(*img), mImageArea(imgArea)
30 | {
31 | mCurrImage = mPrevImage;
32 | }
33 |
34 | void UndoCommand::undo()
35 | {
36 | mImageArea.clearSelection();
37 | mCurrImage = *(mImageArea.getImage());
38 | mImageArea.setImage(mPrevImage);
39 | mImageArea.update();
40 | mImageArea.saveImageChanges();
41 | }
42 |
43 | void UndoCommand::redo()
44 | {
45 | mImageArea.setImage(mCurrImage);
46 | mImageArea.update();
47 | mImageArea.saveImageChanges();
48 | }
49 |
--------------------------------------------------------------------------------
/sources/effects/effectwithsettings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 |
28 | #include "effectwithsettings.h"
29 | #include "../imagearea.h"
30 | #include "../dialogs/effectsettingsdialog.h"
31 |
32 | EffectWithSettings::EffectWithSettings(QObject *parent) :
33 | AbstractEffect(parent)
34 | {
35 | }
36 |
37 | void EffectWithSettings::applyEffect(ImageArea &imageArea)
38 | {
39 | EffectSettingsDialog dlg(*imageArea.getImage(), getSettingsWidget());
40 |
41 | if(dlg.exec())
42 | {
43 | makeUndoCommand(imageArea);
44 |
45 | imageArea.setImage(dlg.getChangedImage());
46 | imageArea.setEdited(true);
47 | imageArea.update();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sources/undocommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef UNDOCOMMAND_H
27 | #define UNDOCOMMAND_H
28 |
29 | #include
30 | #include
31 |
32 | #include "imagearea.h"
33 |
34 | /**
35 | * @brief Class which provides undo/redo actions
36 | *
37 | * In future it should be changed according to architecture changing
38 | */
39 | class UndoCommand : public QUndoCommand
40 | {
41 | public:
42 | UndoCommand(const QImage* img, ImageArea &imgArea, QUndoCommand *parent = 0);
43 |
44 | virtual void undo();
45 | virtual void redo();
46 | private:
47 | QImage mPrevImage;
48 | QImage mCurrImage;
49 | ImageArea& mImageArea;
50 | };
51 |
52 | #endif // UNDOCOMMAND_H
53 |
--------------------------------------------------------------------------------
/sources/effects/gaussianblureffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef GAUSSIANBLUREFFECT_H
27 | #define GAUSSIANBLUREFFECT_H
28 |
29 | #include "effectwithsettings.h"
30 | #include "../widgets/gaussianblurfiltersettings.h"
31 |
32 | #include
33 |
34 | /**
35 | * @brief Gaussian Blur effect class.
36 | *
37 | */
38 | class GaussianBlurEffect : public EffectWithSettings
39 | {
40 | Q_OBJECT
41 | public:
42 | explicit GaussianBlurEffect(QObject *parent = 0) : EffectWithSettings(parent) {}
43 |
44 | protected:
45 | // TODO: change type of widget
46 | virtual AbstractEffectSettings *getSettingsWidget() { return new GaussianBlurFilterSettings(); }
47 |
48 | };
49 |
50 | #endif // GAUSSIANBLUREFFECT_H
51 |
--------------------------------------------------------------------------------
/sources/effects/effectwithsettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 |
27 | #ifndef CONVOLUTIONMATRIXEFFECT_H
28 | #define CONVOLUTIONMATRIXEFFECT_H
29 |
30 | #include "abstracteffect.h"
31 | #include "../widgets/abstracteffectsettings.h"
32 |
33 | #include
34 | #include
35 | #include
36 |
37 | /**
38 | * @brief Base class for filters, which uses convolution matrix.
39 | *
40 | */
41 | class EffectWithSettings : public AbstractEffect
42 | {
43 | Q_OBJECT
44 | public:
45 | explicit EffectWithSettings(QObject *parent = 0);
46 |
47 | virtual void applyEffect(ImageArea &imageArea);
48 |
49 | protected:
50 | virtual AbstractEffectSettings* getSettingsWidget() = 0;
51 |
52 | };
53 |
54 | #endif // CONVOLUTIONMATRIXEFFECT_H
55 |
--------------------------------------------------------------------------------
/sources/widgets/shortcutedit.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SHORTCUTEDIT_H
27 | #define SHORTCUTEDIT_H
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QToolButton;
33 | QT_END_NAMESPACE
34 |
35 | /**
36 | * @brief Widget for editing key sequences.
37 | *
38 | * Just a modified QLineEdit.
39 | */
40 | class ShortcutEdit : public QLineEdit
41 | {
42 | Q_OBJECT
43 | public:
44 | explicit ShortcutEdit(QWidget *parent = 0);
45 |
46 | protected:
47 | virtual void keyPressEvent(QKeyEvent *event);
48 | virtual void resizeEvent(QResizeEvent *);
49 | private:
50 | bool isModifier(int key);
51 | QToolButton *mClearButton;
52 | private slots:
53 | void updateClearButton(const QString& text);
54 | };
55 |
56 | #endif // SHORTCUTEDIT_H
57 |
--------------------------------------------------------------------------------
/sources/instruments/lineinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef LINEINSTRUMENT_H
27 | #define LINEINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Line instrument class.
35 | *
36 | */
37 | class LineInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit LineInstrument(QObject *parent = 0);
43 |
44 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
46 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
47 |
48 | protected:
49 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
50 |
51 | };
52 |
53 | #endif // LINEINSTRUMENT_H
54 |
--------------------------------------------------------------------------------
/sources/instruments/sprayinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SPRAYINSTRUMENT_H
27 | #define SPRAYINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Spray instrument class.
35 | *
36 | */
37 | class SprayInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit SprayInstrument(QObject *parent = 0);
42 |
43 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
44 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
46 |
47 | protected:
48 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
49 |
50 | };
51 |
52 | #endif // SPRAYINSTRUMENT_H
53 |
--------------------------------------------------------------------------------
/sources/instruments/eraserinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ERASERINSTRUMENT_H
27 | #define ERASERINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Eraser instrument class.
35 | *
36 | */
37 | class EraserInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit EraserInstrument(QObject *parent = 0);
43 |
44 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
46 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
47 |
48 | protected:
49 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
50 |
51 | };
52 |
53 | #endif // ERASERINSTRUMENT_H
54 |
--------------------------------------------------------------------------------
/sources/instruments/pencilinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef PENCILINSTRUMENT_H
27 | #define PENCILINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Pencil instrument class.
35 | *
36 | */
37 | class PencilInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit PencilInstrument(QObject *parent = 0);
43 |
44 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
46 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
47 |
48 | protected:
49 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
50 |
51 | };
52 |
53 | #endif // PENCILINSTRUMENT_H
54 |
--------------------------------------------------------------------------------
/sources/instruments/ellipseinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ELLIPSEINSTRUMENT_H
27 | #define ELLIPSEINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Ellipse instrument class.
35 | *
36 | */
37 | class EllipseInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit EllipseInstrument(QObject *parent = 0);
43 |
44 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
46 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
47 |
48 | protected:
49 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
50 |
51 | };
52 |
53 | #endif // ELLIPSEINSTRUMENT_H
54 |
--------------------------------------------------------------------------------
/sources/instruments/magnifierinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef MAGNIFIERINSTRUMENT_H
27 | #define MAGNIFIERINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Magnifier instrument class.
35 | *
36 | */
37 | class MagnifierInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit MagnifierInstrument(QObject *parent = 0);
42 |
43 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
44 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
46 |
47 | protected:
48 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
49 |
50 | };
51 |
52 | #endif // MAGNIFIERINSTRUMENT_H
53 |
--------------------------------------------------------------------------------
/sources/instruments/rectangleinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef RECTANGLEINSTRUMENT_H
27 | #define RECTANGLEINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Rectangle instrument class.
35 | *
36 | */
37 | class RectangleInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit RectangleInstrument(QObject *parent = 0);
42 |
43 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
44 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
46 |
47 | protected:
48 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
49 |
50 | };
51 |
52 | #endif // RECTANGLEINSTRUMENT_H
53 |
--------------------------------------------------------------------------------
/sources/instruments/colorpickerinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef COLORPICKERINSTRUMENT_H
27 | #define COLORPICKERINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Colorpicker instrument class.
35 | *
36 | */
37 | class ColorpickerInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 |
41 | public:
42 | explicit ColorpickerInstrument(QObject *parent = 0);
43 |
44 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
46 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
47 |
48 | protected:
49 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
50 |
51 | };
52 |
53 | #endif // COLORPICKERINSTRUMENT_H
54 |
--------------------------------------------------------------------------------
/sources/effects/grayeffect.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "grayeffect.h"
27 | #include "../imagearea.h"
28 |
29 | GrayEffect::GrayEffect(QObject *parent) :
30 | AbstractEffect(parent)
31 | {
32 | }
33 |
34 | void GrayEffect::applyEffect(ImageArea &imageArea)
35 | {
36 | imageArea.clearSelection();
37 | makeUndoCommand(imageArea);
38 |
39 | for(int i(0); i < imageArea.getImage()->width(); i++)
40 | {
41 | for(int y(0); y < imageArea.getImage()->height(); y++)
42 | {
43 | QRgb pixel(imageArea.getImage()->pixel(i, y));
44 | int rgb = (int)(0.299 * qRed(pixel) + 0.587 * qGreen(pixel) + 0.114 * qBlue(pixel));
45 | pixel = qRgb(rgb, rgb, rgb);
46 | imageArea.getImage()->setPixel(i, y, pixel);
47 | }
48 | }
49 | imageArea.setEdited(true);
50 | imageArea.update();
51 | }
52 |
--------------------------------------------------------------------------------
/sources/dialogs/textdialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef TEXTDIALOG_H
27 | #define TEXTDIALOG_H
28 |
29 | #include "../imagearea.h"
30 |
31 | #include
32 | #include
33 |
34 | /**
35 | * @brief QDialog for text instrument.
36 | *
37 | */
38 | class TextDialog : public QDialog
39 | {
40 | Q_OBJECT
41 |
42 | public:
43 | /**
44 | * @brief Constructor
45 | *
46 | * @param parent Pointer for parent.
47 | */
48 | explicit TextDialog(QString text, ImageArea *parent);
49 |
50 | private:
51 | void initializeGui();
52 | QTextEdit *mTextEdit;
53 |
54 | signals:
55 | void textChanged(ImageArea *, const QString);
56 | void canceled(ImageArea *);
57 |
58 | private slots:
59 | void textChanged();
60 | void selectFont();
61 | void cancel();
62 | void reject();
63 | };
64 |
65 | #endif // TEXTDIALOG_H
66 |
--------------------------------------------------------------------------------
/sources/widgets/customfiltersettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef CUSTOMFILTERSETTINGS_H
27 | #define CUSTOMFILTERSETTINGS_H
28 |
29 | #include
30 | #include
31 |
32 | #include "abstracteffectsettings.h"
33 |
34 | class CustomFilterSettings : public AbstractEffectSettings
35 | {
36 | Q_OBJECT
37 | public:
38 | explicit CustomFilterSettings(QWidget *parent = 0);
39 |
40 | QList virtual getConvolutionMatrix();
41 |
42 | private:
43 | QDoubleSpinBox *mSpinBox_11;
44 | QDoubleSpinBox *mSpinBox_12;
45 | QDoubleSpinBox *mSpinBox_13;
46 | QDoubleSpinBox *mSpinBox_21;
47 | QDoubleSpinBox *mSpinBox_22;
48 | QDoubleSpinBox *mSpinBox_23;
49 | QDoubleSpinBox *mSpinBox_31;
50 | QDoubleSpinBox *mSpinBox_32;
51 | QDoubleSpinBox *mSpinBox_33;
52 |
53 | QDoubleSpinBox* createSpinBox();
54 | };
55 |
56 | #endif // CUSTOMFILTERSETTINGS_H
57 |
--------------------------------------------------------------------------------
/sources/effects/abstracteffect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ABSTRACTEFFECT_H
27 | #define ABSTRACTEFFECT_H
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 | class ImageArea;
33 | QT_END_NAMESPACE
34 |
35 | /**
36 | * @brief Abstract class for implementing effects.
37 | *
38 | */
39 | class AbstractEffect : public QObject
40 | {
41 | Q_OBJECT
42 |
43 | public:
44 | explicit AbstractEffect(QObject *parent = 0);
45 | virtual ~AbstractEffect(){}
46 |
47 | virtual void applyEffect(ImageArea &imageArea) = 0;
48 |
49 | protected:
50 | /**
51 | * @brief Creates UndoCommand & pushes it to UndoStack.
52 | *
53 | * Base realisation simply save all image to UndoStack
54 | * @param imageArea corresponse to image, which is edited
55 | */
56 | virtual void makeUndoCommand(ImageArea &imageArea);
57 |
58 | };
59 |
60 | #endif // ABSTRACTEFFECT_H
61 |
--------------------------------------------------------------------------------
/sources/instruments/fillinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef FILLINSTRUMENT_H
27 | #define FILLINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Fill instrument class.
35 | *
36 | */
37 | class FillInstrument : public AbstractInstrument
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit FillInstrument(QObject *parent = 0);
42 |
43 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
44 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
46 |
47 | protected:
48 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
49 |
50 | private:
51 | void fillRecurs(int x, int y, QRgb switchColor, QRgb oldColor, QImage &tempImage);
52 |
53 | };
54 |
55 | #endif // FILLINSTRUMENT_H
56 |
--------------------------------------------------------------------------------
/sources/easypaintenums.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef EASYPAINTENUMS_H
27 | #define EASYPAINTENUMS_H
28 |
29 | /**
30 | * @brief Enum with instruments names
31 | *
32 | */
33 | typedef enum
34 | {
35 | NONE_INSTRUMENT = 0,
36 | CURSOR,
37 | ERASER,
38 | PEN,
39 | LINE,
40 | COLORPICKER,
41 | MAGNIFIER,
42 | SPRAY,
43 | FILL,
44 | RECTANGLE,
45 | ELLIPSE,
46 | CURVELINE,
47 | TEXT,
48 |
49 | // Don't use it. (Used to know count of current instrument)
50 | INSTRUMENTS_COUNT
51 | } InstrumentsEnum;
52 |
53 | /**
54 | * @brief Enum with effects names
55 | *
56 | */
57 | typedef enum
58 | {
59 | NONE_EFFECT = 0,
60 | NEGATIVE,
61 | GRAY,
62 | BINARIZATION,
63 | GAUSSIANBLUR,
64 | GAMMA,
65 | SHARPEN,
66 | CUSTOM,
67 |
68 | // Don't use it. (Used to know count of current instrument)
69 | EFFECTS_COUNT
70 | } EffectsEnum;
71 |
72 | #endif // EASYPAINTENUMS_H
73 |
--------------------------------------------------------------------------------
/sources/instruments/curvelineinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef CURVELINEINSTRUMENT_H
27 | #define CURVELINEINSTRUMENT_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | #include
32 | #include
33 |
34 | class CurveLineInstrument : public AbstractInstrument
35 | {
36 | Q_OBJECT
37 | public:
38 | explicit CurveLineInstrument(QObject *parent = 0);
39 |
40 | virtual void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
41 | virtual void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
42 | virtual void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
43 |
44 | protected:
45 | void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false);
46 |
47 | private:
48 | QPoint mFirstControlPoint, mSecondControlPoint;
49 | unsigned int mPointsCount : 2; /**< Chaneges from 0 to 2, so 2 bits is enough. */
50 | };
51 |
52 | #endif // CURVELINEINSTRUMENT_H
53 |
--------------------------------------------------------------------------------
/distr/deb/make_deb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #default parameters
4 | NAME="easypaint"
5 | SRC_DIR="../.."
6 | TYPE='-b'
7 | SIGN='-uc -us'
8 | VER=""
9 | OUT_DIR=""
10 |
11 | function help
12 | {
13 | cat << EOF
14 | Usage: make_deb.sh [options]
15 | By default path-to-sources is ${SRC_DIR}
16 |
17 | Options:
18 | -h|--help display help message
19 | -o|--outdir=DIR write result to DIR, by default it's home dir
20 | -v|--version=VERSION easypaint version
21 | -s make source package, if ommited make binary package
22 | -S|--sign sign package
23 |
24 | EOF
25 | }
26 |
27 | while [ ! -z "$1" ]; do
28 | case $1 in
29 | -h|--help)
30 | help
31 | exit
32 | ;;
33 | -o|--outdir)
34 | OUT_DIR=$2
35 | shift 2
36 | ;;
37 | -v|--version)
38 | VER=$2
39 | shift 2
40 | ;;
41 | -s)
42 | TYPE='-S'
43 | shift
44 | ;;
45 | -S|--sign)
46 | SIGN=''
47 | shift
48 | ;;
49 | *)
50 | SRC_DIR=$1
51 | break
52 | ;;
53 | esac
54 | done
55 |
56 | if [ -z "$OUT_DIR" ]; then
57 | OUT_DIR="${HOME}/${NAME}_${VER}_deb"
58 | fi
59 |
60 | #Check, if there is correct source directory
61 | if [ ! -f ${SRC_DIR}/CMakeLists.txt ]; then
62 | echo "There is no CMakeLists.txt in \"${SRC_DIR}\""
63 | exit 2
64 | fi
65 |
66 | #Set version
67 | if [ -z "$VER" ]; then
68 | VER=`awk -F'[)( ]' '/set\s*\(EASYPAINT_VERSION / {print($3)}' ${SRC_DIR}/CMakeLists.txt`
69 | fi
70 |
71 | # TODO: write some messages.
72 | echo Build ${NAME} package...
73 | echo Src dir: ${SRC_DIR}
74 | echo Out dir: ${OUT_DIR}
75 | echo ........................
76 |
77 | OUT_DIR=`readlink -m ${OUT_DIR}`
78 | mkdir -p ${OUT_DIR} || exit 2
79 | DIR=${OUT_DIR}/${NAME}-${VER}
80 | rm -rf ${DIR}
81 |
82 | #copying sources to the destination dir
83 | cp -r ${SRC_DIR} ${DIR}
84 | rm -rf ${DIR}/.git ${DIR}/build ${DIR}/distr
85 |
86 | mkdir ${DIR}/debian
87 | cp -r ${SRC_DIR}/distr/deb/debian ${DIR}
88 |
89 | #Build package
90 | cd ${DIR}/.. && tar cjf ${NAME}_${VER}.orig.tar.bz2 ${NAME}-${VER}
91 | cd ${DIR} && dpkg-buildpackage ${TYPE} ${SIGN}
92 |
93 | #clean OUT_DIR
94 | rm -rf ${DIR}
95 | rm ../${NAME}_${VER}.orig.tar.bz2
96 |
97 | echo Now you can find deb package at ${OUT_DIR}
98 |
--------------------------------------------------------------------------------
/sources/widgets/palettebar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef PALETTEBAR_H
27 | #define PALETTEBAR_H
28 |
29 | #include "toolbar.h"
30 | #include "palettebutton.h"
31 |
32 | #include
33 |
34 | /**
35 | * @brief Toolbar with some number of differrent colors
36 | *
37 | */
38 | class PaletteBar : public QToolBar
39 | {
40 | Q_OBJECT
41 |
42 | public:
43 | PaletteBar(ToolBar *toolBar);
44 |
45 | private:
46 | /**
47 | * @brief Color buttons initializing
48 | *
49 | */
50 | void initializeItems();
51 | /**
52 | * @brief Create new QToolButton
53 | *
54 | * @param name Color name
55 | * @param color Color of button
56 | * @return QToolButton Created QToolButton.
57 | */
58 |
59 | PaletteButton *mColorButton;
60 | ToolBar *mToolBar;
61 | bool mIsRightButtonCLicked;
62 |
63 | private slots:
64 | void colorClicked();
65 |
66 | protected:
67 | void contextMenuEvent(QContextMenuEvent *);
68 | };
69 |
70 | #endif // PALETTEBAR_H
71 |
--------------------------------------------------------------------------------
/sources/dialogs/effectsettingsdialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ABSTRACTEFFECTSDIALOG_H
27 | #define ABSTRACTEFFECTSDIALOG_H
28 |
29 | #include
30 | #include
31 |
32 | #include "../widgets/abstracteffectsettings.h"
33 | #include "../widgets/imagepreview.h"
34 |
35 | class EffectSettingsDialog : public QDialog
36 | {
37 | Q_OBJECT
38 | public:
39 | explicit EffectSettingsDialog(const QImage &img, AbstractEffectSettings *settingsWidget, QWidget *parent = 0);
40 |
41 | inline QImage getChangedImage() { return mImage; }
42 | signals:
43 |
44 | public slots:
45 |
46 | private:
47 | QPushButton *mOkButton;
48 | QPushButton *mCancelButton;
49 | QPushButton *mApplyButton;
50 |
51 | AbstractEffectSettings *mSettingsWidget;
52 | ImagePreview *mImagePreview;
53 |
54 | QImage mImage;
55 |
56 | QRgb convolutePixel(const QImage &image, int x, int y, const QList &kernelMatrix);
57 |
58 | private slots:
59 | void applyMatrix();
60 | };
61 |
62 | #endif // ABSTRACTEFFECTSDIALOG_H
63 |
--------------------------------------------------------------------------------
/sources/resources.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | media/instruments-icons/cursor.png
4 | media/instruments-icons/ellipse.png
5 | media/instruments-icons/fill.png
6 | media/instruments-icons/lastic.png
7 | media/instruments-icons/line.png
8 | media/instruments-icons/loupe.png
9 | media/instruments-icons/pencil.png
10 | media/instruments-icons/pipette.png
11 | media/instruments-icons/rectangle.png
12 | media/instruments-icons/spray.png
13 | media/instruments-icons/text.png
14 | media/instruments-icons/cursor_loupe.png
15 | media/instruments-icons/cursor_pipette.png
16 | media/instruments-icons/cursor_spray.png
17 | media/instruments-icons/cursor_fill.png
18 | media/textures/transparent.jpg
19 | media/actions-icons/application-exit.png
20 | media/actions-icons/document-new.png
21 | media/actions-icons/document-open.png
22 | media/actions-icons/document-print.png
23 | media/actions-icons/document-properties.png
24 | media/actions-icons/document-save-as.png
25 | media/actions-icons/document-save.png
26 | media/actions-icons/edit-copy.png
27 | media/actions-icons/edit-cut.png
28 | media/actions-icons/edit-paste.png
29 | media/actions-icons/edit-redo.png
30 | media/actions-icons/edit-undo.png
31 | media/actions-icons/help-about.png
32 | media/actions-icons/object-rotate-left.png
33 | media/actions-icons/object-rotate-right.png
34 | media/actions-icons/window-close.png
35 | media/actions-icons/zoom-in.png
36 | media/actions-icons/zoom-out.png
37 | media/logo/easypaint_64.png
38 | media/instruments-icons/curve.png
39 | media/actions-icons/clear-gray.png
40 |
41 |
42 |
--------------------------------------------------------------------------------
/sources/effects/binarizationeffect.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "binarizationeffect.h"
27 | #include "../imagearea.h"
28 |
29 | BinarizationEffect::BinarizationEffect(QObject *parent) :
30 | AbstractEffect(parent)
31 | {
32 | }
33 |
34 | void BinarizationEffect::applyEffect(ImageArea &imageArea)
35 | {
36 | makeUndoCommand(imageArea);
37 |
38 | // TODO: add dialog for setting parameters
39 | makeBinarization(imageArea, 200, 100);
40 |
41 | imageArea.setEdited(true);
42 | imageArea.update();
43 | }
44 |
45 | void BinarizationEffect::makeBinarization(ImageArea &imageArea, int coeff1, int coeff2)
46 | {
47 | for (int x(0); x < imageArea.getImage()->width(); x++)
48 | {
49 | for (int y(0); y < imageArea.getImage()->height(); y++)
50 | {
51 | QRgb pixel = imageArea.getImage()->pixel(x, y);
52 | int r = (int)qRed(pixel);
53 | if (r >= coeff1)
54 | r = 0;
55 | else if (r >= coeff2 && r < coeff1)
56 | r = 255;
57 | else
58 | r = 0;
59 | pixel = qRgb(r, r, r);
60 | imageArea.getImage()->setPixel(x, y, pixel);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/sources/effects/gammaeffect.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "gammaeffect.h"
27 | #include "../imagearea.h"
28 |
29 | #include
30 |
31 | GammaEffect::GammaEffect(QObject *parent) :
32 | AbstractEffect(parent)
33 | {
34 | }
35 |
36 | void GammaEffect::applyEffect(ImageArea &imageArea)
37 | {
38 | makeUndoCommand(imageArea);
39 |
40 | // TODO: add dialog for setting parameters
41 | makeGamma(imageArea, 2);
42 |
43 | imageArea.setEdited(true);
44 | imageArea.update();
45 | }
46 |
47 | void GammaEffect::makeGamma(ImageArea &imageArea, float modificator)
48 | {
49 | for(int x(0); x < imageArea.getImage()->width(); x++)
50 | {
51 | for(int y(0); y < imageArea.getImage()->height(); y++)
52 | {
53 | QRgb pixel = imageArea.getImage()->pixel(x, y);
54 | float r = qRed(pixel);
55 | r = 255 * pow(r / 255, modificator);
56 | float g = qGreen(pixel);
57 | g = 255 * pow(g / 255, modificator);
58 | float b = qBlue(pixel);
59 | b = 255 * pow(b / 255, modificator);
60 | pixel = qRgb(r, g, b);
61 | imageArea.getImage()->setPixel(x, y, pixel);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/sources/instruments/magnifierinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "magnifierinstrument.h"
27 | #include "../imagearea.h"
28 |
29 | MagnifierInstrument::MagnifierInstrument(QObject *parent) :
30 | AbstractInstrument(parent)
31 | {
32 | }
33 |
34 | void MagnifierInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
35 | {
36 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
37 | {
38 | imageArea.setIsPaint(true);
39 | }
40 | }
41 |
42 | void MagnifierInstrument::mouseMoveEvent(QMouseEvent *, ImageArea &)
43 | {
44 |
45 | }
46 |
47 | void MagnifierInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
48 | {
49 | if(imageArea.isPaint())
50 | {
51 | if(event->button() == Qt::LeftButton)
52 | {
53 | if(imageArea.zoomImage(2.0))
54 | {
55 | imageArea.setZoomFactor(2.0);
56 | }
57 | }
58 | else if(event->button() == Qt::RightButton)
59 | {
60 | if(imageArea.zoomImage(0.5))
61 | {
62 | imageArea.setZoomFactor(0.5);
63 | }
64 | }
65 | imageArea.setIsPaint(false);
66 | }
67 | }
68 |
69 | void MagnifierInstrument::paint(ImageArea &, bool, bool)
70 | {
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/sources/widgets/sharpenfiltersettings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 | #include
28 |
29 | #include "sharpenfiltersettings.h"
30 |
31 | SharpenFilterSettings::SharpenFilterSettings(QWidget *parent) :
32 | AbstractEffectSettings(parent)
33 | {
34 | QLabel *label = new QLabel(tr("Intensity"), this);
35 |
36 | mIntensitySlider = new QSlider(Qt::Horizontal, this);
37 | mIntensitySlider->setTickPosition(QSlider::TicksBothSides);
38 | mIntensitySlider->setMinimum(1);
39 | mIntensitySlider->setMaximum(10);
40 | mIntensitySlider->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
41 | connect(mIntensitySlider, SIGNAL(valueChanged(int)), this, SIGNAL(matrixChanged()));
42 |
43 | QVBoxLayout *vLayout = new QVBoxLayout();
44 |
45 | vLayout->addWidget(label);
46 | vLayout->addWidget(mIntensitySlider);
47 | vLayout->addStretch();
48 | setLayout(vLayout);
49 | }
50 |
51 | QList SharpenFilterSettings::getConvolutionMatrix()
52 | {
53 | QList matrix;
54 | int intensity = mIntensitySlider->value();
55 |
56 | matrix << 0 << -(intensity) << 0
57 | << -(intensity) << (intensity * 4) + 1 << -(intensity)
58 | << 0 << -(intensity) << 0;
59 |
60 | return matrix;
61 | }
62 |
--------------------------------------------------------------------------------
/sources/widgets/gaussianblurfiltersettings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 | #include
28 |
29 | #include "gaussianblurfiltersettings.h"
30 |
31 | GaussianBlurFilterSettings::GaussianBlurFilterSettings(QWidget *parent) :
32 | AbstractEffectSettings(parent)
33 | {
34 | QLabel *label = new QLabel(tr("Intensity"), this);
35 |
36 | mIntensitySlider = new QSlider(Qt::Horizontal, this);
37 | mIntensitySlider->setTickPosition(QSlider::TicksBothSides);
38 | mIntensitySlider->setMinimum(1);
39 | mIntensitySlider->setMaximum(10);
40 | mIntensitySlider->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
41 | connect(mIntensitySlider, SIGNAL(valueChanged(int)), this, SIGNAL(matrixChanged()));
42 |
43 | QVBoxLayout *vLayout = new QVBoxLayout();
44 |
45 | vLayout->addWidget(label);
46 | vLayout->addWidget(mIntensitySlider);
47 | vLayout->addStretch();
48 | setLayout(vLayout);
49 | }
50 |
51 | QList GaussianBlurFilterSettings::getConvolutionMatrix()
52 | {
53 | QList matrix;
54 | int intensity = mIntensitySlider->value();
55 |
56 | matrix << 1 * intensity << 2 * intensity << 1 * intensity
57 | << 2 * intensity << 4 * intensity << 2 * intensity
58 | << 1 * intensity << 2 * intensity << 1 * intensity;
59 |
60 | return matrix;
61 | }
62 |
--------------------------------------------------------------------------------
/distr/deb/debian/copyright:
--------------------------------------------------------------------------------
1 | Format: http://dep.debian.net/deps/dep5
2 | Upstream-Name: easypaint
3 | Source:
4 |
5 | Files: *
6 | Copyright: Copyright (c) 2012 EasyPaint
7 | License: MIT
8 | Copyright (c) 2012 EasyPaint
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining
11 | a copy of this software and associated documentation files (the
12 | "Software"), to deal in the Software without restriction, including
13 | without limitation the rights to use, copy, modify, merge, publish,
14 | distribute, sublicense, and/or sell copies of the Software, and to
15 | permit persons to whom the Software is furnished to do so, subject to
16 | the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included
19 | in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 |
29 | Files: debian/*
30 | Copyright: 2012 Artem Stepanyuk
31 | License: GPL-2+
32 | This package is free software; you can redistribute it and/or modify
33 | it under the terms of the GNU General Public License as published by
34 | the Free Software Foundation; either version 2 of the License, or
35 | (at your option) any later version.
36 | .
37 | This package is distributed in the hope that it will be useful,
38 | but WITHOUT ANY WARRANTY; without even the implied warranty of
39 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 | GNU General Public License for more details.
41 | .
42 | You should have received a copy of the GNU General Public License
43 | along with this program. If not, see
44 | .
45 | On Debian systems, the complete text of the GNU General
46 | Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
47 |
48 | # Please also look if there are files or directories which have a
49 | # different copyright/license attached and list them here.
50 | # Please avoid to pick license terms that are more restrictive than the
51 | # packaged work, as it may make Debian's contributions unacceptable upstream.
52 |
--------------------------------------------------------------------------------
/sources/instruments/textinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef TEXTINSTRUMENT_H
27 | #define TEXTINSTRUMENT_H
28 |
29 | #include "abstractselection.h"
30 |
31 | #include
32 |
33 | /**
34 | * @brief Text instrument class.
35 | *
36 | */
37 | class TextInstrument : public AbstractSelection
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit TextInstrument(QObject *parent = 0);
42 |
43 | private:
44 | void startAdjusting(ImageArea &);
45 | void startSelection(ImageArea &);
46 | void startResizing(ImageArea &);
47 | void startMoving(ImageArea &);
48 | void select(ImageArea &);
49 | void resize(ImageArea &imageArea);
50 | void move(ImageArea &imageArea);
51 | void completeSelection(ImageArea &imageArea);
52 | void completeResizing(ImageArea &);
53 | void completeMoving(ImageArea &);
54 | void clear();
55 | void paint(ImageArea &imageArea, bool = false, bool = false);
56 | void showMenu(ImageArea &imageArea);
57 |
58 | QString mText;
59 | bool mIsEdited;
60 |
61 | signals:
62 | void sendCloseTextDialog();
63 |
64 | private slots:
65 | void updateText(ImageArea *, QString);
66 | /**
67 | * @brief Clears text and remove selection.
68 | *
69 | * @param imageArea ImageArea for applying changes.
70 | */
71 | void cancel(ImageArea *);
72 |
73 | };
74 |
75 | #endif // TEXTINSTRUMENT_H
76 |
--------------------------------------------------------------------------------
/sources/widgets/colorchooser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef COLORCHOOSER_H
27 | #define COLORCHOOSER_H
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QColor;
33 | class QPixmap;
34 | class QPainter;
35 | class QMouseEvent;
36 | class QColorDialog;
37 | QT_END_NAMESPACE
38 |
39 | /**
40 | * @brief Widget for selecting color.
41 | *
42 | */
43 | class ColorChooser : public QLabel
44 | {
45 | Q_OBJECT
46 |
47 | public:
48 | /**
49 | * @brief Constructor
50 | *
51 | * @param r Red
52 | * @param g Green
53 | * @param b Blue
54 | * @param parent Pointer for parent.
55 | */
56 | explicit ColorChooser(const int &r, const int &g, const int &b,
57 | QWidget *parent = 0);
58 | ~ColorChooser();
59 |
60 | private:
61 | QColor *mCurrentColor;
62 | QPixmap *mPixmapColor;
63 | QPainter *mPainterColor;
64 |
65 | public slots:
66 | /**
67 | * @brief Slot for set color to widget.
68 | *
69 | * @param color Color to set.
70 | */
71 | void setColor(const QColor &color);
72 |
73 | signals:
74 | /**
75 | * @brief Signal for sending choosen color
76 | *
77 | * @param Color to send
78 | */
79 | void sendColor(const QColor &);
80 |
81 | protected:
82 | void mousePressEvent(QMouseEvent *event);
83 |
84 | };
85 |
86 | #endif // COLORCHOOSER_H
87 |
--------------------------------------------------------------------------------
/sources/instruments/abstractinstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ABSTRACTINSTRUMENT_H
27 | #define ABSTRACTINSTRUMENT_H
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | QT_BEGIN_NAMESPACE
34 | class ImageArea;
35 | QT_END_NAMESPACE
36 |
37 | /**
38 | * @brief Abstract instrument class.
39 | *
40 | */
41 | class AbstractInstrument : public QObject
42 | {
43 | Q_OBJECT
44 |
45 | public:
46 | explicit AbstractInstrument(QObject *parent = 0);
47 | virtual ~AbstractInstrument(){}
48 |
49 | virtual void mousePressEvent(QMouseEvent *event, ImageArea &imageArea) = 0;
50 | virtual void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea) = 0;
51 | virtual void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea) = 0;
52 |
53 | signals:
54 |
55 | protected:
56 | QPoint mStartPoint, mEndPoint; /**< Point for events. */
57 | QImage mImageCopy; /**< Image for storing copy of current image on imageArea, needed for some instruments. */
58 |
59 | virtual void paint(ImageArea &imageArea, bool isSecondaryColor = false, bool additionalFlag = false) = 0;
60 |
61 | /**
62 | * @brief Creates UndoCommand & pushes it to UndoStack.
63 | *
64 | * Base realisation simply save all image to UndoStack
65 | * @param imageArea corresponse to image, which is edited
66 | */
67 | virtual void makeUndoCommand(ImageArea &imageArea);
68 |
69 | };
70 |
71 | #endif // ABSTRACTINSTRUMENT_H
72 |
--------------------------------------------------------------------------------
/sources/widgets/colorchooser.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "colorchooser.h"
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | ColorChooser::ColorChooser(const int &r, const int &g, const int &b, QWidget *parent) :
35 | QLabel(parent)
36 | {
37 | setFrameStyle(QFrame::Raised | QFrame::Box);
38 | mCurrentColor = new QColor(r, g, b);
39 | mPixmapColor = new QPixmap(20, 20);
40 | mPainterColor = new QPainter(mPixmapColor);
41 | mPainterColor->fillRect(0, 0, 20, 20, *mCurrentColor);
42 | mPainterColor->end();
43 | setMargin(3);
44 | setAlignment(Qt::AlignHCenter);
45 | setPixmap(*mPixmapColor);
46 | }
47 |
48 | ColorChooser::~ColorChooser()
49 | {
50 | delete mCurrentColor;
51 | delete mPainterColor;
52 | delete mPixmapColor;
53 | }
54 |
55 | void ColorChooser::setColor(const QColor &color)
56 | {
57 | *mCurrentColor = color;
58 | mPainterColor->begin(mPixmapColor);
59 | mPainterColor->fillRect(0, 0, 20, 20, *mCurrentColor);
60 | mPainterColor->end();
61 | setPixmap(*mPixmapColor);
62 | }
63 |
64 | void ColorChooser::mousePressEvent(QMouseEvent *event)
65 | {
66 | if(event->button() == Qt::LeftButton)
67 | {
68 | QColor color = QColorDialog::getColor(*mCurrentColor, this);
69 | if(color.isValid())
70 | {
71 | setColor(color);
72 | emit sendColor(color);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/sources/dialogs/resizedialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef RISEZEDIALOG_H
27 | #define RISEZEDIALOG_H
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QLabel;
33 | class QSpinBox;
34 | class QCheckBox;
35 | QT_END_NAMESPACE
36 |
37 | /**
38 | * @brief QDialog for resizing image.
39 | *
40 | */
41 | class ResizeDialog : public QDialog
42 | {
43 | Q_OBJECT
44 |
45 | public:
46 | /**
47 | * @brief Constructor
48 | *
49 | * @param size Current image size.
50 | * @param parent Pointer for parent.
51 | */
52 | explicit ResizeDialog(const QSize &size, QWidget *parent);
53 |
54 | /**
55 | * @brief Return new image size
56 | *
57 | * @return QSize New size.
58 | */
59 | inline QSize getNewSize() { return QSize(mWidth, mHeight); }
60 |
61 | private:
62 | void initializeGui();
63 |
64 | QLabel *mNewSizeLabel; /**< Label for showing new size */
65 | QSpinBox *mPixelWButton, *mPixelHButton,
66 | *mPercentWButton, *mPercentHButton;
67 | QCheckBox *mPreserveAspectBox;
68 | int mWidth, mHeight,
69 | mOrigWidth, mOrigHeight;
70 |
71 | signals:
72 |
73 | private slots:
74 | void pixelsButtonClicked(bool flag);
75 | void percentButtonClicked(bool flag);
76 | void pixelsWValueChanged(const int &value);
77 | void pixelsHValueChanged(const int &value);
78 | void percentWValueChanged(const int &value);
79 | void percentHValueChanged(const int &value);
80 |
81 | };
82 |
83 | #endif // RISEZEDIALOG_H
84 |
--------------------------------------------------------------------------------
/sources/additionaltools.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ADDITIONALTOOLS_H
27 | #define ADDITIONALTOOLS_H
28 |
29 | #include
30 | #include
31 |
32 | QT_BEGIN_NAMESPACE
33 | class ImageArea;
34 | class QSize;
35 | QT_END_NAMESPACE
36 |
37 | /**
38 | * @brief Class for implementation of additional tools which changing state of image.
39 | *
40 | */
41 | class AdditionalTools : public QObject
42 | {
43 | Q_OBJECT
44 |
45 | public:
46 | /**
47 | * @brief Constructor
48 | *
49 | * @param pImageArea A pointer to ImageArea.
50 | * @param parent Pointer for parent.
51 | */
52 | explicit AdditionalTools(ImageArea *pImageArea, QObject *parent);
53 | ~AdditionalTools();
54 |
55 | /**
56 | * @brief Resize image area
57 | *
58 | * @param width
59 | * @param height
60 | */
61 | void resizeCanvas(int width, int height, bool flag = false);
62 |
63 | /**
64 | * @brief Resize image
65 | *
66 | */
67 | void resizeImage();
68 |
69 | /**
70 | * @brief Rotate image
71 | *
72 | * @param flag Left or right
73 | */
74 | void rotateImage(bool flag);
75 | /**
76 | * @brief Zoom image
77 | *
78 | * @param factor Scale factor
79 | * @return returns true in case of success
80 | */
81 | bool zoomImage(qreal factor);
82 |
83 | private:
84 | ImageArea *mPImageArea; /**< A pointer to ImageArea */
85 | qreal mZoomedFactor; /**< Difference between original and current image */
86 |
87 | signals:
88 | void sendNewImageSize(const QSize&);
89 |
90 | public slots:
91 |
92 | };
93 |
94 | #endif // ADDITIONALTOOLS_H
95 |
--------------------------------------------------------------------------------
/sources/dialogs/settingsdialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SETTINGSDIALOG_H
27 | #define SETTINGSDIALOG_H
28 |
29 | #include
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QComboBox;
33 | class QSpinBox;
34 | class QCheckBox;
35 | class QLineEdit;
36 | class QTreeWidget;
37 | class QTreeWidgetItem;
38 | class QPushButton;
39 | class QKeySequence;
40 | QT_END_NAMESPACE
41 |
42 | class ShortcutEdit;
43 |
44 | /**
45 | * @brief Dialog for changing application settings.
46 | *
47 | */
48 | class SettingsDialog : public QDialog
49 | {
50 | Q_OBJECT
51 |
52 | public:
53 | explicit SettingsDialog(QWidget *parent);
54 | ~SettingsDialog();
55 |
56 | /**
57 | * @brief Get all settings from form and send it to data singleton.
58 | *
59 | */
60 | void sendSettingsToSingleton();
61 |
62 | private:
63 | void initializeGui();
64 | int getLanguageIndex();
65 | /**
66 | * @brief Create top level item in tree widget and create children items with shortcuts.
67 | *
68 | * @param name Top level item name.
69 | * @param QMap Map with all shortcuts for this group.
70 | */
71 | void createItemsGroup(const QString &name, const QMap &shortcuts);
72 |
73 | QComboBox *mLanguageBox;
74 | QSpinBox *mWidth, *mHeight, *mHistoryDepth, *mAutoSaveInterval;
75 | QCheckBox *mIsAutoSave;
76 | QCheckBox *mIsRestoreWindowSize;
77 | ShortcutEdit *mShortcutEdit;
78 | QTreeWidget *mShortcutsTree;
79 | QCheckBox *mIsAskCanvasSize;
80 |
81 | signals:
82 |
83 | private slots:
84 | void itemSelectionChanged();
85 | void textChanged(const QString &text);
86 | void reset();
87 |
88 | };
89 |
90 | #endif // SETTINGSDIALOG_H
91 |
--------------------------------------------------------------------------------
/sources/widgets/customfiltersettings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 |
28 | #include "customfiltersettings.h"
29 |
30 | CustomFilterSettings::CustomFilterSettings(QWidget *parent) :
31 | AbstractEffectSettings(parent)
32 | {
33 | mSpinBox_11 = createSpinBox();
34 | mSpinBox_12 = createSpinBox();
35 | mSpinBox_13 = createSpinBox();
36 | mSpinBox_21 = createSpinBox();
37 | mSpinBox_22 = createSpinBox();
38 | mSpinBox_23 = createSpinBox();
39 | mSpinBox_31 = createSpinBox();
40 | mSpinBox_32 = createSpinBox();
41 | mSpinBox_33 = createSpinBox();
42 |
43 | QGridLayout *gLayout = new QGridLayout();
44 |
45 | gLayout->addWidget(mSpinBox_11, 0, 0);
46 | gLayout->addWidget(mSpinBox_12, 0, 1);
47 | gLayout->addWidget(mSpinBox_13, 0, 2);
48 | gLayout->addWidget(mSpinBox_21, 1, 0);
49 | gLayout->addWidget(mSpinBox_22, 1, 1);
50 | gLayout->addWidget(mSpinBox_23, 1, 2);
51 | gLayout->addWidget(mSpinBox_31, 2, 0);
52 | gLayout->addWidget(mSpinBox_32, 2, 1);
53 | gLayout->addWidget(mSpinBox_33, 2, 2);
54 |
55 | setLayout(gLayout);
56 | }
57 |
58 | QList CustomFilterSettings::getConvolutionMatrix()
59 | {
60 | QList matrix;
61 |
62 | matrix << mSpinBox_11->value() << mSpinBox_12->value() << mSpinBox_13->value()
63 | << mSpinBox_21->value() << mSpinBox_22->value() << mSpinBox_23->value()
64 | << mSpinBox_31->value() << mSpinBox_32->value() << mSpinBox_33->value();
65 |
66 | return matrix;
67 | }
68 |
69 | QDoubleSpinBox* CustomFilterSettings::createSpinBox()
70 | {
71 | QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
72 | spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
73 | spinBox->setRange(-100.0, 100.0);
74 | connect(spinBox, SIGNAL(valueChanged(double)), this, SIGNAL(matrixChanged()));
75 | return spinBox;
76 | }
77 |
--------------------------------------------------------------------------------
/sources/widgets/toolbar.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef TOOLBAR_H
27 | #define TOOLBAR_H
28 |
29 | #include "../easypaintenums.h"
30 |
31 | #include
32 |
33 | QT_BEGIN_NAMESPACE
34 | class QToolButton;
35 | class ColorChooser;
36 | QT_END_NAMESPACE
37 |
38 | /**
39 | * @brief Toolbar with instrumets buttons, color choosers and etc.
40 | *
41 | */
42 | class ToolBar : public QToolBar
43 | {
44 | Q_OBJECT
45 |
46 | public:
47 | explicit ToolBar(const QMap &actMap, QWidget *parent = 0);
48 |
49 | private:
50 | /**
51 | * @brief Initialize all buttons, color choosers and etc.
52 | *
53 | */
54 | void initializeItems();
55 | /**
56 | * @brief Create new QToolButton
57 | *
58 | * @param name Name of button
59 | * @param iconPath Path to button icon.
60 | * @return QToolButton Created QToolButton.
61 | */
62 | QToolButton* createToolButton(QAction *act);
63 |
64 | QToolButton *mCursorButton, *mEraserButton, *mPenButton, *mLineButton,
65 | *mColorPickerButton, *mMagnifierButton, *mSprayButton, *mFillButton,
66 | *mRectangleButton, *mEllipseButton, *mCurveButton, *mTextButton;
67 | ColorChooser *mPColorChooser, *mSColorChooser;
68 | bool mPrevInstrumentSetted;
69 | const QMap &mActMap;
70 |
71 | signals:
72 | void sendClearStatusBarColor();
73 | void sendClearImageSelection();
74 |
75 | public slots:
76 | void setPrimaryColorView();
77 | void setSecondaryColorView();
78 |
79 | private slots:
80 | void penValueChanged(const int &value);
81 | void primaryColorChanged(const QColor &color);
82 | void secondaryColorChanged(const QColor &color);
83 |
84 | protected:
85 | void contextMenuEvent(QContextMenuEvent *);
86 |
87 | };
88 |
89 | #endif // TOOLBAR_H
90 |
--------------------------------------------------------------------------------
/sources/instruments/selectioninstrument.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef SELECTIONINSTRUMENT_H
27 | #define SELECTIONINSTRUMENT_H
28 |
29 | #include "abstractselection.h"
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QUndoStack;
33 | QT_END_NAMESPACE
34 |
35 | class SelectionInstrument : public AbstractSelection
36 | {
37 | Q_OBJECT
38 |
39 | public:
40 | explicit SelectionInstrument(QObject *parent = 0);
41 |
42 | /**
43 | * @brief Clears background image at selection area.
44 | *
45 | * @param imageArea ImageArea for applying changes.
46 | */
47 | void clearSelectionBackground(ImageArea &imageArea);
48 | /**
49 | * @brief Copying image to the clipboard.
50 | *
51 | * @param imageArea ImageArea for applying changes.
52 | */
53 | void copyImage(ImageArea &imageArea);
54 | /**
55 | * @brief Paste image from the clipboard.
56 | *
57 | * @param imageArea ImageArea for applying changes.
58 | */
59 | void pasteImage(ImageArea &imageArea);
60 | /**
61 | * @brief Cut image to the clipboard.
62 | *
63 | * @param imageArea ImageArea for applying changes.
64 | */
65 | void cutImage(ImageArea &imageArea);
66 |
67 | private:
68 | void startAdjusting(ImageArea &imageArea);
69 | void startSelection(ImageArea &);
70 | void startResizing(ImageArea &imageArea);
71 | void startMoving(ImageArea &imageArea);
72 | void select(ImageArea &);
73 | void resize(ImageArea &);
74 | void move(ImageArea &);
75 | void completeSelection(ImageArea &imageArea);
76 | void completeResizing(ImageArea &imageArea);
77 | void completeMoving(ImageArea &imageArea);
78 | void clear();
79 | void paint(ImageArea &imageArea, bool = false, bool = false);
80 | void showMenu(ImageArea &);
81 |
82 | QImage mSelectedImage, /**< Copy of selected image. */
83 | mPasteImage; /**< Image to paste */
84 |
85 | signals:
86 | void sendEnableCopyCutActions(bool enable);
87 | void sendEnableSelectionInstrument(bool enable);
88 |
89 | };
90 |
91 | #endif // SELECTIONINSTRUMENT_H
92 |
--------------------------------------------------------------------------------
/sources/instruments/abstractselection.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef ABSTRACTSELECTION_H
27 | #define ABSTRACTSELECTION_H
28 |
29 | #include "abstractinstrument.h"
30 |
31 | QT_BEGIN_NAMESPACE
32 | class QUndoStack;
33 | class ImageArea;
34 | QT_END_NAMESPACE
35 |
36 | class AbstractSelection : public AbstractInstrument
37 | {
38 | Q_OBJECT
39 |
40 | public:
41 | explicit AbstractSelection(QObject *parent = 0);
42 |
43 | void mousePressEvent(QMouseEvent *event, ImageArea &imageArea);
44 | void mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea);
45 | void mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea);
46 |
47 | /**
48 | * @brief Removes selection borders from image and clears all selection varaibles to default.
49 | *
50 | * @param imageArea ImageArea for applying changes.
51 | */
52 | void clearSelection(ImageArea &imageArea);
53 | /**
54 | * @brief Save all image changes to image copy.
55 | *
56 | */
57 | void saveImageChanges(ImageArea &);
58 |
59 | virtual void startSelection(ImageArea &imageArea) = 0;
60 | virtual void startResizing(ImageArea &imageArea) = 0;
61 | virtual void startMoving(ImageArea &imageArea) = 0;
62 | virtual void startAdjusting(ImageArea &imageArea) = 0;
63 | virtual void select(ImageArea &imageArea) = 0;
64 | virtual void resize(ImageArea &imageArea) = 0;
65 | virtual void move(ImageArea &imageArea) = 0;
66 | virtual void completeSelection(ImageArea &imageArea) = 0;
67 | virtual void completeResizing(ImageArea &imageArea) = 0;
68 | virtual void completeMoving(ImageArea &imageArea) = 0;
69 | virtual void clear() = 0;
70 | virtual void showMenu(ImageArea &imageArea) = 0;
71 |
72 | protected:
73 | void drawBorder(ImageArea &imageArea);
74 | void updateCursor(QMouseEvent *event, ImageArea &imageArea);
75 |
76 | QPoint mBottomRightPoint, mTopLeftPoint, mMoveDiffPoint;
77 | bool mIsPaint, mIsSelectionExists, mIsSelectionMoving, mIsSelectionResizing, mIsImageSelected,
78 | mIsMouseMoved, mIsSelectionAdjusting;;
79 | int mHeight, mWidth;
80 | Qt::MouseButton mButton;
81 | };
82 |
83 | #endif // ABSTRACTSELECTION_H
84 |
--------------------------------------------------------------------------------
/sources/instruments/colorpickerinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "colorpickerinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | ColorpickerInstrument::ColorpickerInstrument(QObject *parent) :
31 | AbstractInstrument(parent)
32 | {
33 | }
34 |
35 | void ColorpickerInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
36 | {
37 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
38 | {
39 | imageArea.setIsPaint(true);
40 | }
41 | }
42 |
43 | void ColorpickerInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
44 | {
45 | QRgb pixel(imageArea.getImage()->pixel(event->pos()));
46 | QColor getColor(pixel);
47 | imageArea.emitColor(getColor);
48 | }
49 |
50 | void ColorpickerInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
51 | {
52 | if(imageArea.isPaint())
53 | {
54 | mStartPoint = mEndPoint = event->pos();
55 | if(event->button() == Qt::LeftButton)
56 | {
57 | paint(imageArea, false);
58 | imageArea.emitPrimaryColorView();
59 | }
60 | else if(event->button() == Qt::RightButton)
61 | {
62 | paint(imageArea, true);
63 | imageArea.emitSecondaryColorView();
64 | }
65 | imageArea.setIsPaint(false);
66 | imageArea.emitRestorePreviousInstrument();
67 | }
68 | }
69 |
70 | void ColorpickerInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
71 | {
72 | bool inArea(true);
73 | if(mStartPoint.x() < 0 || mStartPoint.y() < 0
74 | || mStartPoint.x() > imageArea.getImage()->width()
75 | || mStartPoint.y() > imageArea.getImage()->height())
76 | inArea = false;
77 |
78 | if(inArea && isSecondaryColor)
79 | {
80 | QRgb pixel(imageArea.getImage()->pixel(mStartPoint));
81 | QColor getColor(pixel);
82 | DataSingleton::Instance()->setSecondaryColor(getColor);
83 | }
84 | if(inArea)
85 | {
86 | QRgb pixel(imageArea.getImage()->pixel(mStartPoint));
87 | QColor getColor(pixel);
88 | DataSingleton::Instance()->setPrimaryColor(getColor);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/sources/widgets/shortcutedit.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "shortcutedit.h"
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | ShortcutEdit::ShortcutEdit(QWidget *parent) :
33 | QLineEdit(parent)
34 | {
35 | setReadOnly(true);
36 |
37 | QPixmap icon(":/media/actions-icons/clear-gray.png");
38 | //Create and set clear text button
39 | mClearButton = new QToolButton(this);
40 | mClearButton->setIcon(QIcon(icon));
41 | mClearButton->setIconSize(icon.size());
42 | mClearButton->setCursor(Qt::ArrowCursor);
43 | mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
44 | mClearButton->setToolTip(tr("Clear"));
45 | mClearButton->hide();
46 |
47 | int fr = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
48 | setStyleSheet(QString("QLineEdit { padding-right: %1px; }").arg(mClearButton->sizeHint().width()
49 | + fr + 1));
50 | QSize msz = minimumSizeHint();
51 | setMinimumSize(qMax(msz.width(), mClearButton->sizeHint().height() + fr * 2 + 2),
52 | qMax(msz.height(),mClearButton->sizeHint().height() + fr * 2 + 2));
53 |
54 | connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear()));
55 | connect(this, SIGNAL(textChanged(QString)), SLOT(updateClearButton(QString)));
56 | }
57 |
58 | void ShortcutEdit::keyPressEvent(QKeyEvent *event)
59 | {
60 | if(event->isAutoRepeat() || isModifier(event->key()))
61 | return;
62 | \
63 | QKeySequence keySeq(event->modifiers() + event->key());
64 | setText(keySeq.toString());
65 | }
66 |
67 | void ShortcutEdit::resizeEvent(QResizeEvent *)
68 | {
69 | int fr = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
70 | mClearButton->move(rect().right() - fr - mClearButton->sizeHint().width(),
71 | (rect().bottom() + 1 -mClearButton->sizeHint().height()) / 2);
72 | }
73 |
74 | bool ShortcutEdit::isModifier(int key)
75 | {
76 | if(key == Qt::Key_Control || key == Qt::Key_Meta || key == Qt::Key_Alt
77 | || key == Qt::Key_AltGr || key == Qt::Key_Shift)
78 | return true;
79 | return false;
80 | }
81 |
82 | void ShortcutEdit::updateClearButton(const QString &text)
83 | {
84 | mClearButton->setVisible(!text.isEmpty());
85 | }
86 |
--------------------------------------------------------------------------------
/sources/instruments/eraserinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "eraserinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 |
33 | EraserInstrument::EraserInstrument(QObject *parent) :
34 | AbstractInstrument(parent)
35 | {
36 | }
37 |
38 | void EraserInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
39 | {
40 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
41 | {
42 | mStartPoint = mEndPoint = event->pos();
43 | imageArea.setIsPaint(true);
44 | makeUndoCommand(imageArea);
45 | }
46 | }
47 |
48 | void EraserInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
49 | {
50 | if(imageArea.isPaint())
51 | {
52 | mEndPoint = event->pos();
53 | paint(imageArea, false);
54 | mStartPoint = event->pos();
55 | }
56 | }
57 |
58 | void EraserInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
59 | {
60 | if(imageArea.isPaint())
61 | {
62 | mEndPoint = event->pos();
63 | paint(imageArea);
64 | imageArea.setIsPaint(false);
65 | }
66 | }
67 |
68 | void EraserInstrument::paint(ImageArea &imageArea, bool, bool)
69 | {
70 | QPainter painter(imageArea.getImage());
71 | painter.setPen(QPen(Qt::white,
72 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
73 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
74 |
75 | if(mStartPoint != mEndPoint)
76 | {
77 | painter.drawLine(mStartPoint, mEndPoint);
78 | }
79 |
80 | if(mStartPoint == mEndPoint)
81 | {
82 | painter.drawPoint(mStartPoint);
83 | }
84 | imageArea.setEdited(true);
85 | // int rad(DataSingleton::Instance()->getPenSize() + round(sqrt((mStartPoint.x() - mEndPoint.x()) *
86 | // (mStartPoint.x() - mEndPoint.x()) +
87 | // (mStartPoint.y() - mEndPoint.y()) *
88 | // (mStartPoint.y() - mEndPoint.y()))));
89 | // mPImageArea->update(QRect(mStartPoint, mEndPoint).normalized().adjusted(-rad, -rad, +rad, +rad));
90 | painter.end();
91 | imageArea.update();
92 | }
93 |
--------------------------------------------------------------------------------
/sources/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "mainwindow.h"
33 | #include "datasingleton.h"
34 |
35 | void printHelpMessage()
36 | {
37 | qDebug()<<"EasyPaint - simple graphics painting program\n"
38 | "Usage: easypaint [options] [filename]\n\n"
39 | "Options:\n"
40 | "\t-h, --help\t\tshow this help message and exit\n"
41 | "\t-v, --version\t\tshow program's version number and exit";
42 | }
43 |
44 | void printVersion()
45 | {
46 | qDebug()<<"0.1.1";
47 | }
48 |
49 | int main(int argc, char *argv[])
50 | {
51 | QApplication a(argc, argv);
52 | a.setApplicationName("EasyPaint");
53 | a.setApplicationVersion("0.1.1");
54 |
55 | QStringList args = a.arguments();
56 |
57 | QRegExp rxArgHelp("--help");
58 | QRegExp rxArgH("-h");
59 | QRegExp rxArgVersion("--version");
60 | QRegExp rxArgV("-v");
61 |
62 | bool isHelp(false), isVer(false);
63 | QStringList filePaths;
64 |
65 | for(int i(1); i < args.size(); ++i)
66 | {
67 | if (rxArgHelp.indexIn(args.at(i)) != -1 ||
68 | rxArgH.indexIn(args.at(i)) != -1)
69 | {
70 | isHelp = true;
71 | }
72 | else if (rxArgVersion.indexIn(args.at(i)) != -1 ||
73 | rxArgV.indexIn(args.at(i)) != -1)
74 | {
75 | isVer = true;
76 | }
77 | else
78 | {
79 | if(QFile::exists(args.at(i)))
80 | {
81 | filePaths.append(args.at(i));
82 | }
83 | else
84 | {
85 | qDebug()<getAppLanguage();
105 | if(appLanguage == "system")
106 | {
107 | appTranslator.load(translationsPath + "easypaint_" + QLocale::system().name());
108 | }
109 | else
110 | {
111 | appTranslator.load(translationsPath + appLanguage);
112 | }
113 | a.installTranslator(&appTranslator);
114 |
115 | MainWindow w(filePaths);
116 | w.show();
117 |
118 | return a.exec();
119 | }
120 |
--------------------------------------------------------------------------------
/sources/dialogs/textdialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "textdialog.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | TextDialog::TextDialog(QString text, ImageArea *parent) :
39 | QDialog(parent)
40 | {
41 | initializeGui();
42 | if (!text.isEmpty())
43 | {
44 | mTextEdit->setText(text);
45 | QTextCursor cursor(mTextEdit->textCursor());
46 | cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
47 | mTextEdit->setTextCursor(cursor);
48 | }
49 | layout()->setSizeConstraint(QLayout::SetFixedSize);
50 | setWindowTitle(tr("Text"));
51 | }
52 |
53 | void TextDialog::initializeGui()
54 | {
55 | QPushButton *mFontButton = new QPushButton(tr("Select Font..."));
56 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
57 | QDialogButtonBox::Cancel);
58 | connect(mFontButton, SIGNAL(clicked()), this, SLOT(selectFont()));
59 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
60 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancel()));
61 | QHBoxLayout *hBox = new QHBoxLayout();
62 | hBox->addWidget(mFontButton);
63 | hBox->addWidget(buttonBox);
64 | mTextEdit = new QTextEdit();
65 | mTextEdit->setLineWrapMode(QTextEdit::NoWrap);
66 | QVBoxLayout *mainLayout = new QVBoxLayout();
67 | mainLayout->addWidget(mTextEdit);
68 | mainLayout->addLayout(hBox);
69 | setLayout(mainLayout);
70 | connect(mTextEdit, SIGNAL(textChanged()), this, SLOT(textChanged()));
71 | }
72 |
73 | void TextDialog::textChanged()
74 | {
75 | emit textChanged(qobject_cast(this->parent()), mTextEdit->toPlainText());
76 | }
77 |
78 | void TextDialog::selectFont()
79 | {
80 | bool ok;
81 | QFont font = DataSingleton::Instance()->getTextFont();
82 | font = QFontDialog::getFont(&ok, font, this);
83 | if (ok)
84 | {
85 | DataSingleton::Instance()->setTextFont(font);
86 | textChanged();
87 | mTextEdit->setFocus();
88 | }
89 | }
90 |
91 | void TextDialog::cancel()
92 | {
93 | emit canceled(qobject_cast(this->parent()));
94 | QDialog::reject();
95 | }
96 |
97 | void TextDialog::reject()
98 | {
99 | if (mTextEdit->toPlainText().isEmpty() ||
100 | QMessageBox::question(this, tr("Question"), tr("Clear text?"),
101 | QMessageBox::Yes | QMessageBox::No,
102 | QMessageBox::No) == QMessageBox::Yes)
103 | {
104 | emit canceled(qobject_cast(this->parent()));
105 | }
106 | QDialog::reject();
107 | }
108 |
--------------------------------------------------------------------------------
/sources/instruments/textinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "textinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 | #include "../undocommand.h"
30 | #include "../dialogs/textdialog.h"
31 |
32 | #include
33 |
34 | TextInstrument::TextInstrument(QObject *parent) :
35 | AbstractSelection(parent)
36 | {
37 | mText = QString();
38 | mIsEdited = false;
39 | }
40 |
41 | void TextInstrument::updateText(ImageArea *imageArea, QString textString)
42 | {
43 | mText = textString;
44 | imageArea->setImage(mImageCopy);
45 | if (!mIsEdited)
46 | {
47 | makeUndoCommand(*imageArea);
48 | mIsEdited = true;
49 | }
50 | paint(*imageArea);
51 | drawBorder(*imageArea);
52 | }
53 |
54 | void TextInstrument::startAdjusting(ImageArea &)
55 | {
56 | }
57 |
58 | void TextInstrument::startSelection(ImageArea &)
59 | {
60 | }
61 |
62 | void TextInstrument::startResizing(ImageArea &)
63 | {
64 | }
65 |
66 | void TextInstrument::startMoving(ImageArea &)
67 | {
68 | }
69 |
70 | void TextInstrument::select(ImageArea &)
71 | {
72 | }
73 |
74 | void TextInstrument::resize(ImageArea &imageArea)
75 | {
76 | paint(imageArea);
77 | }
78 |
79 | void TextInstrument::move(ImageArea &imageArea)
80 | {
81 | paint(imageArea);
82 | }
83 |
84 | void TextInstrument::completeSelection(ImageArea &imageArea)
85 | {
86 | TextDialog *td = new TextDialog(mText, &imageArea);
87 | connect(td, SIGNAL(textChanged(ImageArea *, QString)), this, SLOT(updateText(ImageArea *, QString)));
88 | connect(this, SIGNAL(sendCloseTextDialog()), td, SLOT(accept()));
89 | connect(td, SIGNAL(canceled(ImageArea *)), this, SLOT(cancel(ImageArea *)));
90 | td->setAttribute(Qt::WA_DeleteOnClose);
91 | td->show();
92 | }
93 |
94 | void TextInstrument::completeResizing(ImageArea &)
95 | {
96 | }
97 |
98 | void TextInstrument::completeMoving(ImageArea &)
99 | {
100 | }
101 |
102 | void TextInstrument::clear()
103 | {
104 | mText = QString();
105 | mIsEdited = false;
106 | emit sendCloseTextDialog();
107 | }
108 |
109 | void TextInstrument::cancel(ImageArea *imageArea)
110 | {
111 | mText = QString();
112 | clearSelection(*imageArea);
113 | }
114 |
115 | void TextInstrument::paint(ImageArea &imageArea, bool, bool)
116 | {
117 | if(mTopLeftPoint != mBottomRightPoint)
118 | {
119 | QPainter painter(imageArea.getImage());
120 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor()));
121 | painter.setFont(DataSingleton::Instance()->getTextFont());
122 | painter.drawText(QRect(mTopLeftPoint, mBottomRightPoint), mText);
123 | painter.end();
124 | imageArea.setEdited(true);
125 | imageArea.update();
126 | }
127 | }
128 |
129 | void TextInstrument::showMenu(ImageArea &imageArea)
130 | {
131 | emit sendCloseTextDialog();
132 | completeSelection(imageArea); //show text dialog
133 | }
134 |
--------------------------------------------------------------------------------
/sources/instruments/ellipseinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "ellipseinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 |
33 | EllipseInstrument::EllipseInstrument(QObject *parent) :
34 | AbstractInstrument(parent)
35 | {
36 | }
37 |
38 | void EllipseInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
39 | {
40 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
41 | {
42 | mStartPoint = mEndPoint = event->pos();
43 | imageArea.setIsPaint(true);
44 | mImageCopy = *imageArea.getImage();
45 | makeUndoCommand(imageArea);
46 | }
47 | }
48 |
49 | void EllipseInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
50 | {
51 | if(imageArea.isPaint())
52 | {
53 | mEndPoint = event->pos();
54 | imageArea.setImage(mImageCopy);
55 | if(event->buttons() & Qt::LeftButton)
56 | {
57 | paint(imageArea, false);
58 | }
59 | else if(event->buttons() & Qt::RightButton)
60 | {
61 | paint(imageArea, true);
62 | }
63 | }
64 | }
65 |
66 | void EllipseInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
67 | {
68 | if(imageArea.isPaint())
69 | {
70 | imageArea.setImage(mImageCopy);
71 | if(event->button() == Qt::LeftButton)
72 | {
73 | paint(imageArea, false);
74 | }
75 | else if(event->button() == Qt::RightButton)
76 | {
77 | paint(imageArea, true);
78 | }
79 | imageArea.setIsPaint(false);
80 | }
81 | }
82 |
83 | void EllipseInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
84 | {
85 | QPainter painter(imageArea.getImage());
86 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor(),
87 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
88 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
89 | if(isSecondaryColor)
90 | {
91 | painter.setBrush(QBrush(DataSingleton::Instance()->getSecondaryColor()));
92 | }
93 | if(mStartPoint != mEndPoint)
94 | {
95 | painter.drawEllipse(QRect(mStartPoint, mEndPoint));
96 | }
97 | imageArea.setEdited(true);
98 | // int rad(DataSingleton::Instance()->getPenSize() + round(sqrt((mStartPoint.x() - mEndPoint.x()) *
99 | // (mStartPoint.x() - mEndPoint.x()) +
100 | // (mStartPoint.y() - mEndPoint.y()) *
101 | // (mStartPoint.y() - mEndPoint.y()))));
102 | // mPImageArea->update(QRect(mStartPoint, mEndPoint).normalized().adjusted(-rad, -rad, +rad, +rad));
103 | painter.end();
104 | imageArea.update();
105 | }
106 |
--------------------------------------------------------------------------------
/sources/instruments/rectangleinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "rectangleinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 |
33 | RectangleInstrument::RectangleInstrument(QObject *parent) :
34 | AbstractInstrument(parent)
35 | {
36 | }
37 |
38 | void RectangleInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
39 | {
40 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
41 | {
42 | mStartPoint = mEndPoint = event->pos();
43 | imageArea.setIsPaint(true);
44 | mImageCopy = *imageArea.getImage();
45 | makeUndoCommand(imageArea);
46 | }
47 | }
48 |
49 | void RectangleInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
50 | {
51 | if(imageArea.isPaint())
52 | {
53 | mEndPoint = event->pos();
54 | imageArea.setImage(mImageCopy);
55 | if(event->buttons() & Qt::LeftButton)
56 | {
57 | paint(imageArea, false);
58 | }
59 | else if(event->buttons() & Qt::RightButton)
60 | {
61 | paint(imageArea, true);
62 | }
63 | }
64 | }
65 |
66 | void RectangleInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
67 | {
68 | if(imageArea.isPaint())
69 | {
70 | imageArea.setImage(mImageCopy);
71 | if(event->button() == Qt::LeftButton)
72 | {
73 | paint(imageArea, false);
74 | }
75 | else if(event->button() == Qt::RightButton)
76 | {
77 | paint(imageArea, true);
78 | }
79 | imageArea.setIsPaint(false);
80 | }
81 | }
82 |
83 | void RectangleInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
84 | {
85 | QPainter painter(imageArea.getImage());
86 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor(),
87 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
88 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
89 | if(isSecondaryColor)
90 | {
91 | painter.setBrush(QBrush(DataSingleton::Instance()->getSecondaryColor()));
92 | }
93 | if(mStartPoint != mEndPoint)
94 | {
95 | painter.drawRect(QRect(mStartPoint, mEndPoint));
96 | }
97 | imageArea.setEdited(true);
98 | // int rad(DataSingleton::Instance()->getPenSize() + round(sqrt((mStartPoint.x() - mEndPoint.x()) *
99 | // (mStartPoint.x() - mEndPoint.x()) +
100 | // (mStartPoint.y() - mEndPoint.y()) *
101 | // (mStartPoint.y() - mEndPoint.y()))));
102 | // mPImageArea->update(QRect(mStartPoint, mEndPoint).normalized().adjusted(-rad, -rad, +rad, +rad));
103 | painter.end();
104 | imageArea.update();
105 | }
106 |
--------------------------------------------------------------------------------
/sources/dialogs/effectsettingsdialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include
27 |
28 | #include
29 | #include
30 |
31 | #include "effectsettingsdialog.h"
32 |
33 | EffectSettingsDialog::EffectSettingsDialog(const QImage &img, AbstractEffectSettings *settingsWidget, QWidget *parent) :
34 | QDialog(parent), mImage(img)
35 | {
36 | mSettingsWidget = settingsWidget;
37 | mImagePreview = new ImagePreview(&mImage, this);
38 | mImagePreview->setMinimumSize(140, 140);
39 |
40 | mOkButton = new QPushButton(tr("Ok"), this);
41 | connect(mOkButton, SIGNAL(clicked()), this, SLOT(applyMatrix()));
42 | connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
43 | mCancelButton = new QPushButton(tr("Cancel"), this);
44 | connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
45 | mApplyButton = new QPushButton(tr("Apply"), this);
46 | connect(mApplyButton, SIGNAL(clicked()), this, SLOT(applyMatrix()));
47 | connect(mApplyButton, SIGNAL(clicked()), mImagePreview, SLOT(update()));
48 |
49 | QHBoxLayout *hLayout_1 = new QHBoxLayout();
50 |
51 | hLayout_1->addWidget(mImagePreview);
52 | hLayout_1->addWidget(mSettingsWidget);
53 |
54 | QHBoxLayout *hLayout_2 = new QHBoxLayout();
55 |
56 | hLayout_2->addWidget(mOkButton);
57 | hLayout_2->addWidget(mCancelButton);
58 | hLayout_2->addWidget(mApplyButton);
59 |
60 | QVBoxLayout *vLayout = new QVBoxLayout();
61 |
62 | vLayout->addLayout(hLayout_1);
63 | vLayout->addLayout(hLayout_2);
64 |
65 | setLayout(vLayout);
66 | }
67 |
68 | QRgb EffectSettingsDialog::convolutePixel(const QImage &image, int x, int y, const QList &kernelMatrix)
69 | {
70 | int kernelSize = sqrt(kernelMatrix.size());
71 |
72 | double total = 0;
73 | double red = 0;
74 | double green = 0;
75 | double blue = 0;
76 | // TODO: some optimization can be made (maybe use OpenCV in future
77 | for(int r = -kernelSize / 2; r <= kernelSize / 2; ++r)
78 | {
79 | for(int c = -kernelSize / 2; c <= kernelSize / 2; ++c)
80 | {
81 | int kernelValue = kernelMatrix[(kernelSize / 2 + r) * kernelSize + (kernelSize / 2 + c)];
82 | total += kernelValue;
83 | red += qRed(image.pixel(x + c, y + r)) * kernelValue;
84 | green += qGreen(image.pixel(x + c, y + r)) * kernelValue;
85 | blue += qBlue(image.pixel(x + c, y + r)) * kernelValue;
86 | }
87 | }
88 |
89 | if(total == 0)
90 | return qRgb(qBound(0, qRound(red), 255), qBound(0, qRound(green), 255), qBound(0, qRound(blue), 255));
91 |
92 | return qRgb(qBound(0, qRound(red / total), 255), qBound(0, qRound(green / total), 255), qBound(0, qRound(blue / total), 255));
93 | }
94 |
95 | void EffectSettingsDialog::applyMatrix()
96 | {
97 | QImage copy(mImage);
98 |
99 | for(int i = 2; i < copy.height() - 2; ++i)
100 | {
101 | for(int j = 2; j < copy.width() - 2; ++j)
102 | {
103 | copy.setPixel(j, i, convolutePixel(mImage, j, i, mSettingsWidget->getConvolutionMatrix()));
104 | }
105 | }
106 |
107 | mImage = copy;
108 | }
109 |
--------------------------------------------------------------------------------
/sources/widgets/palettebar.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "palettebar.h"
27 | #include "../datasingleton.h"
28 |
29 | PaletteBar::PaletteBar(ToolBar *toolbar) :
30 | QToolBar(tr("Colors"))
31 | {
32 | mToolBar = toolbar;
33 | setMovable(false);
34 | initializeItems();
35 | }
36 |
37 | void PaletteBar::initializeItems()
38 | {
39 | mColorButton = new PaletteButton(Qt::black);
40 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
41 | addWidget(mColorButton);
42 |
43 | mColorButton = new PaletteButton(Qt::white);
44 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
45 | addWidget(mColorButton);
46 |
47 | mColorButton = new PaletteButton(Qt::red);
48 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
49 | addWidget(mColorButton);
50 |
51 | mColorButton = new PaletteButton(Qt::darkRed);
52 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
53 | addWidget(mColorButton);
54 |
55 | mColorButton = new PaletteButton(Qt::green);
56 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
57 | addWidget(mColorButton);
58 |
59 | mColorButton = new PaletteButton(Qt::darkGreen);
60 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
61 | addWidget(mColorButton);
62 |
63 | mColorButton = new PaletteButton(Qt::blue);
64 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
65 | addWidget(mColorButton);
66 |
67 | mColorButton = new PaletteButton(Qt::darkBlue);
68 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
69 | addWidget(mColorButton);
70 |
71 | mColorButton = new PaletteButton(Qt::cyan);
72 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
73 | addWidget(mColorButton);
74 |
75 | mColorButton = new PaletteButton(Qt::darkCyan);
76 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
77 | addWidget(mColorButton);
78 |
79 | mColorButton = new PaletteButton(Qt::magenta);
80 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
81 | addWidget(mColorButton);
82 |
83 | mColorButton = new PaletteButton(Qt::darkMagenta);
84 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
85 | addWidget(mColorButton);
86 |
87 | mColorButton = new PaletteButton(Qt::yellow);
88 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
89 | addWidget(mColorButton);
90 |
91 | mColorButton = new PaletteButton(Qt::darkYellow);
92 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
93 | addWidget(mColorButton);
94 |
95 | mColorButton = new PaletteButton(Qt::gray);
96 | connect(mColorButton, SIGNAL(colorPicked()), this, SLOT(colorClicked()));
97 | addWidget(mColorButton);
98 | }
99 |
100 | void PaletteBar::colorClicked()
101 | {
102 | mToolBar->setPrimaryColorView();
103 | mToolBar->setSecondaryColorView();
104 | }
105 |
106 | void PaletteBar::contextMenuEvent(QContextMenuEvent *) { }
107 |
--------------------------------------------------------------------------------
/sources/instruments/pencilinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "pencilinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 |
33 | PencilInstrument::PencilInstrument(QObject *parent) :
34 | AbstractInstrument(parent)
35 | {
36 | }
37 |
38 | void PencilInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
39 | {
40 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
41 | {
42 | mStartPoint = mEndPoint = event->pos();
43 | imageArea.setIsPaint(true);
44 | makeUndoCommand(imageArea);
45 | }
46 | }
47 |
48 | void PencilInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
49 | {
50 | if(imageArea.isPaint())
51 | {
52 | mEndPoint = event->pos();
53 | if(event->buttons() & Qt::LeftButton)
54 | {
55 | paint(imageArea, false);
56 | }
57 | else if(event->buttons() & Qt::RightButton)
58 | {
59 | paint(imageArea, true);
60 | }
61 | mStartPoint = event->pos();
62 | }
63 | }
64 |
65 | void PencilInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
66 | {
67 | if(imageArea.isPaint())
68 | {
69 | mEndPoint = event->pos();
70 | if(event->button() == Qt::LeftButton)
71 | {
72 | paint(imageArea, false);
73 | }
74 | else if(event->button() == Qt::RightButton)
75 | {
76 | paint(imageArea, true);
77 | }
78 | imageArea.setIsPaint(false);
79 | }
80 | }
81 |
82 | void PencilInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
83 | {
84 | QPainter painter(imageArea.getImage());
85 | if(isSecondaryColor)
86 | {
87 | painter.setPen(QPen(DataSingleton::Instance()->getSecondaryColor(),
88 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
89 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
90 | }
91 | else
92 | {
93 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor(),
94 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
95 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
96 | }
97 |
98 | if(mStartPoint != mEndPoint)
99 | {
100 | painter.drawLine(mStartPoint, mEndPoint);
101 | }
102 |
103 | if(mStartPoint == mEndPoint)
104 | {
105 | painter.drawPoint(mStartPoint);
106 | }
107 | imageArea.setEdited(true);
108 | // int rad(DataSingleton::Instance()->getPenSize() + round(sqrt((mStartPoint.x() - mEndPoint.x()) *
109 | // (mStartPoint.x() - mEndPoint.x()) +
110 | // (mStartPoint.y() - mEndPoint.y()) *
111 | // (mStartPoint.y() - mEndPoint.y()))));
112 | // mPImageArea->update(QRect(mStartPoint, mEndPoint).normalized().adjusted(-rad, -rad, +rad, +rad));
113 | painter.end();
114 | imageArea.update();
115 | }
116 |
--------------------------------------------------------------------------------
/sources/instruments/lineinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "lineinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | LineInstrument::LineInstrument(QObject *parent) :
35 | AbstractInstrument(parent)
36 | {
37 | }
38 |
39 | void LineInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
40 | {
41 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
42 | {
43 | mStartPoint = mEndPoint = event->pos();
44 | imageArea.setIsPaint(true);
45 | mImageCopy = *imageArea.getImage();
46 | makeUndoCommand(imageArea);
47 | }
48 | }
49 |
50 | void LineInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
51 | {
52 | if(imageArea.isPaint())
53 | {
54 | mEndPoint = event->pos();
55 | imageArea.setImage(mImageCopy);
56 | if(event->buttons() & Qt::LeftButton)
57 | {
58 | paint(imageArea, false);
59 | }
60 | else if(event->buttons() & Qt::RightButton)
61 | {
62 | paint(imageArea, true);
63 | }
64 | }
65 | }
66 |
67 | void LineInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
68 | {
69 | if(imageArea.isPaint())
70 | {
71 | imageArea.setImage(mImageCopy);
72 | if(event->button() == Qt::LeftButton)
73 | {
74 | paint(imageArea, false);
75 | }
76 | else if(event->button() == Qt::RightButton)
77 | {
78 | paint(imageArea, true);
79 | }
80 | imageArea.setIsPaint(false);
81 | }
82 | }
83 |
84 | void LineInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
85 | {
86 | QPainter painter(imageArea.getImage());
87 | if(isSecondaryColor)
88 | {
89 | painter.setPen(QPen(DataSingleton::Instance()->getSecondaryColor(),
90 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
91 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
92 | }
93 | else
94 | {
95 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor(),
96 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
97 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
98 | }
99 |
100 | if(mStartPoint != mEndPoint)
101 | {
102 | painter.drawLine(mStartPoint, mEndPoint);
103 | }
104 |
105 | if(mStartPoint == mEndPoint)
106 | {
107 | painter.drawPoint(mStartPoint);
108 | }
109 | imageArea.setEdited(true);
110 | // int rad(DataSingleton::Instance()->getPenSize() + round(sqrt((mStartPoint.x() - mEndPoint.x()) *
111 | // (mStartPoint.x() - mEndPoint.x()) +
112 | // (mStartPoint.y() - mEndPoint.y()) *
113 | // (mStartPoint.y() - mEndPoint.y()))));
114 | // mPImageArea->update(QRect(mStartPoint, mEndPoint).normalized().adjusted(-rad, -rad, +rad, +rad));
115 | painter.end();
116 | imageArea.update();
117 | }
118 |
--------------------------------------------------------------------------------
/sources/easypaint.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2012-03-03T14:45:04
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4) {
10 | QT += widgets printsupport
11 | DEFINES += HAVE_QT5
12 | }
13 |
14 | TARGET = easypaint
15 | VERSION = 0.1.1
16 | TEMPLATE = app
17 |
18 | DESTDIR = bin
19 | OBJECTS_DIR = build
20 | MOC_DIR = build
21 | UI_DIR = build
22 |
23 | SOURCES += main.cpp\
24 | mainwindow.cpp \
25 | imagearea.cpp \
26 | datasingleton.cpp \
27 | additionaltools.cpp \
28 | undocommand.cpp \
29 | widgets/toolbar.cpp \
30 | widgets/colorchooser.cpp \
31 | widgets/palettebar.cpp \
32 | widgets/palettebutton.cpp \
33 | widgets/shortcutedit.cpp \
34 | dialogs/resizedialog.cpp \
35 | dialogs/settingsdialog.cpp \
36 | dialogs/textdialog.cpp \
37 | instruments/abstractinstrument.cpp \
38 | instruments/abstractselection.cpp \
39 | instruments/pencilinstrument.cpp \
40 | instruments/lineinstrument.cpp \
41 | instruments/eraserinstrument.cpp \
42 | instruments/rectangleinstrument.cpp \
43 | instruments/ellipseinstrument.cpp \
44 | instruments/fillinstrument.cpp \
45 | instruments/sprayinstrument.cpp \
46 | instruments/magnifierinstrument.cpp \
47 | instruments/colorpickerinstrument.cpp \
48 | instruments/selectioninstrument.cpp \
49 | instruments/curvelineinstrument.cpp \
50 | instruments/textinstrument.cpp \
51 | effects/abstracteffect.cpp \
52 | effects/negativeeffect.cpp \
53 | effects/grayeffect.cpp \
54 | effects/binarizationeffect.cpp \
55 | effects/gammaeffect.cpp \
56 | dialogs/effectsettingsdialog.cpp \
57 | widgets/customfiltersettings.cpp \
58 | effects/effectwithsettings.cpp \
59 | widgets/sharpenfiltersettings.cpp \
60 | widgets/imagepreview.cpp \
61 | widgets/gaussianblurfiltersettings.cpp
62 |
63 | HEADERS += mainwindow.h \
64 | easypaintenums.h \
65 | imagearea.h \
66 | datasingleton.h \
67 | additionaltools.h \
68 | undocommand.h \
69 | widgets/toolbar.h \
70 | widgets/colorchooser.h \
71 | widgets/palettebar.h \
72 | widgets/palettebutton.h \
73 | widgets/shortcutedit.h \
74 | dialogs/resizedialog.h \
75 | dialogs/settingsdialog.h \
76 | dialogs/textdialog.h \
77 | instruments/abstractinstrument.h \
78 | instruments/abstractselection.h \
79 | instruments/pencilinstrument.h \
80 | instruments/lineinstrument.h \
81 | instruments/eraserinstrument.h \
82 | instruments/rectangleinstrument.h \
83 | instruments/ellipseinstrument.h \
84 | instruments/fillinstrument.h \
85 | instruments/sprayinstrument.h \
86 | instruments/magnifierinstrument.h \
87 | instruments/colorpickerinstrument.h \
88 | instruments/selectioninstrument.h \
89 | instruments/curvelineinstrument.h \
90 | instruments/textinstrument.h \
91 | effects/abstracteffect.h \
92 | effects/negativeeffect.h \
93 | effects/grayeffect.h \
94 | effects/binarizationeffect.h \
95 | effects/gammaeffect.h \
96 | effects/gaussianblureffect.h \
97 | effects/sharpeneffect.h \
98 | dialogs/effectsettingsdialog.h \
99 | widgets/customfiltersettings.h \
100 | widgets/abstracteffectsettings.h \
101 | effects/effectwithsettings.h \
102 | effects/customeffect.h \
103 | widgets/sharpenfiltersettings.h \
104 | widgets/imagepreview.h \
105 | widgets/gaussianblurfiltersettings.h
106 |
107 | TRANSLATIONS += \
108 | translations/easypaint_cs_CZ.ts \
109 | translations/easypaint_fr_FR.ts \
110 | translations/easypaint_ru_RU.ts
111 |
112 | RESOURCES += \
113 | resources.qrc
114 |
115 | target.path = /usr/bin
116 | translations.path = /usr/share/easypaint/translations
117 | translations.files = translations/*.qm
118 | desktop.path = /usr/share/applications
119 | desktop.files = media/easypaint.desktop
120 | icon.path = /usr/share/pixmaps
121 | icon.files = media/logo/easypaint_64.png
122 | isEmpty(QMAKE_LRELEASE) {
123 | win32 {
124 | QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
125 | }
126 | else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease-qt4
127 | }
128 | isEmpty(TS_DIR) {
129 | TS_DIR = translations
130 | }
131 | ;TSQM.name = $$QMAKE_LRELEASE
132 | ;TSQM.input = TRANSLATIONS
133 | ;TSQM.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
134 | ;TSQM.commands = $$QMAKE_LRELEASE
135 | ;TSQM.CONFIG = no_link
136 | ;QMAKE_EXTRA_COMPILERS += TSQM
137 | ;PRE_TARGETDEPS += compiler_TSQM_make_all
138 | INSTALLS += target translations desktop icon
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/sources/instruments/fillinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "fillinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 |
33 | FillInstrument::FillInstrument(QObject *parent) :
34 | AbstractInstrument(parent)
35 | {
36 | }
37 |
38 | void FillInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
39 | {
40 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
41 | {
42 | mStartPoint = mEndPoint = event->pos();
43 | imageArea.setIsPaint(true);
44 | makeUndoCommand(imageArea);
45 | }
46 | }
47 |
48 | void FillInstrument::mouseMoveEvent(QMouseEvent *, ImageArea &)
49 | {
50 |
51 | }
52 |
53 | void FillInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
54 | {
55 | if(imageArea.isPaint())
56 | {
57 | if(event->button() == Qt::LeftButton)
58 | {
59 | paint(imageArea, false);
60 | }
61 | else if(event->button() == Qt::RightButton)
62 | {
63 | paint(imageArea, true);
64 | }
65 | imageArea.setIsPaint(false);
66 | }
67 | }
68 |
69 | void FillInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
70 | {
71 | QColor switchColor;
72 | if(!isSecondaryColor)
73 | switchColor = DataSingleton::Instance()->getPrimaryColor();
74 | else
75 | switchColor = DataSingleton::Instance()->getSecondaryColor();
76 |
77 | QRgb pixel(imageArea.getImage()->pixel(mStartPoint));
78 | QColor oldColor(pixel);
79 |
80 | if(switchColor != oldColor)
81 | {
82 | fillRecurs(mStartPoint.x(), mStartPoint.y(),
83 | switchColor.rgb(), oldColor.rgb(),
84 | *imageArea.getImage());
85 | }
86 | imageArea.setEdited(true);
87 | imageArea.update();
88 | }
89 |
90 | void FillInstrument::fillRecurs(int x, int y, QRgb switchColor, QRgb oldColor, QImage &tempImage)
91 | {
92 | int temp_x(x), left_x(0);
93 | while(true)
94 | {
95 | if(tempImage.pixel(temp_x, y) != oldColor)
96 | break;
97 | tempImage.setPixel(temp_x, y, switchColor);
98 | if(temp_x > 0)
99 | {
100 | --temp_x;
101 | left_x = temp_x;
102 | }
103 | else
104 | break;
105 | }
106 |
107 | int right_x(0);
108 | temp_x = x + 1;
109 | while(true)
110 | {
111 | if(tempImage.pixel(temp_x, y) != oldColor)
112 | break;
113 | tempImage.setPixel(temp_x, y, switchColor);
114 | if(temp_x < tempImage.width() - 1)
115 | {
116 | temp_x++;
117 | right_x = temp_x;
118 | }
119 | else
120 | break;
121 | }
122 |
123 | for(int x_(left_x+1); x_ < right_x; ++x_)
124 | {
125 | if(y < 1 || y >= tempImage.height() - 1)
126 | break;
127 | if(right_x > tempImage.width())
128 | break;
129 | QRgb currentColor = tempImage.pixel(x_, y - 1);
130 | if(currentColor == oldColor && currentColor != switchColor)
131 | fillRecurs(x_, y - 1, switchColor, oldColor, tempImage);
132 | currentColor = tempImage.pixel(x_, y + 1);
133 | if(currentColor == oldColor && currentColor != switchColor)
134 | fillRecurs(x_, y + 1, switchColor, oldColor, tempImage);
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/sources/additionaltools.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "additionaltools.h"
27 | #include "imagearea.h"
28 | #include "dialogs/resizedialog.h"
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | AdditionalTools::AdditionalTools(ImageArea *pImageArea, QObject *parent) :
39 | QObject(parent)
40 | {
41 | mPImageArea = pImageArea;
42 | mZoomedFactor = 1;
43 | }
44 |
45 | AdditionalTools::~AdditionalTools()
46 | {
47 |
48 | }
49 |
50 | void AdditionalTools::resizeCanvas(int width, int height, bool flag)
51 | {
52 | if(flag)
53 | {
54 | ResizeDialog resizeDialog(QSize(width, height), qobject_cast(this->parent()));
55 | if(resizeDialog.exec() == QDialog::Accepted)
56 | {
57 | QSize newSize = resizeDialog.getNewSize();
58 | width = newSize.width();
59 | height = newSize.height();
60 | } else {
61 | return;
62 | }
63 | }
64 |
65 | if(width < 1 || height < 1)
66 | return;
67 | QImage *tempImage = new QImage(width, height, QImage::Format_ARGB32_Premultiplied);
68 | QPainter painter(tempImage);
69 | painter.setPen(Qt::NoPen);
70 | painter.setBrush(QBrush(Qt::white));
71 | painter.drawRect(QRect(0, 0, width, height));
72 | painter.drawImage(0, 0, *mPImageArea->getImage());
73 | painter.end();
74 |
75 | mPImageArea->setImage(*tempImage);
76 |
77 | mPImageArea->resize(mPImageArea->getImage()->rect().right() + 6,
78 | mPImageArea->getImage()->rect().bottom() + 6);
79 | mPImageArea->setEdited(true);
80 | mPImageArea->clearSelection();
81 | }
82 |
83 | void AdditionalTools::resizeImage()
84 | {
85 | ResizeDialog resizeDialog(mPImageArea->getImage()->size(), qobject_cast(this->parent()));
86 | if(resizeDialog.exec() == QDialog::Accepted)
87 | {
88 | mPImageArea->setImage(mPImageArea->getImage()->scaled(resizeDialog.getNewSize()));
89 | mPImageArea->resize(mPImageArea->getImage()->rect().right() + 6,
90 | mPImageArea->getImage()->rect().bottom() + 6);
91 | mPImageArea->setEdited(true);
92 | mPImageArea->clearSelection();
93 | }
94 | }
95 |
96 | void AdditionalTools::rotateImage(bool flag)
97 | {
98 | QTransform transform;
99 | if(flag)
100 | {
101 | transform.rotate(90);
102 | }
103 | else
104 | {
105 | transform.rotate(-90);
106 | }
107 | mPImageArea->setImage(mPImageArea->getImage()->transformed(transform));
108 | mPImageArea->resize(mPImageArea->getImage()->rect().right() + 6,
109 | mPImageArea->getImage()->rect().bottom() + 6);
110 | mPImageArea->update();
111 | mPImageArea->setEdited(true);
112 | mPImageArea->clearSelection();
113 | }
114 |
115 | bool AdditionalTools::zoomImage(qreal factor)
116 | {
117 | mZoomedFactor *= factor;
118 | if(mZoomedFactor < 0.25)
119 | {
120 | mZoomedFactor = 0.25;
121 | return false;
122 | }
123 | else if(mZoomedFactor > 4)
124 | {
125 | mZoomedFactor = 4;
126 | return false;
127 | }
128 | else
129 | {
130 | mPImageArea->setImage(mPImageArea->getImage()->transformed(QTransform::fromScale(factor, factor)));
131 | mPImageArea->resize((mPImageArea->rect().width())*factor, (mPImageArea->rect().height())*factor);
132 | emit sendNewImageSize(mPImageArea->size());
133 | mPImageArea->setEdited(true);
134 | mPImageArea->clearSelection();
135 | return true;
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/sources/instruments/sprayinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "sprayinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | SprayInstrument::SprayInstrument(QObject *parent) :
35 | AbstractInstrument(parent)
36 | {
37 | }
38 |
39 | void SprayInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
40 | {
41 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
42 | {
43 | mStartPoint = mEndPoint = event->pos();
44 | imageArea.setIsPaint(true);
45 | makeUndoCommand(imageArea);
46 | }
47 | }
48 |
49 | void SprayInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
50 | {
51 | if(imageArea.isPaint())
52 | {
53 | mEndPoint = event->pos();
54 | if(event->buttons() & Qt::LeftButton)
55 | {
56 | paint(imageArea, false);
57 | }
58 | else if(event->buttons() & Qt::RightButton)
59 | {
60 | paint(imageArea, true);
61 | }
62 | mStartPoint = event->pos();
63 | }
64 | }
65 |
66 | void SprayInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
67 | {
68 | if(imageArea.isPaint())
69 | {
70 | if(event->button() == Qt::LeftButton)
71 | {
72 | paint(imageArea, false);
73 | }
74 | else if(event->button() == Qt::RightButton)
75 | {
76 | paint(imageArea, true);
77 | }
78 | imageArea.setIsPaint(false);
79 | }
80 | }
81 |
82 | void SprayInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
83 | {
84 | QPainter painter(imageArea.getImage());
85 | if(isSecondaryColor)
86 | {
87 | painter.setPen(QPen(DataSingleton::Instance()->getSecondaryColor(),
88 | sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor()),
89 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
90 | }
91 | else
92 | {
93 | painter.setPen(QPen(DataSingleton::Instance()->getPrimaryColor(),
94 | sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor()),
95 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
96 | }
97 |
98 | int x, y;
99 | for(int i(0); i < 12; i++)
100 | {
101 | switch(i) {
102 | case 0: case 1: case 2: case 3:
103 | x = (qrand() % 5 - 2)
104 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
105 | y = (qrand() % 5 - 2)
106 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
107 | break;
108 | case 4: case 5: case 6: case 7:
109 | x = (qrand() % 10 - 4)
110 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
111 | y = (qrand() % 10 - 4)
112 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
113 | break;
114 | case 8: case 9: case 10: case 11:
115 | x = (qrand() % 15 - 7)
116 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
117 | y = (qrand() % 15 - 7)
118 | * sqrt(DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor());
119 | break;
120 | }
121 | painter.drawPoint(mEndPoint.x() + x,
122 | mEndPoint.y() + y);
123 | }
124 | imageArea.setEdited(true);
125 | painter.end();
126 | imageArea.update();
127 | }
128 |
--------------------------------------------------------------------------------
/sources/instruments/curvelineinstrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #include "curvelineinstrument.h"
27 | #include "../imagearea.h"
28 | #include "../datasingleton.h"
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | CurveLineInstrument::CurveLineInstrument(QObject *parent) :
35 | AbstractInstrument(parent)
36 | {
37 | mPointsCount = 0;
38 | }
39 |
40 | void CurveLineInstrument::mousePressEvent(QMouseEvent *event, ImageArea &imageArea)
41 | {
42 | if(event->button() == Qt::LeftButton || event->button() == Qt::RightButton)
43 | {
44 | if(DataSingleton::Instance()->isResetCurve())
45 | {
46 | mPointsCount = 0;
47 | DataSingleton::Instance()->setResetCurve(false);
48 | }
49 | switch(mPointsCount)
50 | {
51 | //draw linear Bezier curve
52 | case 0:
53 | mImageCopy = *imageArea.getImage();
54 | mStartPoint = mEndPoint = mFirstControlPoint = mSecondControlPoint = event->pos();
55 | ++mPointsCount;
56 | break;
57 | //draw square Bezier curve
58 | case 1:
59 | mFirstControlPoint = mSecondControlPoint = event->pos();
60 | ++mPointsCount;
61 | break;
62 | //draw cubic Bezier curve
63 | case 2:
64 | mSecondControlPoint = event->pos();
65 | mPointsCount = 0;
66 | break;
67 | }
68 | imageArea.setIsPaint(true);
69 | makeUndoCommand(imageArea);
70 | }
71 | }
72 |
73 | void CurveLineInstrument::mouseMoveEvent(QMouseEvent *event, ImageArea &imageArea)
74 | {
75 | if(imageArea.isPaint())
76 | {
77 | switch(mPointsCount)
78 | {
79 | //draw linear Bezier curve
80 | case 1:
81 | mEndPoint = event->pos();
82 | break;
83 | //draw square Bezier curve
84 | case 2:
85 | mFirstControlPoint = mSecondControlPoint = event->pos();
86 | break;
87 | //draw cubic Bezier curve
88 | case 0:
89 | mSecondControlPoint = event->pos();
90 | break;
91 | }
92 |
93 | imageArea.setImage(mImageCopy);
94 | if(event->buttons() & Qt::LeftButton)
95 | paint(imageArea, false);
96 | else if(event->buttons() & Qt::RightButton)
97 | paint(imageArea, true);
98 | }
99 | }
100 |
101 | void CurveLineInstrument::mouseReleaseEvent(QMouseEvent *event, ImageArea &imageArea)
102 | {
103 | if(imageArea.isPaint())
104 | {
105 | imageArea.setImage(mImageCopy);
106 | if(event->button() == Qt::LeftButton)
107 | paint(imageArea, false);
108 | else if(event->button() == Qt::RightButton)
109 | paint(imageArea, true);
110 | imageArea.setIsPaint(false);
111 | }
112 | }
113 |
114 | void CurveLineInstrument::paint(ImageArea &imageArea, bool isSecondaryColor, bool)
115 | {
116 | QPainter painter(imageArea.getImage());
117 | //make Bezier curve path
118 | QPainterPath path;
119 | path.moveTo(mStartPoint);
120 | path.cubicTo(mFirstControlPoint, mSecondControlPoint, mEndPoint);
121 | //choose color
122 | painter.setPen(QPen(isSecondaryColor ? DataSingleton::Instance()->getSecondaryColor() :
123 | DataSingleton::Instance()->getPrimaryColor(),
124 | DataSingleton::Instance()->getPenSize() * imageArea.getZoomFactor(),
125 | Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
126 | //draw Bezier curve with given path
127 | painter.strokePath(path, painter.pen());
128 |
129 | imageArea.setEdited(true);
130 | painter.end();
131 | imageArea.update();
132 | }
133 |
--------------------------------------------------------------------------------
/sources/mainwindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This source file is part of EasyPaint.
3 | *
4 | * Copyright (c) 2012 EasyPaint
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included
15 | * in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | #ifndef MAINWINDOW_H
27 | #define MAINWINDOW_H
28 |
29 | #include
30 | #include
31 |
32 | #include "easypaintenums.h"
33 |
34 | QT_BEGIN_NAMESPACE
35 | class QAction;
36 | class QStatusBar;
37 | class QTabWidget;
38 | class ToolBar;
39 | class PaletteBar;
40 | class ImageArea;
41 | class QLabel;
42 | class QUndoGroup;
43 | QT_END_NAMESPACE
44 |
45 | /**
46 | * @brief Main window class.
47 | *
48 | */
49 | class MainWindow : public QMainWindow
50 | {
51 | Q_OBJECT
52 |
53 | public:
54 | MainWindow(QStringList filePaths, QWidget *parent = 0);
55 | ~MainWindow();
56 |
57 | protected:
58 | void closeEvent(QCloseEvent *event);
59 |
60 | private:
61 | void initializeMainMenu();
62 | void initializeStatusBar();
63 | void initializeToolBar();
64 | void initializePaletteBar();
65 | void initializeTabWidget();
66 | /**
67 | * @brief Initialize new tab for tab bar with new ImageArea and connect all needed slots.
68 | *
69 | * @param isOpen Flag which shows opens a new image or from file.
70 | * @param filePath File path
71 | */
72 | void initializeNewTab(const bool &isOpen = false, const QString &filePath = "");
73 | /**
74 | * @brief Get current ImageArea from current tab.
75 | *
76 | * @return ImageArea Geted ImageArea.
77 | */
78 | ImageArea* getCurrentImageArea();
79 | /**
80 | * @brief Get ImageArea from QTabWidget by index.
81 | *
82 | * @param index tab index
83 | * @return ImageArea, which corresponds to the index.
84 | */
85 | ImageArea* getImageAreaByIndex(int index);
86 | bool closeAllTabs();
87 | bool isSomethingModified();
88 | /**
89 | * @brief Update all shortcuts in menu bar.
90 | *
91 | */
92 | void updateShortcuts();
93 |
94 | QStatusBar *mStatusBar;
95 | QTabWidget *mTabWidget;
96 | ToolBar *mToolbar;
97 | PaletteBar *mPaletteBar;
98 | QLabel *mSizeLabel, *mPosLabel, *mColorPreviewLabel, *mColorRGBLabel;
99 |
100 | QMap mInstrumentsActMap;
101 | QMap mEffectsActMap;
102 | QAction *mSaveAction, *mSaveAsAction, *mCloseAction, *mPrintAction,
103 | *mUndoAction, *mRedoAction, *mCopyAction, *mCutAction,
104 | *mNewAction, *mOpenAction, *mExitAction, *mPasteAction, *mZoomInAction, *mZoomOutAction;
105 | QMenu *mInstrumentsMenu, *mEffectsMenu, *mToolsMenu;
106 | QUndoGroup *mUndoStackGroup;
107 | bool mPrevInstrumentSetted; /**< Used for magnifier */
108 | private slots:
109 | void activateTab(const int &index);
110 | void setNewSizeToSizeLabel(const QSize &size);
111 | void setNewPosToPosLabel(const QPoint &pos);
112 | void setCurrentPipetteColor(const QColor &color);
113 | void clearStatusBarColor();
114 | void setInstrumentChecked(InstrumentsEnum instrument);
115 | void newAct();
116 | void openAct();
117 | void helpAct();
118 | void saveAct();
119 | void saveAsAct();
120 | void printAct();
121 | void copyAct();
122 | void pasteAct();
123 | void cutAct();
124 | void settingsAct();
125 | void effectsAct();
126 | void resizeImageAct();
127 | void resizeCanvasAct();
128 | void rotateLeftImageAct();
129 | void rotateRightImageAct();
130 | void zoomInAct();
131 | void zoomOutAct();
132 | void advancedZoomAct();
133 | void closeTabAct();
134 | void closeTab(int index);
135 | void setAllInstrumentsUnchecked(QAction *action);
136 | /**
137 | * @brief Instruments buttons handler.
138 | *
139 | * If some instrument has specific behavior, edit this slot.
140 | */
141 | void instumentsAct(bool state);
142 | void enableActions(int index);
143 | void enableCopyCutActions(bool enable);
144 | void clearImageSelection();
145 | void restorePreviousInstrument();
146 | void setInstrument(InstrumentsEnum instrument);
147 | signals:
148 | void sendInstrumentChecked(InstrumentsEnum);
149 |
150 | };
151 |
152 | #endif // MAINWINDOW_H
153 |
--------------------------------------------------------------------------------