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 #include "preferencemanager.h"
23 
24 
25 template<typename T> class QList;
26 class QActionGroup;
27 class QToolBar;
28 class Object;
29 class Editor;
30 class ScribbleArea;
31 class BaseDockWidget;
32 class ColorPaletteWidget;
34 class OnionSkinWidget;
35 class ToolOptionWidget;
36 class TimeLine;
37 class ToolBoxWidget;
38 class PreferencesDialog;
39 class PreviewWidget;
40 class ColorBox;
41 class ColorInspector;
42 class RecentFileMenu;
43 class Timeline2;
44 class ActionCommands;
46 class BackupElement;
47 class LayerOpacityDialog;
50 class StatusBar;
51 enum class SETTING;
52 
53 
54 namespace Ui
55 {
56  class MainWindow2;
57 }
58 
59 class MainWindow2 : public QMainWindow
60 {
61  Q_OBJECT
62 
63 public:
64  explicit MainWindow2(QWidget* parent = nullptr);
65  ~MainWindow2() override;
66 
67  Editor* mEditor = nullptr;
68 
69 public slots:
70  void undoActSetText();
71  void updateSaveState();
72  void openPegAlignDialog();
73  void openRepositionDialog();
74  void closeRepositionDialog();
75  void openLayerOpacityDialog();
76  void currentLayerChanged();
77  void selectionChanged();
78  void viewFlipped();
79 
80 public:
81  void newDocument();
82  void openDocument();
83  bool saveDocument();
84  bool saveAsNewDocument();
85  bool maybeSave();
86  bool autoSave();
87  void emptyDocumentWhenErrorOccurred();
88 
89  // import
90  void importImage();
91  void importImageSequence();
92  void importPredefinedImageSet();
93  void importLayers();
94  void importMovieVideo();
95  void importGIF();
96 
97  void lockWidgets(bool shouldLock);
98 
99  void setOpacity(int opacity);
100  void preferences();
101 
102  void openStartupFile(const QString& filename);
103  void openFile(const QString& filename);
104 
105  void displayMessageBox(const QString& title, const QString& body);
106  void displayMessageBoxNoTitle(const QString& body);
107 
108 signals:
110  void windowActivated();
111 
112 protected:
113  void tabletEvent(QTabletEvent*) override;
114  void closeEvent(QCloseEvent*) override;
115  bool event(QEvent*) override;
116 
117 private slots:
118  void updateCopyCutPasteEnabled();
119 private:
120  void newObject();
121  bool newObjectFromPresets(int presetIndex);
122  bool openObject(const QString& strFilename);
123  bool saveObject(QString strFileName);
124  void closeDialogs();
125 
126  void createDockWidgets();
127  void createMenus();
128  void setupKeyboardShortcuts();
129  void clearKeyboardShortcuts();
130  bool loadMostRecent();
131  bool tryLoadPreset();
132 
133  void openPalette();
134  void importPalette();
135  void exportPalette();
136 
137  void readSettings();
138  void writeSettings();
139  void resetAndDockAllSubWidgets();
140 
141  void changePlayState(bool isPlaying);
142 
143  void makeConnections(Editor*);
144  void makeConnections(Editor*, ColorBox* colorBox);
145  void makeConnections(Editor*, ColorInspector*);
146  void makeConnections(Editor*, ScribbleArea*);
147  void makeConnections(Editor*, ColorPaletteWidget*);
148  void makeConnections(Editor*, TimeLine*);
149  void makeConnections(Editor*, DisplayOptionWidget*);
150  void makeConnections(Editor*, ToolOptionWidget*);
151  void makeConnections(Editor*, OnionSkinWidget*);
152  void makeConnections(Editor*, StatusBar*);
153 
154  bool tryRecoverUnsavedProject();
155  void startProjectRecovery(int result);
156 
157  // UI: Dock widgets
158  ColorBox* mColorBox = nullptr;
159  ColorPaletteWidget* mColorPalette = nullptr;
160  DisplayOptionWidget* mDisplayOptionWidget = nullptr;
161  ToolOptionWidget* mToolOptions = nullptr;
162  ToolBoxWidget* mToolBox = nullptr;
163  //Timeline2* mTimeline2 = nullptr;
164  RecentFileMenu* mRecentFileMenu = nullptr;
165  PreferencesDialog* mPrefDialog = nullptr;
166  //PreviewWidget* mPreview = nullptr;
167  TimeLine* mTimeLine = nullptr;
168  ColorInspector* mColorInspector = nullptr;
169  OnionSkinWidget* mOnionSkinWidget = nullptr;
170  QToolBar* mMainToolbar = nullptr;
171  QToolBar* mViewToolbar = nullptr;
172  QToolBar* mOverlayToolbar = nullptr;
173 
174  // backup
175  BackupElement* mBackupAtSave = nullptr;
176 
177  PegBarAlignmentDialog* mPegAlign = nullptr;
178  RepositionFramesDialog* mReposDialog = nullptr;
179  LayerOpacityDialog* mLayerOpacityDialog = nullptr;
180 
181  void createToolbars();
182 private:
183  ActionCommands* mCommands = nullptr;
184  QList<BaseDockWidget*> mDockWidgets;
185  QList<QToolBar*> mToolbars;
186 
187  QIcon mStartIcon;
188  QIcon mStopIcon;
189 
190  // a hack for MacOS because closeEvent fires twice
191  bool m2ndCloseEvent = false;
192 
193  // Whether to suppress the auto save dialog due to internal work
194  bool mSuppressAutoSaveDialog = false;
195 
196  Ui::MainWindow2* ui = nullptr;
197 };
198 
199 #endif // MAINWINDOW2_H
void windowActivated()
Emitted when window regains focus.
Q_OBJECTQ_OBJECT
The status bar of Pencil2D's main window.
Definition: statusbar.h:33
Definition: object.h:41
Definition: editor.h:55
QObject * parent() const const