mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Element info widget : set focus to the first line edit
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3807 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -33,7 +33,8 @@ ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ElementInfoWidget),
|
||||
element_(elmt),
|
||||
elmt_info(elmt->elementInformations())
|
||||
elmt_info(elmt->elementInformations()),
|
||||
m_first_activation (true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
buildInterface();
|
||||
@@ -89,6 +90,27 @@ QUndoCommand* ElementInfoWidget::associatedUndo() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 @@ void ElementInfoWidget::fillInfo() {
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user