2021-12-23 18:36:32 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_MENU_H
|
|
|
|
#define QSK_MENU_H
|
|
|
|
|
|
|
|
#include "QskPopup.h"
|
|
|
|
|
|
|
|
#include <qurl.h>
|
|
|
|
#include <qstring.h>
|
|
|
|
|
|
|
|
class QskTextOptions;
|
|
|
|
class QskGraphic;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskMenu : public QskPopup
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QPointF origin READ origin
|
2021-12-23 19:05:59 +01:00
|
|
|
WRITE setOrigin NOTIFY originChanged )
|
2021-12-23 18:36:32 +01:00
|
|
|
|
2021-12-26 12:17:31 +01:00
|
|
|
Q_PROPERTY( bool cascading READ isCascading WRITE setCascading
|
|
|
|
RESET resetCascading NOTIFY cascadingChanged )
|
|
|
|
|
2021-12-27 09:50:14 +01:00
|
|
|
Q_PROPERTY( int count READ count NOTIFY countChanged )
|
2021-12-23 18:36:32 +01:00
|
|
|
|
|
|
|
Q_PROPERTY( int currentIndex READ currentIndex
|
2021-12-23 19:05:59 +01:00
|
|
|
WRITE setCurrentIndex NOTIFY currentIndexChanged )
|
2021-12-23 18:36:32 +01:00
|
|
|
|
|
|
|
using Inherited = QskPopup;
|
|
|
|
|
|
|
|
public:
|
2022-01-06 18:36:15 +01:00
|
|
|
QSK_SUBCONTROLS( Panel, Cell, Cursor, Text, Graphic, Separator )
|
2021-12-23 18:36:32 +01:00
|
|
|
QSK_STATES( Selected )
|
|
|
|
|
|
|
|
QskMenu( QQuickItem* parentItem = nullptr );
|
|
|
|
~QskMenu() override;
|
|
|
|
|
2021-12-26 12:17:31 +01:00
|
|
|
bool isCascading() const;
|
|
|
|
void setCascading( bool );
|
|
|
|
void resetCascading();
|
|
|
|
|
2021-12-23 18:36:32 +01:00
|
|
|
void setOrigin( const QPointF& );
|
|
|
|
QPointF origin() const;
|
|
|
|
|
2022-01-06 18:36:15 +01:00
|
|
|
void setTextOptions( const QskTextOptions& textOptions );
|
|
|
|
QskTextOptions textOptions() const;
|
|
|
|
|
2021-12-23 18:36:32 +01:00
|
|
|
// insert, remove, functors, actions, QskGraphic ...
|
2022-01-06 18:36:15 +01:00
|
|
|
void addOption( const QUrl& graphicSource, const QString& text );
|
|
|
|
void addOption( const QString& graphicSource, const QString& text );
|
|
|
|
|
|
|
|
QVariantList optionAt( int ) const;
|
|
|
|
int count() const;
|
2021-12-23 18:36:32 +01:00
|
|
|
|
|
|
|
void addSeparator();
|
|
|
|
|
2022-01-06 18:36:15 +01:00
|
|
|
int separatorPosition( int ) const;
|
|
|
|
int separatorCount() const;
|
2021-12-23 18:36:32 +01:00
|
|
|
|
2022-01-06 18:36:15 +01:00
|
|
|
void clear();
|
2021-12-23 18:36:32 +01:00
|
|
|
|
|
|
|
int currentIndex() const;
|
|
|
|
|
|
|
|
QRectF focusIndicatorRect() const override;
|
|
|
|
|
2021-12-24 16:20:34 +01:00
|
|
|
QRectF cellRect( int index ) const;
|
2021-12-26 09:15:15 +01:00
|
|
|
int indexAtPosition( const QPointF& ) const;
|
2021-12-24 16:20:34 +01:00
|
|
|
|
2021-12-30 11:13:48 +01:00
|
|
|
Q_INVOKABLE int exec();
|
|
|
|
|
2021-12-23 18:36:32 +01:00
|
|
|
Q_SIGNALS:
|
2021-12-26 12:17:31 +01:00
|
|
|
void cascadingChanged( bool );
|
|
|
|
void originChanged( const QPointF& );
|
|
|
|
|
2021-12-23 18:36:32 +01:00
|
|
|
void triggered( int index );
|
|
|
|
void currentIndexChanged( int index );
|
|
|
|
|
2021-12-27 09:50:14 +01:00
|
|
|
void countChanged( int );
|
|
|
|
|
2021-12-23 18:36:32 +01:00
|
|
|
public Q_SLOTS:
|
|
|
|
void setCurrentIndex( int index );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent( QKeyEvent* ) override;
|
|
|
|
void keyReleaseEvent( QKeyEvent* ) override;
|
2022-01-05 11:59:32 +01:00
|
|
|
|
|
|
|
#ifndef QT_NO_WHEELEVENT
|
2021-12-23 18:36:32 +01:00
|
|
|
void wheelEvent( QWheelEvent* ) override;
|
2022-01-05 11:59:32 +01:00
|
|
|
#endif
|
2021-12-23 18:36:32 +01:00
|
|
|
|
|
|
|
void mousePressEvent( QMouseEvent* ) override;
|
|
|
|
void mouseReleaseEvent( QMouseEvent* ) override;
|
|
|
|
|
|
|
|
void aboutToShow() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void traverse( int steps );
|
|
|
|
void setSelectedIndex( int index );
|
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|