Selaa lähdekoodia

Use splitter in new batch window to allow optional feature hiding

Neal Wilson 7 vuotta sitten
vanhempi
commit
e031c63753
2 muutettua tiedostoa jossa 114 lisäystä ja 85 poistoa
  1. 101
    85
      config/Windows/newbatch.xml
  2. 13
    0
      src/typica.w

+ 101
- 85
config/Windows/newbatch.xml Näytä tiedosto

@@ -6,94 +6,110 @@
6 6
         <item id="new" shortcut="Ctrl+N">New Batch...</item>
7 7
     </menu>
8 8
     <layout type="horizontal">
9
-        <layout type="vertical">
10
-            <layout type="horizontal">
11
-                <label>Machine:</label>
12
-                <line id="machine" writable="false" />
13
-                <label>Unit:</label>
14
-                <sqldrop id="unit" />
15
-                <stretch />
16
-            </layout>
17
-            <layout type="horizontal">
18
-                <label>Roasted Coffee:</label>
19
-                <sqldrop data="0" display="1" showdata="true" id="roasted">
20
-                    <null />
21
-                    <query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
22
-                </sqldrop>
23
-                <stretch />
24
-            </layout>
25
-            <label>Green Coffee:</label>
26
-            <sqltablearray columns="3" id="greens">
27
-                <column name="Coffee" delegate="sql" showdata="true" null="true" nulltext="Delete" nulldata="delete" data="0" display="1">SELECT id, name FROM coffees WHERE quantity &lt;&gt; 0 ORDER BY name</column>
28
-                <column name="Weight" delegate="numeric" />
29
-                <column name="Remaining" />
30
-            </sqltablearray>
31
-            <layout type="horizontal">
32
-                <label>Green Weight:</label>
33
-                <line id="green" writable="false">0.0</line>
34
-            </layout>
35
-            <layout type="horizontal">
36
-                <button name="Load Profile" type="push" id="load" />
37
-                <button name="No Profile" type="push" id="noprofile" />
38
-            </layout>
39
-            <layout type="horizontal">
40
-                <label>Time:</label>
41
-                <line id="time" writable="false" />
42
-                <label>Duration:</label>
43
-                <line id="duration" writable="false" />
44
-            </layout>
45
-            <layout type="horizontal">
46
-                <label>Roasted Weight:</label>
47
-                <line id="roast" validator="numeric">0.0</line>
48
-                <label>Weight Loss:</label>
49
-                <line id="wloss" writable="false" />
50
-                <button type="check" id="approval" name="Approved" />
51
-            </layout>
52
-            <layout type="horizontal">
53
-                <label>Annotation:</label>
54
-                <textarea id="annotation" />
55
-            </layout>
56
-            <layout type="horizontal">
57
-                <button name="Submit" id="submit" type="push" />
58
-                <button name="Save log as target profile" type="check" id="target" />
59
-            </layout>
60
-        </layout>
61
-        <layout type="vertical">
62
-            <label>Connected Scales</label>
63
-            <layout type="vertical" id="scales" />
64
-            <label>Expected Weight Loss</label>
65
-            <line id="lossspec" writable="false" />
66
-            <label>Expected Roasted Weight</label>
67
-            <layout type="horizontal">
68
-                <label>Min:</label>
69
-                <line id="minroastweight" writable="false" />
70
-            </layout>
71
-            <layout type="horizontal">
72
-                <label>Expected:</label>
73
-                <line id="expectedroastweight" writable="false" />
74
-            </layout>
75
-            <layout type="horizontal">
76
-                <label>Max:</label>
77
-                <line id="maxroastweight" writable="false" />
78
-            </layout>
79
-            <label>Specification Details</label>
80
-            <textarea id="specnotes" />
81
-            <layout type="horizontal">
82
-                <label>File ID:</label>
83
-                <line id="filenofield" writable="false" />
84
-            </layout>
85
-            <stretch />
86
-        </layout>
87
-		<layout type="vertical">
88
-			<webview id="batchTag" />
89
-			<layout type="horizontal">
90
-				<printerselector id="printerlist" />
91
-				<button name="Print" id="printbutton" type="push" />
92
-			</layout>
93
-		</layout>
9
+        <splitter type="horizontal" id="splitter">
10
+            <widget id="required">
11
+                <layout type="vertical">
12
+                    <layout type="horizontal">
13
+                        <label>Machine:</label>
14
+                        <line id="machine" writable="false" />
15
+                        <label>Unit:</label>
16
+                        <sqldrop id="unit" />
17
+                        <stretch />
18
+                    </layout>
19
+                    <layout type="horizontal">
20
+                        <label>Roasted Coffee:</label>
21
+                        <sqldrop data="0" display="1" showdata="true" id="roasted">
22
+                            <null />
23
+                            <query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
24
+                        </sqldrop>
25
+                        <stretch />
26
+                    </layout>
27
+                    <label>Green Coffee:</label>
28
+                    <sqltablearray columns="3" id="greens">
29
+                        <column name="Coffee" delegate="sql" showdata="true" null="true" nulltext="Delete" nulldata="delete" data="0" display="1">SELECT id, name FROM coffees WHERE quantity &lt;&gt; 0 ORDER BY name</column>
30
+                        <column name="Weight" delegate="numeric" />
31
+                        <column name="Remaining" />
32
+                    </sqltablearray>
33
+                    <layout type="horizontal">
34
+                        <label>Green Weight:</label>
35
+                        <line id="green" writable="false">0.0</line>
36
+                    </layout>
37
+                    <layout type="horizontal">
38
+                        <button name="Load Profile" type="push" id="load" />
39
+                        <button name="No Profile" type="push" id="noprofile" />
40
+                    </layout>
41
+                    <layout type="horizontal">
42
+                        <label>Time:</label>
43
+                        <line id="time" writable="false" />
44
+                        <label>Duration:</label>
45
+                        <line id="duration" writable="false" />
46
+                    </layout>
47
+                    <layout type="horizontal">
48
+                        <label>Roasted Weight:</label>
49
+                        <line id="roast" validator="numeric">0.0</line>
50
+                        <label>Weight Loss:</label>
51
+                        <line id="wloss" writable="false" />
52
+                        <button type="check" id="approval" name="Approved" />
53
+                        <stretch />
54
+                    </layout>
55
+                    <layout type="horizontal">
56
+                        <label>Annotation:</label>
57
+                        <textarea id="annotation" />
58
+                    </layout>
59
+                    <layout type="horizontal">
60
+                        <button name="Submit" id="submit" type="push" />
61
+                        <button name="Save log as target profile" type="check" id="target" />
62
+                    </layout>
63
+                </layout>
64
+            </widget>
65
+            <widget>
66
+                <layout type="vertical">
67
+                    <label>Connected Scales</label>
68
+                    <layout type="vertical" id="scales" />
69
+                    <label>Expected Weight Loss</label>
70
+                    <line id="lossspec" writable="false" />
71
+                    <label>Expected Roasted Weight</label>
72
+                    <layout type="horizontal">
73
+                        <label>Min:</label>
74
+                        <line id="minroastweight" writable="false" />
75
+                    </layout>
76
+                    <layout type="horizontal">
77
+                        <label>Expected:</label>
78
+                        <line id="expectedroastweight" writable="false" />
79
+                    </layout>
80
+                    <layout type="horizontal">
81
+                        <label>Max:</label>
82
+                        <line id="maxroastweight" writable="false" />
83
+                    </layout>
84
+                    <label>Specification Details</label>
85
+                    <textarea id="specnotes" />
86
+                    <layout type="horizontal">
87
+                        <label>File ID:</label>
88
+                        <line id="filenofield" writable="false" />
89
+                    </layout>
90
+                    <stretch />
91
+                </layout>
92
+            </widget>
93
+            <widget id="tagcontainer" ignoreSizePolicy="true">
94
+                <layout type="vertical">
95
+                    <webview id="batchTag" />
96
+                    <layout type="horizontal">
97
+                        <printerselector id="printerlist" />
98
+                        <button name="Print" id="printbutton" type="push" />
99
+                    </layout>
100
+                </layout>
101
+            </widget>
102
+        </splitter>
94 103
     </layout>
