bloguetronica / cp2130-conf

CP2130 Configurator (cp2130-conf) is an application that can be used to configure CP2130 devices, including VID, PID, as well as other descriptors. Most importantly, the application allows you to configure pin functions and states.
GNU General Public License v3.0
1 stars 1 forks source link

"Manufacturer", "Product" and "Serial number" line edit boxes accept newline characters on paste #34

Closed samuelfmlourenco closed 1 year ago

samuelfmlourenco commented 1 year ago

The above line edit boxes accept newline characters if they are pasted from the clipboard. These characters appear as spaces, but are still treated as newline characters. Such characters should be converted to spaces after editing the boxes mentioned in the title, following a WYSIWYG philosophy.

samuelfmlourenco commented 1 year ago

Three new functions were implemented in version 1.6: on_lineEditManufacturer_textEdited(), on_lineEditProduct_textEdited() and on_lineEditSerial_textEdited(). These functions actively replace newline characters by spaces, affecting the targeted line edit boxes. The replacement is done on the go, and not after editing.

Here is the implementation of on_lineEditManufacturer_textEdited(), to serve as an example:

// Implemented in version 1.6
void ConfiguratorWindow::on_lineEditManufacturer_textEdited()
{
    int curPosition = ui->lineEditManufacturer->cursorPosition();
    ui->lineEditManufacturer->setText(ui->lineEditManufacturer->text().replace('\n', ' '));
    ui->lineEditManufacturer->setCursorPosition(curPosition);
}