Mercurial > projects > qtd
comparison examples/mainwindows/sdi/mainwindow.d @ 282:256ab6cb8e85
Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
author | eldar |
---|---|
date | Fri, 16 Oct 2009 02:43:59 +0000 |
parents | 5df570e79cfc |
children | 7a3c43424dca |
comparison
equal
deleted
inserted
replaced
281:7f2e3ffa1c33 | 282:256ab6cb8e85 |
---|---|
178 createToolBars(); | 178 createToolBars(); |
179 createStatusBar(); | 179 createStatusBar(); |
180 | 180 |
181 readSettings(); | 181 readSettings(); |
182 | 182 |
183 textEdit.document().contentsChanged.connect(&this.documentWasModified); | 183 connect!("contentsChanged")(textEdit.document(), &this.documentWasModified); |
184 | 184 |
185 setUnifiedTitleAndToolBarOnMac(true); | 185 setUnifiedTitleAndToolBarOnMac(true); |
186 } | 186 } |
187 | 187 |
188 void createActions() | 188 void createActions() |
189 { | 189 { |
190 newAct = new QAction(new QIcon(":/images/new.png"), tr("&New"), this); | 190 newAct = new QAction(new QIcon(":/images/new.png"), tr("&New"), this); |
191 newAct.setShortcuts(QKeySequence.New); | 191 newAct.setShortcuts(QKeySequence.New); |
192 newAct.setStatusTip(tr("Create a new file")); | 192 newAct.setStatusTip(tr("Create a new file")); |
193 newAct.triggered.connect(&this.newFile); | 193 connect!("triggered")(newAct, &this.newFile); |
194 | 194 |
195 openAct = new QAction(new QIcon(":/images/open.png"), tr("&Open..."), this); | 195 openAct = new QAction(new QIcon(":/images/open.png"), tr("&Open..."), this); |
196 openAct.setShortcuts(QKeySequence.Open); | 196 openAct.setShortcuts(QKeySequence.Open); |
197 openAct.setStatusTip(tr("Open an existing file")); | 197 openAct.setStatusTip(tr("Open an existing file")); |
198 openAct.triggered.connect(&this.open); | 198 connect!("triggered")(openAct, &this.open); |
199 | 199 |
200 saveAct = new QAction(new QIcon(":/images/save.png"), tr("&Save"), this); | 200 saveAct = new QAction(new QIcon(":/images/save.png"), tr("&Save"), this); |
201 saveAct.setShortcuts(QKeySequence.Save); | 201 saveAct.setShortcuts(QKeySequence.Save); |
202 saveAct.setStatusTip(tr("Save the document to disk")); | 202 saveAct.setStatusTip(tr("Save the document to disk")); |
203 saveAct.triggered.connect(&this.save); | 203 connect!("triggered")(saveAct, &this.save); |
204 | 204 |
205 saveAsAct = new QAction(tr("Save &As..."), this); | 205 saveAsAct = new QAction(tr("Save &As..."), this); |
206 saveAsAct.setShortcuts(QKeySequence.SaveAs); | 206 saveAsAct.setShortcuts(QKeySequence.SaveAs); |
207 saveAsAct.setStatusTip(tr("Save the document under a new name")); | 207 saveAsAct.setStatusTip(tr("Save the document under a new name")); |
208 saveAsAct.triggered.connect(&this.saveAs); | 208 connect!("triggered")(saveAsAct, &this.saveAs); |
209 | 209 |
210 closeAct = new QAction(tr("&Close"), this); | 210 closeAct = new QAction(tr("&Close"), this); |
211 closeAct.setShortcut(tr("Ctrl+W")); | 211 closeAct.setShortcut(tr("Ctrl+W")); |
212 closeAct.setStatusTip(tr("Close this window")); | 212 closeAct.setStatusTip(tr("Close this window")); |
213 closeAct.triggered.connect(&this.close); | 213 connect!("triggered")(closeAct, &this.close); |
214 | 214 |
215 exitAct = new QAction(tr("E&xit"), this); | 215 exitAct = new QAction(tr("E&xit"), this); |
216 exitAct.setShortcut(tr("Ctrl+Q")); | 216 exitAct.setShortcut(tr("Ctrl+Q")); |
217 exitAct.setStatusTip(tr("Exit the application")); | 217 exitAct.setStatusTip(tr("Exit the application")); |
218 exitAct.triggered.connect(&QApplication.closeAllWindows); | 218 connect!("triggered")(exitAct, &QApplication.closeAllWindows); |
219 | 219 |
220 cutAct = new QAction(new QIcon(":/images/cut.png"), tr("Cu&t"), this); | 220 cutAct = new QAction(new QIcon(":/images/cut.png"), tr("Cu&t"), this); |
221 cutAct.setShortcuts(QKeySequence.Cut); | 221 cutAct.setShortcuts(QKeySequence.Cut); |
222 cutAct.setStatusTip(tr("Cut the current selection's contents to the " ~ | 222 cutAct.setStatusTip(tr("Cut the current selection's contents to the " ~ |
223 "clipboard")); | 223 "clipboard")); |
224 cutAct.triggered.connect(&textEdit.cut); | 224 connect!("triggered")(cutAct, &textEdit.cut); |
225 | 225 |
226 copyAct = new QAction(new QIcon(":/images/copy.png"), tr("&Copy"), this); | 226 copyAct = new QAction(new QIcon(":/images/copy.png"), tr("&Copy"), this); |
227 copyAct.setShortcuts(QKeySequence.Copy); | 227 copyAct.setShortcuts(QKeySequence.Copy); |
228 copyAct.setStatusTip(tr("Copy the current selection's contents to the " ~ | 228 copyAct.setStatusTip(tr("Copy the current selection's contents to the " ~ |
229 "clipboard")); | 229 "clipboard")); |
230 copyAct.triggered.connect(&textEdit.copy); | 230 connect!("triggered")(copyAct, &textEdit.copy); |
231 | 231 |
232 pasteAct = new QAction(new QIcon(":/images/paste.png"), tr("&Paste"), this); | 232 pasteAct = new QAction(new QIcon(":/images/paste.png"), tr("&Paste"), this); |
233 pasteAct.setShortcuts(QKeySequence.Paste); | 233 pasteAct.setShortcuts(QKeySequence.Paste); |
234 pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " ~ | 234 pasteAct.setStatusTip(tr("Paste the clipboard's contents into the current " ~ |
235 "selection")); | 235 "selection")); |
236 pasteAct.triggered.connect(&textEdit.paste); | 236 connect!("triggered")(pasteAct, &textEdit.paste); |
237 | 237 |
238 aboutAct = new QAction(tr("&About"), this); | 238 aboutAct = new QAction(tr("&About"), this); |
239 aboutAct.setStatusTip(tr("Show the application's About box")); | 239 aboutAct.setStatusTip(tr("Show the application's About box")); |
240 aboutAct.triggered.connect(&this.about); | 240 connect!("triggered")(aboutAct, &this.about); |
241 | 241 |
242 aboutQtAct = new QAction(tr("About &Qt"), this); | 242 aboutQtAct = new QAction(tr("About &Qt"), this); |
243 aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); | 243 aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); |
244 aboutQtAct.triggered.connect(&QApplication.aboutQt); | 244 connect!("triggered")(aboutQtAct, &QApplication.aboutQt); |
245 | 245 |
246 cutAct.setEnabled(false); | 246 cutAct.setEnabled(false); |
247 copyAct.setEnabled(false); | 247 copyAct.setEnabled(false); |
248 | 248 |
249 // QtD bug???? | 249 connect!("copyAvailable")(textEdit, &cutAct.setEnabled); |
250 // only one of the following statements can be included | 250 connect!("copyAvailable")(textEdit, ©Act.setEnabled); |
251 // otherwise the app crashes when a MainWindow is closeda | |
252 textEdit.copyAvailable.connect(&cutAct.setEnabled); | |
253 textEdit.copyAvailable.connect(©Act.setEnabled); | |
254 } | 251 } |
255 | 252 |
256 void createMenus() | 253 void createMenus() |
257 { | 254 { |
258 fileMenu = menuBar.addMenu(tr("&File")); | 255 fileMenu = menuBar.addMenu(tr("&File")); |