1 #include "popupwidget.h"
9 PopupWidget::PopupWidget(QWidget
*parent
) :
14 QVBoxLayout
*mainLayout
= new QVBoxLayout();
16 m_layout
= new QHBoxLayout();
17 mainLayout
->addLayout(m_layout
);
19 QHBoxLayout
*buttonLayout
= new QHBoxLayout();
21 m_closeButton
= new QPushButton(tr("Close"));
22 buttonLayout
->addWidget(m_closeButton
);
24 mainLayout
->addLayout(buttonLayout
);
26 setLayout(mainLayout
);
28 connect(m_closeButton
, SIGNAL(clicked()), this, SLOT(close()));
29 connect(this, SIGNAL(accepted()), this, SLOT(close()));
30 connect(this, SIGNAL(rejected()), this, SLOT(close()));
33 void PopupWidget::popUp(QWidget
*widget
)
39 void PopupWidget::setWidget(QWidget
*widget
)
42 m_widgetParent
= widget
->parentWidget();
44 // save the current width,height so we can restore when closed
45 m_widgetWidth
= m_widget
->width();
46 m_widgetHeight
= m_widget
->height();
48 // double the size of the widget for the dialog
49 m_widget
->resize(m_widgetWidth
* 2, m_widgetHeight
* 2);
50 m_layout
->addWidget(m_widget
);
53 bool PopupWidget::close()
57 return QDialog::close();
60 void PopupWidget::done(int result
)
64 QDialog::done(result
);
67 void PopupWidget::closePopup()
69 if (m_widget
&& m_widgetParent
) {
70 if (QGroupBox
* w
= qobject_cast
<QGroupBox
*>(m_widgetParent
)) {
71 m_widget
->resize(m_widgetWidth
, m_widgetHeight
);
72 w
->layout()->addWidget(m_widget
);