1 #pragma once
2 
3 #ifndef STARTUPPOPUP_H
4 #define STARTUPPOPUP_H
5 
6 #include "toonzqt/dvdialog.h"
7 #include "toonzqt/doublefield.h"
8 #include "toonzqt/intfield.h"
9 #include "toonzqt/filefield.h"
10 #include "toonzqt/camerasettingswidget.h"
11 #include <QPushButton>
12 #include <QLabel>
13 #include <QCheckBox>
14 #include <QGroupBox>
15 
16 // forward declaration
17 class QLabel;
18 class QComboBox;
19 class StartupLabel;
20 
21 //=============================================================================
22 // LevelCreatePopup
23 //-----------------------------------------------------------------------------
24 
25 class StartupPopup final : public DVGui::Dialog {
26   Q_OBJECT
27 
28   DVGui::LineEdit *m_nameFld;
29   DVGui::FileField *m_pathFld;
30   QLabel *m_widthLabel;
31   QLabel *m_heightLabel;
32   QLabel *m_fpsLabel;
33   QLabel *m_resXLabel;
34   QLabel *m_resTextLabel;
35   QLabel *m_dpiLabel;
36   QLabel *m_sceneNameLabel;
37   DVGui::DoubleLineEdit *m_dpiFld;
38   DVGui::MeasuredDoubleLineEdit *m_widthFld;
39   DVGui::MeasuredDoubleLineEdit *m_heightFld;
40   DVGui::DoubleLineEdit *m_fpsFld;
41   DVGui::DoubleLineEdit *m_resXFld;
42   DVGui::DoubleLineEdit *m_resYFld;
43   DVGui::IntLineEdit *m_autoSaveTimeFld;
44   QList<QString> m_sceneNames;
45   QList<TFilePath> m_projectPaths;
46   QCheckBox *m_showAtStartCB;
47   QCheckBox *m_autoSaveOnCB;
48   QComboBox *m_projectsCB;
49   QComboBox *m_unitsCB;
50   QPushButton *m_loadOtherSceneButton;
51   QPushButton *m_newProjectButton;
52   QComboBox *m_presetCombo;
53   QPushButton *m_addPresetBtn, *m_removePresetBtn;
54   CameraSettingsWidget *m_cameraSettingsWidget;
55   double m_dpi;
56   int m_xRes, m_yRes;
57   const int RECENT_SCENES_MAX_COUNT = 10;
58   bool m_updating                   = false;
59   QString m_presetListFile;
60   QGroupBox *m_projectBox;
61   QGroupBox *m_sceneBox;
62   QGroupBox *m_recentBox;
63   QVBoxLayout *m_recentSceneLay;
64   QVector<StartupLabel *> m_recentNamesLabels;
65 
66 public:
67   StartupPopup();
68 
69 protected:
70   void showEvent(QShowEvent *) override;
71   void loadPresetList();
72   void savePresetList();
73   void refreshRecentScenes();
74   QString aspectRatioValueToString(double value, int width = 0, int height = 0);
75   double aspectRatioStringToValue(const QString &s);
76   bool parsePresetString(const QString &str, QString &name, int &xres,
77                          int &yres, double &fx, double &fy, QString &xoffset,
78                          QString &yoffset, double &ar, bool forCleanup = false);
79 
80 public slots:
81   void onRecentSceneClicked(int index);
82   void onCreateButton();
83   void onShowAtStartChanged(int index);
84   void updateProjectCB();
85   void onProjectChanged(int index);
86   void onNewProjectButtonPressed();
87   void onLoadSceneButtonPressed();
88   void onSceneChanged();
89   void updateResolution();
90   void updateSize();
91   void onDpiChanged();
92   void addPreset();
93   void removePreset();
94   void onPresetSelected(const QString &str);
95   void onCameraUnitChanged(int index);
96   void onAutoSaveOnChanged(int index);
97   void onAutoSaveTimeChanged();
98 };
99 
100 class StartupLabel : public QLabel {
101   Q_OBJECT
102 public:
103   explicit StartupLabel(const QString &text = "", QWidget *parent = 0,
104                         int index = -1);
105   ~StartupLabel();
106   QString m_text;
107   int m_index;
108 signals:
109   void wasClicked(int index);
110 
111 protected:
112   void mousePressEvent(QMouseEvent *event);
113 };
114 
115 #endif  // STARTUPPOPUP_H
116