From d04a2defd2c8af08f7875820b34e35e32cb18d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Mon, 25 Nov 2024 13:21:00 +0100 Subject: [PATCH] Markers Ui cleanup - Fix layout spacing - Added this to QPushButtons - Consistent new marker comment Ref: https://github.com/friction2d/friction/pull/343 --- src/ui/dialogs/markereditordialog.cpp | 29 +++++++++++++++++++-------- src/ui/widgets/markereditor.cpp | 10 +++++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/ui/dialogs/markereditordialog.cpp b/src/ui/dialogs/markereditordialog.cpp index 2a0636019..8ad397d37 100644 --- a/src/ui/dialogs/markereditordialog.cpp +++ b/src/ui/dialogs/markereditordialog.cpp @@ -41,14 +41,23 @@ MarkerEditorDialog::MarkerEditorDialog(Canvas *scene, setWindowFlag(Qt::WindowStaysOnTopHint); #endif + setContentsMargins(0, 0, 0, 0); const auto lay = new QVBoxLayout(this); const auto editor = new MarkerEditor(scene, this); const auto footer = new QHBoxLayout(); - const auto addButton = new QPushButton(QIcon::fromTheme("plus"), tr("")); - const auto remButton = new QPushButton(QIcon::fromTheme("minus"), tr("")); - const auto clearButton = new QPushButton(QIcon::fromTheme("trash"), tr("")); - const auto closeButton = new QPushButton(QIcon::fromTheme("close"), tr("Close")); + const auto addButton = new QPushButton(QIcon::fromTheme("plus"), + QString(), + this); + const auto remButton = new QPushButton(QIcon::fromTheme("minus"), + QString(), + this); + const auto clearButton = new QPushButton(QIcon::fromTheme("trash"), + QString(), + this); + const auto closeButton = new QPushButton(QIcon::fromTheme("close"), + tr("Close"), + this); addButton->setToolTip(tr("Add a new marker")); remButton->setToolTip(tr("Remove the selected marker from the list")); @@ -60,10 +69,14 @@ MarkerEditorDialog::MarkerEditorDialog(Canvas *scene, closeButton->setFocusPolicy(Qt::StrongFocus); closeButton->setFocus(); - connect(addButton, &QPushButton::clicked, editor, &MarkerEditor::addMarker); - connect(remButton, &QPushButton::clicked, editor, &MarkerEditor::removeMarker); - connect(clearButton, &QPushButton::clicked, editor, &MarkerEditor::clearMarkers); - connect(closeButton, &QPushButton::clicked, this, &QDialog::close); + connect(addButton, &QPushButton::clicked, + editor, &MarkerEditor::addMarker); + connect(remButton, &QPushButton::clicked, + editor, &MarkerEditor::removeMarker); + connect(clearButton, &QPushButton::clicked, + editor, &MarkerEditor::clearMarkers); + connect(closeButton, &QPushButton::clicked, + this, &QDialog::close); footer->addWidget(addButton); footer->addWidget(remButton); diff --git a/src/ui/widgets/markereditor.cpp b/src/ui/widgets/markereditor.cpp index fccc2d90b..cdefc885a 100644 --- a/src/ui/widgets/markereditor.cpp +++ b/src/ui/widgets/markereditor.cpp @@ -37,13 +37,18 @@ MarkerEditor::MarkerEditor(Canvas *scene, , mTree(nullptr) { const auto lay = new QVBoxLayout(this); + + setContentsMargins(0, 0, 0, 0); + lay->setContentsMargins(0, 0, 0, 0); + mTree = new QTreeWidget(this); lay->addWidget(mTree); setup(); populate(); if (mScene) { - connect(mScene, &Canvas::markersChanged, this, &MarkerEditor::populate); + connect(mScene,&Canvas::markersChanged, + this, &MarkerEditor::populate); } } @@ -131,9 +136,10 @@ void MarkerEditor::addMarker() return; } } + const int marker = (mTree->topLevelItemCount() - 1) >= 0 ? mTree->topLevelItemCount() : 0; auto item = new QTreeWidgetItem(mTree); mTree->blockSignals(true); - item->setText(1, QString::number(frame)); + item->setText(1, QString::number(marker)); item->setText(0, QString::number(frame)); item->setData(0, Qt::UserRole, frame); mTree->blockSignals(false);