Skip to content
Snippets Groups Projects
Commit 35bab5e7 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.propertyEditor: fixing some glitcheS

parent b1669660
No related branches found
No related tags found
No related merge requests found
...@@ -1001,6 +1001,8 @@ class MyGroupBox : public QGroupBox ...@@ -1001,6 +1001,8 @@ class MyGroupBox : public QGroupBox
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool animated READ isAnimated)
public: public:
MyGroupBox(QWidget * parent = 0) : QGroupBox(parent), m_animated(false), m_firstExpand(true) MyGroupBox(QWidget * parent = 0) : QGroupBox(parent), m_animated(false), m_firstExpand(true)
{} {}
...@@ -1014,6 +1016,9 @@ void setAnimated(bool animated) ...@@ -1014,6 +1016,9 @@ void setAnimated(bool animated)
void finishFirstExpand() void finishFirstExpand()
{ m_firstExpand = false; } { m_firstExpand = false; }
bool isAnimated()
{ return m_animated; }
public slots: public slots:
virtual void setVisible ( bool visible ); virtual void setVisible ( bool visible );
...@@ -1048,15 +1053,17 @@ class QGroupBoxDeclarativeUI : public QObject ...@@ -1048,15 +1053,17 @@ class QGroupBoxDeclarativeUI : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed) Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed)
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth)
public: public:
QGroupBoxDeclarativeUI(QObject *parent = 0) : QObject(parent), m_expanded(true) QGroupBoxDeclarativeUI(QObject *parent = 0) : QObject(parent), m_expanded(true)
{ {
gb = qobject_cast<MyGroupBox*>(parent); gb = qobject_cast<MyGroupBox*>(parent);
connect(&m_timeLine, SIGNAL(frameChanged(int)), this, SLOT(animate(int))); connect(&m_timeLine, SIGNAL (frameChanged(int)), this, SLOT(animate(int)));
connect(&m_timeLine, SIGNAL(finished()), this, SLOT(finish())); connect(&m_timeLine, SIGNAL(finished()), this, SLOT(finish()));
m_timeLine.setDuration(150); m_timeLine.setDuration(100);
m_timeLine.setFrameRange(0, 5); m_timeLine.setFrameRange(0, 5);
m_smooth = true;
} }
bool isCollapsed() bool isCollapsed()
...@@ -1070,6 +1077,11 @@ public: ...@@ -1070,6 +1077,11 @@ public:
expand(); expand();
} }
bool isSmooth()
{ return m_smooth; }
void setSmooth(bool smooth)
{ m_smooth = smooth; }
public slots: public slots:
void collapse(); void collapse();
void expand(); void expand();
...@@ -1085,6 +1097,7 @@ private: ...@@ -1085,6 +1097,7 @@ private:
int m_oldMAxHeight; int m_oldMAxHeight;
int m_oldMinHeight; int m_oldMinHeight;
QPixmap m_contens; QPixmap m_contens;
bool m_smooth;
void hideChildren(); void hideChildren();
void showChildren(); void showChildren();
...@@ -1094,21 +1107,27 @@ private: ...@@ -1094,21 +1107,27 @@ private:
void QGroupBoxDeclarativeUI::reLayout() void QGroupBoxDeclarativeUI::reLayout()
{ {
gb->setUpdatesEnabled(false);
QLayout *layout = gb->parentWidget()->layout(); QLayout *layout = gb->parentWidget()->layout();
QPoint oldPos = gb->pos();
if (layout) { if (layout) {
layout->invalidate();
layout->activate(); layout->activate();
layout->update();
} }
gb->move(oldPos);
gb->setUpdatesEnabled(true);
gb->update();
} }
void QGroupBoxDeclarativeUI::finish() void QGroupBoxDeclarativeUI::finish()
{ {
gb->setAnimated(false);
if (m_expanded) { if (m_expanded) {
showChildren(); showChildren();
gb->setUpdatesEnabled(false);
gb->setMinimumHeight(m_oldMinHeight); gb->setMinimumHeight(m_oldMinHeight);
gb->setMaximumHeight(m_oldMAxHeight); gb->setMaximumHeight(m_oldMAxHeight);
gb->resize(gb->sizeHint()); gb->setUpdatesEnabled(true);
//gb->resize(gb->sizeHint());
gb->finishFirstExpand(); gb->finishFirstExpand();
} }
else { else {
...@@ -1117,6 +1136,7 @@ void QGroupBoxDeclarativeUI::finish() ...@@ -1117,6 +1136,7 @@ void QGroupBoxDeclarativeUI::finish()
gb->resize(gb->sizeHint().width(), 30); gb->resize(gb->sizeHint().width(), 30);
} }
reLayout(); reLayout();
gb->setAnimated(false);
} }
void QGroupBoxDeclarativeUI::hideChildren() void QGroupBoxDeclarativeUI::hideChildren()
...@@ -1155,6 +1175,7 @@ void QGroupBoxDeclarativeUI::collapse() ...@@ -1155,6 +1175,7 @@ void QGroupBoxDeclarativeUI::collapse()
gb->setPixmap(m_contens,1); gb->setPixmap(m_contens,1);
hideChildren(); hideChildren();
m_expanded = false; m_expanded = false;
gb->setAnimated(true);
m_timeLine.start(); m_timeLine.start();
} }
...@@ -1163,12 +1184,14 @@ void QGroupBoxDeclarativeUI::expand() ...@@ -1163,12 +1184,14 @@ void QGroupBoxDeclarativeUI::expand()
if (m_expanded) if (m_expanded)
return; return;
m_expanded = true; m_expanded = true;
gb->setAnimated(true);
m_timeLine.start(); m_timeLine.start();
} }
void QGroupBoxDeclarativeUI::animate(int frame) void QGroupBoxDeclarativeUI::animate(int frame)
{ {
gb->setAnimated(true); if (!m_smooth)
return;
qreal height; qreal height;
if (m_expanded) { if (m_expanded) {
...@@ -1186,7 +1209,6 @@ void QGroupBoxDeclarativeUI::animate(int frame) ...@@ -1186,7 +1209,6 @@ void QGroupBoxDeclarativeUI::animate(int frame)
gb->setMaximumHeight(height); gb->setMaximumHeight(height);
gb->setMinimumHeight(height); gb->setMinimumHeight(height);
reLayout(); reLayout();
gb->update();
} }
class QTabWidgetDeclarativeUI : public QObject class QTabWidgetDeclarativeUI : public QObject
......
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