Skip to content

Commit

Permalink
Markers Ui cleanup
Browse files Browse the repository at this point in the history
- Fix layout spacing
- Added this to QPushButtons
- Consistent new marker comment

Ref: #343
  • Loading branch information
rodlie committed Nov 25, 2024
1 parent d02f48c commit d04a2de
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
29 changes: 21 additions & 8 deletions src/ui/dialogs/markereditordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions src/ui/widgets/markereditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d04a2de

Please sign in to comment.