Core: Use LayoutBuilder in CommandMappingsPrivate

Change-Id: I327e3eae887c0e4e1dfe600685e71c194f26ff75
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Alessandro Portale
2023-06-01 12:40:59 +02:00
parent f5d02f4bcb
commit 73791080d4

View File

@@ -6,18 +6,17 @@
#include <coreplugin/coreplugintr.h> #include <coreplugin/coreplugintr.h>
#include <coreplugin/dialogs/shortcutsettings.h> #include <coreplugin/dialogs/shortcutsettings.h>
#include <utils/headerviewstretcher.h>
#include <utils/fancylineedit.h> #include <utils/fancylineedit.h>
#include <utils/headerviewstretcher.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QPointer> #include <QPointer>
#include <QPushButton> #include <QPushButton>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QVBoxLayout>
Q_DECLARE_METATYPE(Core::Internal::ShortcutItem*) Q_DECLARE_METATYPE(Core::Internal::ShortcutItem*)
@@ -32,13 +31,10 @@ public:
CommandMappingsPrivate(CommandMappings *parent) CommandMappingsPrivate(CommandMappings *parent)
: q(parent) : q(parent)
{ {
groupBox = new QGroupBox(parent); filterEdit = new FancyLineEdit;
groupBox->setTitle(::Core::Tr::tr("Command Mappings"));
filterEdit = new FancyLineEdit(groupBox);
filterEdit->setFiltering(true); filterEdit->setFiltering(true);
commandList = new QTreeWidget(groupBox); commandList = new QTreeWidget;
commandList->setRootIsDecorated(false); commandList->setRootIsDecorated(false);
commandList->setUniformRowHeights(true); commandList->setUniformRowHeights(true);
commandList->setSortingEnabled(true); commandList->setSortingEnabled(true);
@@ -49,33 +45,28 @@ public:
item->setText(1, ::Core::Tr::tr("Label")); item->setText(1, ::Core::Tr::tr("Label"));
item->setText(0, ::Core::Tr::tr("Command")); item->setText(0, ::Core::Tr::tr("Command"));
defaultButton = new QPushButton(::Core::Tr::tr("Reset All"), groupBox); defaultButton = new QPushButton(::Core::Tr::tr("Reset All"));
defaultButton->setToolTip(::Core::Tr::tr("Reset all to default.")); defaultButton->setToolTip(::Core::Tr::tr("Reset all to default."));
resetButton = new QPushButton(::Core::Tr::tr("Reset"), groupBox); resetButton = new QPushButton(::Core::Tr::tr("Reset"));
resetButton->setToolTip(::Core::Tr::tr("Reset to default.")); resetButton->setToolTip(::Core::Tr::tr("Reset to default."));
resetButton->setVisible(false); resetButton->setVisible(false);
importButton = new QPushButton(::Core::Tr::tr("Import..."), groupBox); importButton = new QPushButton(::Core::Tr::tr("Import..."));
exportButton = new QPushButton(::Core::Tr::tr("Export..."), groupBox); exportButton = new QPushButton(::Core::Tr::tr("Export..."));
auto hboxLayout1 = new QHBoxLayout(); using namespace Layouting;
hboxLayout1->addWidget(defaultButton); Column {
hboxLayout1->addWidget(resetButton); Group {
hboxLayout1->addStretch(); title(::Core::Tr::tr("Command Mappings")),
hboxLayout1->addWidget(importButton); bindTo(&groupBox),
hboxLayout1->addWidget(exportButton); Column {
filterEdit,
auto hboxLayout = new QHBoxLayout(); commandList,
hboxLayout->addWidget(filterEdit); Row { defaultButton, resetButton, st, importButton, exportButton },
},
auto vboxLayout1 = new QVBoxLayout(groupBox); },
vboxLayout1->addLayout(hboxLayout); }.attachTo(parent);
vboxLayout1->addWidget(commandList);
vboxLayout1->addLayout(hboxLayout1);
auto vboxLayout = new QVBoxLayout(parent);
vboxLayout->addWidget(groupBox);
q->connect(exportButton, &QPushButton::clicked, q->connect(exportButton, &QPushButton::clicked,
q, &CommandMappings::exportAction); q, &CommandMappings::exportAction);