Skip to content
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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
The AntScope2 software is designed to support various models of RigExpert analyzers under various operating systems.

Windows: QT5, QT Creator 2 and higher
Windows: Qt6, Qt Creator 2 and higher

Linux: to do
Linux: Qt6, qmake. Build with:

```
qmake6 CONFIG+=release AntScope.pro
make
```

Depends on `qt6-base`, `qt6-serialport`, `qt6-connectivity`, and `libusb` (used via the vendored HIDAPI backend for HID-connected analyzers). Packaged for Arch Linux/AUR as
[`antscope2`](https://aur.archlinux.org/packages/antscope2) (pinned to a known-good commit, patched)
and [`antscope2-git`](https://aur.archlinux.org/packages/antscope2-git) (tracks a patched branch's tip - see either package's `PKGBUILD` for the udev rule, desktop file, and data-path packaging details this repo's own build doesn't set up on its own).

Mac OS: to do
2 changes: 0 additions & 2 deletions analyzer/ble_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <QDataStream>
#include <QTimer>
#include "baseanalyzer.h"
#include "screeninfo.h"

enum {
BLE_VER_CMD = (quint8)0xE6,
Expand Down Expand Up @@ -194,7 +193,6 @@ private slots:
void measuringChanged();
void aliveChanged();
void statsChanged();
void setScreenInfo(ScreenInfo& screen);

private:
QString m_error;
Expand Down
38 changes: 32 additions & 6 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,11 @@ MainWindow::MainWindow(QWidget *parent) :

m_1secTimer = new QTimer(this);
connect(m_1secTimer, SIGNAL(timeout()), this, SLOT(on_1secTimerTick()));
m_1secTimer->start(100);
m_1secTimer->start(1000);

m_focusDebounceTimer = new QTimer(this);
m_focusDebounceTimer->setSingleShot(true);
connect(m_focusDebounceTimer, &QTimer::timeout, this, &MainWindow::onFocusDebounceTimeout);

loadLanguage(languages_small[m_languageNumber]);
ui->tableWidget_presets->horizontalHeader()->show();
Expand Down Expand Up @@ -761,19 +765,31 @@ void MainWindow::closeEvent(QCloseEvent *event)

bool MainWindow::event(QEvent * e)
{
if(e->type() == QEvent::WindowActivate)
{
emit focus(true);
}else if (e->type() == QEvent::WindowDeactivate)
if(e->type() == QEvent::WindowActivate || e->type() == QEvent::WindowDeactivate)
{
emit focus(false);
// Some window managers/compositors send rapid, sometimes
// continuous, Activate/Deactivate churn (e.g. triggered by an
// always-on-top Qt::Tool child being mapped/unmapped, which is
// itself a reaction to a previous Activate here - a feedback
// loop). Do not react to any single event; only act once the
// window's activation state has held steady for a while.
m_focusDebounceTimer->start(300);
}else if (e->type() == QEvent::WindowStateChange)
{
updateGraph();
}
return QMainWindow::event(e) ;
}

void MainWindow::onFocusDebounceTimeout()
{
bool active = isActiveWindow();
if (active != m_lastEmittedFocus) {
m_lastEmittedFocus = active;
emit focus(active);
}
}

void MainWindow::setWidgetsSettings()
{
QPen pen;
Expand Down Expand Up @@ -6806,6 +6822,15 @@ void MainWindow::on_selectDeviceDialog()
return;
}

// dlg.exec() below runs a nested event loop, during which any other
// queued call to this same slot (e.g. a pending QTimer::singleShot
// from on_refreshConnection()) would still fire and stack a second
// SelectDeviceDialog on top of the first. Guard against that.
if (m_selectDeviceDialogOpen) {
return;
}
m_selectDeviceDialogOpen = true;

SelectDeviceDialog dlg(false, this);
if (dlg.exec() == QDialog::Accepted) {
SelectionParameters sel_par = SelectionParameters::selected;
Expand All @@ -6815,6 +6840,7 @@ void MainWindow::on_selectDeviceDialog()
emit m_analyzer->analyzerFound(selected->index());
}
}
m_selectDeviceDialogOpen = false;
closeSettingsDialog();
ui->settingsBtn->setEnabled(true);
}
Expand Down
4 changes: 4 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class MainWindow : public QMainWindow

// QTimer *m_redrawTimer;
QTimer *m_1secTimer;
QTimer *m_focusDebounceTimer;
bool m_lastEmittedFocus = true;

double m_cableVelFactor;
double m_cableResistance;
Expand Down Expand Up @@ -199,6 +201,7 @@ class MainWindow : public QMainWindow
bool m_addingMarker;
bool m_isMouseClick;
bool m_bInterrupted;
bool m_selectDeviceDialogOpen = false;
QMap<QString, QStringList*> m_BandsMap;
bool m_darkColorTheme = true;
QPalette m_lightPalette;
Expand Down Expand Up @@ -338,6 +341,7 @@ private slots:
void on_firmwareAutoUpdateStateChanged( bool state);
void on_antScopeAutoUpdateStateChanged( bool state);
void on_1secTimerTick();
void onFocusDebounceTimeout();
void on_calibrationChanged();
void on_SaveFile(int row, QString path);
void on_mouseDoubleClick(QMouseEvent* e);
Expand Down
2 changes: 1 addition & 1 deletion markers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Markers::Markers(QObject *parent) : QObject(parent),

if(m_markersHint == NULL)
{
m_markersHint = new MarkersPopUp();
m_markersHint = new MarkersPopUp(MainWindow::m_mainWindow, true);
m_markersHint->setHiding(false);
if(m_markersHintEnabled && !m_markersList.isEmpty())
m_markersHint->focusShow();
Expand Down
2 changes: 1 addition & 1 deletion markers.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Markers : public QObject

Measurements *m_measurements;

bool m_focus;
bool m_focus = true;

double interpolate(double fq1, double fq2, double fq3, double param1, double param2);

Expand Down
69 changes: 47 additions & 22 deletions markerspopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

QMap<int, QString> MarkersHeaderColumn::m_mapHeader;

MarkersPopUp::MarkersPopUp(QWidget *parent) : QWidget(parent),
MarkersPopUp::MarkersPopUp(QWidget *parent, bool embedded) : QWidget(parent),
m_durability(2000),
m_hiding(true),
m_x(0),
Expand All @@ -16,15 +16,23 @@ MarkersPopUp::MarkersPopUp(QWidget *parent) : QWidget(parent),
m_mainY(0),
m_mainBiasX(0),
m_mainBiasY(0),
m_embedded(embedded),
m_bgColor(0,0,0,180),
m_penColor(255,255,255,180),
m_textColor("white")
{
setWindowFlags(Qt::FramelessWindowHint | // Отключаем оформление окна
Qt::Tool | // Отменяем показ в качестве отдельного окна
Qt::WindowStaysOnTopHint); // Устанавливаем поверх всех окон
if (m_embedded) {
// A plain child widget of its parent, not a separate top-level
// window - see PopUp::init() in popup.cpp for the full
// rationale (same fix, same class of bug).
} else {
setWindowFlags(Qt::FramelessWindowHint | // Отключаем оформление окна
Qt::Tool | // Отменяем показ в качестве отдельного окна
Qt::WindowStaysOnTopHint | // Устанавливаем поверх всех окон
Qt::WindowDoesNotAcceptFocus); // Никогда не становится активным окном
setAttribute(Qt::WA_ShowWithoutActivating); // При показе, виджет не получается фокуса автоматически
}
setAttribute(Qt::WA_TranslucentBackground); // Указываем, что фон будет прозрачным
setAttribute(Qt::WA_ShowWithoutActivating); // При показе, виджет не получается фокуса автоматически

animation.setTargetObject(this); // Устанавливаем целевой объект анимации
animation.setPropertyName("popupOpacity"); // Устанавливаем анимируемое свойство
Expand Down Expand Up @@ -69,7 +77,20 @@ void MarkersPopUp::setName(QString name)

m_settings->endGroup();

setGeometry(m_x,m_y,width(),height());
applyGeometry();
}

void MarkersPopUp::applyGeometry()
{
// m_x/m_y are tracked as global screen coordinates throughout this
// class (mirrors PopUp::applyGeometry() in popup.cpp - see there for
// the full rationale).
if (m_embedded && parentWidget()) {
QPoint local = parentWidget()->mapFromGlobal(QPoint(m_x, m_y));
setGeometry(local.x(), local.y(), width(), height());
} else {
setGeometry(m_x, m_y, width(), height());
}
}

MarkersPopUp::~MarkersPopUp()
Expand Down Expand Up @@ -177,18 +198,31 @@ void MarkersPopUp::show()

void MarkersPopUp::focusShow()
{
//qDebug() << "MarkersPopUp::focusShow()" << m_menuVisible;
QWidget::show();
applyGeometry();
if (!isVisible()) {
QWidget::show();
}
if (m_embedded) {
raise();
}
}

void MarkersPopUp::focusHide()
{
//qDebug() << "MarkersPopUp::focusHide()" << m_menuVisible;
if (m_menuVisible) {
setVisible(true);
return;
}
QWidget::hide();
if (m_embedded) {
// A plain child widget: hiding it does not touch any top-level
// window, so there is no compositor feedback-loop risk here.
QWidget::hide();
return;
}
// Park off-screen instead of QWidget::hide(): see PopUp::focusHide()
// for why unmapping this Qt::Tool surface causes a feedback loop on
// some Wayland compositors.
move(-32000, -32000);
}

void MarkersPopUp::hideAnimation()
Expand Down Expand Up @@ -230,10 +264,7 @@ void MarkersPopUp::mouseMoveEvent(QMouseEvent * )
{
m_x = QCursor::pos().x() - m_biasX;
m_y = QCursor::pos().y() - m_biasY;
setGeometry(m_x,
m_y,
width(),
height());
applyGeometry();
m_mainBiasX = m_x - m_mainX;
m_mainBiasY = m_y - m_mainY;
}
Expand All @@ -245,20 +276,14 @@ void MarkersPopUp::MainWindowPos(int x, int y)

m_x = x + m_mainBiasX;
m_y = y + m_mainBiasY;
setGeometry(m_x,
m_y,
width(),
height());
applyGeometry();
}

void MarkersPopUp::setPosition(int x, int y)
{
m_x = x;
m_y = y;
setGeometry(m_x,
m_y,
width(),
height());
applyGeometry();
}

void MarkersPopUp::setTextColor(QString color)
Expand Down
8 changes: 7 additions & 1 deletion markerspopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MarkersPopUp : public QWidget
float getPopupOpacity() const;

public:
explicit MarkersPopUp(QWidget *parent = 0);
explicit MarkersPopUp(QWidget *parent = 0, bool embedded = false);
~MarkersPopUp();
void setName(QString name);
int getDurability (void) const {return m_durability;}
Expand Down Expand Up @@ -125,6 +125,12 @@ private slots:
int m_parentX;
int m_parentY;

// When true, this MarkersPopUp is a plain child widget of its parent
// rather than a separate Qt::Tool top-level window - see
// markerspopup.cpp for why.
bool m_embedded;
void applyGeometry();

QColor m_bgColor;
QColor m_penColor;
QString m_textColor;
Expand Down
4 changes: 2 additions & 2 deletions measurements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Measurements::Measurements(QObject *parent) : QObject(parent),

if(m_graphHint == NULL)
{
m_graphHint = new PopUp();
m_graphHint = new PopUp(MainWindow::m_mainWindow, true);
m_graphHint->setHiding(false);
m_settings->beginGroup("Settings");
bool darkTheme = m_settings->value("darkColorTheme", true).toBool();
Expand All @@ -116,7 +116,7 @@ Measurements::Measurements(QObject *parent) : QObject(parent),

if(m_graphBriefHint == NULL)
{
m_graphBriefHint = new PopUp();
m_graphBriefHint = new PopUp(MainWindow::m_mainWindow, true);
m_graphBriefHint->setHiding(false);
//m_graphBriefHint->setPopupText("0\n0");
m_graphBriefHint->setName(tr("BriefHint"));
Expand Down
2 changes: 1 addition & 1 deletion measurements.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Measurements : public QObject
qint32 m_farEndMeasurement;
QCPItemEllipse * m_smithTracer;

bool m_focus;
bool m_focus = true;

bool m_oneFqMode = false;
qint64 m_oneFqStartTime;
Expand Down
2 changes: 1 addition & 1 deletion onefqwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OneFqWidget::OneFqWidget(int _points, QWidget *parent) :
setAttribute(Qt::WA_ShowWithoutActivating);

m_label.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
m_label.setStyleSheet("QLabel { color : " + m_textColor.name() +
m_label.setStyleSheet("QLabel { color : " + m_textColor.name() + ";"
"margin-top: 6px;"
"margin-bottom: 6px;"
"margin-left: 10px;"
Expand Down
Loading