diff --git a/src/vattachmentlist.cpp b/src/vattachmentlist.cpp index 63272310..cdc1d69c 100644 --- a/src/vattachmentlist.cpp +++ b/src/vattachmentlist.cpp @@ -15,7 +15,7 @@ extern VConfigManager *g_config; extern VMainWindow *g_mainWin; VAttachmentList::VAttachmentList(QWidget *p_parent) - : QWidget(p_parent), m_file(NULL) + : QWidget(p_parent), VButtonPopupWidget(this), m_file(NULL) { setupUI(); @@ -617,3 +617,10 @@ void VAttachmentList::checkAttachments() updateContent(); } } + +void VAttachmentList::showEvent(QShowEvent *p_event) +{ + QWidget::showEvent(p_event); + + processShowEvent(p_event); +} diff --git a/src/vattachmentlist.h b/src/vattachmentlist.h index 45c94a93..025a5a03 100644 --- a/src/vattachmentlist.h +++ b/src/vattachmentlist.h @@ -39,6 +39,8 @@ public: protected: void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE; + private slots: void addAttachment(); diff --git a/src/vbuttonwithwidget.h b/src/vbuttonwithwidget.h index a1e50c17..e9f54fb9 100644 --- a/src/vbuttonwithwidget.h +++ b/src/vbuttonwithwidget.h @@ -9,6 +9,7 @@ class QDragEnterEvent; class QDropEvent; class QPaintEvent; +class QShowEvent; class VButtonWithWidget; // Abstract class for the widget used by VButtonWithWidget. @@ -16,7 +17,8 @@ class VButtonWithWidget; class VButtonPopupWidget { public: - VButtonPopupWidget() : m_btn(NULL) + VButtonPopupWidget(QWidget *p_widget) + : m_widget(p_widget), m_btn(NULL) { } @@ -35,7 +37,17 @@ public: return m_btn; } +protected: + // **MUST** be called in subclass at the end of showEvent(). + void processShowEvent(QShowEvent *p_event) + { + Q_UNUSED(p_event); + m_widget->activateWindow(); + } + private: + QWidget *m_widget; + VButtonWithWidget *m_btn; };