#ifndef SHSBUTTONPLUGIN_H
#define SHSBUTTONPLUGIN_H

#include <QObject>
#if QT_VERSION >= 0x050000
#  include <QtUiPlugin/QDesignerCustomWidgetInterface>
#else
#  include <QDesignerCustomWidgetInterface>
#endif
#include <QDesignerTaskMenuExtension>
#include <QDesignerPropertyEditorInterface>
#include <QExtensionFactory>
#include <QListWidget>
#include <QDialog>
#include "button.h"

namespace Ui {
	class SHSButtonMenuExtension;
}

class SHSButtonMenuExtension: public QDialog, public QDesignerTaskMenuExtension
{
	Q_OBJECT
	Q_INTERFACES(QDesignerTaskMenuExtension)
public:
	SHSButtonMenuExtension(SHSButton * widget, QObject * parent);
	~SHSButtonMenuExtension();

	QAction * preferredEditAction() const;
	QList<QAction * > taskActions() const;

private slots:
	void on_treeObjects_commandDoubleClicked(SHS::Command cmd);
	void on_treeObjects_currentCommandChanged(SHS::Command cmd);
	void action_default_triggered();
	void select_ok();

private:
	Ui::SHSButtonMenuExtension * ui;
	SHS::Command cur_cmd;
	SHSButton * widget;
	QAction * action_default;
	QIcon icon_command;
};


class SHSButtonTaskMenuFactory: public QExtensionFactory
{
	Q_OBJECT
public:
	SHSButtonTaskMenuFactory(QExtensionManager * parent = 0): QExtensionFactory(parent) {;}
protected:
	QObject * createExtension(QObject * object, const QString & iid, QObject * parent) const;
};


class SHSButtonPlugin: public QObject, public QDesignerCustomWidgetInterface
{
	Q_OBJECT
	Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
	SHSButtonPlugin(QObject * parent = 0);

	bool isContainer() const;
	bool isInitialized() const;
	QIcon icon() const;
	QString domXml() const;
	QString group() const;
	QString includeFile() const;
	QString name() const;
	QString toolTip() const;
	QString whatsThis() const;
	QWidget * createWidget(QWidget * parent);
	void initialize(QDesignerFormEditorInterface * core);

private:
	bool m_initialized, m_designer;
};

#endif // SHSBUTTONPLUGIN_H
