diff options
Diffstat (limited to 'qt-ui/printdialog.cpp')
-rw-r--r-- | qt-ui/printdialog.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 9ff29e67b..31ec354c8 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, custom_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); @@ -27,6 +36,7 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f templateOptions.font_size = 9; templateOptions.color_palette_index = 0; templateOptions.line_spacing = 1; + custom_colors = almond_colors; } else { s.beginGroup(SETTINGS_GROUP); printOptions.type = (print_options::print_type)s.value("type").toInt(); @@ -39,13 +49,27 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f templateOptions.font_size = s.value("font_size").toDouble(); templateOptions.color_palette_index = s.value("color_palette").toInt(); templateOptions.line_spacing = s.value("line_spacing").toDouble(); + custom_colors.color1 = QColor(s.value("custom_color_1").toString()); + custom_colors.color2 = QColor(s.value("custom_color_2").toString()); + custom_colors.color3 = QColor(s.value("custom_color_3").toString()); + custom_colors.color4 = QColor(s.value("custom_color_4").toString()); + custom_colors.color5 = QColor(s.value("custom_color_5").toString()); + } + + switch (templateOptions.color_palette_index) { + case 0: // almond + templateOptions.color_palette = almond_colors; + break; + case 1: // custom + templateOptions.color_palette = custom_colors; + break; } // create a print options object and pass our options struct optionsWidget = new PrintOptions(this, &printOptions, &templateOptions); // create a new printer object - printer = new Printer(&qprinter, &printOptions, &templateOptions); + printer = new Printer(&qprinter, &printOptions, &templateOptions, Printer::PRINT); QVBoxLayout *layout = new QVBoxLayout(this); setLayout(layout); @@ -105,6 +129,13 @@ void PrintDialog::onFinished() s.setValue("font_size", templateOptions.font_size); s.setValue("color_palette", templateOptions.color_palette_index); s.setValue("line_spacing", templateOptions.line_spacing); + + // save custom colors + s.setValue("custom_color_1", custom_colors.color1.name()); + s.setValue("custom_color_2", custom_colors.color2.name()); + s.setValue("custom_color_3", custom_colors.color3.name()); + s.setValue("custom_color_4", custom_colors.color4.name()); + s.setValue("custom_color_5", custom_colors.color5.name()); } void PrintDialog::previewClicked(void) |