Skip to content

Commit 5d8fb7b

Browse files
author
Mich
committed
Added auto-scroll X shut-off after mouse drag event
1 parent 8c47ea7 commit 5d8fb7b

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/mainwindow.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ void MainWindow::createChart()
169169

170170
connect(ui->widgetChart, SIGNAL(mouseDoubleClick(QMouseEvent *)), this, SLOT(on_chartMouseDoubleClickHandler(QMouseEvent *)));
171171
connect(ui->widgetChart, SIGNAL(mousePress(QMouseEvent *)), this, SLOT(on_chartMousePressHandler(QMouseEvent *)));
172+
connect(ui->widgetChart, SIGNAL(mouseMove(QMouseEvent *)), this, SLOT(on_chartMouseMoveHandler(QMouseEvent *)));
173+
172174
connect(ui->widgetChart, SIGNAL(selectionChangedByUser()), this, SLOT(on_chartSelectionChanged()));
173175
connect(ui->widgetChart, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_chartContextMenuRequest(QPoint)));
174176
connect(ui->widgetChart, SIGNAL(beforeReplot()), this, SLOT(on_chartBeforeReplotSlot()));
@@ -755,6 +757,28 @@ void MainWindow::on_chartMousePressHandler(QMouseEvent *event)
755757
ui->widgetChart->replot();
756758
}
757759

760+
void MainWindow::on_chartMouseMoveHandler(QMouseEvent *event)
761+
{
762+
static int distance = 0, lastPos = 0;
763+
764+
if (event->buttons() & Qt::LeftButton)
765+
{
766+
distance += event->pos().x() - lastPos;
767+
lastPos = event->pos().x();
768+
769+
// qDebug() << "distance: " + QString::number(distance);
770+
771+
if (abs(distance) > 200)
772+
{
773+
ui->checkBoxAutoTrack->setChecked(false);
774+
}
775+
}
776+
else
777+
{
778+
distance = 0;
779+
}
780+
}
781+
758782
void MainWindow::on_updateSerialDeviceList()
759783
{
760784
QList<QSerialPortInfo> devices = QSerialPortInfo::availablePorts();

src/mainwindow.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ private slots:
7373
void on_chartBeforeReplotSlot();
7474
void on_chartContextMenuRequest(QPoint pos);
7575
void on_chartMouseDoubleClickHandler(QMouseEvent *event);
76+
void on_chartMouseMoveHandler(QMouseEvent *event);
7677
void on_chartMousePressHandler(QMouseEvent *event);
7778
void on_chartSelectionChanged();
7879
void on_checkBoxAutoLogging_toggled(bool checked);
7980
void on_checkBoxAutoRefresh_toggled(bool checked);
81+
void on_checkBoxAutoSaveBuffer_toggled(bool checked);
8082
void on_checkBoxAutoTrack_toggled(bool checked);
8183
void on_checkBoxEnableTracer_toggled(bool checked);
8284
void on_checkBoxShowLegend_toggled(bool checked);
8385
void on_checkBoxWrapText_toggled(bool checked);
8486
void on_clearGraphSelection();
87+
void on_comboBoxClockSource_currentIndexChanged(int index);
8588
void on_comboBoxGraphDisplayMode_currentIndexChanged(const QString &arg1);
8689
void on_comboBoxLoggingMode_currentIndexChanged(int index);
8790
void on_comboBoxSendReturnPressedSlot();
@@ -135,9 +138,6 @@ private slots:
135138
void on_toolButtonAdvancedGraphMenu_clicked();
136139
void on_tracerShowPointValue(QMouseEvent *event);
137140
void on_updateSerialDeviceList();
138-
void on_checkBoxAutoSaveBuffer_toggled(bool checked);
139-
void on_comboBoxClockSource_currentIndexChanged(int index);
140-
141141
private:
142142
// QCompleter *completer;
143143
FileReader fileReader;

src/mainwindow.ui

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,9 @@ p, li { white-space: pre-wrap; }
26002600
</property>
26012601
</action>
26022602
<action name="actionWhat_s_new">
2603+
<property name="enabled">
2604+
<bool>false</bool>
2605+
</property>
26032606
<property name="text">
26042607
<string>Changelog</string>
26052608
</property>
@@ -2653,7 +2656,7 @@ p, li { white-space: pre-wrap; }
26532656
</action>
26542657
<action name="actionWhats_this">
26552658
<property name="text">
2656-
<string>Enter &quot;What's this ?&quot;</string>
2659+
<string>&quot;What's this ?&quot; Mode</string>
26572660
</property>
26582661
<property name="shortcut">
26592662
<string>F1</string>

0 commit comments

Comments
 (0)