IOT dashboard: Use cube effect
This commit is contained in:
parent
8bbc14b02b
commit
d3e34f5f97
64
examples/iotdashboard/MainItem.cpp
Normal file
64
examples/iotdashboard/MainItem.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "MainItem.h"
|
||||
|
||||
#include "MainContent.h"
|
||||
#include "MenuBar.h"
|
||||
|
||||
#include <QskGesture.h>
|
||||
#include <QskEvent.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskStackBox.h>
|
||||
|
||||
#include <QQuickFramebufferObject>
|
||||
#include <QGuiApplication>
|
||||
#include <QQuickWindow>
|
||||
|
||||
MainItem::MainItem( QQuickItem* parent )
|
||||
: QskControl( parent )
|
||||
, m_cube( new QskStackBox( false, this ) )
|
||||
, m_mainLayout( new QskLinearBox( Qt::Horizontal, m_cube ) )
|
||||
{
|
||||
setAutoLayoutChildren( true );
|
||||
setAcceptedMouseButtons( Qt::LeftButton );
|
||||
setFiltersChildMouseEvents( true );
|
||||
|
||||
m_panRecognizer.setOrientations( Qt::Horizontal );
|
||||
m_panRecognizer.setMinDistance( 50 );
|
||||
m_panRecognizer.setWatchedItem( this );
|
||||
|
||||
m_mainLayout->setSpacing( 0 );
|
||||
|
||||
(void) new MenuBar( m_mainLayout );
|
||||
(void) new MainContent( m_mainLayout );
|
||||
|
||||
m_cube->addItem( m_mainLayout );
|
||||
}
|
||||
|
||||
void MainItem::gestureEvent( QskGestureEvent* event )
|
||||
{
|
||||
if( event->gesture()->state() == QskGesture::Finished )
|
||||
{
|
||||
// ### here start animation
|
||||
}
|
||||
}
|
||||
|
||||
bool MainItem::gestureFilter( QQuickItem* item, QEvent* event )
|
||||
{
|
||||
auto& recognizer = m_panRecognizer;
|
||||
|
||||
if( event->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
const auto mouseEvent = static_cast< QMouseEvent* >( event );
|
||||
|
||||
if( ( item != this ) || ( recognizer.timeout() < 0 ) )
|
||||
{
|
||||
if( recognizer.hasProcessedBefore( mouseEvent ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
recognizer.setTimeout( ( item == this ) ? -1 : 100 );
|
||||
}
|
||||
|
||||
return recognizer.processEvent( item, event, false );
|
||||
}
|
27
examples/iotdashboard/MainItem.h
Normal file
27
examples/iotdashboard/MainItem.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <QskControl.h>
|
||||
#include <QskPanGestureRecognizer.h>
|
||||
|
||||
#include <QQuickWindow>
|
||||
|
||||
class QskBox;
|
||||
class QskLinearBox;
|
||||
class QskStackBox;
|
||||
|
||||
class MainItem : public QskControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainItem( QQuickItem* parent = nullptr );
|
||||
|
||||
protected:
|
||||
bool gestureFilter( QQuickItem*, QEvent* ) override final;
|
||||
void gestureEvent( QskGestureEvent* ) override final;
|
||||
|
||||
private:
|
||||
QskStackBox* m_cube;
|
||||
QskLinearBox* m_mainLayout;
|
||||
QskPanGestureRecognizer m_panRecognizer;
|
||||
};
|
@ -3,9 +3,8 @@
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MainItem.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MainContent.h"
|
||||
#include "MenuBar.h"
|
||||
|
||||
#include <QskLinearBox.h>
|
||||
|
||||
@ -14,11 +13,7 @@ MainWindow::MainWindow()
|
||||
setPreferredSize( QSize( 1024, 600 ) );
|
||||
setTitle( "IOT dashboard" );
|
||||
|
||||
auto layout = new QskLinearBox( Qt::Horizontal, contentItem() );
|
||||
layout->setSpacing( 0 );
|
||||
|
||||
(void) new MenuBar( layout );
|
||||
(void) new MainContent( layout );
|
||||
(void) new MainItem( contentItem() );
|
||||
}
|
||||
|
||||
#include "moc_MainWindow.cpp"
|
||||
|
@ -14,6 +14,7 @@ SOURCES += \
|
||||
LightDisplaySkinlet.cpp \
|
||||
LightDisplay.cpp \
|
||||
MainContent.cpp \
|
||||
MainItem.cpp \
|
||||
MenuBar.cpp \
|
||||
MyDevices.cpp \
|
||||
PieChart.cpp \
|
||||
@ -45,6 +46,7 @@ HEADERS += \
|
||||
LightDisplaySkinlet.h \
|
||||
LightDisplay.h \
|
||||
MainContent.h \
|
||||
MainItem.h \
|
||||
MainWindow.h \
|
||||
MenuBar.h \
|
||||
MyDevices.h \
|
||||
|
Loading…
x
Reference in New Issue
Block a user