File: pgmsettings.cpp

package info (click to toggle)
kdbg 1.2.4-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,504 kB
  • ctags: 1,945
  • sloc: cpp: 15,961; sh: 8,183; makefile: 481; perl: 71; ansic: 16
file content (141 lines) | stat: -rw-r--r-- 3,563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// $Id: pgmsettings.cpp,v 1.2 2000/03/18 14:24:53 jsixt Exp $

// Copyright by Johannes Sixt
// This file is under GPL, the GNU General Public Licence

#include "pgmsettings.h"
#if QT_VERSION >= 200
#include <klocale.h>			/* i18n */
#endif
#include <kapp.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include "config.h"
#include "mydebug.h"


ChooseDriver::ChooseDriver(QWidget* parent) :
	QWidget(parent, "driver")
{
    QVBoxLayout* layout = new QVBoxLayout(this, 10);

    QLabel* label = new QLabel(this);
    label->setText(i18n("How to invoke &GDB - leave empty to use\n"
			"the default from the global options:"));
    label->setMinimumSize(label->sizeHint());
    layout->addWidget(label);

    m_debuggerCmd = new QLineEdit(this);
    m_debuggerCmd->setMinimumSize(m_debuggerCmd->sizeHint());
    layout->addWidget(m_debuggerCmd);
    label->setBuddy(m_debuggerCmd);

    layout->addStretch(10);
}

void ChooseDriver::setDebuggerCmd(const QString& cmd)
{
    m_debuggerCmd->setText(cmd);
}

QString ChooseDriver::debuggerCmd() const
{
    return m_debuggerCmd->text();
}


OutputSettings::OutputSettings(QWidget* parent) :
	QWidget(parent, "output")
{
    // the group is invisible
    m_group = new QButtonGroup(this);
    m_group->hide();

    QVBoxLayout* layout = new QVBoxLayout(this, 10);

    QRadioButton* btn;

    btn = new QRadioButton(i18n("&No input and output"), this);
    m_group->insert(btn, 0);
    btn->setMinimumSize(btn->sizeHint());
    layout->addWidget(btn);

    btn = new QRadioButton(i18n("&Only output, simple terminal emulation"), this);
    m_group->insert(btn, 1);
    btn->setMinimumSize(btn->sizeHint());
    layout->addWidget(btn);

    btn = new QRadioButton(i18n("&Full terminal emulation"), this);
    m_group->insert(btn, 7);
    btn->setMinimumSize(btn->sizeHint());
    layout->addWidget(btn);

    layout->addStretch(10);

    // there is no simpler way to get to the active button than
    // to connect to a signal
    connect(m_group, SIGNAL(clicked(int)), SLOT(slotLevelChanged(int)));
}

void OutputSettings::setTTYLevel(int l)
{
    m_group->setButton(l);
    m_ttyLevel = l;
}

void OutputSettings::slotLevelChanged(int id)
{
    m_ttyLevel = id;
    TRACE("new ttyLevel: " + QString().setNum(id));
}



ProgramSettings::ProgramSettings(QWidget* parent, QString exeName, bool modal) :
	QTabDialog(parent, "program_settings", modal),
	m_chooseDriver(this),
	m_output(this)
{
    // construct title
    int slash = exeName.findRev('/');
    if (slash >= 0) {
#if QT_VERSION < 200
	exeName.detach();
#endif
	exeName.remove(0, slash+1);
    }
    QString cap = kapp->getCaption();
    QString fmt = i18n("%s: Settings for %s");
    SIZED_QString(title, fmt.length() + cap.length() + exeName.length());
    title.sprintf(fmt, cap.data(), exeName.data());
    setCaption(title);

    setCancelButton(i18n("Cancel"));
    setOKButton(i18n("OK"));
    setDefaultButton(i18n("&Help"));

    connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotHelp()));

    addTab(&m_chooseDriver, i18n("&Debugger"));
    addTab(&m_output, i18n("&Output"));
}

void ProgramSettings::slotHelp()
{
    QString section;

#if QT_VERSION >= 200
    // find active page and jump to its section
    QWidget* curWidget = currentPage();
    if (curWidget != 0) {
	section = curWidget->name();
    }
#endif
    TRACE("invoking help: pgmsettings.html section #" + section);
    kapp->invokeHTMLHelp("kdbg/pgmsettings.html", section);
}

#include "pgmsettings.moc"