Skip to content

Commit

Permalink
[pvr][settings] Cleanup CPVRChannelNumberInputHandler implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Dec 18, 2024
1 parent f09a585 commit f01e619
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
22 changes: 11 additions & 11 deletions xbmc/pvr/PVRChannelNumberInputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
using namespace PVR;
using namespace std::chrono_literals;

CPVRChannelNumberInputHandler::CPVRChannelNumberInputHandler()
: CPVRChannelNumberInputHandler(CServiceBroker::GetSettingsComponent()
->GetAdvancedSettings()
->m_iPVRNumericChannelSwitchTimeout,
CHANNEL_NUMBER_INPUT_MAX_DIGITS)
namespace
{
}
constexpr size_t CHANNEL_NUMBER_INPUT_MAX_DIGITS = 5;

CPVRChannelNumberInputHandler::CPVRChannelNumberInputHandler(
int iDelay, int iMaxDigits /* = CHANNEL_NUMBER_INPUT_MAX_DIGITS */)
: m_iDelay(iDelay), m_iMaxDigits(iMaxDigits), m_timer(this)
} // unnamed namespace

CPVRChannelNumberInputHandler::CPVRChannelNumberInputHandler()
: m_delay(CServiceBroker::GetSettingsComponent()
->GetAdvancedSettings()
->m_iPVRNumericChannelSwitchTimeout),
m_timer(this)
{
}

Expand Down Expand Up @@ -96,7 +96,7 @@ void CPVRChannelNumberInputHandler::AppendChannelNumberCharacter(char cCharacter
return;
}

if (m_inputBuffer.size() == static_cast<size_t>(m_iMaxDigits))
if (m_inputBuffer.size() == CHANNEL_NUMBER_INPUT_MAX_DIGITS)
{
m_inputBuffer.erase(m_inputBuffer.begin());
SetLabel(m_inputBuffer);
Expand Down Expand Up @@ -134,7 +134,7 @@ void CPVRChannelNumberInputHandler::AppendChannelNumberCharacter(char cCharacter
}

if (!m_timer.IsRunning())
m_timer.Start(std::chrono::milliseconds(m_iDelay));
m_timer.Start(std::chrono::milliseconds(m_delay));
else
m_timer.Restart();
}
Expand Down
13 changes: 1 addition & 12 deletions xbmc/pvr/PVRChannelNumberInputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ struct PVRChannelNumberInputChangedEvent
class CPVRChannelNumberInputHandler : private ITimerCallback
{
public:
static const int CHANNEL_NUMBER_INPUT_MAX_DIGITS = 5;

CPVRChannelNumberInputHandler();

/*!
* @brief ctor.
* @param iDelay timer delay in millisecods.
* @param iMaxDigits maximum number of display digits to use.
*/
CPVRChannelNumberInputHandler(int iDelay, int iMaxDigits = CHANNEL_NUMBER_INPUT_MAX_DIGITS);

~CPVRChannelNumberInputHandler() override = default;

/*!
Expand Down Expand Up @@ -107,8 +97,7 @@ class CPVRChannelNumberInputHandler : private ITimerCallback
void SetLabel(const std::string& label);

std::vector<std::string> m_sortedChannelNumbers;
const int m_iDelay;
const int m_iMaxDigits;
const uint32_t m_delay;
std::string m_inputBuffer;
std::string m_label;
CTimer m_timer;
Expand Down
3 changes: 2 additions & 1 deletion xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,8 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetInt(pPVR, "infotoggleinterval", m_iPVRInfoToggleInterval, 0, 30000);
XMLUtils::GetBoolean(pPVR, "channeliconsautoscan", m_bPVRChannelIconsAutoScan);
XMLUtils::GetBoolean(pPVR, "autoscaniconsuserset", m_bPVRAutoScanIconsUserSet);
XMLUtils::GetInt(pPVR, "numericchannelswitchtimeout", m_iPVRNumericChannelSwitchTimeout, 50, 60000);
XMLUtils::GetUInt(pPVR, "numericchannelswitchtimeout", m_iPVRNumericChannelSwitchTimeout, 50,
60000);
XMLUtils::GetInt(pPVR, "timeshiftthreshold", m_iPVRTimeshiftThreshold, 0, 60);
XMLUtils::GetBoolean(pPVR, "timeshiftsimpleosd", m_bPVRTimeshiftSimpleOSD);
TiXmlElement* pSortDecription = pPVR->FirstChildElement("pvrrecordings");
Expand Down
3 changes: 2 additions & 1 deletion xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
int m_iPVRInfoToggleInterval; /*!< @brief if there are more than 1 pvr gui info item available (e.g. multiple recordings active at the same time), use this toggle delay in milliseconds. defaults to 3000. */
bool m_bPVRChannelIconsAutoScan; /*!< @brief automatically scan user defined folder for channel icons when loading internal channel groups */
bool m_bPVRAutoScanIconsUserSet; /*!< @brief mark channel icons populated by auto scan as "user set" */
int m_iPVRNumericChannelSwitchTimeout; /*!< @brief time in msecs after that a channel switch occurs after entering a channel number, if confirmchannelswitch is disabled */
uint32_t
m_iPVRNumericChannelSwitchTimeout; /*!< @brief time in msecs after that a channel switch occurs after entering a channel number, if confirmchannelswitch is disabled */
int m_iPVRTimeshiftThreshold; /*!< @brief time diff between current playing time and timeshift buffer end, in seconds, before a playing stream is displayed as timeshifting. */
bool m_bPVRTimeshiftSimpleOSD; /*!< @brief use simple timeshift OSD (with progress only for the playing event instead of progress for the whole ts buffer). */
SortDescription m_PVRDefaultSortOrder; /*!< @brief SortDecription used to store default recording sort type and sort order */
Expand Down

0 comments on commit f01e619

Please sign in to comment.