Commit 5dfdf75e authored by hjk's avatar hjk
Browse files

KitManager: spacing in dialog



Change-Id: I243de278cd964c9aa51e7ff091a2c33e8043a562
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 3e7d94c3
......@@ -65,20 +65,12 @@ static const char dgbToolsDownloadLink64C[] = "http://www.microsoft.com/whdc/dev
// -----------------------------------------------------------------------
DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy,
const DebuggerKitInformation *ki,
QWidget *parent) :
ProjectExplorer::KitConfigWidget(parent),
m_kit(workingCopy),
const DebuggerKitInformation *ki)
: KitConfigWidget(workingCopy),
m_info(ki),
m_label(new QLabel(this)),
m_button(new QPushButton(tr("Manage..."), this))
m_label(new QLabel),
m_button(new QPushButton(tr("Manage...")))
{
setToolTip(tr("The debugger to use for this kit."));
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->addWidget(m_label);
// ToolButton with Menu, defaulting to 'Autodetect'.
QMenu *buttonMenu = new QMenu(m_button);
QAction *autoDetectAction = buttonMenu->addAction(tr("Auto-detect"));
......@@ -90,6 +82,16 @@ DebuggerKitConfigWidget::DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCo
refresh();
}
QString DebuggerKitConfigWidget::toolTip() const
{
return tr("The debugger to use for this kit.");
}
QWidget *DebuggerKitConfigWidget::mainWidget() const
{
return m_label;
}
QWidget *DebuggerKitConfigWidget::buttonWidget() const
{
return m_button;
......
......@@ -62,23 +62,23 @@ class DebuggerKitConfigWidget : public ProjectExplorer::KitConfigWidget
public:
DebuggerKitConfigWidget(ProjectExplorer::Kit *workingCopy,
const DebuggerKitInformation *ki,
QWidget *parent = 0);
const DebuggerKitInformation *ki);
QString displayName() const;
QString toolTip() const;
void makeReadOnly();
void refresh();
QWidget *buttonWidget() const;
QWidget *mainWidget() const;
private slots:
void autoDetectDebugger();
void showDialog();
private:
ProjectExplorer::Kit *m_kit;
const DebuggerKitInformation *m_info;
QLabel *m_label;
QPushButton *m_button;
......
......@@ -34,30 +34,34 @@
#include <QWidget>
QT_FORWARD_DECLARE_CLASS(QGridLayout)
namespace ProjectExplorer {
class Kit;
// --------------------------------------------------------------------------
// KitConfigWidget
// --------------------------------------------------------------------------
class PROJECTEXPLORER_EXPORT KitConfigWidget : public QWidget
class PROJECTEXPLORER_EXPORT KitConfigWidget : public QObject
{
Q_OBJECT
public:
KitConfigWidget(QWidget *parent = 0) : QWidget(parent)
{ }
KitConfigWidget(Kit *kit) : m_kit(kit) { }
virtual QString displayName() const = 0;
virtual QString toolTip() const { return QString(); }
virtual void makeReadOnly() = 0;
virtual void refresh() = 0;
virtual QWidget *mainWidget() const = 0;
virtual QWidget *buttonWidget() const { return 0; }
signals:
void dirty();
protected:
ProjectExplorer::Kit *m_kit;
};
} // namespace ProjectExplorer
......
......@@ -288,7 +288,6 @@ QList<Task> DeviceTypeKitInformation::validate(const Kit *k) const
KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const
{
Q_ASSERT(k);
return new Internal::DeviceTypeInformationConfigWidget(k);
}
......@@ -381,7 +380,6 @@ void DeviceKitInformation::fix(Kit *k)
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
{
Q_ASSERT(k);
return new Internal::DeviceInformationConfigWidget(k);
}
......
......@@ -43,7 +43,6 @@
#include <utils/pathchooser.h>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
......@@ -54,21 +53,12 @@ namespace Internal {
// SysRootInformationConfigWidget:
// --------------------------------------------------------------------------
SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k, QWidget *parent) :
KitConfigWidget(parent),
m_kit(k)
SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k) :
KitConfigWidget(k)
{
setToolTip(tr("The root directory of the system image to use.<br>"
"Leave empty when building for the desktop."));
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
m_chooser = new Utils::PathChooser;
m_chooser->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_chooser);
m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_chooser->setFileName(SysRootKitInformation::sysRoot(k));
connect(m_chooser, SIGNAL(changed(QString)), this, SLOT(pathWasChanged()));
}
......@@ -77,6 +67,12 @@ QString SysRootInformationConfigWidget::displayName() const
return tr("Sysroot:");
}
QString SysRootInformationConfigWidget::toolTip() const
{
return tr("The root directory of the system image to use.<br>"
"Leave empty when building for the desktop.");
}
void SysRootInformationConfigWidget::refresh()
{
m_chooser->setFileName(SysRootKitInformation::sysRoot(m_kit));
......@@ -87,6 +83,11 @@ void SysRootInformationConfigWidget::makeReadOnly()
m_chooser->setEnabled(false);
}
QWidget *SysRootInformationConfigWidget::mainWidget() const
{
return m_chooser->lineEdit();
}
QWidget *SysRootInformationConfigWidget::buttonWidget() const
{
return m_chooser->buttonAtIndex(0);
......@@ -101,22 +102,13 @@ void SysRootInformationConfigWidget::pathWasChanged()
// ToolChainInformationConfigWidget:
// --------------------------------------------------------------------------
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, QWidget *parent) :
KitConfigWidget(parent),
m_isReadOnly(false), m_kit(k),
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this))
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k) :
KitConfigWidget(k), m_isReadOnly(false)
{
setToolTip(tr("The compiler to use for building.<br>"
"Make sure the compiler will produce binaries compatible with the target device, "
"Qt version and other libraries used."));
ToolChainManager *tcm = ToolChainManager::instance();
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
m_comboBox->setContentsMargins(0, 0, 0, 0);
m_comboBox = new QComboBox;
m_comboBox->setEnabled(false);
m_comboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
layout->addWidget(m_comboBox);
foreach (ToolChain *tc, tcm->toolChains())
toolChainAdded(tc);
......@@ -126,8 +118,8 @@ ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, QWidg
refresh();
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentToolChainChanged(int)));
m_manageButton = new QPushButton(tr("Manage..."));
m_manageButton->setContentsMargins(0, 0, 0, 0);
m_manageButton->setText(tr("Manage..."));
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageToolChains()));
connect(tcm, SIGNAL(toolChainAdded(ProjectExplorer::ToolChain*)),
......@@ -143,6 +135,13 @@ QString ToolChainInformationConfigWidget::displayName() const
return tr("Compiler:");
}
QString ToolChainInformationConfigWidget::toolTip() const
{
return tr("The compiler to use for building.<br>"
"Make sure the compiler will produce binaries compatible with the target device, "
"Qt version and other libraries used.");
}
void ToolChainInformationConfigWidget::refresh()
{
m_comboBox->setCurrentIndex(indexOf(ToolChainKitInformation::toolChain(m_kit)));
......@@ -153,6 +152,11 @@ void ToolChainInformationConfigWidget::makeReadOnly()
m_comboBox->setEnabled(false);
}
QWidget *ToolChainInformationConfigWidget::mainWidget() const
{
return m_comboBox;
}
QWidget *ToolChainInformationConfigWidget::buttonWidget() const
{
return m_manageButton;
......@@ -222,35 +226,35 @@ int ToolChainInformationConfigWidget::indexOf(const ToolChain *tc)
// DeviceTypeInformationConfigWidget:
// --------------------------------------------------------------------------
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy, QWidget *parent) :
KitConfigWidget(parent),
m_isReadOnly(false), m_kit(workingCopy),
m_comboBox(new QComboBox)
DeviceTypeInformationConfigWidget::DeviceTypeInformationConfigWidget(Kit *workingCopy) :
KitConfigWidget(workingCopy), m_isReadOnly(false), m_comboBox(new QComboBox)
{
setToolTip(tr("The type of device to run applications on."));
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
m_comboBox->setContentsMargins(0, 0, 0, 0);
m_comboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
layout->addWidget(m_comboBox);
QList<IDeviceFactory *> factories
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
foreach (IDeviceFactory *factory, factories) {
foreach (Core::Id id, factory->availableCreationIds()) {
foreach (Core::Id id, factory->availableCreationIds())
m_comboBox->addItem(factory->displayNameForId(id), id.uniqueIdentifier());
}
}
refresh();
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentTypeChanged(int)));
}
QWidget *DeviceTypeInformationConfigWidget::mainWidget() const
{
return m_comboBox;
}
QString DeviceTypeInformationConfigWidget::displayName() const
{
return tr("Device type:");
}
QString DeviceTypeInformationConfigWidget::toolTip() const
{
return tr("The type of device to run applications on.");
}
void DeviceTypeInformationConfigWidget::refresh()
{
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(m_kit);
......@@ -279,39 +283,38 @@ void DeviceTypeInformationConfigWidget::currentTypeChanged(int idx)
// DeviceInformationConfigWidget:
// --------------------------------------------------------------------------
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy, QWidget *parent) :
KitConfigWidget(parent),
m_isReadOnly(false), m_kit(workingCopy),
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this)),
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Kit *workingCopy) :
KitConfigWidget(workingCopy),
m_isReadOnly(false),
m_comboBox(new QComboBox),
m_model(new DeviceManagerModel(DeviceManager::instance()))
{
connect(m_model, SIGNAL(modelAboutToBeReset()), SLOT(modelAboutToReset()));
connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
setToolTip(tr("The device to run the applications on."));
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
m_comboBox->setContentsMargins(0, 0, 0, 0);
m_comboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
layout->addWidget(m_comboBox);
m_comboBox->setModel(m_model);
m_manageButton->setContentsMargins(0, 0, 0, 0);
m_manageButton->setText(tr("Manage..."));
m_manageButton = new QPushButton(tr("Manage"));
refresh();
connect(m_model, SIGNAL(modelAboutToBeReset()), SLOT(modelAboutToReset()));
connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentDeviceChanged()));
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageDevices()));
}
QWidget *DeviceInformationConfigWidget::mainWidget() const
{
return m_comboBox;
}
QString DeviceInformationConfigWidget::displayName() const
{
return tr("Device:");
}
QString DeviceInformationConfigWidget::toolTip() const
{
return tr("The device to run the applications on.");
}
void DeviceInformationConfigWidget::refresh()
{
m_model->setTypeFilter(DeviceTypeKitInformation::deviceTypeId(m_kit));
......
......@@ -44,7 +44,6 @@ namespace Utils { class PathChooser; }
namespace ProjectExplorer {
class DeviceManagerModel;
class Kit;
class ToolChain;
namespace Internal {
......@@ -58,18 +57,19 @@ class SysRootInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit SysRootInformationConfigWidget(Kit *k, QWidget *parent = 0);
explicit SysRootInformationConfigWidget(Kit *k);
QString displayName() const;
void refresh();
void makeReadOnly();
QWidget *buttonWidget() const;
QWidget *mainWidget() const;
QString toolTip() const;
private slots:
void pathWasChanged();
private:
Kit *m_kit;
Utils::PathChooser *m_chooser;
};
......@@ -82,12 +82,14 @@ class ToolChainInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit ToolChainInformationConfigWidget(Kit *k, QWidget *parent = 0);
explicit ToolChainInformationConfigWidget(Kit *k);
QString displayName() const;
void refresh();
void makeReadOnly();
QWidget *mainWidget() const;
QWidget *buttonWidget() const;
QString toolTip() const;
private slots:
void toolChainAdded(ProjectExplorer::ToolChain *tc);
......@@ -101,7 +103,6 @@ private:
int indexOf(const ToolChain *tc);
bool m_isReadOnly;
Kit *m_kit;
QComboBox *m_comboBox;
QPushButton *m_manageButton;
};
......@@ -115,9 +116,11 @@ class DeviceTypeInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit DeviceTypeInformationConfigWidget(Kit *workingCopy, QWidget *parent = 0);
explicit DeviceTypeInformationConfigWidget(Kit *workingCopy);
QWidget *mainWidget() const;
QString displayName() const;
QString toolTip() const;
void refresh();
void makeReadOnly();
......@@ -126,7 +129,6 @@ private slots:
private:
bool m_isReadOnly;
Kit *m_kit;
QComboBox *m_comboBox;
};
......@@ -139,12 +141,14 @@ class DeviceInformationConfigWidget : public KitConfigWidget
Q_OBJECT
public:
explicit DeviceInformationConfigWidget(Kit *workingCopy, QWidget *parent = 0);
explicit DeviceInformationConfigWidget(Kit *workingCopy);
QWidget *mainWidget() const;
QWidget *buttonWidget() const;
QString displayName() const;
QString toolTip() const;
void refresh();
void makeReadOnly();
QWidget *buttonWidget() const;
private slots:
void manageDevices();
......@@ -154,7 +158,6 @@ private slots:
private:
bool m_isReadOnly;
Kit *m_kit;
QComboBox *m_comboBox;
QPushButton *m_manageButton;
DeviceManagerModel *m_model;
......
......@@ -33,12 +33,13 @@
#include "kitmanager.h"
#include <utils/detailswidget.h>
#include <utils/qtcassert.h>
#include <QHBoxLayout>
#include <QFileDialog>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPainter>
#include <QToolButton>
#include <QScrollArea>
#include <QSizePolicy>
......@@ -47,11 +48,9 @@
static const char WORKING_COPY_KIT_ID[] = "modified kit";
namespace ProjectExplorer {
namespace Internal {
KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
QWidget(parent),
KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
m_layout(new QGridLayout),
m_iconButton(new QToolButton),
m_nameEdit(new QLineEdit),
......@@ -59,30 +58,27 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, QWidget *parent) :
m_modifiedKit(new Kit(Core::Id(WORKING_COPY_KIT_ID))),
m_fixingKit(false)
{
QVBoxLayout *top = new QVBoxLayout(this);
top->setMargin(0);
m_layout->addWidget(m_nameEdit, 0, WidgetColumn);
m_layout->addWidget(m_iconButton, 0, ButtonColumn);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QWidget *inner = new QWidget;
inner->setLayout(m_layout);
QScrollArea *scroll = new QScrollArea;
scroll->setWidget(inner);
scroll->setFrameShape(QFrame::NoFrame);
scroll->setWidgetResizable(true);
scroll->setFocusPolicy(Qt::NoFocus);
top->addWidget(scroll);
Utils::DetailsWidget *details = new Utils::DetailsWidget;
details->setState(Utils::DetailsWidget::NoSummary);
scroll->setWidget(details);
QWidget *widget = new QWidget;
QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->setMargin(1);
mainLayout->addWidget(scroll, 0, 0);
m_layout->setMargin(0);
m_layout->setSpacing(6);
m_layout->setContentsMargins(6, 0, 6, 0);
m_layout->setRowStretch(1, 1);
widget->setLayout(m_layout);
QString toolTip = tr("Kit name and icon.");
setLabel(tr("Name:"), toolTip, 0);
m_iconButton->setToolTip(toolTip);
details->setWidget(widget);
addToLayout(tr("Name:"), tr("Kit name and icon."), m_nameEdit, m_iconButton);
discard();
connect(m_iconButton, SIGNAL(clicked()), this, SLOT(setIcon()));
......@@ -100,7 +96,7 @@ KitManagerConfigWidget::~KitManagerConfigWidget()
delete m_modifiedKit;
// Make sure our workingCopy did not get registered somehow:
foreach (const Kit *k, KitManager::instance()->kits())
Q_ASSERT(k->id() != Core::Id(WORKING_COPY_KIT_ID));
QTC_CHECK(k->id() != Core::Id(WORKING_COPY_KIT_ID));
}
QString KitManagerConfigWidget::displayName() const
......@@ -159,10 +155,18 @@ QString KitManagerConfigWidget::validityMessage() const
void KitManagerConfigWidget::addConfigWidget(ProjectExplorer::KitConfigWidget *widget)
{
Q_ASSERT(widget);
Q_ASSERT(!m_widgets.contains(widget));
QTC_ASSERT(widget, return);
QTC_ASSERT(!m_widgets.contains(widget), return);
QString name = widget->displayName();
QString toolTip = widget->toolTip();
int row = m_layout->rowCount();
m_layout->addWidget(widget->mainWidget(), row, WidgetColumn);
if (QWidget *button = widget->buttonWidget())
m_layout->addWidget(button, row, ButtonColumn);
setLabel(name, toolTip, row);
addToLayout(widget->displayName(), widget->toolTip(), widget, widget->buttonWidget());
m_widgets.append(widget);
}
......@@ -248,16 +252,7 @@ void KitManagerConfigWidget::kitWasUpdated(Kit *k)
discard();
}
void KitManagerConfigWidget::addToLayout(const QString &name, const QString &toolTip,
QWidget *widget, QWidget *button)
{
int row = m_layout->rowCount();
addLabel(name, toolTip, row);
m_layout->addWidget(widget, row, WidgetColumn);
addButtonWidget(button, toolTip, row);
}
void KitManagerConfigWidget::addLabel(const QString &name, const QString &toolTip, int row)
void KitManagerConfigWidget::setLabel(const QString &name, const QString &toolTip, int row)
{
static const Qt::Alignment alignment
= static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
......@@ -266,13 +261,12 @@ void KitManagerConfigWidget::addLabel(const QString &name, const QString &toolTi
m_layout->addWidget(label, row, LabelColumn, alignment);
}
void KitManagerConfigWidget::addButtonWidget(QWidget *button, const QString &toolTip, int row)
void KitManagerConfigWidget::paintEvent(QPaintEvent *)
{
if (!button)
return;
if (button->toolTip().isEmpty())
button->setToolTip(toolTip);
m_layout->addWidget(button, row, ButtonColumn);
QPainter p(this);
if (m_background.size() != size())
m_background = Utils::DetailsWidget::createBackground(size(), 0, this);
p.drawPixmap(rect(), m_background);
}
} // namespace Internal
......
......@@ -32,8 +32,9 @@
#include "kitconfigwidget.h"
#include <QWidget>
QT_BEGIN_NAMESPACE
class QHBoxLayout;
class QGridLayout;
class QLineEdit;
class QToolButton;
......@@ -49,7 +50,7 @@ class KitManagerConfigWidget : public QWidget
Q_OBJECT
public:
explicit KitManagerConfigWidget(Kit *k, QWidget *parent = 0);
explicit KitManagerConfigWidget(Kit *k);