Changeset 1010


Ignore:
Timestamp:
Aug 19, 2011, 5:03:19 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

tests: embedded: Don't hide widgets in stack.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/embedded/embedded.cpp

    r1004 r1010  
     1#ifdef __OS2__
    12#include <os2.h>
     3#endif
    24
    35#include <QDebug>
     
    2830        layout->addWidget (stable);
    2931
    30         return stable->winId();
     32        WId id = stable->winId();
     33        qDebug() << "stable id" << qDebugHWND (id);
     34        return id;
    3135    }
    3236
     
    5559        /* menus */
    5660        {
    57             QMenu *actionsMenu = menuBar()->addMenu ("&Actions");
    5861            QAction *playAct = new QAction ("&Play", this);
    59             actionsMenu->addAction (playAct);
    60 
    6162            playAct->setShortcut (QKeySequence("Ctrl+P"));
    6263            playAct->setCheckable (true);
    6364            connect (playAct, SIGNAL (triggered(bool)), SLOT (playTriggered(bool)));
     65
     66            QAction *playListAct = new QAction ("Play&list", this);
     67            playListAct->setShortcut (QKeySequence("Ctrl+L"));
     68            playListAct->setCheckable (true);
     69            connect (playListAct, SIGNAL (triggered(bool)), SLOT (playListTriggered(bool)));
     70
     71            QMenu *actionsMenu = menuBar()->addMenu ("&Actions");
     72            actionsMenu->addAction (playAct);
     73            actionsMenu->addAction (playListAct);
    6474        }
    6575
     
    7585        stackCentralW = new QStackedWidget (main);
    7686
     87        // avoid hiding widgets when tossing the stack (just raise/lower)
     88        qobject_cast <QStackedLayout *> (stackCentralW->layout())
     89                ->setStackingMode (QStackedLayout::StackAll);
     90
    7791        bgWidget = new QLabel ("Background");
    7892        stackCentralW->addWidget (bgWidget);
     
    8498
    8599        mainLayout->insertWidget (2, new QLabel ("Controls"));
    86 
    87100    }
    88101
    89102    void timerEvent (QTimerEvent *)
    90103    {
     104        static int tickCount = 0;
     105        ++ tickCount;
     106
     107        if (tickCount == 5)
     108            resize (800, 600);
     109#ifdef __OS2__
    91110        if (id)
    92111        {
     
    97116            {
    98117                RECTL rcl;
    99     //            WinQueryWindowRect (hwnd, &rcl);
     118//                WinQueryWindowRect (hwnd, &rcl);
    100119
    101120                rcl.xLeft = 0;
     
    111130            }
    112131        }
     132#endif
    113133    }
    114134
     
    121141            stackCentralW->setCurrentWidget (videoWidget);
    122142            id = videoWidget->request();
    123 //            timerId = startTimer (1000);
     143            timerId = startTimer (1000);
    124144        }
    125145        else
     
    128148            id = 0;
    129149            killTimer (timerId);
    130 //            timerId = 0;
     150            timerId = 0;
    131151            stackCentralW->setCurrentWidget (bgWidget);
     152        }
     153    }
     154
     155    void playListTriggered (bool checked)
     156    {
     157        if (checked)
     158        {
     159            stackCentralW->setCurrentWidget (bgWidget);
     160        }
     161        else
     162        {
     163            stackCentralW->setCurrentWidget (videoWidget);
    132164        }
    133165    }
Note: See TracChangeset for help on using the changeset viewer.