-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
322 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// Created by toky on 3/12/24. | ||
// | ||
|
||
#include "ParameterInputDialog.h" | ||
#include <QDialogButtonBox> | ||
#include <QFormLayout> | ||
#include <QLabel> | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include "commons/KiterRegistry.h" | ||
#include "generators/generators.h" | ||
|
||
ParameterInputDialog::ParameterInputDialog(const QString &generatorName, QWidget *parent) | ||
: QDialog(parent), generatorName(generatorName) | ||
{ | ||
setWindowTitle(tr("Parameters for %1").arg(generatorName)); | ||
layout = new QVBoxLayout(this); | ||
|
||
QLabel *infoLabel = new QLabel(tr("Enter parameters (name and value):"), this); | ||
layout->addWidget(infoLabel); | ||
|
||
formLayout = new QFormLayout; | ||
|
||
// Add an initial parameter row | ||
QLineEdit *paramNameEdit = new QLineEdit(this); | ||
QLineEdit *paramValueEdit = new QLineEdit(this); | ||
paramNameEdits.append(paramNameEdit); | ||
paramValueEdits.append(paramValueEdit); | ||
formLayout->addRow(paramNameEdit, paramValueEdit); | ||
|
||
layout->addLayout(formLayout); | ||
|
||
// Add "Add Parameter" button | ||
QPushButton *addParamButton = new QPushButton(tr("Add Parameter"), this); | ||
connect(addParamButton, &QPushButton::clicked, this, &ParameterInputDialog::onAddParameterClicked); | ||
layout->addWidget(addParamButton); | ||
|
||
// Add OK and Cancel buttons | ||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | ||
connect(buttonBox, &QDialogButtonBox::accepted, this, &ParameterInputDialog::accept); | ||
connect(buttonBox, &QDialogButtonBox::rejected, this, &ParameterInputDialog::reject); | ||
|
||
layout->addWidget(buttonBox); | ||
} | ||
|
||
void ParameterInputDialog::onAddParameterClicked() | ||
{ | ||
QLineEdit *paramNameEdit = new QLineEdit(this); | ||
QLineEdit *paramValueEdit = new QLineEdit(this); | ||
paramNameEdits.append(paramNameEdit); | ||
paramValueEdits.append(paramValueEdit); | ||
formLayout->addRow(paramNameEdit, paramValueEdit); | ||
} | ||
|
||
void ParameterInputDialog::accept() | ||
{ | ||
// Collect parameters | ||
for (int i = 0; i < paramNameEdits.size(); ++i) { | ||
QString paramName = paramNameEdits[i]->text(); | ||
QString paramValue = paramValueEdits[i]->text(); | ||
if (!paramName.isEmpty()) { | ||
parameters[paramName.toStdString()] = paramValue.toStdString(); | ||
} | ||
} | ||
|
||
QDialog::accept(); | ||
} | ||
|
||
parameters_list_t ParameterInputDialog::getParameters() const | ||
{ | ||
return parameters; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Created by toky on 3/12/24. | ||
// | ||
|
||
#ifndef KITER_PARAMETERINPUTDIALOG_H | ||
#define KITER_PARAMETERINPUTDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <QMap> | ||
#include <QLineEdit> | ||
#include <QVBoxLayout> | ||
#include <QFormLayout> | ||
#include "printers/printers.h" // For parameters_list_t | ||
|
||
class ParameterInputDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit ParameterInputDialog(const QString &generatorName, QWidget *parent = nullptr); | ||
parameters_list_t getParameters() const; | ||
|
||
private slots: | ||
void accept() override; | ||
void onAddParameterClicked(); | ||
|
||
private: | ||
QString generatorName; | ||
parameters_list_t parameters; | ||
QList<QLineEdit*> paramNameEdits; | ||
QList<QLineEdit*> paramValueEdits; | ||
QVBoxLayout *layout; | ||
QFormLayout *formLayout; | ||
}; | ||
|
||
#endif //KITER_PARAMETERINPUTDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters