main_window.h 2.3 KB

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