tahoma2d/toonz/sources/include/toonzqt/popupbutton.h

76 lines
1.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef POPUP_BUTTON_H
#define POPUP_BUTTON_H
2016-06-15 18:43:10 +12:00
// DVAPI includes
2016-03-19 06:57:51 +13:00
#include "tcommon.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
2016-06-15 18:43:10 +12:00
// Qt includes
2016-03-19 06:57:51 +13:00
#include <QPushButton>
#include <QString>
#include <QIcon>
#include <QPushButton>
#include <QList>
2016-06-15 18:43:10 +12:00
// Forward declarations
2016-03-19 06:57:51 +13:00
class QAction;
//********************************************************************************
// PopupButton class
//********************************************************************************
/*!
The PopupButton represents an enum type in a compact, popup-based form.
A PopupButton instance at rest is a simple push button showing an icon
which represents the stored enum. As the user clicks on the button, a
popup appears showing a description and, optionally, an icon of the
selectable enum values.
*/
2016-06-15 18:43:10 +12:00
class DVAPI PopupButton : public QPushButton {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QList<QAction *> m_actions;
int m_index;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
PopupButton(QWidget *parent = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int currentIndex() const;
const QAction *currentItem() const;
int count() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QAction *addItem(const QString &text);
QAction *addItem(const QIcon &icon, const QString &text = QString());
QAction *addSeparator();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int findText(const QString &text,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void activated(int index);
void currentIndexChanged(int index);
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
void setCurrentIndex(int index);
2016-03-19 06:57:51 +13:00
private slots:
2016-06-15 18:43:10 +12:00
void onIndexChange();
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // POPUP_BUTTON_H