forked from qt-creator/qt-creator
Utils: Add a PushButton object to LayoutBuilder
Change-Id: I1ed0fd9a940fcaa5361a7d619a5d316f646332b1 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -469,6 +470,8 @@ LayoutBuilder::AlignAsFormLabel::AlignAsFormLabel(const LayoutItem &item)
|
|||||||
|
|
||||||
namespace Layouting {
|
namespace Layouting {
|
||||||
|
|
||||||
|
// "Widgets"
|
||||||
|
|
||||||
Group::Group(const LayoutBuilder &innerLayout)
|
Group::Group(const LayoutBuilder &innerLayout)
|
||||||
: Group({}, innerLayout)
|
: Group({}, innerLayout)
|
||||||
{}
|
{}
|
||||||
@@ -481,6 +484,15 @@ Group::Group(const LayoutBuilder::Setters &setters, const LayoutBuilder &innerLa
|
|||||||
func(widget);
|
func(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PushButton::PushButton(std::initializer_list<LayoutBuilder::Setter> setters)
|
||||||
|
{
|
||||||
|
widget = new QPushButton;
|
||||||
|
for (const LayoutBuilder::Setter &func : setters)
|
||||||
|
func(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Properties"
|
||||||
|
|
||||||
LayoutBuilder::Setter title(const QString &title, BoolAspect *checker)
|
LayoutBuilder::Setter title(const QString &title, BoolAspect *checker)
|
||||||
{
|
{
|
||||||
return [title, checker](QObject *target) {
|
return [title, checker](QObject *target) {
|
||||||
@@ -498,6 +510,39 @@ LayoutBuilder::Setter title(const QString &title, BoolAspect *checker)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LayoutBuilder::Setter onClicked(const std::function<void ()> &func, QObject *guard)
|
||||||
|
{
|
||||||
|
return [func, guard](QObject *target) {
|
||||||
|
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
||||||
|
QObject::connect(button, &QAbstractButton::clicked, guard ? guard : target, func);
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutBuilder::Setter text(const QString &text)
|
||||||
|
{
|
||||||
|
return [text](QObject *target) {
|
||||||
|
if (auto button = qobject_cast<QAbstractButton *>(target)) {
|
||||||
|
button->setText(text);
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutBuilder::Setter tooltip(const QString &toolTip)
|
||||||
|
{
|
||||||
|
return [toolTip](QObject *target) {
|
||||||
|
if (auto widget = qobject_cast<QWidget *>(target)) {
|
||||||
|
widget->setToolTip(toolTip);
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
LayoutBuilder::Break br;
|
LayoutBuilder::Break br;
|
||||||
LayoutBuilder::Stretch st;
|
LayoutBuilder::Stretch st;
|
||||||
LayoutBuilder::Space empty(0);
|
LayoutBuilder::Space empty(0);
|
||||||
|
|||||||
@@ -188,6 +188,11 @@ namespace Layouting {
|
|||||||
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter title(const QString &title,
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter title(const QString &title,
|
||||||
BoolAspect *checker = nullptr);
|
BoolAspect *checker = nullptr);
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter text(const QString &text);
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter tooltip(const QString &toolTip);
|
||||||
|
QTCREATOR_UTILS_EXPORT LayoutBuilder::Setter onClicked(const std::function<void()> &func,
|
||||||
|
QObject *guard = nullptr);
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Group : public LayoutBuilder::LayoutItem
|
class QTCREATOR_UTILS_EXPORT Group : public LayoutBuilder::LayoutItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -195,6 +200,12 @@ public:
|
|||||||
Group(const LayoutBuilder::Setters &setters, const LayoutBuilder &innerLayout);
|
Group(const LayoutBuilder::Setters &setters, const LayoutBuilder &innerLayout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT PushButton : public LayoutBuilder::LayoutItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PushButton(std::initializer_list<LayoutBuilder::Setter> setters);
|
||||||
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Column : public LayoutBuilder
|
class QTCREATOR_UTILS_EXPORT Column : public LayoutBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -157,10 +157,6 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
Tr::tr("Timeout used when executing test cases. This will apply "
|
Tr::tr("Timeout used when executing test cases. This will apply "
|
||||||
"for each test case on its own, not the whole project."));
|
"for each test case on its own, not the whole project."));
|
||||||
|
|
||||||
auto resetChoicesButton = new QPushButton(Tr::tr("Reset Cached Choices"));
|
|
||||||
resetChoicesButton->setToolTip(
|
|
||||||
Tr::tr("Clear all cached choices of run configurations for tests where the executable could not be deduced."));
|
|
||||||
|
|
||||||
m_frameworkTreeWidget = new QTreeWidget;
|
m_frameworkTreeWidget = new QTreeWidget;
|
||||||
m_frameworkTreeWidget->setRootIsDecorated(false);
|
m_frameworkTreeWidget->setRootIsDecorated(false);
|
||||||
m_frameworkTreeWidget->setHeaderHidden(false);
|
m_frameworkTreeWidget->setHeaderHidden(false);
|
||||||
@@ -181,6 +177,13 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
|
|
||||||
using namespace Utils::Layouting;
|
using namespace Utils::Layouting;
|
||||||
|
|
||||||
|
PushButton resetChoicesButton {
|
||||||
|
text(Tr::tr("Reset Cached Choices")),
|
||||||
|
tooltip(Tr::tr("Clear all cached choices of run configurations for "
|
||||||
|
"tests where the executable could not be deduced.")),
|
||||||
|
onClicked([] { AutotestPlugin::clearChoiceCache(); }, this)
|
||||||
|
};
|
||||||
|
|
||||||
Group generalGroup {
|
Group generalGroup {
|
||||||
title(Tr::tr("General")),
|
title(Tr::tr("General")),
|
||||||
Column {
|
Column {
|
||||||
@@ -218,8 +221,6 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
|
|
||||||
connect(m_frameworkTreeWidget, &QTreeWidget::itemChanged,
|
connect(m_frameworkTreeWidget, &QTreeWidget::itemChanged,
|
||||||
this, &TestSettingsWidget::onFrameworkItemChanged);
|
this, &TestSettingsWidget::onFrameworkItemChanged);
|
||||||
connect(resetChoicesButton, &QPushButton::clicked,
|
|
||||||
this, [] { AutotestPlugin::clearChoiceCache(); });
|
|
||||||
connect(m_openResultsOnFinishCB, &QCheckBox::toggled,
|
connect(m_openResultsOnFinishCB, &QCheckBox::toggled,
|
||||||
m_openResultsOnFailCB, &QCheckBox::setEnabled);
|
m_openResultsOnFailCB, &QCheckBox::setEnabled);
|
||||||
connect(m_limitResultDescriptionCb, &QCheckBox::toggled,
|
connect(m_limitResultDescriptionCb, &QCheckBox::toggled,
|
||||||
|
|||||||
Reference in New Issue
Block a user