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
 
@@ -325,6 +325,22 @@ QString PortControl::currentParityText()
 
    }
 
}
 

	
 
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");
 
@@ -333,6 +349,7 @@ void PortControl::saveSettings(QSettings
 
    settings->setValue("parity", currentParityText());
 
    settings->setValue("dataBits", dataBitsButtons.checkedId());
 
    settings->setValue("stopBits", stopBitsButtons.checkedId());
 
    settings->setValue("flowControl", currentFlowControlText());
 

	
 
    settings->endGroup();
 
}
 
@@ -394,5 +411,22 @@ void PortControl::loadSettings(QSettings
 
        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
 
@@ -69,6 +69,8 @@ private:
 
    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();
0 comments (0 inline, 0 general)