mainwindow.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #pragma once
  2. #include <QMainWindow>
  3. #include <QGraphicsScene>
  4. #include <QStandardItemModel>
  5. #include "mapcontroller.h"
  6. #include "resourceExtractor/ResourceConverter.h"
  7. class ObjectBrowser;
  8. class ObjectBrowserProxyModel;
  9. VCMI_LIB_NAMESPACE_BEGIN
  10. class CMap;
  11. class CGObjectInstance;
  12. VCMI_LIB_NAMESPACE_END
  13. namespace Ui
  14. {
  15. class MainWindow;
  16. const QString teamName = "VCMI Team";
  17. const QString appName = "VCMI Map Editor";
  18. }
  19. class MainWindow : public QMainWindow
  20. {
  21. Q_OBJECT
  22. const QString mainWindowSizeSetting = "MainWindow/Size";
  23. const QString mainWindowPositionSetting = "MainWindow/Position";
  24. #ifdef ENABLE_QT_TRANSLATIONS
  25. QTranslator translator;
  26. #endif
  27. public:
  28. explicit MainWindow(QWidget *parent = nullptr);
  29. ~MainWindow();
  30. void initializeMap(bool isNew);
  31. void saveMap();
  32. bool openMap(const QString &);
  33. MapView * mapView();
  34. void loadObjectsTree();
  35. void setStatusMessage(const QString & status);
  36. int getMapLevel() const {return mapLevel;}
  37. MapController controller;
  38. void loadTranslation();
  39. private slots:
  40. void on_actionOpen_triggered();
  41. void on_actionSave_as_triggered();
  42. void on_actionNew_triggered();
  43. void on_actionLevel_triggered();
  44. void on_actionSave_triggered();
  45. void on_actionErase_triggered();
  46. void on_actionUndo_triggered();
  47. void on_actionRedo_triggered();
  48. void on_actionPass_triggered(bool checked);
  49. void on_actionGrid_triggered(bool checked);
  50. void on_toolBrush_clicked(bool checked);
  51. void on_toolArea_clicked(bool checked);
  52. void terrainButtonClicked(TerrainId terrain);
  53. void roadOrRiverButtonClicked(ui8 type, bool isRoad);
  54. void on_toolErase_clicked();
  55. void on_terrainFilterCombo_currentTextChanged(const QString &arg1);
  56. void on_filter_textChanged(const QString &arg1);
  57. void on_actionFill_triggered();
  58. void on_toolBrush2_clicked(bool checked);
  59. void on_toolBrush4_clicked(bool checked);
  60. void on_toolLasso_clicked(bool checked);
  61. void on_inspectorWidget_itemChanged(QTableWidgetItem *item);
  62. void on_actionMapSettings_triggered();
  63. void on_actionPlayers_settings_triggered();
  64. void on_actionValidate_triggered();
  65. void on_actionUpdate_appearance_triggered();
  66. void on_actionRecreate_obstacles_triggered();
  67. void switchDefaultPlayer(const PlayerColor &);
  68. void on_actionCut_triggered();
  69. void on_actionCopy_triggered();
  70. void on_actionPaste_triggered();
  71. public slots:
  72. void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
  73. void loadInspector(CGObjectInstance * obj, bool switchTab);
  74. void mapChanged();
  75. void enableUndo(bool enable);
  76. void enableRedo(bool enable);
  77. void onSelectionMade(int level, bool anythingSelected);
  78. void onPlayersChanged();
  79. void displayStatus(const QString& message, int timeout = 2000);
  80. private:
  81. void preparePreview(const QModelIndex & index);
  82. void addGroupIntoCatalog(const std::string & groupName, bool staticOnly);
  83. void addGroupIntoCatalog(const std::string & groupName, bool useCustomName, bool staticOnly, int ID);
  84. QAction * getActionPlayer(const PlayerColor &);
  85. void changeBrushState(int idx);
  86. void setTitle();
  87. void closeEvent(QCloseEvent *event) override;
  88. bool getAnswerAboutUnsavedChanges();
  89. void loadUserSettings();
  90. void saveUserSettings();
  91. void parseCommandLine(ExtractionOptions & extractionOptions);
  92. private:
  93. Ui::MainWindow * ui;
  94. ObjectBrowserProxyModel * objectBrowser = nullptr;
  95. QGraphicsScene * scenePreview;
  96. QString filename;
  97. bool unsaved = false;
  98. QStandardItemModel objectsModel;
  99. int mapLevel = 0;
  100. std::set<int> catalog;
  101. // command line options
  102. QString mapFilePath; // FilePath to the H3 or VCMI map to open
  103. };