]> git.lyx.org Git - features.git/blob - src/frontends/qt3/QBoxDialog.C
6bd909759aa3552961b19efca70e2cf897e0a29a
[features.git] / src / frontends / qt3 / 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 "validators.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 QBoxDialog::QBoxDialog(QBox * form)
28         : QBoxDialogBase(0, 0, false, 0),
29         form_(form)
30 {
31         connect(restorePB, SIGNAL(clicked()),
32                 form, SLOT(slotRestore()));
33         connect(okPB, SIGNAL(clicked()),
34                 form, SLOT(slotOK()));
35         connect(applyPB, SIGNAL(clicked()),
36                 form, SLOT(slotApply()));
37         connect(closePB, SIGNAL(clicked()),
38                 form, SLOT(slotClose()));
39
40         heightED->setValidator(unsignedLengthValidator(heightED));
41         widthED->setValidator(unsignedLengthValidator(widthED));
42 }
43
44
45 void QBoxDialog::closeEvent(QCloseEvent * e)
46 {
47         form_->slotWMHide();
48         e->accept();
49 }
50
51
52 void QBoxDialog::change_adaptor()
53 {
54         form_->changed();
55 }
56
57
58 void QBoxDialog::innerBoxChanged(const QString & str)
59 {
60         bool ibox = (str != qt_("None"));
61         valignCO->setEnabled(ibox);
62         ialignCO->setEnabled(ibox);
63         halignCO->setEnabled(!ibox);
64         heightED->setEnabled(ibox);
65         heightUnitsLC->setEnabled(ibox);
66         form_->setSpecial(ibox);
67 }
68
69
70 void QBoxDialog::typeChanged(int index)
71 {
72         bool frameless = (index == 0);
73         if (frameless) {
74                 valignCO->setEnabled(true);
75                 ialignCO->setEnabled(true);
76                 halignCO->setEnabled(false);
77                 heightED->setEnabled(true);
78                 heightUnitsLC->setEnabled(true);
79                 form_->setSpecial(true);
80         }
81         int itype = innerBoxCO->currentItem();
82         form_->setInnerType(frameless, itype);
83 }
84
85
86 void QBoxDialog::restoreClicked()
87 {
88         form_->setInnerType(true, 2);
89         widthED->setText("100");
90         widthUnitsLC->setCurrentItem(LyXLength::PCW);
91         heightED->setText("1");
92         for (int j = 0; j < heightUnitsLC->count(); j++) {
93                 if (heightUnitsLC->text(j) == qt_("Total Height"))
94                         heightUnitsLC->setCurrentItem(j);
95         }
96 }
97
98 } // namespace frontend
99 } // namespace lyx