From e1dda8df636058734ff8ab79ade210c08339b978 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Sun, 12 Jul 2015 05:54:00 +0200 Subject: Printing: implement edit buttons in color tab Add button group and attached edit buttons to it. Signed-off-by: Gehad elrobey Signed-off-by: Lubomir I. Ivanov --- qt-ui/templateedit.cpp | 39 +++++++++++++++++++++++++++++++++++++++ qt-ui/templateedit.h | 3 +++ 2 files changed, 42 insertions(+) (limited to 'qt-ui') 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 +#include 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; -- cgit v1.2.3-70-g09d2