All Classes Namespaces Functions Variables Enumerations Properties Pages
mainwindow2.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2008-2009 Mj Mendoza IV
6 Copyright (C) 2012-2020 Matthew Chiawen Chang
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; version 2 of the License.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 */
18 #ifndef MAINWINDOW2_H
19 #define MAINWINDOW2_H
20 
21 #include <QMainWindow>
22 
23 template<typename T> class QList;
24 class QActionGroup;
25 class Object;
26 class Editor;
27 class ScribbleArea;
28 class BaseDockWidget;
29 class ColorPaletteWidget;
31 class OnionSkinWidget;
32 class ToolOptionWidget;
33 class TimeLine;
34 class ToolBoxWidget;
35 class PreferencesDialog;
36 class PreviewWidget;
37 class ColorBox;
38 class ColorInspector;
39 class RecentFileMenu;
40 class Timeline2;
41 class ActionCommands;
43 class BackupElement;
44 class QLabel;
46 enum class SETTING;
47 
48 
49 namespace Ui
50 {
51  class MainWindow2;
52 }
53 
54 class MainWindow2 : public QMainWindow
55 {
56  Q_OBJECT
57 
58 public:
59  explicit MainWindow2(QWidget* parent = nullptr);
60  ~MainWindow2() override;
61 
62  Editor* mEditor = nullptr;
63 
64 public slots:
65  void undoActSetText();
66  void undoActSetEnabled();
67  void updateSaveState();
68  void clearRecentFilesList();
69  void openPegAlignDialog();
70  void currentLayerChanged();
71  void selectionChanged();
72  void viewFlipped();
73 
74 public:
75  void newDocument();
76  void openDocument();
77  bool saveDocument();
78  bool saveAsNewDocument();
79  bool maybeSave();
80  bool autoSave();
81  void emptyDocumentWhenErrorOccurred();
82 
83  // import
84  void importImage();
85  void importImageSequence();
86  void importPredefinedImageSet();
87  void importLayers();
88  void importMovieVideo();
89  void importGIF();
90 
91  void lockWidgets(bool shouldLock);
92 
93  void setOpacity(int opacity);
94  void preferences();
95 
96  void openFile(const QString& filename);
97 
98  PreferencesDialog* getPrefDialog() { return mPrefDialog; }
99 
100  void displayMessageBox(const QString& title, const QString& body);
101  void displayMessageBoxNoTitle(const QString& body);
102 
103 signals:
104  void updateRecentFilesList(bool b);
105 
106 protected:
107  void tabletEvent(QTabletEvent*) override;
108  void closeEvent(QCloseEvent*) override;
109  void showEvent(QShowEvent*) override;
110 
111 private:
112  void newObject() const;
113  bool newObjectFromPresets(int presetIndex);
114  bool openObject(const QString& strFilename);
115  bool saveObject(QString strFileName);
116 
117  void createDockWidgets();
118  void createMenus();
119  void setupKeyboardShortcuts();
120  void clearKeyboardShortcuts();
121  void updateZoomLabel();
122  bool loadMostRecent();
123  bool tryLoadPreset();
124 
125  void openPalette();
126  void importPalette();
127  void exportPalette();
128 
129  void readSettings();
130  void writeSettings();
131  void resetAndDockAllSubWidgets();
132 
133  void changePlayState(bool isPlaying);
134 
135  void makeConnections(Editor*);
136  void makeConnections(Editor*, ColorBox* colorBox);
137  void makeConnections(Editor*, ColorInspector*);
138  void makeConnections(Editor*, ScribbleArea*);
139  void makeConnections(Editor*, ColorPaletteWidget*);
140  void makeConnections(Editor*, TimeLine*);
141  void makeConnections(Editor*, DisplayOptionWidget*);
142  void makeConnections(Editor*, ToolOptionWidget*);
143  void makeConnections(Editor*, OnionSkinWidget*);
144 
145  bool tryRecoverUnsavedProject();
146  void startProjectRecovery(int result);
147 
148  // UI: Dock widgets
149  ColorBox* mColorBox = nullptr;
150  ColorPaletteWidget* mColorPalette = nullptr;
151  DisplayOptionWidget* mDisplayOptionWidget = nullptr;
152  ToolOptionWidget* mToolOptions = nullptr;
153  ToolBoxWidget* mToolBox = nullptr;
154  //Timeline2* mTimeline2 = nullptr;
155  RecentFileMenu* mRecentFileMenu = nullptr;
156  PreferencesDialog* mPrefDialog = nullptr;
157  //PreviewWidget* mPreview = nullptr;
158  TimeLine* mTimeLine = nullptr;
159  ColorInspector* mColorInspector = nullptr;
160  OnionSkinWidget* mOnionSkinWidget = nullptr;
161 
162  // backup
163  BackupElement* mBackupAtSave = nullptr;
164 
165  PegBarAlignmentDialog* mPegAlign = nullptr;
166 
167  ActionCommands* mCommands = nullptr;
168  QList<BaseDockWidget*> mDockWidgets;
169 
170  QIcon mStartIcon;
171  QIcon mStopIcon;
172 
173  // a hack for MacOS because closeEvent fires twice
174  bool m2ndCloseEvent = false;
175 
176  // statusbar widgets
177  QLabel* mZoomLabel = nullptr;
178 
179  // Whether to suppress the auto save dialog due to internal work
180  bool mSuppressAutoSaveDialog = false;
181 
182  Ui::MainWindow2* ui = nullptr;
183 };
184 
185 #endif // MAINWINDOW2_H
Q_OBJECTQ_OBJECT
Definition: object.h:54
Definition: editor.h:51
QObject * parent() const const