#ifndef virtual_keyboard_h
#define virtual_keyboard_h

#include "qad_virtual_keyboard_export.h"

#include <QWidget>
#include <qad_timers.h>

namespace Ui {
class VirtualKeyboard;
};
class VirtualKeyboardLayout;


class QAD_VIRTUAL_KEYBOARD_EXPORT VirtualKeyboard: public QWidget, private IndexedTimer<> {
	Q_OBJECT
	Q_PROPERTY(QString layoutPath READ layoutPath WRITE setLayoutPath)

public:
	VirtualKeyboard(QWidget * parent = nullptr);
	~VirtualKeyboard();

	const QString & layoutPath() const { return layout_path_; }
	void setLayoutPath(const QString & path);

	bool isAlwaysVisible() const { return always_visible; }
	void setAlwaysVisible(bool yes);

	void setEnabled(bool yes);
	void setDisabled(bool yes);

protected:
	bool eventFilter(QObject * o, QEvent * e) override;
	void changeEvent(QEvent * e) override;
	void resizeEvent(QResizeEvent * e) override;
	void showEvent(QShowEvent * e) override;

	void init(QString layout_path);
	void destroy();
	void adjust();
	void setKeyboardVisible(bool yes);

private:
	Ui::VirtualKeyboard * ui       = nullptr;
	VirtualKeyboardLayout * layout = nullptr;
	QWidget * watched              = nullptr;
	QString layout_path_;
	bool first_show = true, always_visible = false;
	int prev_width = -1;

private slots:
};

#endif
