| [231] | 1 | #include <QDebug> | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #include <QtGui> | 
|---|
|  | 4 |  | 
|---|
|  | 5 | #define myDefFlagEx(var,fl,varstr,flstr) if (var & fl) { \ | 
|---|
| [611] | 6 | if (!varstr.isEmpty()) varstr += "|"; varstr += flstr; \ | 
|---|
| [231] | 7 | } else do {} while(0) | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #define myDefFlag(var,fl,varstr) myDefFlagEx(var,fl,varstr,#fl) | 
|---|
|  | 10 | #define myDefFlagCut(var,fl,varstr,pos) myDefFlagEx(var,fl,varstr,#fl + pos) | 
|---|
|  | 11 |  | 
|---|
| [368] | 12 | #define PRINT_EXPR(e) qWarning() << #e << e | 
|---|
| [231] | 13 |  | 
|---|
|  | 14 | QDebug operator<<(QDebug dbg, Qt::WindowStates st) | 
|---|
|  | 15 | { | 
|---|
| [611] | 16 | QByteArray name; | 
|---|
| [231] | 17 | myDefFlagEx(st, Qt::WindowMinimized, name, "Min"); | 
|---|
|  | 18 | myDefFlagEx(st, Qt::WindowMaximized, name, "Max"); | 
|---|
|  | 19 | myDefFlagEx(st, Qt::WindowFullScreen, name, "Full"); | 
|---|
|  | 20 | myDefFlagEx(st, Qt::WindowActive, name, "Act"); | 
|---|
| [611] | 21 | if (name.isEmpty()) name = "None"; | 
|---|
|  | 22 | dbg.nospace() << "WindowState(" << name.constData() << ")"; | 
|---|
| [231] | 23 | return dbg.space(); | 
|---|
|  | 24 | } | 
|---|
|  | 25 |  | 
|---|
|  | 26 | QDebug operator<<(QDebug dbg, Qt::FocusReason r) | 
|---|
|  | 27 | { | 
|---|
| [611] | 28 | QByteArray name; | 
|---|
| [231] | 29 | if (r == Qt::MouseFocusReason) name = "Mouse"; | 
|---|
|  | 30 | if (r == Qt::TabFocusReason) name = "Tab"; | 
|---|
|  | 31 | if (r == Qt::BacktabFocusReason) name = "Backtab"; | 
|---|
|  | 32 | if (r == Qt::ActiveWindowFocusReason) name = "ActWin"; | 
|---|
|  | 33 | if (r == Qt::PopupFocusReason) name = "Popup"; | 
|---|
|  | 34 | if (r == Qt::ShortcutFocusReason) name = "Shortcut"; | 
|---|
|  | 35 | if (r == Qt::MenuBarFocusReason) name = "MenuBar"; | 
|---|
|  | 36 | if (r == Qt::OtherFocusReason) name = "Other"; | 
|---|
| [611] | 37 | dbg.nospace() << "FocusReason(" << name.constData() << ")"; | 
|---|
| [231] | 38 | return dbg.space(); | 
|---|
|  | 39 | } | 
|---|
|  | 40 |  | 
|---|
| [304] | 41 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 42 |  | 
|---|
|  | 43 | class MyChild : public QWidget | 
|---|
|  | 44 | { | 
|---|
|  | 45 | Q_OBJECT | 
|---|
|  | 46 |  | 
|---|
|  | 47 | public: | 
|---|
|  | 48 |  | 
|---|
|  | 49 | MyChild(QWidget *aParent) : QWidget(aParent), mPressed(0) | 
|---|
|  | 50 | { | 
|---|
|  | 51 | setFocusPolicy(Qt::StrongFocus); | 
|---|
|  | 52 |  | 
|---|
|  | 53 | resize(64, 32); | 
|---|
|  | 54 | } | 
|---|
|  | 55 |  | 
|---|
|  | 56 | void paintEvent(QPaintEvent *aE) | 
|---|
|  | 57 | { | 
|---|
| [611] | 58 | qDebug() << this << __FUNCTION__ | 
|---|
| [304] | 59 | << ": " << aE->rect() << "focus" << hasFocus(); | 
|---|
|  | 60 |  | 
|---|
|  | 61 | QPainter p(this); | 
|---|
|  | 62 | p.setRenderHint(QPainter::Antialiasing); | 
|---|
|  | 63 |  | 
|---|
|  | 64 | if (hasFocus()) | 
|---|
|  | 65 | p.fillRect(aE->rect(), mPressed % 2 ? Qt::red : Qt::green); | 
|---|
|  | 66 | else | 
|---|
|  | 67 | p.fillRect(aE->rect(), Qt::gray); | 
|---|
|  | 68 | } | 
|---|
|  | 69 |  | 
|---|
|  | 70 | void mousePressEvent(QMouseEvent *aE) | 
|---|
|  | 71 | { | 
|---|
| [501] | 72 | Q_UNUSED(aE); | 
|---|
| [304] | 73 | ++mPressed; | 
|---|
|  | 74 | update(); | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
| [311] | 77 | void mouseReleaseEvent(QMouseEvent *aE) | 
|---|
|  | 78 | { | 
|---|
| [501] | 79 | Q_UNUSED(aE); | 
|---|
| [311] | 80 | ++mPressed; | 
|---|
|  | 81 | update(); | 
|---|
|  | 82 | } | 
|---|
|  | 83 |  | 
|---|
| [304] | 84 | void focusInEvent(QFocusEvent *aE) | 
|---|
|  | 85 | { | 
|---|
| [611] | 86 | qDebug() << this << __FUNCTION__ << ": reason" << aE->reason(); | 
|---|
| [304] | 87 | QWidget::focusInEvent(aE); | 
|---|
|  | 88 | } | 
|---|
|  | 89 |  | 
|---|
|  | 90 | void focusOutEvent(QFocusEvent *aE) | 
|---|
|  | 91 | { | 
|---|
| [611] | 92 | qDebug() << this << __FUNCTION__ << ": reason" << aE->reason(); | 
|---|
| [304] | 93 | QWidget::focusOutEvent(aE); | 
|---|
|  | 94 | } | 
|---|
|  | 95 |  | 
|---|
|  | 96 | private: | 
|---|
|  | 97 |  | 
|---|
|  | 98 | int mPressed; | 
|---|
|  | 99 | }; | 
|---|
|  | 100 |  | 
|---|
|  | 101 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 102 |  | 
|---|
| [231] | 103 | class MyButton : public QPushButton | 
|---|
|  | 104 | { | 
|---|
|  | 105 | public: | 
|---|
|  | 106 |  | 
|---|
| [311] | 107 | MyButton(QWidget *aParent) : QPushButton(aParent) | 
|---|
|  | 108 | { | 
|---|
|  | 109 | QMenu *menu = new QMenu(aParent); | 
|---|
|  | 110 | menu->addAction(QLatin1String("Action &1")); | 
|---|
|  | 111 | menu->addAction(QLatin1String("Action &2")); | 
|---|
|  | 112 | setMenu(menu); | 
|---|
|  | 113 | } | 
|---|
| [231] | 114 |  | 
|---|
| [304] | 115 | #if 0 | 
|---|
| [231] | 116 | void focusInEvent(QFocusEvent *aE) | 
|---|
|  | 117 | { | 
|---|
| [611] | 118 | qDebug() << this << __FUNCTION__ << ":" << text() | 
|---|
| [304] | 119 | << "reason" << aE->reason() | 
|---|
| [611] | 120 | << "focus" << qApp->focusWidget(); | 
|---|
| [304] | 121 |  | 
|---|
|  | 122 | QPushButton::focusInEvent(aE); | 
|---|
| [231] | 123 | } | 
|---|
|  | 124 |  | 
|---|
|  | 125 | void focusOutEvent(QFocusEvent *aE) | 
|---|
|  | 126 | { | 
|---|
| [611] | 127 | qDebug() << this << __FUNCTION__ << ":" << text() | 
|---|
| [304] | 128 | << "reason" << aE->reason() | 
|---|
| [611] | 129 | << "focus" << qApp->focusWidget(); | 
|---|
| [304] | 130 | QPushButton::focusOutEvent(aE); | 
|---|
|  | 131 | } | 
|---|
| [231] | 132 | #endif | 
|---|
|  | 133 | }; | 
|---|
|  | 134 |  | 
|---|
| [304] | 135 |  | 
|---|
|  | 136 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 137 |  | 
|---|
| [231] | 138 | class MyCombo : public QComboBox | 
|---|
|  | 139 | { | 
|---|
|  | 140 | public: | 
|---|
|  | 141 |  | 
|---|
|  | 142 | MyCombo(QWidget *aParent) : QComboBox(aParent) {} | 
|---|
|  | 143 |  | 
|---|
| [304] | 144 | #if 0 | 
|---|
| [231] | 145 | void focusInEvent(QFocusEvent *aE) | 
|---|
|  | 146 | { | 
|---|
| [611] | 147 | qDebug() << this << __FUNCTION__ << ":" << currentText() | 
|---|
| [304] | 148 | << "reason" << aE->reason() | 
|---|
| [611] | 149 | << "focus" << qApp->focusWidget(); | 
|---|
| [304] | 150 | QComboBox::focusInEvent(aE); | 
|---|
| [231] | 151 | } | 
|---|
|  | 152 |  | 
|---|
|  | 153 | void focusOutEvent(QFocusEvent *aE) | 
|---|
|  | 154 | { | 
|---|
| [611] | 155 | qDebug() << this << __FUNCTION__ << ":" << currentText() | 
|---|
| [304] | 156 | << "reason" << aE->reason() | 
|---|
| [611] | 157 | << "focus" << qApp->focusWidget(); | 
|---|
| [304] | 158 | QComboBox::focusOutEvent(aE); | 
|---|
|  | 159 | } | 
|---|
| [231] | 160 | #endif | 
|---|
|  | 161 |  | 
|---|
|  | 162 | #if 0 | 
|---|
|  | 163 | void resizeEvent(QResizeEvent *aE) | 
|---|
|  | 164 | { | 
|---|
|  | 165 | qDebug() << __FUNCTION__ << ":"  << currentText() << "g" << geometry() << "fg" << frameGeometry() | 
|---|
|  | 166 | << "sz" << aE->size() << "old" << aE->oldSize(); | 
|---|
|  | 167 | } | 
|---|
|  | 168 |  | 
|---|
|  | 169 | void moveEvent(QMoveEvent *aE) | 
|---|
|  | 170 | { | 
|---|
|  | 171 | qDebug() << __FUNCTION__ << ":" << currentText() << " g" << geometry() << "fg" << frameGeometry() | 
|---|
|  | 172 | << "pos" << aE->pos() << "old" << aE->oldPos(); | 
|---|
|  | 173 | } | 
|---|
|  | 174 | #endif | 
|---|
|  | 175 |  | 
|---|
|  | 176 | #if 0 | 
|---|
|  | 177 | virtual void enterEvent(QEvent *event) | 
|---|
|  | 178 | { | 
|---|
|  | 179 | qDebug() << __FUNCTION__ << ":" << currentText(); | 
|---|
|  | 180 | } | 
|---|
|  | 181 |  | 
|---|
|  | 182 | virtual void leaveEvent(QEvent *event) | 
|---|
|  | 183 | { | 
|---|
|  | 184 | qDebug() << __FUNCTION__ << ":" << currentText(); | 
|---|
|  | 185 | } | 
|---|
|  | 186 | #endif | 
|---|
|  | 187 |  | 
|---|
|  | 188 | #if 0 | 
|---|
|  | 189 | void mousePressEvent(QMouseEvent *aE) | 
|---|
|  | 190 | { | 
|---|
|  | 191 | qDebug() << __FUNCTION__ << ": btn" << aE->button() | 
|---|
| [611] | 192 | << "btns" << qDebugFmtHex(aE->buttons()) | 
|---|
|  | 193 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 194 | << "gpos" << aE->globalPos() << "pos" << aE->pos(); | 
|---|
|  | 195 | QComboBox::mousePressEvent(aE); | 
|---|
|  | 196 | } | 
|---|
|  | 197 |  | 
|---|
|  | 198 | void mouseReleaseEvent(QMouseEvent *aE) | 
|---|
|  | 199 | { | 
|---|
|  | 200 | qDebug() << __FUNCTION__ << ": btn" << aE->button() | 
|---|
| [611] | 201 | << "btns" << qDebugFmtHex(aE->buttons()) | 
|---|
|  | 202 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 203 | << "gpos" << aE->globalPos() << "pos" << aE->pos(); | 
|---|
|  | 204 | QComboBox::mouseReleaseEvent(aE); | 
|---|
|  | 205 | } | 
|---|
|  | 206 |  | 
|---|
|  | 207 | void contextMenuEvent(QContextMenuEvent *aE) | 
|---|
|  | 208 | { | 
|---|
|  | 209 | QMenu menu; | 
|---|
|  | 210 | menu.addAction(QLatin1String("Action &1")); | 
|---|
|  | 211 | menu.addAction(QLatin1String("Action &2")); | 
|---|
|  | 212 | menu.exec(aE->globalPos()); | 
|---|
|  | 213 | winId(); | 
|---|
|  | 214 | } | 
|---|
|  | 215 | #endif | 
|---|
|  | 216 | }; | 
|---|
|  | 217 |  | 
|---|
| [304] | 218 | //////////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 219 |  | 
|---|
| [231] | 220 | class MyWidget : public QWidget | 
|---|
|  | 221 | { | 
|---|
|  | 222 | public: | 
|---|
|  | 223 |  | 
|---|
| [304] | 224 | MyWidget() : mPressed(0) | 
|---|
| [231] | 225 | { | 
|---|
| [481] | 226 | #if 0 | 
|---|
| [304] | 227 | MyButton *btn1 = new MyButton(this); | 
|---|
| [435] | 228 | btn1->setText(QLatin1String("&Hello (also Ctrl+H)")); | 
|---|
|  | 229 | btn1->setObjectName("Hello"); | 
|---|
| [304] | 230 | btn1->move(20, 20); | 
|---|
| [435] | 231 |  | 
|---|
|  | 232 | connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), btn1), | 
|---|
|  | 233 | SIGNAL(activated()), btn1, SLOT(animateClick())); | 
|---|
|  | 234 |  | 
|---|
| [304] | 235 | MyButton *btn2 = new MyButton(this); | 
|---|
| [435] | 236 | btn2->setText(QString::fromUtf16((const ushort *)L"&\u041f\u0440\u0438\u0432\u0435\u0442 (also Ctrl+\u041f)")); | 
|---|
|  | 237 | btn2->setObjectName(QString::fromUtf16((const ushort *)L"\u041f\u0440\u0438\u0432\u0435\u0442")); | 
|---|
| [304] | 238 | btn2->move(20, 60); | 
|---|
| [231] | 239 |  | 
|---|
| [435] | 240 | connect(new QShortcut(QKeySequence(Qt::CTRL + 0x041F), btn2), | 
|---|
|  | 241 | SIGNAL(activated()), btn2, SLOT(animateClick())); | 
|---|
|  | 242 |  | 
|---|
| [304] | 243 | //      QComboBox *cb1 = new MyCombo(this); | 
|---|
|  | 244 | //      cb1->addItem(QLatin1String("Test 1")); | 
|---|
|  | 245 | //      cb1->addItem(QLatin1String("Test 2")); | 
|---|
| [231] | 246 |  | 
|---|
|  | 247 | //      QComboBox *cb2 = new MyCombo(this); | 
|---|
|  | 248 | //      cb2->addItem(QLatin1String("Test 3")); | 
|---|
|  | 249 | //      cb2->addItem(QLatin1String("Test 4")); | 
|---|
|  | 250 |  | 
|---|
| [435] | 251 | QVBoxLayout *mainLayout = new QVBoxLayout(); | 
|---|
|  | 252 | mainLayout->addWidget(btn1); | 
|---|
|  | 253 | mainLayout->addWidget(btn2); | 
|---|
| [304] | 254 | //      mainLayout->addWidget(cb1); | 
|---|
| [231] | 255 | //      mainLayout->addWidget(cb2); | 
|---|
|  | 256 |  | 
|---|
| [435] | 257 | setLayout(mainLayout); | 
|---|
| [311] | 258 | #endif | 
|---|
| [304] | 259 |  | 
|---|
| [341] | 260 | #if 0 | 
|---|
| [311] | 261 | QMenuBar *mb = new QMenuBar(this); | 
|---|
|  | 262 |  | 
|---|
|  | 263 | QMenu *menu = new QMenu(mb); | 
|---|
|  | 264 | menu->setTitle ("Menu &1"); | 
|---|
|  | 265 | menu->addAction(QLatin1String("Action &1")); | 
|---|
|  | 266 | menu->addAction(QLatin1String("Action &2")); | 
|---|
|  | 267 | mb->addMenu(menu); | 
|---|
|  | 268 |  | 
|---|
|  | 269 | menu = new QMenu(mb); | 
|---|
|  | 270 | menu->setTitle ("Menu &2"); | 
|---|
|  | 271 | menu->addAction(QLatin1String("Action &1")); | 
|---|
|  | 272 | menu->addAction(QLatin1String("Action &2")); | 
|---|
|  | 273 | mb->addMenu(menu); | 
|---|
|  | 274 |  | 
|---|
|  | 275 | menu = new QMenu(mb); | 
|---|
|  | 276 | menu->setTitle ("Menu &3"); | 
|---|
|  | 277 | menu->addAction(QLatin1String("Action &1")); | 
|---|
|  | 278 | menu->addAction(QLatin1String("Action &2")); | 
|---|
|  | 279 | mb->addMenu(menu); | 
|---|
|  | 280 | #endif | 
|---|
|  | 281 |  | 
|---|
| [304] | 282 | #if 0 | 
|---|
|  | 283 | new MyChild(this); | 
|---|
|  | 284 | #endif | 
|---|
|  | 285 |  | 
|---|
| [231] | 286 | }; | 
|---|
|  | 287 |  | 
|---|
| [368] | 288 | #if 0 | 
|---|
| [435] | 289 | void closeEvent(QCloseEvent *aE) | 
|---|
|  | 290 | { | 
|---|
|  | 291 | QMessageBox::warning(this, QLatin1String("Close"), | 
|---|
|  | 292 | QLatin1String("Somebody asked us to terminate")); | 
|---|
|  | 293 | aE->accept(); | 
|---|
|  | 294 | } | 
|---|
|  | 295 | #endif | 
|---|
|  | 296 |  | 
|---|
|  | 297 | #if 0 | 
|---|
| [231] | 298 | void paintEvent(QPaintEvent *aE) | 
|---|
|  | 299 | { | 
|---|
|  | 300 | qDebug() << __FUNCTION__ <<": " << aE->rect(); | 
|---|
|  | 301 |  | 
|---|
|  | 302 | QPainter p(this); | 
|---|
| [346] | 303 | #if 0 | 
|---|
|  | 304 | // simple QPainter test | 
|---|
|  | 305 |  | 
|---|
| [231] | 306 | p.setRenderHint(QPainter::Antialiasing); | 
|---|
|  | 307 |  | 
|---|
| [304] | 308 | p.fillRect(0, 0, 20, 20, mPressed % 2 ? Qt::red : Qt::green); | 
|---|
| [231] | 309 |  | 
|---|
|  | 310 | p.setPen(Qt::black); | 
|---|
|  | 311 | p.drawEllipse(10, 10, 10, 10); | 
|---|
|  | 312 |  | 
|---|
|  | 313 | //p.setFont(QFont("Arial", 12)); | 
|---|
|  | 314 | p.drawText(10, 30, QLatin1String("ABC")); | 
|---|
| [346] | 315 | #endif | 
|---|
| [368] | 316 | #if 0 | 
|---|
| [346] | 317 | // simple QClipboard image test | 
|---|
|  | 318 |  | 
|---|
|  | 319 | const QMimeData *data = QApplication::clipboard()->mimeData(); | 
|---|
|  | 320 | if (data && data->hasImage()){ | 
|---|
|  | 321 | QImage img = qvariant_cast<QImage>(data->imageData()); | 
|---|
|  | 322 | p.drawImage(0, 0, img); | 
|---|
|  | 323 | } | 
|---|
|  | 324 | #endif | 
|---|
| [231] | 325 | } | 
|---|
|  | 326 | #endif | 
|---|
|  | 327 |  | 
|---|
|  | 328 | #if 0 | 
|---|
|  | 329 | void resizeEvent(QResizeEvent *aE) | 
|---|
|  | 330 | { | 
|---|
|  | 331 | qDebug() << __FUNCTION__ << ": g" << geometry() << "fg" << frameGeometry() | 
|---|
|  | 332 | << "sz" << aE->size() << "old" << aE->oldSize(); | 
|---|
|  | 333 | } | 
|---|
|  | 334 |  | 
|---|
|  | 335 | void moveEvent(QMoveEvent *aE) | 
|---|
|  | 336 | { | 
|---|
|  | 337 | qDebug() << __FUNCTION__ << ": g" << geometry() << "fg" << frameGeometry() | 
|---|
|  | 338 | << "pos" << aE->pos() << "old" << aE->oldPos(); | 
|---|
|  | 339 | } | 
|---|
|  | 340 | #endif | 
|---|
|  | 341 |  | 
|---|
|  | 342 | #if 0 | 
|---|
|  | 343 | void focusInEvent(QFocusEvent *aE) | 
|---|
|  | 344 | { | 
|---|
| [611] | 345 | qDebug() << this << __FUNCTION__ << ": reason" << aE->reason(); | 
|---|
| [304] | 346 | QWidget::focusInEvent(aE); | 
|---|
| [231] | 347 | } | 
|---|
|  | 348 |  | 
|---|
|  | 349 | void focusOutEvent(QFocusEvent *aE) | 
|---|
|  | 350 | { | 
|---|
| [611] | 351 | qDebug() << this << __FUNCTION__ << ": reason" << aE->reason(); | 
|---|
| [304] | 352 | QWidget::focusOutEvent(aE); | 
|---|
| [231] | 353 | } | 
|---|
|  | 354 | #endif | 
|---|
|  | 355 |  | 
|---|
|  | 356 | #if 0 | 
|---|
|  | 357 | void changeEvent(QEvent *aE) | 
|---|
|  | 358 | { | 
|---|
|  | 359 | switch (aE->type()) { | 
|---|
|  | 360 | case QEvent::WindowStateChange: { | 
|---|
|  | 361 | QWindowStateChangeEvent *e2 = (QWindowStateChangeEvent *)aE; | 
|---|
|  | 362 | qDebug().nospace() << __FUNCTION__ << ": QWindowStateChangeEvent(" << | 
|---|
|  | 363 | e2->oldState() << "->" << windowState() << ")"; | 
|---|
|  | 364 | break; | 
|---|
|  | 365 | } | 
|---|
|  | 366 | default: | 
|---|
|  | 367 | break; | 
|---|
|  | 368 | } | 
|---|
|  | 369 | } | 
|---|
|  | 370 | #endif | 
|---|
|  | 371 |  | 
|---|
| [481] | 372 | #if 0 | 
|---|
| [231] | 373 | void keyPressEvent(QKeyEvent *aE) | 
|---|
|  | 374 | { | 
|---|
| [611] | 375 | qDebug() << __FUNCTION__ << ": cnt" << aE->count() | 
|---|
| [231] | 376 | << "rep" << aE->isAutoRepeat() | 
|---|
| [611] | 377 | << "key" << qDebugFmtHex(aE->key()) | 
|---|
|  | 378 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 379 | << "text" << aE->text() | 
|---|
| [611] | 380 | << qDebugFmtHex((aE->text().isEmpty() ? 0 : | 
|---|
|  | 381 | aE->text()[0].unicode())); | 
|---|
| [231] | 382 | } | 
|---|
|  | 383 |  | 
|---|
|  | 384 | void keyReleaseEvent(QKeyEvent *aE) | 
|---|
|  | 385 | { | 
|---|
|  | 386 | qDebug() << __FUNCTION__ << ": cnt" << aE->count() | 
|---|
|  | 387 | << "rep" << aE->isAutoRepeat() | 
|---|
| [611] | 388 | << "key" << qDebugFmtHex(aE->key()) | 
|---|
|  | 389 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 390 | << "text" << aE->text() | 
|---|
| [611] | 391 | << qDebugFmtHex((aE->text().isEmpty() ? 0 : | 
|---|
|  | 392 | aE->text()[0].unicode())); | 
|---|
| [231] | 393 | } | 
|---|
|  | 394 | #endif | 
|---|
|  | 395 |  | 
|---|
| [488] | 396 | #if 0 | 
|---|
| [481] | 397 | // QCursor shape test | 
|---|
|  | 398 | void mousePressEvent(QMouseEvent *aE) | 
|---|
|  | 399 | { | 
|---|
|  | 400 | static int shape = 0; | 
|---|
|  | 401 | if (aE->button() == Qt::LeftButton) | 
|---|
|  | 402 | ++shape; | 
|---|
|  | 403 | else | 
|---|
|  | 404 | --shape; | 
|---|
|  | 405 | shape = (Qt::LastCursor + 1 + shape) % (Qt::LastCursor + 1); | 
|---|
|  | 406 | setCursor(QCursor((Qt::CursorShape)shape)); | 
|---|
|  | 407 | } | 
|---|
|  | 408 | #endif | 
|---|
|  | 409 |  | 
|---|
| [231] | 410 | #if 0 | 
|---|
| [304] | 411 | void mousePressEvent(QMouseEvent *aE) | 
|---|
| [231] | 412 | { | 
|---|
|  | 413 | qDebug() << __FUNCTION__ << ": btn" << aE->button() | 
|---|
| [611] | 414 | << "btns" << qDebugFmtHex(aE->buttons()) | 
|---|
|  | 415 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 416 | << "gpos" << aE->globalPos() << "pos" << aE->pos(); | 
|---|
| [304] | 417 |  | 
|---|
|  | 418 | ++mPressed; | 
|---|
|  | 419 | update(); | 
|---|
| [231] | 420 | } | 
|---|
|  | 421 |  | 
|---|
| [304] | 422 | void mouseReleaseEvent(QMouseEvent *aE) | 
|---|
| [231] | 423 | { | 
|---|
|  | 424 | qDebug() << __FUNCTION__ << ": btn" << aE->button() | 
|---|
| [611] | 425 | << "btns" << qDebugFmtHex(aE->buttons()) | 
|---|
|  | 426 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 427 | << "gpos" << aE->globalPos() << "pos" << aE->pos(); | 
|---|
|  | 428 | } | 
|---|
|  | 429 |  | 
|---|
| [304] | 430 | void mouseMoveEvent(QMouseEvent *aE) | 
|---|
| [231] | 431 | { | 
|---|
|  | 432 | qDebug() << __FUNCTION__ << ": btn" << aE->button() | 
|---|
| [611] | 433 | << "btns" << qDebugFmtHex(aE->buttons()) | 
|---|
|  | 434 | << "mods" << qDebugFmtHex(aE->modifiers()) | 
|---|
| [231] | 435 | << "gpos" << aE->globalPos() << "pos" << aE->pos(); | 
|---|
|  | 436 | } | 
|---|
|  | 437 | #endif | 
|---|
|  | 438 |  | 
|---|
|  | 439 | #if 0 | 
|---|
|  | 440 | virtual void enterEvent(QEvent *event) | 
|---|
|  | 441 | { | 
|---|
|  | 442 | qDebug() << __FUNCTION__ << ":"; | 
|---|
|  | 443 | } | 
|---|
|  | 444 |  | 
|---|
|  | 445 | virtual void leaveEvent(QEvent *event) | 
|---|
|  | 446 | { | 
|---|
|  | 447 | qDebug() << __FUNCTION__ << ":"; | 
|---|
|  | 448 | } | 
|---|
|  | 449 | #endif | 
|---|
|  | 450 |  | 
|---|
|  | 451 | #if 0 | 
|---|
|  | 452 | void contextMenuEvent(QContextMenuEvent *aE) | 
|---|
|  | 453 | { | 
|---|
|  | 454 | QMenu menu; | 
|---|
|  | 455 | menu.addAction(QLatin1String("Action &1")); | 
|---|
|  | 456 | menu.addAction(QLatin1String("Action &2")); | 
|---|
|  | 457 | menu.exec(aE->globalPos()); | 
|---|
|  | 458 | } | 
|---|
|  | 459 | #endif | 
|---|
|  | 460 |  | 
|---|
|  | 461 | #if 0 | 
|---|
|  | 462 | void timerEvent(QTimerEvent *aE) | 
|---|
|  | 463 | { | 
|---|
|  | 464 | qDebug() << __FUNCTION__ << ": id" << aE->timerId(); | 
|---|
|  | 465 | } | 
|---|
|  | 466 | #endif | 
|---|
| [304] | 467 |  | 
|---|
| [499] | 468 | bool event(QEvent *aE) | 
|---|
|  | 469 | { | 
|---|
|  | 470 | switch (aE->type()) | 
|---|
|  | 471 | { | 
|---|
| [501] | 472 | #if 0 | 
|---|
| [499] | 473 | case QEvent::Enter: | 
|---|
|  | 474 | qDebug() << this << "Enter"; | 
|---|
|  | 475 | break; | 
|---|
|  | 476 | case QEvent::Leave: | 
|---|
|  | 477 | qDebug() << this << "Leave"; | 
|---|
|  | 478 | break; | 
|---|
|  | 479 | case QEvent::NonClientAreaMouseMove: | 
|---|
|  | 480 | case QEvent::NonClientAreaMouseButtonPress: | 
|---|
|  | 481 | case QEvent::NonClientAreaMouseButtonRelease: | 
|---|
|  | 482 | case QEvent::NonClientAreaMouseButtonDblClick: { | 
|---|
|  | 483 | QMouseEvent *me = static_cast<QMouseEvent*>(aE); | 
|---|
|  | 484 | qDebug() << this << aE->type() << ": btn" << me->button() | 
|---|
| [611] | 485 | << "btns" << qDebugFmtHex(me->buttons()) | 
|---|
|  | 486 | << "mods" << qDebugFmtHex(me->modifiers()) | 
|---|
| [499] | 487 | << "gpos" << me->globalPos() << "pos" << me->pos(); | 
|---|
|  | 488 | break; | 
|---|
|  | 489 | } | 
|---|
|  | 490 | #endif | 
|---|
|  | 491 | default: | 
|---|
|  | 492 | break; | 
|---|
|  | 493 | } | 
|---|
|  | 494 |  | 
|---|
|  | 495 | return QWidget::event(aE); | 
|---|
|  | 496 | } | 
|---|
|  | 497 |  | 
|---|
| [304] | 498 | private: | 
|---|
|  | 499 |  | 
|---|
|  | 500 | int mPressed; | 
|---|
| [231] | 501 | }; | 
|---|
|  | 502 |  | 
|---|
| [351] | 503 | void testCodec(const char *title, const QString &sample, QTextCodec *codec) | 
|---|
|  | 504 | { | 
|---|
|  | 505 | // test console output | 
|---|
|  | 506 |  | 
|---|
|  | 507 | printf("%s : Unicode (source) : ", title); | 
|---|
|  | 508 | foreach (QChar ch, sample) | 
|---|
|  | 509 | printf("%hX ", ch.unicode()); | 
|---|
|  | 510 | printf("\n"); | 
|---|
|  | 511 |  | 
|---|
|  | 512 | QByteArray eightbit = codec->fromUnicode(sample); | 
|---|
|  | 513 | printf("%s : 8-bit (as is)    : %s\n", title, eightbit.data()); | 
|---|
|  | 514 |  | 
|---|
|  | 515 | QString sample2 = codec->toUnicode(eightbit); | 
|---|
|  | 516 | printf("%s : Unicode (result) : ", title); | 
|---|
|  | 517 | foreach (QChar ch, sample2) | 
|---|
|  | 518 | printf("%hX ", ch.unicode()); | 
|---|
|  | 519 | printf("\n"); | 
|---|
|  | 520 |  | 
|---|
|  | 521 | if (sample != sample2) | 
|---|
|  | 522 | qWarning() << "Source and resulting Unicode differ!"; | 
|---|
|  | 523 |  | 
|---|
|  | 524 | qWarning() << ""; | 
|---|
|  | 525 |  | 
|---|
|  | 526 | // test GUI output (both window title and window text) | 
|---|
|  | 527 |  | 
|---|
|  | 528 | QString combined = QString("%1 : %2").arg(QLatin1String(title), sample); | 
|---|
|  | 529 | QMessageBox mbox; | 
|---|
|  | 530 | mbox.setWindowTitle(combined); | 
|---|
|  | 531 | mbox.setText(combined); | 
|---|
|  | 532 | mbox.exec(); | 
|---|
|  | 533 | } | 
|---|
|  | 534 |  | 
|---|
| [231] | 535 | int main(int argc, char **argv) | 
|---|
|  | 536 | { | 
|---|
| [625] | 537 | #if 0 | 
|---|
| [341] | 538 | //////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 539 | // Text mode | 
|---|
|  | 540 |  | 
|---|
|  | 541 | QCoreApplication app(argc, argv); | 
|---|
|  | 542 |  | 
|---|
| [625] | 543 | #if 0 | 
|---|
| [536] | 544 | //-------------------------------------------------------------------------- | 
|---|
| [611] | 545 | // Simple QProcess test | 
|---|
|  | 546 | QProcess cmd; | 
|---|
|  | 547 | QStringList params; | 
|---|
|  | 548 | params << "/c" << "ver"; | 
|---|
|  | 549 | cmd.start("cmd", params, QIODevice::ReadOnly); | 
|---|
|  | 550 | cmd.waitForStarted(); | 
|---|
|  | 551 | cmd.waitForFinished(); | 
|---|
|  | 552 | PRINT_EXPR(cmd.readAll()); | 
|---|
|  | 553 | #endif | 
|---|
|  | 554 |  | 
|---|
|  | 555 | #if 0 | 
|---|
|  | 556 | //-------------------------------------------------------------------------- | 
|---|
| [536] | 557 | // QFileInfo test | 
|---|
|  | 558 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/src/corelib/global/qt_windows.h")).isExecutable()); | 
|---|
|  | 559 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/src/corelib/global/qt_os2.h")).isExecutable()); | 
|---|
|  | 560 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/configure.cmd")).isExecutable()); | 
|---|
|  | 561 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/configure.exe")).isExecutable()); | 
|---|
|  | 562 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/bin/qmake.exe")).isExecutable()); | 
|---|
|  | 563 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/bin/QtCore4.dll")).isExecutable()); | 
|---|
|  | 564 | PRINT_EXPR(QFileInfo(QLatin1String("../../qt4/bin")).isExecutable()); | 
|---|
|  | 565 | #endif | 
|---|
|  | 566 |  | 
|---|
| [368] | 567 | #if 0 | 
|---|
|  | 568 | //-------------------------------------------------------------------------- | 
|---|
|  | 569 | // QTextStream test | 
|---|
|  | 570 |  | 
|---|
|  | 571 | QFile file("widget.cpp"); | 
|---|
|  | 572 | file.open(QIODevice::ReadOnly); | 
|---|
|  | 573 | QTextStream text(&file); | 
|---|
|  | 574 | QString str = text.readAll(); | 
|---|
|  | 575 | file.close(); | 
|---|
|  | 576 | qWarning() << "Read" << str.length() << "chars from widget.cpp"; | 
|---|
|  | 577 | #endif | 
|---|
|  | 578 |  | 
|---|
|  | 579 | #if 0 | 
|---|
|  | 580 | //-------------------------------------------------------------------------- | 
|---|
|  | 581 | // absolute/relative path test | 
|---|
|  | 582 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("../aaa")); | 
|---|
|  | 583 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("aaa")); | 
|---|
|  | 584 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("/aaa")); | 
|---|
|  | 585 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("\\aaa")); | 
|---|
|  | 586 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("D:\\aaa")); | 
|---|
|  | 587 | qWarning() << "1" << QDir(QLatin1String("C:\\OS2")).absoluteFilePath(QLatin1String("D:aaa")); | 
|---|
|  | 588 |  | 
|---|
|  | 589 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("../aaa")); | 
|---|
|  | 590 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("aaa")); | 
|---|
|  | 591 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("/aaa")); | 
|---|
|  | 592 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("\\aaa")); | 
|---|
|  | 593 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("D:\\aaa")); | 
|---|
|  | 594 | qWarning() << "2" << QDir(QLatin1String(".")).absoluteFilePath(QLatin1String("D:aaa")); | 
|---|
|  | 595 |  | 
|---|
|  | 596 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("../aaa")); | 
|---|
|  | 597 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("aaa")); | 
|---|
|  | 598 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("/aaa")); | 
|---|
|  | 599 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("\\aaa")); | 
|---|
|  | 600 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("D:\\aaa")); | 
|---|
|  | 601 | qWarning() << "3" << QDir(QLatin1String("D:bbb")).absoluteFilePath(QLatin1String("D:aaa")); | 
|---|
|  | 602 |  | 
|---|
|  | 603 | qWarning() << "4" << QDir(QLatin1String("E:bbb")).absoluteFilePath(QLatin1String("D:aaa")); | 
|---|
|  | 604 | qWarning() << "4" << QDir(QLatin1String("E:bbb")).absoluteFilePath(QLatin1String("bbb")); | 
|---|
|  | 605 | qWarning() << "4" << QDir(QLatin1String("C:bbb")).absoluteFilePath(QLatin1String("bbb")); | 
|---|
|  | 606 | #endif | 
|---|
|  | 607 |  | 
|---|
| [380] | 608 | #if 0 | 
|---|
| [368] | 609 | //-------------------------------------------------------------------------- | 
|---|
|  | 610 | // QDir::mkdir/mkpath test | 
|---|
|  | 611 | PRINT_EXPR(QDir().mkdir("some_dir")); | 
|---|
|  | 612 | PRINT_EXPR(QFile::exists("some_dir")); | 
|---|
|  | 613 | PRINT_EXPR(QDir().rmdir("some_dir")); | 
|---|
|  | 614 |  | 
|---|
|  | 615 | PRINT_EXPR(QDir().mkdir("some_dir/subdir")); | 
|---|
|  | 616 | PRINT_EXPR(QFile::exists("some_dir/subdir")); | 
|---|
|  | 617 | PRINT_EXPR(QDir().rmdir("some_dir/subdir")); | 
|---|
|  | 618 |  | 
|---|
|  | 619 | PRINT_EXPR(QDir().mkpath("some_dir/subdir")); | 
|---|
|  | 620 | PRINT_EXPR(QFile::exists("some_dir/subdir")); | 
|---|
|  | 621 | PRINT_EXPR(QDir().rmpath("some_dir/subdir")); | 
|---|
|  | 622 |  | 
|---|
|  | 623 | PRINT_EXPR(QDir("C:/").mkpath("some_dir/subdir")); | 
|---|
|  | 624 | PRINT_EXPR(QFile::exists("C:/some_dir/subdir")); | 
|---|
|  | 625 | PRINT_EXPR(QDir("C:/").rmpath("some_dir/subdir")); | 
|---|
|  | 626 |  | 
|---|
|  | 627 | PRINT_EXPR(QDir("C:/").mkdir("/aaa")); | 
|---|
|  | 628 | PRINT_EXPR(QFile::exists("C:/aaa")); | 
|---|
|  | 629 | PRINT_EXPR(QDir("C:/").rmdir("/aaa")); | 
|---|
|  | 630 | #endif | 
|---|
|  | 631 |  | 
|---|
|  | 632 | #if 0 | 
|---|
|  | 633 | //-------------------------------------------------------------------------- | 
|---|
|  | 634 | // QLibraryInfo test | 
|---|
|  | 635 | qWarning() << "QLibraryInfo::buildKey :" << QLibraryInfo::buildKey(); | 
|---|
|  | 636 | qWarning() << "QLibraryInfo::licensedProducts :" << QLibraryInfo::licensedProducts(); | 
|---|
|  | 637 | qWarning() << "QLibraryInfo::licensee :" << QLibraryInfo::licensee(); | 
|---|
|  | 638 | #define PRINT_LOC(L) qWarning() << #L << ":" << QLibraryInfo::location(L) | 
|---|
|  | 639 | PRINT_LOC(QLibraryInfo::PrefixPath); | 
|---|
|  | 640 | PRINT_LOC(QLibraryInfo::DocumentationPath); | 
|---|
|  | 641 | PRINT_LOC(QLibraryInfo::HeadersPath); | 
|---|
|  | 642 | PRINT_LOC(QLibraryInfo::LibrariesPath); | 
|---|
|  | 643 | PRINT_LOC(QLibraryInfo::BinariesPath); | 
|---|
|  | 644 | PRINT_LOC(QLibraryInfo::PluginsPath); | 
|---|
|  | 645 | PRINT_LOC(QLibraryInfo::DataPath); | 
|---|
|  | 646 | PRINT_LOC(QLibraryInfo::TranslationsPath); | 
|---|
|  | 647 | PRINT_LOC(QLibraryInfo::SettingsPath); | 
|---|
|  | 648 | PRINT_LOC(QLibraryInfo::DemosPath); | 
|---|
|  | 649 | PRINT_LOC(QLibraryInfo::ExamplesPath); | 
|---|
|  | 650 | #undef PRINT_LOC | 
|---|
|  | 651 | #endif | 
|---|
|  | 652 |  | 
|---|
| [435] | 653 | #if 0 | 
|---|
| [426] | 654 | //-------------------------------------------------------------------------- | 
|---|
|  | 655 | // QSettings test | 
|---|
|  | 656 |  | 
|---|
|  | 657 | QSettings sysOrgSet(QSettings::IniFormat, QSettings::SystemScope, | 
|---|
|  | 658 | QLatin1String("MySoft")); | 
|---|
|  | 659 | QSettings sysAppSet(QSettings::IniFormat, QSettings::SystemScope, | 
|---|
|  | 660 | QLatin1String("MySoft"), QLatin1String("MyApp")); | 
|---|
|  | 661 | QSettings userOrgSet(QSettings::IniFormat, QSettings::UserScope, | 
|---|
|  | 662 | QLatin1String("MySoft")); | 
|---|
|  | 663 | QSettings userAppSet(QSettings::IniFormat, QSettings::UserScope, | 
|---|
|  | 664 | QLatin1String("MySoft"), QLatin1String("MyApp")); | 
|---|
|  | 665 |  | 
|---|
|  | 666 | QList<QSettings *> sets; | 
|---|
|  | 667 | sets << &sysOrgSet << &sysAppSet << &userOrgSet << &userAppSet; | 
|---|
|  | 668 |  | 
|---|
|  | 669 | foreach (QSettings *set, sets) { | 
|---|
|  | 670 | set->setValue("Time", QDateTime::currentDateTime()); | 
|---|
|  | 671 | } | 
|---|
|  | 672 |  | 
|---|
| [435] | 673 | qWarning() << "Modified Time key in MySoft/MyApp (system & user)"; | 
|---|
| [426] | 674 | #endif | 
|---|
|  | 675 |  | 
|---|
| [351] | 676 | #else | 
|---|
|  | 677 | //////////////////////////////////////////////////////////////////////////// | 
|---|
|  | 678 | // GUI | 
|---|
|  | 679 |  | 
|---|
|  | 680 | QApplication app(argc, argv); | 
|---|
| [380] | 681 | app.setQuitOnLastWindowClosed(true); | 
|---|
| [351] | 682 |  | 
|---|
| [625] | 683 | #if 1 | 
|---|
| [351] | 684 | //-------------------------------------------------------------------------- | 
|---|
|  | 685 | // locale test | 
|---|
|  | 686 |  | 
|---|
|  | 687 | QLocale locale = QLocale::system(); | 
|---|
|  | 688 |  | 
|---|
|  | 689 | qWarning() << "Library paths    :" << QApplication::libraryPaths(); | 
|---|
|  | 690 | qWarning() << ""; | 
|---|
| [341] | 691 | qWarning() << "Available codecs :\n" << QTextCodec::availableCodecs(); | 
|---|
|  | 692 | qWarning() << ""; | 
|---|
| [625] | 693 | qWarning() << "System locale    :" << locale.name(); | 
|---|
|  | 694 | qWarning() << ""; | 
|---|
| [341] | 695 | qWarning() << "Codec for locale :" << QTextCodec::codecForLocale()->name(); | 
|---|
|  | 696 | qWarning() << "         Aliases :" << QTextCodec::codecForLocale()->aliases(); | 
|---|
|  | 697 | qWarning() << ""; | 
|---|
| [351] | 698 | qWarning() << "Country for locale  :" << QLocale::countryToString(locale.country()) | 
|---|
|  | 699 | << "[" << locale.country() << "]"; | 
|---|
|  | 700 | qWarning() << "Language for locale :" << QLocale::languageToString(locale.language()) | 
|---|
|  | 701 | << "[" << locale.language() << "]"; | 
|---|
|  | 702 | qWarning() << ""; | 
|---|
| [625] | 703 | qWarning() << "Current date        :" << locale.toString(QDate::currentDate(), QLocale::ShortFormat); | 
|---|
|  | 704 | qWarning() << "Current date (long) :" << locale.toString(QDate::currentDate(), QLocale::LongFormat); | 
|---|
|  | 705 | qWarning() << "Current time        :" << locale.toString(QTime::currentTime(), QLocale::ShortFormat); | 
|---|
|  | 706 | qWarning() << "Current time (long) :" << locale.toString(QTime::currentTime(), QLocale::LongFormat); | 
|---|
|  | 707 | qWarning() << "Current date time   :" << locale.toString(QDateTime::currentDateTime(), QLocale::ShortFormat); | 
|---|
|  | 708 | qWarning() << "Current datetime (l):" << locale.toString(QDateTime::currentDateTime(), QLocale::LongFormat); | 
|---|
| [341] | 709 |  | 
|---|
| [351] | 710 | testCodec("First 3 months", | 
|---|
|  | 711 | QString("%1, %2, %3").arg(locale.standaloneMonthName(1), | 
|---|
|  | 712 | locale.standaloneMonthName(2), | 
|---|
|  | 713 | locale.standaloneMonthName(3)), | 
|---|
|  | 714 | QTextCodec::codecForLocale()); | 
|---|
|  | 715 | return 0; | 
|---|
|  | 716 | #endif | 
|---|
| [341] | 717 |  | 
|---|
| [501] | 718 | #if 0 | 
|---|
| [341] | 719 | QRect r = QApplication::desktop()->availableGeometry(); | 
|---|
| [231] | 720 | MyWidget widget; | 
|---|
|  | 721 | widget.resize(100, 100); | 
|---|
| [341] | 722 | widget.move(r.width() - 200, r.height() - 200); | 
|---|
| [231] | 723 |  | 
|---|
|  | 724 | widget.show(); | 
|---|
| [351] | 725 | #endif | 
|---|
| [304] | 726 |  | 
|---|
| [499] | 727 | #if 0 | 
|---|
| [488] | 728 | //-------------------------------------------------------------------------- | 
|---|
|  | 729 | // QDesktopServices test | 
|---|
|  | 730 | { | 
|---|
|  | 731 | for (int i = 0; i <= 10; ++i) { | 
|---|
|  | 732 | qWarning() << "StandardLocation" << i | 
|---|
|  | 733 | << QDesktopServices:: | 
|---|
|  | 734 | storageLocation((QDesktopServices::StandardLocation)i); | 
|---|
|  | 735 | } | 
|---|
|  | 736 |  | 
|---|
|  | 737 | PRINT_EXPR(QDesktopServices::openUrl(QUrl::fromLocalFile(QDir::currentPath()))); | 
|---|
|  | 738 | PRINT_EXPR(QDesktopServices::openUrl(QUrl("file:///C:/OS2/BITMAP/OCEAN.BMP"))); | 
|---|
|  | 739 | PRINT_EXPR(QDesktopServices::openUrl(QUrl("mailto:user@example.com"))); | 
|---|
|  | 740 | PRINT_EXPR(QDesktopServices::openUrl(QUrl("http://www.ru"))); | 
|---|
|  | 741 | } | 
|---|
|  | 742 | #endif | 
|---|
|  | 743 |  | 
|---|
| [536] | 744 | #if 0 | 
|---|
| [380] | 745 | //-------------------------------------------------------------------------- | 
|---|
|  | 746 | // QFontDialog test | 
|---|
| [231] | 747 | { | 
|---|
| [501] | 748 | int appFont1, appFont2; | 
|---|
|  | 749 |  | 
|---|
|  | 750 | PRINT_EXPR((appFont1 = QFontDatabase::addApplicationFont( | 
|---|
|  | 751 | QLatin1String("fonts/Earthqua.ttf")))); | 
|---|
|  | 752 |  | 
|---|
|  | 753 | QByteArray fontData; | 
|---|
|  | 754 | QFile fontFile(QLatin1String("fonts/NATIONFD.TTF")); | 
|---|
|  | 755 | if (fontFile.open(QIODevice::ReadOnly)) { | 
|---|
|  | 756 | fontData = fontFile.readAll(); | 
|---|
|  | 757 | fontFile.close(); | 
|---|
|  | 758 | } | 
|---|
|  | 759 | PRINT_EXPR((appFont2 = QFontDatabase::addApplicationFontFromData(fontData))); | 
|---|
|  | 760 |  | 
|---|
|  | 761 | PRINT_EXPR(QFontDatabase::applicationFontFamilies(appFont1)); | 
|---|
|  | 762 | PRINT_EXPR(QFontDatabase::applicationFontFamilies(appFont2)); | 
|---|
|  | 763 |  | 
|---|
| [231] | 764 | QFontDialog fntDlg; | 
|---|
|  | 765 | fntDlg.exec(); | 
|---|
| [304] | 766 |  | 
|---|
| [501] | 767 | PRINT_EXPR(QFontDatabase::removeApplicationFont(appFont1)); | 
|---|
|  | 768 | PRINT_EXPR(QFontDatabase::applicationFontFamilies(appFont1)); | 
|---|
|  | 769 |  | 
|---|
|  | 770 | fntDlg.exec(); | 
|---|
|  | 771 |  | 
|---|
| [231] | 772 | { | 
|---|
|  | 773 | QFont font("MyCoolFont"); | 
|---|
|  | 774 | QFontInfo info(font); | 
|---|
|  | 775 | qDebug() << info.family(); | 
|---|
|  | 776 | } | 
|---|
|  | 777 | } | 
|---|
|  | 778 | #endif | 
|---|
|  | 779 |  | 
|---|
| [435] | 780 | #if 0 | 
|---|
| [380] | 781 | //-------------------------------------------------------------------------- | 
|---|
|  | 782 | // QFileDialog test | 
|---|
|  | 783 | { | 
|---|
|  | 784 | QFileDialog dlg; | 
|---|
|  | 785 |  | 
|---|
|  | 786 | dlg.setFileMode(QFileDialog::ExistingFile); | 
|---|
|  | 787 | //dlg.setFilter(QDir::Dirs | QDir::Files | QDir::Drives); | 
|---|
| [625] | 788 | dlg.setNameFilter("*.exe;;*"); | 
|---|
| [380] | 789 | dlg.selectFile("mplayer.exe"); | 
|---|
|  | 790 | dlg.exec(); | 
|---|
|  | 791 |  | 
|---|
|  | 792 | //PRINT_EXPR(QFileDialog::getOpenFileName()); | 
|---|
|  | 793 | } | 
|---|
|  | 794 | #endif | 
|---|
|  | 795 |  | 
|---|
| [231] | 796 | #if 0 | 
|---|
| [300] | 797 | QSound snd2("C:/MMOS2/SOUNDS/DESKTOP/dsk_shut.wav"); | 
|---|
|  | 798 | snd2.setLoops(2); | 
|---|
|  | 799 | snd2.play(); | 
|---|
|  | 800 |  | 
|---|
|  | 801 | QSound snd1("C:/MMOS2/SOUNDS/DESKTOP/dsk_strt.wav"); | 
|---|
|  | 802 | snd1.setLoops(3); | 
|---|
|  | 803 | snd1.play(); | 
|---|
|  | 804 | #endif | 
|---|
|  | 805 |  | 
|---|
|  | 806 | #if 0 | 
|---|
| [231] | 807 | widget.startTimer(1000); | 
|---|
|  | 808 | widget.startTimer(2000); | 
|---|
|  | 809 | widget.startTimer(4000); | 
|---|
|  | 810 | #endif | 
|---|
|  | 811 |  | 
|---|
|  | 812 | #if 0 | 
|---|
|  | 813 | qDebug() << "------------- before min" << widget.geometry() << widget.frameGeometry(); | 
|---|
|  | 814 | widget.showMinimized(); | 
|---|
|  | 815 | qDebug() << "------------- after min" << widget.geometry() << widget.frameGeometry(); | 
|---|
|  | 816 | widget.move(100, 100); | 
|---|
|  | 817 | qDebug() << "------------- after move" << widget.geometry() << widget.frameGeometry(); | 
|---|
|  | 818 | widget.showNormal(); | 
|---|
|  | 819 | qDebug() << "------------- after norm" << widget.geometry() << widget.frameGeometry(); | 
|---|
|  | 820 | widget.showFullScreen(); | 
|---|
|  | 821 | qDebug() << "------------- after full" << widget.geometry() << widget.frameGeometry(); | 
|---|
|  | 822 | #endif | 
|---|
|  | 823 |  | 
|---|
| [501] | 824 | bool haveVisibleTops = false; | 
|---|
|  | 825 | foreach(QWidget *top, app.topLevelWidgets()) { | 
|---|
|  | 826 | if (top->isVisible()) { | 
|---|
|  | 827 | haveVisibleTops = true; | 
|---|
|  | 828 | break; | 
|---|
|  | 829 | } | 
|---|
|  | 830 | } | 
|---|
|  | 831 |  | 
|---|
|  | 832 | if (haveVisibleTops) | 
|---|
| [380] | 833 | return app.exec(); | 
|---|
|  | 834 |  | 
|---|
|  | 835 | return 0; | 
|---|
| [341] | 836 | #endif | 
|---|
| [231] | 837 | } | 
|---|
| [304] | 838 |  | 
|---|
|  | 839 | #include "widget.moc" | 
|---|