mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Minor GUI improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5092 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -84,3 +84,14 @@ void CompositeTextEditDialog::on_m_info_cb_activated(const QString &arg1)
|
||||
Q_UNUSED(arg1)
|
||||
ui->m_plain_text_edit->insertPlainText(ui->m_info_cb->currentData().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CompositeTextEditDialog::focusInEvent
|
||||
* Reimplemented from QWidget::focusInEvent
|
||||
* @param event
|
||||
*/
|
||||
void CompositeTextEditDialog::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
ui->m_plain_text_edit->setFocus();
|
||||
QDialog::focusInEvent(event);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ class CompositeTextEditDialog : public QDialog
|
||||
private slots:
|
||||
void on_m_info_cb_activated(const QString &arg1);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
|
||||
private :
|
||||
void setUpComboBox();
|
||||
QString infoToVar(const QString& info) const;
|
||||
|
||||
@@ -563,6 +563,7 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti
|
||||
case DynamicElementTextModel::textFrom:
|
||||
{
|
||||
QComboBox *qcb = new QComboBox(parent);
|
||||
qcb->setObjectName("text_from");
|
||||
qcb->addItem(tr("Texte utilisateur"));
|
||||
qcb->addItem(tr("Information de l'élément"));
|
||||
qcb->addItem(tr("Texte composé"));
|
||||
@@ -716,6 +717,13 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
|
||||
emit commitData(sb);
|
||||
}
|
||||
|
||||
//Like the hack above, change the current index of the combobox, apply the change immediately, no need to lose focus or press enter.
|
||||
if((object->objectName() == "text_from" || object->objectName() == "info_text") && event->type() == QEvent::FocusIn)
|
||||
{
|
||||
QComboBox *qcb = static_cast<QComboBox *>(object);
|
||||
connect(qcb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this,qcb](){emit commitData(qcb);});
|
||||
}
|
||||
|
||||
return QStyledItemDelegate::eventFilter(object, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ class DynamicElementTextModel : public QStandardItemModel
|
||||
|
||||
class DynamicTextItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user