comparison examples/mainwindows/dockwidgets/mainwindow.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 31520b2c0b3c
comparison
equal deleted inserted replaced
322:7c2cf27391c4 323:7a3c43424dca
80 setWindowTitle(tr("Dock Widgets")); 80 setWindowTitle(tr("Dock Widgets"));
81 newLetter(); 81 newLetter();
82 } 82 }
83 83
84 private : //slots: 84 private : //slots:
85 void newLetter() 85 void slot_newLetter()
86 { 86 {
87 textEdit.clear(); 87 textEdit.clear();
88 88
89 scope cursor = textEdit.textCursor; 89 scope cursor = textEdit.textCursor;
90 cursor.movePosition(QTextCursor.Start); 90 cursor.movePosition(QTextCursor.Start);
126 cursor.insertText("The Boss", textFormat); 126 cursor.insertText("The Boss", textFormat);
127 cursor.insertBlock(); 127 cursor.insertBlock();
128 cursor.insertText("ADDRESS", italicFormat); 128 cursor.insertText("ADDRESS", italicFormat);
129 } 129 }
130 /* 130 /*
131 void save() 131 void slot_save()
132 { 132 {
133 char[] fileName = QFileDialog.getSaveFileName(this, 133 char[] fileName = QFileDialog.getSaveFileName(this,
134 tr("Choose a file name"), ".", 134 tr("Choose a file name"), ".",
135 tr("HTML (*.html *.htm)")); 135 tr("HTML (*.html *.htm)"));
136 if (fileName.isEmpty()) 136 if (fileName.isEmpty())
148 QApplication.restoreOverrideCursor(); 148 QApplication.restoreOverrideCursor();
149 149
150 statusBar.showMessage(layout("Saved '%1'", fileName), 2000); 150 statusBar.showMessage(layout("Saved '%1'", fileName), 2000);
151 }*/ 151 }*/
152 152
153 void print() { } 153 void slot_print() { }
154 154
155 void undo() { 155 void slot_undo() {
156 auto document = textEdit.document(); 156 auto document = textEdit.document();
157 document.undo(); 157 document.undo();
158 } 158 }
159 159
160 void insertCustomer(string customer) 160 void slot_insertCustomer(string customer)
161 { 161 {
162 if (customer == "") 162 if (customer == "")
163 return; 163 return;
164 164
165 string[] customerList = customer.split(", "); 165 string[] customerList = customer.split(", ");
180 else 180 else
181 oldcursor.endEditBlock(); 181 oldcursor.endEditBlock();
182 } 182 }
183 } 183 }
184 184
185 void addParagraph(string paragraph) 185 void slot_addParagraph(string paragraph)
186 { 186 {
187 if (paragraph == "") 187 if (paragraph == "")
188 return; 188 return;
189 auto document = textEdit.document(); 189 auto document = textEdit.document();
190 scope cursor = document.find(tr("Yours sincerely,")); 190 scope cursor = document.find(tr("Yours sincerely,"));
197 cursor.insertBlock(); 197 cursor.insertBlock();
198 cursor.endEditBlock(); 198 cursor.endEditBlock();
199 199
200 } 200 }
201 201
202 void about() 202 void slot_about()
203 { 203 {
204 QMessageBox.about(this, "About Dock Widgets", 204 QMessageBox.about(this, "About Dock Widgets",
205 "The <b>Dock Widgets</b> example demonstrates how to " 205 "The <b>Dock Widgets</b> example demonstrates how to "
206 "use Qt's dock widgets. You can enter your own text, " 206 "use Qt's dock widgets. You can enter your own text, "
207 "click a customer to add a customer name and " 207 "click a customer to add a customer name and "
212 void createActions() 212 void createActions()
213 { 213 {
214 newLetterAct = new QAction(new QIcon(":images/new.png"), tr("&New Letter"), this); 214 newLetterAct = new QAction(new QIcon(":images/new.png"), tr("&New Letter"), this);
215 newLetterAct.setShortcut(tr("Ctrl+N")); 215 newLetterAct.setShortcut(tr("Ctrl+N"));
216 newLetterAct.setStatusTip(tr("Create a new form letter")); 216 newLetterAct.setStatusTip(tr("Create a new form letter"));
217 connect!("triggered")(newLetterAct, &this.newLetter); 217 connect(newLetterAct, "triggered", this, "newLetter");
218 218
219 saveAct = new QAction(new QIcon(":images/save.png"), tr("&Save..."), this); 219 saveAct = new QAction(new QIcon(":images/save.png"), tr("&Save..."), this);
220 saveAct.setShortcut(tr("Ctrl+S")); 220 saveAct.setShortcut(tr("Ctrl+S"));
221 saveAct.setStatusTip(tr("Save the current form letter")); 221 saveAct.setStatusTip(tr("Save the current form letter"));
222 // saveAct.triggered.connect(&save); 222 // saveAct.triggered.connect(&save);
227 // printAct.triggered.connect(&print); 227 // printAct.triggered.connect(&print);
228 228
229 undoAct = new QAction(new QIcon(":images/undo.png"), tr("&Undo"), this); 229 undoAct = new QAction(new QIcon(":images/undo.png"), tr("&Undo"), this);
230 undoAct.setShortcut(tr("Ctrl+Z")); 230 undoAct.setShortcut(tr("Ctrl+Z"));
231 undoAct.setStatusTip(tr("Undo the last editing action")); 231 undoAct.setStatusTip(tr("Undo the last editing action"));
232 connect!("triggered")(undoAct, &undo); 232 connect(undoAct, "triggered", this, "undo");
233 233
234 quitAct = new QAction(tr("&Quit"), this); 234 quitAct = new QAction(tr("&Quit"), this);
235 quitAct.setShortcut(tr("Ctrl+Q")); 235 quitAct.setShortcut(tr("Ctrl+Q"));
236 quitAct.setStatusTip(tr("Quit the application")); 236 quitAct.setStatusTip(tr("Quit the application"));
237 connect!("triggered")(quitAct, &this.close); 237 connect(quitAct, "triggered", this, "close");
238 238
239 aboutAct = new QAction(tr("&About"), this); 239 aboutAct = new QAction(tr("&About"), this);
240 aboutAct.setStatusTip(tr("Show the application's About box")); 240 aboutAct.setStatusTip(tr("Show the application's About box"));
241 connect!("triggered")(aboutAct, &about); 241 connect(aboutAct, "triggered", this, "about");
242 242
243 aboutQtAct = new QAction(tr("About &Qt"), this); 243 aboutQtAct = new QAction(tr("About &Qt"), this);
244 aboutQtAct.setStatusTip(tr("Show the Qt library's About box")); 244 aboutQtAct.setStatusTip(tr("Show the Qt library's About box"));
245 // aboutQtAct.triggered(&aboutQt); 245 connect(aboutQtAct, "triggered", qApp, "aboutQt");
246 } 246 }
247 247
248 void createMenus() 248 void createMenus()
249 { 249 {
250 fileMenu = menuBar.addMenu(tr("&File")); 250 fileMenu = menuBar.addMenu(tr("&File"));
325 "buy more items, or should we return the excess to you?"]); 325 "buy more items, or should we return the excess to you?"]);
326 dock.setWidget(paragraphsList); 326 dock.setWidget(paragraphsList);
327 addDockWidget(Qt.RightDockWidgetArea, dock); 327 addDockWidget(Qt.RightDockWidgetArea, dock);
328 viewMenu.addAction(dock.toggleViewAction()); 328 viewMenu.addAction(dock.toggleViewAction());
329 329
330 connect!("currentTextChanged")(customerList, &this.insertCustomer); 330 connect(customerList, "currentTextChanged", this, "insertCustomer");
331 connect!("currentTextChanged")(paragraphsList, &this.addParagraph); 331 connect(paragraphsList, "currentTextChanged", this, "addParagraph");
332 } 332 }
333 333
334 QTextEdit textEdit; 334 QTextEdit textEdit;
335 QListWidget customerList; 335 QListWidget customerList;
336 QListWidget paragraphsList; 336 QListWidget paragraphsList;
346 QAction printAct; 346 QAction printAct;
347 QAction undoAct; 347 QAction undoAct;
348 QAction aboutAct; 348 QAction aboutAct;
349 QAction aboutQtAct; 349 QAction aboutQtAct;
350 QAction quitAct; 350 QAction quitAct;
351
352 mixin Q_OBJECT;
351 } 353 }
352
353
354 //! [9]