aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-13 11:23:35 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-20 15:28:40 +0300
commitf8f645398857ca7cfb3c9496259e2ab638065642 (patch)
tree25a7bc9d525b32392c74a28e8c1bc87ea977f900 /qt-ui
parentc18e5ec795c309f4ca0993db86a6bf17f000270d (diff)
downloadsubsurface-f8f645398857ca7cfb3c9496259e2ab638065642.tar.gz
Printing: add custom color palette
We can use custom color palette to edit current color palette. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/templateedit.cpp24
-rw-r--r--qt-ui/templateedit.ui5
2 files changed, 29 insertions, 0 deletions
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index 3d84dd63b..ff1c1b7ea 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -71,6 +71,9 @@ void TemplateEdit::updatePreview()
ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
+
+ // update critical UI elements
+ ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index);
}
void TemplateEdit::on_fontsize_valueChanged(int font_size)
@@ -94,6 +97,14 @@ void TemplateEdit::on_fontSelection_currentIndexChanged(int index)
void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
{
newTemplateOptions.color_palette_index = index;
+ switch (newTemplateOptions.color_palette_index) {
+ case 0: // almond
+ newTemplateOptions.color_palette = almond_colors;
+ break;
+ case 1: // custom
+ newTemplateOptions.color_palette = custom_colors;
+ break;
+ }
updatePreview();
}
@@ -110,6 +121,9 @@ void TemplateEdit::saveSettings()
printOptions->p_template = print_options::CUSTOM;
TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
}
+ if (templateOptions->color_palette_index == 1) {
+ custom_colors = templateOptions->color_palette;
+ }
}
}
}
@@ -132,6 +146,15 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button)
void TemplateEdit::colorSelect(QAbstractButton *button)
{
+ // reset custom colors palette
+ switch (newTemplateOptions.color_palette_index) {
+ case 0: // almond
+ newTemplateOptions.color_palette = almond_colors;
+ custom_colors = newTemplateOptions.color_palette;
+ break;
+ }
+
+ //change selected color
QColor color;
switch (btnGroup->id(button)) {
case 1:
@@ -155,5 +178,6 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
newTemplateOptions.color_palette.color5 = color;
break;
}
+ newTemplateOptions.color_palette_index = 1;
updatePreview();
}
diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui
index 771fa90f8..4f9c9c2ed 100644
--- a/qt-ui/templateedit.ui
+++ b/qt-ui/templateedit.ui
@@ -132,6 +132,11 @@
<string>Almond</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </item>
</widget>
</item>
</layout>