attachment_list: fix input method issue of VButtonWithWidget's popup widget

This commit is contained in:
Le Tan 2017-12-15 20:06:15 +08:00
parent 1a62ca15e7
commit 81190cd803
3 changed files with 23 additions and 2 deletions

View File

@ -15,7 +15,7 @@ extern VConfigManager *g_config;
extern VMainWindow *g_mainWin; extern VMainWindow *g_mainWin;
VAttachmentList::VAttachmentList(QWidget *p_parent) VAttachmentList::VAttachmentList(QWidget *p_parent)
: QWidget(p_parent), m_file(NULL) : QWidget(p_parent), VButtonPopupWidget(this), m_file(NULL)
{ {
setupUI(); setupUI();
@ -617,3 +617,10 @@ void VAttachmentList::checkAttachments()
updateContent(); updateContent();
} }
} }
void VAttachmentList::showEvent(QShowEvent *p_event)
{
QWidget::showEvent(p_event);
processShowEvent(p_event);
}

View File

@ -39,6 +39,8 @@ public:
protected: protected:
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
private slots: private slots:
void addAttachment(); void addAttachment();

View File

@ -9,6 +9,7 @@
class QDragEnterEvent; class QDragEnterEvent;
class QDropEvent; class QDropEvent;
class QPaintEvent; class QPaintEvent;
class QShowEvent;
class VButtonWithWidget; class VButtonWithWidget;
// Abstract class for the widget used by VButtonWithWidget. // Abstract class for the widget used by VButtonWithWidget.
@ -16,7 +17,8 @@ class VButtonWithWidget;
class VButtonPopupWidget class VButtonPopupWidget
{ {
public: public:
VButtonPopupWidget() : m_btn(NULL) VButtonPopupWidget(QWidget *p_widget)
: m_widget(p_widget), m_btn(NULL)
{ {
} }
@ -35,7 +37,17 @@ public:
return m_btn; 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: private:
QWidget *m_widget;
VButtonWithWidget *m_btn; VButtonWithWidget *m_btn;
}; };