[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/krita-scripting-rempt] /: Merge branch 'master' into krita-scripting-rempt
From:       Cyrille Berger <cberger () cberger ! net>
Date:       2015-05-02 14:07:14
Message-ID: E1YoY4Y-0000JB-Lp () scm ! kde ! org
[Download RAW message or body]

Git commit bbff7db6bf4c18e790d85d8d6d9165af81b876d2 by Cyrille Berger.
Committed on 02/05/2015 at 14:05.
Pushed by berger into branch 'krita-scripting-rempt'.

Merge branch 'master' into krita-scripting-rempt

Conflicts:
	krita/krita.rc
	krita/plugins/extensions/CMakeLists.txt
	krita/ui/CMakeLists.txt
	krita/ui/KisViewManager.h
	krita/ui/kis_action.h
	krita/ui/kis_view2.cpp

M  +308  -189  krita/krita.rc
M  +2    -6    krita/plugins/extensions/CMakeLists.txt
M  +132  -31   krita/ui/CMakeLists.txt
M  +1299 -0    krita/ui/KisViewManager.cpp
M  +252  -0    krita/ui/KisViewManager.h
A  +3    -3    krita/ui/kis_script_manager.cpp     [License: LGPL (v2+)]
A  +2    -2    krita/ui/kis_script_manager.h     [License: LGPL (v2+)]
M  +46   -28   libs/main/KoMainWindow.cpp

http://commits.kde.org/calligra/bbff7db6bf4c18e790d85d8d6d9165af81b876d2

diff --cc krita/krita.rc
index b5b636e,fcaa55e..1f756a1
--- a/krita/krita.rc
+++ b/krita/krita.rc
@@@ -1,195 -1,311 +1,314 @@@
  <?xml version="1.0"?>
- <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
- <kpartgui name="Krita" version="53">
+ <kpartgui xmlns="http://www.kde.org/standards/kxmlgui/1.0" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Krita" version="66" \
xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0      \
http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd"> +   <MenuBar>
+     <Menu name="file" noMerge="1">
+       <text>&amp;File</text>
+       <Action name="file_new"/>
+       <Action name="file_open"/>
+       <Action name="file_open_recent"/>
+       <Separator/>
+       <Action name="file_save"/>
+       <Action name="file_save_as"/>
+       <Action name="file_reload_file"/>
+       <Separator/>
+       <Action name="file_import_file"/>
+       <Action name="file_export_file"/>
+       <Action name="file_export_pdf"/>
+       <Separator/>
+       <Action name="save_incremental_version"/>
+       <Action name="save_incremental_backup"/>
+       <Action name="create_template"/>
+       <Separator/>
+       <Action name="file_print"/>
+       <Action name="file_print_preview"/>
+       <Separator/>
+       <Action name="file_documentinfo"/>
+       <Separator/>
+       <Action name="file_close"/>
+       <Action name="file_close_all"/>
+       <Action name="file_quit"/>
+     </Menu>
+     <Menu name="edit">
+       <text>&amp;Edit</text>
+       <Action name="edit_undo"/>
+       <Action name="edit_redo"/>
+       <Separator/>
+       <Action name="edit_cut"/>
+       <Action name="edit_copy"/>
+       <Action name="copy_merged"/>
+       <Action name="cut_sharp"/>
+       <Action name="copy_sharp"/>
+       <Action name="edit_paste"/>
+       <Action name="paste_new"/>
+       <Action name="clear"/>
+       <Action name="fill_selection_foreground_color"/>
+       <Action name="fill_selection_background_color"/>
+       <Action name="fill_selection_pattern"/>
+       <Action name="stroke_shapes"/>
+       <Action name="delete"/>
+       <Separator/>
+       <Action name="revert"/>
+     </Menu>
+     <Menu name="view">
+       <text>&amp;View</text>
+       <Action name="view_show_just_the_canvas"/>
+       <Action name="fullscreen"/>
+       <Action name="mirror_canvas"/>
+       <Action name="wrap_around_mode"/>
+       <Separator/>
+       <Action name="zoom"/>
+       <Action name="zoom_in"/>
+       <Action name="zoom_out"/>
+       <Action name="actual_pixels"/>
+       <Action name="actual_size"/>
+       <Action name="fit_to_canvas"/>
+       <Separator/>
+       <Action name="view_ruler"/>
+       <Action name="view_guidelines"/>
+       <!--Action name="view_show_guides"/-->
+       <Action name="showStatusBar" />
+       <Separator/>
+       <Action name="view_grid"/>
+       <!--Action name="view_snap_to_grid"/-->
+       <Menu name="view_fast_grid_config">
+         <text>Grid Spacing</text>
+         <Action name="view_fast_grid_1x1"/>
+         <Action name="view_fast_grid_2x2"/>
+         <Action name="view_fast_grid_5x5"/>
+         <Action name="view_fast_grid_10x10"/>
+         <Action name="view_fast_grid_20x20"/>
+         <Action name="view_fast_grid_40x40"/>
+       </Menu>
+       <Separator/>
+       <Action name="view_toggle_perspective_grid"/>
+       <Action name="view_clear_perspective_grid"/>
+       <Separator/>
+       <Action name="view_toggle_painting_assistants"/>
+       <Action name="view_toggle_assistant_previews"/>
+       <Separator/>
+       <Action name="view_palette_action_menu"/>
+       <Separator/>
+       <Action name="refresh_canvas"/>
+     </Menu>
+     <Menu name="Image">
+       <text>&amp;Image</text>
+       <Action name="image_properties"/>
+       <Action name="image_color"/>
+       <Action name="imagecolorspaceconversion"/>
+       <Action name="duplicate_image"/>
+       <Separator/>
+       <Action name="resizeimagetolayer"/>
+       <Action name="resizeimagetoselection"/>
+       <Separator/>
+       <Menu name="Rotate">
+         <text>&amp;Rotate</text>
+         <Action name="rotateimage"/>
+         <Separator/>
+         <Action name="rotateImageCW90"/>
+         <Action name="rotateImageCCW90"/>
+         <Action name="rotateImage180"/>
+       </Menu>
+       <Action name="shearimage"/>
+       <Separator/>
+       <Action name="mirrorImageHorizontal"/>
+       <Action name="mirrorImageVertical"/>
+       <Separator/>
+       <Action name="imagesize"/>
+       <Action name="offsetimage"/>
+       <Action name="imageresolution"/>
+       <Action name="canvassize"/>
+       <Separator/>
+       <Action name="imagesplit"/>
+       <Action name="separate"/>
+     </Menu>
+     <Menu name="Layer">
+       <text>&amp;Layer</text>
+       <Menu name="LayerNew">
+         <text>New</text>
+         <Action name="add_new_paint_layer"/>
+         <Action name="duplicatelayer"/>
+         <Separator/>
+         <Action name="cut_selection_to_new_layer"/>
+         <Action name="copy_selection_to_new_layer"/>
+       </Menu>
+       <Menu name="LayerImportExport">
+         <text>&amp;Import/Export</text>
+         <Action name="save_node_as_image"/>
+         <Action name="save_groups_as_images"/>
+         <Separator/>
+         <Action name="import_layer_from_file"/>
+         <Menu name="LayerImportAs">
+           <text>Import</text>
+           <Action name="import_layer_as_paint_layer"/>
+           <Action name="import_layer_as_transparency_mask"/>
+           <Action name="import_layer_as_filter_mask"/>
+           <Action name="import_layer_as_selection_mask"/>
+         </Menu>
+       </Menu>
+       <Menu name="LayerConvert">
+         <text>&amp;Convert</text>
+         <Action name="convert_to_paint_layer"/>
+         <Action name="convert_to_transparency_mask"/>
+         <Action name="convert_to_filter_mask"/>
+         <Action name="convert_to_selection_mask"/>
+       </Menu>
+       <Separator/>
+       <Menu name="LayerSplitAlpha">
+         <text>S&amp;plit Alpha</text>
+         <Action name="split_alpha_into_mask"/>
+         <Action name="split_alpha_write"/>
+         <Action name="split_alpha_save_merged"/>
+       </Menu>
+       <Action name="layersplit"/>
+       <Separator/>
+       <Action name="mirrorNodeX"/>
+       <Action name="mirrorNodeY"/>
+       <Menu name="Rotate">
+         <text>&amp;Rotate</text>
+         <Action name="rotatelayer"/>
+         <Separator/>
+         <Action name="rotateLayerCW90"/>
+         <Action name="rotateLayerCCW90"/>
+         <Action name="rotateLayer180"/>
+       </Menu>
+       <Action name="layersize"/>
+       <Action name="shearlayer"/>
+       <Action name="offsetlayer"/>
+       <Action name="clones_array"/>
+       <Separator/>
+       <Action name="EditLayerMetaData"/>
+       <Action name="histogram"/>
+       <Action name="layercolorspaceconversion"/>
+       <Separator/>
+       <Action name="merge_layer"/>
+       <Action name="flatten_layer"/>
+       <Action name="rasterize_layer"/>
+       <Action name="merge_all_shape_layers"/>
+       <Action name="flatten_image"/>
+       <Action name="merge_selected_layers"/>
+       <Action name="layer_style"/>
+       <Separator/>
+       <Action name="dropshadow"/>
+     </Menu>
+     <Menu name="Select">
+       <text>&amp;Select</text>
+       <Action name="select_all"/>
+       <Action name="deselect"/>
+       <Action name="reselect"/>
+       <Action name="invert"/>
+       <Action name="convert_to_vector_selection"/>
+       <Action name="convert_shapes_to_vector_selection"/>
+       <Separator/>
+       <Action name="feather"/>
+       <Action name="similar"/>
+       <Separator/>
+       <Action name="toggle_display_selection"/>
+       <Action name="show-global-selection-mask"/>
+       <Action name="selectionscale"/>
+       <Separator/>
+       <Action name="colorrange"/>
+       <Action name="selectopaque"/>
+       <Separator/>
+       <Action name="featherselection"/>
+       <Action name="growselection"/>
+       <Action name="shrinkselection"/>
+       <Action name="borderselection"/>
+       <Action name="smoothselection"/>
+     </Menu>
+     <Menu name="Filter">
+       <text>Filte&amp;r</text>
+       <Action name="filter_apply_again"/>
+       <Action name="filter_gallery"/>
+       <Separator/>
+       <Action name="adjust_filters"/>
+       <Action name="artistic_filters"/>
+       <Action name="blur_filters"/>
+       <Action name="color_filters"/>
+       <Action name="decor_filters"/>
+       <Action name="edge_filters"/>
+       <Action name="enhance_filters"/>
+       <Action name="emboss_filters"/>     
+       <Action name="map_filters"/>
+       <Action name="nonphotorealistic_filters"/>
+       <Action name="other_filters"/>
+       <Separator/>
+       <Action name="gmic"/>
  
- <MenuBar>
-  <Menu name="file"><text>&amp;File</text>
-   <Separator/>
-   <Action name="save_incremental_version"/>
-   <Action name="save_incremental_backup"/>
-   <Action name="createTemplate"/>
-  </Menu>
- 
-  <Menu name="Edit"><text>&amp;Edit</text>
-   <Action name="edit_undo"/>
-   <Action name="edit_redo"/>
-   <Separator/>
-   <Action name="edit_cut"/>
-   <Action name="edit_copy"/>
-   <Action name="copy_merged"/>
-   <Action name="edit_paste"/>
-   <Action name="paste_new"/>
-   <Action name="clear"/>
-   <Action name="fill_selection_foreground_color"/>
-   <Action name="fill_selection_background_color"/>
-   <Action name="fill_selection_pattern"/>
-   <Action name="stroke_shapes"/>
-   <Action name="delete"/>
-   <Separator/>
-   <Action name="revert"/>
-   <Separator/>
-   <Menu name="Resources"><text>&amp;Resources</text>
-    <Action name="open_resources_directory"/>
-    <Separator/>
-    <Action name="add_palette"/>
-    <Action name="edit_palette"/>
-    <Action name="edit_blacklist_cleanup"/>
-   </Menu>
-  </Menu>
- 
-  <Menu name="View"><text>&amp;View</text>
-   <Action name="view_show_just_the_canvas"/>
-   <Action name="view_fullscreen"/>
-   <Action name="mirror_canvas"/>
-   <Action name="wrap_around_mode"/>
-   <Separator/>
-   <Action name="view_newview"/>    
-   <Separator/>      
-   <Action name="zoom"/>
-   <Action name="zoom_in"/>
-   <Action name="zoom_out"/>
-   <Action name="actual_pixels"/>
-   <Action name="actual_size"/>
-   <Action name="fit_to_canvas"/>
-   <Separator/>
-   <Action name="view_ruler"/>
-   <Action name="view_guidelines"/>
-   <Separator/>
-   <Action name="view_grid"/>
-   <Action name="view_snap_to_grid"/>
-   <Menu name="view_fast_grid_config"><text>Grid Spacing</text>
-    <Action name="view_fast_grid_1x1"/>
-    <Action name="view_fast_grid_2x2"/>
-    <Action name="view_fast_grid_5x5"/>
-    <Action name="view_fast_grid_10x10"/>
-    <Action name="view_fast_grid_20x20"/>
-    <Action name="view_fast_grid_40x40"/>
-   </Menu>
-   <Separator/>
-   <Action name="view_toggle_perspective_grid"/>
-   <Action name="view_clear_perspective_grid"/>
-   <Separator/>
-   <Action name="view_toggle_painting_assistants"/>
-   <Separator/>
-   <Action name="view_palette_action_menu"/>
-   <Separator/>
-   <Action name="refresh_canvas"/>
-  </Menu>
- 
- 
- <Menu name="Image"><text>&amp;Image</text>
-   <Action name="image_properties"/>
-   <Action name="duplicate_image"/>
-   <Separator/>
-   <DefineGroup name="canvas_resize_merge" append="canvas_resize_merge"/>
-   <Action name="resizeimagetolayer"/>
-   <Action name="resizeimagetoselection"/>
-   <Separator/>
-   <DefineGroup name="image_transform_merge" append="image_transform_merge"/>
- </Menu>
- 
- <Menu name="Layer"><text>&amp;Layer</text>
-   <Menu name="LayerNew"><text>New</text>
-     <Action name="add_new_paint_layer"/>
-     <Action name="duplicatelayer"/>
+     </Menu>
+     <Menu name="tools">
+       <text>&amp;Tools</text>
+       <Menu name="Recording">
+         <text>Recording</text>
+         <Action name="Recording_Start_Recording_Macro"/>
+         <Action name="Recording_Stop_Recording_Macro"/>
+       </Menu>
+       <Menu name="Macros">
+         <text>Macros</text>
+         <Action name="Macro_Open_Play"/>
+         <Action name="Macro_Open_Edit"/>
+       </Menu>
+     </Menu>
++    
++    <Action name="scripts"/>
++    
+     <Menu name="settings">
+       <text>Setti&amp;ngs</text>
+       <Action name="options_configure_toolbars"/>
+       <Merge name="StandardToolBarMenuHandler" />
+       <Separator/>
+       <Action name="view_toggledockers"/>
+       <Action name="view_toggledockertitlebars"/>
+       <Action name="settings_dockers_menu"/>
+       <Separator/>
+       <Action name="theme_menu"/> 
+       <Separator/>    
+       <Action name="options_configure_keybinding"/>
+       <Action name="options_configure"/>        
+       <Separator/>    
+       <Action name="manage_bundles"/> 
+       <Action name="switch_application_language"/>    
+       <Separator/>
+     </Menu>
+     <Action name="window"/>
      <Separator/>
-     <Action name="import_layer_from_file"/>
+     <Menu name="help">
+       <text>&amp;Help</text>
+       <Action name="help_contents"/>
+       <Action name="help_whats_this"/>
+       <Separator/>
+       <MergeLocal/>
+       <Action name="help_show_tip"/>
+       <Separator/>
+       <Action name="help_report_bug"/>
+       <Separator/>
+       <Action name="help_about_app"/>
+       <Action name="help_about_kde"/>
+     </Menu>
+   </MenuBar>
+   <ToolBar name="mainToolBar" fullWidth="false" noMerge="1">
+     <Text>File</Text>
+     <Action name="file_new"/>
+     <Action name="file_open"/>
+     <Action name="file_save"/>
+     <!--Separator/>
+     <Action name="edit_undo"/>
+     <Action name="edit_redo"/-->
+   </ToolBar>
+   <ToolBar name="BrushesAndStuff" position="top">
+     <Text>Brushes and Stuff</Text>
+     <Action name="gradients"/>
+     <Action name="patterns"/>
      <Separator/>
-     <Action name="cut_selection_to_new_layer"/>
-     <Action name="copy_selection_to_new_layer"/>
-   </Menu>
-   <Menu name="LayerConvert"><text>Convert</text>
-     <Action name="convert_to_paint_layer"/>
-     <Action name="convert_to_transparency_mask"/>
-     <Action name="convert_to_filter_mask"/>
-     <Action name="convert_to_selection_mask"/>
-   </Menu>
-   <Action name="resizelayertoowner"/>
-   <Separator/>
-   <Action name="save_node_as_image"/>
-   <Action name="save_groups_as_images"/>
-   <Action name="layer_to_image"/>
-   <Separator/>
-   <Action name="mirrorNodeX"/>
-   <Action name="mirrorNodeY"/>
-   <DefineGroup name="layer_transform_merge" append="layer_transform_merge"/>
-   <Separator/>
-   <DefineGroup name="layer_properties_merge"/>
-   <Separator/>
-   <Action name="merge_layer"/>
-   <Action name="flatten_layer"/>
-   <Action name="rasterize_layer"/>
-   <Action name="merge_all_shape_layers"/>
-   <Action name="flatten_image"/>
-   <Action name="merge_selected_layers"/>
- </Menu>
- 
- <Menu name="Select"><text>&amp;Select</text>
-     <Action name="select_all"/>
-     <Action name="deselect"/>
-     <Action name="reselect"/>
-     <Action name="invert"/>
-     <Action name="convert_to_vector_selection"/>
-     <Action name="convert_shapes_to_vector_selection"/>
+     <Action name="dual"/>
      <Separator/>
-     <Action name="feather"/>
-     <Action name="similar"/>
-    <Separator/>
-    <Action name="toggle_display_selection"/>
-    <Action name="show-global-selection-mask"/>
- </Menu>
- 
- <Menu name="Filter"><text>Filte&amp;r</text>
- 	<Action name="filter_apply_again"/>
- 	<Action name="filter_gallery"/>
- 	<Separator/>
-     <Action name="adjust_filters"/>
- 	<Action name="artistic_filters"/>
- 	<Action name="blur_filters"/>
- 	<Action name="color_filters"/>
- 	<Action name="decor_filters"/>
- 	<Action name="edge_filters"/>
- 	<Action name="enhance_filters"/>
- 	<Action name="emboss_filters"/>
-     <Action name="map_filters"/>
-     <Action name="nonphotorealistic_filters"/>
- 	<Action name="other_filters"/>
- </Menu>
- 
- <Menu name="Tools"><text>&amp;Tools</text>
- </Menu>
- 
- <Action name="scripts"/>
- 
- <Menu name="settings"><text>Settings</text>
-   <!--Action name="view_fullscreen" group="settings_show"/-->
-   <Action name="view_toggledockers" group="settings_show"/>
-   <Action name="showStatusBar" group="settings_show"/>
-   <Action name="settings_active_author" group="settings_configure"/>
-   <Action name="preferences" group="settings_configure"/>
-   <Action name="theme_menu"/>
-   <Action name="palette_manager"/>
- </Menu>
- 
- </MenuBar>
- 
- <ToolBar name="BrushesAndStuff" position="top">
-      <Text>Brushes and Stuff</Text>
-      <Action name="gradients"/>
-      <Action name="patterns"/>
-      <Separator/>
-      <Action name="dual"/>
-      <Separator/>
-      <Action name="paintops"/>
-      <Action name="paintop_options"/>
-      <Action name="composite_actions"/>
-      <Separator/>
-      <Action name="brushslider1"/>
-      <Action name="brushslider2"/>
-      <Separator/>
-      <Action name="mirror_actions"/>
-      <Separator/>
-      <Action name="workspaces"/>
- </ToolBar>
- 
+     <Action name="paintops"/>
+     <Action name="paintop_options"/>
+     <Action name="composite_actions"/>
+     <Action name="brushslider1"/>
+     <Action name="brushslider2"/>
+     <Separator/>
+     <Action name="mirror_actions"/>
+     <Action name="expanding_spacer_1"/>
+     <Action name="workspaces"/>
+   </ToolBar>
  </kpartgui>
