diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index a9cbb38e25..e1fa6a93e2 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -1,577 +1,577 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/qtlockedfile ${EXIV2_INCLUDE_DIR} ) include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR} ${OCIO_INCLUDE_DIR} ) add_subdirectory( tests ) if (APPLE) find_library(FOUNDATION_LIBRARY Foundation) find_library(APPKIT_LIBRARY AppKit) endif () set(kritaui_LIB_SRCS canvas/kis_canvas_widget_base.cpp canvas/kis_canvas2.cpp canvas/kis_canvas_updates_compressor.cpp canvas/kis_canvas_controller.cpp canvas/kis_paintop_transformation_connector.cpp canvas/kis_display_color_converter.cpp canvas/kis_display_filter.cpp canvas/kis_exposure_gamma_correction_interface.cpp canvas/kis_tool_proxy.cpp canvas/kis_canvas_decoration.cc canvas/kis_coordinates_converter.cpp canvas/kis_grid_manager.cpp canvas/kis_grid_decoration.cpp canvas/kis_grid_config.cpp canvas/kis_prescaled_projection.cpp canvas/kis_qpainter_canvas.cpp canvas/kis_projection_backend.cpp canvas/kis_update_info.cpp canvas/kis_image_patch.cpp canvas/kis_image_pyramid.cpp canvas/kis_infinity_manager.cpp canvas/kis_change_guides_command.cpp canvas/kis_guides_decoration.cpp canvas/kis_guides_manager.cpp canvas/kis_guides_config.cpp canvas/kis_snap_config.cpp canvas/kis_snap_line_strategy.cpp canvas/KisSnapPointStrategy.cpp dialogs/kis_about_application.cpp dialogs/kis_dlg_adj_layer_props.cc dialogs/kis_dlg_adjustment_layer.cc dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_generator_layer.cpp dialogs/kis_dlg_file_layer.cpp dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_stroke_selection_properties.cpp dialogs/kis_dlg_image_properties.cc dialogs/kis_dlg_layer_properties.cc dialogs/kis_dlg_preferences.cc dialogs/slider_and_spin_box_sync.cpp dialogs/kis_dlg_blacklist_cleanup.cpp dialogs/kis_dlg_layer_style.cpp dialogs/kis_dlg_png_import.cpp dialogs/kis_dlg_import_image_sequence.cpp dialogs/kis_delayed_save_dialog.cpp dialogs/kis_dlg_internal_color_selector.cpp flake/kis_node_dummies_graph.cpp flake/kis_dummies_facade_base.cpp flake/kis_dummies_facade.cpp flake/kis_node_shapes_graph.cpp flake/kis_node_shape.cpp flake/kis_shape_controller.cpp flake/kis_shape_layer.cc flake/kis_shape_layer_canvas.cpp flake/kis_shape_selection.cpp flake/kis_shape_selection_canvas.cpp flake/kis_shape_selection_model.cpp flake/kis_take_all_shapes_command.cpp brushhud/kis_uniform_paintop_property_widget.cpp brushhud/kis_brush_hud.cpp brushhud/kis_round_hud_button.cpp brushhud/kis_dlg_brush_hud_config.cpp brushhud/kis_brush_hud_properties_list.cpp brushhud/kis_brush_hud_properties_config.cpp kis_aspect_ratio_locker.cpp kis_autogradient.cc kis_bookmarked_configurations_editor.cc kis_bookmarked_configurations_model.cc kis_bookmarked_filter_configurations_model.cc kis_base_option.cpp kis_canvas_resource_provider.cpp kis_derived_resources.cpp kis_categories_mapper.cpp kis_categorized_list_model.cpp kis_categorized_item_delegate.cpp kis_clipboard.cc kis_config.cc kis_config_notifier.cpp kis_control_frame.cpp kis_composite_ops_model.cc kis_paint_ops_model.cpp kis_cursor.cc kis_cursor_cache.cpp kis_custom_pattern.cc kis_file_layer.cpp kis_change_file_layer_command.h kis_safe_document_loader.cpp kis_splash_screen.cpp kis_filter_manager.cc kis_filters_model.cc kis_histogram_view.cc KisImageBarrierLockerWithFeedback.cpp kis_image_manager.cc kis_image_view_converter.cpp kis_import_catcher.cc kis_layer_manager.cc kis_mask_manager.cc kis_mimedata.cpp kis_node_commands_adapter.cpp kis_node_manager.cpp kis_node_juggler_compressed.cpp kis_node_selection_adapter.cpp kis_node_insertion_adapter.cpp kis_node_model.cpp kis_node_filter_proxy_model.cpp kis_model_index_converter_base.cpp kis_model_index_converter.cpp kis_model_index_converter_show_all.cpp kis_painting_assistant.cc kis_painting_assistants_decoration.cpp kis_painting_assistants_manager.cpp kis_paintop_box.cc kis_paintop_option.cpp kis_paintop_options_model.cpp kis_paintop_settings_widget.cpp kis_popup_palette.cpp kis_png_converter.cpp kis_preference_set_registry.cpp kis_script_manager.cpp kis_resource_server_provider.cpp KisSelectedShapesProxy.cpp kis_selection_decoration.cc kis_selection_manager.cc kis_statusbar.cc kis_zoom_manager.cc kis_favorite_resource_manager.cpp kis_workspace_resource.cpp kis_action.cpp kis_action_manager.cpp - kis_view_plugin.cpp + KisActionPlugin.cpp kis_canvas_controls_manager.cpp kis_tooltip_manager.cpp kis_multinode_property.cpp kis_stopgradient_editor.cpp kisexiv2/kis_exif_io.cpp kisexiv2/kis_exiv2.cpp kisexiv2/kis_iptc_io.cpp kisexiv2/kis_xmp_io.cpp opengl/kis_opengl.cpp opengl/kis_opengl_canvas2.cpp opengl/kis_opengl_canvas_debugger.cpp opengl/kis_opengl_image_textures.cpp opengl/kis_texture_tile.cpp opengl/kis_opengl_shader_loader.cpp opengl/kis_texture_tile_info_pool.cpp kis_fps_decoration.cpp recorder/kis_node_query_path_editor.cc recorder/kis_recorded_action_creator.cc recorder/kis_recorded_action_creator_factory.cc recorder/kis_recorded_action_creator_factory_registry.cc recorder/kis_recorded_action_editor_factory.cc recorder/kis_recorded_action_editor_factory_registry.cc recorder/kis_recorded_filter_action_editor.cc recorder/kis_recorded_filter_action_creator.cpp recorder/kis_recorded_paint_action_editor.cc tool/kis_selection_tool_helper.cpp tool/kis_selection_tool_config_widget_helper.cpp tool/kis_rectangle_constraint_widget.cpp tool/kis_shape_tool_helper.cpp tool/kis_tool.cc tool/kis_delegated_tool_policies.cpp tool/kis_tool_freehand.cc tool/kis_speed_smoother.cpp tool/kis_painting_information_builder.cpp tool/kis_stabilized_events_sampler.cpp tool/kis_tool_freehand_helper.cpp tool/kis_tool_multihand_helper.cpp tool/kis_figure_painting_tool_helper.cpp tool/kis_recording_adapter.cpp tool/kis_tool_paint.cc tool/kis_tool_shape.cc tool/kis_tool_ellipse_base.cpp tool/kis_tool_rectangle_base.cpp tool/kis_tool_polyline_base.cpp tool/kis_tool_utils.cpp tool/kis_resources_snapshot.cpp tool/kis_smoothing_options.cpp tool/KisStabilizerDelayedPaintHelper.cpp tool/KisStrokeSpeedMonitor.cpp tool/strokes/freehand_stroke.cpp tool/strokes/KisStrokeEfficiencyMeasurer.cpp tool/strokes/kis_painter_based_stroke_strategy.cpp tool/strokes/kis_filter_stroke_strategy.cpp tool/strokes/kis_color_picker_stroke_strategy.cpp tool/strokes/KisFreehandStrokeInfo.cpp tool/strokes/KisMaskedFreehandStrokePainter.cpp tool/strokes/KisMaskingBrushRenderer.cpp tool/strokes/KisMaskingBrushCompositeOpFactory.cpp widgets/kis_cmb_composite.cc widgets/kis_cmb_contour.cpp widgets/kis_cmb_gradient.cpp widgets/kis_paintop_list_widget.cpp widgets/kis_cmb_idlist.cc widgets/kis_color_space_selector.cc widgets/kis_advanced_color_space_selector.cc widgets/kis_cie_tongue_widget.cpp widgets/kis_tone_curve_widget.cpp widgets/kis_curve_widget.cpp widgets/kis_custom_image_widget.cc widgets/kis_image_from_clipboard_widget.cpp widgets/kis_double_widget.cc widgets/kis_filter_selector_widget.cc widgets/kis_gradient_chooser.cc widgets/kis_gradient_slider_widget.cc widgets/kis_gradient_slider.cpp widgets/kis_iconwidget.cc widgets/kis_mask_widgets.cpp widgets/kis_meta_data_merge_strategy_chooser_widget.cc widgets/kis_multi_bool_filter_widget.cc widgets/kis_multi_double_filter_widget.cc widgets/kis_multi_integer_filter_widget.cc widgets/kis_multipliers_double_slider_spinbox.cpp widgets/kis_paintop_presets_popup.cpp widgets/kis_tool_options_popup.cpp widgets/kis_paintop_presets_chooser_popup.cpp widgets/kis_paintop_presets_save.cpp widgets/kis_paintop_preset_icon_library.cpp widgets/kis_pattern_chooser.cc widgets/kis_popup_button.cc widgets/kis_preset_chooser.cpp widgets/kis_progress_widget.cpp widgets/kis_selection_options.cc widgets/kis_scratch_pad.cpp widgets/kis_scratch_pad_event_filter.cpp widgets/kis_preset_selector_strip.cpp widgets/kis_slider_spin_box.cpp widgets/kis_size_group.cpp widgets/kis_size_group_p.cpp widgets/kis_wdg_generator.cpp widgets/kis_workspace_chooser.cpp widgets/kis_categorized_list_view.cpp widgets/kis_widget_chooser.cpp widgets/kis_tool_button.cpp widgets/kis_floating_message.cpp widgets/kis_lod_availability_widget.cpp widgets/kis_color_label_selector_widget.cpp widgets/kis_color_filter_combo.cpp widgets/kis_elided_label.cpp widgets/kis_stopgradient_slider_widget.cpp widgets/kis_spinbox_color_selector.cpp widgets/kis_screen_color_picker.cpp widgets/kis_preset_live_preview_view.cpp widgets/KoDualColorButton.cpp widgets/kis_color_input.cpp widgets/kis_color_button.cpp widgets/KisVisualColorSelector.cpp widgets/KisVisualColorSelectorShape.cpp widgets/KisVisualEllipticalSelectorShape.cpp widgets/KisVisualRectangleSelectorShape.cpp widgets/KisVisualTriangleSelectorShape.cpp widgets/KoStrokeConfigWidget.cpp widgets/KoFillConfigWidget.cpp utils/kis_document_aware_spin_box_unit_manager.cpp input/kis_input_manager.cpp input/kis_input_manager_p.cpp input/kis_extended_modifiers_mapper.cpp input/kis_abstract_input_action.cpp input/kis_tool_invocation_action.cpp input/kis_pan_action.cpp input/kis_alternate_invocation_action.cpp input/kis_rotate_canvas_action.cpp input/kis_zoom_action.cpp input/kis_change_frame_action.cpp input/kis_gamma_exposure_action.cpp input/kis_show_palette_action.cpp input/kis_change_primary_setting_action.cpp input/kis_abstract_shortcut.cpp input/kis_native_gesture_shortcut.cpp input/kis_single_action_shortcut.cpp input/kis_stroke_shortcut.cpp input/kis_shortcut_matcher.cpp input/kis_select_layer_action.cpp input/KisQtWidgetsTweaker.cpp input/KisInputActionGroup.cpp operations/kis_operation.cpp operations/kis_operation_configuration.cpp operations/kis_operation_registry.cpp operations/kis_operation_ui_factory.cpp operations/kis_operation_ui_widget.cpp operations/kis_filter_selection_operation.cpp actions/kis_selection_action_factories.cpp actions/KisPasteActionFactory.cpp input/kis_touch_shortcut.cpp kis_document_undo_store.cpp kis_transaction_based_command.cpp kis_gui_context_command.cpp kis_gui_context_command_p.cpp input/kis_tablet_debugger.cpp input/kis_input_profile_manager.cpp input/kis_input_profile.cpp input/kis_shortcut_configuration.cpp input/config/kis_input_configuration_page.cpp input/config/kis_edit_profiles_dialog.cpp input/config/kis_input_profile_model.cpp input/config/kis_input_configuration_page_item.cpp input/config/kis_action_shortcuts_model.cpp input/config/kis_input_type_delegate.cpp input/config/kis_input_mode_delegate.cpp input/config/kis_input_button.cpp input/config/kis_input_editor_delegate.cpp input/config/kis_mouse_input_editor.cpp input/config/kis_wheel_input_editor.cpp input/config/kis_key_input_editor.cpp processing/fill_processing_visitor.cpp kis_asl_layer_style_serializer.cpp kis_psd_layer_style_resource.cpp canvas/kis_mirror_axis.cpp kis_abstract_perspective_grid.cpp KisApplication.cpp KisAutoSaveRecoveryDialog.cpp KisDetailsPane.cpp KisDocument.cpp KisNodeDelegate.cpp kis_node_view_visibility_delegate.cpp KisNodeToolTip.cpp KisNodeView.cpp kis_node_view_color_scheme.cpp KisImportExportFilter.cpp KisFilterEntry.cpp KisImportExportManager.cpp KisImportExportUtils.cpp kis_async_action_feedback.cpp KisMainWindow.cpp KisOpenPane.cpp KisPart.cpp KisPrintJob.cpp KisTemplate.cpp KisTemplateCreateDia.cpp KisTemplateGroup.cpp KisTemplates.cpp KisTemplatesPane.cpp KisTemplateTree.cpp KisUndoStackAction.cpp KisView.cpp thememanager.cpp kis_mainwindow_observer.cpp KisViewManager.cpp kis_mirror_manager.cpp qtlockedfile/qtlockedfile.cpp qtsingleapplication/qtlocalpeer.cpp qtsingleapplication/qtsingleapplication.cpp KisResourceBundle.cpp KisResourceBundleManifest.cpp kis_md5_generator.cpp KisApplicationArguments.cpp KisNetworkAccessManager.cpp KisMultiFeedRSSModel.cpp KisRemoteFileFetcher.cpp KisPaletteModel.cpp kis_palette_delegate.cpp kis_palette_view.cpp KisColorsetChooser.cpp KisSaveGroupVisitor.cpp ) if(WIN32) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/kis_tablet_event.cpp input/wintab/kis_tablet_support_win.cpp input/wintab/kis_screen_size_choice_dialog.cpp qtlockedfile/qtlockedfile_win.cpp input/wintab/kis_tablet_support_win8.cpp opengl/kis_opengl_win.cpp ) endif() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} kis_animation_frame_cache.cpp kis_animation_cache_populator.cpp KisAsyncAnimationRendererBase.cpp KisAsyncAnimationCacheRenderer.cpp KisAsyncAnimationFramesSavingRenderer.cpp dialogs/KisAsyncAnimationRenderDialogBase.cpp dialogs/KisAsyncAnimationCacheRenderDialog.cpp dialogs/KisAsyncAnimationFramesSaveDialog.cpp canvas/kis_animation_player.cpp kis_animation_importer.cpp KisSyncedAudioPlayback.cpp ) if(UNIX) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/kis_tablet_event.cpp input/wintab/kis_tablet_support.cpp qtlockedfile/qtlockedfile_unix.cpp ) if(NOT APPLE) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/wintab/qxcbconnection_xi2.cpp input/wintab/qxcbconnection.cpp input/wintab/kis_xi2_event_filter.cpp ) endif() endif() if(APPLE) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} osx.mm ) endif() ki18n_wrap_ui(kritaui_LIB_SRCS widgets/KoFillConfigWidget.ui widgets/KoStrokeConfigWidget.ui forms/wdgdlgpngimport.ui forms/wdgfullscreensettings.ui forms/wdgautogradient.ui forms/wdggeneralsettings.ui forms/wdgperformancesettings.ui forms/wdggenerators.ui forms/wdgbookmarkedconfigurationseditor.ui forms/wdgapplyprofile.ui forms/wdgcustompattern.ui forms/wdglayerproperties.ui forms/wdgcolorsettings.ui forms/wdgtabletsettings.ui forms/wdgcolorspaceselector.ui forms/wdgcolorspaceselectoradvanced.ui forms/wdgdisplaysettings.ui forms/kis_previewwidgetbase.ui forms/kis_matrix_widget.ui forms/wdgselectionoptions.ui forms/wdggeometryoptions.ui forms/wdgnewimage.ui forms/wdgimageproperties.ui forms/wdgmaskfromselection.ui forms/wdgmasksource.ui forms/wdgfilterdialog.ui forms/wdgmetadatamergestrategychooser.ui forms/wdgpaintoppresets.ui forms/wdgpaintopsettings.ui forms/wdgdlggeneratorlayer.ui forms/wdgdlgfilelayer.ui forms/wdgfilterselector.ui forms/wdgfilternodecreation.ui forms/wdgpaintactioneditor.ui forms/wdgmultipliersdoublesliderspinbox.ui forms/wdgnodequerypatheditor.ui forms/wdgpresetselectorstrip.ui forms/wdgsavebrushpreset.ui forms/wdgpreseticonlibrary.ui forms/wdgdlgblacklistcleanup.ui forms/wdgrectangleconstraints.ui forms/wdgimportimagesequence.ui forms/wdgstrokeselectionproperties.ui forms/KisDetailsPaneBase.ui forms/KisOpenPaneBase.ui forms/wdgstopgradienteditor.ui brushhud/kis_dlg_brush_hud_config.ui forms/wdgdlginternalcolorselector.ui dialogs/kis_delayed_save_dialog.ui input/config/kis_input_configuration_page.ui input/config/kis_edit_profiles_dialog.ui input/config/kis_input_configuration_page_item.ui input/config/kis_mouse_input_editor.ui input/config/kis_wheel_input_editor.ui input/config/kis_key_input_editor.ui layerstyles/wdgBevelAndEmboss.ui layerstyles/wdgblendingoptions.ui layerstyles/WdgColorOverlay.ui layerstyles/wdgContour.ui layerstyles/wdgdropshadow.ui layerstyles/WdgGradientOverlay.ui layerstyles/wdgInnerGlow.ui layerstyles/wdglayerstyles.ui layerstyles/WdgPatternOverlay.ui layerstyles/WdgSatin.ui layerstyles/WdgStroke.ui layerstyles/wdgstylesselector.ui layerstyles/wdgTexture.ui wdgsplash.ui input/wintab/kis_screen_size_choice_dialog.ui ) QT5_WRAP_CPP(kritaui_HEADERS_MOC KisNodePropertyAction_p.h) add_library(kritaui SHARED ${kritaui_HEADERS_MOC} ${kritaui_LIB_SRCS} ) generate_export_header(kritaui BASE_NAME kritaui) target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::ItemViews Qt5::Network kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils ${PNG_LIBRARIES} ${EXIV2_LIBRARIES} ) if (HAVE_QT_MULTIMEDIA) target_link_libraries(kritaui Qt5::Multimedia) endif() if (HAVE_KIO) target_link_libraries(kritaui KF5::KIOCore) endif() if (NOT WIN32 AND NOT APPLE) target_link_libraries(kritaui ${X11_X11_LIB} ${X11_Xinput_LIB} ${XCB_LIBRARIES}) endif() if(APPLE) target_link_libraries(kritaui ${FOUNDATION_LIBRARY}) target_link_libraries(kritaui ${APPKIT_LIBRARY}) endif () target_link_libraries(kritaui ${OPENEXR_LIBRARIES}) # Add VSync disable workaround if(NOT WIN32 AND NOT APPLE) target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras) endif() if(X11_FOUND) target_link_libraries(kritaui Qt5::X11Extras ${X11_LIBRARIES}) endif() target_include_directories(kritaui PUBLIC $ $ $ $ $ $ $ ) set_target_properties(kritaui PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaui ${INSTALL_TARGETS_DEFAULT_ARGS}) if (APPLE) install(FILES osx.stylesheet DESTINATION ${DATA_INSTALL_DIR}/krita) endif () diff --git a/libs/ui/kis_view_plugin.cpp b/libs/ui/KisActionPlugin.cpp similarity index 78% rename from libs/ui/kis_view_plugin.cpp rename to libs/ui/KisActionPlugin.cpp index 3351391c30..d79a236ded 100644 --- a/libs/ui/kis_view_plugin.cpp +++ b/libs/ui/KisActionPlugin.cpp @@ -1,63 +1,63 @@ /* * Copyright (c) 2013 Sven Langkamp * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "kis_view_plugin.h" +#include "KisActionPlugin.h" #include "KisViewManager.h" #include "kis_action_manager.h" #include "operations/kis_operation.h" -KisViewPlugin::KisViewPlugin(QObject* parent) +KisActionPlugin::KisActionPlugin(QObject* parent) : QObject(parent) { m_view = qobject_cast(parent); Q_ASSERT(m_view); } -KisViewPlugin::~KisViewPlugin() +KisActionPlugin::~KisActionPlugin() { } -void KisViewPlugin::addAction(const QString& name, KisAction* action) +void KisActionPlugin::addAction(const QString& name, KisAction* action) { if (m_view) { m_view->actionManager()->addAction(name, action); } } -KisAction* KisViewPlugin::createAction(const QString& name) +KisAction* KisActionPlugin::createAction(const QString& name) { if (m_view) { return m_view->actionManager()->createAction(name); } return 0; } -void KisViewPlugin::addUIFactory(KisOperationUIFactory* factory) +void KisActionPlugin::addUIFactory(KisOperationUIFactory* factory) { if (m_view) { m_view->actionManager()->registerOperationUIFactory(factory); } } -void KisViewPlugin::addOperation(KisOperation* operation) +void KisActionPlugin::addOperation(KisOperation* operation) { if (m_view) { m_view->actionManager()->registerOperation(operation); } } diff --git a/libs/ui/kis_view_plugin.h b/libs/ui/KisActionPlugin.h similarity index 87% rename from libs/ui/kis_view_plugin.h rename to libs/ui/KisActionPlugin.h index bdaa6041c8..7ebefaac12 100644 --- a/libs/ui/kis_view_plugin.h +++ b/libs/ui/KisActionPlugin.h @@ -1,60 +1,60 @@ /* * Copyright (c) 2013 Sven Langkamp * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_VIEW_PLUGIN_H #define KIS_VIEW_PLUGIN_H #include #include #include class KisOperation; class KisOperationUIFactory; class KisAction; class KisViewManager; /** - * KisViewPlugin is the base for plugins which add actions to the view + * KisActionPlugin is the base for plugins which add actions to the main window */ -class KRITAUI_EXPORT KisViewPlugin : public QObject +class KRITAUI_EXPORT KisActionPlugin : public QObject { Q_OBJECT public: - KisViewPlugin(QObject* parent = 0); - ~KisViewPlugin() override; + KisActionPlugin(QObject* parent = 0); + ~KisActionPlugin() override; protected: /** * Registers a KisAction to the UI and action manager. * @param name - title of the action in the krita4.xmlgui file * @param action the action that should be added */ void addAction(const QString& name, KisAction* action); KisAction* createAction(const QString& name); void addUIFactory(KisOperationUIFactory* factory); void addOperation(KisOperation* operation); QPointer m_view; }; #endif // KIS_VIEW_PLUGIN_H diff --git a/plugins/dockers/throttle/ThrottlePlugin.h b/plugins/dockers/throttle/ThrottlePlugin.h index 58f7ac2f27..3fb02c1868 100644 --- a/plugins/dockers/throttle/ThrottlePlugin.h +++ b/plugins/dockers/throttle/ThrottlePlugin.h @@ -1,49 +1,49 @@ /* * Copyright (c) 2017 Boudewijn Rempt * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef THROTTLEPLUGIN_H #define THROTTLEPLUGIN_H -#include +#include #include #include #include #include class Throttle; class BasicDocker : public QDockWidget, public KoCanvasObserverBase { Q_OBJECT public: BasicDocker() : QDockWidget(i18n("CPU Throttle")) {} ~BasicDocker() override {} QString observerName() override { return "ThrottleDocker"; } void setCanvas(KoCanvasBase *) override {} void unsetCanvas() override {} }; class ThrottlePlugin : public QObject { Q_OBJECT public: ThrottlePlugin(QObject *parent, const QVariantList &); ~ThrottlePlugin() override; }; #endif diff --git a/plugins/extensions/animationrenderer/AnimationRenderer.cpp b/plugins/extensions/animationrenderer/AnimationRenderer.cpp index bb56d326ec..46f650adf0 100644 --- a/plugins/extensions/animationrenderer/AnimationRenderer.cpp +++ b/plugins/extensions/animationrenderer/AnimationRenderer.cpp @@ -1,204 +1,204 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "AnimationRenderer.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "DlgAnimationRenderer.h" #include K_PLUGIN_FACTORY_WITH_JSON(AnimaterionRendererFactory, "kritaanimationrenderer.json", registerPlugin();) AnimaterionRenderer::AnimaterionRenderer(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { // Shows the big dialog KisAction *action = createAction("render_animation"); action->setActivationFlags(KisAction::IMAGE_HAS_ANIMATION); connect(action, SIGNAL(triggered()), this, SLOT(slotRenderAnimation())); // Re-renders the image sequence as defined in the last render action = createAction("render_image_sequence_again"); action->setActivationFlags(KisAction::IMAGE_HAS_ANIMATION); connect(action, SIGNAL(triggered()), this, SLOT(slotRenderSequenceAgain())); } AnimaterionRenderer::~AnimaterionRenderer() { } void AnimaterionRenderer::slotRenderAnimation() { KisImageWSP image = m_view->image(); if (!image) return; if (!image->animationInterface()->hasAnimation()) return; KisDocument *doc = m_view->document(); DlgAnimationRenderer dlgAnimationRenderer(doc, m_view->mainWindow()); dlgAnimationRenderer.setCaption(i18n("Render Animation")); KisConfig kisConfig; KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration(); cfg->fromXML(kisConfig.exportConfiguration("IMAGESEQUENCE")); dlgAnimationRenderer.setSequenceConfiguration(cfg); cfg->clearProperties(); cfg->fromXML(kisConfig.exportConfiguration("ANIMATION_RENDERER")); dlgAnimationRenderer.setVideoConfiguration(cfg); cfg->clearProperties(); cfg->fromXML(kisConfig.exportConfiguration("FFMPEG_CONFIG")); dlgAnimationRenderer.setEncoderConfiguration(cfg); // update the UI to show the selected export options dlgAnimationRenderer.updateExportUIOptions(); if (dlgAnimationRenderer.exec() == QDialog::Accepted) { KisPropertiesConfigurationSP sequenceConfig = dlgAnimationRenderer.getSequenceConfiguration(); kisConfig.setExportConfiguration("IMAGESEQUENCE", sequenceConfig); QString mimetype = sequenceConfig->getString("mimetype"); QString extension = KisMimeDatabase::suffixesForMimeType(mimetype).first(); QString baseFileName = QString("%1/%2.%3").arg(sequenceConfig->getString("directory")) .arg(sequenceConfig->getString("basename")) .arg(extension); const bool batchMode = false; // TODO: fetch correctly! KisAsyncAnimationFramesSaveDialog exporter(doc->image(), KisTimeRange::fromTime(sequenceConfig->getInt("first_frame"), sequenceConfig->getInt("last_frame")), baseFileName, sequenceConfig->getInt("sequence_start"), dlgAnimationRenderer.getFrameExportConfiguration()); exporter.setBatchMode(batchMode); KisAsyncAnimationFramesSaveDialog::Result result = exporter.regenerateRange(m_view->mainWindow()->viewManager()); // the folder could have been read-only or something else could happen if (result == KisAsyncAnimationFramesSaveDialog::RenderComplete) { QString savedFilesMask = exporter.savedFilesMask(); KisPropertiesConfigurationSP videoConfig = dlgAnimationRenderer.getVideoConfiguration(); if (videoConfig) { kisConfig.setExportConfiguration("ANIMATION_RENDERER", videoConfig); KisPropertiesConfigurationSP encoderConfig = dlgAnimationRenderer.getEncoderConfiguration(); if (encoderConfig) { kisConfig.setExportConfiguration("FFMPEG_CONFIG", encoderConfig); encoderConfig->setProperty("savedFilesMask", savedFilesMask); } const QString fileName = videoConfig->getString("filename"); QString resultFile = fileName; KIS_SAFE_ASSERT_RECOVER_NOOP(QFileInfo(resultFile).isAbsolute()) { const QFileInfo info(resultFile); QDir dir(info.absolutePath()); if (!dir.exists()) { dir.mkpath(info.absolutePath()); } KIS_SAFE_ASSERT_RECOVER_NOOP(dir.exists()); } QSharedPointer encoder = dlgAnimationRenderer.encoderFilter(); encoder->setMimeType(mimetype.toLatin1()); QFile fi(resultFile); KisImportExportFilter::ConversionStatus res; if (!fi.open(QIODevice::WriteOnly)) { qWarning() << "Could not open" << fi.fileName() << "for writing!"; res = KisImportExportFilter::CreationError; } else { encoder->setFilename(fi.fileName()); res = encoder->convert(doc, &fi, encoderConfig); fi.close(); } if (res != KisImportExportFilter::OK) { QMessageBox::critical(0, i18nc("@title:window", "Krita"), i18n("Could not render animation:\n%1", doc->errorMessage())); } if (videoConfig->getBool("delete_sequence", false)) { QDir d(sequenceConfig->getString("directory")); QStringList sequenceFiles = d.entryList(QStringList() << sequenceConfig->getString("basename") + "*." + extension, QDir::Files); Q_FOREACH(const QString &f, sequenceFiles) { d.remove(f); } } } } else if (result == KisAsyncAnimationFramesSaveDialog::RenderFailed) { m_view->mainWindow()->viewManager()->showFloatingMessage(i18n("Failed to render animation frames!"), QIcon()); } } } void AnimaterionRenderer::slotRenderSequenceAgain() { KisImageWSP image = m_view->image(); if (!image) return; if (!image->animationInterface()->hasAnimation()) return; KisDocument *doc = m_view->document(); KisConfig kisConfig; KisPropertiesConfigurationSP sequenceConfig = new KisPropertiesConfiguration(); sequenceConfig->fromXML(kisConfig.exportConfiguration("IMAGESEQUENCE")); QString mimetype = sequenceConfig->getString("mimetype"); QString extension = KisMimeDatabase::suffixesForMimeType(mimetype).first(); QString baseFileName = QString("%1/%2.%3").arg(sequenceConfig->getString("directory")) .arg(sequenceConfig->getString("basename")) .arg(extension); const bool batchMode = false; // TODO: fetch correctly! KisAsyncAnimationFramesSaveDialog exporter(doc->image(), KisTimeRange::fromTime(sequenceConfig->getInt("first_frame"), sequenceConfig->getInt("last_frame")), baseFileName, sequenceConfig->getInt("sequence_start"), 0); exporter.setBatchMode(batchMode); bool success = exporter.regenerateRange(0) == KisAsyncAnimationFramesSaveDialog::RenderComplete; KIS_SAFE_ASSERT_RECOVER_NOOP(success); } #include "AnimationRenderer.moc" diff --git a/plugins/extensions/animationrenderer/AnimationRenderer.h b/plugins/extensions/animationrenderer/AnimationRenderer.h index 351b2cf6f6..786ad2d74c 100644 --- a/plugins/extensions/animationrenderer/AnimationRenderer.h +++ b/plugins/extensions/animationrenderer/AnimationRenderer.h @@ -1,39 +1,39 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ANIMATIONRENDERERIMAGE_H #define ANIMATIONRENDERERIMAGE_H #include -#include +#include -class AnimaterionRenderer : public KisViewPlugin +class AnimaterionRenderer : public KisActionPlugin { Q_OBJECT public: AnimaterionRenderer(QObject *parent, const QVariantList &); ~AnimaterionRenderer() override; private Q_SLOTS: void slotRenderAnimation(); void slotRenderSequenceAgain(); }; #endif // ANIMATIONRENDERERIMAGE_H diff --git a/plugins/extensions/bigbrother/bigbrother.cc b/plugins/extensions/bigbrother/bigbrother.cc index 4b5c37b393..49c73d90db 100644 --- a/plugins/extensions/bigbrother/bigbrother.cc +++ b/plugins/extensions/bigbrother/bigbrother.cc @@ -1,238 +1,238 @@ /* * Copyright (c) 2007 Cyrille Berger (cberger@cberger.net) * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bigbrother.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "actionseditor/kis_actions_editor.h" #include "actionseditor/kis_actions_editor_dialog.h" #include #include K_PLUGIN_FACTORY_WITH_JSON(BigBrotherPluginFactory, "kritabigbrother.json", registerPlugin();) class RecordedActionSaveContext : public KisRecordedActionSaveContext { public: void saveGradient(const KoAbstractGradient* ) override {} void savePattern(const KoPattern* ) override {} }; class RecordedActionLoadContext : public KisRecordedActionLoadContext { public: KoAbstractGradient* gradient(const QString& name) const override { return KoResourceServerProvider::instance()->gradientServer()->resourceByName(name); } KoPattern* pattern(const QString& name) const override { return KoResourceServerProvider::instance()->patternServer()->resourceByName(name); } }; BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) , m_recorder(0) { if (parent->inherits("KisViewManager")) { m_view = (KisViewManager*) parent; // Open and play action KisAction* action = createAction("Macro_Open_Play"); connect(action, SIGNAL(triggered()), this, SLOT(slotOpenPlay())); // Open and edit action action = createAction("Macro_Open_Edit"); connect(action, SIGNAL(triggered()), this, SLOT(slotOpenEdit())); // Start recording action m_startRecordingMacroAction = createAction("Recording_Start_Recording_Macro"); connect(m_startRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStartRecordingMacro())); // Save recorded action m_stopRecordingMacroAction = createAction("Recording_Stop_Recording_Macro"); connect(m_stopRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStopRecordingMacro())); m_stopRecordingMacroAction->setEnabled(false); } } BigBrotherPlugin::~BigBrotherPlugin() { m_view = 0; delete m_recorder; } void BigBrotherPlugin::slotOpenPlay() { KisMacro* m = openMacro(); dbgKrita << m; if (!m) return; dbgPlugins << "Play the macro"; KoUpdaterPtr updater = m_view->createUnthreadedUpdater(i18n("Playing back macro")); KisMacroPlayer player(m, KisPlayInfo(m_view->image(), m_view->activeNode()), updater); player.start(); while(player.isRunning()) { QApplication::processEvents(); } dbgPlugins << "Finished"; delete m; } void BigBrotherPlugin::slotOpenEdit() { KisMacro *macro = openMacro(); if (!macro) return; KisActionsEditorDialog aed(m_view->mainWindow()); aed.actionsEditor()->setMacro(macro); if (aed.exec() == QDialog::Accepted) { saveMacro(macro); } delete macro; } void BigBrotherPlugin::slotStartRecordingMacro() { dbgPlugins << "Start recording macro"; if (m_recorder) return; // Alternate actions m_startRecordingMacroAction->setEnabled(false); m_stopRecordingMacroAction->setEnabled(true); // Create recorder m_recorder = new KisMacro(); connect(m_view->image()->actionRecorder(), SIGNAL(addedAction(const KisRecordedAction&)), m_recorder, SLOT(addAction(const KisRecordedAction&))); } void BigBrotherPlugin::slotStopRecordingMacro() { dbgPlugins << "Stop recording macro"; if (!m_recorder) return; // Alternate actions m_startRecordingMacroAction->setEnabled(true); m_stopRecordingMacroAction->setEnabled(false); // Save the macro saveMacro(m_recorder); // Delete recorder delete m_recorder; m_recorder = 0; } KisMacro* BigBrotherPlugin::openMacro() { QStringList mimeFilter; mimeFilter << "*.krarec|Recorded actions (*.krarec)"; KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::OpenFile, "OpenDocument"); dialog.setCaption(i18n("Open Macro")); dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); dialog.setMimeTypeFilters(QStringList() << "application/x-krita-recorded-macro"); QString filename = dialog.filename(); RecordedActionLoadContext loadContext; if (!filename.isNull()) { QDomDocument doc; QFile f(filename); if (f.exists()) { dbgPlugins << f.open(QIODevice::ReadOnly); QString err; int line, col; if (!doc.setContent(&f, &err, &line, &col)) { // TODO error message dbgPlugins << err << " line = " << line << " col = " << col; f.close(); return 0; } f.close(); QDomElement docElem = doc.documentElement(); if (!docElem.isNull() && docElem.tagName() == "RecordedActions") { dbgPlugins << "Load the macro"; KisMacro* m = new KisMacro(); m->fromXML(docElem, &loadContext); return m; } else { // TODO error message } } else { dbgPlugins << "Unexistant file : " << filename; } } return 0; } void BigBrotherPlugin::saveMacro(const KisMacro* macro) { KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::SaveFile, "bigbrother"); dialog.setCaption(i18n("Save Macro")); dialog.setMimeTypeFilters(QStringList() << "application/x-krita-recorded-macro"); QString filename = dialog.filename(); if (!filename.isNull()) { QDomDocument doc; QDomElement e = doc.createElement("RecordedActions"); RecordedActionSaveContext context; macro->toXML(doc, e, &context); doc.appendChild(e); QFile f(filename); f.open(QIODevice::WriteOnly); QTextStream stream(&f); stream.setCodec("UTF-8"); doc.save(stream, 2); f.close(); } } #include "bigbrother.moc" diff --git a/plugins/extensions/bigbrother/bigbrother.h b/plugins/extensions/bigbrother/bigbrother.h index 9459248136..1d428ad96d 100644 --- a/plugins/extensions/bigbrother/bigbrother.h +++ b/plugins/extensions/bigbrother/bigbrother.h @@ -1,54 +1,54 @@ /* * Copyright (c) 2007 Cyrille Berger (cberger@cberger.net) * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _BIGBROTHER_H_ #define _BIGBROTHER_H_ #include -#include +#include class KisAction; class KisMacro; class KisViewManager; -class BigBrotherPlugin : public KisViewPlugin +class BigBrotherPlugin : public KisActionPlugin { Q_OBJECT public: BigBrotherPlugin(QObject *parent, const QVariantList &); ~BigBrotherPlugin() override; private Q_SLOTS: void slotOpenPlay(); void slotOpenEdit(); void slotStartRecordingMacro(); void slotStopRecordingMacro(); private: void saveMacro(const KisMacro* macro); KisMacro *openMacro(); private: KisViewManager *m_view; KisMacro *m_recorder; KisAction *m_startRecordingMacroAction; KisAction *m_stopRecordingMacroAction; }; #endif // bigbrotherPlugin_H diff --git a/plugins/extensions/buginfo/buginfo.cpp b/plugins/extensions/buginfo/buginfo.cpp index 3d6cd71384..9f4338f47d 100644 --- a/plugins/extensions/buginfo/buginfo.cpp +++ b/plugins/extensions/buginfo/buginfo.cpp @@ -1,51 +1,51 @@ /* * Copyright (c) 2017 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "buginfo.h" #include #include #include #include #include #include #include #include "dlg_buginfo.h" K_PLUGIN_FACTORY_WITH_JSON(BugInfoFactory, "kritabuginfo.json", registerPlugin();) BugInfo::BugInfo(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("buginfo"); connect(action, SIGNAL(triggered()), this, SLOT(slotBugInfo())); } BugInfo::~BugInfo() { } void BugInfo::slotBugInfo() { DlgBugInfo dlgBugInfo(m_view->mainWindow()); dlgBugInfo.exec(); } #include "buginfo.moc" diff --git a/plugins/extensions/buginfo/buginfo.h b/plugins/extensions/buginfo/buginfo.h index e6d031441c..21b24a90dc 100644 --- a/plugins/extensions/buginfo/buginfo.h +++ b/plugins/extensions/buginfo/buginfo.h @@ -1,40 +1,40 @@ /* * Copyright (c) 2017 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef BUGINFO_H #define BUGINFO_H #include -#include +#include class KUndo2MagicString; -class BugInfo : public KisViewPlugin +class BugInfo : public KisActionPlugin { Q_OBJECT public: BugInfo(QObject *parent, const QVariantList &); ~BugInfo() override; public Q_SLOTS: void slotBugInfo(); }; #endif // BUGINFO_H diff --git a/plugins/extensions/clonesarray/clonesarray.cpp b/plugins/extensions/clonesarray/clonesarray.cpp index 2a506c1909..9a947e2ee3 100644 --- a/plugins/extensions/clonesarray/clonesarray.cpp +++ b/plugins/extensions/clonesarray/clonesarray.cpp @@ -1,61 +1,61 @@ /* * Copyright (c) 2013 Dmitry Kazakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "clonesarray.h" #include #include #include #include #include #include #include #include "dlg_clonesarray.h" K_PLUGIN_FACTORY_WITH_JSON(ClonesArrayFactory, "kritaclonesarray.json", registerPlugin();) ClonesArray::ClonesArray(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("clones_array"); connect(action, SIGNAL(triggered()), this, SLOT(slotCreateClonesArray())); } ClonesArray::~ClonesArray() { } void ClonesArray::slotCreateClonesArray() { KisImageWSP image = m_view->image(); Q_ASSERT(image); Q_UNUSED(image); DlgClonesArray *dialog = new DlgClonesArray(m_view, m_view->mainWindow()); Q_CHECK_PTR(dialog); if (dialog->exec() == QDialog::Accepted) { } delete dialog; } #include "clonesarray.moc" diff --git a/plugins/extensions/clonesarray/clonesarray.h b/plugins/extensions/clonesarray/clonesarray.h index 63ab9213af..57b6027a23 100644 --- a/plugins/extensions/clonesarray/clonesarray.h +++ b/plugins/extensions/clonesarray/clonesarray.h @@ -1,36 +1,36 @@ /* * Copyright (c) 2013 Dmitry Kazakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CLONESARRAY_H #define CLONESARRAY_H -#include +#include #include -class ClonesArray : public KisViewPlugin +class ClonesArray : public KisActionPlugin { Q_OBJECT public: ClonesArray(QObject *parent, const QVariantList &); ~ClonesArray() override; private Q_SLOTS: void slotCreateClonesArray(); }; #endif // CLONESARRAY<_H diff --git a/plugins/extensions/colorrange/colorrange.cc b/plugins/extensions/colorrange/colorrange.cc index a836520d46..746e43e265 100644 --- a/plugins/extensions/colorrange/colorrange.cc +++ b/plugins/extensions/colorrange/colorrange.cc @@ -1,103 +1,103 @@ /* * colorrange.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "colorrange.h" #include #include #include #include "kis_image.h" #include "kis_layer.h" #include "kis_paint_device.h" #include "kis_global.h" #include "kis_types.h" #include "KisViewManager.h" #include "kis_selection.h" #include "kis_selection_manager.h" #include "kis_selection_tool_helper.h" #include "kis_canvas2.h" #include "kis_iterator_ng.h" #include "kis_action.h" #include "dlg_colorrange.h" #include K_PLUGIN_FACTORY_WITH_JSON(ColorRangeFactory, "kritacolorrange.json", registerPlugin();) ColorRange::ColorRange(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction* action = createAction("colorrange"); connect(action, SIGNAL(triggered()), this, SLOT(slotActivated())); action = createAction("selectopaque"); connect(action, SIGNAL(triggered()), this, SLOT(selectOpaque())); } ColorRange::~ColorRange() { } void ColorRange::slotActivated() { DlgColorRange *dlgColorRange = new DlgColorRange(m_view, m_view->mainWindow()); Q_CHECK_PTR(dlgColorRange); dlgColorRange->exec(); } void ColorRange::selectOpaque() { KisCanvas2 *canvas = m_view->canvasBase(); KisPaintDeviceSP device = m_view->activeNode()->projection(); if (!device) device = m_view->activeNode()->paintDevice(); if (!device) device = m_view->activeNode()->original(); KIS_ASSERT_RECOVER_RETURN(canvas && device); QRect rc = device->exactBounds(); if (rc.isEmpty()) return; KisSelectionToolHelper helper(canvas, kundo2_i18n("Select Opaque")); qint32 x, y, w, h; rc.getRect(&x, &y, &w, &h); const KoColorSpace * cs = device->colorSpace(); KisPixelSelectionSP tmpSel = KisPixelSelectionSP(new KisPixelSelection()); KisHLineConstIteratorSP deviter = device->createHLineConstIteratorNG(x, y, w); KisHLineIteratorSP selIter = tmpSel ->createHLineIteratorNG(x, y, w); for (int row = y; row < h + y; ++row) { do { *selIter->rawData() = cs->opacityU8(deviter->oldRawData()); } while (deviter->nextPixel() && selIter->nextPixel()); deviter->nextRow(); selIter->nextRow(); } tmpSel->invalidateOutlineCache(); helper.selectPixelSelection(tmpSel, SELECTION_ADD); } #include "colorrange.moc" diff --git a/plugins/extensions/colorrange/colorrange.h b/plugins/extensions/colorrange/colorrange.h index e1ab5192b5..878a355b3d 100644 --- a/plugins/extensions/colorrange/colorrange.h +++ b/plugins/extensions/colorrange/colorrange.h @@ -1,40 +1,40 @@ /* * colorrange.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef COLORRANGE_H #define COLORRANGE_H #include -#include +#include -class ColorRange : public KisViewPlugin +class ColorRange : public KisActionPlugin { Q_OBJECT public: ColorRange(QObject *parent, const QVariantList &); ~ColorRange() override; private Q_SLOTS: void slotActivated(); void selectOpaque(); }; #endif // COLORRANGE_H diff --git a/plugins/extensions/colorspaceconversion/colorspaceconversion.cc b/plugins/extensions/colorspaceconversion/colorspaceconversion.cc index dcfd10912f..6c23bd1910 100644 --- a/plugins/extensions/colorspaceconversion/colorspaceconversion.cc +++ b/plugins/extensions/colorspaceconversion/colorspaceconversion.cc @@ -1,134 +1,134 @@ /* * colorspaceconversion.cc -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "colorspaceconversion.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_colorspaceconversion.h" #include "kis_action_manager.h" K_PLUGIN_FACTORY_WITH_JSON(ColorSpaceConversionFactory, "kritacolorspaceconversion.json", registerPlugin();) ColorSpaceConversion::ColorSpaceConversion(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = m_view->actionManager()->createAction("imagecolorspaceconversion"); connect(action, SIGNAL(triggered()), this, SLOT(slotImageColorSpaceConversion())); action = m_view->actionManager()->createAction("layercolorspaceconversion"); connect(action, SIGNAL(triggered()), this, SLOT(slotLayerColorSpaceConversion())); } ColorSpaceConversion::~ColorSpaceConversion() { } void ColorSpaceConversion::slotImageColorSpaceConversion() { KisImageSP image = m_view->image().toStrongRef(); if (!image) return; DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view->mainWindow(), "ColorSpaceConversion"); bool allowLCMSOptimization = KisConfig().allowLCMSOptimization(); dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->setChecked(allowLCMSOptimization); Q_CHECK_PTR(dlgColorSpaceConversion); dlgColorSpaceConversion->setCaption(i18n("Convert All Layers From ") + image->colorSpace()->name()); dlgColorSpaceConversion->setInitialColorSpace(image->colorSpace()); if (dlgColorSpaceConversion->exec() == QDialog::Accepted) { const KoColorSpace * cs = dlgColorSpaceConversion->m_page->colorSpaceSelector->currentColorSpace(); if (cs) { QApplication::setOverrideCursor(KisCursor::waitCursor()); KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality; if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation; if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization; image->convertImageColorSpace(cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags); QApplication::restoreOverrideCursor(); } } delete dlgColorSpaceConversion; } void ColorSpaceConversion::slotLayerColorSpaceConversion() { KisImageSP image = m_view->image().toStrongRef(); if (!image) return; KisLayerSP layer = m_view->activeLayer(); if (!layer) return; DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view->mainWindow(), "ColorSpaceConversion"); Q_CHECK_PTR(dlgColorSpaceConversion); dlgColorSpaceConversion->setCaption(i18n("Convert Current Layer From") + layer->colorSpace()->name()); dlgColorSpaceConversion->setInitialColorSpace(layer->colorSpace()); if (dlgColorSpaceConversion->exec() == QDialog::Accepted) { const KoColorSpace * cs = dlgColorSpaceConversion->m_page->colorSpaceSelector->currentColorSpace(); if (cs) { QApplication::setOverrideCursor(KisCursor::waitCursor()); image->undoAdapter()->beginMacro(kundo2_i18n("Convert Layer Type")); KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality; if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation; if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization; KisColorSpaceConvertVisitor visitor(image, layer->colorSpace(), cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags); layer->accept(visitor); image->undoAdapter()->endMacro(); QApplication::restoreOverrideCursor(); m_view->nodeManager()->nodesUpdated(); } } delete dlgColorSpaceConversion; } #include "colorspaceconversion.moc" diff --git a/plugins/extensions/colorspaceconversion/colorspaceconversion.h b/plugins/extensions/colorspaceconversion/colorspaceconversion.h index 66569aaa67..d3386f806e 100644 --- a/plugins/extensions/colorspaceconversion/colorspaceconversion.h +++ b/plugins/extensions/colorspaceconversion/colorspaceconversion.h @@ -1,44 +1,44 @@ /* * colorspaceconversion.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef COLORSPACECONVERSION_H #define COLORSPACECONVERSION_H #include -#include +#include /** * Dialog for converting between color models. */ -class ColorSpaceConversion : public KisViewPlugin +class ColorSpaceConversion : public KisActionPlugin { Q_OBJECT public: ColorSpaceConversion(QObject *parent, const QVariantList &); ~ColorSpaceConversion() override; private Q_SLOTS: void slotImageColorSpaceConversion(); void slotLayerColorSpaceConversion(); }; #endif // COLORSPACECONVERSION_H diff --git a/plugins/extensions/histogram/histogram.cc b/plugins/extensions/histogram/histogram.cc index e247804d99..ad1b8db5ad 100644 --- a/plugins/extensions/histogram/histogram.cc +++ b/plugins/extensions/histogram/histogram.cc @@ -1,70 +1,70 @@ /* * histogram.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "histogram.h" #include #include #include #include #include #include #include #include "dlg_histogram.h" #include "kis_node_manager.h" #include K_PLUGIN_FACTORY_WITH_JSON(HistogramFactory, "kritahistogram.json", registerPlugin();) Histogram::Histogram(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction* action = createAction("histogram"); connect(action, SIGNAL(triggered()), this, SLOT(slotActivated())); } Histogram::~Histogram() { } void Histogram::slotActivated() { DlgHistogram * dlgHistogram = new DlgHistogram(m_view->mainWindow(), "Histogram"); Q_CHECK_PTR(dlgHistogram); KisLayerSP layer = m_view->nodeManager()->activeLayer(); if (layer) { KisPaintDeviceSP dev = layer->paintDevice(); if (dev) { dlgHistogram->setPaintDevice(dev, layer->image()->bounds()); } if (dlgHistogram->exec() == QDialog::Accepted) { // Do nothing; this is an informational dialog } } delete dlgHistogram; } #include "histogram.moc" diff --git a/plugins/extensions/histogram/histogram.h b/plugins/extensions/histogram/histogram.h index c7fe795293..cfe286ffc3 100644 --- a/plugins/extensions/histogram/histogram.h +++ b/plugins/extensions/histogram/histogram.h @@ -1,39 +1,39 @@ /* * histogram.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef HISTOGRAM_H #define HISTOGRAM_H #include -#include +#include -class Histogram : public KisViewPlugin +class Histogram : public KisActionPlugin { Q_OBJECT public: Histogram(QObject *parent, const QVariantList &); ~Histogram() override; private Q_SLOTS: void slotActivated(); }; #endif // HISTOGRAM_H diff --git a/plugins/extensions/imagesize/imagesize.cc b/plugins/extensions/imagesize/imagesize.cc index 83601304cf..65d5d8ae66 100644 --- a/plugins/extensions/imagesize/imagesize.cc +++ b/plugins/extensions/imagesize/imagesize.cc @@ -1,166 +1,166 @@ /* * imagesize.cc -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "imagesize.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_imagesize.h" #include "dlg_canvassize.h" #include "dlg_layersize.h" #include "kis_filter_strategy.h" #include "kis_action.h" #include "kis_action_manager.h" K_PLUGIN_FACTORY_WITH_JSON(ImageSizeFactory, "kritaimagesize.json", registerPlugin();) ImageSize::ImageSize(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("imagesize"); connect(action, SIGNAL(triggered()), this, SLOT(slotImageSize())); action = createAction("canvassize"); connect(action, SIGNAL(triggered()), this, SLOT(slotCanvasSize())); action = createAction("layersize"); connect(action, SIGNAL(triggered()), this, SLOT(slotLayerSize())); action = createAction("selectionscale"); connect(action, SIGNAL(triggered()), this, SLOT(slotSelectionScale())); } ImageSize::~ImageSize() { } void ImageSize::slotImageSize() { KisImageSP image = m_view->image().toStrongRef(); if (!image) return; DlgImageSize * dlgImageSize = new DlgImageSize(m_view->mainWindow(), image->width(), image->height(), image->yRes()); Q_CHECK_PTR(dlgImageSize); dlgImageSize->setObjectName("ImageSize"); if (dlgImageSize->exec() == QDialog::Accepted) { qint32 w = dlgImageSize->width(); qint32 h = dlgImageSize->height(); double res = dlgImageSize->resolution(); m_view->imageManager()->scaleCurrentImage(QSize(w, h), res, res, dlgImageSize->filterType()); } delete dlgImageSize; } void ImageSize::slotCanvasSize() { KisImageWSP image = m_view->image(); if (!image) return; DlgCanvasSize * dlgCanvasSize = new DlgCanvasSize(m_view->mainWindow(), image->width(), image->height(), image->yRes()); Q_CHECK_PTR(dlgCanvasSize); if (dlgCanvasSize->exec() == QDialog::Accepted) { qint32 width = dlgCanvasSize->width(); qint32 height = dlgCanvasSize->height(); qint32 xOffset = dlgCanvasSize->xOffset(); qint32 yOffset = dlgCanvasSize->yOffset(); m_view->imageManager()->resizeCurrentImage(width, height, xOffset, yOffset); } delete dlgCanvasSize; } void ImageSize::slotLayerSize() { KisImageWSP image = m_view->image(); if (!image) return; KisPaintDeviceSP dev = m_view->activeLayer()->projection(); Q_ASSERT(dev); QRect rc = dev->exactBounds(); DlgLayerSize * dlgLayerSize = new DlgLayerSize(m_view->mainWindow(), "LayerSize", rc.width(), rc.height(), image->yRes()); Q_CHECK_PTR(dlgLayerSize); dlgLayerSize->setCaption(i18n("Resize Layer")); if (dlgLayerSize->exec() == QDialog::Accepted) { qint32 w = dlgLayerSize->width(); qint32 h = dlgLayerSize->height(); m_view->nodeManager()->scale((double)w / ((double)(rc.width())), (double)h / ((double)(rc.height())), dlgLayerSize->filterType()); } delete dlgLayerSize; } void ImageSize::slotSelectionScale() { KisImageSP image = m_view->image(); if (!image) { return; } KisLayerSP layer = m_view->activeLayer(); KIS_ASSERT_RECOVER_RETURN(image && layer); KisSelectionMaskSP selectionMask = layer->selectionMask(); if (!selectionMask) { selectionMask = image->rootLayer()->selectionMask(); } KIS_ASSERT_RECOVER_RETURN(selectionMask); QRect rc = selectionMask->selection()->selectedExactRect(); DlgLayerSize * dlgSize = new DlgLayerSize(m_view->mainWindow(), "SelectionScale", rc.width(), rc.height(), image->yRes()); dlgSize->setCaption(i18n("Scale Selection")); if (dlgSize->exec() == QDialog::Accepted) { qint32 w = dlgSize->width(); qint32 h = dlgSize->height(); image->scaleNode(selectionMask, qreal(w) / rc.width(), qreal(h) / rc.height(), dlgSize->filterType()); } delete dlgSize; } #include "imagesize.moc" diff --git a/plugins/extensions/imagesize/imagesize.h b/plugins/extensions/imagesize/imagesize.h index 740ca2c304..892fc333ee 100644 --- a/plugins/extensions/imagesize/imagesize.h +++ b/plugins/extensions/imagesize/imagesize.h @@ -1,42 +1,42 @@ /* * imagesize.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef IMAGESIZE_H #define IMAGESIZE_H #include -#include +#include -class ImageSize : public KisViewPlugin +class ImageSize : public KisActionPlugin { Q_OBJECT public: ImageSize(QObject *parent, const QVariantList &); ~ImageSize() override; private Q_SLOTS: void slotImageSize(); void slotCanvasSize(); void slotLayerSize(); void slotSelectionScale(); }; #endif // IMAGESIZE_H diff --git a/plugins/extensions/imagesplit/imagesplit.cpp b/plugins/extensions/imagesplit/imagesplit.cpp index 526f4c8069..ddcfd2239c 100644 --- a/plugins/extensions/imagesplit/imagesplit.cpp +++ b/plugins/extensions/imagesplit/imagesplit.cpp @@ -1,207 +1,207 @@ /* * imagesplit.cc -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * Copyright (c) 2011 Srikanth Tiyyagura * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "imagesplit.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_imagesplit.h" K_PLUGIN_FACTORY_WITH_JSON(ImagesplitFactory, "kritaimagesplit.json", registerPlugin();) Imagesplit::Imagesplit(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("imagesplit"); connect(action, SIGNAL(triggered()), this, SLOT(slotImagesplit())); } Imagesplit::~Imagesplit() { } bool Imagesplit::saveAsImage(const QRect &imgSize, const QString &mimeType, const QString &url) { KisImageSP image = m_view->image(); KisDocument *document = KisPart::instance()->createDocument(); KisImageSP dst = new KisImage(document->createUndoStore(), imgSize.width(), imgSize.height(), image->colorSpace(), image->objectName()); dst->setResolution(image->xRes(), image->yRes()); document->setCurrentImage(dst); KisPaintLayer* paintLayer = new KisPaintLayer(dst, dst->nextLayerName(), 255); KisPainter gc(paintLayer->paintDevice()); gc.bitBlt(QPoint(0, 0), image->projection(), imgSize); dst->addNode(paintLayer, KisNodeSP(0)); dst->refreshGraph(); document->setFileBatchMode(true); if (!document->exportDocumentSync(QUrl::fromLocalFile(url), mimeType.toLatin1())) { if (document->errorMessage().isEmpty()) { QMessageBox::critical(0, i18nc("@title:window", "Krita"), i18n("Could not save\n%1", document->localFilePath())); } else { QMessageBox::critical(0, i18nc("@title:window", "Krita"), i18n("Could not save %1\nReason: %2", document->localFilePath(), document->errorMessage())); } return false; } delete document; return true; } void Imagesplit::slotImagesplit() { // Taking the title - url from caption function and removing file extension QStringList strList = ((m_view->document())->caption()).split('.'); QString suffix = strList.at(0); // Getting all mime types and converting them into names which are displayed at combo box QStringList listMimeFilter = KisImportExportManager::mimeFilter(KisImportExportManager::Export); QString defaultMime = QString::fromLatin1(m_view->document()->mimeType()); int defaultMimeIndex = 0; listMimeFilter.sort(); QStringList filteredMimeTypes; QStringList listFileType; int i = 0; Q_FOREACH (const QString & mimeType, listMimeFilter) { listFileType.append(KisMimeDatabase::descriptionForMimeType(mimeType)); filteredMimeTypes.append(mimeType); if (mimeType == defaultMime) { defaultMimeIndex = i; } i++; } listMimeFilter = filteredMimeTypes; Q_ASSERT(listMimeFilter.size() == listFileType.size()); DlgImagesplit *dlgImagesplit = new DlgImagesplit(m_view, suffix, listFileType, defaultMimeIndex); dlgImagesplit->setObjectName("Imagesplit"); Q_CHECK_PTR(dlgImagesplit); KisImageWSP image = m_view->image(); if (dlgImagesplit->exec() == QDialog::Accepted) { int numHorizontalLines = dlgImagesplit->horizontalLines(); int numVerticalLines = dlgImagesplit->verticalLines(); int img_width = image->width() / (numVerticalLines + 1); int img_height = image->height() / (numHorizontalLines + 1); bool stop = false; if (dlgImagesplit->autoSave()) { KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::OpenDirectory, "OpenDocument"); dialog.setCaption(i18n("Save Image on Split")); dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); QStringList mimeFilter = m_view->document()->importExportManager()->mimeFilter(KisImportExportManager::Export); QString defaultMime = QString::fromLatin1(m_view->document()->mimeType()); dialog.setMimeTypeFilters(mimeFilter, defaultMime); QUrl directory = QUrl::fromUserInput(dialog.filename()); if (directory.isEmpty()) return; for (int i = 0, k = 1; i < (numVerticalLines + 1); i++) { for (int j = 0; j < (numHorizontalLines + 1); j++, k++) { QString mimeTypeSelected = listMimeFilter.at(dlgImagesplit->cmbIndex); QString homepath = directory.toLocalFile(); QString suffix = KisMimeDatabase::suffixesForMimeType(mimeTypeSelected).first(); qDebug() << "suffix" << suffix; if (suffix.startsWith("*.")) { suffix = suffix.remove(0, 1); } qDebug() << "\tsuffix" << suffix; if (!suffix.startsWith(".")) { suffix = suffix.prepend('.'); } qDebug() << "\tsuffix" << suffix; QString fileName = dlgImagesplit->suffix() + '_' + QString::number(k) + suffix; QString url = homepath + '/' + fileName; if (!saveAsImage(QRect((i * img_width), (j * img_height), img_width, img_height), listMimeFilter.at(dlgImagesplit->cmbIndex), url)) { stop = true; break; } } if (stop) { break; } } } else { for (int i = 0; i < (numVerticalLines + 1); i++) { for (int j = 0; j < (numHorizontalLines + 1); j++) { KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::SaveFile, "OpenDocument"); dialog.setCaption(i18n("Save Image on Split")); dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); dialog.setMimeTypeFilters(listMimeFilter, defaultMime); QUrl url = QUrl::fromUserInput(dialog.filename()); QString mimefilter = KisMimeDatabase::mimeTypeForFile(url.toLocalFile(), false); if (url.isEmpty()) return; if (!saveAsImage(QRect((i * img_width), (j * img_height), img_width, img_height), mimefilter, url.toLocalFile())) { stop = true; break; } } if (stop) { break; } } } } delete dlgImagesplit; } #include "imagesplit.moc" diff --git a/plugins/extensions/imagesplit/imagesplit.h b/plugins/extensions/imagesplit/imagesplit.h index 09f490bf8d..3d89ae4743 100644 --- a/plugins/extensions/imagesplit/imagesplit.h +++ b/plugins/extensions/imagesplit/imagesplit.h @@ -1,42 +1,42 @@ /* * imagesplit.h -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * Copyright (c) 2011 Srikanth Tiyyagura * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef IMAGESPLIT_H #define IMAGESPLIT_H #include #include -#include +#include -class Imagesplit : public KisViewPlugin +class Imagesplit : public KisActionPlugin { Q_OBJECT public: Imagesplit(QObject *parent, const QVariantList &); ~Imagesplit() override; private Q_SLOTS: void slotImagesplit(); bool saveAsImage(const QRect &imgSize, const QString &mimeType, const QString &url); }; #endif // IMAGESPLIT_H diff --git a/plugins/extensions/layergroupswitcher/layergroupswitcher.cpp b/plugins/extensions/layergroupswitcher/layergroupswitcher.cpp index 6a316987f0..d8e676b6e0 100644 --- a/plugins/extensions/layergroupswitcher/layergroupswitcher.cpp +++ b/plugins/extensions/layergroupswitcher/layergroupswitcher.cpp @@ -1,137 +1,137 @@ /* * layergroupswitcher.cpp -- Part of Krita * * Copyright (c) 2013 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "layergroupswitcher.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_action.h" K_PLUGIN_FACTORY_WITH_JSON(LayerGroupSwitcherFactory, "kritalayergroupswitcher.json", registerPlugin();) LayerGroupSwitcher::LayerGroupSwitcher(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = new KisAction(i18n("Move into previous group"), this); addAction("LayerGroupSwitcher/previous", action); connect(action, SIGNAL(triggered()), this, SLOT(moveIntoPreviousGroup())); action = new KisAction(i18n("Move into next group"), this); addAction("LayerGroupSwitcher/next", action); connect(action, SIGNAL(triggered()), this, SLOT(moveIntoNextGroup())); } LayerGroupSwitcher::~LayerGroupSwitcher() { } void LayerGroupSwitcher::moveIntoNextGroup() { KisImageSP image = m_view->image().toStrongRef(); if (!image) { return; } KisNodeManager *nodeManager = m_view->nodeManager(); KisLayerSP active = nodeManager->activeLayer(); if (!active) { return; } if (active->parentLayer().data() == image->rootLayer().data()) { active->setVisible(false); nodeManager->activateNextNode(); active = nodeManager->activeLayer(); if (active) { active->setVisible(true); } } else if (active->parent()) { KisNodeSP parent = active->parent(); if (parent) { int indexInGroup = active->parent()->index(active); nodeManager->slotNonUiActivatedNode(parent); parent->setVisible(false); nodeManager->activateNextNode(); active = nodeManager->activeLayer(); if (active) { active->setVisible(true); } KisNodeSP child = active->at(indexInGroup); if (child) { nodeManager->slotNonUiActivatedNode(child); child->setVisible(true); } } } image->refreshGraph(); } void LayerGroupSwitcher::moveIntoPreviousGroup() { KisImageSP image = m_view->image().toStrongRef(); if (!image) { return; } KisNodeManager *nodeManager = m_view->nodeManager(); KisLayerSP active = nodeManager->activeLayer(); if (!active) { return; } if (active->parentLayer().data() == image->rootLayer().data()) { active->setVisible(false); nodeManager->activatePreviousNode(); active = nodeManager->activeLayer(); if (active) { active->setVisible(true); } } else if (active->parent()) { KisNodeSP parent = active->parent(); if (parent) { int indexInGroup = active->parent()->index(active); nodeManager->slotNonUiActivatedNode(parent); parent->setVisible(false); nodeManager->activatePreviousNode(); active = nodeManager->activeLayer(); if (active) { active->setVisible(true); } KisNodeSP child = active->at(indexInGroup); if (child) { nodeManager->slotNonUiActivatedNode(child); child->setVisible(true); } } } image->refreshGraph(); } #include "layergroupswitcher.moc" diff --git a/plugins/extensions/layergroupswitcher/layergroupswitcher.h b/plugins/extensions/layergroupswitcher/layergroupswitcher.h index 9a143955b6..fa613ff6be 100644 --- a/plugins/extensions/layergroupswitcher/layergroupswitcher.h +++ b/plugins/extensions/layergroupswitcher/layergroupswitcher.h @@ -1,40 +1,40 @@ /* * layergroupswitcher.h -- Part of Krita * * Copyright (c) 2013 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LAYERGROUP_SWITCHER_H #define LAYERGROUP_SWITCHER_H #include -#include +#include -class LayerGroupSwitcher : public KisViewPlugin +class LayerGroupSwitcher : public KisActionPlugin { Q_OBJECT public: LayerGroupSwitcher(QObject *parent, const QVariantList &); ~LayerGroupSwitcher() override; private Q_SLOTS: void moveIntoNextGroup(); void moveIntoPreviousGroup(); }; #endif // LAYERGROUP_SWITCHER_H diff --git a/plugins/extensions/layersplit/layersplit.cpp b/plugins/extensions/layersplit/layersplit.cpp index 522980f5ca..ac40e09971 100644 --- a/plugins/extensions/layersplit/layersplit.cpp +++ b/plugins/extensions/layersplit/layersplit.cpp @@ -1,226 +1,226 @@ /* * Copyright (C) 2014 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "layersplit.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_layersplit.h" #include "kis_node_manager.h" #include "kis_node_commands_adapter.h" #include "kis_undo_adapter.h" #include #include K_PLUGIN_FACTORY_WITH_JSON(LayerSplitFactory, "kritalayersplit.json", registerPlugin();) LayerSplit::LayerSplit(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("layersplit"); connect(action, SIGNAL(triggered()), this, SLOT(slotLayerSplit())); } LayerSplit::~LayerSplit() { } struct Layer { KoColor color; KisPaintDeviceSP device; KisRandomAccessorSP accessor; int pixelsWritten; bool operator<(const Layer& other) const { return pixelsWritten < other.pixelsWritten; } }; void LayerSplit::slotLayerSplit() { DlgLayerSplit dlg; if (dlg.exec() == QDialog::Accepted) { dlg.hide(); QApplication::setOverrideCursor(Qt::WaitCursor); QPointer updater = m_view->createUnthreadedUpdater(i18n("Split into Layers")); KisImageSP image = m_view->image(); if (!image) return; image->lock(); KisNodeSP node = m_view->activeNode(); if (!node) return; KisPaintDeviceSP projection = node->projection(); if (!projection) return; QList colorMap; const KoColorSpace *cs = projection->colorSpace(); QRect rc = image->bounds(); int fuzziness = dlg.fuzziness(); updater->setProgress(0); KisRandomConstAccessorSP acc = projection->createRandomConstAccessorNG(rc.x(), rc.y()); for (int row = rc.y(); row < rc.height(); ++row) { for (int col = rc.x(); col < rc.width(); ++col) { acc->moveTo(col, row); KoColor c(cs); c.setColor(acc->rawDataConst(), cs); if (c.opacityU8() == OPACITY_TRANSPARENT_U8) { continue; } if (dlg.disregardOpacity()) { c.setOpacity(OPACITY_OPAQUE_U8); } bool found = false; Q_FOREACH (const Layer &l, colorMap) { if (fuzziness == 0) { found = (l.color == c); } else { quint8 match = cs->difference(l.color.data(), c.data()); found = (match <= fuzziness); } if (found) { KisRandomAccessorSP dstAcc = l.accessor; dstAcc->moveTo(col, row); memcpy(dstAcc->rawData(), acc->rawDataConst(), cs->pixelSize()); const_cast(&l)->pixelsWritten++; break; } } if (!found) { QString name = ""; if (dlg.palette()) { name = dlg.palette()->closestColorName(c); } if (name.toLower() == "untitled" || name.toLower() == "none" || name.toLower() == "") { name = KoColor::toQString(c); } Layer l; l.color = c; l.device = new KisPaintDevice(cs, name); l.accessor = l.device->createRandomAccessorNG(col, row); l.accessor->moveTo(col, row); memcpy(l.accessor->rawData(), acc->rawDataConst(), cs->pixelSize()); l.pixelsWritten = 1; colorMap << l; } } if (updater->interrupted()) { return; } updater->setProgress((row - rc.y()) * 100 / rc.height() - rc.y()); } updater->setProgress(100); dbgKrita << "Created" << colorMap.size() << "layers"; // Q_FOREACH (const Layer &l, colorMap) { // dbgKrita << "\t" << l.device->objectName() << ":" << l.pixelsWritten; // } if (dlg.sortLayers()) { std::sort(colorMap.begin(), colorMap.end()); } KisUndoAdapter *undo = image->undoAdapter(); undo->beginMacro(kundo2_i18n("Split Layer")); KisNodeCommandsAdapter adapter(m_view); KisGroupLayerSP baseGroup = dynamic_cast(node->parent().data()); if (!baseGroup) { // Masks are never nested baseGroup = dynamic_cast(node->parent()->parent().data()); } if (dlg.hideOriginal()) { node->setVisible(false); } if (dlg.createBaseGroup()) { KisGroupLayerSP grp = new KisGroupLayer(image, i18n("Color"), OPACITY_OPAQUE_U8); adapter.addNode(grp, baseGroup, 1); baseGroup = grp; } Q_FOREACH (const Layer &l, colorMap) { KisGroupLayerSP grp = baseGroup; if (dlg.createSeparateGroups()) { grp = new KisGroupLayer(image, l.device->objectName(), OPACITY_OPAQUE_U8); adapter.addNode(grp, baseGroup, 1); } KisPaintLayerSP paintLayer = new KisPaintLayer(image, l.device->objectName(), OPACITY_OPAQUE_U8, l.device); adapter.addNode(paintLayer, grp, 0); paintLayer->setAlphaLocked(dlg.lockAlpha()); } undo->endMacro(); image->unlock(); image->setModified(); } QApplication::restoreOverrideCursor(); } #include "layersplit.moc" diff --git a/plugins/extensions/layersplit/layersplit.h b/plugins/extensions/layersplit/layersplit.h index afe3461117..69b8e09306 100644 --- a/plugins/extensions/layersplit/layersplit.h +++ b/plugins/extensions/layersplit/layersplit.h @@ -1,40 +1,40 @@ /* * Copyright (C) 2014 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef LAYERSPLIT_H #define LAYERSPLIT_H #include #include -#include +#include -class LayerSplit : public KisViewPlugin +class LayerSplit : public KisActionPlugin { Q_OBJECT public: LayerSplit(QObject *parent, const QVariantList &); ~LayerSplit() override; private Q_SLOTS: void slotLayerSplit(); }; #endif // LAYERSPLIT_H diff --git a/plugins/extensions/metadataeditor/metadataeditor.cc b/plugins/extensions/metadataeditor/metadataeditor.cc index f9ce456317..62228227a0 100644 --- a/plugins/extensions/metadataeditor/metadataeditor.cc +++ b/plugins/extensions/metadataeditor/metadataeditor.cc @@ -1,69 +1,69 @@ /* * Copyright (c) 2007 Cyrille Berger * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "metadataeditor.h" #include #include #include #include #include #include #include "kis_config.h" #include "kis_cursor.h" #include "kis_global.h" #include "kis_layer.h" #include "kis_node_manager.h" #include "kis_types.h" #include "KisViewManager.h" #include "kis_action.h" #include "kis_image.h" #include #include #include #include #include "kis_entry_editor.h" #include "kis_meta_data_editor.h" K_PLUGIN_FACTORY_WITH_JSON(metadataeditorPluginFactory, "kritametadataeditor.json", registerPlugin();) metadataeditorPlugin::metadataeditorPlugin(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("EditLayerMetaData"); connect(action, SIGNAL(triggered()), this, SLOT(slotEditLayerMetaData())); } metadataeditorPlugin::~metadataeditorPlugin() { } void metadataeditorPlugin::slotEditLayerMetaData() { KisImageWSP image = m_view->image(); if (!image) return; KisMetaDataEditor editor(m_view->mainWindow(), m_view->nodeManager()->activeLayer()->metaData()); editor.exec(); } #include "metadataeditor.moc" diff --git a/plugins/extensions/metadataeditor/metadataeditor.h b/plugins/extensions/metadataeditor/metadataeditor.h index b828285506..3035557bf8 100644 --- a/plugins/extensions/metadataeditor/metadataeditor.h +++ b/plugins/extensions/metadataeditor/metadataeditor.h @@ -1,45 +1,45 @@ /* * Copyright (c) 2007 Cyrille Berger * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _METADATAEDITOR_H_ #define _METADATAEDITOR_H_ #include -#include +#include namespace KisMetaData { } /** * Template of view plugin */ -class metadataeditorPlugin : public KisViewPlugin +class metadataeditorPlugin : public KisActionPlugin { Q_OBJECT public: metadataeditorPlugin(QObject *parent, const QVariantList &); ~metadataeditorPlugin() override; private Q_SLOTS: void slotEditLayerMetaData(); }; #endif // metadataeditorPlugin_H diff --git a/plugins/extensions/modify_selection/modify_selection.cc b/plugins/extensions/modify_selection/modify_selection.cc index ac1344e6ac..94971924e3 100644 --- a/plugins/extensions/modify_selection/modify_selection.cc +++ b/plugins/extensions/modify_selection/modify_selection.cc @@ -1,75 +1,75 @@ /* * modify_selection.cc -- Part of Krita * * Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "modify_selection.h" #include #include #include "kis_action.h" #include #include #include "dlg_grow_selection.h" #include "dlg_shrink_selection.h" #include "dlg_border_selection.h" #include "dlg_feather_selection.h" #include "modify_selection_operations.h" K_PLUGIN_FACTORY_WITH_JSON(ModifySelectionFactory, "kritamodifyselection.json", registerPlugin();) ModifySelection::ModifySelection(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction* action = createAction("growselection"); action->setOperationID("growselection"); addUIFactory(new KisOperationUIWidgetFactory("growselection")); addOperation(new GrowSelectionOperation); action = createAction("shrinkselection"); action->setOperationID("shrinkselection"); addUIFactory(new KisOperationUIWidgetFactory("shrinkselection")); addOperation(new ShrinkSelectionOperation); action = createAction("borderselection"); action->setOperationID("borderselection"); addUIFactory(new KisOperationUIWidgetFactory("borderselection")); addOperation(new BorderSelectionOperation); action = createAction("featherselection"); action->setOperationID("featherselection"); addUIFactory(new KisOperationUIWidgetFactory("featherselection")); addOperation(new FeatherSelectionOperation); action = createAction("smoothselection"); action->setOperationID("smoothselection"); addOperation(new SmoothSelectionOperation); } ModifySelection::~ModifySelection() { } #include "modify_selection.moc" diff --git a/plugins/extensions/modify_selection/modify_selection.h b/plugins/extensions/modify_selection/modify_selection.h index 500387401a..bb36bdcca7 100644 --- a/plugins/extensions/modify_selection/modify_selection.h +++ b/plugins/extensions/modify_selection/modify_selection.h @@ -1,35 +1,35 @@ /* * modify_selection.h -- Part of Krita * * Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MODIFY_SELECTION_H #define MODIFY_SELECTION_H #include -#include +#include -class ModifySelection : public KisViewPlugin +class ModifySelection : public KisActionPlugin { Q_OBJECT public: ModifySelection(QObject *parent, const QVariantList &); ~ModifySelection() override; }; #endif // MODIFY_SELECTION_H diff --git a/plugins/extensions/offsetimage/offsetimage.cpp b/plugins/extensions/offsetimage/offsetimage.cpp index 8bc975bbb2..b082d5ef1c 100644 --- a/plugins/extensions/offsetimage/offsetimage.cpp +++ b/plugins/extensions/offsetimage/offsetimage.cpp @@ -1,143 +1,143 @@ /* * Copyright (c) 2013 Lukáš Tvrdý * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "offsetimage.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_offsetimage.h" #include "kis_offset_processing_visitor.h" K_PLUGIN_FACTORY_WITH_JSON(OffsetImageFactory, "kritaoffsetimage.json", registerPlugin();) OffsetImage::OffsetImage(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("offsetimage"); connect(action, SIGNAL(triggered()), this, SLOT(slotOffsetImage())); action = createAction("offsetlayer"); connect(action, SIGNAL(triggered()), this, SLOT(slotOffsetLayer())); } OffsetImage::~OffsetImage() { } void OffsetImage::slotOffsetImage() { KisImageSP image = m_view->image().toStrongRef(); if (image) { DlgOffsetImage * dlgOffsetImage = new DlgOffsetImage(m_view->mainWindow(), "OffsetImage", offsetWrapRect().size()); Q_CHECK_PTR(dlgOffsetImage); KUndo2MagicString actionName = kundo2_i18n("Offset Image"); dlgOffsetImage->setCaption(i18nc("@title:window", "Offset Image")); if (dlgOffsetImage->exec() == QDialog::Accepted) { QPoint offsetPoint = QPoint(dlgOffsetImage->offsetX(), dlgOffsetImage->offsetY()); offsetImpl(actionName, image->root(), offsetPoint); } delete dlgOffsetImage; } else { dbgKrita << "KisImage not available"; } } void OffsetImage::slotOffsetLayer() { KisImageSP image = m_view->image().toStrongRef(); if (image) { DlgOffsetImage * dlgOffsetImage = new DlgOffsetImage(m_view->mainWindow(), "OffsetLayer", offsetWrapRect().size()); Q_CHECK_PTR(dlgOffsetImage); KUndo2MagicString actionName = kundo2_i18n("Offset Layer"); dlgOffsetImage->setCaption(i18nc("@title:window", "Offset Layer")); if (dlgOffsetImage->exec() == QDialog::Accepted) { QPoint offsetPoint = QPoint(dlgOffsetImage->offsetX(), dlgOffsetImage->offsetY()); KisNodeSP activeNode = m_view->activeNode(); offsetImpl(actionName, activeNode, offsetPoint); } delete dlgOffsetImage; } else { dbgKrita << "KisImage not available"; } } void OffsetImage::offsetImpl(const KUndo2MagicString& actionName, KisNodeSP node, const QPoint& offsetPoint) { KisImageSignalVector emitSignals; emitSignals << ModifiedSignal; KisProcessingApplicator applicator(m_view->image(), node, KisProcessingApplicator::RECURSIVE, emitSignals, actionName); QRect rc = offsetWrapRect(); KisProcessingVisitorSP visitor = new KisOffsetProcessingVisitor(offsetPoint, rc); applicator.applyVisitor(visitor, KisStrokeJobData::CONCURRENT); applicator.end(); } QRect OffsetImage::offsetWrapRect() { QRect offsetWrapRect; if (m_view->selection()) { offsetWrapRect = m_view->selection()->selectedExactRect(); } else { KisImageSP image = m_view->image().toStrongRef(); if (image) { offsetWrapRect = image->bounds(); } } return offsetWrapRect; } #include "offsetimage.moc" diff --git a/plugins/extensions/offsetimage/offsetimage.h b/plugins/extensions/offsetimage/offsetimage.h index 6f6f2b6c0d..05fb79296e 100644 --- a/plugins/extensions/offsetimage/offsetimage.h +++ b/plugins/extensions/offsetimage/offsetimage.h @@ -1,49 +1,49 @@ /* * Copyright (c) 2013 Lukáš Tvrdý * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef OFFSETIMAGE_H #define OFFSETIMAGE_H #include -#include +#include #include #include class KUndo2MagicString; -class OffsetImage : public KisViewPlugin +class OffsetImage : public KisActionPlugin { Q_OBJECT public: OffsetImage(QObject *parent, const QVariantList &); ~OffsetImage() override; public Q_SLOTS: void slotOffsetImage(); void slotOffsetLayer(); void offsetImpl(const KUndo2MagicString &actionName, KisNodeSP node, const QPoint &offsetPoint); private: QRect offsetWrapRect(); }; #endif // OFFSETIMAGE_H diff --git a/plugins/extensions/pykrita/plugin/plugin.cpp b/plugins/extensions/pykrita/plugin/plugin.cpp index 207231e965..0bf434d1e7 100644 --- a/plugins/extensions/pykrita/plugin/plugin.cpp +++ b/plugins/extensions/pykrita/plugin/plugin.cpp @@ -1,95 +1,95 @@ /* * Copyright (c) 2014 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "plugin.h" #include #include #include #include #include "pyqtpluginsettings.h" #include K_PLUGIN_FACTORY_WITH_JSON(KritaPyQtPluginFactory, "kritapykrita.json", registerPlugin();) KritaPyQtPlugin::KritaPyQtPlugin(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) , m_autoReload(false) { qDebug() << "Loading Python plugin"; PyKrita::InitResult initResult = PyKrita::initialize(); switch (initResult) { case PyKrita::INIT_OK: break; case PyKrita::INIT_CANNOT_LOAD_PYTHON_LIBRARY: qWarning() << i18n("Cannot load Python library"); return; case PyKrita::INIT_CANNOT_SET_PYTHON_PATHS: qWarning() << i18n("Cannot set Python paths"); return; case PyKrita::INIT_CANNOT_LOAD_PYKRITA_MODULE: qWarning() << i18n("Cannot load built-in pykrita module"); return; default: qWarning() << i18n("Unexpected error initializing python plugin."); return; } pluginManager = PyKrita::pluginManager(); KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance(); PyQtPluginSettingsFactory* settingsFactory = new PyQtPluginSettingsFactory(pluginManager); //load and save preferences //if something in kritarc is missing, then the default from this load function will be used and saved back to kconfig. //this way, cfg.readEntry() in any part won't be able to set its own default KisPreferenceSet* settings = settingsFactory->createPreferenceSet(); KIS_SAFE_ASSERT_RECOVER_RETURN(settings); settings->loadPreferences(); settings->savePreferences(); delete settings; preferenceSetRegistry->add("PyQtPluginSettingsFactory", settingsFactory); // Try to import the `pykrita` module PyKrita::Python py = PyKrita::Python(); PyObject* pykritaPackage = py.moduleImport("pykrita"); pykritaPackage = py.moduleImport("krita"); if (pykritaPackage) { dbgScript << "Loaded pykrita, now load plugins"; pluginManager->scanPlugins(); pluginManager->tryLoadEnabledPlugins(); //py.functionCall("_pykritaLoaded", PyKrita::Python::PYKRITA_ENGINE); } else { dbgScript << "Cannot load pykrita module"; } Q_FOREACH (Extension* ext, Krita::instance()->extensions()) { ext->setup(); } } KritaPyQtPlugin::~KritaPyQtPlugin() { PyKrita::finalize(); } #include "plugin.moc" diff --git a/plugins/extensions/pykrita/plugin/plugin.h b/plugins/extensions/pykrita/plugin/plugin.h index afac770a74..f7fbe40cdd 100644 --- a/plugins/extensions/pykrita/plugin/plugin.h +++ b/plugins/extensions/pykrita/plugin/plugin.h @@ -1,41 +1,41 @@ /* * This file is part of PyKrita, Krita' Python scripting plugin. * * Copyright (C) 2013 Alex Turbov * Copyright (C) 2014-2016 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) version 3. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef _PYQT_PLUGIN_H_ #define _PYQT_PLUGIN_H_ #include -#include +#include #include "PythonPluginManager.h" -class KritaPyQtPlugin : public KisViewPlugin +class KritaPyQtPlugin : public KisActionPlugin { Q_OBJECT public: KritaPyQtPlugin(QObject *parent, const QVariantList &); virtual ~KritaPyQtPlugin(); private: PythonPluginManager *pluginManager; bool m_autoReload; }; #endif diff --git a/plugins/extensions/qmic/QMic.cpp b/plugins/extensions/qmic/QMic.cpp index a9e0f974b9..6a667a6327 100644 --- a/plugins/extensions/qmic/QMic.cpp +++ b/plugins/extensions/qmic/QMic.cpp @@ -1,464 +1,464 @@ /* * Copyright (c) 2017 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "QMic.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_input_output_mapper.h" #include "kis_qmic_simple_convertor.h" #include "kis_import_qmic_processing_visitor.h" #include #include "kis_qmic_applicator.h" static const char ack[] = "ack"; K_PLUGIN_FACTORY_WITH_JSON(QMicFactory, "kritaqmic.json", registerPlugin();) QMic::QMic(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) , m_gmicApplicator(0) { #ifndef Q_OS_MAC KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance(); PluginSettingsFactory* settingsFactory = new PluginSettingsFactory(); preferenceSetRegistry->add("QMicPluginSettingsFactory", settingsFactory); m_qmicAction = createAction("QMic"); m_qmicAction->setActivationFlags(KisAction::ACTIVE_DEVICE); connect(m_qmicAction , SIGNAL(triggered()), this, SLOT(slotQMic())); m_againAction = createAction("QMicAgain"); m_againAction->setActivationFlags(KisAction::ACTIVE_DEVICE); m_againAction->setEnabled(false); connect(m_againAction, SIGNAL(triggered()), this, SLOT(slotQMicAgain())); m_gmicApplicator = new KisQmicApplicator(); connect(m_gmicApplicator, SIGNAL(gmicFinished(bool, int, QString)), this, SLOT(slotGmicFinished(bool, int, QString))); #endif } QMic::~QMic() { Q_FOREACH(QSharedMemory *memorySegment, m_sharedMemorySegments) { // qDebug() << "detaching" << memorySegment->key(); memorySegment->detach(); } qDeleteAll(m_sharedMemorySegments); m_sharedMemorySegments.clear(); if (m_pluginProcess) { m_pluginProcess->close(); } delete m_gmicApplicator; delete m_localServer; } void QMic::slotQMicAgain() { slotQMic(true); } void QMic::slotQMic(bool again) { m_qmicAction->setEnabled(false); m_againAction->setEnabled(false); // find the krita-gmic-qt plugin QString pluginPath = PluginSettings::gmicQtPath(); if (pluginPath.isEmpty() || !QFileInfo(pluginPath).exists() || !QFileInfo(pluginPath).isFile()) { QMessageBox::warning(0, i18nc("@title:window", "Krita"), i18n("Krita cannot find the gmic-qt plugin.")); return; } m_key = QUuid::createUuid().toString(); m_localServer = new QLocalServer(); m_localServer->listen(m_key); connect(m_localServer, SIGNAL(newConnection()), SLOT(connected())); m_pluginProcess = new QProcess(this); connect(m_view, SIGNAL(destroyed(QObject *o)), m_pluginProcess, SLOT(terminate())); m_pluginProcess->setProcessChannelMode(QProcess::ForwardedChannels); connect(m_pluginProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(pluginFinished(int,QProcess::ExitStatus))); connect(m_pluginProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(pluginStateChanged(QProcess::ProcessState))); m_pluginProcess->start(pluginPath, QStringList() << m_key << (again ? QString(" reapply") : QString())); bool r = m_pluginProcess->waitForStarted(); while (m_pluginProcess->waitForFinished(10)) { qApp->processEvents(QEventLoop::ExcludeUserInputEvents); } qDebug() << "Plugin started" << r << m_pluginProcess->state(); } void QMic::connected() { qDebug() << "connected"; if (!m_view) return; QLocalSocket *socket = m_localServer->nextPendingConnection(); if (!socket) { return; } while (socket->bytesAvailable() < static_cast(sizeof(quint32))) { if (!socket->isValid()) { // stale request return; } socket->waitForReadyRead(1000); } QDataStream ds(socket); QByteArray msg; quint32 remaining; ds >> remaining; msg.resize(remaining); int got = 0; char* uMsgBuf = msg.data(); // FIXME: Should use read transaction for Qt >= 5.7: // https://doc.qt.io/qt-5/qdatastream.html#using-read-transactions do { got = ds.readRawData(uMsgBuf, remaining); remaining -= got; uMsgBuf += got; } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); if (got < 0) { qWarning() << "Message reception failed" << socket->errorString(); delete socket; m_localServer->close(); delete m_localServer; m_localServer = 0; return; } QString message = QString::fromUtf8(msg); qDebug() << "Received" << message; // Check the message: we can get three different ones QMultiMap messageMap; Q_FOREACH(QString line, message.split('\n', QString::SkipEmptyParts)) { QList kv = line.split('=', QString::SkipEmptyParts); if (kv.size() == 2) { messageMap.insert(kv[0], kv[1]); } else { qWarning() << "line" << line << "is invalid."; } } if (!messageMap.contains("command")) { qWarning() << "Message did not contain a command"; return; } int mode = 0; if (messageMap.contains("mode")) { mode = messageMap.values("mode").first().toInt(); } QByteArray ba; QString messageBoxWarningText; if (messageMap.values("command").first() == "gmic_qt_get_image_size") { KisSelectionSP selection = m_view->image()->globalSelection(); if (selection) { QRect selectionRect = selection->selectedExactRect(); ba = QByteArray::number(selectionRect.width()) + "," + QByteArray::number(selectionRect.height()); } else { ba = QByteArray::number(m_view->image()->width()) + "," + QByteArray::number(m_view->image()->height()); } } else if (messageMap.values("command").first() == "gmic_qt_get_cropped_images") { // Parse the message, create the shared memory segments, and create a new message to send back and waid for ack QRectF cropRect(0.0, 0.0, 1.0, 1.0); if (!messageMap.contains("croprect") || messageMap.values("croprect").first().split(',', QString::SkipEmptyParts).size() != 4) { qWarning() << "gmic-qt didn't send a croprect or not a valid croprect"; } else { QStringList cr = messageMap.values("croprect").first().split(',', QString::SkipEmptyParts); cropRect.setX(cr[0].toFloat()); cropRect.setY(cr[1].toFloat()); cropRect.setWidth(cr[2].toFloat()); cropRect.setHeight(cr[3].toFloat()); } if (!prepareCroppedImages(&ba, cropRect, mode)) { qWarning() << "Failed to prepare images for gmic-qt"; } } else if (messageMap.values("command").first() == "gmic_qt_output_images") { // Parse the message. read the shared memory segments, fix up the current image and send an ack qDebug() << "gmic_qt_output_images"; QStringList layers = messageMap.values("layer"); m_outputMode = (OutputMode)mode; if (m_outputMode != IN_PLACE) { messageBoxWarningText = i18n("Sorry, this output mode is not implemented yet."); m_outputMode = IN_PLACE; } slotStartApplicator(layers); } else if (messageMap.values("command").first() == "gmic_qt_detach") { Q_FOREACH(QSharedMemory *memorySegment, m_sharedMemorySegments) { qDebug() << "detaching" << memorySegment->key() << memorySegment->isAttached(); if (memorySegment->isAttached()) { if (!memorySegment->detach()) { qDebug() << "\t" << memorySegment->error() << memorySegment->errorString(); } } } qDeleteAll(m_sharedMemorySegments); m_sharedMemorySegments.clear(); } else { qWarning() << "Received unknown command" << messageMap.values("command"); } qDebug() << "Sending" << QString::fromUtf8(ba); // HACK: Make sure QDataStream does not refuse to write! // Proper fix: Change the above read to use read transaction ds.resetStatus(); ds.writeBytes(ba.constData(), ba.length()); // Flush the socket because we might not return to the event loop! if (!socket->waitForBytesWritten(2000)) { qWarning() << "Failed to write response:" << socket->error(); } // Wait for the ack bool r = true; r &= socket->waitForReadyRead(2000); // wait for ack r &= (socket->read(qstrlen(ack)) == ack); if (!socket->waitForDisconnected(2000)) { qWarning() << "Remote not disconnected:" << socket->error(); // Wait again socket->disconnectFromServer(); if (socket->waitForDisconnected(2000)) { qWarning() << "Disconnect timed out:" << socket->error(); } } if (!messageBoxWarningText.isEmpty()) { // Defer the message box to the event loop QTimer::singleShot(0, [messageBoxWarningText]() { QMessageBox::warning(KisPart::instance()->currentMainwindow(), i18nc("@title:window", "Krita"), messageBoxWarningText); }); } } void QMic::pluginStateChanged(QProcess::ProcessState state) { qDebug() << "stateChanged" << state; } void QMic::pluginFinished(int exitCode, QProcess::ExitStatus exitStatus) { qDebug() << "pluginFinished" << exitCode << exitStatus; delete m_pluginProcess; m_pluginProcess = 0; delete m_localServer; m_localServer = 0; m_qmicAction->setEnabled(true); m_againAction->setEnabled(true); } void QMic::slotGmicFinished(bool successfully, int milliseconds, const QString &msg) { qDebug() << "slotGmicFinished();" << successfully << milliseconds << msg; if (successfully) { m_gmicApplicator->finish(); } else { m_gmicApplicator->cancel(); QMessageBox::warning(0, i18nc("@title:window", "Krita"), i18n("G'Mic failed, reason:") + msg); } } void QMic::slotStartApplicator(QStringList gmicImages) { qDebug() << "slotStartApplicator();" << gmicImages; if (!m_view) return; // Create a vector of gmic images QVector *> images; Q_FOREACH(const QString &image, gmicImages) { QStringList parts = image.split(',', QString::SkipEmptyParts); Q_ASSERT(parts.size() == 4); QString key = parts[0]; QString layerName = QByteArray::fromHex(parts[1].toLatin1()); int spectrum = parts[2].toInt(); int width = parts[3].toInt(); int height = parts[4].toInt(); qDebug() << key << layerName << width << height; QSharedMemory m(key); if (!m.attach(QSharedMemory::ReadOnly)) { qWarning() << "Could not attach to shared memory area." << m.error() << m.errorString(); } if (m.isAttached()) { if (!m.lock()) { qDebug() << "Could not lock memeory segment" << m.error() << m.errorString(); } qDebug() << "Memory segment" << key << m.size() << m.constData() << m.data(); gmic_image *gimg = new gmic_image(); gimg->assign(width, height, 1, spectrum); gimg->name = layerName; gimg->_data = new float[width * height * spectrum * sizeof(float)]; qDebug() << "width" << width << "height" << height << "size" << width * height * spectrum * sizeof(float) << "shared memory size" << m.size(); memcpy(gimg->_data, m.constData(), width * height * spectrum * sizeof(float)); qDebug() << "created gmic image" << gimg->name << gimg->_width << gimg->_height; if (!m.unlock()) { qDebug() << "Could not unlock memeory segment" << m.error() << m.errorString(); } if (!m.detach()) { qDebug() << "Could not detach from memeory segment" << m.error() << m.errorString(); } images.append(gimg); } } qDebug() << "Got" << images.size() << "gmic images"; // Start the applicator KUndo2MagicString actionName = kundo2_i18n("Gmic filter"); KisNodeSP rootNode = m_view->image()->root(); KisInputOutputMapper mapper(m_view->image(), m_view->activeNode()); KisNodeListSP layers = mapper.inputNodes(m_inputMode); m_gmicApplicator->setProperties(m_view->image(), rootNode, images, actionName, layers); m_gmicApplicator->preview(); m_gmicApplicator->finish(); } bool QMic::prepareCroppedImages(QByteArray *message, QRectF &rc, int inputMode) { if (!m_view) return false; m_view->image()->lock(); m_inputMode = (InputLayerMode)inputMode; qDebug() << "prepareCroppedImages()" << QString::fromUtf8(*message) << rc << inputMode; KisInputOutputMapper mapper(m_view->image(), m_view->activeNode()); KisNodeListSP nodes = mapper.inputNodes(m_inputMode); if (nodes->isEmpty()) { m_view->image()->unlock(); return false; } for (int i = 0; i < nodes->size(); ++i) { KisNodeSP node = nodes->at(i); if (node && node->paintDevice()) { QRect cropRect; KisSelectionSP selection = m_view->image()->globalSelection(); if (selection) { cropRect = selection->selectedExactRect(); } else { cropRect = m_view->image()->bounds(); } qDebug() << "Converting node" << node->name() << cropRect; const QRectF mappedRect = KisAlgebra2D::mapToRect(cropRect).mapRect(rc); const QRect resultRect = mappedRect.toAlignedRect(); QSharedMemory *m = new QSharedMemory(QString("key_%1").arg(QUuid::createUuid().toString())); m_sharedMemorySegments.append(m); if (!m->create(resultRect.width() * resultRect.height() * 4 * sizeof(float))) { //buf.size())) { qWarning() << "Could not create shared memory segment" << m->error() << m->errorString(); return false; } m->lock(); gmic_image img; img.assign(resultRect.width(), resultRect.height(), 1, 4); img._data = reinterpret_cast(m->data()); KisQmicSimpleConvertor::convertToGmicImageFast(node->paintDevice(), &img, resultRect); message->append(m->key().toUtf8()); m->unlock(); message->append(","); message->append(node->name().toUtf8().toHex()); message->append(","); message->append(QByteArray::number(resultRect.width())); message->append(","); message->append(QByteArray::number(resultRect.height())); message->append("\n"); } } qDebug() << QString::fromUtf8(*message); m_view->image()->unlock(); return true; } #include "QMic.moc" diff --git a/plugins/extensions/qmic/QMic.h b/plugins/extensions/qmic/QMic.h index 95f9564980..f839112d03 100644 --- a/plugins/extensions/qmic/QMic.h +++ b/plugins/extensions/qmic/QMic.h @@ -1,69 +1,69 @@ /* * Copyright (c) 2017 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef QMIC_H #define QMIC_H #include #include #include -#include +#include #include #include "gmic.h" class KisAction; class QLocalServer; class QSharedMemory; class KisQmicApplicator; -class QMic : public KisViewPlugin +class QMic : public KisActionPlugin { Q_OBJECT public: QMic(QObject *parent, const QVariantList &); virtual ~QMic(); private Q_SLOTS: void slotQMicAgain(); void slotQMic(bool again = false); void connected(); void pluginStateChanged(QProcess::ProcessState); void pluginFinished(int exitCode, QProcess::ExitStatus exitStatus); void slotGmicFinished(bool successfully, int milliseconds = -1, const QString& msg = QString()); void slotStartApplicator(QStringList gmicImages); private: bool prepareCroppedImages(QByteArray *message, QRectF &rc, int inputMode); QProcess *m_pluginProcess {0}; QLocalServer *m_localServer {0}; QString m_key; KisAction *m_qmicAction {0}; KisAction *m_againAction {0}; QVector m_sharedMemorySegments; KisQmicApplicator *m_gmicApplicator {0}; InputLayerMode m_inputMode {ACTIVE_LAYER}; OutputMode m_outputMode {IN_PLACE}; }; #endif // QMic_H diff --git a/plugins/extensions/resourcemanager/resourcemanager.cpp b/plugins/extensions/resourcemanager/resourcemanager.cpp index 5953a79c1d..0567b063a1 100644 --- a/plugins/extensions/resourcemanager/resourcemanager.cpp +++ b/plugins/extensions/resourcemanager/resourcemanager.cpp @@ -1,328 +1,328 @@ /* * resourcemanager.cc -- Part of Krita * * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "resourcemanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_bundle_manager.h" #include "dlg_create_bundle.h" #include #include "krita_container_utils.h" class ResourceManager::Private { public: Private() { brushServer = KisBrushServer::instance()->brushServer(false); paintopServer = KisResourceServerProvider::instance()->paintOpPresetServer(false); gradientServer = KoResourceServerProvider::instance()->gradientServer(false); patternServer = KoResourceServerProvider::instance()->patternServer(false); paletteServer = KoResourceServerProvider::instance()->paletteServer(false); workspaceServer = KisResourceServerProvider::instance()->workspaceServer(false); } KisBrushResourceServer* brushServer; KisPaintOpPresetResourceServer * paintopServer; KoResourceServer* gradientServer; KoResourceServer *patternServer; KoResourceServer* paletteServer; KoResourceServer* workspaceServer; }; K_PLUGIN_FACTORY_WITH_JSON(ResourceManagerFactory, "kritaresourcemanager.json", registerPlugin();) ResourceManager::ResourceManager(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) , d(new Private()) { KisAction *action = new KisAction(i18n("Import Bundles..."), this); addAction("import_bundles", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportBundles())); action = new KisAction(i18n("Import Brushes..."), this); addAction("import_brushes", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportBrushes())); action = new KisAction(i18n("Import Gradients..."), this); addAction("import_gradients", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportGradients())); action = new KisAction(i18n("Import Palettes..."), this); addAction("import_palettes", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportPalettes())); action = new KisAction(i18n("Import Patterns..."), this); addAction("import_patterns", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportPatterns())); action = new KisAction(i18n("Import Presets..."), this); addAction("import_presets", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportPresets())); action = new KisAction(i18n("Import Workspaces..."), this); addAction("import_workspaces", action); connect(action, SIGNAL(triggered()), this, SLOT(slotImportWorkspaces())); action = new KisAction(i18n("Create Resource Bundle..."), this); addAction("create_bundle", action); connect(action, SIGNAL(triggered()), this, SLOT(slotCreateBundle())); action = new KisAction(i18n("Manage Resources..."), this); addAction("manage_bundles", action); connect(action, SIGNAL(triggered()), this, SLOT(slotManageBundles())); } ResourceManager::~ResourceManager() { } void ResourceManager::slotCreateBundle() { DlgCreateBundle dlgCreateBundle; if (dlgCreateBundle.exec() != QDialog::Accepted) { return; } saveBundle(dlgCreateBundle); } KisResourceBundle *ResourceManager::saveBundle(const DlgCreateBundle &dlgCreateBundle) { QString bundlePath = dlgCreateBundle.saveLocation() + "/" + dlgCreateBundle.bundleName() + ".bundle"; KisResourceBundle *newBundle = new KisResourceBundle(bundlePath); newBundle->addMeta("name", dlgCreateBundle.bundleName()); newBundle->addMeta("author", dlgCreateBundle.authorName()); newBundle->addMeta("email", dlgCreateBundle.email()); newBundle->addMeta("license", dlgCreateBundle.license()); newBundle->addMeta("website", dlgCreateBundle.website()); newBundle->addMeta("description", dlgCreateBundle.description()); newBundle->setThumbnail(dlgCreateBundle.previewImage()); QStringList res = dlgCreateBundle.selectedBrushes(); Q_FOREACH (const QString &r, res) { KoResource *res = d->brushServer->resourceByFilename(r).data(); newBundle->addResource("kis_brushes", res->filename(), d->brushServer->assignedTagsList(res), res->md5()); } res = dlgCreateBundle.selectedGradients(); Q_FOREACH (const QString &r, res) { KoResource *res = d->gradientServer->resourceByFilename(r); newBundle->addResource("ko_gradients", res->filename(), d->gradientServer->assignedTagsList(res), res->md5()); } res = dlgCreateBundle.selectedPalettes(); Q_FOREACH (const QString &r, res) { KoResource *res = d->paletteServer->resourceByFilename(r); newBundle->addResource("ko_palettes", res->filename(), d->paletteServer->assignedTagsList(res), res->md5()); } res = dlgCreateBundle.selectedPatterns(); Q_FOREACH (const QString &r, res) { KoResource *res = d->patternServer->resourceByFilename(r); newBundle->addResource("ko_patterns", res->filename(), d->patternServer->assignedTagsList(res), res->md5()); } res = dlgCreateBundle.selectedPresets(); Q_FOREACH (const QString &r, res) { KisPaintOpPresetSP preset = d->paintopServer->resourceByFilename(r); KoResource *res = preset.data(); newBundle->addResource("kis_paintoppresets", res->filename(), d->paintopServer->assignedTagsList(res), res->md5()); KisPaintOpSettingsSP settings = preset->settings(); QStringList requiredFiles = settings->getStringList(KisPaintOpUtils::RequiredBrushFilesListTag); requiredFiles << settings->getString(KisPaintOpUtils::RequiredBrushFileTag); KritaUtils::makeContainerUnique(requiredFiles); Q_FOREACH (const QString &brushFile, requiredFiles) { KisBrush *brush = d->brushServer->resourceByFilename(brushFile).data(); if (brush) { newBundle->addResource("kis_brushes", brushFile, d->brushServer->assignedTagsList(brush), brush->md5()); } else { qWarning() << "There is no brush with name" << brushFile; } } } res = dlgCreateBundle.selectedWorkspaces(); Q_FOREACH (const QString &r, res) { KoResource *res = d->workspaceServer->resourceByFilename(r); newBundle->addResource("kis_workspaces", res->filename(), d->workspaceServer->assignedTagsList(res), res->md5()); } newBundle->addMeta("fileName", bundlePath); newBundle->addMeta("created", QDate::currentDate().toString("dd/MM/yyyy")); if (!newBundle->save()) { QMessageBox::critical(m_view->mainWindow(), i18nc("@title:window", "Krita"), i18n("Could not create the new bundle.")); } else { newBundle->setValid(true); if (QDir(KisResourceServerProvider::instance()->resourceBundleServer()->saveLocation()) != QDir(QFileInfo(bundlePath).path())) { newBundle->setFilename(KisResourceServerProvider::instance()->resourceBundleServer()->saveLocation() + "/" + dlgCreateBundle.bundleName() + ".bundle"); } if (KisResourceServerProvider::instance()->resourceBundleServer()->resourceByName(newBundle->name())) { KisResourceServerProvider::instance()->resourceBundleServer()->removeResourceFromServer( KisResourceServerProvider::instance()->resourceBundleServer()->resourceByName(newBundle->name())); } KisResourceServerProvider::instance()->resourceBundleServer()->addResource(newBundle, true); newBundle->load(); } return newBundle; } void ResourceManager::slotManageBundles() { DlgBundleManager* dlg = new DlgBundleManager(this, m_view->actionManager()); if (dlg->exec() != QDialog::Accepted) { return; } } QStringList ResourceManager::importResources(const QString &title, const QStringList &mimes) const { KoFileDialog dialog(m_view->mainWindow(), KoFileDialog::OpenFiles, "krita_resources"); dialog.setDefaultDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); dialog.setCaption(title); dialog.setMimeTypeFilters(mimes); return dialog.filenames(); } void ResourceManager::slotImportBrushes() { QStringList resources = importResources(i18n("Import Brushes"), QStringList() << "image/x-gimp-brush" << "image/x-gimp-x-gimp-brush-animated" << "image/x-adobe-brushlibrary" << "image/png" << "image/svg+xml"); Q_FOREACH (const QString &res, resources) { d->brushServer->importResourceFile(res); } } void ResourceManager::slotImportPresets() { QStringList resources = importResources(i18n("Import Presets"), QStringList() << "application/x-krita-paintoppreset"); Q_FOREACH (const QString &res, resources) { d->paintopServer->importResourceFile(res); } } void ResourceManager::slotImportGradients() { QStringList resources = importResources(i18n("Import Gradients"), QStringList() << "image/svg+xml" << "application/x-gimp-gradient" << "applicaition/x-karbon-gradient"); Q_FOREACH (const QString &res, resources) { d->gradientServer->importResourceFile(res); } } void ResourceManager::slotImportBundles() { QStringList resources = importResources(i18n("Import Bundles"), QStringList() << "application/x-krita-bundle"); Q_FOREACH (const QString &res, resources) { KisResourceBundle *bundle = KisResourceServerProvider::instance()->resourceBundleServer()->createResource(res); bundle->load(); if (bundle->valid()) { if (!bundle->install()) { QMessageBox::warning(0, i18nc("@title:window", "Krita"), i18n("Could not install the resources for bundle %1.").arg(res)); } } else { QMessageBox::warning(0, i18nc("@title:window", "Krita"), i18n("Could not load bundle %1.").arg(res)); } QFileInfo fi(res); QString newFilename = KisResourceServerProvider::instance()->resourceBundleServer()->saveLocation() + fi.baseName() + bundle->defaultFileExtension(); QFileInfo fileInfo(newFilename); int i = 1; while (fileInfo.exists()) { fileInfo.setFile(KisResourceServerProvider::instance()->resourceBundleServer()->saveLocation() + fi.baseName() + QString("%1").arg(i) + bundle->defaultFileExtension()); i++; } bundle->setFilename(fileInfo.filePath()); QFile::copy(res, newFilename); KisResourceServerProvider::instance()->resourceBundleServer()->addResource(bundle, false); } } void ResourceManager::slotImportPatterns() { QStringList resources = importResources(i18n("Import Patterns"), QStringList() << "image/png" << "image/svg+xml" << "application/x-gimp-pattern" << "image/jpeg" << "image/tiff" << "image/bmp" << "image/xpg"); Q_FOREACH (const QString &res, resources) { d->patternServer->importResourceFile(res); } } void ResourceManager::slotImportPalettes() { QStringList resources = importResources(i18n("Import Palettes"), QStringList() << "image/x-gimp-color-palette"); Q_FOREACH (const QString &res, resources) { d->paletteServer->importResourceFile(res); } } void ResourceManager::slotImportWorkspaces() { QStringList resources = importResources(i18n("Import Workspaces"), QStringList() << "application/x-krita-workspace"); Q_FOREACH (const QString &res, resources) { d->workspaceServer->importResourceFile(res); } } #include "resourcemanager.moc" diff --git a/plugins/extensions/resourcemanager/resourcemanager.h b/plugins/extensions/resourcemanager/resourcemanager.h index 11ae3373c1..968fed07a0 100644 --- a/plugins/extensions/resourcemanager/resourcemanager.h +++ b/plugins/extensions/resourcemanager/resourcemanager.h @@ -1,63 +1,63 @@ /* * resourcemanager.h -- Part of Krita * * Copyright (c) 2014 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef RESOURCEMANAGER_H #define RESOURCEMANAGER_H #include #include #include #include -#include +#include #include "KisResourceBundle.h" #include "dlg_create_bundle.h" -class ResourceManager : public KisViewPlugin +class ResourceManager : public KisActionPlugin { Q_OBJECT public: ResourceManager(QObject *parent, const QVariantList &); ~ResourceManager() override; KisResourceBundle *saveBundle(const DlgCreateBundle &dlgCreateBundle); private Q_SLOTS: void slotCreateBundle(); void slotManageBundles(); void slotImportBrushes(); void slotImportGradients(); void slotImportPalettes(); void slotImportPatterns(); void slotImportPresets(); void slotImportWorkspaces(); void slotImportBundles(); private: QStringList importResources(const QString &title, const QStringList &mimes) const; class Private; QScopedPointer d; }; #endif // RESOURCEMANAGER_H diff --git a/plugins/extensions/rotateimage/rotateimage.cc b/plugins/extensions/rotateimage/rotateimage.cc index 77a9e73c05..8ab121485d 100644 --- a/plugins/extensions/rotateimage/rotateimage.cc +++ b/plugins/extensions/rotateimage/rotateimage.cc @@ -1,148 +1,148 @@ /* * rotateimage.cc -- Part of Krita * * Copyright (c) 2004 Michael Thaler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "rotateimage.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_rotateimage.h" K_PLUGIN_FACTORY_WITH_JSON(RotateImageFactory, "kritarotateimage.json", registerPlugin();) RotateImage::RotateImage(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("rotateimage"); connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage())); action = createAction("rotateImageCW90"); connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage90())); action = createAction("rotateImage180"); connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage180())); action = createAction("rotateImageCCW90"); connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage270())); action = createAction("mirrorImageHorizontal"); connect(action, SIGNAL(triggered()), this, SLOT(slotMirrorImageHorizontal())); action = createAction("mirrorImageVertical"); connect(action, SIGNAL(triggered()), this, SLOT(slotMirrorImageVertical())); action = createAction("rotatelayer"); connect(action, SIGNAL(triggered()), this, SLOT(slotRotateLayer())); action = createAction("rotateLayer180"); connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotate180())); action = createAction("rotateLayerCW90"); connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateRight90())); action = createAction("rotateLayerCCW90"); connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateLeft90())); } RotateImage::~RotateImage() { } void RotateImage::slotRotateImage() { KisImageWSP image = m_view->image(); if (!image) return; DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view->mainWindow(), "RotateImage"); Q_CHECK_PTR(dlgRotateImage); dlgRotateImage->setCaption(i18n("Rotate Image")); if (dlgRotateImage->exec() == QDialog::Accepted) { double angle = dlgRotateImage->angle() * M_PI / 180; m_view->imageManager()->rotateCurrentImage(angle); } delete dlgRotateImage; } void RotateImage::slotRotateImage90() { m_view->imageManager()->rotateCurrentImage(M_PI / 2); } void RotateImage::slotRotateImage180() { m_view->imageManager()->rotateCurrentImage(M_PI); } void RotateImage::slotRotateImage270() { m_view->imageManager()->rotateCurrentImage(- M_PI / 2 + M_PI*2); } void RotateImage::slotMirrorImageVertical() { KisImageWSP image = m_view->image(); if (!image) return; m_view->nodeManager()->mirrorNode(image->rootLayer(), kundo2_i18n("Mirror Image Vertically"), Qt::Vertical); } void RotateImage::slotMirrorImageHorizontal() { KisImageWSP image = m_view->image(); if (!image) return; m_view->nodeManager()->mirrorNode(image->rootLayer(), kundo2_i18n("Mirror Image Horizontally"), Qt::Horizontal); } void RotateImage::slotRotateLayer() { KisImageWSP image = m_view->image(); if (!image) return; DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view->mainWindow(), "RotateLayer"); Q_CHECK_PTR(dlgRotateImage); dlgRotateImage->setCaption(i18n("Rotate Layer")); if (dlgRotateImage->exec() == QDialog::Accepted) { double angle = dlgRotateImage->angle() * M_PI / 180; m_view->nodeManager()->rotate(angle); } delete dlgRotateImage; } #include "rotateimage.moc" diff --git a/plugins/extensions/rotateimage/rotateimage.h b/plugins/extensions/rotateimage/rotateimage.h index 60a610245b..b0e88dcb23 100644 --- a/plugins/extensions/rotateimage/rotateimage.h +++ b/plugins/extensions/rotateimage/rotateimage.h @@ -1,45 +1,45 @@ /* * rotateimage.h -- Part of Krita * * Copyright (c) 2004 Michael Thaler (michael.thaler@physik.tu-muenchen.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ROTATEIMAGE_H #define ROTATEIMAGE_H #include -#include +#include -class RotateImage : public KisViewPlugin +class RotateImage : public KisActionPlugin { Q_OBJECT public: RotateImage(QObject *parent, const QVariantList &); ~RotateImage() override; private Q_SLOTS: void slotRotateImage(); void slotRotateImage90(); void slotRotateImage180(); void slotRotateImage270(); void slotMirrorImageVertical(); void slotMirrorImageHorizontal(); void slotRotateLayer(); }; #endif // ROTATEIMAGE_H diff --git a/plugins/extensions/separate_channels/kis_separate_channels_plugin.cc b/plugins/extensions/separate_channels/kis_separate_channels_plugin.cc index ece1e7c064..19163e5f79 100644 --- a/plugins/extensions/separate_channels/kis_separate_channels_plugin.cc +++ b/plugins/extensions/separate_channels/kis_separate_channels_plugin.cc @@ -1,99 +1,99 @@ /* * This file is part of the KDE project * * Copyright (c) 2005 Michael Thaler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_separate_channels_plugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_channel_separator.h" #include "dlg_separate.h" K_PLUGIN_FACTORY_WITH_JSON(KisSeparateChannelsPluginFactory, "kritaseparatechannels.json", registerPlugin();) KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("separate"); connect(action, SIGNAL(triggered(bool)), SLOT(slotSeparate())); } KisSeparateChannelsPlugin::~KisSeparateChannelsPlugin() { } void KisSeparateChannelsPlugin::slotSeparate() { KisImageSP image = m_view->image(); if (!image) return; KisLayerSP l = m_view->nodeManager()->activeLayer(); if (!l) return; KisPaintDeviceSP dev = l->paintDevice(); if (!dev) return; DlgSeparate * dlgSeparate = new DlgSeparate(dev->colorSpace()->name(), image->colorSpace()->name(), m_view->mainWindow(), "Separate"); Q_CHECK_PTR(dlgSeparate); dlgSeparate->setCaption(i18n("Separate Image")); // If we're 8-bits, disable the downscale option if (dev->pixelSize() == dev->channelCount()) { dlgSeparate->enableDownscale(false); } if (dlgSeparate->exec() == QDialog::Accepted) { QApplication::setOverrideCursor(Qt::BusyCursor); KisChannelSeparator separator(m_view); separator.separate(m_view->createUnthreadedUpdater(i18n("Separate Image")), dlgSeparate->getAlphaOptions(), dlgSeparate->getSource(), dlgSeparate->getOutput(), dlgSeparate->getDownscale(), dlgSeparate->getToColor()); QApplication::restoreOverrideCursor(); } delete dlgSeparate; } #include "kis_separate_channels_plugin.moc" diff --git a/plugins/extensions/separate_channels/kis_separate_channels_plugin.h b/plugins/extensions/separate_channels/kis_separate_channels_plugin.h index f9e9e2019e..0f8c4c65f8 100644 --- a/plugins/extensions/separate_channels/kis_separate_channels_plugin.h +++ b/plugins/extensions/separate_channels/kis_separate_channels_plugin.h @@ -1,39 +1,39 @@ /* * This file is part of Krita * * Copyright (c) Michael Thaler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _KIS_SEPARATE_CHANNELS_PLUGIN_H_ #define _KIS_SEPARATE_CHANNELS_PLUGIN_H_ #include -#include +#include -class KisSeparateChannelsPlugin : public KisViewPlugin +class KisSeparateChannelsPlugin : public KisActionPlugin { Q_OBJECT public: KisSeparateChannelsPlugin(QObject *parent, const QVariantList &); ~KisSeparateChannelsPlugin() override; private Q_SLOTS: void slotSeparate(); }; #endif diff --git a/plugins/extensions/shearimage/shearimage.cc b/plugins/extensions/shearimage/shearimage.cc index abdbd1239f..8976c880b2 100644 --- a/plugins/extensions/shearimage/shearimage.cc +++ b/plugins/extensions/shearimage/shearimage.cc @@ -1,89 +1,89 @@ /* * shearimage.cc -- Part of Krita * * Copyright (c) 2004 Michael Thaler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "shearimage.h" #include #include #include #include #include #include #include #include "dlg_shearimage.h" K_PLUGIN_FACTORY_WITH_JSON(ShearImageFactory, "kritashearimage.json", registerPlugin();) ShearImage::ShearImage(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("shearimage"); connect(action, SIGNAL(triggered()), this, SLOT(slotShearImage())); action = createAction("shearlayer"); connect(action, SIGNAL(triggered()), this, SLOT(slotShearLayer())); } ShearImage::~ShearImage() { } void ShearImage::slotShearImage() { KisImageWSP image = m_view->image(); if (!image) return; DlgShearImage * dlgShearImage = new DlgShearImage(m_view->mainWindow(), "ShearImage"); Q_CHECK_PTR(dlgShearImage); dlgShearImage->setCaption(i18n("Shear Image")); if (dlgShearImage->exec() == QDialog::Accepted) { qint32 angleX = dlgShearImage->angleX(); qint32 angleY = dlgShearImage->angleY(); m_view->imageManager()->shearCurrentImage(angleX, angleY); } delete dlgShearImage; } void ShearImage::slotShearLayer() { KisImageWSP image = m_view->image(); if (!image) return; DlgShearImage * dlgShearImage = new DlgShearImage(m_view->mainWindow(), "ShearLayer"); Q_CHECK_PTR(dlgShearImage); dlgShearImage->setCaption(i18n("Shear Layer")); if (dlgShearImage->exec() == QDialog::Accepted) { qint32 angleX = dlgShearImage->angleX(); qint32 angleY = dlgShearImage->angleY(); m_view->nodeManager()->shear(angleX, angleY); } delete dlgShearImage; } #include "shearimage.moc" diff --git a/plugins/extensions/shearimage/shearimage.h b/plugins/extensions/shearimage/shearimage.h index d9d1f8b5f8..4948724513 100644 --- a/plugins/extensions/shearimage/shearimage.h +++ b/plugins/extensions/shearimage/shearimage.h @@ -1,40 +1,40 @@ /* * shearimage.h -- Part of Krita * * Copyright (c) 2004 Michael Thaler (michael.thaler@physik.tu-muenchen.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SHEARIMAGE_H #define SHEARIMAGE_H #include -#include +#include -class ShearImage : public KisViewPlugin +class ShearImage : public KisActionPlugin { Q_OBJECT public: ShearImage(QObject *parent, const QVariantList &); ~ShearImage() override; private Q_SLOTS: void slotShearImage(); void slotShearLayer(); }; #endif // SHEARIMAGE_H diff --git a/plugins/extensions/waveletdecompose/waveletdecompose.cpp b/plugins/extensions/waveletdecompose/waveletdecompose.cpp index ce52f85e66..fe865334f8 100644 --- a/plugins/extensions/waveletdecompose/waveletdecompose.cpp +++ b/plugins/extensions/waveletdecompose/waveletdecompose.cpp @@ -1,158 +1,158 @@ /* * Copyright (C) 2016 Miroslav Talasek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "waveletdecompose.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dlg_waveletdecompose.h" #include "kis_node_manager.h" #include "kis_node_commands_adapter.h" #include "kis_undo_adapter.h" #include #include K_PLUGIN_FACTORY_WITH_JSON(WaveletDecomposeFactory, "kritawaveletdecompose.json", registerPlugin();) WaveletDecompose::WaveletDecompose(QObject *parent, const QVariantList &) - : KisViewPlugin(parent) + : KisActionPlugin(parent) { KisAction *action = createAction("waveletdecompose"); connect(action, SIGNAL(triggered()), this, SLOT(slotWaveletDecompose())); } WaveletDecompose::~WaveletDecompose() { } void WaveletDecompose::slotWaveletDecompose() { DlgWaveletDecompose dlg(m_view->mainWindow(), "WaveletDecompose"); if (dlg.exec() == QDialog::Accepted) { QApplication::setOverrideCursor(Qt::WaitCursor); QPointer updater = m_view->createUnthreadedUpdater(i18n("Wavelet Decompose")); KisImageSP image = m_view->image(); if (!image) return; if (!m_view->blockUntilOperationsFinished(image)) return; image->barrierLock(); KisPaintDeviceSP projection = new KisPaintDevice(*(image->projection()), false, 0); if (!projection) return; const KoColorSpace *cs = projection->colorSpace(); const KoCompositeOp* op = cs->compositeOp(COMPOSITE_GRAIN_EXTRACT); int scales = dlg.scales(); QList results; const QBitArray flags(0); QRect rc = image->bounds(); KisPaintDeviceSP original = projection; //main loop for(int level = 0; level < scales; ++level){ //copy original KisPaintDeviceSP blur = new KisPaintDevice(*original, false, 0); //blur it KisWaveletKernel::applyWavelet(blur, rc, 1 << level, 1 << level, flags, 0); //do grain extract blur from original KisPainter painter(original); painter.setCompositeOp(op); painter.bitBlt(0, 0, blur, 0, 0, rc.width(), rc.height()); painter.end(); //original is new scale and blur is new original results << original; original = blur; updater->setProgress((level * 100) / scales); } //add new layers KisUndoAdapter *undo = image->undoAdapter(); undo->beginMacro(kundo2_i18n("Wavelet decompose")); KisNodeCommandsAdapter adapter(m_view); KisGroupLayerSP baseGroup = image->rootLayer(); //add layer goup KisGroupLayerSP grp = new KisGroupLayer(image, i18n("Wavelet decompose"), OPACITY_OPAQUE_U8); adapter.addNode(grp, baseGroup, baseGroup->lastChild()); baseGroup = grp; //add scales int i = 1; const KoCompositeOp* op2 = cs->compositeOp(COMPOSITE_GRAIN_MERGE); Q_FOREACH (const KisPaintDeviceSP &l, results) { KisPaintLayerSP paintLayer = new KisPaintLayer(image, QStringLiteral("Scale %1").arg(i), OPACITY_OPAQUE_U8, l); adapter.addNode(paintLayer, baseGroup, 0); adapter.setCompositeOp(paintLayer, op2); ++i; } //add residual KisPaintLayerSP paintLayer = new KisPaintLayer(image, "Residual", OPACITY_OPAQUE_U8, original); adapter.addNode(paintLayer, baseGroup, 0); undo->endMacro(); updater->setProgress(100); image->unlock(); image->setModified(); } QApplication::restoreOverrideCursor(); } #include "waveletdecompose.moc" diff --git a/plugins/extensions/waveletdecompose/waveletdecompose.h b/plugins/extensions/waveletdecompose/waveletdecompose.h index 9456ca7044..e9aa86159d 100644 --- a/plugins/extensions/waveletdecompose/waveletdecompose.h +++ b/plugins/extensions/waveletdecompose/waveletdecompose.h @@ -1,40 +1,40 @@ /* * Copyright (C) 2016 Miroslav Talasek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef WAVELETDECOMPOSE_H #define WAVELETDECOMPOSE_H #include #include -#include +#include -class WaveletDecompose : public KisViewPlugin +class WaveletDecompose : public KisActionPlugin { Q_OBJECT public: WaveletDecompose(QObject *parent, const QVariantList &); ~WaveletDecompose() override; private Q_SLOTS: void slotWaveletDecompose(); }; #endif // WAVELETDECOMPOSE_H