Changeset - 64927d61468d
[Not reviewed]
settings
0 2 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-09-02 15:58:56
hy@ozderya.net
save/load flow control
2 files changed with 36 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/portcontrol.cpp
Show inline comments
 
@@ -322,20 +322,37 @@ QString PortControl::currentParityText()
 
    else // no parity
 
    {
 
        return "none";
 
    }
 
}
 

	
 
QString PortControl::currentFlowControlText()
 
{
 
    if (flowControlButtons.checkedId() == QSerialPort::HardwareControl)
 
    {
 
        return "hardware";
 
    }
 
    else if (flowControlButtons.checkedId() == QSerialPort::SoftwareControl)
 
    {
 
        return "software";
 
    }
 
    else // no parity
 
    {
 
        return "none";
 
    }
 
}
 

	
 
void PortControl::saveSettings(QSettings* settings)
 
{
 
    settings->beginGroup("Port");
 
    settings->setValue("selectedPort", selectedPortName());
 
    settings->setValue("baudRate", ui->cbBaudRate->currentText());
 
    settings->setValue("parity", currentParityText());
 
    settings->setValue("dataBits", dataBitsButtons.checkedId());
 
    settings->setValue("stopBits", stopBitsButtons.checkedId());
 
    settings->setValue("flowControl", currentFlowControlText());
 

	
 
    settings->endGroup();
 
}
 

	
 
void PortControl::loadSettings(QSettings* settings)
 
{
 
@@ -391,8 +408,25 @@ void PortControl::loadSettings(QSettings
 
    else if (stopBits == QSerialPort::TwoStop)
 
    {
 
        ui->rb2StopBit->setChecked(true);
 
        selectStopBits(QSerialPort::TwoStop);
 
    }
 

	
 
    // load flow control
 
    QString flowControlSetting =
 
        settings->value("flowControl", currentFlowControlText()).toString();
 
    if (flowControlSetting == "hardware")
 
    {
 
        ui->rbHardwareControl->setChecked(true);
 
    }
 
    else if (flowControlSetting == "software")
 
    {
 
        ui->rbSoftwareControl->setChecked(true);
 
    }
 
    else
 
    {
 
        ui->rbNoFlowControl->setChecked(true);
 
    }
 
    selectFlowControl(flowControlButtons.checkedId());
 

	
 
    settings->endGroup();
 
}
src/portcontrol.h
Show inline comments
 
@@ -66,12 +66,14 @@ private:
 
    PortList portList;
 

	
 
    /// Returns the currently selected (entered) "portName" in the UI
 
    QString selectedPortName();
 
    /// Returns currently selected parity as text to be saved in settings
 
    QString currentParityText();
 
    /// Returns currently selected flow control as text to be saved in settings
 
    QString currentFlowControlText();
 

	
 
public slots:
 
    void loadPortList();
 
    void loadBaudRateList();
 
    void togglePort();
 
    void selectPort(QString portName);
0 comments (0 inline, 0 general)