Mercurial > projects > qtd
comparison examples/desktop/systray/window.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 | 4e31cbd9e20c |
comparison
equal
deleted
inserted
replaced
322:7c2cf27391c4 | 323:7a3c43424dca |
---|---|
70 iconLabel.setMinimumWidth(durationLabel.sizeHint().width()); | 70 iconLabel.setMinimumWidth(durationLabel.sizeHint().width()); |
71 | 71 |
72 createActions(); | 72 createActions(); |
73 createTrayIcon(); | 73 createTrayIcon(); |
74 | 74 |
75 connect!("clicked")(showMessageButton, &this.showMessage); | 75 connect(showMessageButton, "clicked", this, "showMessage"); |
76 connect!("toggled")(showIconCheckBox, &trayIcon.setVisible); | 76 connect(showIconCheckBox, "toggled", trayIcon, "setVisible"); |
77 connect!("currentIndexChanged")(iconComboBox, &this.setIcon); | 77 connect(iconComboBox, "currentIndexChanged", this, "setIcon"); |
78 connect!("messageClicked")(trayIcon, &this.messageClicked); | 78 connect(trayIcon, "messageClicked", this, "messageClicked"); |
79 connect!("activated")(trayIcon, &this.iconActivated); | 79 connect(trayIcon, "activated", this, "iconActivated"); |
80 | 80 |
81 QVBoxLayout mainLayout = new QVBoxLayout; | 81 QVBoxLayout mainLayout = new QVBoxLayout; |
82 mainLayout.addWidget(iconGroupBox); | 82 mainLayout.addWidget(iconGroupBox); |
83 mainLayout.addWidget(messageGroupBox); | 83 mainLayout.addWidget(messageGroupBox); |
84 setLayout(mainLayout); | 84 setLayout(mainLayout); |
109 hide(); | 109 hide(); |
110 event.ignore(); | 110 event.ignore(); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: // slots |
115 | 115 |
116 void setIcon(int index) | 116 void slot_setIcon(int index) |
117 { | 117 { |
118 QIcon icon = iconComboBox.itemIcon(index); | 118 QIcon icon = iconComboBox.itemIcon(index); |
119 trayIcon.setIcon(icon); | 119 trayIcon.setIcon(icon); |
120 setWindowIcon(icon); | 120 setWindowIcon(icon); |
121 | 121 |
122 trayIcon.setToolTip(iconComboBox.itemText(index)); | 122 trayIcon.setToolTip(iconComboBox.itemText(index)); |
123 } | 123 } |
124 | 124 |
125 void iconActivated(QSystemTrayIcon.ActivationReason reason) | 125 void slot_iconActivated(QSystemTrayIcon.ActivationReason reason) |
126 { | 126 { |
127 switch (reason) { | 127 switch (reason) { |
128 case QSystemTrayIcon.Trigger: | 128 case QSystemTrayIcon.Trigger: |
129 case QSystemTrayIcon.DoubleClick: | 129 case QSystemTrayIcon.DoubleClick: |
130 iconComboBox.setCurrentIndex((iconComboBox.currentIndex() + 1) % iconComboBox.count()); | 130 iconComboBox.setCurrentIndex((iconComboBox.currentIndex() + 1) % iconComboBox.count()); |
134 break; | 134 break; |
135 default: | 135 default: |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 void showMessage() | 139 void slot_showMessage() |
140 { | 140 { |
141 QSystemTrayIcon.MessageIcon icon = cast(QSystemTrayIcon.MessageIcon) | 141 QSystemTrayIcon.MessageIcon icon = cast(QSystemTrayIcon.MessageIcon) |
142 typeComboBox.itemData(typeComboBox.currentIndex()).toInt(); | 142 typeComboBox.itemData(typeComboBox.currentIndex()).toInt(); |
143 trayIcon.showMessage(titleEdit.text(), bodyEdit.toPlainText(), icon, durationSpinBox.value() * 1000); | 143 trayIcon.showMessage(titleEdit.text(), bodyEdit.toPlainText(), icon, durationSpinBox.value() * 1000); |
144 } | 144 } |
145 | 145 |
146 void messageClicked() | 146 void slot_messageClicked() |
147 { | 147 { |
148 QMessageBox.information(null, tr("Systray"), | 148 QMessageBox.information(null, tr("Systray"), |
149 tr("Sorry, I already gave what help I could.\nMaybe you should try asking a human?")); | 149 tr("Sorry, I already gave what help I could.\nMaybe you should try asking a human?")); |
150 } | 150 } |
151 | 151 |
231 } | 231 } |
232 | 232 |
233 void createActions() | 233 void createActions() |
234 { | 234 { |
235 minimizeAction = new QAction(tr("Mi&nimize"), this); | 235 minimizeAction = new QAction(tr("Mi&nimize"), this); |
236 connect!("triggered")(minimizeAction, &this.hide); | 236 connect(minimizeAction, "activated", this, "hide"); |
237 | 237 |
238 maximizeAction = new QAction(tr("Ma&ximize"), this); | 238 maximizeAction = new QAction(tr("Ma&ximize"), this); |
239 connect!("triggered")(maximizeAction, &this.showMaximized); | 239 connect(maximizeAction, "activated", this, "showMaximized"); |
240 | 240 |
241 restoreAction = new QAction(tr("&Restore"), this); | 241 restoreAction = new QAction(tr("&Restore"), this); |
242 connect!("triggered")(restoreAction, &this.showNormal); | 242 connect(restoreAction, "activated", this, "showNormal"); |
243 | 243 |
244 quitAction = new QAction(tr("&Quit"), this); | 244 quitAction = new QAction(tr("&Quit"), this); |
245 connect!("triggered")(quitAction, &QApplication.quit); | 245 connect(quitAction, "triggered", qApp(), "quit"); |
246 } | 246 } |
247 | 247 |
248 void createTrayIcon() | 248 void createTrayIcon() |
249 { | 249 { |
250 trayIconMenu = new QMenu(this); | 250 trayIconMenu = new QMenu(this); |
280 QAction restoreAction; | 280 QAction restoreAction; |
281 QAction quitAction; | 281 QAction quitAction; |
282 | 282 |
283 QSystemTrayIcon trayIcon; | 283 QSystemTrayIcon trayIcon; |
284 QMenu trayIconMenu; | 284 QMenu trayIconMenu; |
285 | |
286 mixin Q_OBJECT; | |
285 } | 287 } |