1 // Copyright (C) 2012-2019 The VPaint Developers.
2 // See the COPYRIGHT file at the top-level directory of this distribution
3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef EXPORTPNGDIALOG_H
18 #define EXPORTPNGDIALOG_H
19 
20 #include <QDialog>
21 
22 class QCheckBox;
23 class QSpinBox;
24 class QDoubleSpinBox;
25 class Scene;
26 
27 class ExportPngDialog: public QDialog
28 {
29     Q_OBJECT
30 
31 public:
32     ExportPngDialog(Scene * scene);
33 
34     // Reimplements from QDialog
35     void setVisible(bool visible);
36 
37     // Access linked scene
38     Scene * scene() const;
39 
40     // Access canvas settings
41     double left() const;
42     double top() const;
43     double width() const;
44     double height() const;
45 
46     // Access png settings
47     int pngWidth() const;
48     int pngHeight() const;
49     bool preserveAspectRatio() const;
50     bool exportSequence() const;
51     bool useViewSettings() const;
52 
53 public slots:
54     // Reimplements from QDialog
55     void accept();
56     void reject();
57 
58     // Backend <-> Frontend conversions
59     void updateDialogFromScene();
60     void updateSceneFromDialog();
61 
62 private slots:
63     void processCanvasSizeChanged_();
64     void processPngWidthChanged_(int w);
65     void processPngHeightChanged_(int h);
66     void processPreserveAspectRatioChanged_(bool b);
67 
68 private:
69     Scene * scene_;
70 
71     QDoubleSpinBox * topSpinBox_;
72     QDoubleSpinBox * leftSpinBox_;
73     QDoubleSpinBox * widthSpinBox_;
74     QDoubleSpinBox * heightSpinBox_;
75 
76     QSpinBox * pngWidthSpinBox_;
77     QSpinBox * pngHeightSpinBox_;
78     QCheckBox * preserveAspectRatioCheckBox_;
79     QCheckBox * exportSequenceCheckBox_;
80     QCheckBox * useViewSettings_;
81 
82     double oldTop_;
83     double oldLeft_;
84     double oldWidth_;
85     double oldHeight_;
86 
87     bool ignoreSceneChanged_;
88     bool ignoreWidthHeightChanged_;
89 
90     void backupCurrentCanvasSize_();
91     void enforcePngAspectRatio_();
92     void setPngWidthForHeight_();
93     void setPngHeightForWidth_();
94 };
95 
96 
97 #endif // EXPORTPNGDIALOG_H
98