#ifndef virtual_keyboard_layout_page_h
#define virtual_keyboard_layout_page_h

#include <QToolButton>
#include <pibase.h>


class VirtualKeyboardLayoutPage: public QWidget {
	Q_OBJECT

public:
	VirtualKeyboardLayoutPage(QJsonObject root);
	~VirtualKeyboardLayoutPage();

	bool isValid() const {return !buttons.isEmpty();}
	QString name() const {return name_;}

	bool isCapital() const {return capital;}
	void setCapital(bool yes);
	void setGotoEnabled(bool yes);
	void setCapitalEnabled(bool yes);

	int buttonColumns() const {return columns;}
	void setButtonsSize(int h);

	enum Role {
		rInvalid,
		rLetter,
		rBackspace,
		rReturn,
		rSpace,
		rHide,
		rShift,
		rGotoPage,
	};

protected:
	QToolButton * createButton(QJsonObject jb);
	Role roleFromText(QString str);
	Role buttonRole(QToolButton * b) const;

	QVector<QToolButton * > buttons;
	QString name_;
	int columns = 0;
	bool capital = false, capital_enabled = true;

private slots:

signals:
	void gotoPageRequest(QString);
	void hideRequest();

};

#endif
