Clean up CDB options page, make room for further options.

Introduce grid layout and columns. Move the paths to separate
dialogs, saving space. Fix search keywords.

Task-number: QTCREATORBUG-8141
Change-Id: I05b5ee3ab0c123bbe018f4b6d8613dffe8558d34
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2012-11-05 17:22:21 +01:00
committed by hjk
parent ae07238c78
commit e7b6108934
3 changed files with 210 additions and 105 deletions

View File

@@ -32,6 +32,7 @@
#include "commonoptionspage.h" #include "commonoptionspage.h"
#include "debuggerinternalconstants.h" #include "debuggerinternalconstants.h"
#include "cdbengine.h" #include "cdbengine.h"
#include "cdbsymbolpathlisteditor.h"
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
@@ -39,7 +40,10 @@
#include <QTextStream> #include <QTextStream>
#include <QLineEdit> #include <QLineEdit>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QCheckBox> #include <QCheckBox>
#include <QVBoxLayout>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -157,6 +161,46 @@ QStringList CdbBreakEventWidget::breakEvents() const
return rc; return rc;
} }
CdbPathDialog::CdbPathDialog(QWidget *parent, Mode mode)
: QDialog(parent)
, m_pathListEditor(0)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setMinimumWidth(700);
switch (mode) {
case SymbolPaths:
setWindowTitle(tr("CDB Symbol Paths"));
m_pathListEditor = new CdbSymbolPathListEditor(this);
break;
case SourcePaths:
setWindowTitle(tr("CDB Source Paths"));
m_pathListEditor = new Utils::PathListEditor(this);
break;
}
QVBoxLayout *layout = new QVBoxLayout(this);
QGroupBox *groupBox = new QGroupBox(this);
(new QVBoxLayout(groupBox))->addWidget(m_pathListEditor);
layout->addWidget(groupBox);
QDialogButtonBox *buttonBox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
layout->addWidget(buttonBox);
}
QStringList CdbPathDialog::paths() const
{
return m_pathListEditor->pathList();
}
void CdbPathDialog::setPaths(const QStringList &paths)
{
m_pathListEditor->setPathList(paths);
}
CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) : CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
QWidget(parent), m_breakEventWidget(new CdbBreakEventWidget) QWidget(parent), m_breakEventWidget(new CdbBreakEventWidget)
{ {
@@ -165,11 +209,11 @@ CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
// accommodate all options. This page only shows on // accommodate all options. This page only shows on
// Windows, which has large margins by default. // Windows, which has large margins by default.
const int margin = m_ui.verticalLayout->margin(); const int margin = layout()->margin();
const QMargins margins(margin, margin / 3, margin, margin / 3); const QMargins margins(margin, margin / 3, margin, margin / 3);
m_ui.startupFormLayout->setContentsMargins(margins); m_ui.startupFormLayout->setContentsMargins(margins);
m_ui.pathFormLayout->setContentsMargins(margins); m_ui.pathGroupBox->layout()->setContentsMargins(margins);
m_ui.breakpointLayout->setContentsMargins(margins); m_ui.breakpointLayout->setContentsMargins(margins);
QVBoxLayout *eventLayout = new QVBoxLayout; QVBoxLayout *eventLayout = new QVBoxLayout;
@@ -181,13 +225,34 @@ CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
const QString hint = tr("This is useful to catch runtime error messages, for example caused by assert()."); const QString hint = tr("This is useful to catch runtime error messages, for example caused by assert().");
m_ui.breakCrtDbgReportCheckBox m_ui.breakCrtDbgReportCheckBox
->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip(CdbOptions::crtDbgReport, hint)); ->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip(CdbOptions::crtDbgReport, hint));
connect(m_ui.symbolPathButton, SIGNAL(clicked()), this, SLOT(showSymbolPathDialog()));
connect(m_ui.sourcePathButton, SIGNAL(clicked()), this, SLOT(showSourcePathDialog()));
}
void CdbOptionsPageWidget::setSymbolPaths(const QStringList &s)
{
m_symbolPaths = s;
const QString summary =
tr("Symbol paths: %1").arg(m_symbolPaths.isEmpty() ?
tr("<none>") : QString::number(m_symbolPaths.size()));
m_ui.symbolPathLabel->setText(summary);
}
void CdbOptionsPageWidget::setSourcePaths(const QStringList &s)
{
m_sourcePaths = s;
const QString summary =
tr("Source paths: %1").arg(m_sourcePaths.isEmpty() ?
tr("<none>") : QString::number(m_sourcePaths.size()));
m_ui.sourcePathLabel->setText(summary);
} }
void CdbOptionsPageWidget::setOptions(CdbOptions &o) void CdbOptionsPageWidget::setOptions(CdbOptions &o)
{ {
m_ui.additionalArgumentsLineEdit->setText(o.additionalArguments); m_ui.additionalArgumentsLineEdit->setText(o.additionalArguments);
setSymbolPaths(o.symbolPaths); setSymbolPaths(o.symbolPaths);
m_ui.sourcePathListEditor->setPathList(o.sourcePaths); setSourcePaths(o.sourcePaths);
m_breakEventWidget->setBreakEvents(o.breakEvents); m_breakEventWidget->setBreakEvents(o.breakEvents);
m_ui.consoleCheckBox->setChecked(o.cdbConsole); m_ui.consoleCheckBox->setChecked(o.cdbConsole);
m_ui.breakpointCorrectionCheckBox->setChecked(o.breakpointCorrection); m_ui.breakpointCorrectionCheckBox->setChecked(o.breakpointCorrection);
@@ -198,8 +263,8 @@ CdbOptions CdbOptionsPageWidget::options() const
{ {
CdbOptions rc; CdbOptions rc;
rc.additionalArguments = m_ui.additionalArgumentsLineEdit->text().trimmed(); rc.additionalArguments = m_ui.additionalArgumentsLineEdit->text().trimmed();
rc.symbolPaths = symbolPaths(); rc.symbolPaths = m_symbolPaths;
rc.sourcePaths = m_ui.sourcePathListEditor->pathList(); rc.sourcePaths = m_sourcePaths;
rc.breakEvents = m_breakEventWidget->breakEvents(); rc.breakEvents = m_breakEventWidget->breakEvents();
rc.cdbConsole = m_ui.consoleCheckBox->isChecked(); rc.cdbConsole = m_ui.consoleCheckBox->isChecked();
rc.breakpointCorrection = m_ui.breakpointCorrectionCheckBox->isChecked(); rc.breakpointCorrection = m_ui.breakpointCorrectionCheckBox->isChecked();
@@ -208,21 +273,39 @@ CdbOptions CdbOptionsPageWidget::options() const
return rc; return rc;
} }
QStringList CdbOptionsPageWidget::symbolPaths() const void CdbOptionsPageWidget::showSymbolPathDialog()
{ {
return m_ui.symbolPathListEditor->pathList(); CdbPathDialog pathDialog(this, CdbPathDialog::SymbolPaths);
pathDialog.setPaths(m_symbolPaths);
if (pathDialog.exec() == QDialog::Accepted)
setSymbolPaths(pathDialog.paths());
} }
void CdbOptionsPageWidget::setSymbolPaths(const QStringList &s) void CdbOptionsPageWidget::showSourcePathDialog()
{ {
m_ui.symbolPathListEditor->setPathList(s); CdbPathDialog pathDialog(this, CdbPathDialog::SourcePaths);
pathDialog.setPaths(m_sourcePaths);
if (pathDialog.exec() == QDialog::Accepted)
setSourcePaths(pathDialog.paths());
}
static QString stripColon(QString s)
{
const int lastColon = s.lastIndexOf(QLatin1Char(':'));
if (lastColon != -1)
s.truncate(lastColon);
return s;
} }
QString CdbOptionsPageWidget::searchKeywords() const QString CdbOptionsPageWidget::searchKeywords() const
{ {
QString rc; QString rc;
QTextStream(&rc) << m_ui.symbolPathLabel->text() QTextStream(&rc)
<< ' ' << m_ui.sourcePathLabel->text(); << stripColon(m_ui.additionalArgumentsLabel->text()) << ' '
<< stripColon(m_ui.breakFunctionGroupBox->title()) << ' '
<< m_ui.breakpointsGroupBox->title() << ' '
<< stripColon(m_ui.symbolPathLabel->text()) << ' '
<< stripColon(m_ui.sourcePathLabel->text());
rc.remove(QLatin1Char('&')); rc.remove(QLatin1Char('&'));
return rc; return rc;
} }

View File

@@ -38,14 +38,20 @@
#include <QWidget> #include <QWidget>
#include <QPointer> #include <QPointer>
#include <QSharedPointer> #include <QSharedPointer>
#include <QDialog>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCheckBox; class QCheckBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils {
class PathListEditor;
}
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class CdbSymbolPathListEditor;
// Widget displaying a list of break events for the 'sxe' command // Widget displaying a list of break events for the 'sxe' command
// with a checkbox to enable 'break' and optionally a QLineEdit for // with a checkbox to enable 'break' and optionally a QLineEdit for
// events with parameters (like 'out:Needle'). // events with parameters (like 'out:Needle').
@@ -67,6 +73,24 @@ private:
QList<QLineEdit*> m_lineEdits; QList<QLineEdit*> m_lineEdits;
}; };
class CdbPathDialog : public QDialog
{
Q_OBJECT
public:
enum Mode {
SymbolPaths,
SourcePaths
};
explicit CdbPathDialog(QWidget *parent, Mode mode);
QStringList paths() const;
void setPaths(const QStringList &paths);
private:
Utils::PathListEditor *m_pathListEditor;
};
class CdbOptionsPageWidget : public QWidget class CdbOptionsPageWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -79,13 +103,20 @@ public:
QString searchKeywords() const; QString searchKeywords() const;
private slots:
void showSymbolPathDialog();
void showSourcePathDialog();
private: private:
QStringList symbolPaths() const; void setSymbolPaths(const QStringList &);
void setSymbolPaths(const QStringList &s); void setSourcePaths(const QStringList &);
inline QString path() const; inline QString path() const;
Ui::CdbOptionsPageWidget m_ui; Ui::CdbOptionsPageWidget m_ui;
CdbBreakEventWidget *m_breakEventWidget; CdbBreakEventWidget *m_breakEventWidget;
QStringList m_symbolPaths;
QStringList m_sourcePaths;
}; };
class CdbOptionsPage : public Core::IOptionsPage class CdbOptionsPage : public Core::IOptionsPage

