Printing: add another color in color palettes

Add another color 'Table cells 2' to the color palette, make all the
backgrounds solid white by default.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
Gehad elrobey 2015-08-07 09:54:09 +02:00 committed by Lubomir I. Ivanov
parent 1a2f154cf4
commit 1dbe10fe27
5 changed files with 80 additions and 25 deletions

View file

@ -17,21 +17,24 @@ template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_co
PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
{ {
// initialize const colors // initialize const colors
ssrf_colors.color1 = QColor::fromRgb(0xef, 0xf7, 0xff); ssrf_colors.color1 = QColor::fromRgb(0xff, 0xff, 0xff);
ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7); ssrf_colors.color2 = QColor::fromRgb(0xef, 0xf7, 0xff);
ssrf_colors.color3 = QColor::fromRgb(0x34, 0x65, 0xa4); ssrf_colors.color3 = QColor::fromRgb(0xa6, 0xbc, 0xd7);
ssrf_colors.color4 = QColor::fromRgb(0x20, 0x4a, 0x87); ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4);
ssrf_colors.color5 = QColor::fromRgb(0x17, 0x37, 0x64); ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87);
almond_colors.color1 = QColor::fromRgb(243, 234, 207); ssrf_colors.color6 = QColor::fromRgb(0x17, 0x37, 0x64);
almond_colors.color2 = QColor::fromRgb(253, 204, 156); almond_colors.color1 = QColor::fromRgb(255, 255, 255);
almond_colors.color3 = QColor::fromRgb(136, 160, 150); almond_colors.color2 = QColor::fromRgb(243, 234, 207);
almond_colors.color4 = QColor::fromRgb(187, 171, 139); almond_colors.color3 = QColor::fromRgb(253, 204, 156);
almond_colors.color5 = QColor::fromRgb(239, 130, 117); almond_colors.color4 = QColor::fromRgb(136, 160, 150);
blueshades_colors.color1 = QColor::fromRgb(182, 192, 206); almond_colors.color5 = QColor::fromRgb(187, 171, 139);
blueshades_colors.color2 = QColor::fromRgb(142, 152, 166); almond_colors.color6 = QColor::fromRgb(239, 130, 117);
blueshades_colors.color3 = QColor::fromRgb(31, 49, 75); blueshades_colors.color1 = QColor::fromRgb(255, 255, 255);
blueshades_colors.color4 = QColor::fromRgb(21, 45, 84); blueshades_colors.color2 = QColor::fromRgb(182, 192, 206);
blueshades_colors.color5 = QColor::fromRgb(5, 25, 56); blueshades_colors.color3 = QColor::fromRgb(142, 152, 166);
blueshades_colors.color4 = QColor::fromRgb(31, 49, 75);
blueshades_colors.color5 = QColor::fromRgb(21, 45, 84);
blueshades_colors.color6 = QColor::fromRgb(5, 25, 56);
// check if the options were previously stored in the settings; if not use some defaults. // check if the options were previously stored in the settings; if not use some defaults.
QSettings s; QSettings s;

View file

@ -27,12 +27,14 @@ struct template_options {
QColor color3; QColor color3;
QColor color4; QColor color4;
QColor color5; QColor color5;
QColor color6;
bool operator!=(const color_palette_struct &other) const { bool operator!=(const color_palette_struct &other) const {
return other.color1 != color1 return other.color1 != color1
|| other.color2 != color2 || other.color2 != color2
|| other.color3 != color3 || other.color3 != color3
|| other.color4 != color4 || other.color4 != color4
|| other.color5 != color5; || other.color5 != color5
|| other.color6 != color6;
} }
} color_palette; } color_palette;
bool operator!=(const template_options &other) const { bool operator!=(const template_options &other) const {

View file

@ -30,6 +30,7 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
btnGroup->addButton(ui->editButton3, 3); btnGroup->addButton(ui->editButton3, 3);
btnGroup->addButton(ui->editButton4, 4); btnGroup->addButton(ui->editButton4, 4);
btnGroup->addButton(ui->editButton5, 5); btnGroup->addButton(ui->editButton5, 5);
btnGroup->addButton(ui->editButton6, 6);
connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*))); connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*)));
ui->plainTextEdit->setPlainText(grantlee_template); ui->plainTextEdit->setPlainText(grantlee_template);
@ -60,12 +61,14 @@ void TemplateEdit::updatePreview()
ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}"); ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}");
ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}"); ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}");
ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}"); ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}");
ui->colorLable6->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color6.name() + "\";}");
ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name()); ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name());
ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name()); ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name());
ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name()); ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name()); ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name()); ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
ui->colorLable6->setText(newTemplateOptions.color_palette.color6.name());
// update critical UI elements // update critical UI elements
ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index); ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index);
@ -197,6 +200,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
if (color.isValid()) { if (color.isValid()) {
newTemplateOptions.color_palette.color5 = color; newTemplateOptions.color_palette.color5 = color;
} break; } break;
case 6:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color6, this);
if (color.isValid()) {
newTemplateOptions.color_palette.color6 = color;
} break;
} }
newTemplateOptions.color_palette_index = CUSTOM; newTemplateOptions.color_palette_index = CUSTOM;
updatePreview(); updatePreview();

View file

@ -347,9 +347,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_6">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -357,7 +357,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Text 1</string> <string>Table cells 2</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -387,9 +387,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_7">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -397,7 +397,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Text 2</string> <string>Text 1</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -427,9 +427,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_11">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -437,7 +437,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Borders</string> <string>Text 2</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -466,6 +466,46 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Borders</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="colorLable6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>color6</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton6">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">

View file

@ -165,6 +165,8 @@ if (property == "font") {
return object.color_palette.color4.name(); return object.color_palette.color4.name();
} else if (property == "color5") { } else if (property == "color5") {
return object.color_palette.color5.name(); return object.color_palette.color5.name();
} else if (property == "color6") {
return object.color_palette.color6.name();
} }
GRANTLEE_END_LOOKUP GRANTLEE_END_LOOKUP