| 4306 | } |
| 4307 | |
| 4308 | void MainWindow::buildTimelineAlignRail() { |
| 4309 | // A 24-px icon column on the right edge of the timeline panel that visually |
| 4310 | // continues the global toolbar above it (they line up when the right panel is |
| 4311 | // closed). Holds the Source Timeline alignment actions. The buttons mirror the |
| 4312 | // global toolbar's style (theme-tinted SVG, chrome-metrics sizing); the rail's |
| 4313 | // show/hide tracks the strip in applyBottomPanelConstraints. |
| 4314 | auto* outer = qobject_cast<QVBoxLayout*>(ui_->timelineAlignRail->layout()); |
| 4315 | if (outer == nullptr) { |
| 4316 | return; |
| 4317 | } |
| 4318 | outer->setSpacing(0); |
| 4319 | outer->setContentsMargins(0, 0, 0, 0); |
| 4320 | |
| 4321 | auto add_button = [this, outer](const char* object_name, const char* icon_path, const char* tooltip) -> QToolButton* { |
| 4322 | auto* btn = new SvgButton(ui_->timelineAlignRail); |
| 4323 | btn->setObjectName(QString::fromLatin1(object_name)); |
| 4324 | btn->setIconPath(QString::fromLatin1(icon_path)); |
| 4325 | btn->setExtent(chrome_metrics_.icon_size + chrome_metrics_.icon_padding, chrome_metrics_.icon_size); |
| 4326 | btn->setToolTip(tr(tooltip)); |
| 4327 | outer->addWidget(btn); |
| 4328 | return btn; |
| 4329 | }; |
| 4330 | |
| 4331 | QToolButton* align_left = add_button( |
| 4332 | "buttonAlignStarts", ":/resources/svg/align_horizontal_left.svg", |
| 4333 | "Align sources: line every source's start up at the earliest start"); |
| 4334 | |
| 4335 | QToolButton* align_right = add_button( |
| 4336 | "buttonAlignEnds", ":/resources/svg/align_horizontal_right.svg", |
| 4337 | "Align sources: line every source's end up at the latest end"); |
| 4338 | |
| 4339 | // Zoom-out-horizontally: fit all source bars into the view (the timeline's |
| 4340 | // equivalent of the plot's "Zoom Out Horizontally", same icon). Replaces the |
| 4341 | // former align-centers action on the rail. |
| 4342 | QToolButton* zoom_fit = |
| 4343 | add_button("buttonTimelineFit", ":/resources/svg/zoom_horizontal.svg", "Zoom out to fit all sources"); |
| 4344 | |
| 4345 | // "Snap to" toggle — when on, a dragged bar's start/end snaps to a neighbour's |
| 4346 | // edge (with a guide line). Checkable; on by default. |
| 4347 | QToolButton* snap_toggle = add_button( |
| 4348 | "buttonTimelineSnap", ":/resources/svg/transition_push.svg", "Snap to neighbouring dataset edges while dragging"); |
| 4349 | snap_toggle->setCheckable(true); |
| 4350 | snap_toggle->setChecked(true); |
| 4351 | |
| 4352 | // Stretch pins the align/snap icons to the top of the content area; the reset |
| 4353 | // button below it sits at the BOTTOM of the rail. |
| 4354 | outer->addStretch(1); |
| 4355 | QToolButton* reset_all = |
| 4356 | add_button("buttonTimelineReset", ":/resources/svg/restart_alt.svg", "Reset all timeline changes"); |
| 4357 | |
| 4358 | if (source_timeline_controller_ != nullptr) { |
| 4359 | connect(align_left, &QToolButton::clicked, source_timeline_controller_, &SourceTimelineController::alignStarts); |
| 4360 | connect(align_right, &QToolButton::clicked, source_timeline_controller_, &SourceTimelineController::alignEnds); |
| 4361 | connect(reset_all, &QToolButton::clicked, source_timeline_controller_, &SourceTimelineController::resetAll); |
| 4362 | } |
| 4363 | if (source_timeline_ != nullptr) { |
| 4364 | connect(zoom_fit, &QToolButton::clicked, source_timeline_, &Timeline::zoomToFit); |
| 4365 | connect(snap_toggle, &QToolButton::toggled, source_timeline_, &Timeline::setSnapEnabled); |
nothing calls this directly
no test coverage detected