mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
Explain array counts, offsets, rotations, image dimensions, file naming, and step ranges with translated tooltips and contextual help. Give both dialogs a standard Help button and dialog-scoped F1 support that falls back from the focused control through its parent groups to the overview. Link image field labels to their buddies and share tooltip and field help text. Add accessible names for unlabeled controls. Document the writing and maintenance conventions, with concise guidance in the existing AGENTS.md. Refresh all eight language catalogs while preserving existing translations and review status. The 62 new help and accessibility strings remain unfinished pending translation. Validation: Qt 6.10 debug build; runtime checks for seven F1 routes, Help, Escape, dialog state, spin-box focus, and five label buddies with matching help; visual layout inspection; catalog coverage for all 2,118 active source messages and existing translation preservation; git diff --check.
112 lines
2.9 KiB
C++
112 lines
2.9 KiB
C++
#include "lc_global.h"
|
|
#include "lc_imagedialog.h"
|
|
#include "ui_lc_imagedialog.h"
|
|
#include "project.h"
|
|
#include "lc_qutils.h"
|
|
|
|
lcImageDialog::lcImageDialog(QWidget* Parent, lcImageDialogOptions* Options)
|
|
: QDialog(Parent), mOptions(Options), ui(new Ui::lcImageDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
lcSetupDialogHelp(this, ui->buttonBox);
|
|
|
|
connect(ui->fileNameBrowse, &QPushButton::clicked, this, &lcImageDialog::FileNameBrowseClicked);
|
|
|
|
ui->width->setValidator(new QIntValidator(1, 32768, this));
|
|
ui->height->setValidator(new QIntValidator(1, 32768, this));
|
|
ui->firstStep->setValidator(new QIntValidator(this));
|
|
ui->lastStep->setValidator(new QIntValidator(this));
|
|
|
|
ui->fileName->setText(mOptions->FilePath);
|
|
ui->width->setText(QString::number(mOptions->Width));
|
|
ui->height->setText(QString::number(mOptions->Height));
|
|
ui->firstStep->setText(QString::number(mOptions->Start));
|
|
ui->lastStep->setText(QString::number(mOptions->End));
|
|
ui->rangeCurrent->setChecked(true);
|
|
}
|
|
|
|
lcImageDialog::~lcImageDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void lcImageDialog::accept()
|
|
{
|
|
QString FilePath = ui->fileName->text();
|
|
|
|
if (FilePath.isEmpty())
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("Output file cannot be empty."));
|
|
return;
|
|
}
|
|
|
|
int Width = ui->width->text().toInt();
|
|
|
|
if (Width < 1 || Width > 32768)
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("Please enter a width between 1 and 32768."));
|
|
return;
|
|
}
|
|
|
|
int Height = ui->height->text().toInt();
|
|
|
|
if (Height < 1 || Height > 32768)
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("Please enter a height between 1 and 32768."));
|
|
return;
|
|
}
|
|
|
|
int Start = mOptions->Start, End = mOptions->Start;
|
|
|
|
if (ui->rangeAll->isChecked())
|
|
{
|
|
Start = 1;
|
|
End = mOptions->End;
|
|
}
|
|
else if (ui->rangeCurrent->isChecked())
|
|
{
|
|
Start = mOptions->Start;
|
|
End = mOptions->Start;
|
|
}
|
|
else if (ui->rangeCustom->isChecked())
|
|
{
|
|
Start = ui->firstStep->text().toInt();
|
|
|
|
if (Start < 1 || Start > mOptions->End)
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("First step must be between 1 and %1.").arg(QString::number(mOptions->End)));
|
|
return;
|
|
}
|
|
|
|
End = ui->lastStep->text().toInt();
|
|
|
|
if (End < 1 || End > mOptions->End)
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("Last step must be between 1 and %1.").arg(QString::number(mOptions->End)));
|
|
return;
|
|
}
|
|
|
|
if (End < Start)
|
|
{
|
|
QMessageBox::information(this, windowTitle(), tr("Last step must be greater than first step."));
|
|
return;
|
|
}
|
|
}
|
|
|
|
mOptions->FilePath = FilePath;
|
|
mOptions->Width = Width;
|
|
mOptions->Height = Height;
|
|
mOptions->Start = Start;
|
|
mOptions->End = End;
|
|
|
|
QDialog::accept();
|
|
}
|
|
|
|
void lcImageDialog::FileNameBrowseClicked()
|
|
{
|
|
QString result = QFileDialog::getSaveFileName(this, tr("Save Image File"), ui->fileName->text(), tr("Supported Image Files (*.bmp *.png *.jpg);;BMP Files (*.bmp);;PNG Files (*.png);;JPEG Files (*.jpg);;All Files (*.*)"));
|
|
|
|
if (!result.isEmpty())
|
|
ui->fileName->setText(QDir::toNativeSeparators(result));
|
|
}
|