forked from qt-creator/qt-creator
Target options layout fixes.
* smaller icon button (waste less space) * align manage/choose buttons Change-Id: Idb2cb111a40353f2405cd964c2ec4f5cf8b24d78 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
6473d7b611
commit
d8d5efcd40
@@ -204,6 +204,7 @@ public:
|
||||
QString m_baseDirectory;
|
||||
Environment m_environment;
|
||||
BinaryVersionToolTipEventFilter *m_binaryVersionToolTipEventFilter;
|
||||
QList<QAbstractButton *> m_buttons;
|
||||
};
|
||||
|
||||
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
|
||||
@@ -270,16 +271,22 @@ PathChooser::~PathChooser()
|
||||
}
|
||||
|
||||
void PathChooser::addButton(const QString &text, QObject *receiver, const char *slotFunc)
|
||||
{
|
||||
insertButton(d->m_buttons.count(), text, receiver, slotFunc);
|
||||
}
|
||||
|
||||
void PathChooser::insertButton(int index, const QString &text, QObject *receiver, const char *slotFunc)
|
||||
{
|
||||
QPushButton *button = new QPushButton;
|
||||
button->setText(text);
|
||||
connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
||||
d->m_hLayout->addWidget(button);
|
||||
d->m_hLayout->insertWidget(index + 1/*line edit*/, button);
|
||||
d->m_buttons.insert(index, button);
|
||||
}
|
||||
|
||||
QAbstractButton *PathChooser::buttonAtIndex(int index) const
|
||||
{
|
||||
return findChildren<QAbstractButton*>().at(index);
|
||||
return d->m_buttons.at(index);
|
||||
}
|
||||
|
||||
QString PathChooser::baseDirectory() const
|
||||
@@ -343,8 +350,7 @@ bool PathChooser::isReadOnly() const
|
||||
void PathChooser::setReadOnly(bool b)
|
||||
{
|
||||
d->m_lineEdit->setReadOnly(b);
|
||||
const QList<QAbstractButton *> &allButtons = findChildren<QAbstractButton *>();
|
||||
foreach (QAbstractButton *button, allButtons)
|
||||
foreach (QAbstractButton *button, d->m_buttons)
|
||||
button->setEnabled(!b);
|
||||
}
|
||||
|
||||
|
@@ -114,6 +114,7 @@ public:
|
||||
static QString homePath();
|
||||
|
||||
void addButton(const QString &text, QObject *receiver, const char *slotFunc);
|
||||
void insertButton(int index, const QString &text, QObject *receiver, const char *slotFunc);
|
||||
QAbstractButton *buttonAtIndex(int index) const;
|
||||
|
||||
QLineEdit *lineEdit() const;
|
||||
|
@@ -96,15 +96,8 @@ DebuggerProfileConfigWidget::DebuggerProfileConfigWidget(ProjectExplorer::Profil
|
||||
|
||||
m_chooser->setContentsMargins(0, 0, 0, 0);
|
||||
m_chooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
m_chooser->insertButton(0, tr("Auto detect"), this, SLOT(autoDetectDebugger()));
|
||||
|
||||
QPushButton *button = new QPushButton(tr("Auto detect"));
|
||||
button->setContentsMargins(0, 0, 0, 0);
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(autoDetectDebugger()));
|
||||
|
||||
QHBoxLayout *box = dynamic_cast<QHBoxLayout *>(m_chooser->layout());
|
||||
QTC_CHECK(box);
|
||||
if (box)
|
||||
box->insertWidget(1, button);
|
||||
layout->addWidget(m_chooser);
|
||||
|
||||
discard();
|
||||
@@ -137,6 +130,11 @@ bool DebuggerProfileConfigWidget::isDirty() const
|
||||
return m_chooser->fileName() != DebuggerProfileInformation::debuggerCommand(m_profile);
|
||||
}
|
||||
|
||||
QWidget *DebuggerProfileConfigWidget::buttonWidget() const
|
||||
{
|
||||
return m_chooser->buttonAtIndex(1);
|
||||
}
|
||||
|
||||
void DebuggerProfileConfigWidget::autoDetectDebugger()
|
||||
{
|
||||
QVariant v = m_info->defaultValue(m_profile);
|
||||
|
@@ -65,6 +65,7 @@ public:
|
||||
void apply();
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
QWidget *buttonWidget() const;
|
||||
|
||||
private slots:
|
||||
void autoDetectDebugger();
|
||||
|
@@ -58,6 +58,7 @@ public:
|
||||
virtual void discard() = 0;
|
||||
virtual bool isDirty() const = 0;
|
||||
|
||||
virtual QWidget *buttonWidget() const { return 0; }
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
@@ -98,6 +98,11 @@ void SysRootInformationConfigWidget::makeReadOnly()
|
||||
m_chooser->setEnabled(false);
|
||||
}
|
||||
|
||||
QWidget *SysRootInformationConfigWidget::buttonWidget() const
|
||||
{
|
||||
return m_chooser->buttonAtIndex(0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// ToolChainInformationConfigWidget:
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -105,7 +110,7 @@ void SysRootInformationConfigWidget::makeReadOnly()
|
||||
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Profile *p, QWidget *parent) :
|
||||
ProfileConfigWidget(parent),
|
||||
m_isReadOnly(false), m_profile(p),
|
||||
m_comboBox(new QComboBox), m_manageButton(new QPushButton)
|
||||
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this))
|
||||
{
|
||||
ToolChainManager *tcm = ToolChainManager::instance();
|
||||
|
||||
@@ -126,7 +131,6 @@ ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Profile *p, Q
|
||||
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
m_manageButton->setText(tr("Manage..."));
|
||||
layout->addWidget(m_manageButton);
|
||||
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(manageToolChains()));
|
||||
|
||||
connect(tcm, SIGNAL(toolChainAdded(ProjectExplorer::ToolChain*)),
|
||||
@@ -166,6 +170,11 @@ void ToolChainInformationConfigWidget::makeReadOnly()
|
||||
m_comboBox->setEnabled(false);
|
||||
}
|
||||
|
||||
QWidget *ToolChainInformationConfigWidget::buttonWidget() const
|
||||
{
|
||||
return m_manageButton;
|
||||
}
|
||||
|
||||
void ToolChainInformationConfigWidget::toolChainAdded(ProjectExplorer::ToolChain *tc)
|
||||
{
|
||||
m_comboBox->addItem(tc->displayName(), tc->id());
|
||||
@@ -292,7 +301,7 @@ void DeviceTypeInformationConfigWidget::makeReadOnly()
|
||||
DeviceInformationConfigWidget::DeviceInformationConfigWidget(Profile *p, QWidget *parent) :
|
||||
ProfileConfigWidget(parent),
|
||||
m_isReadOnly(false), m_profile(p),
|
||||
m_comboBox(new QComboBox), m_manageButton(new QPushButton),
|
||||
m_comboBox(new QComboBox), m_manageButton(new QPushButton(this)),
|
||||
m_model(new DeviceManagerModel(DeviceManager::instance()))
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
@@ -305,7 +314,6 @@ DeviceInformationConfigWidget::DeviceInformationConfigWidget(Profile *p, QWidget
|
||||
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
m_manageButton->setText(tr("Manage..."));
|
||||
layout->addWidget(m_manageButton);
|
||||
|
||||
discard();
|
||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(dirty()));
|
||||
@@ -343,6 +351,11 @@ void DeviceInformationConfigWidget::makeReadOnly()
|
||||
m_comboBox->setEnabled(false);
|
||||
}
|
||||
|
||||
QWidget *DeviceInformationConfigWidget::buttonWidget() const
|
||||
{
|
||||
return m_manageButton;
|
||||
}
|
||||
|
||||
void DeviceInformationConfigWidget::manageDevices()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(QLatin1String(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY),
|
||||
|
@@ -64,6 +64,7 @@ public:
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
void makeReadOnly();
|
||||
QWidget *buttonWidget() const;
|
||||
|
||||
private:
|
||||
Profile *m_profile;
|
||||
@@ -86,6 +87,7 @@ public:
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
void makeReadOnly();
|
||||
QWidget *buttonWidget() const;
|
||||
|
||||
private slots:
|
||||
void toolChainAdded(ProjectExplorer::ToolChain *tc);
|
||||
@@ -142,6 +144,7 @@ public:
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
void makeReadOnly();
|
||||
QWidget *buttonWidget() const;
|
||||
|
||||
private slots:
|
||||
void manageDevices();
|
||||
|
@@ -36,24 +36,24 @@
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
#include <QSizePolicy>
|
||||
#include <QStyle>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
ProfileManagerConfigWidget::ProfileManagerConfigWidget(Profile *p, QWidget *parent) :
|
||||
ProfileConfigWidget(parent),
|
||||
m_layout(new QFormLayout),
|
||||
m_iconButton(new QPushButton),
|
||||
m_layout(new QGridLayout),
|
||||
m_iconButton(new QToolButton),
|
||||
m_profile(p)
|
||||
{
|
||||
m_layout->setMargin(0);
|
||||
m_layout->setSpacing(6);
|
||||
|
||||
m_iconButton->setMinimumSize(70, 70);
|
||||
m_iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
QVBoxLayout *iconLayout = new QVBoxLayout;
|
||||
iconLayout->addWidget(m_iconButton);
|
||||
iconLayout->addStretch();
|
||||
@@ -103,7 +103,12 @@ void ProfileManagerConfigWidget::addConfigWidget(ProjectExplorer::ProfileConfigW
|
||||
Q_ASSERT(!m_widgets.contains(widget));
|
||||
|
||||
connect(widget, SIGNAL(dirty()), this, SIGNAL(dirty()));
|
||||
m_layout->addRow(widget->displayName(), widget);
|
||||
int row = m_layout->rowCount();
|
||||
m_layout->addWidget(new QLabel(widget->displayName()), row, 0,
|
||||
Qt::Alignment(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)));
|
||||
m_layout->addWidget(widget, row, 1);
|
||||
if (widget->buttonWidget())
|
||||
m_layout->addWidget(widget->buttonWidget(), row, 2);
|
||||
m_widgets.append(widget);
|
||||
}
|
||||
|
||||
|
@@ -37,8 +37,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QHBoxLayout;
|
||||
class QFormLayout;
|
||||
class QPushButton;
|
||||
class QGridLayout;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -65,8 +65,8 @@ private slots:
|
||||
void setIcon();
|
||||
|
||||
private:
|
||||
QFormLayout *m_layout;
|
||||
QPushButton *m_iconButton;
|
||||
QGridLayout *m_layout;
|
||||
QToolButton *m_iconButton;
|
||||
QList<ProfileConfigWidget *> m_widgets;
|
||||
Profile *m_profile;
|
||||
QString m_iconPath;
|
||||
|
@@ -53,7 +53,7 @@ QtProfileConfigWidget::QtProfileConfigWidget(ProjectExplorer::Profile *p,
|
||||
ProjectExplorer::ProfileConfigWidget(parent),
|
||||
m_profile(p),
|
||||
m_combo(new QComboBox),
|
||||
m_manageButton(new QPushButton)
|
||||
m_manageButton(new QPushButton(this))
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
@@ -64,7 +64,6 @@ QtProfileConfigWidget::QtProfileConfigWidget(ProjectExplorer::Profile *p,
|
||||
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
m_manageButton->setText(tr("Manage..."));
|
||||
layout->addWidget(m_manageButton);
|
||||
|
||||
QtVersionManager *mgr = QtVersionManager::instance();
|
||||
|
||||
@@ -114,6 +113,11 @@ bool QtProfileConfigWidget::isDirty() const
|
||||
return id != QtProfileInformation::qtVersionId(m_profile);
|
||||
}
|
||||
|
||||
QWidget *QtProfileConfigWidget::buttonWidget() const
|
||||
{
|
||||
return m_manageButton;
|
||||
}
|
||||
|
||||
void QtProfileConfigWidget::versionsChanged(const QList<int> &added, const QList<int> &removed,
|
||||
const QList<int> &changed)
|
||||
{
|
||||
|
@@ -59,6 +59,7 @@ public:
|
||||
void apply();
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
QWidget *buttonWidget() const;
|
||||
|
||||
private slots:
|
||||
void versionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed);
|
||||
|
Reference in New Issue
Block a user