mirror of
https://github.com/leozide/leocad.git
synced 2026-07-27 19:56:49 +00:00
Move Image Dialog files.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
#include "lc_global.h"
|
||||
#include "lc_imagedialog.h"
|
||||
#include "ui_lc_imagedialog.h"
|
||||
#include "project.h"
|
||||
|
||||
lcImageDialog::lcImageDialog(QWidget* Parent, lcImageDialogOptions* Options)
|
||||
: QDialog(Parent), mOptions(Options), ui(new Ui::lcImageDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
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, tr("Error"), tr("Output File cannot be empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
int Width = ui->width->text().toInt();
|
||||
|
||||
if (Width < 1 || Width > 32768)
|
||||
{
|
||||
QMessageBox::information(this, tr("Error"), tr("Please enter a width between 1 and 32768."));
|
||||
return;
|
||||
}
|
||||
|
||||
int Height = ui->height->text().toInt();
|
||||
|
||||
if (Height < 1 || Height > 32768)
|
||||
{
|
||||
QMessageBox::information(this, tr("Error"), 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, tr("Error"), 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, tr("Error"), tr("Last step must be between 1 and %1.").arg(QString::number(mOptions->End)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (End < Start)
|
||||
{
|
||||
QMessageBox::information(this, tr("Error"), 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));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
namespace Ui {
|
||||
class lcImageDialog;
|
||||
}
|
||||
|
||||
struct lcImageDialogOptions;
|
||||
|
||||
class lcImageDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lcImageDialog(QWidget* Parent, lcImageDialogOptions* Options);
|
||||
virtual ~lcImageDialog();
|
||||
|
||||
public slots:
|
||||
void accept() override;
|
||||
|
||||
private slots:
|
||||
void FileNameBrowseClicked();
|
||||
|
||||
private:
|
||||
lcImageDialogOptions* mOptions;
|
||||
Ui::lcImageDialog* ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>lcImageDialog</class>
|
||||
<widget class="QDialog" name="lcImageDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>545</width>
|
||||
<height>180</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Save Image</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>File name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fileName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="fileName"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fileNameBrowse">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Dimensions</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>width</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="width">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Height:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>height</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="height">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Step Range</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rangeAll">
|
||||
<property name="text">
|
||||
<string>All Steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rangeCurrent">
|
||||
<property name="text">
|
||||
<string>Current Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rangeCustom">
|
||||
<property name="text">
|
||||
<string>Custom Range</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>From:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="firstStep">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>To:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lastStep">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>fileName</tabstop>
|
||||
<tabstop>fileNameBrowse</tabstop>
|
||||
<tabstop>width</tabstop>
|
||||
<tabstop>height</tabstop>
|
||||
<tabstop>rangeAll</tabstop>
|
||||
<tabstop>rangeCurrent</tabstop>
|
||||
<tabstop>rangeCustom</tabstop>
|
||||
<tabstop>firstStep</tabstop>
|
||||
<tabstop>lastStep</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>lcImageDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>222</x>
|
||||
<y>225</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>lcImageDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>290</x>
|
||||
<y>231</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>239</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "lc_htmldialog.h"
|
||||
#include "lc_renderdialog.h"
|
||||
#include "lc_instructionsdialog.h"
|
||||
#include "lc_qimagedialog.h"
|
||||
#include "lc_imagedialog.h"
|
||||
#include "lc_profile.h"
|
||||
#include "lc_view.h"
|
||||
#include "project.h"
|
||||
|
||||
Reference in New Issue
Block a user