]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QGraphicsDialog.C
enable Font cache only for MacOSX and inline width() for other platform.
[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( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( filenameChanged(const QString&) ) );
58         connect( subcaption, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
59         connect( subfigure, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
60         connect( latexoptions, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
61         connect( clip, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
62         connect( lbX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
63         connect( showCB, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
64         connect( displayscale, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
65         connect( Width, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
66         connect( widthUnit, SIGNAL( activated(int) ), this, SLOT( change_WUnit() ) );
67         connect( aspectratio, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
68         connect( displayCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
69         connect( draftCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
70         connect( unzipCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) );
71         connect( displayCB, SIGNAL( toggled(bool) ), showCB, SLOT( setEnabled(bool) ) );
72         connect( displayCB, SIGNAL( toggled(bool) ), displayscale, SLOT( setEnabled(bool) ) );
73         connect( Height, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
74         connect( heightUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) );
75         connect( angle, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
76         connect( origin, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
77         connect( getPB, SIGNAL( clicked() ), this, SLOT( getBB_clicked() ) );
78         connect( getPB, SIGNAL( clicked() ), this, SLOT( change_adaptor() ) );
79         connect( lbY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
80         connect( rtX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
81         connect( rtY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) );
82         connect( lbXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
83         connect( lbYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
84         connect( rtXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
85         connect( rtYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) );
86
87         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
88
89         lbX->setValidator(new QIntValidator(lbX));
90         lbY->setValidator(new QIntValidator(lbY));
91         rtX->setValidator(new QIntValidator(rtX));
92         rtY->setValidator(new QIntValidator(rtY));
93
94         displayscale->setValidator(new QIntValidator(displayscale));
95         Height->setValidator(unsignedLengthValidator(Height));
96         Width->setValidator(unsignedLengthValidator(Width));
97
98         filename->setValidator(new PathValidator(true, filename));
99 }
100
101
102 void QGraphicsDialog::show()
103 {
104         QDialog::show();
105         filename->setFocus();
106 }
107
108
109 void QGraphicsDialog::change_adaptor()
110 {
111         form_->changed();
112 }
113
114
115 void QGraphicsDialog::change_bb()
116 {
117         form_->controller().bbChanged = true;
118         lyxerr[Debug::GRAPHICS]
119                 << "[controller().bb_Changed set to true]\n";
120         form_->changed();
121 }
122
123
124 void QGraphicsDialog::change_WUnit()
125 {
126         bool useHeight = (widthUnit->currentIndex() > 0);
127         Height->setEnabled(useHeight);
128         heightUnit->setEnabled(useHeight);
129         heightL->setEnabled(useHeight);
130         form_->changed();
131 }
132
133
134 void QGraphicsDialog::closeEvent(QCloseEvent * e)
135 {
136         form_->slotWMHide();
137         e->accept();
138 }
139
140
141 void QGraphicsDialog::browse_clicked()
142 {
143         string const str =
144                 form_->controller().browse(fromqstr(filename->text()));
145         filename->setText(toqstr(str));
146         form_->changed();
147 }
148
149
150 void QGraphicsDialog::getBB_clicked()
151 {
152         form_->getBB();
153 }
154
155
156 void QGraphicsDialog::edit_clicked()
157 {
158         form_->controller().editGraphics();
159 }
160
161 void QGraphicsDialog::filenameChanged(const QString & filename)
162 {
163         editPB->setDisabled(filename.isEmpty());
164 }
165
166 } // namespace frontend
167 } // namespace lyx
168
169 #include "QGraphicsDialog_moc.cpp"