diff --git a/src/ui/form/opt/pages/applicationspage.cpp b/src/ui/form/opt/pages/applicationspage.cpp index 2909499b..24e6ce7a 100644 --- a/src/ui/form/opt/pages/applicationspage.cpp +++ b/src/ui/form/opt/pages/applicationspage.cpp @@ -258,10 +258,7 @@ void ApplicationsPage::setupGroupOptions() void ApplicationsPage::setupGroupLimitIn() { - m_cscLimitIn = new CheckSpinCombo(); - m_cscLimitIn->spinBox()->setRange(0, 99999); - m_cscLimitIn->spinBox()->setSuffix(" KiB/s"); - m_cscLimitIn->setValues(speedLimitValues); + m_cscLimitIn = createGroupLimit(); connect(m_cscLimitIn->checkBox(), &QCheckBox::toggled, [&](bool checked) { if (appGroup()->limitInEnabled() == checked) @@ -285,10 +282,7 @@ void ApplicationsPage::setupGroupLimitIn() void ApplicationsPage::setupGroupLimitOut() { - m_cscLimitOut = new CheckSpinCombo(); - m_cscLimitOut->spinBox()->setRange(0, 99999); - m_cscLimitOut->spinBox()->setSuffix(" KiB/s"); - m_cscLimitOut->setValues(speedLimitValues); + m_cscLimitOut = createGroupLimit(); connect(m_cscLimitOut->checkBox(), &QCheckBox::toggled, [&](bool checked) { if (appGroup()->limitOutEnabled() == checked) @@ -310,6 +304,15 @@ void ApplicationsPage::setupGroupLimitOut() }); } +CheckSpinCombo *ApplicationsPage::createGroupLimit() +{ + auto c = new CheckSpinCombo(); + c->spinBox()->setRange(0, 99999); + c->spinBox()->setSuffix(" KiB/s"); + c->setValues(speedLimitValues); + return c; +} + void ApplicationsPage::setupGroupFragmentPacket() { m_cbFragmentPacket = ControlUtil::createCheckBox(false, [&](bool checked) { diff --git a/src/ui/form/opt/pages/applicationspage.h b/src/ui/form/opt/pages/applicationspage.h index 740c92e7..bb118c74 100644 --- a/src/ui/form/opt/pages/applicationspage.h +++ b/src/ui/form/opt/pages/applicationspage.h @@ -34,6 +34,7 @@ private: void setupGroupOptions(); void setupGroupLimitIn(); void setupGroupLimitOut(); + static CheckSpinCombo *createGroupLimit(); void setupGroupFragmentPacket(); void setupGroupOptionsEnabled(); void retranslateGroupLimits();