src/dialogs.cpp

changeset 1100
9b2797729c82
parent 1086
621c2e5853bb
child 1115
117e4880666e
equal deleted inserted replaced
1099:14276e435640 1100:9b2797729c82
24 #include "dialogs.h" 24 #include "dialogs.h"
25 #include "ui_overlay.h" 25 #include "ui_overlay.h"
26 #include "ui_extprogpath.h" 26 #include "ui_extprogpath.h"
27 27
28 extern const char* g_extProgPathFilter; 28 extern const char* g_extProgPathFilter;
29
30 // =============================================================================
31 // =============================================================================
32 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f)
33 {
34 ui = new Ui_OverlayUI;
35 ui->setupUi (this);
36
37 m_cameraArgs =
38 {
39 { ui->top, TopCamera },
40 { ui->bottom, BottomCamera },
41 { ui->front, FrontCamera },
42 { ui->back, BackCamera },
43 { ui->left, LeftCamera },
44 { ui->right, RightCamera }
45 };
46
47 Camera cam = g_win->renderer()->camera();
48
49 if (cam == FreeCamera)
50 cam = TopCamera;
51
52 connect (ui->width, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged()));
53 connect (ui->height, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged()));
54 connect (ui->buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_help()));
55 connect (ui->fileSearchButton, SIGNAL (clicked (bool)), this, SLOT (slot_fpath()));
56
57 slot_dimensionsChanged();
58 fillDefaults (cam);
59 }
60
61 // =============================================================================
62 // =============================================================================
63 OverlayDialog::~OverlayDialog()
64 {
65 delete ui;
66 }
67
68 // =============================================================================
69 // =============================================================================
70 void OverlayDialog::fillDefaults (int newcam)
71 {
72 LDGLOverlay& info = g_win->renderer()->getOverlay (newcam);
73 RadioDefault<int> (newcam, m_cameraArgs);
74
75 if (info.image)
76 {
77 ui->filename->setText (info.fileName);
78 ui->originX->setValue (info.offsetX);
79 ui->originY->setValue (info.offsetY);
80 ui->width->setValue (info.width);
81 ui->height->setValue (info.height);
82 }
83 else
84 {
85 ui->filename->setText ("");
86 ui->originX->setValue (0);
87 ui->originY->setValue (0);
88 ui->width->setValue (0.0f);
89 ui->height->setValue (0.0f);
90 }
91 }
92
93 // =============================================================================
94 // =============================================================================
95 QString OverlayDialog::fpath() const
96 {
97 return ui->filename->text();
98 }
99
100 int OverlayDialog::ofsx() const
101 {
102 return ui->originX->value();
103 }
104
105 int OverlayDialog::ofsy() const
106 {
107 return ui->originY->value();
108 }
109
110 double OverlayDialog::lwidth() const
111 {
112 return ui->width->value();
113 }
114
115 double OverlayDialog::lheight() const
116 {
117 return ui->height->value();
118 }
119
120 int OverlayDialog::camera() const
121 {
122 return RadioSwitch<int> (TopCamera, m_cameraArgs);
123 }
124
125 void OverlayDialog::slot_fpath()
126 {
127 ui->filename->setText (QFileDialog::getOpenFileName (nullptr, "Overlay image"));
128 }
129
130 void OverlayDialog::slot_help()
131 {
132 showDocumentation (g_docs_overlays);
133 }
134
135 void OverlayDialog::slot_dimensionsChanged()
136 {
137 bool enable = (ui->width->value() != 0) or (ui->height->value() != 0);
138 ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (enable);
139 }
140 29
141 // ============================================================================= 30 // =============================================================================
142 // ============================================================================= 31 // =============================================================================
143 ExtProgPathPrompt::ExtProgPathPrompt (QString progName, QWidget* parent, Qt::WindowFlags f) : 32 ExtProgPathPrompt::ExtProgPathPrompt (QString progName, QWidget* parent, Qt::WindowFlags f) :
144 QDialog (parent, f), 33 QDialog (parent, f),

mercurial