wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ClockDialogUI.cpp
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
5
6#include <QtCore/QCoreApplication>
7#include <QtCore/QMetaObject>
8#include <QtGui/QIcon>
9
11{
12 if (ClockDialog->objectName().isEmpty()) {
13 ClockDialog->setObjectName("ClockDialog");
14 }
15
16 // Fixed dialog size — no resizing needed since the content is minimal.
17 ClockDialog->resize(184, 116);
18
19 ClockDialog->setWindowIcon(QIcon(":/Interface/Toolbar/wavyIcon.svg"));
20
21 gridLayout_2 = new QGridLayout(ClockDialog);
22 gridLayout_2->setObjectName("gridLayout_2");
23
24 buttonBox = new QDialogButtonBox(ClockDialog);
25 buttonBox->setObjectName("buttonBox");
26 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
27 gridLayout_2->addWidget(buttonBox, 6, 0, 1, 2);
28
29 // The value is a clock period in waveform time-step columns. Minimum of 2 because a
30 // period of 1 would toggle every step (degenerate); step of 2 enforces even periods so
31 // the 50% duty cycle divides cleanly.
32 periodSpinBox = new QSpinBox(ClockDialog);
33 periodSpinBox->setObjectName("periodSpinBox");
34 periodSpinBox->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
35 periodSpinBox->setMinimum(2);
36 periodSpinBox->setMaximum(1024);
37 periodSpinBox->setSingleStep(2);
38 gridLayout_2->addWidget(periodSpinBox, 0, 1, 1, 1);
39
40 periodSlider = new QSlider(ClockDialog);
41 periodSlider->setObjectName("periodSlider");
42 // Slider mirrors the spin box constraints exactly so both controls always
43 // show the same legal range.
44 periodSlider->setMinimum(2);
45 periodSlider->setMaximum(1024);
46 periodSlider->setSingleStep(2);
47 periodSlider->setOrientation(Qt::Horizontal);
48 gridLayout_2->addWidget(periodSlider, 3, 0, 1, 2);
49
50 titleLabel = new QLabel(ClockDialog);
51 titleLabel->setObjectName("titleLabel");
52 gridLayout_2->addWidget(titleLabel, 0, 0, 1, 1);
53
54 maxLabel = new QLabel(ClockDialog);
55 maxLabel->setObjectName("maxLabel");
56 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing);
57 gridLayout_2->addWidget(maxLabel, 4, 1, 1, 1);
58
59 minLabel = new QLabel(ClockDialog);
60 minLabel->setObjectName("minLabel");
61 minLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
62 gridLayout_2->addWidget(minLabel, 4, 0, 1, 1);
63
65
66 // Bidirectionally sync the slider and spin box so either control can drive the other
67 QObject::connect(periodSlider, &QSlider::valueChanged, periodSpinBox, &QSpinBox::setValue);
68 QObject::connect(periodSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), periodSlider, &QSlider::setValue);
69
70 QMetaObject::connectSlotsByName(ClockDialog);
71}
72
74{
75 ClockDialog->setWindowTitle(QCoreApplication::translate("ClockDialog", "Clock"));
76 titleLabel->setText(QCoreApplication::translate("ClockDialog", "Clock Period"));
77 // Range end labels are numbers, not translatable text — build them from the slider's
78 // actual bounds instead of shipping bare "2"/"1024" strings to the Weblate catalog.
79 maxLabel->setText(QString::number(periodSlider->maximum()));
80 minLabel->setText(QString::number(periodSlider->minimum()));
81}
ClockDialogUi: hand-written UI class for the ClockDialog.
QSpinBox * periodSpinBox
void setupUi(QDialog *ClockDialog)
Creates and lays out all child widgets inside ClockDialog.
void retranslateUi(QDialog *ClockDialog)
Updates all translatable strings in the dialog.
QSlider * periodSlider
QLabel * titleLabel
QLabel * minLabel
QLabel * maxLabel
QGridLayout * gridLayout_2
QDialogButtonBox * buttonBox
Modal dialog for selecting the period of a beWavedDolphin clock wave.
Definition ClockDialog.h:25