Changeset 1004 for tests/embedded


Ignore:
Timestamp:
Aug 18, 2011, 2:39:17 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

tests: embedded: Reproduce #203 behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/embedded/embedded.cpp

    r1003 r1004  
    4646class MainWindow : public QMainWindow
    4747{
     48    Q_OBJECT
     49
    4850public:
    4951
    5052    MainWindow()
     53        : id (0), timerId (0)
    5154    {
     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
    5268        QWidget *main = new QWidget();
    5369        setCentralWidget (main);
     
    5773        mainLayout->setMargin (0);
    5874
    59         QStackedWidget *stackCentralW = new QStackedWidget (main);
     75        stackCentralW = new QStackedWidget (main);
    6076
    61         stackCentralW->addWidget (new QLabel ("Background"));
     77        bgWidget = new QLabel ("Background");
     78        stackCentralW->addWidget (bgWidget);
    6279
    6380        videoWidget = new VideoWidget();
     
    6885        mainLayout->insertWidget (2, new QLabel ("Controls"));
    6986
    70         stackCentralW->setCurrentWidget (videoWidget);
    71 
    72         id = videoWidget->request();
    73 
    74         startTimer (1000);
    7587    }
    7688
    7789    void timerEvent (QTimerEvent *)
    7890    {
    79         qDebug() << "*** timer" << qDebugFmtHex (id);
    80         HWND hwnd = id;
    81         HPS hps = WinGetPS (hwnd);
    82         if (hps)
     91        if (id)
    8392        {
    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);
    86100
    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();
    91105
    92             qDebug() << rcl.xRight << rcl.yTop;
     106                qDebug() << rcl.xRight << rcl.yTop;
    93107
    94             WinDrawBorder (hps, &rcl, 3, 3, CLR_RED, CLR_DARKGREEN, DB_INTERIOR);
     108                WinDrawBorder (hps, &rcl, 3, 3, CLR_RED, CLR_DARKGREEN, DB_INTERIOR);
    95109
    96             WinReleasePS (hps);
     110                WinReleasePS (hps);
     111            }
    97112        }
    98113    }
    99114
     115public 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
     135public:
     136
     137    QStackedWidget *stackCentralW;
     138    QLabel *bgWidget;
    100139    VideoWidget *videoWidget;
    101140    WId id;
     141    int timerId;
    102142};
    103143
     
    111151    return app.exec();
    112152}
     153
     154#include "embedded.moc"
Note: See TracChangeset for help on using the changeset viewer.