qskinny/src/controls/QskMenu.h

97 lines
2.4 KiB
C
Raw Normal View History

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
Q_PROPERTY( int count READ count )
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:
struct Entry
{
QUrl iconSource;
QString text;
};
2021-12-24 16:20:34 +01:00
QSK_SUBCONTROLS( Panel, Cell, Cursor, Text, Graphic )
2021-12-23 18:36:32 +01:00
QSK_STATES( Selected )
QskMenu( QQuickItem* parentItem = nullptr );
~QskMenu() override;
void setOrigin( const QPointF& );
QPointF origin() const;
// insert, remove, functors, actions, QskGraphic ...
void addItem( const QUrl& graphicSource, const QString& text );
void addItem( const QString& graphicSource, const QString& text );
void addSeparator();
Entry entryAt( int index ) const;
QskGraphic graphicAt( int index ) const;
void setTextOptions( const QskTextOptions& textOptions );
QskTextOptions textOptions() const;
int currentIndex() const;
int count() const;
virtual QskColorFilter graphicFilterAt( int index ) 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-23 18:36:32 +01:00
Q_SIGNALS:
void triggered( int index );
void currentIndexChanged( int index );
void originChanged( const QPointF& );
public Q_SLOTS:
void setCurrentIndex( int index );
void clear();
protected:
void keyPressEvent( QKeyEvent* ) override;
void keyReleaseEvent( QKeyEvent* ) override;
void wheelEvent( QWheelEvent* ) override;
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