OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / debuggerlanguagechooser.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "debuggerlanguagechooser.h"
34
35 #include <QtGui/QHBoxLayout>
36 #include <QtGui/QCheckBox>
37 #include <QtGui/QSpinBox>
38 #include <QtGui/QLabel>
39
40 namespace Utils {
41
42 DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
43     QWidget(parent)
44 {
45     m_useCppDebugger = new QCheckBox(tr("C++"), this);
46     m_useQmlDebugger = new QCheckBox(tr("QML"), this);
47
48     connect(m_useCppDebugger, SIGNAL(toggled(bool)),
49             this, SLOT(useCppDebuggerToggled(bool)));
50     connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
51             this, SLOT(useQmlDebuggerToggled(bool)));
52
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);
57
58     m_debugServerPortLabel->setBuddy(m_debugServerPort);
59
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)));
63
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)));
67
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();
75
76     QVBoxLayout *layout = new QVBoxLayout;
77     layout->setMargin(0);
78     layout->addWidget(m_useCppDebugger);
79     layout->addLayout(qmlLayout);
80
81     setLayout(layout);
82 }
83
84 bool DebuggerLanguageChooser::cppChecked() const
85 {
86     return m_useCppDebugger->isChecked();
87 }
88
89 bool DebuggerLanguageChooser::qmlChecked() const
90 {
91     return m_useQmlDebugger->isChecked();
92 }
93
94 uint DebuggerLanguageChooser::qmlDebugServerPort() const
95 {
96     return m_debugServerPort->value();
97 }
98
99 void DebuggerLanguageChooser::setCppChecked(bool value)
100 {
101     m_useCppDebugger->setChecked(value);
102 }
103
104 void DebuggerLanguageChooser::setQmlChecked(bool value)
105 {
106     m_useQmlDebugger->setChecked(value);
107     m_debugServerPortLabel->setEnabled(value);
108     m_debugServerPort->setEnabled(value);
109 }
110
111 void DebuggerLanguageChooser::setQmlDebugServerPort(uint port)
112 {
113     m_debugServerPort->setValue(port);
114 }
115
116 void DebuggerLanguageChooser::useCppDebuggerToggled(bool toggled)
117 {
118     emit cppLanguageToggled(toggled);
119     if (!toggled && !m_useQmlDebugger->isChecked())
120         m_useQmlDebugger->setChecked(true);
121 }
122
123 void DebuggerLanguageChooser::useQmlDebuggerToggled(bool toggled)
124 {
125     emit qmlLanguageToggled(toggled);
126     if (!toggled && !m_useCppDebugger->isChecked())
127         m_useCppDebugger->setChecked(true);
128 }
129
130 void DebuggerLanguageChooser::onDebugServerPortChanged(int port)
131 {
132     emit qmlDebugServerPortChanged((uint)port);
133 }
134
135
136 } // namespace Utils