]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QBoxDialog.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / qt2 / QBoxDialog.C
1 /**
2  * \file QBoxDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QBoxDialog.h"
14
15 #include "lengthcombo.h"
16 #include "lengthvalidator.h"
17 #include "QBox.h"
18 #include "qt_helpers.h"
19
20 #include <qcombobox.h>
21 #include <qlineedit.h>
22 #include <qpushbutton.h>
23
24 namespace lyx {
25 namespace frontend {
26
27 namespace {
28
29 LengthValidator * unsignedLengthValidator(QLineEdit * ed)
30 {
31         LengthValidator * v = new LengthValidator(ed);
32         v->setBottom(LyXLength());
33         return v;
34 }
35
36 } // namespace anon
37
38
39 QBoxDialog::QBoxDialog(QBox * form)
40         : QBoxDialogBase(0, 0, false, 0),
41         form_(form)
42 {
43         connect(restorePB, SIGNAL(clicked()),
44                 form, SLOT(slotRestore()));
45         connect(okPB, SIGNAL(clicked()),
46                 form, SLOT(slotOK()));
47         connect(applyPB, SIGNAL(clicked()),
48                 form, SLOT(slotApply()));
49         connect(closePB, SIGNAL(clicked()),
50                 form, SLOT(slotClose()));
51                 
52         heightED->setValidator(unsignedLengthValidator(heightED));
53         widthED->setValidator(unsignedLengthValidator(widthED));
54 }
55
56
57 void QBoxDialog::closeEvent(QCloseEvent * e)
58 {
59         form_->slotWMHide();
60         e->accept();
61 }
62
63
64 void QBoxDialog::change_adaptor()
65 {
66         form_->changed();
67 }
68
69
70 void QBoxDialog::innerBoxChanged(const QString & str)
71 {
72         bool ibox = (str != qt_("None"));
73         valignCO->setEnabled(ibox);
74         ialignCO->setEnabled(ibox);
75         halignCO->setEnabled(!ibox);
76         heightED->setEnabled(ibox);
77         heightUnitsLC->setEnabled(ibox);
78         form_->setSpecial(ibox);
79 }
80
81
82 void QBoxDialog::typeChanged(int index)
83 {
84         bool frameless = (index == 0);
85         if (frameless) {
86                 valignCO->setEnabled(true);
87                 ialignCO->setEnabled(true);
88                 halignCO->setEnabled(false);
89                 heightED->setEnabled(true);
90                 heightUnitsLC->setEnabled(true);
91                 form_->setSpecial(true);
92         }
93         int itype = innerBoxCO->currentItem();
94         form_->setInnerType(frameless, itype);
95 }
96
97
98 void QBoxDialog::restoreClicked()
99 {
100         form_->setInnerType(true, 2);
101         widthED->setText("100");
102         widthUnitsLC->setCurrentItem(LyXLength::PCW);
103         heightED->setText("1");
104         for (int j = 0; j < heightUnitsLC->count(); j++) {
105                 if (heightUnitsLC->text(j) == qt_("Total Height"))
106                         heightUnitsLC->setCurrentItem(j);
107         }
108 }
109
110 } // namespace frontend
111 } // namespace lyx