diff options
-rw-r--r-- | qt-ui/templateedit.cpp | 39 | ||||
-rw-r--r-- | qt-ui/templateedit.h | 3 |
2 files changed, 42 insertions, 0 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index bb545392a..3d84dd63b 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -4,6 +4,7 @@ #include "ui_templateedit.h" #include <QMessageBox> +#include <QColorDialog> TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, struct template_options *templateOptions) : QDialog(parent), @@ -28,12 +29,22 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, grantlee_template = TemplateLayout::readTemplate("custom.html"); } + // gui + btnGroup = new QButtonGroup; + btnGroup->addButton(ui->editButton1, 1); + btnGroup->addButton(ui->editButton2, 2); + btnGroup->addButton(ui->editButton3, 3); + btnGroup->addButton(ui->editButton4, 4); + btnGroup->addButton(ui->editButton5, 5); + connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*))); + ui->plainTextEdit->setPlainText(grantlee_template); updatePreview(); } TemplateEdit::~TemplateEdit() { + delete btnGroup; delete ui; } @@ -118,3 +129,31 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button) break; } } + +void TemplateEdit::colorSelect(QAbstractButton *button) +{ + QColor color; + switch (btnGroup->id(button)) { + case 1: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this); + newTemplateOptions.color_palette.color1 = color; + break; + case 2: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this); + newTemplateOptions.color_palette.color2 = color; + break; + case 3: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this); + newTemplateOptions.color_palette.color3 = color; + break; + case 4: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this); + newTemplateOptions.color_palette.color4 = color; + break; + case 5: + color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this); + newTemplateOptions.color_palette.color5 = color; + break; + } + updatePreview(); +} diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h index 21cbc0321..15b717f78 100644 --- a/qt-ui/templateedit.h +++ b/qt-ui/templateedit.h @@ -26,8 +26,11 @@ private slots: void on_buttonBox_clicked(QAbstractButton *button); + void colorSelect(QAbstractButton *button); + private: Ui::TemplateEdit *ui; + QButtonGroup *btnGroup; struct template_options *templateOptions; struct template_options newTemplateOptions; struct print_options *printOptions; |