Commit b5eacb9c authored by Brijesh Patel's avatar Brijesh Patel
Browse files

Merge branch 'master' of git://anongit.kde.org/calligra

parents a21bf1ea 8fcbb895
......@@ -706,7 +706,7 @@ void KisToolTransform::setTransformFunction(QPointF mousePos, Qt::KeyboardModifi
}
}
else {
if (modifiers & Qt::AltModifier) {
if (modifiers & Qt::AltModifier || modifiers & Qt::MetaModifier) {
m_function = PERSPECTIVE;
setFunctionalCursor();
return;
......@@ -828,8 +828,8 @@ void KisToolTransform::setTransformFunction(QPointF mousePos, Qt::KeyboardModifi
void KisToolTransform::mousePressEvent(KoPointerEvent *event)
{
if (!PRESS_CONDITION_OM(event, KisTool::HOVER_MODE,
Qt::LeftButton, Qt::AltModifier)) {
if (!PRESS_CONDITION_OM(event, KisTool::HOVER_MODE, Qt::LeftButton, Qt::AltModifier)
|| !PRESS_CONDITION_OM(event, KisTool::HOVER_MODE, Qt::LeftButton, Qt::MetaModifier)) {
KisTool::mousePressEvent(event);
return;
......
include_directories( ${KOTEXT_INCLUDES}
include_directories( ${KOTEXT_INCLUDES}
${TEXTLAYOUT_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/pigment/colorprofiles
${CMAKE_CURRENT_SOURCE_DIR}/flake
${CMAKE_CURRENT_SOURCE_DIR}/flake
${CMAKE_CURRENT_SOURCE_DIR}/pigment/resources
${CMAKE_CURRENT_SOURCE_DIR}/widgets/resources
${CMAKE_CURRENT_SOURCE_DIR}/openrastertk
${CMAKE_SOURCE_DIR}/krita/image/metadata
${CMAKE_SOURCE_DIR}/krita/image/metadata
${EXIV2_INCLUDE_DIR} )
add_subdirectory( tests )
......@@ -16,22 +16,22 @@ configure_file(config-processor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-proce
include(kdefx.cmake)
set(kritaui_LIB_SRCS
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas2.cpp
canvas/kis_canvas_controller.cpp
canvas/kis_tool_proxy.cpp
canvas/kis_canvas_decoration.cc
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
canvas/kis_grid_painter_configuration.cpp
canvas/kis_perspective_grid_manager.cpp
canvas/kis_perspective_grid_manager.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
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adjustment_layer.cc
dialogs/kis_dlg_filter.cpp
dialogs/kis_dlg_generator_layer.cpp
......@@ -44,21 +44,21 @@ set(kritaui_LIB_SRCS
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_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_shape_selection_model.cpp
kis_autogradient.cc
kis_autogradient_resource.cc
kis_bookmarked_configurations_editor.cc
kis_bookmarked_configurations_model.cc
kis_bookmarked_filter_configurations_model.cc
kis_canvas_resource_provider.cpp
kis_canvas_resource_provider.cpp
kis_categorized_item_delegate.cpp
kis_clipboard.cc
kis_clipboard.cc
kis_config.cc
kis_config_notifier.cpp
kis_config_notifier.cpp
kis_color_data_list.cpp
kis_control_frame.cpp
kis_composite_ops_model.cc
......@@ -66,38 +66,38 @@ set(kritaui_LIB_SRCS
kis_cursor.cc
kis_custom_palette.cc
kis_custom_pattern.cc
kis_doc2.cc
kis_exposure_visitor.cc
kis_doc2.cc
kis_exposure_visitor.cc
kis_factory2.cc
kis_filter_handler.cc
kis_filter_manager.cc
kis_filter_handler.cc
kis_filter_manager.cc
kis_filters_model.cc
kis_histogram_view.cc
kis_histogram_view.cc
kis_image_manager.cc
kis_image_view_converter.cpp
kis_import_catcher.cc
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_manager.cpp
kis_node_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_manager.cc
kis_paintop_box.cc
kis_painting_assistant.cc
kis_painting_assistants_manager.cc
kis_paintop_box.cc
kis_palette_manager.cpp
kis_popup_palette.cpp
kis_png_converter.cpp
kis_preference_set_registry.cpp
kis_print_job.cpp
kis_resource_server_provider.cpp
kis_resource_server_provider.cpp
kis_selection_decoration.cc
kis_selection_manager.cc
kis_selection_manager.cc
kis_statusbar.cc
kis_view2.cpp
kis_view2.cpp
kis_zoom_manager.cc
thememanager.cpp
ko_favorite_resource_manager.cpp
......@@ -108,11 +108,11 @@ set(kritaui_LIB_SRCS
kisexiv2/kis_xmp_io.cpp
kra/kis_kra_utils.cpp
kra/kis_kra_load_visitor.cpp
kra/kis_kra_loader.cpp
kra/kis_kra_save_visitor.cpp
kra/kis_kra_loader.cpp
kra/kis_kra_save_visitor.cpp
kra/kis_kra_saver.cpp
kra/kis_kra_savexml_visitor.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl_canvas2.cpp
opengl/kis_opengl_image_textures.cpp
opengl/kis_texture_tile.cpp
......@@ -127,17 +127,17 @@ set(kritaui_LIB_SRCS
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_shape_tool_helper.cpp
tool/kis_tool.cc
tool/kis_tool_freehand.cc
tool/kis_selection_tool_helper.cpp
tool/kis_selection_tool_config_widget_helper.cpp
tool/kis_shape_tool_helper.cpp
tool/kis_tool.cc
tool/kis_tool_freehand.cc
tool/kis_painting_information_builder.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_paint.cc
tool/kis_tool_shape.cc
tool/kis_tool_select_base.cpp
tool/kis_tool_ellipse_base.cpp
......@@ -147,36 +147,36 @@ set(kritaui_LIB_SRCS
tool/kis_resources_snapshot.cpp
tool/strokes/freehand_stroke.cpp
tool/strokes/kis_painter_based_stroke_strategy.cpp
widgets/kis_channelflags_widget.cpp
widgets/kis_channelflags_widget.cpp
widgets/kis_cmb_composite.cc
widgets/kis_paintop_list_widget.cpp
widgets/kis_cmb_idlist.cc
widgets/kis_cmb_idlist.cc
widgets/kis_color_space_selector.cc
widgets/kis_curve_widget.cpp
widgets/kis_custom_image_widget.cc
widgets/kis_custom_image_widget.cc
widgets/kis_double_widget.cc
widgets/kis_filter_selector_widget.cc
widgets/kis_gradient_chooser.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_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_paintop_presets_popup.cpp
widgets/kis_paintop_presets_chooser_popup.cpp
widgets/kis_pattern_chooser.cc
widgets/kis_popup_button.cc
widgets/kis_popup_button.cc
widgets/kis_preset_chooser.cpp
widgets/kis_progress_widget.cpp
widgets/kis_selection_options.cc
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_tree_view_popup.cc
widgets/kis_tree_view_popup.cc
widgets/kis_slider_spin_box.cpp
widgets/kis_wdg_generator.cpp
widgets/kis_workspace_chooser.cpp
......@@ -187,6 +187,16 @@ set(kritaui_LIB_SRCS
widgets/kis_floating_message.cpp
# widgets/kis_light_source.cpp
# widgets/kis_light_stage.cpp
input/kis_input_manager.cpp
input/kis_shortcut.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_show_palette_action.cpp
input/kis_change_primary_setting_action.cpp
)
if(HAVE_OPENGL)
......
......@@ -65,6 +65,8 @@
#include <ko_favorite_resource_manager.h>
#include <kis_paintop_box.h>
#include "input/kis_input_manager.h"
struct KisCanvas2::KisCanvas2Private
{
......@@ -103,6 +105,8 @@ public:
#endif
KisPrescaledProjectionSP prescaledProjection;
bool vastScrolling;
KisInputManager* inputManager;
};
KisCanvas2::KisCanvas2(KisCoordinatesConverter* coordConverter, KisView2 * view, KoShapeBasedDocumentBase * sc)
......@@ -111,6 +115,9 @@ KisCanvas2::KisCanvas2(KisCoordinatesConverter* coordConverter, KisView2 * view,
{
// a bit of duplication from slotConfigChanged()
KisConfig cfg;
m_d->inputManager = new KisInputManager(this, m_d->toolProxy);
m_d->vastScrolling = cfg.vastScrolling();
createCanvas(cfg.useOpenGL());
......@@ -161,6 +168,7 @@ void KisCanvas2::setCanvasWidget(QWidget * widget)
widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setMouseTracking(true);
widget->setAcceptDrops(true);
widget->installEventFilter(m_d->inputManager);
KoCanvasControllerWidget *controller = dynamic_cast<KoCanvasControllerWidget*>(canvasController());
if (controller) {
Q_ASSERT(controller->canvas() == this);
......@@ -394,7 +402,7 @@ void KisCanvas2::connectCurrentImage()
SLOT(startResizingImage(qint32, qint32)),
Qt::DirectConnection);
connect(this, SIGNAL(sigContinueResizeImage(qint32, qint32)),
this, SLOT(finishResisingImage(qint32, qint32)));
this, SLOT(finishResizingImage(qint32, qint32)));
startResizingImage(image->width(), image->height());
......@@ -475,7 +483,7 @@ void KisCanvas2::startResizingImage(qint32 w, qint32 h)
}
}
void KisCanvas2::finishResisingImage(qint32 w, qint32 h)
void KisCanvas2::finishResizingImage(qint32 w, qint32 h)
{
if (m_d->currentCanvasIsOpenGL) {
#ifdef HAVE_OPENGL
......@@ -483,7 +491,7 @@ void KisCanvas2::finishResisingImage(qint32 w, qint32 h)
m_d->openGLImageTextures->slotImageSizeChanged(w, h);
#else
Q_ASSERT_X(0, "finishResisingImage()", "Bad use of finishResisingImage(). It shouldn't have happened =(");
Q_ASSERT_X(0, "finishResizingImage()", "Bad use of finishResizingImage(). It shouldn't have happened =(");
#endif
} else {
Q_ASSERT(m_d->prescaledProjection);
......
......@@ -171,7 +171,7 @@ public slots:
void updateCanvasProjection(KisUpdateInfoSP info);
void startResizingImage(qint32 w, qint32 h);
void finishResisingImage(qint32 w, qint32 h);
void finishResizingImage(qint32 w, qint32 h);
/// adjust the origin of the document
void adjustOrigin();
......
......@@ -55,7 +55,7 @@ public:
const KoViewConverter * viewConverter;
KoToolProxy * toolProxy;
QTimer blockMouseEvent;
bool ignorenextMouseEventExceptRightMiddleClick; // HACK work around Qt bug not sending tablet right/dblclick http://bugreports.qt.nokia.com/browse/QTBUG-8598
QColor borderColor;
};
......@@ -180,110 +180,6 @@ KoToolProxy *KisCanvasWidgetBase::toolProxy()
return m_d->toolProxy;
}
QPointF KisCanvasWidgetBase::mouseEventWidgetToDocument(const QPoint& mousePosition) const
{
const qreal PIXEL_CENTRE_OFFSET = 0.5;
const QPointF pixelCentre(mousePosition.x() + PIXEL_CENTRE_OFFSET,
mousePosition.y() + PIXEL_CENTRE_OFFSET);
return m_d->coordinatesConverter->widgetToDocument(pixelCentre);
}
void KisCanvasWidgetBase::processMouseMoveEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick )
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseMoveEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processContextMenuEvent(QContextMenuEvent *e)
{
Q_UNUSED(e);
// m_d->canvas->view()->unplugActionList("flake_tool_actions");
// m_d->canvas->view()->plugActionList("flake_tool_actions",
// m_d->toolProxy->popupActionList());
// QMenu *menu = dynamic_cast<QMenu*>(m_d->canvas->view()->factory()->container("image_popup", m_d->canvas->view()));
// if (menu)
// menu->exec(e->globalPos());
}
void KisCanvasWidgetBase::processMousePressEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick)
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mousePressEvent(e, mouseEventWidgetToDocument(e->pos()));
}
e->setAccepted(true);
return;
}
if (m_d->blockMouseEvent.isActive()) {
e->setAccepted(true);
return;
}
m_d->toolProxy->mousePressEvent(e, mouseEventWidgetToDocument(e->pos()));
e->setAccepted(true);
}
void KisCanvasWidgetBase::processMouseReleaseEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick)
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mouseReleaseEvent(e, mouseEventWidgetToDocument(e->pos()));
}
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseReleaseEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processMouseDoubleClickEvent(QMouseEvent *e)
{
if (m_d->ignorenextMouseEventExceptRightMiddleClick )
{
m_d->ignorenextMouseEventExceptRightMiddleClick = false;
if (e->button() == Qt::RightButton || e->button() == Qt::MidButton)
{
m_d->toolProxy->mouseDoubleClickEvent(e, mouseEventWidgetToDocument(e->pos()));
}
return;
}
if (m_d->blockMouseEvent.isActive()) {
return;
}
m_d->toolProxy->mouseDoubleClickEvent(e, mouseEventWidgetToDocument(e->pos()));
}
void KisCanvasWidgetBase::processKeyPressEvent(QKeyEvent *e)
{
m_d->toolProxy->keyPressEvent(e);
if (! e->isAccepted()) {
if (e->key() == Qt::Key_Backtab
|| (e->key() == Qt::Key_Tab && (e->modifiers() & Qt::ShiftModifier)))
callFocusNextPrevChild(false);
else if (e->key() == Qt::Key_Tab)
callFocusNextPrevChild(true);
}
}
void KisCanvasWidgetBase::processKeyReleaseEvent(QKeyEvent *e)
{
m_d->toolProxy->keyReleaseEvent(e);
}
QVariant KisCanvasWidgetBase::processInputMethodQuery(Qt::InputMethodQuery query) const
{
if (query == Qt::ImMicroFocus) {
......@@ -299,24 +195,3 @@ void KisCanvasWidgetBase::processInputMethodEvent(QInputMethodEvent *event)
{
m_d->toolProxy->inputMethodEvent(event);
}
void KisCanvasWidgetBase::processTabletEvent(QTabletEvent *e)
{
widget()->setFocus(Qt::OtherFocusReason);
m_d->blockMouseEvent.start(100);
const QPointF pos = e->hiResGlobalPos() - widget()->mapToGlobal(QPoint(0, 0));
m_d->toolProxy->tabletEvent(e, m_d->coordinatesConverter->widgetToDocument(pos));
// HACK
e->ignore();
m_d->ignorenextMouseEventExceptRightMiddleClick = true;
// HACK
}
void KisCanvasWidgetBase::processWheelEvent(QWheelEvent *e)
{
m_d->toolProxy->wheelEvent(e, m_d->coordinatesConverter->widgetToDocument(e->pos()));
}
......@@ -78,34 +78,16 @@ protected:
KisCoordinatesConverter* coordinatesConverter();
/**
* Convert a mouse event widget coordinate to a document
* coordinate, applying an offset to convert the integer
* coordinate to floating point.
*
* @param mousePosition mouse event coordinate
*/
QPointF mouseEventWidgetToDocument(const QPoint& mousePosition) const;
/**
* Event handlers to be called by derived canvas event handlers.
* All common event processing is carried out by these
* All common event processing is carried out by these
* functions.
*/
void processKeyPressEvent(QKeyEvent *e);
void processKeyReleaseEvent(QKeyEvent *e);
void processMousePressEvent(QMouseEvent *e);
void processMouseMoveEvent(QMouseEvent *e);
void processMouseReleaseEvent(QMouseEvent *e);
void processMouseDoubleClickEvent(QMouseEvent *e);
void processContextMenuEvent(QContextMenuEvent *e);
void processTabletEvent(QTabletEvent *e);
void processWheelEvent(QWheelEvent *e);
QVariant processInputMethodQuery(Qt::InputMethodQuery query) const;
void processInputMethodEvent(QInputMethodEvent *event);
void notifyConfigChanged();
/// To be implemented by the derived canvas
/// To be implemented by the derived canvas
virtual bool callFocusNextPrevChild(bool next) = 0;
private:
......
......@@ -178,56 +178,6 @@ bool KisQPainterCanvas::event(QEvent *e)
return QWidget::event(e);
}
void KisQPainterCanvas::enterEvent(QEvent* e)
{
if(!hasFocus()) {
setFocus();
}
QWidget::enterEvent(e);
}
void KisQPainterCanvas::leaveEvent(QEvent* e)
{
QWidget::leaveEvent(e);
}
void KisQPainterCanvas::mouseMoveEvent(QMouseEvent *e)
{
processMouseMoveEvent(e);
}
void KisQPainterCanvas::contextMenuEvent(QContextMenuEvent *e)
{
processContextMenuEvent(e);
}
void KisQPainterCanvas::mousePressEvent(QMouseEvent *e)
{
m_d->smooth = false;
processMousePressEvent(e);
}
void KisQPainterCanvas::mouseReleaseEvent(QMouseEvent *e)
{
m_d->smooth = true;
processMouseReleaseEvent(e);
}
void KisQPainterCanvas::mouseDoubleClickEvent(QMouseEvent *e)
{
processMouseDoubleClickEvent(e);
}
void KisQPainterCanvas::keyPressEvent(QKeyEvent *e)
{
processKeyPressEvent(e);
}
void KisQPainterCanvas::keyReleaseEvent(QKeyEvent *e)
{
processKeyReleaseEvent(e);
}
QVariant KisQPainterCanvas::inputMethodQuery(Qt::InputMethodQuery query) const
{
return processInputMethodQuery(query);
......@@ -238,16 +188,6 @@ void KisQPainterCanvas::inputMethodEvent(QInputMethodEvent *event)
processInputMethodEvent(event);
}
void KisQPainterCanvas::tabletEvent(QTabletEvent *e)
{
processTabletEvent(e);
}
void KisQPainterCanvas::wheelEvent(QWheelEvent *e)
{
processWheelEvent(e);
}
void KisQPainterCanvas::resizeEvent(QResizeEvent *e)
{
QSize size(e->size());
......
......@@ -61,42 +61,9 @@ public: // QWidget
/// reimplemented method from superclass
bool event(QEvent *);
/// reimplemented method from superclass
void enterEvent(QEvent* e);
/// reimplemented method from superclass
void leaveEvent(QEvent* e);
/// reimplemented method from superclass
void keyPressEvent(QKeyEvent *e);
/// reimplemented method from superclass
void mouseMoveEvent(QMouseEvent *e);
/// reimplemented method from superclass
void contextMenuEvent(QContextMenuEvent *e);
/// reimplemented method from superclass
void mousePressEvent(QMouseEvent *e);
/// reimplemented method from superclass
void mouseReleaseEvent(QMouseEvent *e);
/// reimplemented method from superclass
void mouseDoubleClickEvent(QMouseEvent *e);
/// reimplemented method from superclass
void keyReleaseEvent(QKeyEvent *e);
/// reimplemented method from superclass
void paintEvent(QPaintEvent * ev);
/// reimplemented method from superclass
void tabletEvent(QTabletEvent *e);
/// reimplemented method from superclass
void wheelEvent(QWheelEvent *e);
/// reimplemented method from superclass
void resizeEvent(QResizeEvent *e);