95 104
     <program>
96 105
         <![CDATA[
106
+            var window = this;
107
+            var splitter = findChildObject(this, 'splitter');
108
+            window.aboutToClose.connect(function() {
109
+                splitter.saveState("script/newbatch/splitter");
110
+            });
111
+            splitter.setCollapsible(0, false);
112
+            splitter.restoreState("script/newbatch/splitter");
97 113
             var unitBox = findChildObject(this, 'unit');
98 114
             unitBox.addItem("g");
99 115
             unitBox.addItem("Kg");

+ 13
- 0
src/typica.w Näytä tiedosto

@@ -5587,6 +5587,12 @@ otherwise empty widgets to be included in a splitter for cases where a splitter
5587 5587
 should manage several widgets together as a group. A row of annotation buttons
5588 5588
 is an example of such a layout.
5589 5589
 
5590
+When splitters are used as a way to hide optional features it sometimes has the
5591
+effect of forcing a window to stay larger than should be required. To fix this,
5592
+it is possible to set the \tt{ignoreSizePolicy} attribute to true. While this
5593
+does solve the window size issue, this technique is inconsistent with generally
5594
+expected behavior and its use should generally be discouraged.
5595
+
5590 5596
 @<Functions for scripting@>=
5591 5597
 void addWidgetToSplitter(QDomElement element, QStack<QWidget *> *widgetStack,
5592 5598
                          QStack<QLayout *> *layoutStack)
@@ -5597,6 +5603,13 @@ void addWidgetToSplitter(QDomElement element, QStack<QWidget *> *widgetStack,
5597 5603
     {
5598 5604
         widget->setObjectName(element.attribute("id"));
5599 5605
     }
5606
+    if(element.hasAttribute("ignoreSizePolicy"))
5607
+    {
5608
+        if(element.attribute("ignoreSizePolicy") == "true")
5609
+        {
5610
+            widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
5611
+        }
5612
+    }
5600 5613
     splitter->addWidget(widget);
5601 5614
     if(element.hasChildNodes())
5602 5615
     {

Loading…
Peruuta
Tallenna