- Timestamp:
- Aug 18, 2011, 2:39:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/embedded/embedded.cpp
r1003 r1004 46 46 class MainWindow : public QMainWindow 47 47 { 48 Q_OBJECT 49 48 50 public: 49 51 50 52 MainWindow() 53 : id (0), timerId (0) 51 54 { 55 /* menus */ 56 { 57 QMenu *actionsMenu = menuBar()->addMenu ("&Actions"); 58 QAction *playAct = new QAction ("&Play", this); 59 actionsMenu->addAction (playAct); 60 61 playAct->setShortcut (QKeySequence("Ctrl+P")); 62 playAct->setCheckable (true); 63 connect (playAct, SIGNAL (triggered(bool)), SLOT (playTriggered(bool))); 64 } 65 66 /* this mimics VLC behavior */ 67 52 68 QWidget *main = new QWidget(); 53 69 setCentralWidget (main); … … 57 73 mainLayout->setMargin (0); 58 74 59 QStackedWidget *stackCentralW = new QStackedWidget (main);75 stackCentralW = new QStackedWidget (main); 60 76 61 stackCentralW->addWidget (new QLabel ("Background")); 77 bgWidget = new QLabel ("Background"); 78 stackCentralW->addWidget (bgWidget); 62 79 63 80 videoWidget = new VideoWidget(); … … 68 85 mainLayout->insertWidget (2, new QLabel ("Controls")); 69 86 70 stackCentralW->setCurrentWidget (videoWidget);71 72 id = videoWidget->request();73 74 startTimer (1000);75 87 } 76 88 77 89 void timerEvent (QTimerEvent *) 78 90 { 79 qDebug() << "*** timer" << qDebugFmtHex (id); 80 HWND hwnd = id; 81 HPS hps = WinGetPS (hwnd); 82 if (hps) 91 if (id) 83 92 { 84 RECTL rcl; 85 // WinQueryWindowRect (hwnd, &rcl); 93 qDebug() << "window handle" << qDebugFmtHex (id); 94 HWND hwnd = id; 95 HPS hps = WinGetPS (hwnd); 96 if (hps) 97 { 98 RECTL rcl; 99 // WinQueryWindowRect (hwnd, &rcl); 86 100 87 rcl.xLeft = 0;88 rcl.yBottom = 0;89 rcl.xRight = videoWidget->size().width();90 rcl.yTop = videoWidget->size().height();101 rcl.xLeft = 0; 102 rcl.yBottom = 0; 103 rcl.xRight = videoWidget->size().width(); 104 rcl.yTop = videoWidget->size().height(); 91 105 92 qDebug() << rcl.xRight << rcl.yTop;106 qDebug() << rcl.xRight << rcl.yTop; 93 107 94 WinDrawBorder (hps, &rcl, 3, 3, CLR_RED, CLR_DARKGREEN, DB_INTERIOR);108 WinDrawBorder (hps, &rcl, 3, 3, CLR_RED, CLR_DARKGREEN, DB_INTERIOR); 95 109 96 WinReleasePS (hps); 110 WinReleasePS (hps); 111 } 97 112 } 98 113 } 99 114 115 public slots: 116 117 void playTriggered (bool checked) 118 { 119 if (checked) 120 { 121 stackCentralW->setCurrentWidget (videoWidget); 122 id = videoWidget->request(); 123 // timerId = startTimer (1000); 124 } 125 else 126 { 127 videoWidget->release(); 128 id = 0; 129 killTimer (timerId); 130 // timerId = 0; 131 stackCentralW->setCurrentWidget (bgWidget); 132 } 133 } 134 135 public: 136 137 QStackedWidget *stackCentralW; 138 QLabel *bgWidget; 100 139 VideoWidget *videoWidget; 101 140 WId id; 141 int timerId; 102 142 }; 103 143 … … 111 151 return app.exec(); 112 152 } 153 154 #include "embedded.moc"
Note:
See TracChangeset
for help on using the changeset viewer.