diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2016-11-01 15:13:27 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-11-01 09:39:58 -0700 |
commit | f33f2812cf062db63d8c3e85c231ec637debb6f6 (patch) | |
tree | b37778501ae7e70c6cc9977ff705398a05ef83ec /desktop-widgets/printdialog.cpp | |
parent | ce8f621623aeff34c9b0fbbe51415c3c35e2386e (diff) | |
download | subsurface-f33f2812cf062db63d8c3e85c231ec637debb6f6.tar.gz |
Use default values if value doesn't exist
By using the default value argument we can reduce
this code size to a half.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/printdialog.cpp')
-rw-r--r-- | desktop-widgets/printdialog.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/desktop-widgets/printdialog.cpp b/desktop-widgets/printdialog.cpp index 72e4d20c8..5fdc78198 100644 --- a/desktop-widgets/printdialog.cpp +++ b/desktop-widgets/printdialog.cpp @@ -41,35 +41,22 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : // check if the options were previously stored in the settings; if not use some defaults. QSettings s; - bool stored = s.childGroups().contains(SETTINGS_GROUP); - if (!stored) { - printOptions.print_selected = true; - printOptions.color_selected = true; - printOptions.landscape = false; - printOptions.p_template = "one_dive.html"; - printOptions.type = print_options::DIVELIST; - templateOptions.font_index = 0; - templateOptions.font_size = 9; - templateOptions.color_palette_index = SSRF_COLORS; - templateOptions.line_spacing = 1; - custom_colors = ssrf_colors; - } else { - s.beginGroup(SETTINGS_GROUP); - printOptions.type = (print_options::print_type)s.value("type").toInt(); - printOptions.print_selected = s.value("print_selected").toBool(); - printOptions.color_selected = s.value("color_selected").toBool(); - printOptions.landscape = s.value("landscape").toBool(); - printOptions.p_template = s.value("template_selected").toString(); - templateOptions.font_index = s.value("font").toInt(); - 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()); - } + s.beginGroup(SETTINGS_GROUP); + printOptions.type = (print_options::print_type)s.value("type", print_options::DIVELIST).toInt(); + printOptions.print_selected = s.value("print_selected", true).toBool(); + printOptions.color_selected = s.value("color_selected", true).toBool(); + printOptions.landscape = s.value("landscape", false).toBool(); + printOptions.p_template = s.value("template_selected", "one_dive.html").toString(); + templateOptions.font_index = s.value("font", 0).toInt(); + templateOptions.font_size = s.value("font_size", 9).toDouble(); + templateOptions.color_palette_index = s.value("color_palette", SSRF_COLORS).toInt(); + templateOptions.line_spacing = s.value("line_spacing", 1).toDouble(); + custom_colors.color1 = QColor(s.value("custom_color_1", ssrf_colors.color1).toString()); + custom_colors.color2 = QColor(s.value("custom_color_2", ssrf_colors.color2).toString()); + custom_colors.color3 = QColor(s.value("custom_color_3", ssrf_colors.color3).toString()); + custom_colors.color4 = QColor(s.value("custom_color_4", ssrf_colors.color4).toString()); + custom_colors.color5 = QColor(s.value("custom_color_5", ssrf_colors.color5).toString()); + s.endGroup(); // handle cases from old QSettings group if (templateOptions.font_size < 9) { |