comparison examples/layouts/dynamiclayouts/dialog.d @ 323:7a3c43424dca signals

make all examples compile with new signals/slots
author eldar_ins@eldar-laptop
date Mon, 28 Dec 2009 16:28:55 +0500
parents 256ab6cb8e85
children 5896535a03cd
comparison
equal deleted inserted replaced
322:7c2cf27391c4 323:7a3c43424dca
74 mainLayout.setSizeConstraint(QLayout.SetMinimumSize); 74 mainLayout.setSizeConstraint(QLayout.SetMinimumSize);
75 75
76 setWindowTitle(tr("Dynamic Layouts")); 76 setWindowTitle(tr("Dynamic Layouts"));
77 } 77 }
78 78
79 private: 79 private: // slots
80 80
81 void buttonsOrientationChanged(int index) 81 void slot_buttonsOrientationChanged(int index)
82 { 82 {
83 mainLayout.setSizeConstraint(QLayout.SetNoConstraint); 83 mainLayout.setSizeConstraint(QLayout.SetNoConstraint);
84 setMinimumSize(0, 0); 84 setMinimumSize(0, 0);
85 85
86 Qt.Orientation orientation = cast(Qt.Orientation) buttonsOrientationComboBox.itemData(index).toInt(); 86 Qt.Orientation orientation = cast(Qt.Orientation) buttonsOrientationComboBox.itemData(index).toInt();
105 } 105 }
106 106
107 mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint); 107 mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint);
108 } 108 }
109 109
110 void rotateWidgets() 110 void slot_rotateWidgets()
111 { 111 {
112 assert(rotableWidgets.length % 2 == 0); 112 assert(rotableWidgets.length % 2 == 0);
113 113
114 foreach (QWidget widget; rotableWidgets) 114 foreach (QWidget widget; rotableWidgets)
115 rotableLayout.removeWidget(widget); 115 rotableLayout.removeWidget(widget);
121 rotableLayout.addWidget(rotableWidgets[n - i - 1], 0, i); 121 rotableLayout.addWidget(rotableWidgets[n - i - 1], 0, i);
122 rotableLayout.addWidget(rotableWidgets[i], 1, i); 122 rotableLayout.addWidget(rotableWidgets[i], 1, i);
123 } 123 }
124 } 124 }
125 125
126 void help() 126 void slot_help()
127 { 127 {
128 QMessageBox.information(this, tr("Dynamic Layouts Help"), 128 QMessageBox.information(this, tr("Dynamic Layouts Help"),
129 tr("This example shows how to change layouts dynamically.")); 129 tr("This example shows how to change layouts dynamically."));
130 } 130 }
131 131
143 rotableWidgets ~= a0; 143 rotableWidgets ~= a0;
144 rotableWidgets ~= a1; 144 rotableWidgets ~= a1;
145 rotableWidgets ~= a2; 145 rotableWidgets ~= a2;
146 rotableWidgets ~= a3; 146 rotableWidgets ~= a3;
147 147
148 connect!("valueChanged")(a0, &a1.setValue);
149 connect!("valueChanged")(a1, &a2.setValue);
150 connect!("valueChanged")(a2, &a3.setValue);
151 connect!("valueChanged")(a3, &a0.setValue);
152
153 /*
154 int n = rotableWidgets.length; 148 int n = rotableWidgets.length;
155 for (int i = 0; i < n; ++i) { 149 for (int i = 0; i < n; ++i)
156 rotableWidgets[i].valueChanged.connect(&rotableWidgets[(i + 1) % n].setValue); 150 connect(rotableWidgets[i], "valueChanged", rotableWidgets[(i + 1) % n], "setValue");
157 }*/ 151
158 152
159 rotableLayout = new QGridLayout; 153 rotableLayout = new QGridLayout;
160 rotableGroupBox.setLayout(rotableLayout); 154 rotableGroupBox.setLayout(rotableLayout);
161 155
162 rotateWidgets(); 156 rotateWidgets();
163 } 157 }
170 164
171 buttonsOrientationComboBox = new QComboBox; 165 buttonsOrientationComboBox = new QComboBox;
172 buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal)); 166 buttonsOrientationComboBox.addItem(tr("Horizontal"), new QVariant(cast(ulong) Qt.Horizontal));
173 buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical)); 167 buttonsOrientationComboBox.addItem(tr("Vertical"), new QVariant(cast(ulong) Qt.Vertical));
174 168
175 connect!("currentIndexChanged")(buttonsOrientationComboBox, &this.buttonsOrientationChanged); 169 connect(buttonsOrientationComboBox, "currentIndexChanged", this, "buttonsOrientationChanged");
176 170
177 optionsLayout = new QGridLayout; 171 optionsLayout = new QGridLayout;
178 optionsLayout.addWidget(buttonsOrientationLabel, 0, 0); 172 optionsLayout.addWidget(buttonsOrientationLabel, 0, 0);
179 optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1); 173 optionsLayout.addWidget(buttonsOrientationComboBox, 0, 1);
180 optionsLayout.setColumnStretch(2, 1); 174 optionsLayout.setColumnStretch(2, 1);
181 optionsGroupBox.setLayout(optionsLayout); 175 optionsGroupBox.setLayout(optionsLayout);
187 181
188 closeButton = buttonBox.addButton(QDialogButtonBox.Close); 182 closeButton = buttonBox.addButton(QDialogButtonBox.Close);
189 helpButton = buttonBox.addButton(QDialogButtonBox.Help); 183 helpButton = buttonBox.addButton(QDialogButtonBox.Help);
190 rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole); 184 rotateWidgetsButton = buttonBox.addButton(tr("Rotate &Widgets"), QDialogButtonBox.ActionRole);
191 185
192 connect!("clicked")(rotateWidgetsButton, &this.rotateWidgets); 186 connect(rotateWidgetsButton, "clicked", this, "rotateWidgets");
193 connect!("clicked")(closeButton, &this.close); 187 connect(closeButton, "clicked", this, "close");
194 connect!("clicked")(helpButton, &this.help); 188 connect(helpButton, "clicked", this, "help");
195 } 189 }
196 190
197 QGroupBox rotableGroupBox; 191 QGroupBox rotableGroupBox;
198 QWidget[] rotableWidgets; 192 QWidget[] rotableWidgets;
199 193
207 QPushButton rotateWidgetsButton; 201 QPushButton rotateWidgetsButton;
208 202
209 QGridLayout mainLayout; 203 QGridLayout mainLayout;
210 QGridLayout rotableLayout; 204 QGridLayout rotableLayout;
211 QGridLayout optionsLayout; 205 QGridLayout optionsLayout;
206
207 mixin Q_OBJECT;
212 } 208 }