2 * Copyright Johannes Sixt
3 * This file is licensed under the GNU General Public License Version 2.
4 * See the file COPYING in the toplevel directory of the source directory.
8 #include <klocalizedstring.h> /* i18n */
10 PrefMisc::PrefMisc(QWidget
* parent
) :
13 m_popForeground(this),
14 m_backTimeoutLabel(this),
16 m_tabWidthLabel(this),
18 m_sourceFilterLabel(this),
20 m_headerFilterLabel(this),
23 m_popForeground
.setText(i18n("&Pop into foreground when program stops"));
24 m_popForeground
.setMinimumSize(m_popForeground
.sizeHint());
25 m_grid
.addWidget(&m_popForeground
, 0, 0, 1, 2);
26 m_grid
.addItem(new QSpacerItem(0, m_popForeground
.sizeHint().height()), 0, 0);
28 m_backTimeoutLabel
.setText(i18n("Time until window goes &back (in milliseconds):"));
29 m_backTimeoutLabel
.setMinimumSize(m_backTimeoutLabel
.sizeHint());
30 m_backTimeoutLabel
.setBuddy(&m_backTimeout
);
31 m_backTimeout
.setMinimumSize(m_backTimeout
.sizeHint());
32 m_grid
.addWidget(&m_backTimeoutLabel
, 1, 0);
33 m_grid
.addWidget(&m_backTimeout
, 1, 1);
35 setupEditGroup(i18n("&Tabstop every (characters):"),
36 m_tabWidthLabel
, m_tabWidth
, 2);
37 setupEditGroup(i18n("File filter for &source files:"),
38 m_sourceFilterLabel
, m_sourceFilter
, 3);
39 setupEditGroup(i18n("File filter for &header files:"),
40 m_headerFilterLabel
, m_headerFilter
, 4);
42 m_grid
.setColumnStretch(1, 10);
43 // last (empty) row gets all the vertical stretch
44 m_grid
.setRowStretch(5, 10);
47 void PrefMisc::setupEditGroup(const QString
& label
, QLabel
& labWidget
, QLineEdit
& edit
, int row
)
49 labWidget
.setText(label
);
50 labWidget
.setMinimumSize(labWidget
.sizeHint());
51 labWidget
.setBuddy(&edit
);
52 edit
.setMinimumSize(edit
.sizeHint());
53 m_grid
.addWidget(&labWidget
, row
, 0);
54 m_grid
.addWidget(&edit
, row
, 1);
57 static int readNumeric(const QLineEdit
& edit
)
59 QString str
= edit
.text();
63 int PrefMisc::backTimeout() const
65 return readNumeric(m_backTimeout
);
68 void PrefMisc::setBackTimeout(int to
)
72 m_backTimeout
.setText(str
);
75 int PrefMisc::tabWidth() const
77 return readNumeric(m_tabWidth
);
80 void PrefMisc::setTabWidth(int tw
)
84 m_tabWidth
.setText(str
);