diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index cae66b748e..3ae8ff3d8d 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -1,554 +1,556 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/qtlockedfile ${EXIV2_INCLUDE_DIR} ) include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR} ${OCIO_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ) add_subdirectory( tests ) if (APPLE) find_library(FOUNDATION_LIBRARY Foundation) endif () set(kritaui_LIB_SRCS canvas/kis_canvas_widget_base.cpp canvas/kis_canvas2.cpp canvas/kis_canvas_updates_compressor.cpp canvas/kis_canvas_controller.cpp canvas/kis_paintop_transformation_connector.cpp canvas/kis_display_color_converter.cpp canvas/kis_display_filter.cpp canvas/kis_exposure_gamma_correction_interface.cpp canvas/kis_tool_proxy.cpp canvas/kis_canvas_decoration.cc canvas/kis_coordinates_converter.cpp canvas/kis_grid_manager.cpp canvas/kis_grid_decoration.cpp canvas/kis_grid_config.cpp canvas/kis_prescaled_projection.cpp canvas/kis_qpainter_canvas.cpp canvas/kis_projection_backend.cpp canvas/kis_update_info.cpp canvas/kis_image_patch.cpp canvas/kis_image_pyramid.cpp canvas/kis_infinity_manager.cpp canvas/kis_change_guides_command.cpp canvas/kis_guides_decoration.cpp canvas/kis_guides_manager.cpp canvas/kis_guides_config.cpp canvas/kis_snap_config.cpp canvas/kis_snap_line_strategy.cpp canvas/KisSnapPointStrategy.cpp dialogs/kis_about_application.cpp dialogs/kis_dlg_adj_layer_props.cc dialogs/kis_dlg_adjustment_layer.cc dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_generator_layer.cpp dialogs/kis_dlg_file_layer.cpp dialogs/kis_dlg_filter.cpp dialogs/kis_dlg_stroke_selection_properties.cpp dialogs/kis_dlg_send_telemetry.cpp dialogs/kis_dlg_image_properties.cc dialogs/kis_dlg_layer_properties.cc dialogs/kis_dlg_preferences.cc dialogs/slider_and_spin_box_sync.cpp dialogs/kis_dlg_blacklist_cleanup.cpp dialogs/kis_dlg_layer_style.cpp dialogs/kis_dlg_png_import.cpp dialogs/kis_dlg_import_image_sequence.cpp dialogs/kis_delayed_save_dialog.cpp dialogs/kis_dlg_internal_color_selector.cpp flake/kis_node_dummies_graph.cpp flake/kis_dummies_facade_base.cpp flake/kis_dummies_facade.cpp flake/kis_node_shapes_graph.cpp flake/kis_node_shape.cpp flake/kis_shape_controller.cpp flake/kis_shape_layer.cc flake/kis_shape_layer_canvas.cpp flake/kis_shape_selection.cpp flake/kis_shape_selection_canvas.cpp flake/kis_shape_selection_model.cpp flake/kis_take_all_shapes_command.cpp brushhud/kis_uniform_paintop_property_widget.cpp brushhud/kis_brush_hud.cpp brushhud/kis_round_hud_button.cpp brushhud/kis_dlg_brush_hud_config.cpp brushhud/kis_brush_hud_properties_list.cpp brushhud/kis_brush_hud_properties_config.cpp kis_aspect_ratio_locker.cpp kis_autogradient.cc kis_bookmarked_configurations_editor.cc kis_bookmarked_configurations_model.cc kis_bookmarked_filter_configurations_model.cc kis_base_option.cpp kis_canvas_resource_provider.cpp kis_derived_resources.cpp kis_categories_mapper.cpp kis_categorized_list_model.cpp kis_categorized_item_delegate.cpp kis_clipboard.cc kis_config.cc kis_config_notifier.cpp kis_control_frame.cpp kis_composite_ops_model.cc kis_paint_ops_model.cpp kis_cursor.cc kis_cursor_cache.cpp kis_custom_pattern.cc kis_file_layer.cpp kis_safe_document_loader.cpp kis_splash_screen.cpp kis_filter_manager.cc kis_filters_model.cc kis_histogram_view.cc KisImageBarrierLockerWithFeedback.cpp kis_image_manager.cc kis_image_view_converter.cpp kis_import_catcher.cc kis_layer_manager.cc kis_mask_manager.cc kis_mimedata.cpp kis_node_commands_adapter.cpp kis_node_manager.cpp kis_node_juggler_compressed.cpp kis_node_selection_adapter.cpp kis_node_insertion_adapter.cpp kis_node_model.cpp kis_node_filter_proxy_model.cpp kis_model_index_converter_base.cpp kis_model_index_converter.cpp kis_model_index_converter_show_all.cpp kis_painting_assistant.cc kis_painting_assistants_decoration.cpp kis_painting_assistants_manager.cpp kis_paintop_box.cc kis_paintop_option.cpp kis_paintop_options_model.cpp kis_paintop_settings_widget.cpp kis_popup_palette.cpp kis_png_converter.cpp kis_preference_set_registry.cpp kis_script_manager.cpp kis_resource_server_provider.cpp KisSelectedShapesProxy.cpp kis_selection_decoration.cc kis_selection_manager.cc kis_statusbar.cc kis_zoom_manager.cc kis_favorite_resource_manager.cpp kis_workspace_resource.cpp kis_action.cpp kis_action_manager.cpp kis_view_plugin.cpp kis_canvas_controls_manager.cpp kis_tooltip_manager.cpp kis_multinode_property.cpp kis_stopgradient_editor.cpp kisexiv2/kis_exif_io.cpp kisexiv2/kis_exiv2.cpp kisexiv2/kis_iptc_io.cpp kisexiv2/kis_xmp_io.cpp opengl/kis_opengl.cpp opengl/kis_opengl_canvas2.cpp opengl/kis_opengl_canvas_debugger.cpp opengl/kis_opengl_image_textures.cpp opengl/kis_texture_tile.cpp opengl/kis_opengl_shader_loader.cpp kis_fps_decoration.cpp recorder/kis_node_query_path_editor.cc recorder/kis_recorded_action_creator.cc recorder/kis_recorded_action_creator_factory.cc recorder/kis_recorded_action_creator_factory_registry.cc recorder/kis_recorded_action_editor_factory.cc recorder/kis_recorded_action_editor_factory_registry.cc recorder/kis_recorded_filter_action_editor.cc recorder/kis_recorded_filter_action_creator.cpp recorder/kis_recorded_paint_action_editor.cc tool/kis_selection_tool_helper.cpp tool/kis_selection_tool_config_widget_helper.cpp tool/kis_rectangle_constraint_widget.cpp tool/kis_shape_tool_helper.cpp tool/kis_tool.cc tool/kis_delegated_tool_policies.cpp tool/kis_tool_freehand.cc tool/kis_speed_smoother.cpp tool/kis_painting_information_builder.cpp tool/kis_stabilized_events_sampler.cpp tool/kis_tool_freehand_helper.cpp tool/kis_tool_multihand_helper.cpp tool/kis_figure_painting_tool_helper.cpp tool/kis_recording_adapter.cpp tool/kis_tool_paint.cc tool/kis_tool_shape.cc tool/kis_tool_ellipse_base.cpp tool/kis_tool_rectangle_base.cpp tool/kis_tool_polyline_base.cpp tool/kis_tool_utils.cpp tool/kis_resources_snapshot.cpp tool/kis_smoothing_options.cpp tool/KisStabilizerDelayedPaintHelper.cpp tool/strokes/freehand_stroke.cpp tool/strokes/kis_painter_based_stroke_strategy.cpp tool/strokes/kis_filter_stroke_strategy.cpp tool/strokes/kis_color_picker_stroke_strategy.cpp widgets/kis_cmb_composite.cc widgets/kis_cmb_contour.cpp widgets/kis_cmb_gradient.cpp widgets/kis_paintop_list_widget.cpp widgets/kis_cmb_idlist.cc widgets/kis_color_space_selector.cc widgets/kis_advanced_color_space_selector.cc widgets/kis_cie_tongue_widget.cpp widgets/kis_tone_curve_widget.cpp widgets/kis_curve_widget.cpp widgets/kis_custom_image_widget.cc widgets/kis_image_from_clipboard_widget.cpp widgets/kis_double_widget.cc widgets/kis_filter_selector_widget.cc widgets/kis_gradient_chooser.cc widgets/kis_gradient_slider_widget.cc widgets/kis_gradient_slider.cpp widgets/kis_iconwidget.cc widgets/kis_mask_widgets.cpp widgets/kis_meta_data_merge_strategy_chooser_widget.cc widgets/kis_multi_bool_filter_widget.cc widgets/kis_multi_double_filter_widget.cc widgets/kis_multi_integer_filter_widget.cc widgets/kis_multipliers_double_slider_spinbox.cpp widgets/kis_paintop_presets_popup.cpp widgets/kis_tool_options_popup.cpp widgets/kis_paintop_presets_chooser_popup.cpp widgets/kis_pattern_chooser.cc widgets/kis_popup_button.cc widgets/kis_preset_chooser.cpp widgets/kis_progress_widget.cpp widgets/kis_selection_options.cc widgets/kis_scratch_pad.cpp widgets/kis_scratch_pad_event_filter.cpp widgets/kis_preset_selector_strip.cpp widgets/kis_slider_spin_box.cpp widgets/kis_size_group.cpp widgets/kis_size_group_p.cpp widgets/kis_wdg_generator.cpp widgets/kis_workspace_chooser.cpp widgets/squeezedcombobox.cpp widgets/kis_categorized_list_view.cpp widgets/kis_widget_chooser.cpp widgets/kis_tool_button.cpp widgets/kis_floating_message.cpp widgets/kis_lod_availability_widget.cpp widgets/kis_color_label_selector_widget.cpp widgets/kis_color_filter_combo.cpp widgets/kis_elided_label.cpp widgets/kis_stopgradient_slider_widget.cpp widgets/kis_spinbox_color_selector.cpp widgets/kis_screen_color_picker.cpp widgets/KoDualColorButton.cpp widgets/kis_color_input.cpp widgets/kis_color_button.cpp widgets/KisVisualColorSelector.cpp widgets/KisVisualColorSelectorShape.cpp widgets/KisVisualEllipticalSelectorShape.cpp widgets/KisVisualRectangleSelectorShape.cpp widgets/KisVisualTriangleSelectorShape.cpp widgets/KoStrokeConfigWidget.cpp widgets/KoFillConfigWidget.cpp widgets/KoShapeFillWrapper.cpp utils/kis_document_aware_spin_box_unit_manager.cpp input/kis_input_manager.cpp input/kis_input_manager_p.cpp input/kis_extended_modifiers_mapper.cpp input/kis_abstract_input_action.cpp input/kis_tool_invocation_action.cpp input/kis_pan_action.cpp input/kis_alternate_invocation_action.cpp input/kis_rotate_canvas_action.cpp input/kis_zoom_action.cpp input/kis_change_frame_action.cpp input/kis_gamma_exposure_action.cpp input/kis_show_palette_action.cpp input/kis_change_primary_setting_action.cpp input/kis_abstract_shortcut.cpp input/kis_single_action_shortcut.cpp input/kis_stroke_shortcut.cpp input/kis_shortcut_matcher.cpp input/kis_select_layer_action.cpp operations/kis_operation.cpp operations/kis_operation_configuration.cpp operations/kis_operation_registry.cpp operations/kis_operation_ui_factory.cpp operations/kis_operation_ui_widget.cpp operations/kis_filter_selection_operation.cpp actions/kis_selection_action_factories.cpp actions/KisPasteActionFactory.cpp input/kis_touch_shortcut.cpp kis_document_undo_store.cpp kis_transaction_based_command.cpp kis_gui_context_command.cpp kis_gui_context_command_p.cpp input/kis_tablet_debugger.cpp input/kis_input_profile_manager.cpp input/kis_input_profile.cpp input/kis_shortcut_configuration.cpp input/config/kis_input_configuration_page.cpp input/config/kis_edit_profiles_dialog.cpp input/config/kis_input_profile_model.cpp input/config/kis_input_configuration_page_item.cpp input/config/kis_action_shortcuts_model.cpp input/config/kis_input_type_delegate.cpp input/config/kis_input_mode_delegate.cpp input/config/kis_input_button.cpp input/config/kis_input_editor_delegate.cpp input/config/kis_mouse_input_editor.cpp input/config/kis_wheel_input_editor.cpp input/config/kis_key_input_editor.cpp processing/fill_processing_visitor.cpp kis_asl_layer_style_serializer.cpp kis_psd_layer_style_resource.cpp canvas/kis_mirror_axis.cpp kis_abstract_perspective_grid.cpp KisApplication.cpp KisAutoSaveRecoveryDialog.cpp KisDetailsPane.cpp KisDocument.cpp KisNodeDelegate.cpp kis_node_view_visibility_delegate.cpp KisNodeToolTip.cpp KisNodeView.cpp kis_node_view_color_scheme.cpp KisImportExportFilter.cpp KisFilterEntry.cpp KisImportExportManager.cpp kis_async_action_feedback.cpp KisMainWindow.cpp KisOpenPane.cpp KisPart.cpp KisPrintJob.cpp KisTemplate.cpp KisTemplateCreateDia.cpp KisTemplateGroup.cpp KisTemplates.cpp KisTemplatesPane.cpp KisTemplateTree.cpp KisUndoStackAction.cpp KisView.cpp thememanager.cpp kis_mainwindow_observer.cpp KisViewManager.cpp kis_mirror_manager.cpp qtlockedfile/qtlockedfile.cpp qtsingleapplication/qtlocalpeer.cpp qtsingleapplication/qtsingleapplication.cpp KisResourceBundle.cpp KisResourceBundleManifest.cpp kis_md5_generator.cpp KisApplicationArguments.cpp KisNetworkAccessManager.cpp KisMultiFeedRSSModel.cpp KisRemoteFileFetcher.cpp KisPaletteModel.cpp kis_palette_delegate.cpp kis_palette_view.cpp KisColorsetChooser.cpp KisSaveGroupVisitor.cpp + + kis_telemetry_abstruct.cpp ) if(WIN32) if (NOT Qt5Gui_PRIVATE_INCLUDE_DIRS) message(FATAL_ERROR "Qt5Gui Private header are missing!") endif() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/kis_tablet_event.cpp input/wintab/kis_tablet_support_win.cpp input/wintab/kis_screen_size_choice_dialog.cpp qtlockedfile/qtlockedfile_win.cpp ) include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) endif() set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} kis_animation_frame_cache.cpp kis_animation_cache_populator.cpp KisAnimationCacheRegenerator.cpp dialogs/KisAnimationCacheUpdateProgressDialog.cpp canvas/kis_animation_player.cpp kis_animation_exporter.cpp kis_animation_importer.cpp KisSyncedAudioPlayback.cpp ) if(UNIX) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/kis_tablet_event.cpp input/wintab/kis_tablet_support.cpp qtlockedfile/qtlockedfile_unix.cpp ) if(NOT APPLE) set(kritaui_LIB_SRCS ${kritaui_LIB_SRCS} input/wintab/kis_tablet_support_x11.cpp input/wintab/qxcbconnection_xi2.cpp input/wintab/qxcbconnection.cpp input/wintab/kis_xi2_event_filter.cpp ) endif() endif() ki18n_wrap_ui(kritaui_LIB_SRCS widgets/KoFillConfigWidget.ui forms/wdgdlgpngimport.ui forms/wdgfullscreensettings.ui forms/wdgautogradient.ui forms/wdggeneralsettings.ui forms/wdgperformancesettings.ui forms/wdggenerators.ui forms/wdgbookmarkedconfigurationseditor.ui forms/wdgapplyprofile.ui forms/wdgcustompattern.ui forms/wdglayerproperties.ui forms/wdgcolorsettings.ui forms/wdgtabletsettings.ui forms/wdgcolorspaceselector.ui forms/wdgcolorspaceselectoradvanced.ui forms/wdgdisplaysettings.ui forms/kis_previewwidgetbase.ui forms/kis_matrix_widget.ui forms/wdgselectionoptions.ui forms/wdggeometryoptions.ui forms/wdgnewimage.ui forms/wdgimageproperties.ui forms/wdgmaskfromselection.ui forms/wdgmasksource.ui forms/wdgfilterdialog.ui forms/wdgmetadatamergestrategychooser.ui forms/wdgpaintoppresets.ui forms/wdgpaintopsettings.ui forms/wdgdlggeneratorlayer.ui forms/wdgdlgfilelayer.ui forms/wdgfilterselector.ui forms/wdgfilternodecreation.ui forms/wdgpaintactioneditor.ui forms/wdgmultipliersdoublesliderspinbox.ui forms/wdgnodequerypatheditor.ui forms/wdgpresetselectorstrip.ui forms/wdgdlgblacklistcleanup.ui forms/wdgrectangleconstraints.ui forms/wdgimportimagesequence.ui forms/wdgstrokeselectionproperties.ui forms/KisDetailsPaneBase.ui forms/KisOpenPaneBase.ui forms/wdgstopgradienteditor.ui forms/wdgtelemetry.ui brushhud/kis_dlg_brush_hud_config.ui forms/wdgdlginternalcolorselector.ui dialogs/kis_delayed_save_dialog.ui input/config/kis_input_configuration_page.ui input/config/kis_edit_profiles_dialog.ui input/config/kis_input_configuration_page_item.ui input/config/kis_mouse_input_editor.ui input/config/kis_wheel_input_editor.ui input/config/kis_key_input_editor.ui layerstyles/wdgBevelAndEmboss.ui layerstyles/wdgblendingoptions.ui layerstyles/WdgColorOverlay.ui layerstyles/wdgContour.ui layerstyles/wdgdropshadow.ui layerstyles/WdgGradientOverlay.ui layerstyles/wdgInnerGlow.ui layerstyles/wdglayerstyles.ui layerstyles/WdgPatternOverlay.ui layerstyles/WdgSatin.ui layerstyles/WdgStroke.ui layerstyles/wdgstylesselector.ui layerstyles/wdgTexture.ui wdgsplash.ui input/wintab/kis_screen_size_choice_dialog.ui ) QT5_WRAP_CPP(kritaui_HEADERS_MOC KisNodePropertyAction_p.h) add_library(kritaui SHARED ${kritaui_HEADERS_MOC} ${kritaui_LIB_SRCS} ) generate_export_header(kritaui BASE_NAME kritaui) target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::ItemViews Qt5::Network kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils ${PNG_LIBRARIES} ${EXIV2_LIBRARIES} ) if (HAVE_QT_MULTIMEDIA) target_link_libraries(kritaui Qt5::Multimedia) endif() if (HAVE_KIO) target_link_libraries(kritaui KF5::KIOCore) endif() if (NOT WIN32 AND NOT APPLE) target_link_libraries(kritaui ${X11_X11_LIB} ${X11_Xinput_LIB} ${XCB_LIBRARIES}) endif() if(APPLE) target_link_libraries(kritaui ${FOUNDATION_LIBRARY}) endif () target_link_libraries(kritaui ${OPENEXR_LIBRARIES}) # Add VSync disable workaround if(NOT WIN32 AND NOT APPLE) target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras) endif() if(X11_FOUND) target_link_libraries(kritaui Qt5::X11Extras ${X11_LIBRARIES}) endif() target_include_directories(kritaui PUBLIC $ $ $ $ $ $ $ ) set_target_properties(kritaui PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaui ${INSTALL_TARGETS_DEFAULT_ARGS}) if (APPLE) install(FILES osx.stylesheet DESTINATION ${DATA_INSTALL_DIR}/krita) endif () diff --git a/libs/ui/kis_telemetry_abstruct.cpp b/libs/ui/kis_telemetry_abstruct.cpp new file mode 100644 index 0000000000..f3a7d0c28f --- /dev/null +++ b/libs/ui/kis_telemetry_abstruct.cpp @@ -0,0 +1,8 @@ +#include "kis_telemetry_abstruct.h" + +QString KisTelemetryAbstruct::getToolId(QString id) +{ + QString toolId = "Tool/"; + toolId += id; + return toolId; +} diff --git a/libs/ui/kis_telemetry_abstruct.h b/libs/ui/kis_telemetry_abstruct.h index 94f4a6d263..3aa1353af1 100644 --- a/libs/ui/kis_telemetry_abstruct.h +++ b/libs/ui/kis_telemetry_abstruct.h @@ -1,45 +1,47 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_ABSTRUCT_H #define KIS_TELEMETRY_ABSTRUCT_H #include "QScopedPointer" #include "kritaflake_export.h" #include #include #include #include #include -#include class KRITAFLAKE_EXPORT KisTelemetryAbstruct { public: virtual KUserFeedback::Provider* provider() = 0; virtual void sendData() = 0; - virtual void storeData(QVector& args) = 0; - virtual ~KisTelemetryAbstruct(){} + virtual void getTimeTicket(QString id) = 0; + virtual void putTimeTicket(QString id) = 0; + QString getToolId(QString id); + virtual ~KisTelemetryAbstruct() {} protected: QString m_adress = "http://localhost:8080/"; // QString m_adress = "http://akapustin.me:8080/"; }; -#endif + +#endif diff --git a/libs/ui/tool/kis_tool.cc b/libs/ui/tool/kis_tool.cc index 2e50593403..4e223fef87 100644 --- a/libs/ui/tool/kis_tool.cc +++ b/libs/ui/tool/kis_tool.cc @@ -1,711 +1,703 @@ /* * Copyright (c) 2006, 2010 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_tool.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_node_manager.h" #include #include #include #include #include #include #include #include #include #include #include #include "opengl/kis_opengl_canvas2.h" #include "kis_canvas_resource_provider.h" #include "canvas/kis_canvas2.h" #include "kis_coordinates_converter.h" #include "filter/kis_filter_configuration.h" #include "kis_config.h" #include "kis_config_notifier.h" #include "kis_cursor.h" #include #include #include "kis_resources_snapshot.h" #include #include "kis_action_registry.h" #include "kis_tool_utils.h" #include "KisPart.h" -#include "tuple" +#include struct Q_DECL_HIDDEN KisTool::Private { QCursor cursor; // the cursor that should be shown on tool activation. // From the canvas resources KoPattern* currentPattern{0}; KoAbstractGradient* currentGradient{0}; KoColor currentFgColor; KoColor currentBgColor; float currentExposure{1.0}; KisFilterConfigurationSP currentGenerator; QWidget* optionWidget{0}; ToolMode m_mode{HOVER_MODE}; bool m_isActive{false}; }; KisTool::KisTool(KoCanvasBase * canvas, const QCursor & cursor) : KoToolBase(canvas) , d(new Private) { d->cursor = cursor; connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetCursorStyle())); connect(this, SIGNAL(isActiveChanged()), SLOT(resetCursorStyle())); KActionCollection *collection = this->canvas()->canvasController()->actionCollection(); if (!collection->action("toggle_fg_bg")) { QAction *toggleFgBg = KisActionRegistry::instance()->makeQAction("toggle_fg_bg", collection); collection->addAction("toggle_fg_bg", toggleFgBg); } if (!collection->action("reset_fg_bg")) { QAction *toggleFgBg = KisActionRegistry::instance()->makeQAction("reset_fg_bg", collection); collection->addAction("reset_fg_bg", toggleFgBg); } addAction("toggle_fg_bg", dynamic_cast(collection->action("toggle_fg_bg"))); addAction("reset_fg_bg", dynamic_cast(collection->action("reset_fg_bg"))); } KisTool::~KisTool() { delete d; } void KisTool::activate(ToolActivation activation, const QSet &shapes) { KoToolBase::activate(activation, shapes); qDebug()<provider(KisPart::RegularProvider); if(KisPart::instance()->provider(KisPart::RegularProvider)){ KisTelemetryAbstruct * provider = KisPart::instance()->provider(KisPart::RegularProvider); - QVector temp; - temp.push_back("Deactivate"); - temp.push_back(toolId()); - - provider->storeData(temp); + provider->putTimeTicket(toolId()); } resetCursorStyle(); if (!canvas()) return; if (!canvas()->resourceManager()) return; d->currentFgColor = canvas()->resourceManager()->resource(KoCanvasResourceManager::ForegroundColor).value(); d->currentBgColor = canvas()->resourceManager()->resource(KoCanvasResourceManager::BackgroundColor).value(); if (canvas()->resourceManager()->hasResource(KisCanvasResourceProvider::CurrentPattern)) { d->currentPattern = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentPattern).value(); } if (canvas()->resourceManager()->hasResource(KisCanvasResourceProvider::CurrentGradient)) { d->currentGradient = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentGradient).value(); } KisPaintOpPresetSP preset = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value(); if (preset && preset->settings()) { preset->settings()->activate(); } if (canvas()->resourceManager()->hasResource(KisCanvasResourceProvider::HdrExposure)) { d->currentExposure = static_cast(canvas()->resourceManager()->resource(KisCanvasResourceProvider::HdrExposure).toDouble()); } if (canvas()->resourceManager()->hasResource(KisCanvasResourceProvider::CurrentGeneratorConfiguration)) { d->currentGenerator = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentGeneratorConfiguration).value(); } connect(actions().value("toggle_fg_bg"), SIGNAL(triggered()), SLOT(slotToggleFgBg()), Qt::UniqueConnection); connect(actions().value("reset_fg_bg"), SIGNAL(triggered()), SLOT(slotResetFgBg()), Qt::UniqueConnection); d->m_isActive = true; emit isActiveChanged(); } void KisTool::deactivate() { bool result = true; if(KisPart::instance()->provider(KisPart::RegularProvider)){ KisTelemetryAbstruct * provider = KisPart::instance()->provider(KisPart::RegularProvider); - QVector temp; - temp.push_back("Deactivate"); - temp.push_back(toolId()); - - provider->storeData(temp); + provider->getTimeTicket(toolId()); } result &= disconnect(actions().value("toggle_fg_bg"), 0, this, 0); result &= disconnect(actions().value("reset_fg_bg"), 0, this, 0); if (!result) { warnKrita << "WARNING: KisTool::deactivate() failed to disconnect" << "some signal connections. Your actions might be executed twice!"; } d->m_isActive = false; emit isActiveChanged(); KoToolBase::deactivate(); } void KisTool::canvasResourceChanged(int key, const QVariant & v) { switch (key) { case(KoCanvasResourceManager::ForegroundColor): d->currentFgColor = v.value(); break; case(KoCanvasResourceManager::BackgroundColor): d->currentBgColor = v.value(); break; case(KisCanvasResourceProvider::CurrentPattern): d->currentPattern = static_cast(v.value()); break; case(KisCanvasResourceProvider::CurrentGradient): d->currentGradient = static_cast(v.value()); break; case(KisCanvasResourceProvider::HdrExposure): d->currentExposure = static_cast(v.toDouble()); break; case(KisCanvasResourceProvider::CurrentGeneratorConfiguration): d->currentGenerator = static_cast(v.value()); break; case(KisCanvasResourceProvider::CurrentPaintOpPreset): emit statusTextChanged(v.value()->name()); break; case(KisCanvasResourceProvider::CurrentKritaNode): resetCursorStyle(); break; default: break; // Do nothing }; } void KisTool::updateSettingsViews() { } QPointF KisTool::widgetCenterInWidgetPixels() { KisCanvas2 *kritaCanvas = dynamic_cast(canvas()); Q_ASSERT(kritaCanvas); const KisCoordinatesConverter *converter = kritaCanvas->coordinatesConverter(); return converter->flakeToWidget(converter->flakeCenterPoint()); } QPointF KisTool::convertDocumentToWidget(const QPointF& pt) { KisCanvas2 *kritaCanvas = dynamic_cast(canvas()); Q_ASSERT(kritaCanvas); return kritaCanvas->coordinatesConverter()->documentToWidget(pt); } QPointF KisTool::convertToPixelCoord(KoPointerEvent *e) { if (!image()) return e->point; return image()->documentToPixel(e->point); } QPointF KisTool::convertToPixelCoord(const QPointF& pt) { if (!image()) return pt; return image()->documentToPixel(pt); } QPointF KisTool::convertToPixelCoordAndSnap(KoPointerEvent *e, const QPointF &offset, bool useModifiers) { if (!image()) return e->point; KoSnapGuide *snapGuide = canvas()->snapGuide(); QPointF pos = snapGuide->snap(e->point, offset, useModifiers ? e->modifiers() : Qt::NoModifier); return image()->documentToPixel(pos); } QPointF KisTool::convertToPixelCoordAndSnap(const QPointF& pt, const QPointF &offset) { if (!image()) return pt; KoSnapGuide *snapGuide = canvas()->snapGuide(); QPointF pos = snapGuide->snap(pt, offset, Qt::NoModifier); return image()->documentToPixel(pos); } QPoint KisTool::convertToIntPixelCoord(KoPointerEvent *e) { if (!image()) return e->point.toPoint(); return image()->documentToIntPixel(e->point); } QPointF KisTool::viewToPixel(const QPointF &viewCoord) const { if (!image()) return viewCoord; return image()->documentToPixel(canvas()->viewConverter()->viewToDocument(viewCoord)); } QRectF KisTool::convertToPt(const QRectF &rect) { if (!image()) return rect; QRectF r; //We add 1 in the following to the extreme coords because a pixel always has size r.setCoords(int(rect.left()) / image()->xRes(), int(rect.top()) / image()->yRes(), int(1 + rect.right()) / image()->xRes(), int(1 + rect.bottom()) / image()->yRes()); return r; } QPointF KisTool::pixelToView(const QPoint &pixelCoord) const { if (!image()) return pixelCoord; QPointF documentCoord = image()->pixelToDocument(pixelCoord); return canvas()->viewConverter()->documentToView(documentCoord); } QPointF KisTool::pixelToView(const QPointF &pixelCoord) const { if (!image()) return pixelCoord; QPointF documentCoord = image()->pixelToDocument(pixelCoord); return canvas()->viewConverter()->documentToView(documentCoord); } QRectF KisTool::pixelToView(const QRectF &pixelRect) const { if (!image()) return pixelRect; QPointF topLeft = pixelToView(pixelRect.topLeft()); QPointF bottomRight = pixelToView(pixelRect.bottomRight()); return QRectF(topLeft, bottomRight); } QPainterPath KisTool::pixelToView(const QPainterPath &pixelPolygon) const { QTransform matrix; qreal zoomX, zoomY; canvas()->viewConverter()->zoom(&zoomX, &zoomY); matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes()); return matrix.map(pixelPolygon); } QPolygonF KisTool::pixelToView(const QPolygonF &pixelPath) const { QTransform matrix; qreal zoomX, zoomY; canvas()->viewConverter()->zoom(&zoomX, &zoomY); matrix.scale(zoomX/image()->xRes(), zoomY/ image()->yRes()); return matrix.map(pixelPath); } void KisTool::updateCanvasPixelRect(const QRectF &pixelRect) { canvas()->updateCanvas(convertToPt(pixelRect)); } void KisTool::updateCanvasViewRect(const QRectF &viewRect) { canvas()->updateCanvas(canvas()->viewConverter()->viewToDocument(viewRect)); } KisImageWSP KisTool::image() const { // For now, krita tools only work in krita, not for a krita shape. Krita shapes are for 2.1 KisCanvas2 * kisCanvas = dynamic_cast(canvas()); if (kisCanvas) { return kisCanvas->currentImage(); } return 0; } QCursor KisTool::cursor() const { return d->cursor; } void KisTool::notifyModified() const { if (image()) { image()->setModified(); } } KoPattern * KisTool::currentPattern() { return d->currentPattern; } KoAbstractGradient * KisTool::currentGradient() { return d->currentGradient; } KisPaintOpPresetSP KisTool::currentPaintOpPreset() { return canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentPaintOpPreset).value(); } KisNodeSP KisTool::currentNode() const { KisNodeSP node = canvas()->resourceManager()->resource(KisCanvasResourceProvider::CurrentKritaNode).value(); return node; } KisNodeList KisTool::selectedNodes() const { KisCanvas2 * kiscanvas = static_cast(canvas()); KisViewManager* viewManager = kiscanvas->viewManager(); return viewManager->nodeManager()->selectedNodes(); } KoColor KisTool::currentFgColor() { return d->currentFgColor; } KoColor KisTool::currentBgColor() { return d->currentBgColor; } KisImageWSP KisTool::currentImage() { return image(); } KisFilterConfigurationSP KisTool::currentGenerator() { return d->currentGenerator; } void KisTool::setMode(ToolMode mode) { d->m_mode = mode; } KisTool::ToolMode KisTool::mode() const { return d->m_mode; } void KisTool::setCursor(const QCursor &cursor) { d->cursor = cursor; } KisTool::AlternateAction KisTool::actionToAlternateAction(ToolAction action) { KIS_ASSERT_RECOVER_RETURN_VALUE(action != Primary, Secondary); return (AlternateAction)action; } void KisTool::activatePrimaryAction() { resetCursorStyle(); } void KisTool::deactivatePrimaryAction() { resetCursorStyle(); } void KisTool::beginPrimaryAction(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::beginPrimaryDoubleClickAction(KoPointerEvent *event) { beginPrimaryAction(event); } void KisTool::continuePrimaryAction(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::endPrimaryAction(KoPointerEvent *event) { Q_UNUSED(event); } bool KisTool::primaryActionSupportsHiResEvents() const { return false; } void KisTool::activateAlternateAction(AlternateAction action) { Q_UNUSED(action); } void KisTool::deactivateAlternateAction(AlternateAction action) { Q_UNUSED(action); } void KisTool::beginAlternateAction(KoPointerEvent *event, AlternateAction action) { Q_UNUSED(event); Q_UNUSED(action); } void KisTool::beginAlternateDoubleClickAction(KoPointerEvent *event, AlternateAction action) { beginAlternateAction(event, action); } void KisTool::continueAlternateAction(KoPointerEvent *event, AlternateAction action) { Q_UNUSED(event); Q_UNUSED(action); } void KisTool::endAlternateAction(KoPointerEvent *event, AlternateAction action) { Q_UNUSED(event); Q_UNUSED(action); } void KisTool::mouseDoubleClickEvent(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::mouseTripleClickEvent(KoPointerEvent *event) { mouseDoubleClickEvent(event); } void KisTool::mousePressEvent(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::mouseReleaseEvent(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::mouseMoveEvent(KoPointerEvent *event) { Q_UNUSED(event); } void KisTool::deleteSelection() { KisResourcesSnapshotSP resources = new KisResourcesSnapshot(image(), currentNode(), this->canvas()->resourceManager()); if (!blockUntilOperationsFinished()) { return; } if (!KisToolUtils::clearImage(image(), resources->currentNode(), resources->activeSelection())) { KoToolBase::deleteSelection(); } } void KisTool::setupPaintAction(KisRecordedPaintAction* action) { action->setPaintColor(currentFgColor()); action->setBackgroundColor(currentBgColor()); } QWidget* KisTool::createOptionWidget() { d->optionWidget = new QLabel(i18n("No options")); d->optionWidget->setObjectName("SpecialSpacer"); return d->optionWidget; } #define NEAR_VAL -1000.0 #define FAR_VAL 1000.0 #define PROGRAM_VERTEX_ATTRIBUTE 0 void KisTool::paintToolOutline(QPainter* painter, const QPainterPath &path) { KisOpenGLCanvas2 *canvasWidget = dynamic_cast(canvas()->canvasWidget()); if (canvasWidget) { painter->beginNativePainting(); canvasWidget->paintToolOutline(path); painter->endNativePainting(); } else { painter->setCompositionMode(QPainter::RasterOp_SourceXorDestination); painter->setPen(QColor(128, 255, 128)); painter->drawPath(path); } } void KisTool::resetCursorStyle() { useCursor(d->cursor); } bool KisTool::overrideCursorIfNotEditable() { // override cursor for canvas iff this tool is active // and we can't paint on the active layer if (isActive()) { KisNodeSP node = currentNode(); if (node && !node->isEditable()) { canvas()->setCursor(Qt::ForbiddenCursor); return true; } } return false; } bool KisTool::blockUntilOperationsFinished() { KisCanvas2 * kiscanvas = static_cast(canvas()); KisViewManager* viewManager = kiscanvas->viewManager(); return viewManager->blockUntilOperationsFinished(image()); } void KisTool::blockUntilOperationsFinishedForced() { KisCanvas2 * kiscanvas = static_cast(canvas()); KisViewManager* viewManager = kiscanvas->viewManager(); viewManager->blockUntilOperationsFinishedForced(image()); } bool KisTool::isActive() const { return d->m_isActive; } void KisTool::slotToggleFgBg() { KoCanvasResourceManager* resourceManager = canvas()->resourceManager(); KoColor newFg = resourceManager->backgroundColor(); KoColor newBg = resourceManager->foregroundColor(); /** * NOTE: Some of color selectors do not differentiate foreground * and background colors, so if one wants them to end up * being set up to foreground color, it should be set the * last. */ resourceManager->setBackgroundColor(newBg); resourceManager->setForegroundColor(newFg); } void KisTool::slotResetFgBg() { KoCanvasResourceManager* resourceManager = canvas()->resourceManager(); // see a comment in slotToggleFgBg() resourceManager->setBackgroundColor(KoColor(Qt::white, KoColorSpaceRegistry::instance()->rgb8())); resourceManager->setForegroundColor(KoColor(Qt::black, KoColorSpaceRegistry::instance()->rgb8())); } bool KisTool::nodeEditable() { KisNodeSP node = currentNode(); if (!node) { return false; } bool nodeEditable = node->isEditable(); if (!nodeEditable) { KisCanvas2 * kiscanvas = static_cast(canvas()); QString message; if (!node->visible() && node->userLocked()) { message = i18n("Layer is locked and invisible."); } else if (node->userLocked()) { message = i18n("Layer is locked."); } else if(!node->visible()) { message = i18n("Layer is invisible."); } else { message = i18n("Group not editable."); } kiscanvas->viewManager()->showFloatingMessage(message, KisIconUtils::loadIcon("object-locked")); } return nodeEditable; } bool KisTool::selectionEditable() { KisCanvas2 * kisCanvas = static_cast(canvas()); KisViewManager * view = kisCanvas->viewManager(); bool editable = view->selectionEditable(); if (!editable) { KisCanvas2 * kiscanvas = static_cast(canvas()); kiscanvas->viewManager()->showFloatingMessage(i18n("Local selection is locked."), KisIconUtils::loadIcon("object-locked")); } return editable; } void KisTool::listenToModifiers(bool listen) { Q_UNUSED(listen); } bool KisTool::listeningToModifiers() { return false; } diff --git a/plugins/telemetry/CMakeLists.txt b/plugins/telemetry/CMakeLists.txt index 234b9ae596..d5ac1da25c 100644 --- a/plugins/telemetry/CMakeLists.txt +++ b/plugins/telemetry/CMakeLists.txt @@ -1,13 +1,14 @@ set(kritatelemetry_SOURCES kis_telemetry_install_provider.cpp kis_telemetry_regular_provider.cpp kis_telemetry.cpp kis_cpuinfosource.cpp kis_toolsinfosource.cpp + kis_tickets.cpp ) add_library(kritatelemetry MODULE ${kritatelemetry_SOURCES}) target_link_libraries(kritatelemetry KUserFeedbackCore kritaui) install(TARGETS kritatelemetry DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/telemetry/kis_telemetry.cpp b/plugins/telemetry/kis_telemetry.cpp index 1472ead7c1..8ad566f945 100644 --- a/plugins/telemetry/kis_telemetry.cpp +++ b/plugins/telemetry/kis_telemetry.cpp @@ -1,49 +1,48 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_telemetry.h" #include "KPluginFactory" #include #include #include #include #include #include "kis_telemetry_install_provider.h" #include "KisPart.h" #include "kis_telemetry_regular_provider.h" K_PLUGIN_FACTORY_WITH_JSON(KisTelemetryFactory, "kritatelemetry.json", registerPlugin();) KisTelemetry::KisTelemetry(QObject* parent, const QVariantList&) : QObject(parent) { KisPart::instance()->setProvider(new KisTelemetryInstallProvider,KisPart::InstallProvider); KisPart::instance()->setProvider(new KisTelemetryRegularProvider, KisPart::RegularProvider); - } KisTelemetry::~KisTelemetry() { } #include "kis_telemetry.moc" diff --git a/plugins/telemetry/kis_telemetry_install_provider.cpp b/plugins/telemetry/kis_telemetry_install_provider.cpp index abf470bfce..ba47581a7e 100644 --- a/plugins/telemetry/kis_telemetry_install_provider.cpp +++ b/plugins/telemetry/kis_telemetry_install_provider.cpp @@ -1,80 +1,75 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_telemetry_install_provider.h" #include "KPluginFactory" #include "KisPart.h" #include #include #include #include #include #include #include #include #include "Vc/cpuid.h" KisTelemetryInstallProvider::KisTelemetryInstallProvider() { m_provider.reset(new KUserFeedback::Provider); m_provider.data()->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); std::unique_ptr cpu(new KisUserFeedback::CpuInfoSource()); m_sources.push_back(std::move(cpu)); std::unique_ptr qt(new KUserFeedback::QtVersionSource()); m_sources.push_back(std::move(qt)); std::unique_ptr compiler(new KUserFeedback::CompilerInfoSource()); m_sources.push_back(std::move(compiler)); std::unique_ptr locale(new KUserFeedback::LocaleInfoSource()); m_sources.push_back(std::move(locale)); std::unique_ptr opengl(new KUserFeedback::OpenGLInfoSource()); m_sources.push_back(std::move(opengl)); std::unique_ptr platform(new KUserFeedback::PlatformInfoSource()); m_sources.push_back(std::move(platform)); std::unique_ptr screen(new KUserFeedback::ScreenInfoSource()); m_sources.push_back(std::move(screen)); for (auto &source : m_sources) { m_provider.data()->addDataSource(source.get()); } } KUserFeedback::Provider* KisTelemetryInstallProvider::provider() { return m_provider.data(); } void KisTelemetryInstallProvider::sendData() { // m_provider.data()->setFeedbackServer(QUrl("http://akapustin.me:8080/")); m_provider.data()->setFeedbackServer(QUrl(m_adress)); m_provider.data()->submit(); } KisTelemetryInstallProvider::~KisTelemetryInstallProvider() { } - -void KisTelemetryInstallProvider::storeData(QVector &args) -{ - -} diff --git a/plugins/telemetry/kis_telemetry_install_provider.h b/plugins/telemetry/kis_telemetry_install_provider.h index e19cea90c6..e93fd66759 100644 --- a/plugins/telemetry/kis_telemetry_install_provider.h +++ b/plugins/telemetry/kis_telemetry_install_provider.h @@ -1,55 +1,55 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_INSTALL_PROVIDER_H #define KIS_TELEMETRY_INSTALL_PROVIDER_H #include "QScopedPointer" -#include #include -#include #include #include #include #include #include +#include #include #include +#include #include "kis_cpuinfosource.h" #include #include #include - class KisTelemetryInstallProvider : public KisTelemetryAbstruct { public: KisTelemetryInstallProvider(); KUserFeedback::Provider* provider() override; void sendData() override; + void getTimeTicket(QString id) override {} + void putTimeTicket(QString id) override {} virtual ~KisTelemetryInstallProvider(); - void storeData(QVector& args); private: QScopedPointer m_provider; std::vector > m_sources; }; #endif diff --git a/plugins/telemetry/kis_telemetry_regular_provider.cpp b/plugins/telemetry/kis_telemetry_regular_provider.cpp index 76a9852a2f..1a4afb6b6d 100644 --- a/plugins/telemetry/kis_telemetry_regular_provider.cpp +++ b/plugins/telemetry/kis_telemetry_regular_provider.cpp @@ -1,85 +1,112 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_telemetry_regular_provider.h" #include "KPluginFactory" #include "KisPart.h" #include #include #include #include +#include "kis_tickets.h" #include "kis_toolsinfosource.h" #include #include #include #include -#include KisTelemetryRegularProvider::KisTelemetryRegularProvider() { m_provider.reset(new KUserFeedback::Provider); m_provider.data()->setTelemetryMode(KUserFeedback::Provider::DetailedUsageStatistics); std::unique_ptr tools(new KisUserFeedback::ToolsInfoSource); m_sources.push_back(std::move(tools)); for (auto& source : m_sources) { m_provider.data()->addDataSource(source.get()); } } KUserFeedback::Provider* KisTelemetryRegularProvider::provider() { return m_provider.data(); } void KisTelemetryRegularProvider::sendData() { // m_provider.data()->setFeedbackServer(QUrl("http://akapustin.me:8080/")); m_provider.data()->setFeedbackServer(QUrl(m_adress)); m_provider.data()->submit(); } -KisTelemetryRegularProvider::~KisTelemetryRegularProvider() +void KisTelemetryRegularProvider::getTimeTicket(QString id) { + id = getToolId(id); + KisTicket* ticket = m_tickets.value(id).lock().data(); + KisTimeTicket* timeTicket; + KUserFeedback::AbstractDataSource* m_tools = m_sources[0].get(); + KisUserFeedback::ToolsInfoSource* tools = nullptr; + + timeTicket = dynamic_cast(ticket); + if (!ticket) { + Q_ASSERT_X(1 != 0, "timeTicket is lost", id.); + return; + } + tools = dynamic_cast(m_tools); + if (!timeTicket || !tools) { + Q_ASSERT_X(1 != 0, "get tool's timeTicket ", id.toStdString().c_str()); + return; + } + tools->deactivateTool(id); + m_tickets.remove(id); } -void KisTelemetryRegularProvider::storeData(QVector& args) +void KisTelemetryRegularProvider::putTimeTicket(QString id) { - QString whatIsIt = args[0]; - QString toolName = args[1]; - + id = getToolId(id); KUserFeedback::AbstractDataSource* m_tools = m_sources[0].get(); KisUserFeedback::ToolsInfoSource* tools = nullptr; - try { - tools = dynamic_cast(m_tools); - } catch (...) { + QSharedPointer timeTicket; + timeTicket.reset(new KisTimeTicket(id)); + + qDebug() << "TOOL_ID" << id; + + tools = dynamic_cast(m_tools); + + if (!tools) { + Q_ASSERT_X(1 != 0, "create tool's timeTicket ", id); return; } - - if (whatIsIt == QString("Activate")) { - tools->activateTool(toolName); - } else { - tools->deactivateTool(toolName); + QWeakPointer weakTimeTicket(timeTicket); + if(m_tickets.count(id)){ + Q_ASSERT_X(1 != 0, "tools duplicate ", id); + m_tickets.remove(id); } + m_tickets.insert(id, weakTimeTicket); + tools->activateTool(timeTicket); +} + +KisTelemetryRegularProvider::~KisTelemetryRegularProvider() +{ } diff --git a/plugins/telemetry/kis_telemetry_regular_provider.h b/plugins/telemetry/kis_telemetry_regular_provider.h index c5d5d1abb8..6790c6979d 100644 --- a/plugins/telemetry/kis_telemetry_regular_provider.h +++ b/plugins/telemetry/kis_telemetry_regular_provider.h @@ -1,56 +1,62 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KIS_TELEMETRY_REGULAR_PROVIDER_H #define KIS_TELEMETRY_REGULAR_PROVIDER_H #include "QScopedPointer" #include #include #include #include #include #include #include #include #include #include #include "kis_cpuinfosource.h" #include #include #include +#include +#include +#include "kis_tickets.h" class KisTelemetryRegularProvider : public KisTelemetryAbstruct { public: KisTelemetryRegularProvider(); KUserFeedback::Provider* provider() override; void sendData() override; + void getTimeTicket(QString id) override; + void putTimeTicket(QString id) override; + virtual ~KisTelemetryRegularProvider(); - void storeData(QVector& args) override; private: QScopedPointer m_provider; std::vector > m_sources; + QMultiMap> m_tickets; }; #endif diff --git a/libs/ui/kis_telemetry_abstruct.h b/plugins/telemetry/kis_tickets.cpp similarity index 57% copy from libs/ui/kis_telemetry_abstruct.h copy to plugins/telemetry/kis_tickets.cpp index 94f4a6d263..67a7faf2b0 100644 --- a/libs/ui/kis_telemetry_abstruct.h +++ b/plugins/telemetry/kis_tickets.cpp @@ -1,45 +1,57 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#ifndef KIS_TELEMETRY_ABSTRUCT_H -#define KIS_TELEMETRY_ABSTRUCT_H -#include "QScopedPointer" -#include "kritaflake_export.h" -#include -#include -#include -#include -#include -#include - -class KRITAFLAKE_EXPORT KisTelemetryAbstruct { -public: - virtual KUserFeedback::Provider* provider() = 0; - virtual void sendData() = 0; - virtual void storeData(QVector& args) = 0; - virtual ~KisTelemetryAbstruct(){} - -protected: - QString m_adress = "http://localhost:8080/"; - // QString m_adress = "http://akapustin.me:8080/"; -}; - -#endif - +#include "kis_tickets.h" +#include + +KisTimeTicket::KisTimeTicket(QString id) + : KisTicket(id) +{ + m_start = QTime::currentTime(); +} + +void KisTimeTicket::setStartTime(QTime& time) +{ + m_start = time; +} + +void KisTimeTicket::setEndTime(QTime &time) +{ + m_end = time; +} + +QTime KisTimeTicket::startTime() const +{ + return m_end; +} + +QTime KisTimeTicket::endTime() const +{ + return m_end; +} + +KisTicket::KisTicket(QString id) + : m_id(id) +{ +} + +QString KisTicket::ticketId() const { return m_id; } + +void KisTicket::setTickedId(QString id) { m_id = id; } diff --git a/libs/ui/kis_telemetry_abstruct.h b/plugins/telemetry/kis_tickets.h similarity index 58% copy from libs/ui/kis_telemetry_abstruct.h copy to plugins/telemetry/kis_tickets.h index 94f4a6d263..735c4ba61d 100644 --- a/libs/ui/kis_telemetry_abstruct.h +++ b/plugins/telemetry/kis_tickets.h @@ -1,45 +1,49 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ +#ifndef KIS_TICKETS_H +#define KIS_TICKETS_H -#ifndef KIS_TELEMETRY_ABSTRUCT_H -#define KIS_TELEMETRY_ABSTRUCT_H -#include "QScopedPointer" -#include "kritaflake_export.h" -#include -#include -#include -#include -#include -#include - -class KRITAFLAKE_EXPORT KisTelemetryAbstruct { -public: - virtual KUserFeedback::Provider* provider() = 0; - virtual void sendData() = 0; - virtual void storeData(QVector& args) = 0; - virtual ~KisTelemetryAbstruct(){} +#include +class KisTicket { +public: + KisTicket(){} + KisTicket(QString id); + QString ticketId() const; + void setTickedId(QString id); + virtual ~KisTicket(){} protected: - QString m_adress = "http://localhost:8080/"; - // QString m_adress = "http://akapustin.me:8080/"; + QString m_id; +}; + +class KisTimeTicket: public KisTicket{ +public: + KisTimeTicket(QString id); + void setStartTime(QTime &time); + void setEndTime(QTime &time); + QTime startTime() const; + QTime endTime() const; +private: + QTime m_start; + QTime m_end; }; #endif diff --git a/plugins/telemetry/kis_toolsinfosource.cpp b/plugins/telemetry/kis_toolsinfosource.cpp index 4ed6a3127f..6fbdc7aa4d 100644 --- a/plugins/telemetry/kis_toolsinfosource.cpp +++ b/plugins/telemetry/kis_toolsinfosource.cpp @@ -1,68 +1,81 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_toolsinfosource.h" #include #include #include #include #include using namespace KisUserFeedback; using namespace KUserFeedback; ToolsInfoSource::ToolsInfoSource() : AbstractDataSource(QStringLiteral("Tools"), Provider::DetailedSystemInformation) { } QString ToolsInfoSource::description() const { return QObject::tr("Inforamation about tools"); } QVariant ToolsInfoSource::data() { return m_tools; } -void ToolsInfoSource::activateTool(QString toolName) +void ToolsInfoSource::activateTool(QSharedPointer ticket) { QMutexLocker locker(&m_mutex); - m_currentTools.insert(toolName, QTime::currentTime()); - std::cout<<"ACTIVATE TOOL "<ticketId(), QSharedPointer::create(ticket)); + m_currentTools.insert(ticket->ticketId(), ticket); + + std::cout << "ACTIVATE TOOL " << ticket->ticketId().toStdString()<< std::endl; } -void ToolsInfoSource::deactivateTool(QString toolName) +void ToolsInfoSource::deactivateTool(QString id) { QMutexLocker locker(&m_mutex); + KisTicket* ticket = m_currentTools.value(id).data(); + KisTimeTicket *timeTicket = nullptr; + + try { + timeTicket = dynamic_cast(ticket); + + } catch (...) { + Q_ASSERT_X(1!=0,"deactivate tool",""); + return; + } QTime deactivateTime = QTime::currentTime(); - QTime activateTime = m_currentTools.value(toolName); - m_currentTools.remove(toolName); - int timeUse = activateTime.second() - deactivateTime.second(); + + timeTicket->setEndTime(deactivateTime); + int timeUse = timeTicket->endTime().second() - timeTicket->startTime().second(); QVariantMap m; - m.insert(QStringLiteral("toolname"), toolName); - m.insert(QStringLiteral("timeUse"), timeUse); + m.insert(QStringLiteral("toolname"), ticket->ticketId()); + m.insert(QStringLiteral("timeUseSeconds"), timeUse); m_tools.push_back(m); - std::cout<<"DE_ACTIVATE TOOL "<ticketId().toStdString() << std::endl; } diff --git a/plugins/telemetry/kis_toolsinfosource.h b/plugins/telemetry/kis_toolsinfosource.h index 37c811d116..a884b2c671 100644 --- a/plugins/telemetry/kis_toolsinfosource.h +++ b/plugins/telemetry/kis_toolsinfosource.h @@ -1,54 +1,58 @@ /* This file is part of the KDE project Copyright (C) 2017 Alexey Kapustin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KISUSERFEEDBACK_TOOLSINFOSOURCE_H #define KISUSERFEEDBACK_TOOLSINFOSOURCE_H #include "abstractdatasource.h" #include "kuserfeedbackcore_export.h" #include #include #include +#include #include #include #include +#include "kis_telemetry_abstruct.h" +#include "kis_tickets.h" + namespace KisUserFeedback { /*! Data source reporting the type and amount of CPUs. * * The default telemetry mode for this source is Provider::DetailedSystemInformation. */ class ToolsInfoSource : public KUserFeedback::AbstractDataSource { public: ToolsInfoSource(); QString description() const override; QVariant data() override; - void activateTool(QString toolName); - void deactivateTool(QString toolName); + void activateTool(QSharedPointer ticket); + void deactivateTool(QString id); private: QVariantList m_tools; - QMap m_currentTools; + QMap > m_currentTools; QMutex m_mutex; }; } #endif // KISUSERFEEDBACK_TOOLSINFOSOURCE_H