Skip to content
Snippets Groups Projects
Commit 2796fbab authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner.NodeInstances: Restart render timer in Preview

Now rendering is only happen if no changes happen anymore.
parent d81f81a1
No related branches found
No related tags found
No related merge requests found
......@@ -135,6 +135,21 @@ void NodeInstanceServer::setSlowRenderTimerInterval(int timerInterval)
m_slowRenderTimerInterval = timerInterval;
}
void NodeInstanceServer::setTimerId(int timerId)
{
m_timer = timerId;
}
int NodeInstanceServer::timerId() const
{
return m_timer;
}
int NodeInstanceServer::renderTimerInterval() const
{
return m_renderTimerInterval;
}
void NodeInstanceServer::startRenderTimer()
{
if (m_slowRenderTimer)
......@@ -151,6 +166,11 @@ void NodeInstanceServer::slowDownRenderTimer()
if (!m_slowRenderTimer)
stopRenderTimer();
if (m_timer != 0) {
killTimer(m_timer);
m_timer = 0;
}
if (m_timer == 0)
m_timer = startTimer(m_slowRenderTimerInterval);
......
......@@ -118,10 +118,11 @@ protected:
void addChangedProperty(const InstancePropertyPair &property);
void startRenderTimer();
virtual void startRenderTimer();
void slowDownRenderTimer();
void stopRenderTimer();
void setRenderTimerInterval(int timerInterval);
int renderTimerInterval() const;
void setSlowRenderTimerInterval(int timerInterval);
void initializeDeclarativeView();
......@@ -129,6 +130,9 @@ protected:
QImage renderPreviewImage();
void setTimerId(int timerId);
int timerId() const;
private:
ServerNodeInstance m_rootNodeInstance;
ServerNodeInstance m_activeStateInstance;
......
......@@ -7,7 +7,7 @@ namespace QmlDesigner {
PreviewNodeInstanceServer::PreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
NodeInstanceServer(nodeInstanceClient)
{
setRenderTimerInterval(50);
setRenderTimerInterval(500);
setSlowRenderTimerInterval(10000);
}
......@@ -18,6 +18,15 @@ void PreviewNodeInstanceServer::createScene(const CreateSceneCommand &command)
startRenderTimer();
}
void PreviewNodeInstanceServer::startRenderTimer()
{
if (timerId() != 0)
killTimer(timerId());
int timerId = startTimer(renderTimerInterval());
setTimerId(timerId);
}
void PreviewNodeInstanceServer::findItemChangesAndSendChangeCommands()
{
......
......@@ -15,6 +15,7 @@ public:
protected:
void findItemChangesAndSendChangeCommands();
void startRenderTimer();
private:
ServerNodeInstance m_actualState;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment