瀏覽代碼

A more general settings window. Fixes #97

Neal Wilson 11 年之前
父節點
當前提交
6c14c3f87d
共有 3 個文件被更改,包括 72 次插入6 次删除
  1. 1
    1
      config/Windows/navigation.xml
  2. 52
    0
      src/settings.w
  3. 19
    5
      src/typica.w

+ 1
- 1
config/Windows/navigation.xml 查看文件

@@ -172,7 +172,7 @@ type="push" />
172 172
         });
173 173
 		var configurebutton = findChildObject(this, 'configure');
174 174
 		configurebutton.clicked.connect(function() {
175
-			var confwindow = new DeviceConfigurationWindow;
175
+			var confwindow = new SettingsWindow;
176 176
 			confwindow.show();
177 177
 		});
178 178
         <![CDATA[

+ 52
- 0
src/settings.w 查看文件

@@ -0,0 +1,52 @@
1
+@** A window for program configuration.
2
+
3
+\noindent A previous version of Typica introduced a window specifically for
4
+configuring the measurement pipeline in Typica. This is a fairly limited subset
5
+of things that should be more easily configurable in Typica. Starting with
6
+version 1.6 that window has been converted into a widget that is available
7
+through a tab in a more general configuration window with other tabs available
8
+for settings that do not logically belong with a single part of the measurement
9
+pipeline.
10
+
11
+@<Class declarations@>=
12
+class SettingsWindow : public QMainWindow
13
+{
14
+	Q_OBJECT
15
+	public:
16
+		SettingsWindow();
17
+};
18
+
19
+@ The constructor takes care of the initial interface setup. Most of the
20
+functionality is delegated to more specialized widgets that are available
21
+through a set of tabs.
22
+
23
+@<SettingsWindow implementation@>=
24
+SettingsWindow::SettingsWindow() : QMainWindow(NULL)
25
+{
26
+	QTabWidget *settingsTab = new QTabWidget;
27
+	DeviceConfigurationWindow *deviceSettings = new DeviceConfigurationWindow;
28
+	settingsTab->addTab(deviceSettings, tr("Roasters"));
29
+	setCentralWidget(settingsTab);
30
+}
31
+
32
+@ This widget is made available to the host environment for access wherever
33
+appropriate.
34
+
35
+@<Function prototypes for scripting@>=
36
+QScriptValue constructSettingsWindow(QScriptContext *context, QScriptEngine *engine);
37
+
38
+@ The constructor is trivial.
39
+
40
+@<Functions for scripting@>=
41
+QScriptValue constructSettingsWindow(QScriptContext *, QScriptEngine *engine)
42
+{
43
+	QScriptValue object = engine->newQObject(new SettingsWindow);
44
+	return object;
45
+}
46
+
47
+@ The host environment is informed of this as usual.
48
+
49
+@<Set up the scripting engine@>=
50
+constructor = engine->newFunction(constructSettingsWindow);
51
+value = engine->newQMetaObject(&DeviceConfigurationWindow::staticMetaObject, constructor);
52
+engine->globalObject().setProperty("SettingsWindow", value);

+ 19
- 5
src/typica.w 查看文件

@@ -836,6 +836,7 @@ generated file empty.
836 836
 @<TranslationConfWidget implementation@>@/
837 837
 @<FreeAnnotationConfWidget implementation@>@/
838 838
 @<RateOfChange implementation@>@/
839
+@<SettingsWindow implementation@>@/
839 840
 
840 841
 @ A few headers are required for various parts of \pn{}. These allow the use of
841 842
 various Qt modules.
@@ -7653,7 +7654,8 @@ class GraphView : public QGraphicsView@/
7653 7654
 	QMap<int, QPointF> *prevPoints;
7654 7655
 	QMap<int, double> *translations;
7655 7656
 	QList<QGraphicsItem *> *gridLinesF;
7656
-	QList<QGraphicsItem *> *gridLinesC;@/
7657
+	QList<QGraphicsItem *> *gridLinesC;
7658
+	QList<QGraphicsItem *> *relativeGridLines;@/
7657 7659
 	public:@/
7658 7660
 		GraphView(QWidget *parent = NULL);
7659 7661
 		void removeSeries(int column);@/
@@ -7695,7 +7697,8 @@ GraphView::GraphView(QWidget *parent) : QGraphicsView(parent),
7695 7697
 	prevPoints(new QMap<int, QPointF>),
7696 7698
 	translations(new QMap<int, double>),
7697 7699
 	gridLinesF(new QList<QGraphicsItem *>),
7698
-	gridLinesC(new QList<QGraphicsItem *>)@/
7700
+	gridLinesC(new QList<QGraphicsItem *>),
7701
+	relativeGridLines(new QList<QGraphicsItem *>)@/
7699 7702
 {
7700 7703
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7701 7704
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -14763,8 +14766,12 @@ QList<NodeInserter *> topLevelNodeInserters;
14763 14766
 @ With this done, we can now produce a window which allows someone to easily
14764 14767
 edit the device configuration.
14765 14768
 
14769
+As of version 1.6 this class is no longer a window but just a |QWidget| which
14770
+is inserted into another more general settings window. The name of the class
14771
+should be changed in a future version to reflect this change.
14772
+
14766 14773
 @<Class declarations@>=
14767
-class DeviceConfigurationWindow : public QMainWindow
14774
+class DeviceConfigurationWindow : public QWidget
14768 14775
 {
14769 14776
 	@[Q_OBJECT@]@;
14770 14777
 	public:@/
@@ -14797,7 +14804,7 @@ this) is expanded to show the new child node if it has not already been
14797 14804
 expanded.
14798 14805
 
14799 14806
 @<DeviceConfigurationWindow implementation@>=
14800
-DeviceConfigurationWindow::DeviceConfigurationWindow() : QMainWindow(NULL),
14807
+DeviceConfigurationWindow::DeviceConfigurationWindow() : QWidget(NULL),
14801 14808
 	view(new QTreeView), configArea(new QScrollArea)
14802 14809
 {
14803 14810
 	QSplitter *splitter = new QSplitter;
@@ -14832,7 +14839,9 @@ DeviceConfigurationWindow::DeviceConfigurationWindow() : QMainWindow(NULL),
14832 14839
 	configArea->setMinimumWidth(580);
14833 14840
 	configArea->setMinimumHeight(460);
14834 14841
 	splitter->addWidget(configArea);
14835
-	setCentralWidget(splitter);
14842
+	QVBoxLayout *centralLayout = new QVBoxLayout;
14843
+	centralLayout->addWidget(splitter);
14844
+	setLayout(centralLayout);
14836 14845
 	connect(view, SIGNAL(activated(QModelIndex)),
14837 14846
 	        this, SLOT(newSelection(QModelIndex)));
14838 14847
 	connect(view, SIGNAL(clicked(QModelIndex)),
@@ -14899,6 +14908,9 @@ void DeviceConfigurationWindow::resizeColumn()
14899 14908
 instantiate this from the host environment. For this we at least require a
14900 14909
 constructor.
14901 14910
 
14911
+Now that this widget is available through a more general settings window it may
14912
+be better to remove direct access to this class from the host environment.
14913
+
14902 14914
 @<Function prototypes for scripting@>=
14903 14915
 QScriptValue constructDeviceConfigurationWindow(QScriptContext *context,
14904 14916
                                                 QScriptEngine *engine);
@@ -16817,6 +16829,8 @@ app.registerDeviceConfigurationWidget("annotationspinbox", NoteSpinConfWidget::s
16817 16829
 
16818 16830
 @i freeannotation.w
16819 16831
 
16832
+@i settings.w
16833
+
16820 16834
 @** Communicating with a Device through Modbus RTU.
16821 16835
 
16822 16836
 \noindent The classes described here need to be further generalized to support

Loading…
取消
儲存