Make toolbar visible again.
[kdbg.git] / kdbg / pgmsettings.cpp
blobdf0ecfd0d184a9dfb69eb4c788ade1d95c707e72
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 "config.h"
17 #include "mydebug.h"
20 ChooseDriver::ChooseDriver(QWidget* parent) :
21 QWidget(parent, "driver")
23 QVBoxLayout* layout = new QVBoxLayout(this, 10);
25 QLabel* label = new QLabel(this);
26 label->setText(i18n("How to invoke &GDB - leave empty to use\n"
27 "the default from the global options:"));
28 label->setMinimumSize(label->sizeHint());
29 layout->addWidget(label);
31 m_debuggerCmd = new QLineEdit(this);
32 m_debuggerCmd->setMinimumSize(m_debuggerCmd->sizeHint());
33 layout->addWidget(m_debuggerCmd);
34 label->setBuddy(m_debuggerCmd);
36 layout->addStretch(10);
39 void ChooseDriver::setDebuggerCmd(const QString& cmd)
41 m_debuggerCmd->setText(cmd);
44 QString ChooseDriver::debuggerCmd() const
46 return m_debuggerCmd->text();
50 OutputSettings::OutputSettings(QWidget* parent) :
51 QWidget(parent, "output")
53 // the group is invisible
54 m_group = new QButtonGroup(this);
55 m_group->hide();
57 QVBoxLayout* layout = new QVBoxLayout(this, 10);
59 QRadioButton* btn;
61 btn = new QRadioButton(i18n("&No input and output"), this);
62 m_group->insert(btn, 0);
63 btn->setMinimumSize(btn->sizeHint());
64 layout->addWidget(btn);
66 btn = new QRadioButton(i18n("&Only output, simple terminal emulation"), this);
67 m_group->insert(btn, 1);
68 btn->setMinimumSize(btn->sizeHint());
69 layout->addWidget(btn);
71 btn = new QRadioButton(i18n("&Full terminal emulation"), this);
72 m_group->insert(btn, 7);
73 btn->setMinimumSize(btn->sizeHint());
74 layout->addWidget(btn);
76 layout->addStretch(10);
78 // there is no simpler way to get to the active button than
79 // to connect to a signal
80 connect(m_group, SIGNAL(clicked(int)), SLOT(slotLevelChanged(int)));
83 void OutputSettings::setTTYLevel(int l)
85 m_group->setButton(l);
86 m_ttyLevel = l;
89 void OutputSettings::slotLevelChanged(int id)
91 m_ttyLevel = id;
92 TRACE("new ttyLevel: " + QString().setNum(id));
97 ProgramSettings::ProgramSettings(QWidget* parent, QString exeName, bool modal) :
98 QTabDialog(parent, "program_settings", modal),
99 m_chooseDriver(this),
100 m_output(this)
102 // construct title
103 int slash = exeName.findRev('/');
104 if (slash >= 0) {
105 #if QT_VERSION < 200
106 exeName.detach();
107 #endif
108 exeName.remove(0, slash+1);
110 QString cap = kapp->getCaption();
111 QString fmt = i18n("%s: Settings for %s");
112 SIZED_QString(title, fmt.length() + cap.length() + exeName.length());
113 title.sprintf(fmt, cap.data(), exeName.data());
114 setCaption(title);
116 setCancelButton(i18n("Cancel"));
117 setOKButton(i18n("OK"));
118 setDefaultButton(i18n("&Help"));
120 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotHelp()));
122 addTab(&m_chooseDriver, i18n("&Debugger"));
123 addTab(&m_output, i18n("&Output"));
126 void ProgramSettings::slotHelp()
128 QString section;
130 #if QT_VERSION >= 200
131 // find active page and jump to its section
132 QWidget* curWidget = currentPage();
133 if (curWidget != 0) {
134 section = curWidget->name();
136 #endif
137 TRACE("invoking help: pgmsettings.html section #" + section);
138 kapp->invokeHTMLHelp("kdbg/pgmsettings.html", section);
141 #include "pgmsettings.moc"