1
0
Эх сурвалжийг харах

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

Le Tan 8 жил өмнө
parent
commit
81190cd803

+ 8 - 1
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);
+}

+ 2 - 0
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();
 

+ 13 - 1
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;
 };