Changeset 55951 in webkit


Ignore:
Timestamp:
Mar 13, 2010 12:14:24 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-13 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

Add a "Toggle FullScreen" option to QtLauncher Menu.

[Qt] QtLauncher needs an option to toggle FullScreen Mode
https://bugs.webkit.org/show_bug.cgi?id=35755

  • QtLauncher/main.cpp: (LauncherWindow::init): (LauncherWindow::eventFilter): (LauncherWindow::initializeView): (LauncherWindow::toggleFullScreenMode): (LauncherWindow::createChrome):
Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r55940 r55951  
     12010-03-13  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Add a "Toggle FullScreen" option to QtLauncher Menu.
     6
     7        [Qt] QtLauncher needs an option to toggle FullScreen Mode
     8        https://bugs.webkit.org/show_bug.cgi?id=35755
     9
     10        * QtLauncher/main.cpp:
     11        (LauncherWindow::init):
     12        (LauncherWindow::eventFilter):
     13        (LauncherWindow::initializeView):
     14        (LauncherWindow::toggleFullScreenMode):
     15        (LauncherWindow::createChrome):
     16
    1172010-03-12  Dirk Pranke  <dpranke@chromium.org>
    218
  • trunk/WebKitTools/QtLauncher/main.cpp

    r55610 r55951  
    7171#endif
    7272
    73 
     73static const int gExitClickArea = 80;
    7474static bool gUseGraphicsView = false;
    7575static bool gUseCompositing = false;
     
    9191#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    9292    void sendTouchEvent();
     93#endif
     94
    9395    bool eventFilter(QObject* obj, QEvent* event);
    94 #endif
    9596
    9697protected slots:
     
    120121    void initializeView(bool useGraphicsView = false);
    121122    void toggleSpatialNavigation(bool b);
     123    void toggleFullScreenMode(bool enable);
    122124
    123125public slots:
    124126    void newWindow();
    125127    void cloneWindow();
     128
     129signals:
     130    void enteredFullScreenMode(bool on);
    126131
    127132private:
     
    184189
    185190#if defined(Q_WS_S60)
    186     showMaximized();
     191    setWindowState(Qt::WindowMaximized);
    187192#else
     193    setWindowState(Qt::WindowNoState);
    188194    resize(800, 600);
    189195#endif
     
    195201    connect(page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
    196202            this, SLOT(showLinkHover(const QString&, const QString&)));
     203    connect(this, SIGNAL(enteredFullScreenMode(bool)), this, SLOT(toggleFullScreenMode(bool)));
    197204
    198205    if (!gInspectorUrl.isEmpty())
     
    305312        m_touchPoints.removeAt(1);
    306313}
     314#endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    307315
    308316bool LauncherWindow::eventFilter(QObject* obj, QEvent* event)
    309317{
     318    // If click pos is the bottom right corner (square with size defined by gExitClickArea)
     319    // and the window is on FullScreen, the window must return to its original state.
     320    if (event->type() == QEvent::MouseButtonRelease) {
     321        QMouseEvent* ev = static_cast<QMouseEvent*>(event);
     322        if (windowState() == Qt::WindowFullScreen
     323            && ev->pos().x() > (width() - gExitClickArea)
     324            && ev->pos().y() > (height() - gExitClickArea)) {
     325
     326            emit enteredFullScreenMode(false);
     327        }
     328    }
     329
     330#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    310331    if (!m_touchMocking || obj != m_view)
    311332        return QObject::eventFilter(obj, event);
     
    369390        }
    370391    }
     392#endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
     393
    371394    return false;
    372395}
    373 #endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    374396
    375397void LauncherWindow::loadStarted()
     
    518540        WebViewTraditional* view = new WebViewTraditional(splitter);
    519541        view->setPage(page());
     542
     543        view->installEventFilter(this);
     544
    520545        m_view = view;
    521546    } else {
     
    529554            connect(m_flipYAnimated, SIGNAL(triggered()), view, SLOT(animatedYFlip()));
    530555
     556        // The implementation of QAbstractScrollArea::eventFilter makes us need
     557        // to install the event filter on the viewport of a QGraphicsView.
     558        view->viewport()->installEventFilter(this);
     559
    531560        m_view = view;
    532561    }
    533562
    534563#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
    535     m_view->installEventFilter(this);
    536564    m_touchMocking = false;
    537565#endif
     
    541569{
    542570    page()->settings()->setAttribute(QWebSettings::SpatialNavigationEnabled, b);
     571}
     572
     573void LauncherWindow::toggleFullScreenMode(bool enable)
     574{
     575    if (enable)
     576        setWindowState(Qt::WindowFullScreen);
     577    else {
     578#if defined(Q_WS_S60)
     579        setWindowState(Qt::WindowMaximized);
     580#else
     581        setWindowState(Qt::WindowNoState);
     582#endif
     583    }
    543584}
    544585
     
    607648    resetZoom->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
    608649
     650    QMenu* windowMenu = menuBar()->addMenu("&Window");
     651    QAction* toggleFullScreen = windowMenu->addAction("Toggle FullScreen", this, SIGNAL(enteredFullScreenMode(bool)));
     652    toggleFullScreen->setCheckable(true);
     653    toggleFullScreen->setChecked(false);
     654
     655    // when exit fullscreen mode by clicking on the exit area (bottom right corner) we must
     656    // uncheck the Toggle FullScreen action
     657    toggleFullScreen->connect(this, SIGNAL(enteredFullScreenMode(bool)), SLOT(setChecked(bool)));
     658
    609659    QMenu* toolsMenu = menuBar()->addMenu("&Develop");
    610660    toolsMenu->addAction("Select Elements...", this, SLOT(selectElements()));
Note: See TracChangeset for help on using the changeset viewer.