2 * \file QGraphicsDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
15 #include "QGraphicsDialog.h"
16 #include "QGraphics.h"
18 #include <QCloseEvent>
20 #include "lengthcombo.h"
21 #include "validators.h"
22 #include "qt_helpers.h"
26 #include "controllers/ControlGraphics.h"
28 #include <qpushbutton.h>
29 #include <qlineedit.h>
30 #include <qvalidator.h>
39 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
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()));
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() ) );
87 angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
89 lbX->setValidator(new QIntValidator(lbX));
90 lbY->setValidator(new QIntValidator(lbY));
91 rtX->setValidator(new QIntValidator(rtX));
92 rtY->setValidator(new QIntValidator(rtY));
94 displayscale->setValidator(new QIntValidator(displayscale));
95 Height->setValidator(unsignedLengthValidator(Height));
96 Width->setValidator(unsignedLengthValidator(Width));
98 filename->setValidator(new PathValidator(true, filename));
102 void QGraphicsDialog::show()
105 filename->setFocus();
109 void QGraphicsDialog::change_adaptor()
115 void QGraphicsDialog::change_bb()
117 form_->controller().bbChanged = true;
118 lyxerr[Debug::GRAPHICS]
119 << "[controller().bb_Changed set to true]\n";
124 void QGraphicsDialog::change_WUnit()
126 bool useHeight = (widthUnit->currentIndex() > 0);
127 Height->setEnabled(useHeight);
128 heightUnit->setEnabled(useHeight);
129 heightL->setEnabled(useHeight);
134 void QGraphicsDialog::closeEvent(QCloseEvent * e)
141 void QGraphicsDialog::browse_clicked()
144 form_->controller().browse(fromqstr(filename->text()));
145 filename->setText(toqstr(str));
150 void QGraphicsDialog::getBB_clicked()
156 void QGraphicsDialog::edit_clicked()
158 form_->controller().editGraphics();
161 void QGraphicsDialog::filenameChanged(const QString & filename)
163 editPB->setDisabled(filename.isEmpty());
166 } // namespace frontend
169 #include "QGraphicsDialog_moc.cpp"