Commit 96113064 authored by Victor Yacovlev's avatar Victor Yacovlev

All actors creates GUI only if required

parent 4b867291
......@@ -744,9 +744,12 @@ void DrawView::resizeEvent ( QResizeEvent * event )
DrawModule::DrawModule(ExtensionSystem::KPlugin * parent)
: DrawModuleBase(parent)
{
CurView = 0;
}
void DrawModule::createGui()
{
CurView=new DrawView();
netStepX=1;
netStepY=1;
......@@ -758,19 +761,19 @@ DrawModule::DrawModule(ExtensionSystem::KPlugin * parent)
showToolsBut=new QToolButton(CurView);
showToolsBut->move(20,20);
showToolsBut->setCheckable(true);
connect(showToolsBut,SIGNAL(toggled (bool)),this,SLOT(showNavigator(bool)));
connect(m_actionDrawSaveDrawing,SIGNAL(triggered()),this,SLOT(saveFile()));
connect(m_actionDrawLoadDrawing,SIGNAL(triggered()),this,SLOT(openFile()));
navigator->setDraw(this);
navigator->setParent(CurView);
navigator->setFixedSize(QSize(130,200));
navigator->move(20,showToolsBut->pos().y()+showToolsBut->height());
navigator->hide();
CurScene->setDraw(this);
CurView->setScene(CurScene);
penColor.r = penColor.g = penColor.b = 0;
......@@ -784,16 +787,22 @@ DrawModule::DrawModule(ExtensionSystem::KPlugin * parent)
CurView->setNet();
netStepX=1;
netStepY=1;
CurView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
CurView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QBrush curBackground=QBrush(QColor(DrawSettings()->value("Draw/BackColor","lightgreen").toString()));
CurScene->setBackgroundBrush (curBackground);
}
QString DrawModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
void DrawModule::openFile()
......
......@@ -205,6 +205,7 @@ public /* methods */:
{
return QColor(DrawSettings()->value("AxisColor","blue").toString());
}
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
public slots:
void changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current);
void loadActorData(QIODevice * source);
......@@ -233,6 +234,7 @@ public slots:
/* ========= CLASS PRIVATE ========= */
private:
void createGui();
void CreatePen(void);
DrawScene* CurScene;
......
......@@ -33,11 +33,24 @@ private:
GrasshopperModule::GrasshopperModule(ExtensionSystem::KPlugin * parent)
: GrasshopperModuleBase(parent)
{
kuznec=new KumKuznec(myResourcesDir());
kuznec = 0;
// Module constructor, called once on plugin load
// TODO implement me
}
void GrasshopperModule::createGui()
{
kuznec=new KumKuznec(myResourcesDir());
}
QString GrasshopperModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
/* public static */ QList<ExtensionSystem::CommandLineParameter> GrasshopperModule::acceptableCommandLineParameters()
{
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
......@@ -74,6 +87,7 @@ GrasshopperModule::GrasshopperModule(ExtensionSystem::KPlugin * parent)
/* public */ QWidget* GrasshopperModule::mainWidget() const
{
if (!kuznec) return 0;
// Returns module main view widget, or nullptr if there is no any views
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
......@@ -83,6 +97,7 @@ GrasshopperModule::GrasshopperModule(ExtensionSystem::KPlugin * parent)
/* public */ QWidget* GrasshopperModule::pultWidget() const
{
if (!kuznec) return 0;
// Returns module control view widget, or nullptr if there is no control view
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
......
......@@ -32,6 +32,7 @@ public /* methods */:
static QList<ExtensionSystem::CommandLineParameter> acceptableCommandLineParameters();
QWidget* mainWidget() const;
QWidget* pultWidget() const;
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
public slots:
void changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current);
void loadActorData(QIODevice * source);
......@@ -48,6 +49,7 @@ public slots:
private:
void createGui();
KumKuznec* kuznec;
......
......@@ -17,15 +17,30 @@ namespace ActorIsometricRobot {
IsometricRobotModule::IsometricRobotModule(ExtensionSystem::KPlugin * parent)
: IsometricRobotModuleBase(parent)
, window_(new Robot25DWindow(parent->myResourcesDir(), 0))
, robotView_(window_->robotView())
, window_(0)
, robotView_(0)
, parentObject_(parent)
{
}
void IsometricRobotModule::createGui()
{
window_ = new Robot25DWindow(parentObject_->myResourcesDir(), 0);
robotView_ = window_->robotView();
connect(m_actionRobot25DLoadEnvironment, SIGNAL(triggered()),
window_, SLOT(handleLoadAction()));
connect(m_actionRobot25DResetEnvironment, SIGNAL(triggered()),
this, SLOT(reset()));
}
QString IsometricRobotModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
QList<ExtensionSystem::CommandLineParameter> IsometricRobotModule::acceptableCommandLineParameters()
{
return QList<ExtensionSystem::CommandLineParameter>();
......
......@@ -56,10 +56,13 @@ public:
// GUI access methods
QWidget* mainWidget() const;
inline QWidget* pultWidget() const { return nullptr; }
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
private:
void createGui();
Robot25DWindow * window_;
Robot25D::RobotView * robotView_;
ExtensionSystem::KPlugin* parentObject_;
}; // IsometricRobotModule
......
......@@ -21,6 +21,12 @@ namespace ActorPainter {
PainterModule::PainterModule(ExtensionSystem::KPlugin * parent)
: PainterModuleBase(parent)
{
m_window = 0;
dirty_ = true;
}
void PainterModule::createGui()
{
m_window = new PainterWindow(this, 0);
view = m_window->view();
......@@ -31,11 +37,18 @@ PainterModule::PainterModule(ExtensionSystem::KPlugin * parent)
canvasLock = new QMutex;
m_window->setCanvasSize(canvas->size());
dirtyLock_ = new QMutex;
dirty_ = true;
startTimer(50);
reset();
}
QString PainterModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
void PainterModule::timerEvent(QTimerEvent *event)
{
dirtyLock_->lock();
......
......@@ -83,8 +83,10 @@ public:
// GUI access methods
QWidget* mainWidget() const;
inline QWidget* pultWidget() const { return nullptr; }
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
private:
private:
void createGui();
void timerEvent(QTimerEvent *);
void markViewDirty();
void drawPolygon(const QVector<QPoint> & points);
......
......@@ -3302,10 +3302,17 @@ RobotModule::RobotModule(ExtensionSystem::KPlugin * parent)
*/
animation=true;
pressed=false;
m_mainWidget = 0;
m_pultWidget = 0;
}
void RobotModule::createGui()
{
field=new RoboField(0);
//field->editField();
field->createField(10,15);
field->setRoboPos(0,0);
field->createRobot();
view=new RobotView(field);
......@@ -3342,7 +3349,7 @@ RobotModule::RobotModule(ExtensionSystem::KPlugin * parent)
connect(m_actionRobotLoadEnvironment,SIGNAL(triggered()) , this, SLOT(loadEnv()));
connect(m_actionRobotRevertEnvironment,SIGNAL(triggered()) , this, SLOT(resetEnv()));
connect(m_actionRobotSaveEnvironment,SIGNAL(triggered()) , this, SLOT(saveEnv()));
connect(m_actionRobotEditEnvironment,SIGNAL(triggered()) , this, SLOT(editEnv()));
connect(m_actionRobotEditEnvironment,SIGNAL(triggered()) , this, SLOT(editEnv()));
connect(m_actionRobotNewEnvironment,SIGNAL(triggered()) , this, SLOT(newEnv()));
connect(m_actionRobotAutoWindowSize,SIGNAL(triggered()) , this, SLOT(setWindowSize()));
......@@ -3350,8 +3357,9 @@ RobotModule::RobotModule(ExtensionSystem::KPlugin * parent)
rescentMenu=new QMenu();
m_actionRobotLoadRescent->setMenu(rescentMenu);
view->setWindowTitle(trUtf8("Робот - нет файла"));
}
}
void RobotModule::copyFromPult(QString log)
{
QClipboard *clipboard = QApplication::clipboard();
......@@ -3492,13 +3500,16 @@ QList<ExtensionSystem::CommandLineParameter> RobotModule::acceptableCommandLine
}
QString RobotModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine & runtimeParameters)
{ExtensionSystem::SettingsPtr sett;
sett=robotSettings();
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
ExtensionSystem::SettingsPtr sett;
sett=robotSettings();
if(runtimeParameters.value("field").isValid())
{
qDebug()<<"FIELD:|"<<runtimeParameters.value("field").toString()<<"|";
// std::cout <<"FIELD:" <<runtimeParameters.value("field").toString().toStdString();
// std::cout <<"FIELD:" <<runtimeParameters.value("field").toString().toStdString();
if(LoadFromFile(runtimeParameters.value("field").toString())!=0)return "Error loading:"+runtimeParameters.value("field").toString();
return "";
}
......@@ -3506,17 +3517,19 @@ QString RobotModule::initialize(const QStringList &configurationParameters, cons
{
if(LoadFromFile(sett->value("Robot/SFF").toString())!=0){
createEmptyField(7,7);
}
}
setWindowSize();
}
if(sett->value("Robot/Dir").isValid())
{
curDir=sett->value("Robot/Dir").toString();
}
// setWindowSize();
return "";
// setWindowSize();
}
return "";
}
void RobotModule::runGoUp()
{
/* TODO implement me */
......
......@@ -525,6 +525,7 @@ namespace ActorRobot {
void copyFromPult(QString log);
private:
void createGui();
void createEmptyField(int rows,int cols);
int LoadFromFile(QString p_FileName);
int SaveToFile(QString p_FileName);
......
......@@ -30,14 +30,25 @@ namespace ActorTurtle {
};
TurtleModule::TurtleModule(ExtensionSystem::KPlugin * parent)
: TurtleModuleBase(parent)
{
Turtle = 0;
Tpult = 0;
animation=false;
}
void TurtleModule::createGui()
{
Turtle=new turtle(myResourcesDir());
Tpult=new TurtlePult(myResourcesDir());
Tpult->turtleObj=Turtle;
animation=false;
// Module constructor, called once on plugin load
// TODO implement me
}
QString TurtleModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
/* public static */ QList<ExtensionSystem::CommandLineParameter> TurtleModule::acceptableCommandLineParameters()
......@@ -85,7 +96,7 @@ TurtleModule::TurtleModule(ExtensionSystem::KPlugin * parent)
// Returns module control view widget, or nullptr if there is no control view
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
if (!Tpult) return 0;
// TODO implement me
static QWidget * dummy = new AAA(Tpult);
return dummy;
......
......@@ -32,6 +32,7 @@ public /* methods */:
static QList<ExtensionSystem::CommandLineParameter> acceptableCommandLineParameters();
QWidget* mainWidget() const;
QWidget* pultWidget() const;
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
public slots:
void changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current);
void loadActorData(QIODevice * source);
......@@ -50,6 +51,7 @@ public slots:
/* ========= CLASS PRIVATE ========= */
private:
void createGui();
turtle* Turtle;
TurtlePult* Tpult;
bool animation;
......
......@@ -25,6 +25,11 @@ VodoleyModule::VodoleyModule(ExtensionSystem::KPlugin * parent)
: VodoleyModuleBase(parent)
{
self = this;
MainWindow = 0;
}
void VodoleyModule::createGui()
{
MainWindow=new Vodoley();
// Module constructor, called once on plugin load
// TODO implement me
......@@ -36,6 +41,14 @@ VodoleyModule::VodoleyModule(ExtensionSystem::KPlugin * parent)
// m_actionVodoleyNewEnvironment
}
QString VodoleyModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
/* public static */ QList<ExtensionSystem::CommandLineParameter> VodoleyModule::acceptableCommandLineParameters()
{
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
......
......@@ -32,6 +32,7 @@ public /* methods */:
static QList<ExtensionSystem::CommandLineParameter> acceptableCommandLineParameters();
QWidget* mainWidget() const;
QWidget* pultWidget() const;
QString initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &runtimeParameters);
public slots:
void changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current);
void loadActorData(QIODevice * source);
......@@ -57,6 +58,7 @@ public slots:
/* ========= CLASS PRIVATE ========= */
private:
void createGui();
Vodoley *MainWindow;
......
......@@ -20,7 +20,7 @@ endif()
set(
CONFIGURATION_TEMPLATE
"Actor*,!KumirCompilerTool,KumirCodeGenerator,KumirAnalizer\(teacher,preload=Files,preload=Strings\)"
"Actor*(tablesOnly),!KumirCompilerTool,KumirCodeGenerator,KumirAnalizer\(teacher,preload=Files,preload=Strings\)"
)
set(SRC ../main.cpp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment