浏览代码

UI: Fix text handling for dialogs

Signal only needs to be connected once, not every keystroke.

Also commit data only when text widget focus is lost to fix cursor
moving to the end of the string after every keystroke.
jpark37 5 年之前
父节点
当前提交
36e2a9fa33
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 3 2
      UI/window-importer.cpp
  2. 3 2
      UI/window-remux.cpp

+ 3 - 2
UI/window-importer.cpp

@@ -92,6 +92,9 @@ QWidget *ImporterEntryPathItemDelegate::createEditor(
 					QSizePolicy::ControlType::LineEdit));
 	layout->addWidget(text);
 
+	QObject::connect(text, SIGNAL(editingFinished()), this,
+			 SLOT(updateText()));
+
 	QToolButton *browseButton = new QToolButton();
 	browseButton->setText("...");
 	browseButton->setSizePolicy(buttonSizePolicy);
@@ -121,8 +124,6 @@ void ImporterEntryPathItemDelegate::setEditorData(
 {
 	QLineEdit *text = editor->findChild<QLineEdit *>();
 	text->setText(index.data().toString());
-	QObject::connect(text, SIGNAL(textEdited(QString)), this,
-			 SLOT(updateText()));
 	editor->setProperty(PATH_LIST_PROP, QVariant());
 }
 

+ 3 - 2
UI/window-remux.cpp

@@ -112,6 +112,9 @@ QWidget *RemuxEntryPathItemDelegate::createEditor(
 				    QSizePolicy::ControlType::LineEdit));
 		layout->addWidget(text);
 
+		QObject::connect(text, SIGNAL(editingFinished()), this,
+				 SLOT(updateText()));
+
 		QToolButton *browseButton = new QToolButton();
 		browseButton->setText("...");
 		browseButton->setSizePolicy(buttonSizePolicy);
@@ -143,8 +146,6 @@ void RemuxEntryPathItemDelegate::setEditorData(QWidget *editor,
 {
 	QLineEdit *text = editor->findChild<QLineEdit *>();
 	text->setText(index.data().toString());
-	QObject::connect(text, SIGNAL(textEdited(QString)), this,
-			 SLOT(updateText()));
 	editor->setProperty(PATH_LIST_PROP, QVariant());
 }