mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:33:24 +00:00
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>
This commit is contained in:
parent
ce8f621623
commit
f33f2812cf
1 changed files with 16 additions and 29 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue