1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#include "printoptions.h"
#include "ui_printoptions.h"
#include "../display.h"
PrintOptions::PrintOptions(QWidget *parent, struct options *printOpt)
: ui( new Ui::PrintOptions())
{
hasSetupSlots = false;
ui->setupUi(this);
if (parent)
setParent(parent);
if (!printOpt)
return;
setup(printOpt);
}
void PrintOptions::setup(struct options *printOpt)
{
printOptions = printOpt;
// layout height sliders
initSliderWithLabel(ui->sliderPHeight, ui->valuePHeight, printOptions->profile_height);
initSliderWithLabel(ui->sliderOHeight, ui->valueOHeight, printOptions->notes_height);
initSliderWithLabel(ui->sliderNHeight, ui->valueNHeight, printOptions->tanks_height);
// print type radio buttons
switch (printOptions->type) {
case options::PRETTY:
ui->radioSixDives->setChecked(true);
break;
case options::TWOPERPAGE:
ui->radioTwoDives->setChecked(true);
break;
case options::TABLE:
ui->radioTablePrint->setChecked(true);
break;
}
// general print option checkboxes
if (printOptions->color_selected)
ui->printInColor->setChecked(true);
if (printOptions->print_selected)
ui->printSelected->setChecked(true);
// ordering
if (printOptions->notes_up)
ui->notesOnTop->setChecked(true);
else
ui->profileOnTop->setChecked(true);
// connect slots only once
if (hasSetupSlots)
return;
connect(ui->sliderPHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderPHeightMoved(int)));
connect(ui->sliderOHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderOHeightMoved(int)));
connect(ui->sliderNHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderNHeightMoved(int)));
connect(ui->radioSixDives, SIGNAL(clicked(bool)), this, SLOT(radioSixDivesClicked(bool)));
connect(ui->radioTwoDives, SIGNAL(clicked(bool)), this, SLOT(radioTwoDivesClicked(bool)));
connect(ui->radioTablePrint, SIGNAL(clicked(bool)), this, SLOT(radioTablePrintClicked(bool)));
connect(ui->printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
connect(ui->printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
connect(ui->notesOnTop, SIGNAL(clicked(bool)), this, SLOT(notesOnTopClicked(bool)));
connect(ui->profileOnTop, SIGNAL(clicked(bool)), this, SLOT(profileOnTopClicked(bool)));
hasSetupSlots = true;
}
// layout height sliders
void PrintOptions::initSliderWithLabel(QSlider *slider, QLabel *label, int value)
{
slider->setValue(value);
label->setText(formatSliderValueText(value));
}
QString PrintOptions::formatSliderValueText(int value)
{
QString str = QString("%1%").arg(QString::number(value));
return str;
}
void PrintOptions::sliderPHeightMoved(int value)
{
ui->valuePHeight->setText(formatSliderValueText(value));
printOptions->profile_height = value;
}
void PrintOptions::sliderOHeightMoved(int value)
{
ui->valueOHeight->setText(formatSliderValueText(value));
printOptions->notes_height = value;
}
void PrintOptions::sliderNHeightMoved(int value)
{
ui->valueNHeight->setText(formatSliderValueText(value));
printOptions->tanks_height = value;
}
// print type radio buttons
void PrintOptions::radioSixDivesClicked(bool check)
{
printOptions->type = options::PRETTY;
}
void PrintOptions::radioTwoDivesClicked(bool check)
{
printOptions->type = options::TWOPERPAGE;
}
void PrintOptions::radioTablePrintClicked(bool check)
{
printOptions->type = options::TABLE;
}
// general print option checkboxes
void PrintOptions::printInColorClicked(bool check)
{
printOptions->color_selected = (int)check;
}
void PrintOptions::printSelectedClicked(bool check)
{
printOptions->print_selected = (int)check;
}
// ordering
void PrintOptions::notesOnTopClicked(bool check)
{
printOptions->notes_up = true;
}
void PrintOptions::profileOnTopClicked(bool check)
{
printOptions->notes_up = false;
}
|