#define EXAMPLE_COMPLEXITY 0
#include "ui_Basic_dialog.h"
#include <CGAL/Three/Polyhedron_demo_plugin_interface.h>
#include <QApplication>
#include <QObject>
#include <QAction>
#include <QMainWindow>
#include <QInputDialog>
#include <QMessageBox>
#include "Messages_interface.h"
class ComplexDialog :
public QDialog,
public Ui::BasicDialog
{
Q_OBJECT
public:
ComplexDialog(QWidget* =0)
{
setupUi(this);
}
};
class BasicPlugin :
public QObject,
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0")
public:
bool applicable(QAction*) const Q_DECL_OVERRIDE
{
return true;
}
QList<QAction*> actions() const Q_DECL_OVERRIDE
{
return _actions;
}
{
this->messageInterface = mi;
this->scene = sc;
this->mw = mainWindow;
QAction *actionHelloWorld= new QAction(QString("Hello World"), mw);
actionHelloWorld->setProperty("submenuName", "Basic");
if(actionHelloWorld) {
connect(actionHelloWorld, SIGNAL(triggered()),
this, SLOT(helloWorld()));
_actions << actionHelloWorld;
}
}
private Q_SLOTS:
#if EXAMPLE_COMPLEXITY == 0
void helloWorld()
{
messageInterface->information(QString("Hello World!"));
}
#elif EXAMPLE_COMPLEXITY == 1
void helloWorld()
{
bool ok = false;
const unsigned int parameter =
QInputDialog::getInt((QWidget*)mw,
tr("Hello World"),
tr("Hello dear user! What integer would you want me to display for you ? "),
10,
0,
100,
1,
&ok);
if(!ok) return;
messageInterface->information(QString("You asked me to display %1, so here it is : %1").arg(parameter));
}
#elif EXAMPLE_COMPLEXITY == 2
void helloWorld()
{
ComplexDialog *dialog = new ComplexDialog();
if(!dialog->exec())
return;
QString result = dialog->lineEdit->text();
bool ok = false;
int int_res = result.toInt(&ok);
if(!ok)
{
QMessageBox::warning(mw,
"ERROR",
tr("This is not an integer !")
);
return;
}
messageInterface->information(QString("You asked me to display %1, so here it is : %1").arg(int_res));
}
#endif
private:
QList<QAction*> _actions;
Messages_interface* messageInterface;
QMainWindow* mw;
};
#include "Basic_plugin.moc"