Skip to content

Commit

Permalink
Merge pull request #999 from LouDou/fix-freqctrl-digit-move
Browse files Browse the repository at this point in the history
change digit in CFreqCtrl without moving the mouse cursor
  • Loading branch information
argilo authored Dec 18, 2021
2 parents 49de5f3 + 62490ea commit 728ea4d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ The following people and organisations have contributed to gqrx:
* Darin Franklin
* Davide Gerhard
* Dominic Chen
* Doug Hammond
* Elias Önal
* Federico Fuga
* Frank Brickle, AB2KT
Expand Down
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

FIXED: DSP stops when device is changed.
FIXED: USB error when device settings are changed.
FIXED: Changing frequency using the keyboard doesn't work on MacOS.


2.15: Released December 15, 2021
Expand Down
56 changes: 32 additions & 24 deletions src/qtgui/freqctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ bool CFreqCtrl::inRect(QRect &rect, QPoint &point)
return false;
}

void CFreqCtrl::setActiveDigit(int idx)
{
for (int i = m_DigStart; i < m_NumDigits; i++)
{
if (i == idx)
{
if (!m_DigitInfo[i].editmode)
{
m_DigitInfo[i].editmode = true;
m_ActiveEditDigit = i;
}
}
else
{
// un-highlight the previous digit if moved off it
if (m_DigitInfo[i].editmode)
{
m_DigitInfo[i].editmode = false;
m_DigitInfo[i].modified = true;
}
}
}

updateCtrl(false);

}

static int fmax_to_numdigits(qint64 fmax)
{
if (fmax < 10e6)
Expand Down Expand Up @@ -401,24 +428,9 @@ void CFreqCtrl::mouseMoveEvent(QMouseEvent *event)
{
if (inRect(m_DigitInfo[i].dQRect, pt))
{
if (!m_DigitInfo[i].editmode)
{
m_DigitInfo[i].editmode = true;
m_ActiveEditDigit = i;
}
}
else
{
// un-highlight the previous digit if moved off it
if (m_DigitInfo[i].editmode)
{
m_DigitInfo[i].editmode = false;
m_DigitInfo[i].modified = true;
}
setActiveDigit(i);
}
}

updateCtrl(false);
}
}

Expand Down Expand Up @@ -822,35 +834,31 @@ void CFreqCtrl::moveCursorLeft()
{
if ((m_ActiveEditDigit >= 0) && (m_ActiveEditDigit < m_NumDigits - 1))
{
cursor().setPos(mapToGlobal(m_DigitInfo[++m_ActiveEditDigit].dQRect.
center()));
setActiveDigit(m_ActiveEditDigit + 1);
}
}

void CFreqCtrl::moveCursorRight()
{
if (m_ActiveEditDigit > m_FirstEditableDigit)
{
cursor().setPos(mapToGlobal(m_DigitInfo[--m_ActiveEditDigit].dQRect.
center()));
setActiveDigit(m_ActiveEditDigit - 1);
}
}

void CFreqCtrl::cursorHome()
{
if (m_ActiveEditDigit >= 0)
{
cursor().setPos(mapToGlobal(
m_DigitInfo[m_NumDigits - 1].dQRect.center()));
setActiveDigit(m_NumDigits - 1);
}
}

void CFreqCtrl::cursorEnd()
{
if (m_ActiveEditDigit > 0)
{
cursor().setPos(mapToGlobal(m_DigitInfo[m_FirstEditableDigit].dQRect.
center()));
setActiveDigit(m_FirstEditableDigit);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/qtgui/freqctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public slots:
void moveCursorLeft();
void moveCursorRight();
bool inRect(QRect &rect, QPoint &point);
void setActiveDigit(int idx);

bool m_UpdateAll;
bool m_ExternalKeyActive;
Expand Down

0 comments on commit 728ea4d

Please sign in to comment.