[qet] [3807] Element info widget : set focus to the first line edit |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3807
Author: blacksun
Date: 2015-03-05 11:26:09 +0100 (Thu, 05 Mar 2015)
Log Message:
-----------
Element info widget : set focus to the first line edit
Modified Paths:
--------------
trunk/sources/ui/elementinfopartwidget.cpp
trunk/sources/ui/elementinfopartwidget.h
trunk/sources/ui/elementinfowidget.cpp
trunk/sources/ui/elementinfowidget.h
Modified: trunk/sources/ui/elementinfopartwidget.cpp
===================================================================
--- trunk/sources/ui/elementinfopartwidget.cpp 2015-03-05 08:37:19 UTC (rev 3806)
+++ trunk/sources/ui/elementinfopartwidget.cpp 2015-03-05 10:26:09 UTC (rev 3807)
@@ -87,3 +87,11 @@
void ElementInfoPartWidget::setHideShow(const bool &hide) {
ui -> checkBox -> setHidden(hide);
}
+
+/**
+ * @brief ElementInfoPartWidget::setFocusTolineEdit
+ * Set the focus to the line edit
+ */
+void ElementInfoPartWidget::setFocusTolineEdit() {
+ ui->line_edit->setFocus();
+}
Modified: trunk/sources/ui/elementinfopartwidget.h
===================================================================
--- trunk/sources/ui/elementinfopartwidget.h 2015-03-05 08:37:19 UTC (rev 3806)
+++ trunk/sources/ui/elementinfopartwidget.h 2015-03-05 10:26:09 UTC (rev 3807)
@@ -38,6 +38,7 @@
bool mustShow () const;
void setShow (const bool &);
void setHideShow (const bool &);
+ void setFocusTolineEdit();
//ATTRIBUTES
private:
Modified: trunk/sources/ui/elementinfowidget.cpp
===================================================================
--- trunk/sources/ui/elementinfowidget.cpp 2015-03-05 08:37:19 UTC (rev 3806)
+++ trunk/sources/ui/elementinfowidget.cpp 2015-03-05 10:26:09 UTC (rev 3807)
@@ -33,7 +33,8 @@
QWidget(parent),
ui(new Ui::ElementInfoWidget),
element_(elmt),
- elmt_info(elmt->elementInformations())
+ elmt_info(elmt->elementInformations()),
+ m_first_activation (true)
{
ui->setupUi(this);
buildInterface();
@@ -90,6 +91,27 @@
}
/**
+ * @brief ElementInfoWidget::event
+ * Reimplemented from QWidget::event
+ * Only give focus to the first line edit at first activation.
+ * After send the event to QWidget.
+ * @param event
+ * @return
+ */
+bool ElementInfoWidget::event(QEvent *event)
+{
+ if (m_first_activation)
+ {
+ if (event -> type() == QEvent::WindowActivate || event -> type() == QEvent::Show)
+ {
+ QTimer::singleShot(250, this, SLOT(firstActivated()));
+ m_first_activation = false;
+ }
+ }
+ return(QWidget::event(event));
+}
+
+/**
* @brief ElementInfoWidget::buildInterface
* Build the widget
*/
@@ -122,3 +144,12 @@
eipw->setHideShow(true);
}
}
+
+/**
+ * @brief ElementInfoWidget::firstActivated
+ * Slot activated when this widget is show.
+ * Set the focus to the first line edit provided by this widget
+ */
+void ElementInfoWidget::firstActivated() {
+ eipw_list.first() -> setFocusTolineEdit();
+}
Modified: trunk/sources/ui/elementinfowidget.h
===================================================================
--- trunk/sources/ui/elementinfowidget.h 2015-03-05 08:37:19 UTC (rev 3806)
+++ trunk/sources/ui/elementinfowidget.h 2015-03-05 10:26:09 UTC (rev 3807)
@@ -45,16 +45,23 @@
bool apply();
QUndoCommand* associatedUndo () const;
+ protected:
+ virtual bool event(QEvent *event);
+
private:
void buildInterface();
void fillInfo();
+ private slots:
+ void firstActivated();
+
//ATTRIBUTES
private:
Ui::ElementInfoWidget *ui;
Element *element_;
DiagramContext elmt_info;
QList <ElementInfoPartWidget *> eipw_list;
+ bool m_first_activation;
};
#endif // ELEMENTINFOWIDGET_H