3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
13 #include "QBoxDialog.h"
15 #include <QCloseEvent>
17 #include "lengthcombo.h"
18 #include "validators.h"
20 #include "qt_helpers.h"
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
28 QBoxDialog::QBoxDialog(QBox * form)
32 connect(restorePB, SIGNAL(clicked()),
33 form, SLOT(slotRestore()));
34 connect(okPB, SIGNAL(clicked()),
35 form, SLOT(slotOK()));
36 connect(applyPB, SIGNAL(clicked()),
37 form, SLOT(slotApply()));
38 connect(closePB, SIGNAL(clicked()),
39 form, SLOT(slotClose()));
41 connect( widthED, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
42 connect( widthUnitsLC, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) );
43 connect( valignCO, SIGNAL( highlighted(const QString&) ), this, SLOT( change_adaptor() ) );
44 connect( heightED, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
45 connect( heightUnitsLC, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) );
46 connect( restorePB, SIGNAL( clicked() ), this, SLOT( restoreClicked() ) );
47 connect( typeCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
48 connect( typeCO, SIGNAL( activated(int) ), this, SLOT( typeChanged(int) ) );
49 connect( halignCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
50 connect( ialignCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
51 connect( innerBoxCO, SIGNAL( activated(const QString&) ), this, SLOT( innerBoxChanged(const QString &) ) );
52 connect( innerBoxCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
54 heightED->setValidator(unsignedLengthValidator(heightED));
55 widthED->setValidator(unsignedLengthValidator(widthED));
59 void QBoxDialog::closeEvent(QCloseEvent * e)
66 void QBoxDialog::change_adaptor()
72 void QBoxDialog::innerBoxChanged(const QString & str)
74 bool ibox = (str != qt_("None"));
75 valignCO->setEnabled(ibox);
76 ialignCO->setEnabled(ibox);
77 halignCO->setEnabled(!ibox);
78 heightED->setEnabled(ibox);
79 heightUnitsLC->setEnabled(ibox);
80 form_->setSpecial(ibox);
84 void QBoxDialog::typeChanged(int index)
86 bool frameless = (index == 0);
88 valignCO->setEnabled(true);
89 ialignCO->setEnabled(true);
90 halignCO->setEnabled(false);
91 heightED->setEnabled(true);
92 heightUnitsLC->setEnabled(true);
93 form_->setSpecial(true);
95 int itype = innerBoxCO->currentItem();
96 form_->setInnerType(frameless, itype);
100 void QBoxDialog::restoreClicked()
102 form_->setInnerType(true, 2);
103 widthED->setText("100");
104 widthUnitsLC->setCurrentItem(LyXLength::PCW);
105 heightED->setText("1");
106 for (int j = 0; j < heightUnitsLC->count(); j++) {
107 if (heightUnitsLC->text(j) == qt_("Total Height"))
108 heightUnitsLC->setCurrentItem(j);
112 } // namespace frontend
115 #include "QBoxDialog_moc.cpp"