Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change digit in CFreqCtrl without moving the mouse cursor #999

Merged
merged 2 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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