Implemented program specific settings, in particular the debugger command
[kdbg.git] / kdbg / pgmsettings.cpp
blobff5cf9aed4b3d546f47f616575be3cce5c536cba
1 // $Id$
3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
6 #include "pgmsettings.h"
7 #if QT_VERSION >= 200
8 #include <klocale.h> /* i18n */
9 #endif
10 #include <kapp.h>
11 #include <qlayout.h>
12 #include <qlineedit.h>
13 #include <qlabel.h>
14 #include <qradiobutton.h>
15 #include <qbuttongroup.h>
16 #include "mydebug.h"
19 ChooseDriver::ChooseDriver(QWidget* parent) :
20 QWidget(parent, "driver")
22 QVBoxLayout* layout = new QVBoxLayout(this, 10);
24 QLabel* label = new QLabel(this);
25 label->setText(i18n("How to invoke &GDB - leave empty to use\n"
26 "the default from the global options:"));
27 label->setMinimumSize(label->sizeHint());
28 layout->addWidget(label);
30 m_debuggerCmd = new QLineEdit(this);
31 m_debuggerCmd->setMinimumSize(m_debuggerCmd->sizeHint());
32 layout->addWidget(m_debuggerCmd);
33 label->setBuddy(m_debuggerCmd);
35 layout->addStretch(10);
38 void ChooseDriver::setDebuggerCmd(const QString& cmd)
40 m_debuggerCmd->setText(cmd);
43 QString ChooseDriver::debuggerCmd() const
45 return m_debuggerCmd->text();
49 OutputSettings::OutputSettings(QWidget* parent) :
50 QWidget(parent, "output")
52 // the group is invisible
53 m_group = new QButtonGroup(this);
54 m_group->hide();
56 QVBoxLayout* layout = new QVBoxLayout(this, 10);
58 QRadioButton* btn;
60 btn = new QRadioButton(i18n("&No input and output"), this);
61 m_group->insert(btn, 0);
62 btn->setMinimumSize(btn->sizeHint());
63 layout->addWidget(btn);
65 btn = new QRadioButton(i18n("&Only output, simple terminal emulation"), this);
66 m_group->insert(btn, 1);
67 btn->setMinimumSize(btn->sizeHint());
68 layout->addWidget(btn);
70 btn = new QRadioButton(i18n("&Full terminal emulation"), this);
71 m_group->insert(btn, 7);
72 btn->setMinimumSize(btn->sizeHint());
73 layout->addWidget(btn);
75 layout->addStretch(10);
77 // there is no simpler way to get to the active button than
78 // to connect to a signal
79 connect(m_group, SIGNAL(clicked(int)), SLOT(slotLevelChanged(int)));
82 void OutputSettings::setTTYLevel(int l)
84 m_group->setButton(l);
85 m_ttyLevel = l;
88 void OutputSettings::slotLevelChanged(int id)
90 m_ttyLevel = id;
91 TRACE("new ttyLevel: " + QString().setNum(id));
96 ProgramSettings::ProgramSettings(QWidget* parent, QString exeName, bool modal) :
97 QTabDialog(parent, "program_settings", modal),
98 m_chooseDriver(this),
99 m_output(this)
101 // construct title
102 int slash = exeName.findRev('/');
103 if (slash >= 0) {
104 #if QT_VERSION < 200
105 exeName.detach();
106 #endif
107 exeName.remove(0, slash+1);
109 QString cap = kapp->getCaption();
110 QString fmt = i18n("%s: Settings for %s");
111 SIZED_QString(title, fmt.length() + cap.length() + exeName.length());
112 title.sprintf(fmt, cap.data(), exeName.data());
113 setCaption(title);
115 setCancelButton(i18n("Cancel"));
116 setOKButton(i18n("OK"));
117 setDefaultButton(i18n("&Help"));
119 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotHelp()));
121 addTab(&m_chooseDriver, i18n("&Debugger"));
122 addTab(&m_output, i18n("&Output"));
125 void ProgramSettings::slotHelp()
127 QString section;
129 #if QT_VERSION >= 200
130 // find active page and jump to its section
131 QWidget* curWidget = currentPage();
132 if (curWidget != 0) {
133 section = curWidget->name();
135 #endif
136 TRACE("invoking help: pgmsettings.html section #" + section);
137 kapp->invokeHTMLHelp("kdbg/pgmsettings.html", section);
140 #include "pgmsettings.moc"