From 69324f8e0776d1af9bcc4ee5cc3cb6bf39c11080 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 13 Dec 2024 16:13:51 +0000 Subject: [PATCH] Group apply button with format text box in buffer formatter * The apply button used to be below the text box but now can be hard to see with the saved formats also in the way. --- qrenderdoc/Widgets/BufferFormatSpecifier.cpp | 58 +++++++++++++++----- qrenderdoc/Widgets/BufferFormatSpecifier.h | 2 +- qrenderdoc/Widgets/BufferFormatSpecifier.ui | 30 ---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp index 59f769d6b..56f32c80e 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp @@ -25,6 +25,7 @@ #include "BufferFormatSpecifier.h" #include #include +#include #include #include #include @@ -111,10 +112,13 @@ BufferFormatSpecifier::BufferFormatSpecifier(QWidget *parent) formatText->setMarginWidthN(2, 0); QFrame *formatContainer = new QFrame(this); - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(2, 2, 2, 2); - layout->addWidget(formatText); - formatContainer->setLayout(layout); + { + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(2, 2, 2, 2); + layout->addWidget(formatText); + + formatContainer->setLayout(layout); + } QPalette pal = formatContainer->palette(); pal.setColor(QPalette::Window, pal.color(QPalette::Base)); @@ -131,15 +135,41 @@ BufferFormatSpecifier::BufferFormatSpecifier(QWidget *parent) formatText->annotationClearAll(); }); - QHBoxLayout *hbox = new QHBoxLayout(); - hbox->setSpacing(0); - hbox->setContentsMargins(2, 2, 2, 2); + QWidget *formatAndApply = new QWidget(this); + { + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + formatAndApply->setLayout(layout); + } + + formatAndApply->layout()->addWidget(formatContainer); + + { + QPushButton *apply = new QPushButton(tr("Apply"), this); + QObject::connect(apply, &QPushButton::clicked, this, &BufferFormatSpecifier::apply_clicked); + + QHBoxLayout *hbox = new QHBoxLayout(); + hbox->setSpacing(0); + hbox->setContentsMargins(0, 0, 0, 0); + hbox->addWidget(apply); + hbox->addSpacerItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); + + QWidget *applyFrame = new QWidget(this); + applyFrame->setLayout(hbox); + + formatAndApply->layout()->addWidget(applyFrame); + } QWidget *helpOrFormat = new QWidget(this); - helpOrFormat->setLayout(hbox); + { + QHBoxLayout *hbox = new QHBoxLayout(); + hbox->setSpacing(0); + hbox->setContentsMargins(2, 2, 2, 2); + helpOrFormat->setLayout(hbox); - hbox->insertWidget(0, formatContainer); - hbox->insertWidget(1, ui->helpText); + hbox->insertWidget(0, formatAndApply); + hbox->insertWidget(1, ui->helpText); + } m_Splitter = new RDSplitter(Qt::Horizontal, this); m_Splitter->setHandleWidth(12); @@ -178,7 +208,7 @@ void BufferFormatSpecifier::setAutoFormat(QString autoFormat) formatText->emptyUndoBuffer(); - on_apply_clicked(); + apply_clicked(); } void BufferFormatSpecifier::setContext(ICaptureContext *ctx) @@ -192,7 +222,7 @@ void BufferFormatSpecifier::setContext(ICaptureContext *ctx) &BufferFormatSpecifier::updateFormatList); m_Ctx->GetMainWindow()->RegisterShortcut(QKeySequence(QKeySequence::Refresh).toString(), this, - [this](QWidget *) { on_apply_clicked(); }); + [this](QWidget *) { apply_clicked(); }); updateFormatList(); } @@ -368,7 +398,7 @@ void BufferFormatSpecifier::on_savedList_itemSelectionChanged() void BufferFormatSpecifier::on_showHelp_toggled(bool help) { ui->helpText->setVisible(help); - formatText->parentWidget()->setVisible(!help); + formatText->parentWidget()->parentWidget()->setVisible(!help); if(help) ui->verticalLayout->invalidate(); @@ -447,7 +477,7 @@ void BufferFormatSpecifier::on_delDef_clicked() globalFormatList->setFormat(name, QString()); } -void BufferFormatSpecifier::on_apply_clicked() +void BufferFormatSpecifier::apply_clicked() { setErrors({}); emit processFormat(QString::fromUtf8(formatText->getText(formatText->textLength() + 1))); diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.h b/qrenderdoc/Widgets/BufferFormatSpecifier.h index c8607fb23..f1e1fae87 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.h +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.h @@ -91,7 +91,7 @@ public slots: void updateFormatList(); private slots: - void on_apply_clicked(); + void apply_clicked(); private: Ui::BufferFormatSpecifier *ui; diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.ui b/qrenderdoc/Widgets/BufferFormatSpecifier.ui index 796bebed1..d51bb4127 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.ui +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.ui @@ -225,36 +225,6 @@ p, li { white-space: pre-wrap; } - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Apply - - - - -