Warning, file /graphics/glaxnimate/src/gui/widgets/dialogs/glaxnimate_window.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef GLAXNIMATEWINDOW_H 0008 #define GLAXNIMATEWINDOW_H 0009 0010 #include <memory> 0011 0012 #include <KXmlGuiWindow> 0013 #include <QUndoGroup> 0014 #include <QLocalSocket> 0015 0016 #include "model/document.hpp" 0017 #include "model/shapes/shape.hpp" 0018 0019 #include "plugin/executor.hpp" 0020 0021 #include "selection_manager.hpp" 0022 #include "item_models/document_node_model.hpp" 0023 0024 0025 namespace glaxnimate::plugin { 0026 class Plugin; 0027 class PluginScript; 0028 } // namespace plugin 0029 0030 namespace glaxnimate::model { 0031 class BrushStyle; 0032 } // namespace model 0033 0034 class QItemSelection; 0035 0036 0037 namespace glaxnimate::gui { 0038 class PluginUiDialog; 0039 0040 class GlaxnimateWindow : public KXmlGuiWindow, public glaxnimate::gui::SelectionManager 0041 { 0042 Q_OBJECT 0043 0044 Q_PROPERTY(glaxnimate::model::Document* document READ document) 0045 Q_PROPERTY(glaxnimate::model::VisualNode* current_item READ current_document_node WRITE set_current_document_node) 0046 Q_PROPERTY(glaxnimate::model::ShapeElement* current_shape READ current_shape) 0047 Q_PROPERTY(glaxnimate::model::Object* current_shape_container READ current_shape_container_script) 0048 Q_PROPERTY(glaxnimate::model::Composition* current_composition READ current_composition WRITE set_current_composition) 0049 Q_PROPERTY(QColor fill_color READ current_color WRITE set_current_color) 0050 Q_PROPERTY(QColor stroke_color READ secondary_color WRITE set_secondary_color) 0051 0052 public: 0053 0054 explicit GlaxnimateWindow(bool restore_state = true, bool debug = false, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); 0055 0056 ~GlaxnimateWindow(); 0057 0058 model::Document* document() const override; 0059 0060 model::VisualNode* current_document_node() const override; 0061 void set_current_document_node(model::VisualNode* node) override; 0062 0063 void set_current_composition(model::Composition* comp) override; 0064 model::Composition* current_composition() const override; 0065 0066 model::Object* current_shape_container_script(); 0067 0068 QColor current_color() const override; 0069 void set_current_color(const QColor& c) override; 0070 QColor secondary_color() const override; 0071 void set_secondary_color(const QColor& c) override; 0072 0073 QPen current_pen_style() const override; 0074 0075 /** 0076 * @brief Shows a warning popup 0077 */ 0078 Q_INVOKABLE void warning(const QString& message, const QString& title = "") const; 0079 0080 /** 0081 * @brief Shows a message in the status bar 0082 */ 0083 Q_INVOKABLE void status(const QString& message) const; 0084 0085 /** 0086 * \brief Shows a dialog to pick one of the given options 0087 */ 0088 Q_INVOKABLE QVariant choose_option(const QString& label, const QVariantMap& options, const QString& title = "") const; 0089 0090 /** 0091 * \brief Selected nodes, removing nodes that are descendants of other selected nodes 0092 */ 0093 std::vector<model::VisualNode*> cleaned_selection() const override; 0094 /** 0095 * \brief Update the selection 0096 */ 0097 void select(const std::vector<model::VisualNode*>& nodes); 0098 0099 void group_shapes(); 0100 void ungroup_shapes(); 0101 void move_to(); 0102 0103 item_models::DocumentNodeModel* model() const override; 0104 0105 qreal current_zoom() const override; 0106 0107 void document_open(const QString& filename); 0108 void document_open_settings(const QString& filename, const QVariantMap& settings); 0109 0110 void switch_tool(tools::Tool* tool) override; 0111 0112 /** 0113 * \brief Shows a file dialog to open an image file 0114 * \returns The selected name or an empty string if the user canceled the operation 0115 */ 0116 Q_INVOKABLE QString get_open_image_file(const QString& title, const QString& dir = "") const; 0117 0118 /** 0119 * \brief BrushStyle used for fill or strole (stroke is secondary) 0120 */ 0121 model::BrushStyle* linked_brush_style(bool secondary) const override; 0122 0123 PluginUiDialog* create_dialog(const QString& ui_file) const; 0124 0125 void trace_dialog(model::DocumentNode* object); 0126 0127 void shape_to_composition(model::ShapeElement* node); 0128 0129 QMenu* create_layer_menu() const; 0130 0131 /** 0132 * \brief Converts \p shape to path 0133 * \returns The converted shape 0134 */ 0135 Q_INVOKABLE glaxnimate::model::ShapeElement* convert_to_path(glaxnimate::model::ShapeElement* shape); 0136 0137 /** 0138 * \brief Converts \p shapes to path 0139 * \returns The converted shapes 0140 */ 0141 std::vector<model::ShapeElement*> convert_to_path(const std::vector<model::ShapeElement*>& shapes); 0142 0143 void show_startup_dialog(); 0144 0145 QWidget* as_widget() override { return this; } 0146 std::vector<io::mime::MimeSerializer*> supported_mimes() const override; 0147 0148 void set_selection(const std::vector<model::VisualNode*>& selected) override; 0149 void update_selection(const std::vector<model::VisualNode*>& selected, const std::vector<model::VisualNode*>& deselected) override; 0150 0151 void ipc_connect(const QString& name); 0152 0153 /** 0154 * \brief Checks if there are any autosave files left pending 0155 */ 0156 void check_autosaves(); 0157 0158 public Q_SLOTS: 0159 void document_save(); 0160 void document_save_as(); 0161 void document_export(); 0162 void document_export_as(); 0163 void document_export_sequence(); 0164 void view_fit(); 0165 /** 0166 * \brief Copies the current selection to the clipboard 0167 */ 0168 void copy() const; 0169 void paste(); 0170 void cut(); 0171 void duplicate_selection() const; 0172 void delete_selected(); 0173 0174 private Q_SLOTS: 0175 void document_new(); 0176 void document_open_dialog(); 0177 void document_reload(); 0178 0179 void document_treeview_current_changed(model::VisualNode* node); 0180 void document_treeview_selection_changed(const std::vector<model::VisualNode*>& selected, const std::vector<model::VisualNode*>& deselected); 0181 void scene_selection_changed(const std::vector<model::VisualNode*>& selected, const std::vector<model::VisualNode*>& deselected); 0182 0183 void layer_new_menu(); 0184 0185 void layer_delete(); 0186 void layer_duplicate(); 0187 void layer_top(); 0188 void layer_raise(); 0189 void layer_lower(); 0190 void layer_bottom(); 0191 0192 void help_about(); 0193 void help_manual(); 0194 void help_issue(); 0195 void help_donate(); 0196 0197 void refresh_title(); 0198 void document_open_recent(QAction* action); 0199 void preferences(); 0200 void save_frame_bmp(); 0201 void save_frame_svg(); 0202 void tool_triggered(bool checked); 0203 void validate_tgs(); 0204 0205 void switch_composition(model::Composition* comp, int index); 0206 0207 void ipc_signal_connections(bool enable); 0208 void ipc_error(QLocalSocket::LocalSocketError socketError); 0209 void ipc_read(); 0210 void ipc_write_time(model::FrameTime t); 0211 void ipc_draw_background(QPainter *painter); 0212 0213 protected: 0214 void changeEvent(QEvent *e) override; 0215 void showEvent(QShowEvent * event) override; 0216 void closeEvent ( QCloseEvent * event ) override; 0217 void timerEvent(QTimerEvent * event) override; 0218 0219 void dragEnterEvent(QDragEnterEvent* event) override; 0220 void dragMoveEvent(QDragMoveEvent* event) override; 0221 void dragLeaveEvent(QDragLeaveEvent* event) override; 0222 void dropEvent(QDropEvent* event) override; 0223 0224 private: 0225 class Private; 0226 std::unique_ptr<Private> d; 0227 }; 0228 0229 0230 } // namespace glaxnimate::gui 0231 0232 #endif // GLAXNIMATEWINDOW_H