main_window.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * main_window.h - main window
  3. * Copyright (C) 2017 caryoscelus
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __STUDIO__MAIN_WINDOW_H__D1BD80BA
  19. #define __STUDIO__MAIN_WINDOW_H__D1BD80BA
  20. #include <memory>
  21. #include <QMainWindow>
  22. #include <core/node/abstract_value.h>
  23. #include <generic/context_listener.h>
  24. #include "renderer.h"
  25. namespace Ui {
  26. class MainWindow;
  27. }
  28. class QErrorMessage;
  29. namespace rainynite::studio {
  30. class MainWindow : public QMainWindow, public ContextListener {
  31. Q_OBJECT
  32. public:
  33. explicit MainWindow(QWidget *parent = nullptr);
  34. ~MainWindow();
  35. public:
  36. void set_context(shared_ptr<EditorContext> context_) override;
  37. private Q_SLOTS:
  38. void new_document();
  39. void open();
  40. void reload();
  41. void save(QString format="");
  42. void save_as();
  43. void update_title();
  44. void about();
  45. void quit();
  46. void undo();
  47. void redo();
  48. void activate(shared_ptr<core::AbstractValue> node);
  49. void add_all_docks();
  50. void add_dock(string const& name);
  51. private:
  52. void setup_dock_menu();
  53. void setup_tools();
  54. void set_fname(string const& fname_);
  55. private:
  56. shared_ptr<Renderer> renderer;
  57. unique_ptr<Ui::MainWindow> ui;
  58. unique_ptr<QErrorMessage> error_box;
  59. shared_ptr<core::Document> document;
  60. shared_ptr<core::AbstractValue> active_node;
  61. string fname;
  62. string saved_format;
  63. string window_title_template;
  64. };
  65. } // namespace rainynite::studio
  66. #endif