summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-12 05:00:03 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-20 15:28:20 +0300
commitad531c25fbf4094f2cbfd54018fe74d710b547f1 (patch)
treea44f688d1a8e14891fea59595639d400e6c7499e
parentdcedc8ebea5a686f87d51daefa83728696d26b1a (diff)
downloadsubsurface-ad531c25fbf4094f2cbfd54018fe74d710b547f1.tar.gz
Printing: show colors in edit tab
- Add default color struct - Init the color struct with default colors - Show color text in labels - Preview colors Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--qt-ui/printdialog.cpp11
-rw-r--r--qt-ui/printoptions.h21
-rw-r--r--qt-ui/templateedit.cpp14
3 files changed, 44 insertions, 2 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 0a2c7898f..c999e8f25 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -12,8 +12,17 @@
#define SETTINGS_GROUP "PrintDialog"
+template_options::color_palette_struct almond_colors;
+
PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
{
+ // initialize const colors
+ almond_colors.color1 = QColor::fromRgb(243, 234, 207);
+ almond_colors.color2 = QColor::fromRgb(253, 204, 156);
+ almond_colors.color3 = QColor::fromRgb(136, 160, 150);
+ almond_colors.color4 = QColor::fromRgb(187, 171, 139);
+ almond_colors.color5 = QColor::fromRgb(239, 130, 117);
+
// check if the options were previously stored in the settings; if not use some defaults.
QSettings s;
bool stored = s.childGroups().contains(SETTINGS_GROUP);
@@ -41,6 +50,8 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
templateOptions.line_spacing = s.value("line_spacing").toDouble();
}
+ templateOptions.color_palette = almond_colors;
+
// create a print options object and pass our options struct
optionsWidget = new PrintOptions(this, &printOptions, &templateOptions);
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 3a5c2b179..92064d223 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -26,13 +26,30 @@ struct template_options {
int color_palette_index;
double font_size;
double line_spacing;
+ struct color_palette_struct {
+ QColor color1;
+ QColor color2;
+ QColor color3;
+ QColor color4;
+ QColor color5;
+ bool operator!=(const color_palette_struct &other) const {
+ return other.color1 != color1
+ || other.color2 != color2
+ || other.color3 != color3
+ || other.color4 != color4
+ || other.color5 != color5;
+ }
+ } color_palette;
bool operator!=(const template_options &other) const {
return other.font_index != font_index
|| other.color_palette_index != color_palette_index
|| other.font_size != font_size
- || other.line_spacing != line_spacing;
+ || other.line_spacing != line_spacing
+ || other.color_palette != color_palette;
}
-};
+ };
+
+extern template_options::color_palette_struct almond_colors;
// should be based on a custom QPrintDialog class
class PrintOptions : public QWidget {
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index 8d216d998..bb545392a 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -39,6 +39,7 @@ TemplateEdit::~TemplateEdit()
void TemplateEdit::updatePreview()
{
+ // update Qpixmap preview
int width = ui->label->width();
int height = ui->label->height();
QPixmap map(width * 2, height * 2);
@@ -46,6 +47,19 @@ void TemplateEdit::updatePreview()
Printer printer(&map, printOptions, &newTemplateOptions, Printer::PREVIEW);
printer.previewOnePage();
ui->label->setPixmap(map.scaled(width, height, Qt::IgnoreAspectRatio));
+
+ // update colors tab
+ ui->colorLable1->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color1.name() + "\";}");
+ ui->colorLable2->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color2.name() + "\";}");
+ ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}");
+ ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}");
+ ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}");
+
+ ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name());
+ ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name());
+ ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
+ ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
+ ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
}
void TemplateEdit::on_fontsize_valueChanged(int font_size)