diff --cc krita/plugins/extensions/CMakeLists.txt
index 2593d80,9846da7..ffe01d9
--- a/krita/plugins/extensions/CMakeLists.txt
+++ b/krita/plugins/extensions/CMakeLists.txt
@@@ -14,12 -13,8 +13,9 @@@ add_subdirectory( separate_channels 
  add_subdirectory( shearimage )
  add_subdirectory( dockers )
  add_subdirectory( layergroupswitcher )
 +add_subdirectory( pykrita )
- 
- option(WITH_RESOURCE_MANAGER "Build the experimental resource manager" OFF)
- if (WITH_RESOURCE_MANAGER)
-     add_subdirectory( resourcemanager )
- endif()
+ add_subdirectory( resourcemanager )
+ add_subdirectory( layersplit )
  
  # Allow to skip building GMIC plugin
  option(WITH_GMIC "Build the G'Mic plugin" ON)
diff --cc krita/ui/CMakeLists.txt
index 41db934,b7b0825..b08bb47
--- a/krita/ui/CMakeLists.txt
+++ b/krita/ui/CMakeLists.txt
@@@ -113,9 -121,6 +121,7 @@@ set(kritaui_LIB_SRC
      kis_popup_palette.cpp
      kis_png_converter.cpp
      kis_preference_set_registry.cpp
-     kis_print_job.cpp
 +    kis_script_manager.cpp
      kis_resource_server_provider.cpp
      kis_selection_decoration.cc
      kis_selection_manager.cc
diff --cc krita/ui/KisViewManager.cpp
index 0000000,2890a3f6..c0bba70
mode 000000,100644..100644
--- a/krita/ui/KisViewManager.cpp
+++ b/krita/ui/KisViewManager.cpp
@@@ -1,0 -1,1287 +1,1299 @@@
+ /*
+  *  This file is part of KimageShop^WKrayon^WKrita
+  *
+  *  Copyright (c) 1999 Matthias Elter  <me@kde.org>
+  *                1999 Michael Koch    <koch@kde.org>
+  *                1999 Carsten Pfeiffer <pfeiffer@kde.org>
+  *                2002 Patrick Julien <freak@codepimps.org>
+  *                2003-2011 Boudewijn Rempt <boud@valdyas.org>
+  *                2004 Clarence Dang <dang@kde.org>
+  *                2011 José Luis Vergara <pentalis@gmail.com>
+  *
+  *  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 <stdio.h>
+ 
+ #include "KisViewManager.h"
+ #include <QPrinter>
+ 
+ #include <QDesktopServices>
+ #include <QDesktopWidget>
+ #include <QGridLayout>
+ #include <QRect>
+ #include <QWidget>
+ #include <QToolBar>
+ #include <QApplication>
+ #include <QPrintDialog>
+ #include <QObject>
+ #include <QByteArray>
+ #include <QBuffer>
+ #include <QScrollBar>
+ #include <QMainWindow>
+ #include <QPoint>
+ 
+ #include <kactioncollection.h>
+ #include <kaction.h>
+ #include <kio/netaccess.h>
+ #include <klocale.h>
+ #include <kmenubar.h>
+ #include <kmenu.h>
+ #include <QMessageBox>
+ #include <KoServiceLocator.h>
+ #include <kservice.h>
+ #include <kstandarddirs.h>
+ #include <kstatusbar.h>
+ #include <kurl.h>
+ #include <kxmlguifactory.h>
+ 
+ #include <KoCanvasController.h>
+ #include <KoCompositeOp.h>
+ #include <KoDockRegistry.h>
+ #include <KoDockWidgetTitleBar.h>
+ #include <KoProperties.h>
+ #include <KoResourceItemChooserSync.h>
+ #include <KoResourceServerProvider.h>
+ #include <KoSelection.h>
+ #include <KoStore.h>
+ #include <KoToolManager.h>
+ #include <KoToolRegistry.h>
+ #include <KoViewConverter.h>
+ #include <KoZoomHandler.h>
+ #include <KoPluginLoader.h>
+ 
+ #include "input/kis_input_manager.h"
+ #include "canvas/kis_canvas2.h"
+ #include "canvas/kis_canvas_controller.h"
+ #include "canvas/kis_grid_manager.h"
+ #include "canvas/kis_perspective_grid_manager.h"
+ #include "dialogs/kis_dlg_blacklist_cleanup.h"
+ #include "input/kis_input_profile_manager.h"
+ #include "kis_action_manager.h"
+ #include "kis_action.h"
+ #include "kis_canvas_controls_manager.h"
+ #include "kis_canvas_resource_provider.h"
+ #include "kis_composite_progress_proxy.h"
+ #include "kis_config.h"
+ #include "kis_config_notifier.h"
+ #include "kis_control_frame.h"
+ #include "kis_coordinates_converter.h"
+ #include <KisDocumentEntry.h>
+ #include "KisDocument.h"
+ #include "kis_factory2.h"
+ #include "kis_favorite_resource_manager.h"
+ #include "kis_filter_manager.h"
+ #include "kis_group_layer.h"
+ #include <kis_image.h>
+ #include "kis_image_manager.h"
+ #include <kis_layer.h>
+ #include "KisMainWindow.h"
+ #include "kis_mainwindow_observer.h"
+ #include "kis_mask_manager.h"
+ #include "kis_mimedata.h"
+ #include "kis_mirror_manager.h"
+ #include "kis_node_commands_adapter.h"
+ #include "kis_node.h"
+ #include "kis_node_manager.h"
+ #include "kis_painting_assistants_manager.h"
+ #include <kis_paint_layer.h>
+ #include "kis_paintop_box.h"
+ #include <kis_paintop_preset.h>
+ #include "KisPart.h"
+ #include "KisPrintJob.h"
+ #include "kis_progress_widget.h"
+ #include "kis_resource_server_provider.h"
+ #include "kis_selection.h"
+ #include "kis_selection_manager.h"
+ #include "kis_shape_controller.h"
+ #include "kis_shape_layer.h"
+ #include <kis_signal_compressor.h>
+ #include "kis_statusbar.h"
+ #include <KisTemplateCreateDia.h>
+ #include <kis_tool_freehand.h>
+ #include "kis_tooltip_manager.h"
+ #include <kis_undo_adapter.h>
+ #include "KisView.h"
+ #include "kis_zoom_manager.h"
+ #include "kra/kis_kra_loader.h"
+ #include "widgets/kis_floating_message.h"
+ #include "kis_signal_auto_connection.h"
++#include "kis_script_manager.h"
+ 
+ 
+ class StatusBarItem
+ {
+ public:
+     StatusBarItem() // for QValueList
+         : m_widget(0),
+           m_connected(false),
+           m_hidden(false) {}
+ 
+     StatusBarItem(QWidget * widget, int stretch, bool permanent)
+         : m_widget(widget),
+           m_stretch(stretch),
+           m_permanent(permanent),
+           m_connected(false),
+           m_hidden(false) {}
+ 
+     bool operator==(const StatusBarItem& rhs) {
+         return m_widget == rhs.m_widget;
+     }
+ 
+     bool operator!=(const StatusBarItem& rhs) {
+         return m_widget != rhs.m_widget;
+     }
+ 
+     QWidget * widget() const {
+         return m_widget;
+     }
+ 
+     void ensureItemShown(KStatusBar * sb) {
+         Q_ASSERT(m_widget);
+         if (!m_connected) {
+             if (m_permanent)
+                 sb->addPermanentWidget(m_widget, m_stretch);
+             else
+                 sb->addWidget(m_widget, m_stretch);
+ 
+             if(!m_hidden)
+                 m_widget->show();
+ 
+             m_connected = true;
+         }
+     }
+     void ensureItemHidden(KStatusBar * sb) {
+         if (m_connected) {
+             m_hidden = m_widget->isHidden();
+             sb->removeWidget(m_widget);
+             m_widget->hide();
+             m_connected = false;
+         }
+     }
+ private:
+     QWidget * m_widget;
+     int m_stretch;
+     bool m_permanent;
+     bool m_connected;
+     bool m_hidden;
+ };
+ 
+ class BlockingUserInputEventFilter : public QObject
+ {
+     bool eventFilter(QObject *watched, QEvent *event)
+     {
+         Q_UNUSED(watched);
+         if(dynamic_cast<QWheelEvent*>(event)
+                 || dynamic_cast<QKeyEvent*>(event)
+                 || dynamic_cast<QMouseEvent*>(event)) {
+             return true;
+         }
+         else {
+             return false;
+         }
+     }
+ };
+ 
+ class KisViewManager::KisViewManagerPrivate
+ {
+ 
+ public:
+ 
+     KisViewManagerPrivate()
+         : filterManager(0)
+         , statusBar(0)
+         , createTemplate(0)
+         , saveIncremental(0)
+         , saveIncrementalBackup(0)
+         , openResourcesDirectory(0)
+         , rotateCanvasRight(0)
+         , rotateCanvasLeft(0)
+         , wrapAroundAction(0)
+         , showRulersAction(0)
+         , zoomTo100pct(0)
+         , showGuidesAction(0)
+         , selectionManager(0)
+         , controlFrame(0)
+         , nodeManager(0)
+         , imageManager(0)
+         , gridManager(0)
+         , perspectiveGridManager(0)
+         , paintingAssistantsManager(0)
+         , actionManager(0)
+         , mainWindow(0)
+         , showFloatingMessage(true)
+         , currentImageView(0)
+         , canvasResourceProvider(0)
+         , canvasResourceManager(0)
+         , guiUpdateCompressor(0)
+         , actionCollection(0)
+         , mirrorManager(0)
++        , scriptManager(0)
+     {
+     }
+ 
+     ~KisViewManagerPrivate() {
+         delete filterManager;
+         delete selectionManager;
+         delete nodeManager;
+         delete imageManager;
+         delete gridManager;
+         delete perspectiveGridManager;
+         delete paintingAssistantsManager;
+         delete statusBar;
+         delete actionManager;
+         delete canvasControlsManager;
+         delete canvasResourceProvider;
+         delete canvasResourceManager;
+         delete mirrorManager;
++        delete scriptManager;
+     }
+ 
+ public:
+     KisFilterManager *filterManager;
+     KisStatusBar *statusBar;
+     KisAction *createTemplate;
+     KisAction *saveIncremental;
+     KisAction *saveIncrementalBackup;
+     KisAction *openResourcesDirectory;
+     KisAction *rotateCanvasRight;
+     KisAction *rotateCanvasLeft;
+     KisAction *wrapAroundAction;
+     KisAction *showRulersAction;
+     KisAction *zoomTo100pct;
+     KisAction *showGuidesAction;
+ 
+     KisSelectionManager *selectionManager;
+     KisControlFrame *controlFrame;
+     KisNodeManager *nodeManager;
+     KisImageManager *imageManager;
+     KisGridManager *gridManager;
+     KisCanvasControlsManager *canvasControlsManager;
+     KisPerspectiveGridManager * perspectiveGridManager;
+     KisPaintingAssistantsManager *paintingAssistantsManager;
+     BlockingUserInputEventFilter blockingEventFilter;
+     KisActionManager* actionManager;
+     QMainWindow* mainWindow;
+     QPointer<KisFloatingMessage> savedFloatingMessage;
+     bool showFloatingMessage;
+     QPointer<KisView> currentImageView;
+     KisCanvasResourceProvider* canvasResourceProvider;
+     KoCanvasResourceManager* canvasResourceManager;
+     QList<StatusBarItem> statusBarItems;
+     KisSignalCompressor* guiUpdateCompressor;
+     KActionCollection *actionCollection;
+     KisMirrorManager *mirrorManager;
+     QPointer<KisInputManager> inputManager;
+ 
+     KisSignalAutoConnectionsStore viewConnections;
++    KisScriptManager *scriptManager;
+ };
+ 
+ 
+ KisViewManager::KisViewManager(QWidget *parent, KActionCollection *_actionCollection)
+     : d(new KisViewManagerPrivate())
+ {
+     d->actionCollection = _actionCollection;
+     d->actionManager = new KisActionManager(this);
+     d->mainWindow = dynamic_cast<QMainWindow*>(parent);
+ 
+     d->canvasResourceProvider = new KisCanvasResourceProvider(this);
+     d->canvasResourceManager = new KoCanvasResourceManager();
+     d->canvasResourceProvider->setResourceManager(d->canvasResourceManager);
+ 
+     d->guiUpdateCompressor = new KisSignalCompressor(30, KisSignalCompressor::POSTPONE, \
this); +     connect(d->guiUpdateCompressor, SIGNAL(timeout()), this, \
SLOT(guiUpdateTimeout())); + 
+     createActions();
+     createManagers();
+ 
+     d->controlFrame = new KisControlFrame(this, parent);
+ 
+     //Check to draw scrollbars after "Canvas only mode" toggle is created.
+     this->showHideScrollbars();
+ 
+     KoCanvasController *dummy = new KoDummyCanvasController(actionCollection());
+     KoToolManager::instance()->registerTools(actionCollection(), dummy);
+ 
+     d->statusBar = new KisStatusBar(this);
+     QTimer::singleShot(0, this, SLOT(makeStatusBarVisible()));
+ 
+     connect(KoToolManager::instance(), SIGNAL(inputDeviceChanged(KoInputDevice)),
+             d->controlFrame->paintopBox(), SLOT(slotInputDeviceChanged(KoInputDevice)));
+ 
+     connect(KoToolManager::instance(), SIGNAL(changedTool(KoCanvasController*,int)),
+             d->controlFrame->paintopBox(), SLOT(slotToolChanged(KoCanvasController*,int)));
+ 
+     connect(d->nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)),
+             resourceProvider(), SLOT(slotNodeActivated(KisNodeSP)));
+ 
+     connect(resourceProvider()->resourceManager(), \
SIGNAL(canvasResourceChanged(int,QVariant)), +             d->controlFrame->paintopBox(), \
SLOT(slotCanvasResourceChanged(int,QVariant))); + 
+     connect(KisPart::instance(), SIGNAL(sigViewAdded(KisView*)), \
SLOT(slotViewAdded(KisView*))); +     connect(KisPart::instance(), \
SIGNAL(sigViewRemoved(KisView*)), SLOT(slotViewRemoved(KisView*))); + 
+     KisInputProfileManager::instance()->loadProfiles();
+ 
+     KisConfig cfg;
+     d->showFloatingMessage = cfg.showCanvasMessages();
+ 
+ }
+ 
+ 
+ KisViewManager::~KisViewManager()
+ {
+     KisConfig cfg;
+     if (resourceProvider() && resourceProvider()->currentPreset()) {
+         cfg.writeEntry("LastPreset", resourceProvider()->currentPreset()->name());
+     }
+     cfg.writeEntry("baseLength", KoResourceItemChooserSync::instance()->baseLength());
+ 
+     if (d->filterManager->isStrokeRunning()) {
+         d->filterManager->cancel();
+     }
+     delete d;
+ }
+ 
+ KActionCollection *KisViewManager::actionCollection() const
+ {
+     return d->actionCollection;
+ }
+ 
+ void KisViewManager::slotViewAdded(KisView *view)
+ {
+     d->inputManager->addTrackedCanvas(view->canvasBase());
+ }
+ 
+ void KisViewManager::slotViewRemoved(KisView *view)
+ {
+     d->inputManager->removeTrackedCanvas(view->canvasBase());
+ }
+ 
+ void KisViewManager::setCurrentView(KisView *view)
+ {
+     bool first = true;
+     if (d->currentImageView) {
+         d->currentImageView->canvasBase()->setCursor(QCursor(Qt::ArrowCursor));
+         first = false;
+         KisDocument* doc = d->currentImageView->document();
+         if (doc) {
+             doc->disconnect(this);
+         }
+         d->currentImageView->canvasController()->proxyObject->disconnect(d->statusBar);
+         d->viewConnections.clear();
+     }
+ 
+     QPointer<KisView>imageView = qobject_cast<KisView*>(view);
+ 
+     if (imageView) {
+         d->viewConnections.addUniqueConnection(resourceProvider(), \
SIGNAL(sigDisplayProfileChanged(const KoColorProfile*)), imageView->canvasBase(), \
SLOT(slotSetDisplayProfile(const KoColorProfile*))); +         \
resourceProvider()->resetDisplayProfile(QApplication::desktop()->screenNumber(mainWindow())); + \
 +         // Wait for the async image to have loaded
+         KisDocument* doc = view->document();
+         //        connect(canvasController()->proxyObject, \
SIGNAL(documentMousePositionChanged(QPointF)), d->statusBar, \
SLOT(documentMousePositionChanged(QPointF))); + 
+         d->currentImageView = imageView;
+ 
+         d->viewConnections.addUniqueConnection(d->nodeManager, \
SIGNAL(sigNodeActivated(KisNodeSP)), doc->image(), SLOT(requestStrokeEnd())); +         \
d->viewConnections.addUniqueConnection(d->rotateCanvasRight, SIGNAL(triggered()), \
dynamic_cast<KisCanvasController*>(d->currentImageView->canvasController()), \
SLOT(rotateCanvasRight15())); +         \
d->viewConnections.addUniqueConnection(d->rotateCanvasLeft, \
SIGNAL(triggered()),dynamic_cast<KisCanvasController*>(d->currentImageView->canvasController()), \
SLOT(rotateCanvasLeft15())); +         \
d->viewConnections.addUniqueConnection(d->wrapAroundAction, SIGNAL(toggled(bool)), \
dynamic_cast<KisCanvasController*>(d->currentImageView->canvasController()), \
SLOT(slotToggleWrapAroundMode(bool))); +         \
d->viewConnections.addUniqueConnection(d->currentImageView->canvasController(), \
SIGNAL(toolOptionWidgetsChanged(QList<QPointer<QWidget> >)), mainWindow(), \
SLOT(newOptionWidgets(QList<QPointer<QWidget> >))); +         \
d->viewConnections.addUniqueConnection(d->currentImageView->image(), \
SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), d->controlFrame->paintopBox(), \
SLOT(slotColorSpaceChanged(const KoColorSpace*))); +         \
d->viewConnections.addUniqueConnection(d->showRulersAction, SIGNAL(triggered(bool)), \
imageView->zoomManager(), SLOT(toggleShowRulers(bool))); +         \
d->viewConnections.addUniqueConnection(d->zoomTo100pct, SIGNAL(triggered()), \
imageView->zoomManager(), SLOT(zoomTo100())); +         \
d->viewConnections.addUniqueConnection(d->showGuidesAction, SIGNAL(triggered(bool)), \
imageView->zoomManager(), SLOT(showGuides(bool))); + 
+         showHideScrollbars();
+     }
+ 
+     d->filterManager->setView(imageView);
+     d->selectionManager->setView(imageView);
+     d->nodeManager->setView(imageView);
+     d->imageManager->setView(imageView);
+     d->canvasControlsManager->setView(imageView);
+     d->actionManager->setView(imageView);
+     d->gridManager->setView(imageView);
+     d->statusBar->setView(imageView);
+     d->paintingAssistantsManager->setView(imageView);
+     d->perspectiveGridManager->setView(imageView);
+     d->mirrorManager->setView(imageView);
+ 
+     if (d->currentImageView) {
+         d->currentImageView->canvasController()->activate();
+         d->currentImageView->canvasController()->setFocus();
+     }
+ 
+     d->actionManager->updateGUI();
+ 
+     d->viewConnections.addUniqueConnection(
+         image(), SIGNAL(sigSizeChanged(const QPointF&, const QPointF&)),
+         resourceProvider(), SLOT(slotImageSizeChanged()));
+ 
+     d->viewConnections.addUniqueConnection(
+         image(), SIGNAL(sigResolutionChanged(double,double)),
+         resourceProvider(), SLOT(slotOnScreenResolutionChanged()));
+ 
+     d->viewConnections.addUniqueConnection(
+         image(), SIGNAL(sigNodeChanged(KisNodeSP)),
+         this, SLOT(updateGUI()));
+ 
+     d->viewConnections.addUniqueConnection(
+         view->zoomManager()->zoomController(),
+         SIGNAL(zoomChanged(KoZoomMode::Mode,qreal)),
+         resourceProvider(), SLOT(slotOnScreenResolutionChanged()));
+ 
+     resourceProvider()->slotImageSizeChanged();
+     resourceProvider()->slotOnScreenResolutionChanged();
+ 
+     // Restore the last used brush preset
+     if (first) {
+         KisConfig cfg;
+         KisPaintOpPresetResourceServer * rserver = \
KisResourceServerProvider::instance()->paintOpPresetServer(); +         QString lastPreset = \
cfg.readEntry("LastPreset", QString("Basic_tip_default")); +         KisPaintOpPresetSP preset \
= rserver->resourceByName(lastPreset); +         if (!preset) {
+             preset = rserver->resourceByName("Basic_tip_default");
+         }
+ 
+         if (!preset) {
+             preset = rserver->resources().first();
+         }
+         if (preset) {
+             paintOpBox()->restoreResource(preset.data());
+         }
+ 
+     }
+ }
+ 
+ 
+ KoZoomController *KisViewManager::zoomController() const
+ {
+     if (d->currentImageView) {
+         return d->currentImageView->zoomController();
+     }
+     return 0;
+ }
+ 
+ KisImageWSP KisViewManager::image() const
+ {
+     if (document()) {
+         return document()->image();
+     }
+     return 0;
+ }
+ 
+ KisCanvasResourceProvider * KisViewManager::resourceProvider()
+ {
+     return d->canvasResourceProvider;
+ }
+ 
+ KisCanvas2 * KisViewManager::canvasBase() const
+ {
+     if (d && d->currentImageView) {
+         return d->currentImageView->canvasBase();
+     }
+     return 0;
+ }
+ 
+ QWidget* KisViewManager::canvas() const
+ {
+     if (d && d->currentImageView && d->currentImageView->canvasBase()->canvasWidget()) {
+         return d->currentImageView->canvasBase()->canvasWidget();
+     }
+     return 0;
+ }
+ 
+ KisStatusBar * KisViewManager::statusBar() const
+ {
+     return d->statusBar;
+ }
+ 
+ void KisViewManager::addStatusBarItem(QWidget * widget, int stretch, bool permanent)
+ {
+     if (!mainWindow()) return;
+ 
+     StatusBarItem item(widget, stretch, permanent);
+     KStatusBar * sb = mainWindow()->statusBar();
+     if (sb) {
+         item.ensureItemShown(sb);
+     }
+     d->statusBarItems.append(item);
+ }
+ 
+ void KisViewManager::removeStatusBarItem(QWidget * widget)
+ {
+     KStatusBar *sb = mainWindow()->statusBar();
+ 
+     int itemCount = d->statusBarItems.count();
+     for (int i = itemCount-1; i >= 0; --i) {
+         StatusBarItem &sbItem = d->statusBarItems[i];
+         if (sbItem.widget() == widget) {
+             if (sb) {
+                 sbItem.ensureItemHidden(sb);
+             }
+             d->statusBarItems.removeOne(sbItem);
+             break;
+         }
+     }
+ }
+ 
+ KisPaintopBox* KisViewManager::paintOpBox() const
+ {
+     return d->controlFrame->paintopBox();
+ }
+ 
+ KoProgressUpdater* KisViewManager::createProgressUpdater(KoProgressUpdater::Mode mode)
+ {
+     return new KisProgressUpdater(d->statusBar->progress(), document()->progressProxy(), \
mode); + }
+ 
+ KisSelectionManager * KisViewManager::selectionManager()
+ {
+     return d->selectionManager;
+ }
+ 
+ KisNodeSP KisViewManager::activeNode()
+ {
+     if (d->nodeManager)
+         return d->nodeManager->activeNode();
+     else
+         return 0;
+ }
+ 
+ KisLayerSP KisViewManager::activeLayer()
+ {
+     if (d->nodeManager)
+         return d->nodeManager->activeLayer();
+     else
+         return 0;
+ }
+ 
+ KisPaintDeviceSP KisViewManager::activeDevice()
+ {
+     if (d->nodeManager)
+         return d->nodeManager->activePaintDevice();
+     else
+         return 0;
+ }
+ 
+ KisZoomManager * KisViewManager::zoomManager()
+ {
+     if (d->currentImageView) {
+         return d->currentImageView->zoomManager();
+     }
+     return 0;
+ }
+ 
+ KisFilterManager * KisViewManager::filterManager()
+ {
+     return d->filterManager;
+ }
+ 
+ KisImageManager * KisViewManager::imageManager()
+ {
+     return d->imageManager;
+ }
+ 
+ KisInputManager* KisViewManager::inputManager() const
+ {
+     return d->inputManager;
+ }
+ 
+ KisSelectionSP KisViewManager::selection()
+ {
+     if (d->currentImageView) {
+         return d->currentImageView->selection();
+     }
+     return 0;
+ 
+ }
+ 
+ bool KisViewManager::selectionEditable()
+ {
+     KisLayerSP layer = activeLayer();
+     if (layer) {
+         KoProperties properties;
+         QList<KisNodeSP> masks = layer->childNodes(QStringList("KisSelectionMask"), \
properties); +         if (masks.size() == 1) {
+             return masks[0]->isEditable();
+         }
+     }
+     // global selection is always editable
+     return true;
+ }
+ 
+ KisUndoAdapter * KisViewManager::undoAdapter()
+ {
+     if (!document()) return 0;
+ 
+     KisImageWSP image = document()->image();
+     Q_ASSERT(image);
+ 
+     return image->undoAdapter();
+ }
+ 
+ void KisViewManager::createActions()
+ {
+     d->saveIncremental = new KisAction(i18n("Save Incremental &Version"), this);
+     d->saveIncremental->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S));
+     d->saveIncremental->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("save_incremental_version", d->saveIncremental);
+     connect(d->saveIncremental, SIGNAL(triggered()), this, SLOT(slotSaveIncremental()));
+ 
+     d->saveIncrementalBackup = new KisAction(i18n("Save Incremental Backup"), this);
+     d->saveIncrementalBackup->setShortcut(Qt::Key_F4);
+     d->saveIncrementalBackup->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("save_incremental_backup", d->saveIncrementalBackup);
+     connect(d->saveIncrementalBackup, SIGNAL(triggered()), this, \
SLOT(slotSaveIncrementalBackup())); + 
+     connect(mainWindow(), SIGNAL(documentSaved()), this, SLOT(slotDocumentSaved()));
+ 
+     d->saveIncremental->setEnabled(false);
+     d->saveIncrementalBackup->setEnabled(false);
+ 
+     KisAction *tabletDebugger = new KisAction(i18n("Toggle Tablet Debugger"), this);
+     actionManager()->addAction("tablet_debugger", tabletDebugger );
+     tabletDebugger->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
+     connect(tabletDebugger, SIGNAL(triggered()), this, SLOT(toggleTabletLogger()));
+ 
+     d->createTemplate = new KisAction( i18n( "&Create Template From Image..." ), this);
+     d->createTemplate->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("create_template", d->createTemplate);
+     connect(d->createTemplate, SIGNAL(triggered()), this, SLOT(slotCreateTemplate()));
+ 
+     d->openResourcesDirectory = new KisAction(i18n("Open Resources Folder"), this);
+     d->openResourcesDirectory->setToolTip(i18n("Opens a file browser at the location Krita \
saves resources such as brushes to.")); +     \
d->openResourcesDirectory->setWhatsThis(i18n("Opens a file browser at the location Krita saves \
resources such as brushes to.")); +     actionManager()->addAction("open_resources_directory", \
d->openResourcesDirectory); +     connect(d->openResourcesDirectory, SIGNAL(triggered()), \
SLOT(openResourcesDirectory())); + 
+     d->rotateCanvasRight = new KisAction(i18n("Rotate Canvas Right"), this);
+     actionManager()->addAction("rotate_canvas_right", d->rotateCanvasRight);
+     d->rotateCanvasRight->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     d->rotateCanvasRight->setShortcut(QKeySequence("Ctrl+]"));
+ 
+     d->rotateCanvasLeft = new KisAction(i18n("Rotate Canvas Left"), this);
+     actionManager()->addAction("rotate_canvas_left", d->rotateCanvasLeft);
+     d->rotateCanvasLeft->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     d->rotateCanvasLeft->setShortcut(QKeySequence("Ctrl+["));
+ 
+     d->wrapAroundAction = new KisAction(i18n("Wrap Around Mode"), this);
+     d->wrapAroundAction->setCheckable(true);
+     d->wrapAroundAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("wrap_around_mode", d->wrapAroundAction);
+     d->wrapAroundAction->setShortcut(QKeySequence(Qt::Key_W));
+ 
+     KisAction *tAction = new KisAction(i18n("Show Status Bar"), this);
+     tAction->setCheckable(true);
+     tAction->setChecked(true);
+     tAction->setToolTip(i18n("Shows or hides the status bar"));
+     actionManager()->addAction("showStatusBar", tAction);
+     tAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool)));
+ 
+     tAction = new KisAction(i18n("Show Canvas Only"), this);
+     tAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     tAction->setCheckable(true);
+     tAction->setToolTip(i18n("Shows just the canvas or the whole window"));
+     QList<QKeySequence> shortcuts;
+     shortcuts << QKeySequence(Qt::Key_Tab);
+     tAction->setShortcuts(shortcuts);
+     tAction->setChecked(false);
+     actionManager()->addAction("view_show_just_the_canvas", tAction);
+     connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showJustTheCanvas(bool)));
+ 
+     //Workaround, by default has the same shortcut as mirrorCanvas
+     KisAction *a = dynamic_cast<KisAction*>(actionCollection()->action("format_italic"));
+     if (a) {
+         a->setShortcut(QKeySequence(), KAction::DefaultShortcut);
+         a->setShortcut(QKeySequence(), KAction::ActiveShortcut);        
+         a->setActivationConditions(KisAction::SELECTION_EDITABLE);
+     }
+ 
+     a = new KisAction(i18n("Cleanup removed files..."), this);
+     actionManager()->addAction("edit_blacklist_cleanup", a);
+     connect(a, SIGNAL(triggered()), this, SLOT(slotBlacklistCleanup()));
+ 
+     d->showRulersAction = new KisAction(i18n("Show Rulers"), this);
+     d->showRulersAction->setCheckable(true);
+     d->showRulersAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("view_ruler", d->showRulersAction);
+     d->showRulersAction->setWhatsThis(i18n("The rulers show the horizontal and vertical \
positions of the mouse on the image " +                                            "and can be \
used to position your mouse at the right place on the canvas. <p>Uncheck this to hide the \
rulers.</p>")); +     KisConfig cfg;
+     d->showRulersAction->setChecked(cfg.showRulers());
+ 
+ 
+     d->showGuidesAction = new KisAction(i18n("Show Guides"), this);
+     d->showGuidesAction->setCheckable(true);
+     d->showGuidesAction->setCheckable(false);
+     d->showGuidesAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     d->showGuidesAction->setToolTip(i18n("Shows or hides guides"));
+     actionManager()->addAction("view_show_guides", d->showGuidesAction);
+ 
+     d->zoomTo100pct = new KisAction(i18n("Reset zoom"), this);
+     d->zoomTo100pct->setActivationFlags(KisAction::ACTIVE_IMAGE);
+     actionManager()->addAction("zoom_to_100pct", d->zoomTo100pct);
+     d->zoomTo100pct->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_0 ) );
+ }
+ 
+ 
+ 
+ void KisViewManager::createManagers()
+ {
+     // Create the managers for filters, selections, layers etc.
+     // XXX: When the currentlayer changes, call updateGUI on all
+     // managers
+ 
+     d->filterManager = new KisFilterManager(this);
+     d->filterManager->setup(actionCollection(), actionManager());
+ 
+     d->selectionManager = new KisSelectionManager(this);
+     d->selectionManager->setup(actionManager());
+ 
+     d->nodeManager = new KisNodeManager(this);
+     d->nodeManager->setup(actionCollection(), actionManager());
+ 
+     d->imageManager = new KisImageManager(this);
+     d->imageManager->setup(actionManager());
+ 
+     d->gridManager = new KisGridManager(this);
+     d->gridManager->setup(this->actionManager());
+ 
+     d->perspectiveGridManager = new KisPerspectiveGridManager(this);
+     d->perspectiveGridManager->setup(actionCollection());
+ 
+     d->paintingAssistantsManager = new KisPaintingAssistantsManager(this);
+     d->paintingAssistantsManager->setup(actionManager());
+ 
+     d->canvasControlsManager = new KisCanvasControlsManager(this);
+     d->canvasControlsManager->setup(actionManager());
+ 
+     d->mirrorManager = new KisMirrorManager(this);
+     d->mirrorManager->setup(actionCollection());
+ 
+     d->inputManager = new KisInputManager(this);
++    
++    d->scriptManager = new KisScriptManager(this);
++    d->scriptManager->setup(actionCollection());
+ }
+ 
+ void KisViewManager::updateGUI()
+ {
+     d->guiUpdateCompressor->start();
+ }
+ 
+ void KisViewManager::slotBlacklistCleanup()
+ {
+     KisDlgBlacklistCleanup dialog;
+     dialog.exec();
+ }
+ 
+ KisNodeManager * KisViewManager::nodeManager() const
+ {
+     return d->nodeManager;
+ }
+ 
+ KisActionManager* KisViewManager::actionManager() const
+ {
+     return d->actionManager;
+ }
+ 
+ KisPerspectiveGridManager* KisViewManager::perspectiveGridManager() const
+ {
+     return d->perspectiveGridManager;
+ }
+ 
+ KisGridManager * KisViewManager::gridManager() const
+ {
+     return d->gridManager;
+ }
+ 
+ KisPaintingAssistantsManager* KisViewManager::paintingAssistantsManager() const
+ {
+     return d->paintingAssistantsManager;
+ }
+ 
+ KisDocument *KisViewManager::document() const
+ {
+     if (d->currentImageView && d->currentImageView->document()) {
+         return d->currentImageView->document();
+     }
+     return 0;
+ }
+ 
++KisScriptManager *KisViewManager::scriptManager() const
++{
++  return d->scriptManager;
++}
++
+ int KisViewManager::viewCount() const
+ {
+     KisMainWindow *mw  = qobject_cast<KisMainWindow*>(d->mainWindow);
+     if (mw) {
+         return mw->viewCount();
+     }
+     return 0;
+ }
+ 
+ void KisViewManager::slotCreateTemplate()
+ {
+     if (!document()) return;
+     KisTemplateCreateDia::createTemplate("krita_template", ".kra",
+                                         KisFactory::componentData(), document(), \
mainWindow()); + }
+ 
+ QMainWindow* KisViewManager::qtMainWindow() const
+ {
+     if (d->mainWindow)
+         return d->mainWindow;
+ 
+     //Fallback for when we have not yet set the main window.
+     QMainWindow* w = qobject_cast<QMainWindow*>(qApp->activeWindow());
+     if(w)
+         return w;
+ 
+     return mainWindow();
+ }
+ 
+ void KisViewManager::setQtMainWindow(QMainWindow* newMainWindow)
+ {
+     d->mainWindow = newMainWindow;
+ }
+ 
+ 
+ void KisViewManager::slotDocumentSaved()
+ {
+     d->saveIncremental->setEnabled(true);
+     d->saveIncrementalBackup->setEnabled(true);
+ }
+ 
+ void KisViewManager::slotSaveIncremental()
+ {
+     if (!document()) return;
+ 
+     bool foundVersion;
+     bool fileAlreadyExists;
+     bool isBackup;
+     QString version = "000";
+     QString newVersion;
+     QString letter;
+     QString fileName = document()->localFilePath();
+ 
+     // Find current version filenames
+     // v v Regexp to find incremental versions in the filename, taking our backup scheme into \
account as well +     // Considering our incremental version and backup scheme, format is \
filename_001~001.ext +     QRegExp \
regex("_\\d{1,4}[.]|_\\d{1,4}[a-z][.]|_\\d{1,4}[~]|_\\d{1,4}[a-z][~]"); +     \
regex.indexIn(fileName);     //  Perform the search +     QStringList matches = \
regex.capturedTexts(); +     foundVersion = matches.at(0).isEmpty() ? false : true;
+ 
+     // Ensure compatibility with Save Incremental Backup
+     // If this regex is not kept separate, the entire algorithm needs modification;
+     // It's simpler to just add this.
+     QRegExp regexAux("_\\d{1,4}[~]|_\\d{1,4}[a-z][~]");
+     regexAux.indexIn(fileName);     //  Perform the search
+     QStringList matchesAux = regexAux.capturedTexts();
+     isBackup = matchesAux.at(0).isEmpty() ? false : true;
+ 
+     // If the filename has a version, prepare it for incrementation
+     if (foundVersion) {
+         version = matches.at(matches.count() - 1);     //  Look at the last index, we don't \
care about other matches +         if (version.contains(QRegExp("[a-z]"))) {
+             version.chop(1);             //  Trim "."
+             letter = version.right(1);   //  Save letter
+             version.chop(1);             //  Trim letter
+         } else {
+             version.chop(1);             //  Trim "."
+         }
+         version.remove(0, 1);            //  Trim "_"
+     } else {
+         // ...else, simply add a version to it so the next loop works
+         QRegExp regex2("[.][a-z]{2,4}$");  //  Heuristic to find file extension
+         regex2.indexIn(fileName);
+         QStringList matches2 = regex2.capturedTexts();
+         QString extensionPlusVersion = matches2.at(0);
+         extensionPlusVersion.prepend(version);
+         extensionPlusVersion.prepend("_");
+         fileName.replace(regex2, extensionPlusVersion);
+     }
+ 
+     // Prepare the base for new version filename
+     int intVersion = version.toInt(0);
+     ++intVersion;
+     QString baseNewVersion = QString::number(intVersion);
+     while (baseNewVersion.length() < version.length()) {
+         baseNewVersion.prepend("0");
+     }
+ 
+     // Check if the file exists under the new name and search until options are exhausted \
(test appending a to z) +     do {
+         newVersion = baseNewVersion;
+         newVersion.prepend("_");
+         if (!letter.isNull()) newVersion.append(letter);
+         if (isBackup) {
+             newVersion.append("~");
+         } else {
+             newVersion.append(".");
+         }
+         fileName.replace(regex, newVersion);
+         fileAlreadyExists = KIO::NetAccess::exists(fileName, KIO::NetAccess::DestinationSide, \
mainWindow()); +         if (fileAlreadyExists) {
+             if (!letter.isNull()) {
+                 char letterCh = letter.at(0).toLatin1();
+                 ++letterCh;
+                 letter = QString(QChar(letterCh));
+             } else {
+                 letter = 'a';
+             }
+         }
+     } while (fileAlreadyExists && letter != "{");  // x, y, z, {...
+ 
+     if (letter == "{") {
+         QMessageBox::critical(mainWindow(), i18nc("@title:window", "Couldn't save incremental \
version"), i18n("Alternative names exhausted, try manually saving with a higher number")); +    \
return; +     }
+     document()->setSaveInBatchMode(true);
+     document()->saveAs(fileName);
+     document()->setSaveInBatchMode(false);
+ 
+     if (mainWindow()) {
+         mainWindow()->updateCaption();
+     }
+ 
+ }
+ 
+ void KisViewManager::slotSaveIncrementalBackup()
+ {
+     if (!document()) return;
+ 
+     bool workingOnBackup;
+     bool fileAlreadyExists;
+     QString version = "000";
+     QString newVersion;
+     QString letter;
+     QString fileName = document()->localFilePath();
+ 
+     // First, discover if working on a backup file, or a normal file
+     QRegExp regex("~\\d{1,4}[.]|~\\d{1,4}[a-z][.]");
+     regex.indexIn(fileName);     //  Perform the search
+     QStringList matches = regex.capturedTexts();
+     workingOnBackup = matches.at(0).isEmpty() ? false : true;
+ 
+     if (workingOnBackup) {
+         // Try to save incremental version (of backup), use letter for alt versions
+         version = matches.at(matches.count() - 1);     //  Look at the last index, we don't \
care about other matches +         if (version.contains(QRegExp("[a-z]"))) {
+             version.chop(1);             //  Trim "."
+             letter = version.right(1);   //  Save letter
+             version.chop(1);             //  Trim letter
+         } else {
+             version.chop(1);             //  Trim "."
+         }
+         version.remove(0, 1);            //  Trim "~"
+ 
+         // Prepare the base for new version filename
+         int intVersion = version.toInt(0);
+         ++intVersion;
+         QString baseNewVersion = QString::number(intVersion);
+         QString backupFileName = document()->localFilePath();
+         while (baseNewVersion.length() < version.length()) {
+             baseNewVersion.prepend("0");
+         }
+ 
+         // Check if the file exists under the new name and search until options are exhausted \
(test appending a to z) +         do {
+             newVersion = baseNewVersion;
+             newVersion.prepend("~");
+             if (!letter.isNull()) newVersion.append(letter);
+             newVersion.append(".");
+             backupFileName.replace(regex, newVersion);
+             fileAlreadyExists = KIO::NetAccess::exists(backupFileName, \
KIO::NetAccess::DestinationSide, mainWindow()); +             if (fileAlreadyExists) {
+                 if (!letter.isNull()) {
+                     char letterCh = letter.at(0).toLatin1();
+                     ++letterCh;
+                     letter = QString(QChar(letterCh));
+                 } else {
+                     letter = 'a';
+                 }
+             }
+         } while (fileAlreadyExists && letter != "{");  // x, y, z, {...
+ 
+         if (letter == "{") {
+             QMessageBox::critical(mainWindow(), i18nc("@title:window", "Couldn't save \
incremental backup"), i18n("Alternative names exhausted, try manually saving with a higher \
number")); +             return;
+         }
+         QFile::copy(fileName, backupFileName);
+         document()->saveAs(fileName);
+ 
+         if (mainWindow()) mainWindow()->updateCaption();
+     }
+     else { // if NOT working on a backup...
+         // Navigate directory searching for latest backup version, ignore letters
+         const quint8 HARDCODED_DIGIT_COUNT = 3;
+         QString baseNewVersion = "000";
+         QString backupFileName = document()->localFilePath();
+         QRegExp regex2("[.][a-z]{2,4}$");  //  Heuristic to find file extension
+         regex2.indexIn(backupFileName);
+         QStringList matches2 = regex2.capturedTexts();
+         QString extensionPlusVersion = matches2.at(0);
+         extensionPlusVersion.prepend(baseNewVersion);
+         extensionPlusVersion.prepend("~");
+         backupFileName.replace(regex2, extensionPlusVersion);
+ 
+         // Save version with 1 number higher than the highest version found ignoring letters
+         do {
+             newVersion = baseNewVersion;
+             newVersion.prepend("~");
+             newVersion.append(".");
+             backupFileName.replace(regex, newVersion);
+             fileAlreadyExists = KIO::NetAccess::exists(backupFileName, \
KIO::NetAccess::DestinationSide, mainWindow()); +             if (fileAlreadyExists) {
+                 // Prepare the base for new version filename, increment by 1
+                 int intVersion = baseNewVersion.toInt(0);
+                 ++intVersion;
+                 baseNewVersion = QString::number(intVersion);
+                 while (baseNewVersion.length() < HARDCODED_DIGIT_COUNT) {
+                     baseNewVersion.prepend("0");
+                 }
+             }
+         } while (fileAlreadyExists);
+ 
+         // Save both as backup and on current file for interapplication workflow
+         document()->setSaveInBatchMode(true);
+         QFile::copy(fileName, backupFileName);
+         document()->saveAs(fileName);
+         document()->setSaveInBatchMode(false);
+ 
+         if (mainWindow()) mainWindow()->updateCaption();
+     }
+ }
+ 
+ void KisViewManager::disableControls()
+ {
+     // prevents possible crashes, if somebody changes the paintop during dragging by using \
the mousewheel +     // this is for Bug 250944
+     // the solution blocks all wheel, mouse and key event, while dragging with the freehand \
tool +     // see KisToolFreehand::initPaint() and endPaint()
+     d->controlFrame->paintopBox()->installEventFilter(&d->blockingEventFilter);
+     foreach(QObject* child, d->controlFrame->paintopBox()->children()) {
+         child->installEventFilter(&d->blockingEventFilter);
+     }
+ }
+ 
+ void KisViewManager::enableControls()
+ {
+     d->controlFrame->paintopBox()->removeEventFilter(&d->blockingEventFilter);
+     foreach(QObject* child, d->controlFrame->paintopBox()->children()) {
+         child->removeEventFilter(&d->blockingEventFilter);
+     }
+ }
+ 
+ void KisViewManager::showStatusBar(bool toggled)
+ {
+     if (d->currentImageView && d->currentImageView->statusBar()) {
+         d->currentImageView->statusBar()->setVisible(toggled);
+     }
+ }
+ 
+ #if defined HAVE_OPENGL && defined Q_OS_WIN32
+ #include <QGLContext>
+ #endif
+ 
+ void KisViewManager::showJustTheCanvas(bool toggled)
+ {
+     KisConfig cfg;
+     KisMainWindow* main = mainWindow();
+ 
+     if(!main) {
+         dbgUI << "Unable to switch to canvas-only mode, main window not found";
+         return;
+     }
+ 
+     if (cfg.hideStatusbarFullscreen()) {
+         if(main->statusBar() && main->statusBar()->isVisible() == toggled) {
+             main->statusBar()->setVisible(!toggled);
+         }
+     }
+ 
+     if (cfg.hideDockersFullscreen()) {
+         KisAction* action = \
qobject_cast<KisAction*>(main->actionCollection()->action("view_toggledockers")); +         \
action->setCheckable(true); +         if (action && action->isChecked() == toggled) {
+             action->setChecked(!toggled);
+         }
+     }
+ 
+     if (cfg.hideTitlebarFullscreen()) {
+         if(toggled) {
+             main->setWindowState( main->windowState() | Qt::WindowFullScreen);
+         } else {
+             main->setWindowState( main->windowState() & ~Qt::WindowFullScreen);
+         }
+     }
+ 
+     if (cfg.hideMenuFullscreen()) {
+         if (main->menuBar()->isVisible() == toggled) {
+             main->menuBar()->setVisible(!toggled);
+         }
+     }
+ 
+     if (cfg.hideToolbarFullscreen()) {
+         QList<QToolBar*> toolBars = main->findChildren<QToolBar*>();
+         foreach(QToolBar* toolbar, toolBars) {
+             if (toolbar->isVisible() == toggled) {
+                 toolbar->setVisible(!toggled);
+             }
+         }
+     }
+ 
+     showHideScrollbars();
+ 
+     if (toggled) {
+         // show a fading heads-up display about the shortcut to go back
+ 
+         showFloatingMessage(i18n("Going into Canvas-Only mode.\nPress %1 to go back.",
+                                  \
actionCollection()->action("view_show_just_the_canvas")->shortcut().toString()), QIcon()); +    \
} + }
+ 
+ void KisViewManager::toggleTabletLogger()
+ {
+     d->inputManager->toggleTabletLogger();
+ }
+ 
+ void KisViewManager::openResourcesDirectory()
+ {
+     QString dir = KStandardDirs::locateLocal("data", "krita");
+     QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
+ }
+ 
+ void KisViewManager::updateIcons()
+ {
+ #if QT_VERSION >= 0x040700
+     QColor background = mainWindow()->palette().background().color();
+ 
+     bool useDarkIcons = background.value() > 100;
+     QString prefix = useDarkIcons ? QString("dark_") : QString("light_");
+ 
+     QStringList whitelist;
+     whitelist << "ToolBox" << "KisLayerBox";
+ 
+     QStringList blacklistedIcons;
+     blacklistedIcons << "editpath" << "artistictext-tool" << "view-choose";
+ 
+     if (mainWindow()) {
+         QList<QDockWidget*> dockers = mainWindow()->dockWidgets();
+         foreach(QDockWidget* dock, dockers) {
+             kDebug() << "name " << dock->objectName();
+             KoDockWidgetTitleBar* titlebar = \
dynamic_cast<KoDockWidgetTitleBar*>(dock->titleBarWidget()); +             if (titlebar) {
+                 titlebar->updateIcons();
+             }
+             if (!whitelist.contains(dock->objectName())) {
+                 continue;
+             }
+ 
+             QObjectList objects;
+             objects.append(dock);
+             while (!objects.isEmpty()) {
+                 QObject* object = objects.takeFirst();
+                 objects.append(object->children());
+ 
+                 QAbstractButton* button = dynamic_cast<QAbstractButton*>(object);
+                 if (button && !button->icon().name().isEmpty()) {
+                     QString name = button->icon().name(); name = \
name.remove("dark_").remove("light_"); + 
+                     if (!blacklistedIcons.contains(name)) {
+                         QString iconName = prefix + name;
+                         KIcon icon = koIcon(iconName.toLatin1());
+                         button->setIcon(icon);
+                     }
+                 }
+             }
+         }
+     }
+ #endif
+ }
+ void KisViewManager::makeStatusBarVisible()
+ {
+     d->mainWindow->statusBar()->setVisible(true);
+ }
+ 
+ void KisViewManager::guiUpdateTimeout()
+ {
+     d->nodeManager->updateGUI();
+     d->selectionManager->updateGUI();
+     d->filterManager->updateGUI();
+     if (zoomManager()) {
+         zoomManager()->updateGUI();
+     }
+     d->gridManager->updateGUI();
+     d->perspectiveGridManager->updateGUI();
+     d->actionManager->updateGUI();
+ }
+ 
+ void KisViewManager::showFloatingMessage(const QString message, const QIcon& icon, int \
timeout, KisFloatingMessage::Priority priority, int alignment) + {
+     if(d->showFloatingMessage && qtMainWindow()) {
+         if (d->savedFloatingMessage) {
+             d->savedFloatingMessage->tryOverrideMessage(message, icon, timeout, priority, \
alignment); +         } else {
+             if(d->currentImageView) {
+                 d->savedFloatingMessage = new KisFloatingMessage(message, \
d->currentImageView->canvasBase()->canvasWidget(), false, timeout, priority, alignment); +      \
d->savedFloatingMessage->setShowOverParent(true); +                 \
d->savedFloatingMessage->setIcon(icon); +                 \
d->savedFloatingMessage->showMessage(); +             }
+         }
+     }
+ #if QT_VERSION >= 0x040700
+     emit floatingMessageRequested(message, icon.name());
+ #endif
+ }
+ 
+ KisMainWindow *KisViewManager::mainWindow() const
+ {
+     return qobject_cast<KisMainWindow*>(d->mainWindow);
+ }
+ 
+ 
+ void KisViewManager::showHideScrollbars()
+ {
+     if (!d->currentImageView) return;
+     if (!d->currentImageView->canvasController()) return;
+ 
+     KisConfig cfg;
+     bool toggled = actionCollection()->action("view_show_just_the_canvas")->isChecked();
+ 
+     if ( (toggled && cfg.hideScrollbarsFullscreen()) || (!toggled && cfg.hideScrollbars()) ) \
{ +         d->currentImageView->canvasController()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 +         d->currentImageView->canvasController()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 +     } else {
+         d->currentImageView->canvasController()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 +         d->currentImageView->canvasController()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 +     }
+ }
+ 
+ void KisViewManager::setShowFloatingMessage(bool show)
+ {
+     d->showFloatingMessage = show;
+ }
+ 
+ 
+ #include "KisViewManager.moc"
diff --cc krita/ui/KisViewManager.h
index 0000000,3929494..aa8fafa
mode 000000,100644..100644
--- a/krita/ui/KisViewManager.h
+++ b/krita/ui/KisViewManager.h
@@@ -1,0 -1,249 +1,252 @@@
+ /*
+  *  Copyright (c) 2006 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 KIS_GUI_CLIENT_H
+ #define KIS_GUI_CLIENT_H
+ 
+ #include <QDockWidget>
+ #include <QQueue>
+ #include <QPointer>
+ 
+ #include <KisMainWindow.h>
+ #include <KisView.h>
+ #include <KoProgressUpdater.h>
+ #include <KoToolManager.h>
+ 
+ #include <krita_export.h>
+ #include <kis_types.h>
+ 
+ #include "kis_floating_message.h"
+ #include "KisView.h"
+ 
+ class KisAction;
+ class QPoint;
+ 
+ 
+ class KisCanvas2;
+ class KisCanvasResourceProvider;
+ class KisDocument;
+ class KisFilterManager;
+ class KisGridManager;
+ class KisImage;
+ class KisImageManager;
+ class KisNodeManager;
+ class KisPaintingAssistantsManager;
+ class KisPaintopBox;
+ class KisPerspectiveGridManager;
+ class KisSelectionManager;
+ class KisStatusBar;
+ class KisUndoAdapter;
+ class KisZoomManager;
+ class KisPaintopBox;
+ class KisActionManager;
++class KisScriptManager;
+ class KisInputManager;
+ 
+ /**
+  * Krita view class
+  *
+  * Following the broad model-view-controller idea this class shows you one view on the \
document. +  * There can be multiple views of the same document each in with independent \
settings for viewMode and zoom etc. +  */
+ class KRITAUI_EXPORT KisViewManager : public QObject
+ {
+ 
+     Q_OBJECT
+ 
+ public:
+     /**
+      * Construct a new view on the krita document.
+      * @param document   the document we show.
+      * @param parent   a parent widget we show ourselves in.
+      */
+     KisViewManager(QWidget *parent, KActionCollection *actionCollection);
+     virtual ~KisViewManager();
+ 
+     /**
+      * Retrieves the entire action collection.
+      */
+     virtual KActionCollection* actionCollection() const;
+ 
+ public:  // Krita specific interfaces
+ 
+     void setCurrentView(KisView *view);
+ 
+     /// Return the image this view is displaying
+     KisImageWSP image() const;
+ 
+     KoZoomController *zoomController() const;
+ 
+     /// The resource provider contains all per-view settings, such as
+     /// current color, current paint op etc.
+     KisCanvasResourceProvider * resourceProvider();
+ 
+     /// Return the canvasbase class
+     KisCanvas2 * canvasBase() const;
+ 
+     /// Return the actual widget that is displaying the current image
+     QWidget* canvas() const;
+ 
+     /// Return the wrapper class around the statusbar
+     KisStatusBar * statusBar() const;
+ 
+     /**
+       * This adds a widget to the statusbar for this view.
+       * If you use this method instead of using statusBar() directly,
+       * KisView will take care of removing the items when the view GUI is deactivated
+       * and readding them when it is reactivated.
+       * The parameters are the same as QStatusBar::addWidget().
+       *
+       * Note that you can't use KStatusBar methods (inserting text items by id).
+       * But you can create a KStatusBarLabel with a dummy id instead, and use
+       * it directly, to get the same look and feel.
+       */
+     void addStatusBarItem(QWidget * widget, int stretch = 0, bool permanent = false);
+ 
+     /**
+       * Remove a widget from the statusbar for this view.
+       */
+     void removeStatusBarItem(QWidget * widget);
+ 
+     KisPaintopBox* paintOpBox() const;
+ 
+     /// create a new progress updater
+     KoProgressUpdater *createProgressUpdater(KoProgressUpdater::Mode mode = \
KoProgressUpdater::Threaded); + 
+     /// The selection manager handles everything action related to
+     /// selections.
+     KisSelectionManager *selectionManager();
+ 
+     /// The node manager handles everything about nodes
+     KisNodeManager *nodeManager() const;
+ 
+     KisActionManager *actionManager() const;
+ 
+     /**
+      * Convenience method to get at the active node, which may be
+      * a layer or a mask or a selection
+      */
+     KisNodeSP activeNode();
+ 
+     /// Convenience method to get at the active layer
+     KisLayerSP activeLayer();
+ 
+     /// Convenience method to get at the active paint device
+     KisPaintDeviceSP activeDevice();
+ 
+     /// The filtermanager handles everything action-related to filters
+     KisFilterManager *filterManager();
+ 
+     /// The image manager handles everything action-related to the
+     /// current image
+     KisImageManager *imageManager();
+ 
+     /// Filters events and sends them to canvas actions
+     KisInputManager *inputManager() const;
+ 
+     /// Convenience method to get at the active selection (the
+     /// selection of the current layer, or, if that does not exist,
+     /// the global selection.
+     KisSelectionSP selection();
+ 
+     /// Checks if the current global or local selection is editable
+     bool selectionEditable();
+ 
+     /// The undo adapter is used to add commands to the undo stack
+     KisUndoAdapter *undoAdapter();
+ 
+     KisDocument *document() const;
++    
++    KisScriptManager *scriptManager() const;
+ 
+     int viewCount() const;
+ 
+ public:
+ 
+     KisGridManager * gridManager() const;
+     KisPerspectiveGridManager* perspectiveGridManager() const;
+     KisPaintingAssistantsManager* paintingAssistantsManager() const;
+ 
+     /// disable and enable toolbar controls. used for disabling them during painting.
+     void enableControls();
+     void disableControls();
+ 
+ 
+     /// shows a floating message in the top right corner of the canvas
+     void showFloatingMessage(const QString message, const QIcon& icon, int timeout = 4500,
+                              KisFloatingMessage::Priority priority = \
KisFloatingMessage::Medium, +                              int alignment = Qt::AlignCenter | \
Qt::TextWordWrap); + 
+     /// @return the KoMaindow this view is in, or 0
+     KisMainWindow *mainWindow() const;
+ 
+     /// The QMainWindow associated with this view. This is most likely going to be shell(), \
but +     /// when running as Gemini or Sketch, this will be set to the applications' own \
QMainWindow. +     /// This can be checked by qobject_casting to KisMainWindow to check the \
difference. +     QMainWindow* qtMainWindow() const;
+ 
+     /// The mainWindow function will return the shell() value, unless this function is called
+     /// with a non-null value. To make it return shell() again, simply pass null to this \
function. +     void setQtMainWindow(QMainWindow* newMainWindow);
+ 
+ public Q_SLOTS:
+ 
+     void showJustTheCanvas(bool toggled);
+     void setShowFloatingMessage(bool show);
+     void showHideScrollbars();
+ 
+     /// Go to all managers and enable or disable all actions and other
+     /// gui elements
+     void updateGUI();
+ 
+     /// Update the style of all the icons
+     void updateIcons();
+ 
+     void slotViewAdded(KisView *view);
+     void slotViewRemoved(KisView *view);
+ 
+ Q_SIGNALS:
+ 
+     void floatingMessageRequested(QString message, QString iconName);
+ 
+ private Q_SLOTS:
+ 
+     void slotBlacklistCleanup();
+     void slotCreateTemplate();
+     void slotDocumentSaved();
+     void slotSaveIncremental();
+     void slotSaveIncrementalBackup();
+     void showStatusBar(bool toggled);
+     void toggleTabletLogger();
+     void openResourcesDirectory();
+     void makeStatusBarVisible();
+     void guiUpdateTimeout();
+ 
+ private:
+     void createActions();
+     void createManagers();
+ 
+     /// The zoommanager handles everything action-related to zooming
+     KisZoomManager * zoomManager();
+ 
+ private:
+     class KisViewManagerPrivate;
+     KisViewManagerPrivate * const d;
+ };
+ 
+ #endif
diff --cc krita/ui/kis_script_manager.cpp
index b293bdb,0000000..25b955c
mode 100644,000000..100644
--- a/krita/ui/kis_script_manager.cpp
+++ b/krita/ui/kis_script_manager.cpp
@@@ -1,84 -1,0 +1,84 @@@
 +/*
 + *  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; 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 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 "kis_script_manager.h"
 +
 +#include <klocale.h>
 +#include <kaction.h>
 +#include <kactionmenu.h>
 +#include <kactioncollection.h>
 +
- #include "kis_view2.h"
++#include "KisViewManager.h"
 +
 +struct KisScriptManager::Private {
 +    Private()
 +        : actionCollection(0)
 +        , view(0)
 +        , scriptMenu(0)
 +    {
 +    }
 +
 +    QHash<KisFilter*, KAction*> script2Action;
 +
 +    KActionCollection *actionCollection;
-     KisView2 *view;
++    KisViewManager *view;
 +    KActionMenu *scriptMenu;
 +};
 +
 +
- KisScriptManager::KisScriptManager(KisView2 *view)
++KisScriptManager::KisScriptManager(KisViewManager *view)
 +    : QObject(view)
 +    , d(new Private())
 +{
 +    d->view = view;
 +    d->actionCollection = view->actionCollection();
 +    d->scriptMenu = new KActionMenu(i18n("Scripts"),this);
 +    d->actionCollection->addAction("scripting", d->scriptMenu);
 +}
 +
 +KisScriptManager::~KisScriptManager()
 +{
 +    delete d;
 +}
 +
 +
 +void KisScriptManager::setup(KActionCollection * ac)
 +{
 +    d->actionCollection = ac;
 +}
 +
 +void KisScriptManager::updateGUI()
 +{
 +    if (!d->view) return;
 +
 +//    bool enable = false;
 +
 +//    KisNodeSP activeNode = d->view->activeNode();
 +//    enable = activeNode && activeNode->hasEditablePaintDevice();
 +
 +//    d->reapplyAction->setEnabled(enable);
 +
 +//    foreach(KAction *action, d->script2Action.values()) {
 +//        action->setEnabled(enable);
 +    //    }
 +}
 +
 +void KisScriptManager::addAction(QAction *action)
 +{
 +    d->scriptMenu->addAction(action);
 +}
diff --cc krita/ui/kis_script_manager.h
index 4ea4e0d,0000000..24c24c3
mode 100644,000000..100644
--- a/krita/ui/kis_script_manager.h
+++ b/krita/ui/kis_script_manager.h
@@@ -1,48 -1,0 +1,48 @@@
 +/*
 + *  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; 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 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 KIS_SCRIPT_MANAGER_H
 +#define KIS_SCRIPT_MANAGER_H
 +
 +#include <QObject>
 +
 +#include <krita_export.h>
 +
 +class QAction;
 +
- class KisView2;
++class KisViewManager;
 +class KActionCollection;
 +
 +class KRITAUI_EXPORT KisScriptManager : public QObject
 +{
 +    Q_OBJECT
 +public:
-     explicit KisScriptManager(KisView2 * view);
++    explicit KisScriptManager(KisViewManager * view);
 +    ~KisScriptManager();
 +
 +    void setup(KActionCollection * ac);
 +    void updateGUI();
 +
 +    void addAction(QAction *action);
 +
 +private:
 +    struct Private;
 +    Private * const d;
 +};
 +
 +#endif // KIS_SCRIPT_MANAGER_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic