vnote/src/widgets/dialogs/selectdialog.h
tootal 911392deab
Feature Task System (#1947)
* add task system code

* enable ci build

* Revert "enable ci build"

This reverts commit 8c457a22e44e64c7d87804fc3c76ee778c1c3b6f.
2021-12-09 18:40:14 +08:00

68 lines
1.5 KiB
C++

#ifndef SELECTDIALOG_H
#define SELECTDIALOG_H
#include <QDialog>
#include <QMap>
class QPushButton;
class QMouseEvent;
class QListWidget;
class QListWidgetItem;
class QShowEvent;
class QKeyEvent;
class QLabel;
namespace vnotex
{
class SelectDialog : public QDialog
{
Q_OBJECT
public:
SelectDialog(const QString &p_title, QWidget *p_parent = nullptr);
SelectDialog(const QString &p_title,
const QString &p_text,
QWidget *p_parent = nullptr);
// @p_selectID should >= 0.
void addSelection(const QString &p_selectStr, int p_selectID);
int getSelection() const;
bool eventFilter(QObject *p_watched, QEvent *p_event) Q_DECL_OVERRIDE;
protected:
void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
private slots:
void selectionChosen(QListWidgetItem *p_item);
private:
enum { CANCEL_ID = -1 };
void setupUI(const QString &p_title, const QString &p_text = QString());
void updateSize();
int m_choice = CANCEL_ID;
QLabel *m_label = nullptr;
QListWidget *m_list = nullptr;
QMap<QChar, QListWidgetItem *> m_shortcuts;
QString m_shortcutIconForeground;
QString m_shortcutIconBorder;
QChar m_nextShortcut = QLatin1Char('a');
static const QChar c_cancelShortcut;
};
} // ns vnotex
#endif // SELECTDIALOG_H