|
@@ -0,0 +1,162 @@
|
|
1
|
+@* Graph widget configuration.
|
|
2
|
+
|
|
3
|
+\noindent There are many features of the graph in Typica which ought to be
|
|
4
|
+configurable. Most of these cannot be configured until changes are made to the
|
|
5
|
+graph widget. The original motivation for the class comes from a need to
|
|
6
|
+configure secondary axes.
|
|
7
|
+
|
|
8
|
+@<Class declarations@>=
|
|
9
|
+class GraphSettingsWidget : public QWidget
|
|
10
|
+{
|
|
11
|
+ Q_OBJECT
|
|
12
|
+ public:
|
|
13
|
+ GraphSettingsWidget();
|
|
14
|
+};
|
|
15
|
+
|
|
16
|
+@ At present there are three types of data that the graph might present. This
|
|
17
|
+will likely be expanded as support for additional unit types are added.
|
|
18
|
+
|
|
19
|
+Different measurement categories are presently organized into different tabs.
|
|
20
|
+This will potentially need to change later as more features are added and the
|
|
21
|
+tab set becomes excessively large but for now this is the best that I can
|
|
22
|
+think of. If anybody with UI design experience would like to propose something
|
|
23
|
+better I would be glad to consider it.
|
|
24
|
+
|
|
25
|
+@<GraphSettingsWidget implementation@>=
|
|
26
|
+GraphSettingsWidget::GraphSettingsWidget() : QWidget(NULL)
|
|
27
|
+{
|
|
28
|
+ QTabWidget *graphCategories = new QTabWidget;
|
|
29
|
+ GraphSettingsRelativeTab *relative = new GraphSettingsRelativeTab;
|
|
30
|
+ graphCategories->addTab(relative, tr("Relative Temperatures"));
|
|
31
|
+ QVBoxLayout *layout = new QVBoxLayout;
|
|
32
|
+ layout->addWidget(graphCategories);
|
|
33
|
+ setLayout(layout);
|
|
34
|
+}
|
|
35
|
+
|
|
36
|
+@ Relative temperature measurements are different from the absolute temperature
|
|
37
|
+measurements that fall on the primary axis in that it is likely that negative
|
|
38
|
+values will be presented. These may be important and should not be hidden off
|
|
39
|
+the bottom of the graph, but the most important values will be in a relatively
|
|
40
|
+small range of positive values. The particulars will depend on the settings
|
|
41
|
+used to construct the relative values and the style of coffee roasting. It is
|
|
42
|
+also possible to disable the graphing of relative temperature measurements.
|
|
43
|
+
|
|
44
|
+@<Class declarations@>=
|
|
45
|
+class GraphSettingsRelativeTab : public QWidget
|
|
46
|
+{
|
|
47
|
+ Q_OBJECT
|
|
48
|
+ public:
|
|
49
|
+ GraphSettingsRelativeTab();
|
|
50
|
+ public slots:
|
|
51
|
+ void updateEnableSetting(bool enable);
|
|
52
|
+ void updateColorSetting(const QString &color);
|
|
53
|
+ void updateAxisSetting(const QString &gridList);
|
|
54
|
+ void updateUnit(int unit);
|
|
55
|
+ void showColorPicker();
|
|
56
|
+ private:
|
|
57
|
+ QLineEdit *colorEdit;
|
|
58
|
+};
|
|
59
|
+
|
|
60
|
+@ The constructor sets up the interface and restores any previous values from
|
|
61
|
+settings.
|
|
62
|
+
|
|
63
|
+@<GraphSettingsWidget implementation@>=
|
|
64
|
+GraphSettingsRelativeTab::GraphSettingsRelativeTab() : QWidget(NULL),
|
|
65
|
+ colorEdit(new QLineEdit)
|
|
66
|
+{
|
|
67
|
+ QSettings settings;
|
|
68
|
+ QVBoxLayout *layout = new QVBoxLayout;
|
|
69
|
+ QCheckBox *enable = new QCheckBox(tr("Graph relative temperatures"));
|
|
70
|
+ enable->setChecked(settings.value("settings/graph/relative/enable", true).toBool());
|
|
71
|
+ updateEnableSetting(enable->isChecked());
|
|
72
|
+ connect(enable, SIGNAL(toggled(bool)), this, SLOT(updateEnableSetting(bool)));
|
|
73
|
+ layout->addWidget(enable);
|
|
74
|
+ QHBoxLayout *colorLayout = new QHBoxLayout;
|
|
75
|
+ QLabel *colorLabel = new QLabel(tr("Axis color:"));
|
|
76
|
+ colorEdit->setText(settings.value("settings/graph/relative/color", "#000000").toString());
|
|
77
|
+ updateColorSetting(colorEdit->text());
|
|
78
|
+ connect(colorEdit, SIGNAL(textChanged(QString)), this, SLOT(updateColorSetting(QString)));
|
|
79
|
+ QToolButton *colorPickerButton = new QToolButton();
|
|
80
|
+ colorPickerButton->setIcon(QIcon::fromTheme("applications-graphics"));
|
|
81
|
+ connect(colorPickerButton, SIGNAL(clicked()), this, SLOT(showColorPicker()));
|
|
82
|
+ colorLayout->addWidget(colorLabel);
|
|
83
|
+ colorLayout->addWidget(colorEdit);
|
|
84
|
+ colorLayout->addWidget(colorPickerButton);
|
|
85
|
+ colorLayout->addStretch();
|
|
86
|
+ layout->addLayout(colorLayout);
|
|
87
|
+ QHBoxLayout *unitLayout = new QHBoxLayout;
|
|
88
|
+ QLabel *unitLabel = new QLabel(tr("Unit"));
|
|
89
|
+ QComboBox *unitSelector = new QComboBox;
|
|
90
|
+ unitSelector->addItem(tr("Fahrenheit"));
|
|
91
|
+ unitSelector->addItem(tr("Celsius"));
|
|
92
|
+ unitSelector->setCurrentIndex(settings.value("settings/graph/relative/unit", 0).toInt());
|
|
93
|
+ updateUnit(unitSelector->currentIndex());
|
|
94
|
+ connect(unitSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUnit(int)));
|
|
95
|
+ unitLayout->addWidget(unitLabel);
|
|
96
|
+ unitLayout->addWidget(unitSelector);
|
|
97
|
+ unitLayout->addStretch();
|
|
98
|
+ layout->addLayout(unitLayout);
|
|
99
|
+ QHBoxLayout *axisLayout = new QHBoxLayout;
|
|
100
|
+ QLabel *axisLabel = new QLabel(tr("Grid line positions (comma separated):"));
|
|
101
|
+ QLineEdit *axisEdit = new QLineEdit;
|
|
102
|
+ axisEdit->setText(settings.value("settings/graph/relative/grid", "-300, -100, -10, 0, 10, 30, 50").toString());
|
|
103
|
+ updateAxisSetting(axisEdit->text());
|
|
104
|
+ connect(axisEdit, SIGNAL(textChanged(QString)), this, SLOT(updateAxisSetting(QString)));
|
|
105
|
+ axisLayout->addWidget(axisLabel);
|
|
106
|
+ axisLayout->addWidget(axisEdit);
|
|
107
|
+ layout->addLayout(axisLayout);
|
|
108
|
+ layout->addStretch();
|
|
109
|
+ setLayout(layout);
|
|
110
|
+}
|
|
111
|
+
|
|
112
|
+@ A set of methods updates the settings as they are adjusted.
|
|
113
|
+
|
|
114
|
+@<GraphSettingsWidget implementation@>=
|
|
115
|
+void GraphSettingsRelativeTab::updateEnableSetting(bool enabled)
|
|
116
|
+{
|
|
117
|
+ QSettings settings;
|
|
118
|
+ settings.setValue("settings/graph/relative/enable", enabled);
|
|
119
|
+}
|
|
120
|
+
|
|
121
|
+void GraphSettingsRelativeTab::updateColorSetting(const QString &color)
|
|
122
|
+{
|
|
123
|
+ QSettings settings;
|
|
124
|
+ settings.setValue("settings/graph/relative/color", color);
|
|
125
|
+}
|
|
126
|
+
|
|
127
|
+void GraphSettingsRelativeTab::updateAxisSetting(const QString &gridList)
|
|
128
|
+{
|
|
129
|
+ QSettings settings;
|
|
130
|
+ QString settingValue;
|
|
131
|
+ QStringList points = gridList.split(QRegExp("[\\s,]+"), QString::SkipEmptyParts);
|
|
132
|
+ QStringList numbers;
|
|
133
|
+ foreach(QString text, points)
|
|
134
|
+ {
|
|
135
|
+ bool okay = false;
|
|
136
|
+ text.toDouble(&okay);
|
|
137
|
+ if(okay)
|
|
138
|
+ {
|
|
139
|
+ numbers.append(text);
|
|
140
|
+ }
|
|
141
|
+ }
|
|
142
|
+ numbers.removeDuplicates();
|
|
143
|
+ settings.setValue("settings/graph/relative/grid", numbers.join(","));
|
|
144
|
+}
|
|
145
|
+
|
|
146
|
+void GraphSettingsRelativeTab::updateUnit(int unit)
|
|
147
|
+{
|
|
148
|
+ QSettings settings;
|
|
149
|
+ settings.setValue("settings/graph/relative/unit", unit);
|
|
150
|
+}
|
|
151
|
+
|
|
152
|
+@ When selecting a color, it is possible to either type the color into the line
|
|
153
|
+edit directly or use a color picker to select the color graphically. A tool
|
|
154
|
+button displays a color picker and pushes the selected color into the line edit
|
|
155
|
+which in turn updates the setting.
|
|
156
|
+
|
|
157
|
+@<GraphSettingsWidget implementation@>=
|
|
158
|
+void GraphSettingsRelativeTab::showColorPicker()
|
|
159
|
+{
|
|
160
|
+ QColor color = QColorDialog::getColor(QColor(colorEdit->text()), this);
|
|
161
|
+ colorEdit->setText(color.name());
|
|
162
|
+}
|