]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QGraphicsDialog.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / qt2 / 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  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "QGraphicsDialog.h"
15 #include "QGraphics.h"
16
17 #include "lengthcombo.h"
18 #include "lengthvalidator.h"
19 #include "qt_helpers.h"
20
21 #include "debug.h"
22
23 #include "controllers/ControlGraphics.h"
24
25 #include <qpushbutton.h>
26 #include <qlineedit.h>
27 #include <qvalidator.h>
28
29
30 using std::string;
31
32 namespace lyx {
33 namespace frontend {
34
35
36 namespace {
37
38 LengthValidator * unsignedLengthValidator(QLineEdit * ed)
39 {
40         LengthValidator * v = new LengthValidator(ed);
41         v->setBottom(LyXLength());
42         return v;
43 }
44
45 } // namespace anon
46
47
48 QGraphicsDialog::QGraphicsDialog(QGraphics * form)
49         : QGraphicsDialogBase(0, 0, false, 0),
50         form_(form)
51 {
52         connect(okPB, SIGNAL(clicked()),
53                 form, SLOT(slotOK()));
54         connect(applyPB, SIGNAL(clicked()),
55                 form, SLOT(slotApply()));
56         connect(closePB, SIGNAL(clicked()),
57                 form, SLOT(slotClose()));
58         connect(restorePB, SIGNAL(clicked()),
59                 form, SLOT(slotRestore()));
60         connect(editPB, SIGNAL(clicked()),
61                 this, SLOT(edit_clicked()));
62                 
63         angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
64
65         lbX->setValidator(new QIntValidator(lbX));
66         lbY->setValidator(new QIntValidator(lbY));
67         rtX->setValidator(new QIntValidator(rtX));
68         rtY->setValidator(new QIntValidator(rtY));
69                 
70         displayscale->setValidator(new QIntValidator(displayscale));
71         height->setValidator(unsignedLengthValidator(height));
72         width->setValidator(unsignedLengthValidator(width));
73 }
74
75
76 void QGraphicsDialog::show()
77 {
78         QGraphicsDialogBase::show();
79         filename->setFocus();
80 }
81
82
83 void QGraphicsDialog::change_adaptor()
84 {
85         form_->changed();
86 }
87
88
89 void QGraphicsDialog::change_bb()
90 {
91         form_->controller().bbChanged = true;
92         lyxerr[Debug::GRAPHICS]
93                 << "[controller().bb_Changed set to true]\n";
94         form_->changed();
95 }
96
97
98 void QGraphicsDialog::change_WUnit()
99 {
100         bool useHeight = (widthUnit->currentItem() > 0);
101         height->setEnabled(useHeight);
102         heightUnit->setEnabled(useHeight);
103         form_->changed();
104 }
105
106
107 void QGraphicsDialog::closeEvent(QCloseEvent * e)
108 {
109         form_->slotWMHide();
110         e->accept();
111 }
112
113
114 void QGraphicsDialog::browse_clicked()
115 {
116         string const str =
117                 form_->controller().browse(fromqstr(filename->text()));
118         filename->setText(toqstr(str));
119         form_->changed();
120 }
121
122
123 void QGraphicsDialog::getBB_clicked()
124 {
125         form_->getBB();
126 }
127
128
129 void QGraphicsDialog::edit_clicked()
130 {
131         form_->controller().editGraphics();
132 }
133
134 } // namespace frontend
135 } // namespace lyx