]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QBoxDialog.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / 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 //Added by qt3to4:
15 #include <QCloseEvent>
16
17 #include "lengthcombo.h"
18 #include "validators.h"
19 #include "QBox.h"
20 #include "qt_helpers.h"
21
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
24
25 namespace lyx {
26 namespace frontend {
27
28 QBoxDialog::QBoxDialog(QBox * form)
29         : form_(form)
30 {
31         setupUi(this);
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()));
40
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() ) );
53
54         heightED->setValidator(unsignedLengthValidator(heightED));
55         widthED->setValidator(unsignedLengthValidator(widthED));
56 }
57
58
59 void QBoxDialog::closeEvent(QCloseEvent * e)
60 {
61         form_->slotWMHide();
62         e->accept();
63 }
64
65
66 void QBoxDialog::change_adaptor()
67 {
68         form_->changed();
69 }
70
71
72 void QBoxDialog::innerBoxChanged(const QString & str)
73 {
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);
81 }
82
83
84 void QBoxDialog::typeChanged(int index)
85 {
86         bool frameless = (index == 0);
87         if (frameless) {
88                 valignCO->setEnabled(true);
89                 ialignCO->setEnabled(true);
90                 halignCO->setEnabled(false);
91                 heightED->setEnabled(true);
92                 heightUnitsLC->setEnabled(true);
93                 form_->setSpecial(true);
94         }
95         int itype = innerBoxCO->currentIndex();
96         form_->setInnerType(frameless, itype);
97 }
98
99
100 void QBoxDialog::restoreClicked()
101 {
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->itemText(j) == qt_("Total Height"))
108                         heightUnitsLC->setCurrentItem(j);
109         }
110 }
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #include "QBoxDialog_moc.cpp"