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  */
6 
7 #include "pgmsettings.h"
8 #include <klocalizedstring.h>		/* i18n */
9 #include <QFileInfo>
10 #include <QLineEdit>
11 #include <QLabel>
12 #include <QRadioButton>
13 #include <QButtonGroup>
14 #include <QVBoxLayout>
15 #include "mydebug.h"
16 
17 
ChooseDriver(QWidget * parent)18 ChooseDriver::ChooseDriver(QWidget* parent) :
19 	QWidget(parent)
20 {
21     QVBoxLayout* layout = new QVBoxLayout(this);
22 
23     QLabel* label = new QLabel(this);
24     label->setText(i18n("How to invoke &GDB - leave empty to use\n"
25 			"the default from the global options:"));
26     label->setMinimumSize(label->sizeHint());
27     layout->addWidget(label);
28 
29     m_debuggerCmd = new QLineEdit(this);
30     m_debuggerCmd->setMinimumSize(m_debuggerCmd->sizeHint());
31     layout->addWidget(m_debuggerCmd);
32     label->setBuddy(m_debuggerCmd);
33 
34     layout->addStretch();
35     this->setLayout(layout);
36 }
37 
setDebuggerCmd(const QString & cmd)38 void ChooseDriver::setDebuggerCmd(const QString& cmd)
39 {
40     m_debuggerCmd->setText(cmd);
41 }
42 
debuggerCmd() const43 QString ChooseDriver::debuggerCmd() const
44 {
45     return m_debuggerCmd->text();
46 }
47 
48 
OutputSettings(QWidget * parent)49 OutputSettings::OutputSettings(QWidget* parent) :
50 	QWidget(parent)
51 {
52     m_group = new QButtonGroup(this);
53 
54     QVBoxLayout* layout = new QVBoxLayout(this);
55 
56     QRadioButton* btn;
57 
58     btn = new QRadioButton(i18n("&No input and output"), this);
59     m_group->addButton(btn, 0);
60     layout->addWidget(btn);
61 
62     btn = new QRadioButton(i18n("&Only output, simple terminal emulation"), this);
63     m_group->addButton(btn, 1);
64     layout->addWidget(btn);
65 
66     btn = new QRadioButton(i18n("&Full terminal emulation"), this);
67     m_group->addButton(btn, 7);
68     layout->addWidget(btn);
69 
70     layout->addStretch();
71 
72     this->setLayout(layout);
73 
74     // there is no simpler way to get to the active button than
75     // to connect to a signal
76     connect(m_group, SIGNAL(buttonClicked(int)), SLOT(slotLevelChanged(int)));
77 }
78 
setTTYLevel(int l)79 void OutputSettings::setTTYLevel(int l)
80 {
81     QAbstractButton* button = m_group->button(l);
82     Q_ASSERT(button);
83     button->setChecked(true);
84     m_ttyLevel = l;
85 }
86 
slotLevelChanged(int id)87 void OutputSettings::slotLevelChanged(int id)
88 {
89     m_ttyLevel = id;
90     TRACE("new ttyLevel: " + QString().setNum(id));
91 }
92 
93 
94 
ProgramSettings(QWidget * parent,QString exeName)95 ProgramSettings::ProgramSettings(QWidget* parent, QString exeName) :
96 	KPageDialog(parent),
97 	m_chooseDriver(this),
98 	m_output(this)
99 {
100     // construct title
101     QFileInfo fi(exeName);
102     QString title = i18n("Settings for %1");
103     setWindowTitle(title.arg(fi.fileName()));
104 
105     addPage(&m_chooseDriver, i18n("Debugger"));
106     addPage(&m_output, i18n("Output"));
107 }
108 
109 #include "pgmsettings.moc"
110