cdboptionspage.cpp 6.56 KB
Newer Older
1
2
3
4
5
6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
27
28
29
30
31
32
33
34
**
**************************************************************************/

#include "cdboptionspage.h"
#include "cdboptions.h"
#include "debuggerconstants.h"

#include <coreplugin/icore.h>
35

36
#include <QtCore/QCoreApplication>
37
#include <QtCore/QUrl>
38
#include <QtCore/QTextStream>
39
#include <QtGui/QMessageBox>
40
#include <QtGui/QDesktopServices>
41

42
43
44
static const char *dgbToolsDownloadLink32C = "http://www.microsoft.com/whdc/devtools/debugging/installx86.Mspx";
static const char *dgbToolsDownloadLink64C = "http://www.microsoft.com/whdc/devtools/debugging/install64bit.Mspx";

45
46
47
namespace Debugger {
namespace Internal {

48
49
50
51
52
53
54
55
static inline QString msgPathConfigNote()
{
#ifdef Q_OS_WIN64
    const bool is64bit = true;
#else
    const bool is64bit = false;
#endif
    const QString link = is64bit ? QLatin1String(dgbToolsDownloadLink64C) : QLatin1String(dgbToolsDownloadLink32C);
56
    //: Label text for path configuration. %2 is "x-bit version".
57
58
59
    return CdbOptionsPageWidget::tr(
    "<html><body><p>Specify the path to the "
    "<a href=\"%1\">Debugging Tools for Windows</a>"
60
    " (%2) here.</p>"
61
    "<p><b>Note:</b> Restarting Qt Creator is required for these settings to take effect.</p></p>"
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
62
63
    "</body></html>").arg(link, (is64bit ? CdbOptionsPageWidget::tr("64-bit version")
                                         : CdbOptionsPageWidget::tr("32-bit version")));
64
65
}

66
67
68
69
CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
    QWidget(parent)
{
    m_ui.setupUi(this);
70
71
72
73
    m_ui.noteLabel->setText(msgPathConfigNote());
    m_ui.noteLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
    connect(m_ui.noteLabel, SIGNAL(linkActivated(QString)), this, SLOT(downLoadLinkActivated(QString)));

74
    m_ui.pathChooser->setExpectedKind(Utils::PathChooser::Directory);
75
76
77
78
79
80
81
82
    m_ui.pathChooser->addButton(tr("Autodetect"), this, SLOT(autoDetect()));
    m_ui.failureLabel->setVisible(false);
}


void CdbOptionsPageWidget::setOptions(CdbOptions &o)
{
    m_ui.pathChooser->setPath(o.path);
83
    m_ui.cdbPathGroupBox->setChecked(o.enabled);
84
85
    m_ui.symbolPathListEditor->setPathList(o.symbolPaths);
    m_ui.sourcePathListEditor->setPathList(o.sourcePaths);
86
87
    m_ui.verboseSymbolLoadingCheckBox->setChecked(o.verboseSymbolLoading);

88
89
90
91
92
93
}

CdbOptions CdbOptionsPageWidget::options() const
{
    CdbOptions  rc;
    rc.path = m_ui.pathChooser->path();
94
    rc.enabled = m_ui.cdbPathGroupBox->isChecked();
95
96
    rc.symbolPaths = m_ui.symbolPathListEditor->pathList();
    rc.sourcePaths = m_ui.sourcePathListEditor->pathList();
97
    rc.verboseSymbolLoading = m_ui.verboseSymbolLoadingCheckBox->isChecked();
98
99
100
101
102
103
    return rc;
}

void CdbOptionsPageWidget::autoDetect()
{
    QString path;
104
105
    QStringList checkedDirectories;
    const bool ok = CdbOptions::autoDetectPath(&path, &checkedDirectories);
106
    m_ui.cdbPathGroupBox->setChecked(ok);
107
    if (ok) {
108
        m_ui.pathChooser->setPath(path);
109
110
111
112
113
114
115
    } else {
        const QString msg = tr("\"Debugging Tools for Windows\" could not be found.");
        const QString details = tr("Checked:\n%1").arg(checkedDirectories.join(QString(QLatin1Char('\n'))));
        QMessageBox msbBox(QMessageBox::Information, tr("Autodetection"), msg, QMessageBox::Ok, this);
        msbBox.setDetailedText(details);
        msbBox.exec();
    }
116
117
118
119
120
121
122
123
}

void CdbOptionsPageWidget::setFailureMessage(const QString &msg)
{
    m_ui.failureLabel->setText(msg);
    m_ui.failureLabel->setVisible(!msg.isEmpty());
}

124
125
126
127
128
void CdbOptionsPageWidget::downLoadLinkActivated(const QString &link)
{
    QDesktopServices::openUrl(QUrl(link));
}

129
130
131
132
133
134
135
136
137
138
QString CdbOptionsPageWidget::searchKeywords() const
{
    QString rc;
    QTextStream(&rc) << m_ui.pathLabel->text() << ' ' << m_ui.symbolPathLabel->text()
            << ' ' << m_ui.sourcePathLabel->text()
            << ' ' << m_ui.verboseSymbolLoadingCheckBox->text();
    rc.remove(QLatin1Char('&'));
    return rc;
}

139
140
141
142
143
144
145
146
147
148
149
150
// ---------- CdbOptionsPage
CdbOptionsPage::CdbOptionsPage(const QSharedPointer<CdbOptions> &options) :
        m_options(options)
{
}

CdbOptionsPage::~CdbOptionsPage()
{
}

QString CdbOptionsPage::settingsId()
{
Friedemann Kleint's avatar
Friedemann Kleint committed
151
    return QLatin1String("F.Cdb");
152
153
154
155
}

QString CdbOptionsPage::trName() const
{
Friedemann Kleint's avatar
Friedemann Kleint committed
156
    return tr("Cdb");
157
158
159
160
}

QString CdbOptionsPage::category() const
{
Friedemann Kleint's avatar
Friedemann Kleint committed
161
    return QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY);
162
163
164
165
}

QString CdbOptionsPage::trCategory() const
{
Friedemann Kleint's avatar
Friedemann Kleint committed
166
    return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_TR_CATEGORY);
167
168
169
170
171
172
173
}

QWidget *CdbOptionsPage::createPage(QWidget *parent)
{
    m_widget = new CdbOptionsPageWidget(parent);
    m_widget->setOptions(*m_options);
    m_widget->setFailureMessage(m_failureMessage);
174
175
    if (m_searchKeywords.isEmpty())
        m_searchKeywords = m_widget->searchKeywords();
176
177
178
179
180
181
182
183
    return m_widget;
}

void CdbOptionsPage::apply()
{
    if (!m_widget)
        return;
    const CdbOptions newOptions = m_widget->options();
184
    if (unsigned changedMask = m_options->compare(newOptions)) {
185
186
        *m_options = newOptions;
        m_options->toSettings(Core::ICore::instance()->settings());
187
188
        // Paths changed?
        if (changedMask & CdbOptions::DebuggerPathsChanged) {
189
            emit debuggerPathsChanged();
190
191
192
193
194
            changedMask &= ~CdbOptions::DebuggerPathsChanged;
        }
        // Remaining options?
        if (changedMask)
            emit optionsChanged();
195
196
197
198
199
200
201
    }
}

void CdbOptionsPage::finish()
{
}

202
203
204
205
206
bool CdbOptionsPage::matches(const QString &s) const
{
    return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}

207
208
} // namespace Internal
} // namespace Debugger