Skip to content

Commit

Permalink
Fixed toggling visibility and enabling controls
Browse files Browse the repository at this point in the history
  • Loading branch information
etet100 committed Sep 14, 2024
1 parent 816510e commit 1670eb2
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 68 deletions.
45 changes: 33 additions & 12 deletions src/candle/frmmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ frmMain::frmMain(QWidget *parent) :
// qDebug() << "Command: " << command;
// });

// toggle section visibility
connect(ui->grpControl, &QGroupBox::toggled, this, [=](bool checked) {
updateLayouts();
ui->control->setVisible(checked);
});
connect(ui->grpState, &QGroupBox::toggled, this, [=](bool checked) {
updateLayouts();
ui->state->setVisible(checked);
});
connect(ui->grpSpindle, &QGroupBox::toggled, this, [=](bool checked) {
ui->grpSpindle->setProperty("overrided", checked);
style()->unpolish(ui->grpSpindle);
ui->grpSpindle->ensurePolished();

if (checked) {
if (!ui->grpSpindle->isChecked()) ui->grpSpindle->setTitle(tr("Spindle") + QString(tr(" (%1)")).arg(ui->slbSpindle->value()));
} else {
ui->grpSpindle->setTitle(tr("Spindle"));
}
});

connect(ui->jog, &partMainJog::jog, this, [=](JoggindDir dir, QVector3D jog) {
Q_UNUSED(dir)
qDebug() << "Jog: " << jog;
Expand Down Expand Up @@ -816,18 +837,18 @@ void frmMain::on_cmdFileReset_clicked()
// m_connection->sendByteArray(QByteArray(1, (char)0xa0));
// }

void frmMain::on_cmdSpindle_toggled(bool checked)
{
ui->grpSpindle->setProperty("overrided", checked);
style()->unpolish(ui->grpSpindle);
ui->grpSpindle->ensurePolished();
// void frmMain::on_cmdSpindle_toggled(bool checked)
// {
// ui->grpSpindle->setProperty("overrided", checked);
// style()->unpolish(ui->grpSpindle);
// ui->grpSpindle->ensurePolished();

if (checked) {
if (!ui->grpSpindle->isChecked()) ui->grpSpindle->setTitle(tr("Spindle") + QString(tr(" (%1)")).arg(ui->slbSpindle->value()));
} else {
ui->grpSpindle->setTitle(tr("Spindle"));
}
}
// if (checked) {
// if (!ui->grpSpindle->isChecked()) ui->grpSpindle->setTitle(tr("Spindle") + QString(tr(" (%1)")).arg(ui->slbSpindle->value()));
// } else {
// ui->grpSpindle->setTitle(tr("Spindle"));
// }
// }

void frmMain::on_cmdSpindle_clicked(bool checked)
{
Expand Down Expand Up @@ -2931,7 +2952,7 @@ void frmMain::updateControlsState()
SenderState senderState = m_communicator->senderState();

ui->grpState->setEnabled(portOpened);
ui->grpControl->setEnabled(portOpened);
ui->control->setEnabled(portOpened);
ui->spindle->setEnabled(portOpened);
ui->jog->setEnabled(portOpened && ((senderState == SenderStopped)
|| (senderState == SenderChangingTool)));
Expand Down
2 changes: 1 addition & 1 deletion src/candle/frmmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private slots:
void on_cmdFilePause_clicked(bool checked);
void on_cmdFileAbort_clicked();
void on_cmdFileReset_clicked();
void on_cmdSpindle_toggled(bool checked);
// void on_cmdSpindle_toggled(bool checked);
void on_cmdSpindle_clicked(bool checked);
void on_cmdTop_clicked();
void on_cmdFront_clicked();
Expand Down
Loading

0 comments on commit 1670eb2

Please sign in to comment.