]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QGraphicsDialog.C
This new citation dialog follows a new design similar to lyx-1.3:
[lyx.git] / src / frontends / qt4 / QGraphicsDialog.C
1 /**
2  * \file QGraphicsDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Herbert Voß
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "QGraphicsDialog.h"
16 #include "QGraphics.h"
17 //Added by qt3to4:
18 #include <QCloseEvent>
19
20 #include "lengthcombo.h"
21 #include "validators.h"
22 #include "qt_helpers.h"
23
24 #include "debug.h"
25
26 #include "controllers/ControlGraphics.h"
27
28 #include <qpushbutton.h>
29 #include <qlineedit.h>
30 #include <qvalidator.h>
31
32
33 using std::string;
34
35 namespace lyx {
36 namespace frontend {
37
38
39 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
40         : form_(form)
41 {
42         setupUi(this);
43         connect(okPB, SIGNAL(clicked()),
44                 form, SLOT(slotOK()));
45         connect(applyPB, SIGNAL(clicked()),
46                 form, SLOT(slotApply()));
47         connect(closePB, SIGNAL(clicked()),
48                 form, SLOT(slotClose()));
49         connect(restorePB, SIGNAL(clicked()),
50                 form, SLOT(slotRestore()));
51         connect(editPB, SIGNAL(clicked()),
52                 this, SLOT(edit_clicked()));
53
54     connect( subfigure, SIGNAL( toggled(bool) ), subcaption, SLOT( setEnabled(bool) ) );
55     connect( browsePB, SIGNAL( clicked() ), this, SLOT( browse_clicked() ) );
56     connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
57     connect( subcaption, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
58     connect( subfigure, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
59     connect( latexoptions, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
60     connect( clip, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
61     connect( lbX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
62     connect( showCB, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
63     connect( displayscale, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
64     connect( Width, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
65     connect( widthUnit, SIGNAL( activated(int) ), this, SLOT( change_WUnit() ) );
66     connect( aspectratio, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
67     connect( displayCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
68     connect( draftCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
69     connect( unzipCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
70     connect( displayCB, SIGNAL( toggled(bool) ), showCB, SLOT( setEnabled(bool) ) );
71     connect( displayCB, SIGNAL( toggled(bool) ), displayscale, SLOT( setEnabled(bool) ) );
72     connect( Height, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
73     connect( heightUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) );
74     connect( angle, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
75     connect( origin, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
76     connect( getPB, SIGNAL( clicked() ), this, SLOT( getBB_clicked() ) );
77     connect( getPB, SIGNAL( clicked() ), this, SLOT( change_adaptor() ) );
78     connect( lbY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
79     connect( rtX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
80     connect( rtY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
81     connect( lbXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
82     connect( lbYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
83     connect( rtXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
84     connect( rtYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
85
86         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
87
88         lbX->setValidator(new QIntValidator(lbX));
89         lbY->setValidator(new QIntValidator(lbY));
90         rtX->setValidator(new QIntValidator(rtX));
91         rtY->setValidator(new QIntValidator(rtY));
92
93         displayscale->setValidator(new QIntValidator(displayscale));
94         Height->setValidator(unsignedLengthValidator(Height));
95         Width->setValidator(unsignedLengthValidator(Width));
96
97         filename->setValidator(new PathValidator(true, filename));
98 }
99
100
101 void QGraphicsDialog::show()
102 {
103         QDialog::show();
104         filename->setFocus();
105 }
106
107
108 void QGraphicsDialog::change_adaptor()
109 {
110         form_->changed();
111 }
112
113
114 void QGraphicsDialog::change_bb()
115 {
116         form_->controller().bbChanged = true;
117         lyxerr[Debug::GRAPHICS]
118                 << "[controller().bb_Changed set to true]\n";
119         form_->changed();
120 }
121
122
123 void QGraphicsDialog::change_WUnit()
124 {
125         bool useHeight = (widthUnit->currentItem() > 0);
126         Height->setEnabled(useHeight);
127         heightUnit->setEnabled(useHeight);
128         form_->changed();
129 }
130
131
132 void QGraphicsDialog::closeEvent(QCloseEvent * e)
133 {
134         form_->slotWMHide();
135         e->accept();
136 }
137
138
139 void QGraphicsDialog::browse_clicked()
140 {
141         string const str =
142                 form_->controller().browse(fromqstr(filename->text()));
143         filename->setText(toqstr(str));
144         form_->changed();
145 }
146
147
148 void QGraphicsDialog::getBB_clicked()
149 {
150         form_->getBB();
151 }
152
153
154 void QGraphicsDialog::edit_clicked()
155 {
156         form_->controller().editGraphics();
157 }
158
159 } // namespace frontend
160 } // namespace lyx