Kaynağa Gözat

A more general settings window. Fixes #97

Neal Wilson 11 yıl önce
ebeveyn
işleme
6c14c3f87d
3 değiştirilmiş dosya ile 72 ekleme ve 6 silme
  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 Dosyayı Görüntüle

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

+ 52
- 0
src/settings.w Dosyayı Görüntüle

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 Dosyayı Görüntüle

836
 @<TranslationConfWidget implementation@>@/
836
 @<TranslationConfWidget implementation@>@/
837
 @<FreeAnnotationConfWidget implementation@>@/
837
 @<FreeAnnotationConfWidget implementation@>@/
838
 @<RateOfChange implementation@>@/
838
 @<RateOfChange implementation@>@/
839
+@<SettingsWindow implementation@>@/
839
 
840
 
840
 @ A few headers are required for various parts of \pn{}. These allow the use of
841
 @ A few headers are required for various parts of \pn{}. These allow the use of
841
 various Qt modules.
842
 various Qt modules.
7653
 	QMap<int, QPointF> *prevPoints;
7654
 	QMap<int, QPointF> *prevPoints;
7654
 	QMap<int, double> *translations;
7655
 	QMap<int, double> *translations;
7655
 	QList<QGraphicsItem *> *gridLinesF;
7656
 	QList<QGraphicsItem *> *gridLinesF;
7656
-	QList<QGraphicsItem *> *gridLinesC;@/
7657
+	QList<QGraphicsItem *> *gridLinesC;
7658
+	QList<QGraphicsItem *> *relativeGridLines;@/
7657
 	public:@/
7659
 	public:@/
7658
 		GraphView(QWidget *parent = NULL);
7660
 		GraphView(QWidget *parent = NULL);
7659
 		void removeSeries(int column);@/
7661
 		void removeSeries(int column);@/
7695
 	prevPoints(new QMap<int, QPointF>),
7697
 	prevPoints(new QMap<int, QPointF>),
7696
 	translations(new QMap<int, double>),
7698
 	translations(new QMap<int, double>),
7697
 	gridLinesF(new QList<QGraphicsItem *>),
7699
 	gridLinesF(new QList<QGraphicsItem *>),
7698
-	gridLinesC(new QList<QGraphicsItem *>)@/
7700
+	gridLinesC(new QList<QGraphicsItem *>),
7701
+	relativeGridLines(new QList<QGraphicsItem *>)@/
7699
 {
7702
 {
7700
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7703
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7701
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
7704
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
14763
 @ With this done, we can now produce a window which allows someone to easily
14766
 @ With this done, we can now produce a window which allows someone to easily
14764
 edit the device configuration.
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
 @<Class declarations@>=
14773
 @<Class declarations@>=
14767
-class DeviceConfigurationWindow : public QMainWindow
14774
+class DeviceConfigurationWindow : public QWidget
14768
 {
14775
 {
14769
 	@[Q_OBJECT@]@;
14776
 	@[Q_OBJECT@]@;
14770
 	public:@/
14777
 	public:@/
14797
 expanded.
14804
 expanded.
14798
 
14805
 
14799
 @<DeviceConfigurationWindow implementation@>=
14806
 @<DeviceConfigurationWindow implementation@>=
14800
-DeviceConfigurationWindow::DeviceConfigurationWindow() : QMainWindow(NULL),
14807
+DeviceConfigurationWindow::DeviceConfigurationWindow() : QWidget(NULL),
14801
 	view(new QTreeView), configArea(new QScrollArea)
14808
 	view(new QTreeView), configArea(new QScrollArea)
14802
 {
14809
 {
14803
 	QSplitter *splitter = new QSplitter;
14810
 	QSplitter *splitter = new QSplitter;
14832
 	configArea->setMinimumWidth(580);
14839
 	configArea->setMinimumWidth(580);
14833
 	configArea->setMinimumHeight(460);
14840
 	configArea->setMinimumHeight(460);
14834
 	splitter->addWidget(configArea);
14841
 	splitter->addWidget(configArea);
14835
-	setCentralWidget(splitter);
14842
+	QVBoxLayout *centralLayout = new QVBoxLayout;
14843
+	centralLayout->addWidget(splitter);
14844
+	setLayout(centralLayout);
14836
 	connect(view, SIGNAL(activated(QModelIndex)),
14845
 	connect(view, SIGNAL(activated(QModelIndex)),
14837
 	        this, SLOT(newSelection(QModelIndex)));
14846
 	        this, SLOT(newSelection(QModelIndex)));
14838
 	connect(view, SIGNAL(clicked(QModelIndex)),
14847
 	connect(view, SIGNAL(clicked(QModelIndex)),
14899
 instantiate this from the host environment. For this we at least require a
14908
 instantiate this from the host environment. For this we at least require a
14900
 constructor.
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
 @<Function prototypes for scripting@>=
14914
 @<Function prototypes for scripting@>=
14903
 QScriptValue constructDeviceConfigurationWindow(QScriptContext *context,
14915
 QScriptValue constructDeviceConfigurationWindow(QScriptContext *context,
14904
                                                 QScriptEngine *engine);
14916
                                                 QScriptEngine *engine);
16817
 
16829
 
16818
 @i freeannotation.w
16830
 @i freeannotation.w
16819
 
16831
 
16832
+@i settings.w
16833
+
16820
 @** Communicating with a Device through Modbus RTU.
16834
 @** Communicating with a Device through Modbus RTU.
16821
 
16835
 
16822
 \noindent The classes described here need to be further generalized to support
16836
 \noindent The classes described here need to be further generalized to support

Loading…
İptal
Kaydet