[qet] qet/qet: [5092] Minor GUI improvement

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5092
Author:   blacksun
Date:     2017-11-06 17:17:48 +0100 (Mon, 06 Nov 2017)
Log Message:
-----------
Minor GUI improvement

Modified Paths:
--------------
    trunk/sources/ui/compositetexteditdialog.cpp
    trunk/sources/ui/compositetexteditdialog.h
    trunk/sources/ui/dynamicelementtextmodel.cpp
    trunk/sources/ui/dynamicelementtextmodel.h

Modified: trunk/sources/ui/compositetexteditdialog.cpp
===================================================================
--- trunk/sources/ui/compositetexteditdialog.cpp	2017-11-05 23:15:35 UTC (rev 5091)
+++ trunk/sources/ui/compositetexteditdialog.cpp	2017-11-06 16:17:48 UTC (rev 5092)
@@ -84,3 +84,14 @@
 	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);
+}

Modified: trunk/sources/ui/compositetexteditdialog.h
===================================================================
--- trunk/sources/ui/compositetexteditdialog.h	2017-11-05 23:15:35 UTC (rev 5091)
+++ trunk/sources/ui/compositetexteditdialog.h	2017-11-06 16:17:48 UTC (rev 5092)
@@ -28,6 +28,9 @@
 	
 	private slots:
 		void on_m_info_cb_activated(const QString &arg1);
+		
+	protected:
+		void focusInEvent(QFocusEvent *event) override;
 	
 	private :
 		void setUpComboBox();

Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp	2017-11-05 23:15:35 UTC (rev 5091)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp	2017-11-06 16:17:48 UTC (rev 5092)
@@ -563,6 +563,7 @@
 		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 @@
 			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);
 }
 

Modified: trunk/sources/ui/dynamicelementtextmodel.h
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.h	2017-11-05 23:15:35 UTC (rev 5091)
+++ trunk/sources/ui/dynamicelementtextmodel.h	2017-11-06 16:17:48 UTC (rev 5092)
@@ -73,6 +73,8 @@
 
 class DynamicTextItemDelegate : public QStyledItemDelegate
 {
+	Q_OBJECT
+	
     public:
         DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
         


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/