leocad/common/lc_categorydialog.cpp

50 lines
974 B
C++
Raw Permalink Normal View History

2013-08-09 06:57:18 +02:00
#include "lc_global.h"
2023-05-16 06:12:08 +02:00
#include "lc_categorydialog.h"
#include "ui_lc_categorydialog.h"
2013-08-09 06:57:18 +02:00
#include "lc_category.h"
2023-05-16 06:02:17 +02:00
lcCategoryDialog::lcCategoryDialog(QWidget* Parent, lcLibraryCategory* Options)
: QDialog(Parent), ui(new Ui::lcCategoryDialog)
2013-08-09 06:57:18 +02:00
{
ui->setupUi(this);
2023-05-16 06:02:17 +02:00
mOptions = Options;
2013-08-09 06:57:18 +02:00
2023-05-16 06:02:17 +02:00
if (!mOptions->Name.isEmpty())
2013-08-09 06:57:18 +02:00
setWindowTitle(tr("Edit Category"));
else
setWindowTitle(tr("New Category"));
2023-05-16 06:02:17 +02:00
ui->name->setText(mOptions->Name);
ui->keywords->setText(mOptions->Keywords);
2013-08-09 06:57:18 +02:00
}
2023-05-16 06:02:17 +02:00
lcCategoryDialog::~lcCategoryDialog()
2013-08-09 06:57:18 +02:00
{
delete ui;
}
2023-05-16 06:02:17 +02:00
void lcCategoryDialog::accept()
2013-08-09 06:57:18 +02:00
{
2023-05-16 06:02:17 +02:00
QString Name = ui->name->text();
2013-08-09 06:57:18 +02:00
2023-05-16 06:02:17 +02:00
if (Name.isEmpty())
2013-08-09 06:57:18 +02:00
{
QMessageBox::information(this, "LeoCAD", tr("Name cannot be empty."));
return;
}
2023-05-16 06:02:17 +02:00
QString Keywords = ui->keywords->text();
2013-08-09 06:57:18 +02:00
2023-05-16 06:02:17 +02:00
if (Keywords.isEmpty())
2013-08-09 06:57:18 +02:00
{
QMessageBox::information(this, "LeoCAD", tr("Keywords cannot be empty."));
return;
}
2023-05-16 06:02:17 +02:00
mOptions->Name = Name;
mOptions->Keywords = Keywords.toLatin1();
2013-08-09 06:57:18 +02:00
QDialog::accept();
}