17#include "moc_qgswidgetstatehelper_p.cpp"
33 if ( event->type() == QEvent::Close || event->type() == QEvent::Destroy || event->type() == QEvent::Hide )
35 QWidget *widget = qobject_cast<QWidget *>(
object );
38 if ( widget->property(
"widgetStateHelperWasShown" ).toBool() )
40 const QString name = widgetSafeName( widget );
41 const QString key = mKeys[name];
45 else if ( event->type() == QEvent::Show )
47 QWidget *widget = qobject_cast<QWidget *>(
object );
48 const QString name = widgetSafeName( widget );
56 QWindow *win = widget->windowHandle();
58 return QObject::eventFilter(
object, event );
60 if ( !( win->windowStates() & Qt::WindowMaximized ) )
62 const QString key = mKeys[name];
66 widget->setProperty(
"widgetStateHelperWasShown", QVariant(
true ) );
68 return QObject::eventFilter(
object, event );
73 const QString name = widgetSafeName( widget );
75 widget->installEventFilter(
this );
78QString QgsWidgetStateHelper::widgetSafeName( QWidget *widget )
80 if ( widget->objectName().isEmpty() )
82 return widget->metaObject()->className();
84 return widget->objectName();
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.