1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "debuggerlanguagechooser.h"
35 #include <QtGui/QHBoxLayout>
36 #include <QtGui/QCheckBox>
37 #include <QtGui/QSpinBox>
38 #include <QtGui/QLabel>
42 DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
45 m_useCppDebugger = new QCheckBox(tr("C++"), this);
46 m_useQmlDebugger = new QCheckBox(tr("QML"), this);
48 connect(m_useCppDebugger, SIGNAL(toggled(bool)),
49 this, SLOT(useCppDebuggerToggled(bool)));
50 connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
51 this, SLOT(useQmlDebuggerToggled(bool)));
53 m_debugServerPortLabel = new QLabel(tr("Debug port:"), this);
54 m_debugServerPort = new QSpinBox(this);
55 m_debugServerPort->setMinimum(1);
56 m_debugServerPort->setMaximum(65535);
58 m_debugServerPortLabel->setBuddy(m_debugServerPort);
60 m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\"qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html\">What are the prerequisites?</a>"));
61 connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)),
62 this, SIGNAL(openHelpUrl(QString)));
64 connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPort, SLOT(setEnabled(bool)));
65 connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPortLabel, SLOT(setEnabled(bool)));
66 connect(m_debugServerPort, SIGNAL(valueChanged(int)), this, SLOT(onDebugServerPortChanged(int)));
68 QHBoxLayout *qmlLayout = new QHBoxLayout;
69 qmlLayout->setMargin(0);
70 qmlLayout->addWidget(m_useQmlDebugger);
71 qmlLayout->addWidget(m_debugServerPortLabel);
72 qmlLayout->addWidget(m_debugServerPort);
73 qmlLayout->addWidget(m_qmlDebuggerInfoLabel);
74 qmlLayout->addStretch();
76 QVBoxLayout *layout = new QVBoxLayout;
78 layout->addWidget(m_useCppDebugger);
79 layout->addLayout(qmlLayout);
84 bool DebuggerLanguageChooser::cppChecked() const
86 return m_useCppDebugger->isChecked();
89 bool DebuggerLanguageChooser::qmlChecked() const
91 return m_useQmlDebugger->isChecked();
94 uint DebuggerLanguageChooser::qmlDebugServerPort() const
96 return m_debugServerPort->value();
99 void DebuggerLanguageChooser::setCppChecked(bool value)
101 m_useCppDebugger->setChecked(value);
104 void DebuggerLanguageChooser::setQmlChecked(bool value)
106 m_useQmlDebugger->setChecked(value);
107 m_debugServerPortLabel->setEnabled(value);
108 m_debugServerPort->setEnabled(value);
111 void DebuggerLanguageChooser::setQmlDebugServerPort(uint port)
113 m_debugServerPort->setValue(port);
116 void DebuggerLanguageChooser::useCppDebuggerToggled(bool toggled)
118 emit cppLanguageToggled(toggled);
119 if (!toggled && !m_useQmlDebugger->isChecked())
120 m_useQmlDebugger->setChecked(true);
123 void DebuggerLanguageChooser::useQmlDebuggerToggled(bool toggled)
125 emit qmlLanguageToggled(toggled);
126 if (!toggled && !m_useCppDebugger->isChecked())
127 m_useCppDebugger->setChecked(true);
130 void DebuggerLanguageChooser::onDebugServerPortChanged(int port)
132 emit qmlDebugServerPortChanged((uint)port);