View File

@@ -12,8 +12,8 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QGridLayout" name="gridLayout_2">
<item> <item row="0" column="0">
<widget class="QGroupBox" name="cdbPathGroupBox"> <widget class="QGroupBox" name="cdbPathGroupBox">
<property name="title"> <property name="title">
<string extracomment="Placeholder">Startup</string> <string extracomment="Placeholder">Startup</string>
@@ -54,84 +54,89 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QGroupBox" name="pathGroupBox">
<property name="title">
<string>Paths</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="symbolPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="symbolPathButton">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="sourcePathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="sourcePathButton">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="breakpointsGroupBox">
<property name="title">
<string>Breakpoints</string>
</property>
<layout class="QVBoxLayout" name="breakpointLayout">
<item>
<widget class="QCheckBox" name="breakpointCorrectionCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Attempt to correct the location of a breakpoint based on file and line number should it be in a comment or in a line for which no code is generated. The correction is based on the code model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Correct breakpoint location</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="breakFunctionGroupBox">
<property name="title">
<string>Break on functions:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="breakCrtDbgReportCheckBox"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="eventGroupBox">
<property name="title">
<string>Break on:</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item>
<widget class="QGroupBox" name="startupGroupBox">
<property name="title">
<string>Debugger Paths</string>
</property>
<layout class="QFormLayout" name="pathFormLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="symbolPathLabel">
<property name="text">
<string>&amp;Symbol paths:</string>
</property>
<property name="buddy">
<cstring>symbolPathListEditor</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Debugger::Internal::CdbSymbolPathListEditor" name="symbolPathListEditor" native="true"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="sourcePathLabel">
<property name="text">
<string>S&amp;ource paths:</string>
</property>
<property name="buddy">
<cstring>sourcePathListEditor</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathListEditor" name="sourcePathListEditor" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="breakpointsGroupBox">
<property name="title">
<string>Breakpoints</string>
</property>
<layout class="QVBoxLayout" name="breakpointLayout">
<item>
<widget class="QCheckBox" name="breakpointCorrectionCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Attempt to correct the location of a breakpoint based on file and line number should it be in a comment or in a line for which no code is generated. The correction is based on the code model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Correct breakpoint location</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="eventGroupBox">
<property name="title">
<string>Break on:</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="breakFunctionGroupBox">
<property name="title">
<string>Break on functions:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="breakCrtDbgReportCheckBox"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@@ -147,20 +152,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>Utils::PathListEditor</class>
<extends>QWidget</extends>
<header location="global">utils/pathlisteditor.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Debugger::Internal::CdbSymbolPathListEditor</class>
<extends>QWidget</extends>
<header location="global">cdbsymbolpathlisteditor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>