Extend copyright to 2018.
[kdbg.git] / kdbg / prefmisc.cpp
blobaba3c28de3b4415c25e7dc7f5c5eb5fc1b2acbbc
1 /*
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.
5 */
7 #include "prefmisc.h"
8 #include <klocalizedstring.h> /* i18n */
10 PrefMisc::PrefMisc(QWidget* parent) :
11 QWidget(parent),
12 m_grid(this),
13 m_popForeground(this),
14 m_backTimeoutLabel(this),
15 m_backTimeout(this),
16 m_tabWidthLabel(this),
17 m_tabWidth(this),
18 m_sourceFilterLabel(this),
19 m_sourceFilter(this),
20 m_headerFilterLabel(this),
21 m_headerFilter(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();
60 return str.toInt();
63 int PrefMisc::backTimeout() const
65 return readNumeric(m_backTimeout);
68 void PrefMisc::setBackTimeout(int to)
70 QString str;
71 str.setNum(to);
72 m_backTimeout.setText(str);
75 int PrefMisc::tabWidth() const
77 return readNumeric(m_tabWidth);
80 void PrefMisc::setTabWidth(int tw)
82 QString str;
83 str.setNum(tw);
84 m_tabWidth.setText(str);