[qet] qet/qet: [5805] DynamicElementTextModel : change the way how to display the QFontDialog use for change the font of the dynamic text.

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


Revision: 5805
Author:   blacksun
Date:     2019-03-20 21:38:58 +0100 (Wed, 20 Mar 2019)
Log Message:
-----------
DynamicElementTextModel : change the way how to display the QFontDialog use for change the font of the dynamic text.

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

Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp	2019-03-19 18:44:30 UTC (rev 5804)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp	2019-03-20 20:38:58 UTC (rev 5805)
@@ -1527,9 +1527,16 @@
 		}
 		case DynamicElementTextModel::font:
 		{
-			QFontDialog *fd = new QFontDialog(index.data(Qt::UserRole+2).value<QFont>(), parent);
-			fd->setObjectName("font_dialog");
-			return fd;
+			bool ok;
+			QFont font = QFontDialog::getFont(&ok, index.data(Qt::UserRole+2).value<QFont>(), parent);
+			QWidget *w = new QWidget(parent);
+			if (ok)
+			{
+				w->setFont(font);
+				w->setProperty("ok", ok);
+			}
+			w->setObjectName("font_dialog");
+			return w;
 		}
 		case DynamicElementTextModel::color:
 		{
@@ -1617,17 +1624,10 @@
 			{
 				if(QStandardItem *qsi = qsim->itemFromIndex(index))
 				{
-					QFontDialog *fd = static_cast<QFontDialog *>(editor);
-					if (fd->result() == QDialog::Accepted)
+					if (editor->property("ok").toBool() == true)
 					{
-						//qsi->setData(fd->selectedFont().family(), Qt::EditRole);
-						//qsi->setData(fd->selectedFont(), Qt::UserRole+2);
-						/**For unknow reason, call selectedFont doesn't work,
-						 * (always return the same font, no matter what you select)
-						 * Instead we use curentFont
-						 **/
-						qsi->setData(fd->currentFont().family(), Qt::EditRole);
-						qsi->setData(fd->currentFont(), Qt::UserRole+2);
+						qsi->setData(editor->font().family(), Qt::EditRole);
+						qsi->setData(editor->font(), Qt::UserRole+2);
 					}
 					return;
 				}


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