Commit e7b61089 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

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: default avatarhjk <qthjk@ovi.com>
parent ae07238c
......@@ -32,6 +32,7 @@
#include "commonoptionspage.h"
#include "debuggerinternalconstants.h"
#include "cdbengine.h"
#include "cdbsymbolpathlisteditor.h"
#include <utils/synchronousprocess.h>
......@@ -39,7 +40,10 @@
#include <QTextStream>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QCheckBox>
#include <QVBoxLayout>
namespace Debugger {
namespace Internal {
......@@ -157,6 +161,46 @@ QStringList CdbBreakEventWidget::breakEvents() const
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) :
QWidget(parent), m_breakEventWidget(new CdbBreakEventWidget)
{
......@@ -165,11 +209,11 @@ CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent) :
// accommodate all options. This page only shows on
// 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);
m_ui.startupFormLayout->setContentsMargins(margins);
m_ui.pathFormLayout->setContentsMargins(margins);
m_ui.pathGroupBox->layout()->setContentsMargins(margins);
m_ui.breakpointLayout->setContentsMargins(margins);
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().");
m_ui.breakCrtDbgReportCheckBox
->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)
{
m_ui.additionalArgumentsLineEdit->setText(o.additionalArguments);
setSymbolPaths(o.symbolPaths);
m_ui.sourcePathListEditor->setPathList(o.sourcePaths);
setSourcePaths(o.sourcePaths);
m_breakEventWidget->setBreakEvents(o.breakEvents);
m_ui.consoleCheckBox->setChecked(o.cdbConsole);
m_ui.breakpointCorrectionCheckBox->setChecked(o.breakpointCorrection);
......@@ -198,8 +263,8 @@ CdbOptions CdbOptionsPageWidget::options() const
{
CdbOptions rc;
rc.additionalArguments = m_ui.additionalArgumentsLineEdit->text().trimmed();
rc.symbolPaths = symbolPaths();
rc.sourcePaths = m_ui.sourcePathListEditor->pathList();
rc.symbolPaths = m_symbolPaths;
rc.sourcePaths = m_sourcePaths;
rc.breakEvents = m_breakEventWidget->breakEvents();
rc.cdbConsole = m_ui.consoleCheckBox->isChecked();
rc.breakpointCorrection = m_ui.breakpointCorrectionCheckBox->isChecked();
......@@ -208,21 +273,39 @@ CdbOptions CdbOptionsPageWidget::options() const
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()
{
CdbPathDialog pathDialog(this, CdbPathDialog::SourcePaths);
pathDialog.setPaths(m_sourcePaths);
if (pathDialog.exec() == QDialog::Accepted)
setSourcePaths(pathDialog.paths());
}
static QString stripColon(QString s)
{
m_ui.symbolPathListEditor->setPathList(s);
const int lastColon = s.lastIndexOf(QLatin1Char(':'));
if (lastColon != -1)
s.truncate(lastColon);
return s;
}
QString CdbOptionsPageWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui.symbolPathLabel->text()
<< ' ' << m_ui.sourcePathLabel->text();
QTextStream(&rc)
<< 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('&'));
return rc;
}
......
......@@ -38,14 +38,20 @@
#include <QWidget>
#include <QPointer>
#include <QSharedPointer>
#include <QDialog>
QT_BEGIN_NAMESPACE
class QCheckBox;
QT_END_NAMESPACE
namespace Utils {
class PathListEditor;
}
namespace Debugger {
namespace Internal {
class CdbSymbolPathListEditor;
// Widget displaying a list of break events for the 'sxe' command
// with a checkbox to enable 'break' and optionally a QLineEdit for
// events with parameters (like 'out:Needle').
......@@ -67,6 +73,24 @@ private:
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
{
Q_OBJECT
......@@ -79,13 +103,20 @@ public:
QString searchKeywords() const;
private slots:
void showSymbolPathDialog();
void showSourcePathDialog();
private:
QStringList symbolPaths() const;
void setSymbolPaths(const QStringList &s);
void setSymbolPaths(const QStringList &);
void setSourcePaths(const QStringList &);
inline QString path() const;
Ui::CdbOptionsPageWidget m_ui;
CdbBreakEventWidget *m_breakEventWidget;
QStringList m_symbolPaths;
QStringList m_sourcePaths;
};
class CdbOptionsPage : public Core::IOptionsPage
......
......@@ -12,8 +12,8 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="cdbPathGroupBox">
<property name="title">
<string extracomment="Placeholder">Startup</string>
......@@ -54,84 +54,89 @@
</layout>
</widget>
</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>
</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>
<spacer name="verticalSpacer">
<property name="orientation">
......@@ -147,20 +152,6 @@
</item>
</layout>
</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/>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment