diff --git a/src/plugins/debugger/cdb/cdboptions.cpp b/src/plugins/debugger/cdb/cdboptions.cpp index cb2ffd758cece2b71cf1bf413771f0efba9e0917..0aba1a84ff8751e42bf005c7eaab80b5e44057e0 100644 --- a/src/plugins/debugger/cdb/cdboptions.cpp +++ b/src/plugins/debugger/cdb/cdboptions.cpp @@ -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); diff --git a/src/plugins/debugger/cdb/cdboptionspage.cpp b/src/plugins/debugger/cdb/cdboptionspage.cpp index e20214aaafa3c0b44abf19d2638beca2b76948da..38ee2a840be61ae6a25c42ba45fab1b389e6bfcf 100644 --- a/src/plugins/debugger/cdb/cdboptionspage.cpp +++ b/src/plugins/debugger/cdb/cdboptionspage.cpp @@ -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) diff --git a/src/plugins/debugger/cdb/cdboptionspage.h b/src/plugins/debugger/cdb/cdboptionspage.h index a1778cde9a6073e234f01e53001731ebbfb293fb..381c6dba0e61e6cb100b11f674f1060b519e5460 100644 --- a/src/plugins/debugger/cdb/cdboptionspage.h +++ b/src/plugins/debugger/cdb/cdboptionspage.h @@ -55,6 +55,7 @@ public: private slots: void autoDetect(); + void downLoadLinkActivated(const QString &); private: Ui::CdbOptionsPageWidget m_ui; diff --git a/src/plugins/debugger/cdb/cdboptionspagewidget.ui b/src/plugins/debugger/cdb/cdboptionspagewidget.ui index e14fe0a969236f2e85d390fdb59033389e6ade4f..7e71c535f733e821a277e0ff91438384aff1a731 100644 --- a/src/plugins/debugger/cdb/cdboptionspagewidget.ui +++ b/src/plugins/debugger/cdb/cdboptionspagewidget.ui @@ -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 "Debugging Tools for Windows":</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> diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 842fe92479d35250ae9fad518455b1ba8321efa9..ba16c92ff170704febe240088f7507be863b6cbb 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -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)