wip
This commit is contained in:
parent
8c2093d151
commit
4d7db7c479
@ -18,6 +18,7 @@
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskSwitchButton.h>
|
||||
#include <QskPushButton.h>
|
||||
#include <QskMenu.h>
|
||||
#include <QskWindow.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
@ -42,6 +43,39 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
class MenuButton : public QskPushButton
|
||||
{
|
||||
public:
|
||||
MenuButton( const QString& text, QQuickItem* parent = nullptr )
|
||||
: QskPushButton( text, parent )
|
||||
{
|
||||
setFlat( true ); // until we have the section bit in QskAspect
|
||||
|
||||
connect( this, &QskPushButton::pressed, this, &MenuButton::openMenu );
|
||||
}
|
||||
|
||||
private:
|
||||
void openMenu()
|
||||
{
|
||||
auto pos = geometry().bottomLeft();
|
||||
|
||||
QskMenu menu( window()->contentItem() );
|
||||
menu.setPopupFlag( QskPopup::DeleteOnClose, false );
|
||||
|
||||
menu.addOption( "image://shapes/Rectangle/White", "Print" );
|
||||
menu.addOption( "image://shapes/Diamond/Yellow", "Save As" );
|
||||
menu.addOption( "image://shapes/Ellipse/Red", "Setup" );
|
||||
menu.addSeparator();
|
||||
menu.addOption( "image://shapes/Hexagon/PapayaWhip", "Help" );
|
||||
|
||||
menu.setOrigin( pos );
|
||||
|
||||
const int result = menu.exec();
|
||||
if ( result >= 0 )
|
||||
qDebug() << "Selected:" << result;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Once QskApplicationView and friends are implemented we can replace
|
||||
Header/ApplicationWindow with it. TODO ...
|
||||
@ -70,6 +104,10 @@ namespace
|
||||
[] { Skinny::changeSkin( 500 ); } );
|
||||
}
|
||||
|
||||
{
|
||||
new MenuButton( "Menu", this );
|
||||
}
|
||||
|
||||
addStretch( 10 );
|
||||
|
||||
{
|
||||
|
@ -20,11 +20,6 @@
|
||||
#include <QskTabView.h>
|
||||
#include <QskBoxShapeMetrics.h>
|
||||
|
||||
#ifdef CONTEXT_MENU
|
||||
#include <QskMenu.h>
|
||||
#include <QskEvent.h>
|
||||
#endif
|
||||
|
||||
#include <QDir>
|
||||
#include <QVariant>
|
||||
|
||||
@ -46,10 +41,6 @@ class GraphicLabel : public QskGraphicLabel
|
||||
setBoxShapeHint( Panel, 8 );
|
||||
setAlignment( Qt::AlignCenter );
|
||||
setDarknessMode( false );
|
||||
|
||||
#ifdef CONTEXT_MENU
|
||||
setAcceptedMouseButtons( Qt::LeftButton );
|
||||
#endif
|
||||
}
|
||||
|
||||
void setDarknessMode( bool on )
|
||||
@ -80,27 +71,6 @@ class GraphicLabel : public QskGraphicLabel
|
||||
startTransition( QskGraphicLabel::Graphic | QskAspect::GraphicRole,
|
||||
duration, oldRole, graphicRole() );
|
||||
}
|
||||
|
||||
#ifdef CONTEXT_MENU
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent* event ) override
|
||||
{
|
||||
QskMenu menu( this );
|
||||
menu.setPopupFlag( QskPopup::DeleteOnClose, false );
|
||||
|
||||
menu.addOption( "image://shapes/Rectangle/White", "Print" );
|
||||
menu.addOption( "image://shapes/Diamond/Yellow", "Save As" );
|
||||
menu.addOption( "image://shapes/Ellipse/Red", "Setup" );
|
||||
menu.addSeparator();
|
||||
menu.addOption( "image://shapes/Hexagon/PapayaWhip", "Help" );
|
||||
|
||||
menu.setOrigin( qskMousePosition( event ) );
|
||||
|
||||
const int result = menu.exec();
|
||||
if ( result >= 0 )
|
||||
qDebug() << "Selected:" << result;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
MainWindow::MainWindow()
|
||||
|
@ -7,10 +7,6 @@
|
||||
|
||||
#include <SkinnyShortcut.h>
|
||||
|
||||
#ifdef CONTEXT_MENU
|
||||
#include <SkinnyShapeProvider.h>
|
||||
#endif
|
||||
|
||||
#include <QskFocusIndicator.h>
|
||||
#include <QskObjectCounter.h>
|
||||
|
||||
@ -22,10 +18,6 @@ int main( int argc, char* argv[] )
|
||||
QskObjectCounter counter( true );
|
||||
#endif
|
||||
|
||||
#ifdef CONTEXT_MENU
|
||||
Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() );
|
||||
#endif
|
||||
|
||||
QGuiApplication app( argc, argv );
|
||||
|
||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||
|
@ -1,5 +1,4 @@
|
||||
CONFIG += qskexample
|
||||
DEFINES += CONTEXT_MENU
|
||||
|
||||
HEADERS += \
|
||||
MainWindow.h
|
||||
|
@ -75,6 +75,9 @@ QskMenu::~QskMenu()
|
||||
{
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
// has no effect as we do not offer submenus yet. TODO ...
|
||||
bool QskMenu::isCascading() const
|
||||
{
|
||||
return flagHint( QskMenu::Panel | QskAspect::Style );
|
||||
@ -92,6 +95,8 @@ void QskMenu::resetCascading()
|
||||
Q_EMIT cascadingChanged( isCascading() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void QskMenu::setOrigin( const QPointF& origin )
|
||||
{
|
||||
if ( origin != m_data->origin )
|
||||
|
Loading…
x
Reference in New Issue
Block a user