Improved CDB settings dialog, adapted autodetection to 64bit.

Use correct path, display download link and notify that
settings take effect at next restart.
Acked-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
Friedemann Kleint
2009-05-20 11:48:31 +02:00
parent bcaa2556f4
commit 3f19a0504e
5 changed files with 79 additions and 32 deletions

View File

@@ -83,8 +83,9 @@ void CdbOptions::toSettings(QSettings *s) const
bool CdbOptions::autoDetectPath(QString *outPath, QStringList *checkedDirectories /* = 0 */)
{
// Look for $ProgramFiles/"Debugging Tools For Windows" and its
// :" (x86)", " (x64)" variations
// Look for $ProgramFiles/"Debugging Tools For Windows <bit-idy>" and its
// " (x86)", " (x64)" variations. Qt Creator needs 64/32 bit depending
// on how it was built.
static const char *postFixes[] = { " (x86)", " (x32)", " (x64)" };
outPath->clear();
@@ -93,7 +94,12 @@ bool CdbOptions::autoDetectPath(QString *outPath, QStringList *checkedDirectorie
return false;
const QString programDir = QString::fromLocal8Bit(programDirB) + QDir::separator();
#ifdef Q_OS_WIN64
const QString installDir = QLatin1String("Debugging Tools For Windows (x64)");
#else
const QString installDir = QLatin1String("Debugging Tools For Windows");
#endif
QString path = programDir + installDir;
if (checkedDirectories)
checkedDirectories->push_back(path);

View File

@@ -34,17 +34,43 @@
#include <coreplugin/icore.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QUrl>
#include <QtGui/QMessageBox>
#include <QtGui/QDesktopServices>
const char * const CDB_SETTINGS_ID = QT_TRANSLATE_NOOP("Debugger::Internal::CdbOptionsPageWidget", "Cdb");
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";
namespace Debugger {
namespace Internal {
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);
//: Label text for path configuration. Singular form is not very likely to occur ;-)
return CdbOptionsPageWidget::tr(
"<html><body><p>Specify the path to the "
"<a href=\"%1\">Debugging Tools for Windows</a>"
" (%n bit-version) here.</p>"
"<p><b>Note:</b> Restarting Qt Creator is required for these settings to take effect.</p></p>"
"</body></html>", 0, (is64bit ? 64 : 32)).arg(link);
}
CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
m_ui.noteLabel->setText(msgPathConfigNote());
m_ui.noteLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
connect(m_ui.noteLabel, SIGNAL(linkActivated(QString)), this, SLOT(downLoadLinkActivated(QString)));
m_ui.pathChooser->setExpectedKind(Core::Utils::PathChooser::Directory);
m_ui.pathChooser->addButton(tr("Autodetect"), this, SLOT(autoDetect()));
m_ui.failureLabel->setVisible(false);
@@ -54,7 +80,7 @@ CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
void CdbOptionsPageWidget::setOptions(CdbOptions &o)
{
m_ui.pathChooser->setPath(o.path);
m_ui.cdbOptionsGroupBox->setChecked(o.enabled);
m_ui.cdbPathGroupBox->setChecked(o.enabled);
m_ui.symbolPathListEditor->setPathList(o.symbolPaths);
m_ui.sourcePathListEditor->setPathList(o.sourcePaths);
}
@@ -63,7 +89,7 @@ CdbOptions CdbOptionsPageWidget::options() const
{
CdbOptions rc;
rc.path = m_ui.pathChooser->path();
rc.enabled = m_ui.cdbOptionsGroupBox->isChecked();
rc.enabled = m_ui.cdbPathGroupBox->isChecked();
rc.symbolPaths = m_ui.symbolPathListEditor->pathList();
rc.sourcePaths = m_ui.sourcePathListEditor->pathList();
return rc;
@@ -74,7 +100,7 @@ void CdbOptionsPageWidget::autoDetect()
QString path;
QStringList checkedDirectories;
const bool ok = CdbOptions::autoDetectPath(&path, &checkedDirectories);
m_ui.cdbOptionsGroupBox->setChecked(ok);
m_ui.cdbPathGroupBox->setChecked(ok);
if (ok) {
m_ui.pathChooser->setPath(path);
} else {
@@ -92,6 +118,11 @@ void CdbOptionsPageWidget::setFailureMessage(const QString &msg)
m_ui.failureLabel->setVisible(!msg.isEmpty());
}
void CdbOptionsPageWidget::downLoadLinkActivated(const QString &link)
{
QDesktopServices::openUrl(QUrl(link));
}
// ---------- CdbOptionsPage
CdbOptionsPage::CdbOptionsPage(const QSharedPointer<CdbOptions> &options) :
m_options(options)

View File

@@ -55,6 +55,7 @@ public:
private slots:
void autoDetect();
void downLoadLinkActivated(const QString &);
private:
Ui::CdbOptionsPageWidget m_ui;

View File

@@ -14,43 +14,37 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="cdbOptionsGroupBox">
<widget class="QGroupBox" name="cdbPathGroupBox">
<property name="toolTip">
<string>These options take effect at the next start of Qt Creator.</string>
</property>
<property name="title">
<string>Cdb</string>
<string extracomment="Placeholder">Cdb</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="1" column="0">
<widget class="QLabel" name="pathLabel">
<property name="text">
<string>Path to &quot;Debugging Tools for Windows&quot;:</string>
<string>Path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="noteLabel">
<property name="text">
<string extracomment="Placeholder">ote: bla, blah</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>

View File

@@ -783,13 +783,15 @@ void DebuggerManager::setConfigValue(const QString &name, const QVariant &value)
// Figure out the debugger type of an executable
static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
QString *errorMessage)
QString *errorMessage,
QString *settingsIdHint)
{
if (executable.endsWith(_(".js")))
return scriptEngine;
#ifndef Q_OS_WIN
Q_UNUSED(errorMessage)
Q_UNUSED(settingsIdHint)
return gdbEngine;
#else
// If a file has PDB files, it has been compiled by VS.
@@ -802,7 +804,8 @@ static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
// We need the CDB debugger in order to be able to debug VS
// executables
if (!winEngine) {
*errorMessage = DebuggerManager::tr("Debugging VS executables is not supported.");
*errorMessage = DebuggerManager::tr("Debugging VS executables is currently not enabled.");
*settingsIdHint = QLatin1String("Cdb");
return 0;
}
return winEngine;
@@ -979,17 +982,29 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl)
emit debugModeRequested();
QString errorMessage;
if (startMode() == AttachExternal)
QString settingsIdHint;
switch (startMode()) {
case AttachExternal:
m_engine = determineDebuggerEngine(m_attachedPID, &errorMessage);
else if (startMode() == AttachTcf)
break;
case AttachTcf:
m_engine = tcfEngine;
else
m_engine = determineDebuggerEngine(m_executable, &errorMessage);
break;
default:
m_engine = determineDebuggerEngine(m_executable, &errorMessage, &settingsIdHint);
break;
}
if (!m_engine) {
QMessageBox::warning(mainWindow(), tr("Warning"),
tr("Cannot debug '%1': %2").arg(m_executable, errorMessage));
debuggingFinished();
// Create Message box with possibility to go to settings
QAbstractButton *settingsButton = 0;
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), tr("Cannot debug '%1': %2").arg(m_executable, errorMessage), QMessageBox::Ok);
if (!settingsIdHint.isEmpty())
settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole);
msgBox.exec();
if (msgBox.clickedButton() == settingsButton)
Core::ICore::instance()->showOptionsDialog(_(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY), settingsIdHint);
return;
}
if (Debugger::Constants::Internal::debug)